| | |
| | | <!--新增对话框--> |
| | | <el-dialog :visible.sync="addVisible" append-to-body class="avue-dialog avue-dialog--top" title="配置数据统计分析" |
| | | top="-50px"> |
| | | <el-table ref="table" :data="tableData" border style="width: 100%" @selection-change="selectChange"> |
| | | <el-table ref="table" :data="tableData" border style="width: 100%" @selection-change="selectChange" @row-click="rowHandlerClick"> |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column align="center" label="主数据库名" prop="menuName" width="300"></el-table-column> |
| | | <el-table-column align="center" label="类型" prop="codeType"> |
| | |
| | | import pieChart from "../../components/StatisticsComponent/pieChart" |
| | | import ColumnarChart from "../../components/StatisticsComponent/ColumnarChart" |
| | | import mixCart from "../../components/StatisticsComponent/mixCart" |
| | | import {getStatisticAnalysis, getBtmAndChart, saveStatisticAnalysis, deleteChartId} from "@/api/statistic/chart" |
| | | import {getStatisticAnalysis, getBtmAndChart, saveStatisticAnalysis} from "@/api/statistic/chart" |
| | | //配置表单主数据列表接口 |
| | | import {getList} from "@/api/system/statistic"; |
| | | |
| | | export default { |
| | |
| | | async getEcharts() { |
| | | try { |
| | | const firstResponse = await getBtmAndChart(); |
| | | this.ResponseData = await getBtmAndChart(); |
| | | this.loading = false; |
| | | const btmNames = Object.keys(firstResponse.data.data).join(','); |
| | | const btmValue = Object.values(firstResponse.data.data); |
| | | if (!btmNames) { |
| | |
| | | this.pieList = []; |
| | | this.columnarList = []; |
| | | this.mixList = []; |
| | | this.loading = false; |
| | | 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 = []; |
| | | } |
| | | } |
| | | const typeList = { |
| | | '0': 'lineList', |
| | | '1': 'pieList', |
| | | '2': 'columnarList', |
| | | '3': 'mixList' |
| | | }; |
| | | await this.handleStatisticAnalysis(btmNames, firstResponse); |
| | | this.loading = false; |
| | | } catch (error) { |
| | | this.loading = false; |
| | | console.error('Error:', error); |
| | | // console.error('Error:', error); |
| | | } |
| | | }, |
| | | async handleStatisticAnalysis(type, btmNames, firstResponse) { |
| | | async handleStatisticAnalysis(btmNames, firstResponse) { |
| | | const secondResponse = await getStatisticAnalysis({btmNames}); |
| | | const secondData = secondResponse.data.data; |
| | | const typeList = { |
| | |
| | | "2": "columnarList", |
| | | "3": "mixList" |
| | | }; |
| | | this.lineList = []; |
| | | this.pieList = []; |
| | | this.columnarList = []; |
| | | this.mixList = []; |
| | | const firstData = firstResponse.data.data; |
| | | //Object.keys导致对象顺序不一致,使用sort排序与后端返回格式一致 |
| | | Object.keys(firstData).sort().forEach((key, index) => { |
| | |
| | | btmname: key |
| | | }; |
| | | }); |
| | | this[listType] = []; |
| | | this.$nextTick(() => { |
| | | list.forEach((i, j) => { |
| | | if (index === j) { |
| | |
| | | this.$message.warning('请至少选择一条数据!'); |
| | | return; |
| | | } |
| | | let codeStatus = this.selectData.every(key => key.codeType) |
| | | let codeStatus = this.selectData.every(key => key.codeType.length > 0); |
| | | |
| | | if (!codeStatus) { |
| | | this.$message.warning("请检查已勾选数据类型是否为空!"); |
| | | return; |
| | | } |
| | | |
| | | const newArray = this.selectData.map(item => { |
| | | return { |
| | | btmname: item.code, |
| | |
| | | }, |
| | | //表格多选 |
| | | selectChange(selection) { |
| | | console.log('selection', selection) |
| | | this.selectData = selection; |
| | | }, |
| | | rowHandlerClick(row){ |
| | | this.selectData = row; |
| | | this.$refs.table.toggleRowSelection(row); |
| | | } |
| | | } |
| | | } |
| | | |