From d9d4963658d7f39e9bd7fc256012abb453be2ae0 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期四, 21 十二月 2023 11:32:56 +0800 Subject: [PATCH] 统计分析增删改查 --- Source/UBCS-WEB/src/views/statistic/statisticPage.vue | 151 ++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 108 insertions(+), 43 deletions(-) diff --git a/Source/UBCS-WEB/src/views/statistic/statisticPage.vue b/Source/UBCS-WEB/src/views/statistic/statisticPage.vue index ea9146a..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,17 +105,16 @@ columnarList: [], mixList: [], selectData: [], - tableData: [] + tableData: [], + ResponseData: {} } }, created() { - this.getMasterList(); - // deleteChartId({btmname:'zxssaac',chartId:'3'}).then(res=>{ - // console.log('res',res) - // }) + this.loading = true; }, mounted() { this.getEcharts(); + this.getMasterList(); }, methods: { getMasterList() { @@ -116,49 +125,104 @@ this.$message.error(error) }) }, + //鍒楄〃鏁版嵁 async getEcharts() { try { const firstResponse = await getBtmAndChart(); - const typeList = { - "0": "lineList", - "1": "pieList", - "2": "columnarList", - "3": "mixList" - }; - + this.ResponseData = await getBtmAndChart(); + this.loading = false; const btmNames = Object.keys(firstResponse.data.data).join(','); - const firstData = firstResponse.data.data; - if (btmNames) { - const secondResponse = await getStatisticAnalysis({btmNames}); - const secondData = secondResponse.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 type = typeList[indexSec]; - const List = secondData.map(record => { - return { - menuData: record.menuData, - menuName: record.menuName - } - }) - List.forEach((i, j) => { - if (index === j) { - this[type].push(i) - } - }) - } - } - }) + 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() { @@ -183,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) }); -- Gitblit v1.9.3