调整前端代码格式符合ESLint规范

This commit is contained in:
zer0Black
2023-02-28 22:43:03 +08:00
parent f5e5990a3b
commit 77b1ca8f0d
48 changed files with 3199 additions and 3179 deletions
+178 -178
View File
@@ -88,194 +88,194 @@
</template>
<script>
import {v4 as uuidv4} from "uuid";
import { v4 as uuidv4 } from 'uuid'
import vuedraggable from 'vuedraggable'
export default {
name: "Demo",
components: {
vuedraggable
name: 'Demo',
components: {
vuedraggable
},
data () {
return {
option1: {
xAxis: {
type: 'category',
data: []
},
yAxis: {
type: 'value'
},
series: [
{
data: [],
type: 'scatter',
symbolSize: function (data) {
return data[1] / 2.5
}
}
]
},
sortData: [
{ id: uuidv4(), name: 'Mon', value: 150 },
{ id: uuidv4(), name: 'Tue', value: 230 },
{ id: uuidv4(), name: 'Wed', value: 224 },
{ id: uuidv4(), name: 'Thu', value: 218 },
{ id: uuidv4(), name: 'Fri', value: 135 },
{ id: uuidv4(), name: 'Sat', value: 147 },
{ id: uuidv4(), name: 'Sun', value: 260 }
],
week: '',
year_week: '',
startDate: '',
endDate: '',
option: {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line'
}
]
},
max: 0,
value: 0,
q: {
page: 1,
size: 20,
total: 200
},
uuid: uuidv4(),
tableHeader: [
{ field: 'a', title: '2020-01' },
{ field: 'b', title: '2020-02' },
{ field: 'c', title: '2020-03' },
{ field: 'd', title: '2020-04' }
],
treeData: [
{ id: 10000, parentId: null, a: 'Test1', b: '1111', c: '222', d: '3333' },
{ id: 10001, parentId: 10000, a: 'Test1', b: '1111', c: '222', d: '3333' },
{ id: 10002, parentId: 10000, a: 'Test1', b: '1111', c: '222', d: '3333' },
{ id: 10003, parentId: 10000, a: 'Test1', b: '1111', c: '222', d: '3333' },
{ id: 20000, parentId: null, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 20001, parentId: 20000, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 20002, parentId: 20000, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 20003, parentId: 20000, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 20004, parentId: 20000, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 30000, parentId: null, a: 'Test3', b: '1111', c: '222', d: '3333' },
{ id: 30001, parentId: 30000, a: 'Test3', b: '1111', c: '222', d: '3333' },
{ id: 40000, parentId: null, a: 'Test4', b: '1111', c: '222', d: '3333' }
]
}
},
methods: {
handleTree (arr) {
const cloneData = JSON.parse(JSON.stringify(arr)) // 对源数据深度克隆
return cloneData.filter((father) => {
const branchArr = cloneData.filter(child => father.id == child.parentId) // 返回每一项的子级数组
father.children = branchArr.length > 0 ? branchArr : null // 如果存在子级,则给父级添加一个children属性,并赋值
return father.parentId == -1 // 返回第一层
})
},
data() {
return {
option1: {
xAxis: {
type: "category",
data: [],
},
yAxis: {
type: "value",
},
series: [
{
data: [],
type: "scatter",
symbolSize: function (data) {
return data[1] / 2.5;
},
},
],
},
sortData: [
{id: uuidv4(), name: 'Mon', value: 150},
{id: uuidv4(), name: 'Tue', value: 230},
{id: uuidv4(), name: 'Wed', value: 224},
{id: uuidv4(), name: 'Thu', value: 218},
{id: uuidv4(), name: 'Fri', value: 135},
{id: uuidv4(), name: 'Sat', value: 147},
{id: uuidv4(), name: 'Sun', value: 260},
],
week: "",
year_week: "",
startDate: "",
endDate: "",
option: {
xAxis: {
type: "category",
data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
},
yAxis: {
type: "value",
},
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: "line",
},
],
},
max: 0,
value: 0,
q: {
page: 1,
size: 20,
total: 200,
},
uuid: uuidv4(),
tableHeader: [
{ field: 'a', title: '2020-01'},
{ field: 'b', title: '2020-02'},
{ field: 'c', title: '2020-03'},
{ field: 'd', title: '2020-04'},
],
treeData: [
{ id: 10000, parentId: null, a: 'Test1', b: '1111', c: '222', d: '3333' },
{ id: 10001, parentId: 10000, a: 'Test1', b: '1111', c: '222', d: '3333' },
{ id: 10002, parentId: 10000, a: 'Test1', b: '1111', c: '222', d: '3333' },
{ id: 10003, parentId: 10000, a: 'Test1', b: '1111', c: '222', d: '3333' },
{ id: 20000, parentId: null, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 20001, parentId: 20000, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 20002, parentId: 20000, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 20003, parentId: 20000, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 20004, parentId: 20000, a: 'Test2', b: '1111', c: '222', d: '3333' },
{ id: 30000, parentId: null, a: 'Test3', b: '1111', c: '222', d: '3333' },
{ id: 30001, parentId: 30000, a: 'Test3', b: '1111', c: '222', d: '3333' },
{ id: 40000, parentId: null, a: 'Test4', b: '1111', c: '222', d: '3333' },
],
};
handleWeekChange (val) {
const date = `${new Date(val).getFullYear()}-${new Date(val).getMonth() + 1}-${new Date(val).getDate()}`
const firstTime = new Date(date).getTime() - 24 * 60 * 60 * 1000
this.startDate = `${new Date(firstTime).getFullYear()}-${new Date(firstTime).getMonth() + 1}-${new Date(firstTime).getDate()}`
const lastTime = new Date(date).getTime() + 5 * 24 * 60 * 60 * 1000
this.endDate = `${new Date(lastTime).getFullYear()}-${new Date(lastTime).getMonth() + 1}-${new Date(lastTime).getDate()}`
const year = require('moment')(val).utcOffset('+08:00').format('yyyy')
const week = require('moment')(val).utcOffset('+08:00').format('WW')
this.year_week = `${year}${week}`
},
// Api
exFun () {
console.log(require('moment'))
this.$api.ex
.exFun()
.then((res) => {
console.log(res)
})
.catch((err) => {
console.log(err)
})
},
methods: {
handleTree(arr){
let cloneData = JSON.parse(JSON.stringify(arr)) // 对源数据深度克隆
return cloneData.filter((father) => {
let branchArr = cloneData.filter(child => father.id == child.parentId); //返回每一项的子级数组
father.children = branchArr.length > 0 ? branchArr : null; //如果存在子级,则给父级添加一个children属性,并赋值
return father.parentId == -1; //返回第一层
})
},
handleWeekChange(val) {
let date = `${new Date(val).getFullYear()}-${new Date(val).getMonth() + 1}-${new Date(val).getDate()}`;
// vue-echarts
changeOption () {
this.option.series[0].type = 'bar'
},
let firstTime = new Date(date).getTime() - 24 * 60 * 60 * 1000;
this.startDate = `${new Date(firstTime).getFullYear()}-${new Date(firstTime).getMonth() + 1}-${new Date(firstTime).getDate()}`;
let lastTime = new Date(date).getTime() + 5 * 24 * 60 * 60 * 1000;
this.endDate = `${new Date(lastTime).getFullYear()}-${new Date(lastTime).getMonth() + 1}-${new Date(lastTime).getDate()}`;
let year = require("moment")(val).utcOffset("+08:00").format("yyyy");
let week = require("moment")(val).utcOffset("+08:00").format("WW");
this.year_week = `${year}${week}`;
},
// Api
exFun() {
console.log(require("moment"));
this.$api.ex
.exFun()
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
},
// vue-echarts
changeOption() {
this.option.series[0].type = "bar";
},
// el-scrollbar
scrollChange() {
this.max =
// el-scrollbar
scrollChange () {
this.max =
this.$refs.scrollbar.wrap.scrollHeight -
this.$refs.scrollbar.wrap.clientHeight;
this.$refs.scrollbar.wrap.onscroll = (e) => {
this.value = e.target.scrollTop;
};
},
formatTooltip(value) {
this.$refs.scrollbar.wrap.scrollTop = value;
},
this.$refs.scrollbar.wrap.clientHeight
this.$refs.scrollbar.wrap.onscroll = (e) => {
this.value = e.target.scrollTop
}
},
formatTooltip (value) {
this.$refs.scrollbar.wrap.scrollTop = value
},
// VXETable
getTableData() {
this.$nextTick(() => {
const $table = this.$refs.xTable;
const list = [];
for (let index = 0; index < 50; index++) {
list.push({
name: `名称${index}`,
sex: "0",
num: 123,
age: 18,
num2: 234,
rate: 3,
address: "shenzhen",
});
}
$table.loadData(list);
});
},
// VXETable
getTableData () {
this.$nextTick(() => {
const $table = this.$refs.xTable
const list = []
for (let index = 0; index < 50; index++) {
list.push({
name: `名称${index}`,
sex: '0',
num: 123,
age: 18,
num2: 234,
rate: 3,
address: 'shenzhen'
})
}
$table.loadData(list)
})
},
// vuex-persistedstate
saveUserInfo() {
// this.$store.commit("saveUserInfo", {name: "Lee"});
},
},
created() {
console.log("created");
},
mounted() {
this.scrollChange();
this.getTableData();
console.log("mounted");
},
updated(){
// 修改统计顺序
this.option1.xAxis.data = this.sortData.map(item => item.name);
this.option1.series[0].data = this.sortData.map(item => [item.name, item.value]);
},
// 进入组件执行 仅在keep-alive时起作用
activated() {
this.$refs.scrollbar.wrap.scrollTop = this.value;
console.log("activated");
},
// 离开组件执行 仅在keep-alive时起作用
deactivated() {
console.log("deactivated");
},
};
// vuex-persistedstate
saveUserInfo () {
// this.$store.commit("saveUserInfo", {name: "Lee"});
}
},
created () {
console.log('created')
},
mounted () {
this.scrollChange()
this.getTableData()
console.log('mounted')
},
updated () {
// 修改统计顺序
this.option1.xAxis.data = this.sortData.map(item => item.name)
this.option1.series[0].data = this.sortData.map(item => [item.name, item.value])
},
// 进入组件执行 仅在keep-alive时起作用
activated () {
this.$refs.scrollbar.wrap.scrollTop = this.value
console.log('activated')
},
// 离开组件执行 仅在keep-alive时起作用
deactivated () {
console.log('deactivated')
}
}
</script>
<style lang="scss" scoped>
+275 -275
View File
@@ -5,304 +5,304 @@
<script>
import * as echarts from 'echarts/lib/echarts'
import debounce from 'lodash/debounce'
import {addListener, removeListener} from 'resize-detector'
import { addListener, removeListener } from 'resize-detector'
// enumerating ECharts events for now
const EVENTS = [
'legendselectchanged',
'legendselected',
'legendunselected',
'legendscroll',
'datazoom',
'datarangeselected',
'timelinechanged',
'timelineplaychanged',
'restore',
'dataviewchanged',
'magictypechanged',
'geoselectchanged',
'geoselected',
'geounselected',
'pieselectchanged',
'pieselected',
'pieunselected',
'mapselectchanged',
'mapselected',
'mapunselected',
'axisareaselected',
'focusnodeadjacency',
'unfocusnodeadjacency',
'brush',
'brushselected',
'rendered',
'finished',
'click',
'dblclick',
'mouseover',
'mouseout',
'mousemove',
'mousedown',
'mouseup',
'globalout',
'contextmenu'
'legendselectchanged',
'legendselected',
'legendunselected',
'legendscroll',
'datazoom',
'datarangeselected',
'timelinechanged',
'timelineplaychanged',
'restore',
'dataviewchanged',
'magictypechanged',
'geoselectchanged',
'geoselected',
'geounselected',
'pieselectchanged',
'pieselected',
'pieunselected',
'mapselectchanged',
'mapselected',
'mapunselected',
'axisareaselected',
'focusnodeadjacency',
'unfocusnodeadjacency',
'brush',
'brushselected',
'rendered',
'finished',
'click',
'dblclick',
'mouseover',
'mouseout',
'mousemove',
'mousedown',
'mouseup',
'globalout',
'contextmenu'
]
const ZR_EVENTS = [
'click',
'mousedown',
'mouseup',
'mousewheel',
'dblclick',
'contextmenu'
'click',
'mousedown',
'mouseup',
'mousewheel',
'dblclick',
'contextmenu'
]
const INIT_TRIGGERS = ['theme', 'initOptions', 'autoresize']
const REWATCH_TRIGGERS = ['manualUpdate', 'watchShallow']
export default {
props: {
options: Object,
theme: [String, Object],
initOptions: Object,
group: String,
autoresize: Boolean,
watchShallow: Boolean,
manualUpdate: Boolean
props: {
options: Object,
theme: [String, Object],
initOptions: Object,
group: String,
autoresize: Boolean,
watchShallow: Boolean,
manualUpdate: Boolean
},
data () {
return {
lastArea: 0
}
},
watch: {
group (group) {
this.chart.group = group
}
},
methods: {
// provide an explicit merge option method
mergeOptions (options, notMerge, lazyUpdate) {
if (this.manualUpdate) {
this.manualOptions = options
}
if (!this.chart) {
this.init(options)
} else {
this.delegateMethod('setOption', options, notMerge, lazyUpdate)
}
},
data() {
return {
lastArea: 0
}
// just delegates ECharts methods to Vue component
// use explicit params to reduce transpiled size for now
appendData (params) {
this.delegateMethod('appendData', params)
},
watch: {
group(group) {
this.chart.group = group
},
resize (options) {
this.delegateMethod('resize', options)
},
methods: {
// provide an explicit merge option method
mergeOptions(options, notMerge, lazyUpdate) {
if (this.manualUpdate) {
this.manualOptions = options
}
if (!this.chart) {
this.init(options)
} else {
this.delegateMethod('setOption', options, notMerge, lazyUpdate)
}
},
// just delegates ECharts methods to Vue component
// use explicit params to reduce transpiled size for now
appendData(params) {
this.delegateMethod('appendData', params)
},
resize(options) {
this.delegateMethod('resize', options)
},
dispatchAction(payload) {
this.delegateMethod('dispatchAction', payload)
},
convertToPixel(finder, value) {
return this.delegateMethod('convertToPixel', finder, value)
},
convertFromPixel(finder, value) {
return this.delegateMethod('convertFromPixel', finder, value)
},
containPixel(finder, value) {
return this.delegateMethod('containPixel', finder, value)
},
showLoading(type, options) {
this.delegateMethod('showLoading', type, options)
},
hideLoading() {
this.delegateMethod('hideLoading')
},
getDataURL(options) {
return this.delegateMethod('getDataURL', options)
},
getConnectedDataURL(options) {
return this.delegateMethod('getConnectedDataURL', options)
},
clear() {
this.delegateMethod('clear')
},
dispose() {
this.delegateMethod('dispose')
},
delegateMethod(name, ...args) {
if (!this.chart) {
this.init()
}
return this.chart[name](...args)
},
delegateGet(methodName) {
if (!this.chart) {
this.init()
}
return this.chart[methodName]()
},
getArea() {
return this.$el.offsetWidth * this.$el.offsetHeight
},
init(options) {
if (this.chart) {
return
}
let chart = echarts.init(this.$el, this.theme, this.initOptions)
if (this.group) {
chart.group = this.group
}
chart.setOption(options || this.manualOptions || this.options || {}, true)
// expose ECharts events as custom events
EVENTS.forEach(event => {
chart.on(event, params => {
this.$emit(event, params)
})
})
ZR_EVENTS.forEach(event => {
chart.getZr().on(event, params => {
this.$emit(`zr:${event}`, params)
})
})
if (this.autoresize) {
this.lastArea = this.getArea()
this.__resizeHandler = debounce(() => {
if (this.lastArea === 0) {
// emulate initial render for initially hidden charts
this.mergeOptions({}, true)
this.resize()
this.mergeOptions(this.options || this.manualOptions || {}, true)
} else {
this.resize()
}
this.lastArea = this.getArea()
}, 100, {leading: true})
addListener(this.$el, this.__resizeHandler)
}
Object.defineProperties(this, {
// Only recalculated when accessed from JavaScript.
// Won't update DOM on value change because getters
// don't depend on reactive values
width: {
configurable: true,
get: () => {
return this.delegateGet('getWidth')
}
},
height: {
configurable: true,
get: () => {
return this.delegateGet('getHeight')
}
},
isDisposed: {
configurable: true,
get: () => {
return !!this.delegateGet('isDisposed')
}
},
computedOptions: {
configurable: true,
get: () => {
return this.delegateGet('getOption')
}
}
})
this.chart = chart
},
initOptionsWatcher() {
if (this.__unwatchOptions) {
this.__unwatchOptions()
this.__unwatchOptions = null
}
if (!this.manualUpdate) {
this.__unwatchOptions = this.$watch('options', (val, oldVal) => {
if (!this.chart && val) {
this.init()
} else {
// mutating `options` will lead to merging
// replacing it with new reference will lead to not merging
// eg.
// `this.options = Object.assign({}, this.options, { ... })`
// will trigger `this.chart.setOption(val, true)
// `this.options.title.text = 'Trends'`
// will trigger `this.chart.setOption(val, false)`
this.chart.setOption(val, val !== oldVal)
}
}, {deep: !this.watchShallow})
}
},
destroy() {
if (this.autoresize) {
removeListener(this.$el, this.__resizeHandler)
}
this.dispose()
this.chart = null
},
refresh() {
if (this.chart) {
this.destroy()
this.init()
}
}
dispatchAction (payload) {
this.delegateMethod('dispatchAction', payload)
},
created() {
this.initOptionsWatcher()
convertToPixel (finder, value) {
return this.delegateMethod('convertToPixel', finder, value)
},
convertFromPixel (finder, value) {
return this.delegateMethod('convertFromPixel', finder, value)
},
containPixel (finder, value) {
return this.delegateMethod('containPixel', finder, value)
},
showLoading (type, options) {
this.delegateMethod('showLoading', type, options)
},
hideLoading () {
this.delegateMethod('hideLoading')
},
getDataURL (options) {
return this.delegateMethod('getDataURL', options)
},
getConnectedDataURL (options) {
return this.delegateMethod('getConnectedDataURL', options)
},
clear () {
this.delegateMethod('clear')
},
dispose () {
this.delegateMethod('dispose')
},
delegateMethod (name, ...args) {
if (!this.chart) {
this.init()
}
return this.chart[name](...args)
},
delegateGet (methodName) {
if (!this.chart) {
this.init()
}
return this.chart[methodName]()
},
getArea () {
return this.$el.offsetWidth * this.$el.offsetHeight
},
init (options) {
if (this.chart) {
return
}
INIT_TRIGGERS.forEach(prop => {
this.$watch(prop, () => {
this.refresh()
}, {deep: true})
const chart = echarts.init(this.$el, this.theme, this.initOptions)
if (this.group) {
chart.group = this.group
}
chart.setOption(options || this.manualOptions || this.options || {}, true)
// expose ECharts events as custom events
EVENTS.forEach(event => {
chart.on(event, params => {
this.$emit(event, params)
})
})
REWATCH_TRIGGERS.forEach(prop => {
this.$watch(prop, () => {
this.initOptionsWatcher()
this.refresh()
})
ZR_EVENTS.forEach(event => {
chart.getZr().on(event, params => {
this.$emit(`zr:${event}`, params)
})
})
if (this.autoresize) {
this.lastArea = this.getArea()
this.__resizeHandler = debounce(() => {
if (this.lastArea === 0) {
// emulate initial render for initially hidden charts
this.mergeOptions({}, true)
this.resize()
this.mergeOptions(this.options || this.manualOptions || {}, true)
} else {
this.resize()
}
this.lastArea = this.getArea()
}, 100, { leading: true })
addListener(this.$el, this.__resizeHandler)
}
Object.defineProperties(this, {
// Only recalculated when accessed from JavaScript.
// Won't update DOM on value change because getters
// don't depend on reactive values
width: {
configurable: true,
get: () => {
return this.delegateGet('getWidth')
}
},
height: {
configurable: true,
get: () => {
return this.delegateGet('getHeight')
}
},
isDisposed: {
configurable: true,
get: () => {
return !!this.delegateGet('isDisposed')
}
},
computedOptions: {
configurable: true,
get: () => {
return this.delegateGet('getOption')
}
}
})
this.chart = chart
},
mounted() {
// auto init if `options` is already provided
if (this.options) {
initOptionsWatcher () {
if (this.__unwatchOptions) {
this.__unwatchOptions()
this.__unwatchOptions = null
}
if (!this.manualUpdate) {
this.__unwatchOptions = this.$watch('options', (val, oldVal) => {
if (!this.chart && val) {
this.init()
}
} else {
// mutating `options` will lead to merging
// replacing it with new reference will lead to not merging
// eg.
// `this.options = Object.assign({}, this.options, { ... })`
// will trigger `this.chart.setOption(val, true)
// `this.options.title.text = 'Trends'`
// will trigger `this.chart.setOption(val, false)`
this.chart.setOption(val, val !== oldVal)
}
}, { deep: !this.watchShallow })
}
},
activated() {
if (this.autoresize) {
this.chart && this.chart.resize()
}
destroy () {
if (this.autoresize) {
removeListener(this.$el, this.__resizeHandler)
}
this.dispose()
this.chart = null
},
destroyed() {
if (this.chart) {
this.destroy()
}
},
connect(group) {
if (typeof group !== 'string') {
group = group.map(chart => chart.chart)
}
echarts.connect(group)
},
disconnect(group) {
echarts.disConnect(group)
},
registerMap(mapName, geoJSON, specialAreas) {
echarts.registerMap(mapName, geoJSON, specialAreas)
},
registerTheme(name, theme) {
echarts.registerTheme(name, theme)
},
graphic: echarts.graphic
refresh () {
if (this.chart) {
this.destroy()
this.init()
}
}
},
created () {
this.initOptionsWatcher()
INIT_TRIGGERS.forEach(prop => {
this.$watch(prop, () => {
this.refresh()
}, { deep: true })
})
REWATCH_TRIGGERS.forEach(prop => {
this.$watch(prop, () => {
this.initOptionsWatcher()
this.refresh()
})
})
},
mounted () {
// auto init if `options` is already provided
if (this.options) {
this.init()
}
},
activated () {
if (this.autoresize) {
this.chart && this.chart.resize()
}
},
destroyed () {
if (this.chart) {
this.destroy()
}
},
connect (group) {
if (typeof group !== 'string') {
group = group.map(chart => chart.chart)
}
echarts.connect(group)
},
disconnect (group) {
echarts.disConnect(group)
},
registerMap (mapName, geoJSON, specialAreas) {
echarts.registerMap(mapName, geoJSON, specialAreas)
},
registerTheme (name, theme) {
echarts.registerTheme(name, theme)
},
graphic: echarts.graphic
}
</script>
+56 -56
View File
@@ -44,64 +44,64 @@
</template>
<script>
import {mapGetters} from 'vuex';
import {BASE_URL} from "../utils/http";
import { mapGetters } from 'vuex'
import { BASE_URL } from '../utils/http'
export default {
name: "Header",
data() {
return {
popoverValue: false
}
},
computed: {
...mapGetters({
menuData: 'menuData',
}),
isSystemManager() {
return this.menuData.some(menu => menu.id === 'AVL9YSB7ZF');
},
isSystemManagerBelong() {
return this.menuData.some(menu => menu.id === 'AVL9YSB7ZF' && menu.belong == 1);
},
},
methods: {
// 退出系统
logout() {
this.$confirm('确定退出系统?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.login.logout().then(_ => {
this.$message.success('退出成功');
this.$store.commit('saveUserInfo', null);
// var sevice = "http://"+window.location.host+"/";
// var serviceUrl = encodeURIComponent(sevice);
//正式
// window.open("https://caddmuat.changan.com.cn/cas/logout?service=http://10.64.23.30:7766/home", '_self');
//测试
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
this.$router.push('/login');
})
})
},
goSystemPage() {
if(this.isSystemManagerBelong){
if (this.$route.path === '/system/menu') return;
this.$store.commit('savePathUrl', '/system/menu');
this.$router.push({path: '/system/menu', query: {id: 'AVL9YSB7ZF'}});
}else{
if(this.$route.path == '/system/401Page'){
}else{
this.$router.replace({name: '401Page', query: {id: 'AVL9YSB7ZF'}});
}
}
}
}
export default {
name: 'Header',
data () {
return {
popoverValue: false
}
},
computed: {
...mapGetters({
menuData: 'menuData'
}),
isSystemManager () {
return this.menuData.some(menu => menu.id === 'AVL9YSB7ZF')
},
isSystemManagerBelong () {
return this.menuData.some(menu => menu.id === 'AVL9YSB7ZF' && menu.belong == 1)
}
},
methods: {
// 退出系统
logout () {
this.$confirm('确定退出系统?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.login.logout().then(_ => {
this.$message.success('退出成功')
this.$store.commit('saveUserInfo', null)
// var sevice = "http://"+window.location.host+"/";
// var serviceUrl = encodeURIComponent(sevice);
// 正式
// window.open("https://caddmuat.changan.com.cn/cas/logout?service=http://10.64.23.30:7766/home", '_self');
// 测试
// window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self');
this.$router.push('/login')
})
})
},
goSystemPage () {
if (this.isSystemManagerBelong) {
if (this.$route.path === '/system/menu') return
this.$store.commit('savePathUrl', '/system/menu')
this.$router.push({ path: '/system/menu', query: { id: 'AVL9YSB7ZF' } })
} else {
if (this.$route.path == '/system/401Page') {
} else {
this.$router.replace({ name: '401Page', query: { id: 'AVL9YSB7ZF' } })
}
}
}
}
}
</script>
<style lang="scss" scoped>
+45 -46
View File
@@ -44,54 +44,54 @@
</template>
<script>
import {createLogger} from 'vuex';
import MenuItem from "./MenuItem";
import login from '../api/modules/login'
import store from '../store'
export default {
name: "Menu",
props: ["menuData", "path"],
components: {
MenuItem
},
methods: {
handleRouter(item) {
if(item.belong == 0){
this.$store.commit('saveMenuName', item.label);
if(this.$route.path == '/system/401Page'){
import { createLogger } from 'vuex'
import MenuItem from './MenuItem'
import login from '../api/modules/login'
import store from '../store'
export default {
name: 'Menu',
props: ['menuData', 'path'],
components: {
MenuItem
},
methods: {
handleRouter (item) {
if (item.belong == 0) {
this.$store.commit('saveMenuName', item.label)
if (this.$route.path == '/system/401Page') {
}else{
this.$router.push({name: '401Page', query: this.$route.query});
}
}else{
this.$store.commit('savePathUrl', item.href);
if (item.isUrl && Number(item.isUrl || 0)) {
var param = this.$route.query
// delete(this.$route.query.itemHref)
// param.itemHref = item.href
if(this.$route.path == '/system/urlIndex'){
this.$store.commit('saveMenuName', item.label);
login.pageLog(this.$store.state.menuName).then(res => {
}).catch(_ => {
})
}else{
this.$store.commit('saveMenuName', item.label);
this.$router.push({name: 'urlIndex', query: param});
}
} else {
if (this.$route.path === item.href) return;
// delete(this.$route.query.itemHref)
this.$router.push({path: item.href, query: this.$route.query});
}
}
},
collageMenu(item) {
item.isCollage = !item.isCollage;
console.log(item.isCollage);
}
} else {
this.$router.push({ name: '401Page', query: this.$route.query })
}
} else {
this.$store.commit('savePathUrl', item.href)
if (item.isUrl && Number(item.isUrl || 0)) {
const param = this.$route.query
// delete(this.$route.query.itemHref)
// param.itemHref = item.href
if (this.$route.path == '/system/urlIndex') {
this.$store.commit('saveMenuName', item.label)
login.pageLog(this.$store.state.menuName).then(res => {
}).catch(_ => {
})
} else {
this.$store.commit('saveMenuName', item.label)
this.$router.push({ name: 'urlIndex', query: param })
}
} else {
if (this.$route.path === item.href) return
// delete(this.$route.query.itemHref)
this.$router.push({ path: item.href, query: this.$route.query })
}
}
},
collageMenu (item) {
item.isCollage = !item.isCollage
console.log(item.isCollage)
}
}
}
</script>
<style lang="scss" scoped>
@@ -175,7 +175,6 @@
}
}
.icon-level2 {
display: inline-block;
width: 3px;
+2 -2
View File
@@ -4,8 +4,8 @@
<script>
export default {
name: "MenuItem",
props: ['menuItemData']
name: 'MenuItem',
props: ['menuItemData']
}
</script>
+145 -146
View File
@@ -32,152 +32,151 @@
</template>
<script>
export default {
data() {
return {
clicked: '',
options: [],
wordList: [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z'
],
dialogVisible: false
}
},
props: ['callback'],
mounted() {
this.getList()
this.clicked = ''
},
methods: {
changeOpen() {
this.dialogVisible = !this.dialogVisible
},
selectFun(item) {
if (this.callback && item.length == 3) {
this.callback(item)
this.dialogVisible = false
}
},
getList() {
this.options = []
this.$api.config.gradient.chooseStyleAdd().then(res => {
this.options = this.formatDataFirst(res.data)
// Object.keys(res.data).forEach(key => {
// // tag
// let d = {
// value:key,
// label:key
// }
// this.options.push(d)
// // info
// let info = res.data[key]
// Object.keys(info).forEach(newkey => {
// debugger
// let ib = {
// value:newkey,
// label:newkey,
// children:info[newkey]
// }
// this.options.push(ib)
// })
// });
//
})
},
formatDataFirst(data) {
let list = []
Object.keys(data).forEach(key => {
// tag
let d = {
level: 1,
value: key,
label: key
}
list.push(d)
// info
let info = data[key]
Object.keys(info).forEach(newkey => {
let ib = {
level: 1,
value: newkey,
label: newkey,
children: []
}
ib.children = this.formatData(info[newkey])
list.push(ib)
})
});
return list
},
formatData(data) {
let list = []
Object.keys(data).forEach(key => {
let id = data[key]
let d = {
level: 2,
value: key,
label: key,
children: []
}
id.forEach(newdata => {
let ib = {
level: 3,
value: newdata,
label: newdata['kxmc'] + (newdata['msrpw'] ? (" " + newdata['msrpw']) : '') + " " + newdata['mix'],
data: newdata
}
d.children.push(ib)
})
// debugger
list.push(d)
})
return list
},
goIndex(params) {
const groupRef = this.$refs.groupRef.$children[0].$children[0].$refs.resize
const titleRef = this.$refs.groupRef.$children[0].$children[0].$refs.resize.childNodes
this.clicked = params
titleRef.forEach((item) => {
if (item.innerText === params) {
// debugger
groupRef.parentElement.scrollTo({
top: item.offsetTop,
behavior: 'smooth' // 平滑移动
})
}
})
// groupRef.scrollTop = offsetTop
}
}
export default {
data () {
return {
clicked: '',
options: [],
wordList: [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z'
],
dialogVisible: false
}
},
props: ['callback'],
mounted () {
this.getList()
this.clicked = ''
},
methods: {
changeOpen () {
this.dialogVisible = !this.dialogVisible
},
selectFun (item) {
if (this.callback && item.length == 3) {
this.callback(item)
this.dialogVisible = false
}
},
getList () {
this.options = []
this.$api.config.gradient.chooseStyleAdd().then(res => {
this.options = this.formatDataFirst(res.data)
// Object.keys(res.data).forEach(key => {
// // tag
// let d = {
// value:key,
// label:key
// }
// this.options.push(d)
// // info
// let info = res.data[key]
// Object.keys(info).forEach(newkey => {
// debugger
// let ib = {
// value:newkey,
// label:newkey,
// children:info[newkey]
// }
// this.options.push(ib)
// })
// });
//
})
},
formatDataFirst (data) {
const list = []
Object.keys(data).forEach(key => {
// tag
const d = {
level: 1,
value: key,
label: key
}
list.push(d)
// info
const info = data[key]
Object.keys(info).forEach(newkey => {
const ib = {
level: 1,
value: newkey,
label: newkey,
children: []
}
ib.children = this.formatData(info[newkey])
list.push(ib)
})
})
return list
},
formatData (data) {
const list = []
Object.keys(data).forEach(key => {
const id = data[key]
const d = {
level: 2,
value: key,
label: key,
children: []
}
id.forEach(newdata => {
const ib = {
level: 3,
value: newdata,
label: newdata.kxmc + (newdata.msrpw ? (' ' + newdata.msrpw) : '') + ' ' + newdata.mix,
data: newdata
}
d.children.push(ib)
})
// debugger
list.push(d)
})
return list
},
goIndex (params) {
const groupRef = this.$refs.groupRef.$children[0].$children[0].$refs.resize
const titleRef = this.$refs.groupRef.$children[0].$children[0].$refs.resize.childNodes
this.clicked = params
titleRef.forEach((item) => {
if (item.innerText === params) {
// debugger
groupRef.parentElement.scrollTo({
top: item.offsetTop,
behavior: 'smooth' // 平滑移动
})
}
})
// groupRef.scrollTop = offsetTop
}
}
}
</script>
<style lang="scss" scoped>
@@ -253,4 +252,4 @@
height: auto;
line-height: 17px;
}
</style>
</style>