feat:基础组件代码重构

main
liu.shiyi 2 years ago
parent 1115de732c
commit 84a2d76f7f

@ -56,6 +56,9 @@ export default {
}
},
methods: {
changeStyle (config) {
this.getCurrentTime(config.dateFormat)
},
//
getCurrentTime (dateFormat) {
if (this.timer) {

@ -94,10 +94,9 @@ export default {
},
watch: {},
mounted () {
this.chartInit()
},
methods: {
buildOption (config, data) {
dataFormatting (config, data) {
let dataList = ''
if (data.data instanceof Array) {
dataList = config.dataSource.dimensionField
@ -111,14 +110,6 @@ export default {
data: dataList
}
return config
},
updateData () {
this.getCurrentOption().then(({ data, config }) => {
if (data.success) {
const _config = this.buildOption(config, data)
this.config.option.data = _config.option.data
}
})
}
}
}

@ -48,7 +48,11 @@ export default {
},
watch: {},
mounted () {},
methods: {}
methods: {
// changeStyle
changeStyle () {
}
}
}
</script>

@ -42,9 +42,12 @@ export default {
},
watch: {},
mounted () {
this.newUrl = this.replaceUrlVariables(this.config.url)
this.changeStyle()
},
methods: {
changeStyle (config) {
this.newUrl = this.replaceUrlVariables(this.config.url)
},
replaceUrlVariables (url) {
const variableRegex = /\${([A-Za-z0-9_.]+)}/g
const variables = {}

@ -58,17 +58,12 @@ export default {
}
}
},
buildOption (config, data) {
dataFormatting (config, data) {
//
if (config.dataSource.businessKey) {
config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据'
}
return config
},
updateData () {
this.getCurrentOption().then(({ data, config }) => {
this.config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据'
})
}
}
}

@ -50,7 +50,11 @@ export default {
computed: {},
watch: {},
mounted () {},
methods: {}
methods: {
// changeStyle
changeStyle () {
}
}
}
</script>

@ -48,7 +48,7 @@ export default {
this.chartInit()
},
methods: {
buildOption (config, data) {
dataFormatting (config, data) {
const header = []
const dataList = []
const alignList = []
@ -105,13 +105,6 @@ export default {
align: [...alignList]
}
return config
},
updateData () {
this.getCurrentOption().then(({ data, config }) => {
const _config = this.buildOption(config, data)
this.option.data = _config.option.data
this.updateKey++
})
}
}

@ -47,10 +47,9 @@ export default {
watch: {
},
mounted () {
this.chartInit()
},
methods: {
buildOption (config, data) {
dataFormatting (config, data) {
const dataSourseList = []
data.data.forEach(item => {
dataSourseList.push({ name: item[config.dataSource.dimensionField || 'name'], value: item[config.dataSource.metricField || 'sum(num)'] })
@ -60,13 +59,6 @@ export default {
data: dataSourseList
}
return config
},
updateData () {
this.getCurrentOption().then(({ data, config }) => {
const _config = this.buildOption(config, data)
this.option.data = _config.option.data
this.updateKey++
})
}
}

@ -14,6 +14,7 @@
:header-cell-style="headerCellStyle"
:cell-style="cellStyle"
:row-class-name="tableRowClassName"
@row-click="rowClick"
>
<el-table-column
v-for="(col, index) in config.option.columnData"
@ -112,6 +113,10 @@ export default {
this.initStyle()
},
methods: {
//
rowClick (row) {
this.linkage(row)
},
initStyle () {
if (this.customTheme === 'custom') {
this.headerCellStyleToObj()
@ -174,7 +179,7 @@ export default {
tableRowClassName ({ row, rowIndex }) {
return rowIndex % 2 === 0 ? `even-row${this.config.code}` : `odd-row${this.config.code}`
},
buildOption (config, data) {
dataFormatting (config, data) {
config.option.tableData = data?.data
const filteredData = {}
const columnData = data?.columnData || {}
@ -192,16 +197,6 @@ export default {
}
return config
},
//
updateData () {
this.getCurrentOption().then(({ data, config }) => {
if (data.success) {
this.config.option.tableData = data?.data
this.config.option.columnData = data?.columnData || {}
this.$refs.table.doLayout()
}
})
},
// ,
headerCellStyleToObj () {
const str = this.themeJson.themeCss

@ -36,18 +36,12 @@ export default {
this.chartInit()
},
methods: {
buildOption (config, data) {
dataFormatting (config, data) {
//
if (config.dataSource.businessKey) {
config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据'
}
return config
},
//
updateData () {
this.getCurrentOption().then(({ data, config }) => {
this.config.customize.title = data && data.data && data.data.length ? data.data[0][config.dataSource.metricField] : '暂无数据'
})
}
}
}

@ -83,10 +83,7 @@ export default {
}
},
mounted () {
this.config.endTime = this.config.endTime
? new Date(this.config.endTime).getTime()
: new Date().getTime() + 3 * 3600 * 1000 * 24 - 1000
this.getTime()
this.changeStyle()
},
//
destroyed () {
@ -96,6 +93,12 @@ export default {
},
methods: {
changeStyle (config) {
this.config.endTime = this.config.endTime
? new Date(this.config.endTime).getTime()
: new Date().getTime() + 3 * 3600 * 1000 * 24 - 1000
this.getTime()
},
getTime () {
if (this.timer) {
clearInterval(this.timer)

@ -48,7 +48,11 @@ export default {
},
watch: {},
mounted () {},
methods: {}
methods: {
// changeStyle
changeStyle () {
}
}
}
</script>

@ -77,7 +77,11 @@ export default {
watch: {},
mounted () {},
methods: {}
methods: {
// changeStyle
changeStyle () {
}
}
}
</script>

@ -24,7 +24,7 @@ export default {
}
},
mounted () {
if (!['digitalFlop', 'screenScrollRanking', 'screenScrollBoard', 'tables'].includes(this.config.type)) {
if (!['tables'].includes(this.config.type)) {
this.chartInit()
}
this.watchCacheData()

Loading…
Cancel
Save