| | |
| | | <el-table-column |
| | | align="center" |
| | | label="主数据库名" |
| | | prop="menuName"> |
| | | prop="menuName" |
| | | width="300"> |
| | | </el-table-column> |
| | | <el-table-column |
| | | align="center" |
| | | label="类型" |
| | | prop="codeType"> |
| | | <template slot-scope="{ row }"> |
| | | <el-select v-model="row.codeType" placeholder="请选择图表类型"> |
| | | <el-option label="折线图" value="0"></el-option> |
| | | <el-option label="饼状图" value="1"></el-option> |
| | | <el-option label="柱状图" value="2"></el-option> |
| | | <el-option label="堆叠折线图" value="3"></el-option> |
| | | <el-select v-model="row.codeType" :multiple="true" limit="4" placeholder="请选择图表类型" style="width: 400px"> |
| | | <el-option v-for="(item) in selectList" :label="item.label" :value="item.value"></el-option> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | import pieChart from "../../components/StatisticsComponent/pieChart" |
| | | import ColumnarChart from "../../components/StatisticsComponent/ColumnarChart" |
| | | import mixCart from "../../components/StatisticsComponent/mixCart" |
| | | import {getStatisticAnalysis} from "@/api/statistic/chart" |
| | | import {getStatisticAnalysis,getBtmAndChart,saveStatisticAnalysis} from "@/api/statistic/chart" |
| | | import {getList} from "@/api/system/statistic"; |
| | | |
| | | export default { |
| | |
| | | name: "statisticPage", |
| | | data() { |
| | | return { |
| | | selectValue: '', |
| | | selectList: [ |
| | | { |
| | | label: '折线图', |
| | | value: '0' |
| | | }, |
| | | { |
| | | label: '饼状图', |
| | | value: '1' |
| | | }, |
| | | { |
| | | label: '柱状图', |
| | | value: '2' |
| | | }, |
| | | { |
| | | label: '堆叠折线图', |
| | | value: '3' |
| | | } |
| | | ], |
| | | menuList: [], |
| | | dataKeyList: [], |
| | | addVisible: false, |
| | |
| | | } |
| | | }, |
| | | created() { |
| | | this.getMasterList() |
| | | this.getMasterList(); |
| | | this.getEcharts() |
| | | }, |
| | | methods: { |
| | | getMasterList() { |
| | | const userId = localStorage.getItem('userId'); |
| | | getList({userId: userId}).then(res => { |
| | | this.tableData = res.data.data; |
| | | }).catch(error=>{ |
| | | this.$message.error(error) |
| | | }) |
| | | }, |
| | | getEcharts(){ |
| | | getBtmAndChart().then(res=>{ |
| | | const btmNames = Object.keys(res.data.data).join(','); |
| | | console.log(btmNames); |
| | | if(btmNames){ |
| | | getStatisticAnalysis({btmNames}).then(item=>{ |
| | | console.log(item) |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | //新增 |
| | |
| | | this.addVisible = false; |
| | | }, |
| | | //保存 |
| | | addSaveHandler() { |
| | | async addSaveHandler() { |
| | | if (this.selectData.length <= 0) { |
| | | this.$message.warning('请至少选择一条数据!'); |
| | | return; |
| | |
| | | return; |
| | | } |
| | | |
| | | this.dataKeyList = this.selectData.map(obj => obj.code) |
| | | const btmName = this.dataKeyList.join(","); |
| | | if (btmName) { |
| | | getStatisticAnalysis({btmNames: btmName}).then(res => { |
| | | const newArray = this.selectData.map(item => { |
| | | return { |
| | | btmname: item.code, |
| | | chartIds: item.codeType.join(',') |
| | | } |
| | | }) |
| | | saveStatisticAnalysis(newArray).then(res => { |
| | | this.menuList = res.data.data; |
| | | this.nextSave(); |
| | | this.$message.success('保存成功') |
| | | }).catch(error=>{ |
| | | this.$message.error(error) |
| | | }); |
| | | } else { |
| | | this.$message.warning('请选择数据!') |
| | | } |
| | | }, |
| | | nextSave() { |
| | | const typeList = { |
| | |
| | | const dataKey = typeList[item.codeType]; |
| | | if (dataKey) { |
| | | this[dataKey].push(item); |
| | | this[dataKey].forEach(res=>{ |
| | | console.log('this[dataKey]',this[dataKey]) |
| | | console.log('res',res) |
| | | this[dataKey].forEach(res => { |
| | | }) |
| | | hasValidData = true; |
| | | } |