| | |
| | | <template> |
| | | <basic-container> |
| | | <v-chart id="chart" :auto-resize="true" :options="chartOptions"></v-chart> |
| | | <div style="display: inline-block;float: right;margin-bottom: 10px;margin-right: 60px"> |
| | | <el-button size="small" type="primary" plain @click="delHandler">删除</el-button> |
| | | </div> |
| | | </basic-container> |
| | | </template> |
| | | |
| | |
| | | import 'echarts/lib/component/tooltip' |
| | | import 'echarts/lib/component/title' |
| | | import 'echarts/lib/component/legend' |
| | | import {deleteChartId} from "@/api/statistic/chart" |
| | | |
| | | export default { |
| | | name: "ColumnarChart", |
| | |
| | | chartName:{ |
| | | type:String, |
| | | default: "" |
| | | }, |
| | | btmname :{ |
| | | type: String |
| | | } |
| | | }, |
| | | watch:{ |
| | |
| | | }, |
| | | created() { |
| | | }, |
| | | methods:{ |
| | | delHandler(){ |
| | | deleteChartId({btmname:this.btmname,chartId:'2'}).then(res=>{ |
| | | this.$message.success('删除成功') |
| | | this.$emit('refresh'); |
| | | }).catch(error=>{ |
| | | this.$message.error(error) |
| | | }) |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | |
| | | <template> |
| | | <div id="main"> |
| | | <div id="main" style="height: 460px;margin-bottom: 15px"> |
| | | <basic-container> |
| | | <v-chart id="chart" :auto-resize="true" :options="chartOptions"></v-chart> |
| | | <div style="display: inline-block;float: right;margin-bottom: 10px;margin-right: 60px"> |
| | | <el-button size="small" type="primary" plain @click="delHandler">删除</el-button> |
| | | </div> |
| | | </basic-container> |
| | | </div> |
| | | </template> |
| | |
| | | import 'echarts/lib/component/tooltip' |
| | | import 'echarts/lib/component/title' |
| | | import 'echarts/lib/component/legend' |
| | | import {deleteChartId} from "@/api/statistic/chart" |
| | | |
| | | export default { |
| | | name: "lineChart", |
| | |
| | | chartName: { |
| | | type: String, |
| | | default: "" |
| | | }, |
| | | btmname :{ |
| | | type: String |
| | | } |
| | | }, |
| | | watch: { |
| | |
| | | }, |
| | | immediate: true, |
| | | deep: true |
| | | } |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | } |
| | | }; |
| | | }, |
| | | created() { |
| | | methods:{ |
| | | delHandler(){ |
| | | deleteChartId({btmname:this.btmname,chartId:'0'}).then(res=>{ |
| | | this.$message.success('删除成功') |
| | | this.$emit('refresh'); |
| | | }).catch(error=>{ |
| | | this.$message.error(error) |
| | | }) |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | |
| | | width: 100%; |
| | | height: 400px; |
| | | } |
| | | |
| | | </style> |
| | |
| | | <template> |
| | | <basic-container> |
| | | <v-chart id="chart" :auto-resize="true" :options="chartOptions"></v-chart> |
| | | <div style="display: inline-block;float: right;margin-bottom: 10px;margin-right: 60px"> |
| | | <el-button size="small" type="primary" plain @click="delHandler">删除</el-button> |
| | | </div> |
| | | </basic-container> |
| | | </template> |
| | | |
| | |
| | | import 'echarts/lib/component/tooltip' |
| | | import 'echarts/lib/component/title' |
| | | import 'echarts/lib/component/legend' |
| | | import {deleteChartId} from "@/api/statistic/chart" |
| | | |
| | | export default { |
| | | name: "stackedAreaChart", |
| | |
| | | chartName: { |
| | | type: String, |
| | | default: "" |
| | | }, |
| | | btmname :{ |
| | | type: String |
| | | } |
| | | }, |
| | | data() { |
| | |
| | | immediate: true, |
| | | deep: true |
| | | } |
| | | }, |
| | | methods:{ |
| | | delHandler(){ |
| | | deleteChartId({btmname:this.btmname,chartId:'3'}).then(res=>{ |
| | | this.$message.success('删除成功') |
| | | this.$emit('refresh'); |
| | | }).catch(error=>{ |
| | | this.$message.error(error) |
| | | }) |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | |
| | | <template> |
| | | <basic-container style="width: 100%"> |
| | | <v-chart :options="chartOptions" :auto-resize="true" id="chart"></v-chart> |
| | | <div style="display: inline-block;float: right;margin-bottom: 10px;margin-right: 60px"> |
| | | <el-button size="small" type="primary" plain @click="delHandler">删除</el-button> |
| | | </div> |
| | | </basic-container> |
| | | </template> |
| | | |
| | |
| | | import 'echarts/lib/chart/bar' // 导入柱状图组件 |
| | | import 'echarts/lib/component/tooltip' |
| | | import 'echarts/lib/component/legend' |
| | | import {deleteChartId} from "@/api/statistic/chart" |
| | | export default { |
| | | name: "polarBarChart", |
| | | props:{ |
| | |
| | | monthData:{ |
| | | type:Array, |
| | | default: () => ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'] |
| | | }, |
| | | btmname :{ |
| | | type: String |
| | | } |
| | | }, |
| | | watch:{ |
| | |
| | | }, |
| | | created(){ |
| | | this.chartOptions.color = ['#5470c6', '#91cc75', '#fac858', '#ca8622', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4']; |
| | | }, |
| | | methods:{ |
| | | delHandler(){ |
| | | deleteChartId({btmname:this.btmname,chartId:'1'}).then(res=>{ |
| | | this.$message.success('删除成功') |
| | | this.$emit('refresh'); |
| | | }).catch(error=>{ |
| | | this.$message.error(error) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | |
| | | <template> |
| | | <!-- 新增右侧按钮--> |
| | | <div> |
| | | <div v-loading="loading"> |
| | | <div style=" display: flex; justify-content: flex-end;"> |
| | | <el-button plain type="primary" @click="addHandler">配置</el-button> |
| | | </div> |
| | |
| | | <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> |
| | |
| | | name: "statisticPage", |
| | | data() { |
| | | return { |
| | | loading: false, |
| | | selectValue: '', |
| | | selectList: [ |
| | | { |
| | |
| | | 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() { |
| | |
| | | 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() { |
| | |
| | | } |
| | | }) |
| | | 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) |
| | | }); |