mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-28 03:09:24 +08:00
组件之间数据渲染逻辑
This commit is contained in:
@@ -49,23 +49,23 @@ export default {
|
||||
type: Object,
|
||||
default: () => ({}), // 默认空对象
|
||||
required: false // 非必须
|
||||
},
|
||||
tableData: {
|
||||
type: Array,
|
||||
default: () => ([]), // 默认空对象
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
paramsDate: {},
|
||||
tableData: [],
|
||||
tableOption: {
|
||||
scroll: {
|
||||
x: 1500
|
||||
}
|
||||
},
|
||||
select: false,
|
||||
},
|
||||
tableH: 0,
|
||||
pageOption: {
|
||||
current: 1,
|
||||
pageSize: 15,
|
||||
total: 1
|
||||
},
|
||||
|
||||
// chartOptions: [
|
||||
// {
|
||||
// title: '充放电分析',
|
||||
@@ -233,45 +233,24 @@ export default {
|
||||
chartInstances: [] // 存储 ECharts 实例
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
chartData: {
|
||||
handler(n) {
|
||||
this.$nextTick(() => {
|
||||
this.initCharts()
|
||||
window.addEventListener('resize', this.handleResize)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
// 确保 DOM 完全渲染
|
||||
this.initCharts()
|
||||
window.addEventListener('resize', this.handleResize)
|
||||
})
|
||||
|
||||
},
|
||||
beforeUnmount() {
|
||||
window.removeEventListener('resize', this.handleResize)
|
||||
this.chartInstances.forEach((chart) => chart && chart.dispose())
|
||||
},
|
||||
methods: {
|
||||
async getList() {
|
||||
let that = this
|
||||
this.$refs.comTable.loading = true
|
||||
const query = {
|
||||
...this.paramsDate,
|
||||
pageSize: this.pageOption.pageSize,
|
||||
pageNumber: this.pageOption.current
|
||||
}
|
||||
try {
|
||||
const res = await postReq(query, this.tableInfo.getUrl)
|
||||
if (res.code === 200) {
|
||||
this.$refs.comTable.loading = false
|
||||
this.tableData = res.data.records
|
||||
this.pageOption = {
|
||||
current: res.data.pageNumber,
|
||||
pageSize: res.data.pageSize,
|
||||
total: res.data.totalRow
|
||||
}
|
||||
this.getScrollDateFail = false
|
||||
} else {
|
||||
throw res
|
||||
}
|
||||
} catch (error) {
|
||||
that.tableData = []
|
||||
that.$refs.comTable.loading = false
|
||||
}
|
||||
},
|
||||
initCharts() {
|
||||
this.chartOptions.forEach((option, index) => {
|
||||
const dom = this.$refs[`chartContainer${index}`][0]
|
||||
@@ -380,9 +359,10 @@ export default {
|
||||
},
|
||||
|
||||
handlePagesizeChange(pageOption) {
|
||||
this.pageOption.pageSize = pageOption.pageSize
|
||||
this.pageOption.current = pageOption.current
|
||||
this.getList()
|
||||
this.$emit('pagesizeChange_energy',pageOption)
|
||||
// this.pageOption.pageSize = pageOption.pageSize
|
||||
// this.pageOption.current = pageOption.current
|
||||
// this.getList()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,7 +370,7 @@ export default {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
height: calc(100% - 38px);
|
||||
height: calc(100% - 10px);
|
||||
overflow: scroll;
|
||||
}
|
||||
.content-echarts {
|
||||
|
||||
Reference in New Issue
Block a user