From ec3add985f600fe56a7232484bbe89a11b73c23b Mon Sep 17 00:00:00 2001 From: wanghong <309858992@qq.com> Date: 星期四, 21 十二月 2023 12:25:50 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS-WEB/src/views/statistic/statisticPage.vue | 144 +++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 117 insertions(+), 27 deletions(-) diff --git a/Source/UBCS-WEB/src/views/statistic/statisticPage.vue b/Source/UBCS-WEB/src/views/statistic/statisticPage.vue index 0369f5c..cf657d2 100644 --- a/Source/UBCS-WEB/src/views/statistic/statisticPage.vue +++ b/Source/UBCS-WEB/src/views/statistic/statisticPage.vue @@ -1,6 +1,6 @@ <template> <!-- 鏂板鍙充晶鎸夐挳--> - <div> + <div v-loading="loading"> <div style=" display: flex; justify-content: flex-end;"> <el-button plain type="primary" @click="addHandler">閰嶇疆</el-button> </div> @@ -28,23 +28,32 @@ <lineChart v-for="(item,index) in lineList" :key="index" + :btmname="item.btmname" :chartName="item.menuName" - :lineData="item.menuData"></lineChart> + :lineData="item.menuData" + @refresh="getEcharts"> + </lineChart> <pieChart v-for="(item,index) in pieList" :key="index" + :btmname="item.btmname" :chartName="item.menuName" - :pieData="item.menuData"></pieChart> + :pieData="item.menuData" + @refresh="getEcharts"></pieChart> <ColumnarChart v-for="(item,index) in columnarList" :key="index" + :btmname="item.btmname" :chartName="item.menuName" - :columnarData="item.menuData"></ColumnarChart> + :columnarData="item.menuData" + @refresh="getEcharts"></ColumnarChart> <mixCart v-for="(item,index) in mixList" :key="index" + :btmname="item.btmname" :chartName="item.menuName" - :mixData="item.menuData"></mixCart> + :mixData="item.menuData" + @refresh="getEcharts"></mixCart> </div> </div> </template> @@ -67,6 +76,7 @@ name: "statisticPage", data() { return { + loading: false, selectValue: '', selectList: [ { @@ -95,15 +105,16 @@ columnarList: [], mixList: [], selectData: [], - tableData: [] + tableData: [], + ResponseData: {} } }, created() { - this.getMasterList(); + this.loading = true; + }, + mounted() { this.getEcharts(); - // deleteChartId({btmname:'zxssaac',chartId:'3'}).then(res=>{ - // console.log('res',res) - // }) + this.getMasterList(); }, methods: { getMasterList() { @@ -114,25 +125,104 @@ this.$message.error(error) }) }, - getEcharts() { - getBtmAndChart().then(firstResponse => { - console.log('btm', firstResponse) + //鍒楄〃鏁版嵁 + async getEcharts() { + try { + const firstResponse = await getBtmAndChart(); + this.ResponseData = await getBtmAndChart(); + this.loading = false; const btmNames = Object.keys(firstResponse.data.data).join(','); - const firstData = firstResponse.data.data; - Object.keys(firstData).forEach((item,index) => { - let firstIndex = firstData[item].split(','); - console.log('firstIndex',firstIndex); - }); - if (btmNames) { - getStatisticAnalysis({btmNames}).then(secondResponse => { - console.log('getStatisticAnalysis', secondResponse) - }) + const btmValue = Object.values(firstResponse.data.data); + if (!btmNames) { + this.lineList = []; + this.pieList = []; + this.columnarList = []; + this.mixList = []; + return; } - }) + for (const value of btmValue) { + if (value.includes('0')) { + await this.handleStatisticAnalysis('lineList', btmNames, firstResponse); + } else { + this.lineList = []; + } + if (value.includes('1')) { + await this.handleStatisticAnalysis('pieList', btmNames, firstResponse); + } else { + this.pieList = []; + } + if (value.includes('2')) { + await this.handleStatisticAnalysis('columnarList', btmNames, firstResponse); + } else { + this.columnarList = []; + } + if (value.includes('3')) { + await this.handleStatisticAnalysis('mixList', btmNames, firstResponse); + } else { + this.mixList = []; + } + } + } catch (error) { + this.loading = false; + console.error('Error:', error); + } + }, + async handleStatisticAnalysis(type, btmNames, firstResponse) { + const secondResponse = await getStatisticAnalysis({btmNames}); + const secondData = secondResponse.data.data; + const typeList = { + "0": "lineList", + "1": "pieList", + "2": "columnarList", + "3": "mixList" + }; + const firstData = firstResponse.data.data; + //Object.keys瀵艰嚧瀵硅薄椤哄簭涓嶄竴鑷达紝浣跨敤sort鎺掑簭涓庡悗绔繑鍥炴牸寮忎竴鑷� + Object.keys(firstData).sort().forEach((key, index) => { + if (firstData[key]) { + const indexes = firstData[key].split(','); + for (const indexSec of indexes) { + const listType = typeList[indexSec]; + const list = secondData.map(record => { + return { + menuData: record.menuData, + menuName: record.menuName, + btmname: key + }; + }); + this[listType] = []; + this.$nextTick(() => { + list.forEach((i, j) => { + if (index === j) { + this[listType].push(i); + } + }); + }); + } + } + }); }, //鏂板 addHandler() { this.addVisible = true; + // let checkedrow = [] + // this.tableData.forEach(item => { + // // item.codeType = []; + // Object.keys(this.ResponseData.data.data).forEach(k => { + // if (item.code === k) { + // Object.values(this.ResponseData.data.data).forEach(v => { + // // item.codeType.push(v); + // checkedrow.push(item) + // }) + // } + // }) + // }) + // this.$nextTick(() => { + // checkedrow.forEach(row => { + // // console.log(row) + // this.$refs.table.toggleRowSelection(row, true) // 鍥炴樉 + // }) + // }) }, //鍙栨秷 escHandler() { @@ -157,9 +247,10 @@ } }) saveStatisticAnalysis(newArray).then(res => { - this.menuList = res.data.data; - this.nextSave(); + // this.menuList = res.data.data; + this.getEcharts(); this.$message.success('淇濆瓨鎴愬姛') + this.addVisible = false; }).catch(error => { this.$message.error(error) }); @@ -179,8 +270,6 @@ const dataKey = typeList[item.codeType]; if (dataKey) { this[dataKey].push(item); - this[dataKey].forEach(res => { - }) hasValidData = true; } }); @@ -192,6 +281,7 @@ }, //琛ㄦ牸澶氶�� selectChange(selection) { + console.log('selection', selection) this.selectData = selection; }, } -- Gitblit v1.9.3