| | |
| | | <!-- 新增右侧按钮--> |
| | | <div> |
| | | <div style=" display: flex; justify-content: flex-end;"> |
| | | <el-button plain type="primary" @click="addHandler">新增</el-button> |
| | | <el-button plain type="primary" @click="addHandler">配置</el-button> |
| | | </div> |
| | | <!-- 新增对话框--> |
| | | <el-dialog |
| | | :visible.sync="addVisible" |
| | | append-to-body |
| | | class="avue-dialog avue-dialog--top" |
| | | title="新增数据统计分析" |
| | | top="-50px" |
| | | > |
| | | <el-table |
| | | :data="tableData" |
| | | border |
| | | style="width: 100%" |
| | | @selection-change="selectChange" |
| | | > |
| | | <el-table-column |
| | | type="selection" |
| | | width="55"> |
| | | </el-table-column> |
| | | <el-table-column |
| | | align="center" |
| | | label="主数据库名" |
| | | prop="menuName"> |
| | | </el-table-column> |
| | | <el-table-column |
| | | align="center" |
| | | label="类型" |
| | | prop="codeType"> |
| | | <!--新增对话框--> |
| | | <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-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"> |
| | | <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> |
| | |
| | | <el-button type="primary" @click="addSaveHandler">保存</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | <!-- echarts组件--> |
| | | <div> |
| | | <lineChart v-for="(item,index) in lineList" :key="index" :chartName="item.menuName" |
| | | :lineData="item.menuData"></lineChart> |
| | | <pieChart v-for="(item,index) in pieList" :key="index" :chartName="item.menuName" |
| | | :pieData="item.menuData"></pieChart> |
| | | <ColumnarChart v-for="(item,index) in columnarList" :key="index" :chartName="item.menuName" |
| | | :columnarData="item.menuData"></ColumnarChart> |
| | | <mixCart v-for="(item,index) in mixList" :key="index" :chartName="item.menuName" |
| | | :mixData="item.menuData"></mixCart> |
| | | <!--echarts组件--> |
| | | <div style="margin-top: 15px;padding-bottom: 35px"> |
| | | <lineChart |
| | | v-for="(item,index) in lineList" |
| | | :key="index" |
| | | :chartName="item.menuName" |
| | | :lineData="item.menuData"></lineChart> |
| | | <pieChart |
| | | v-for="(item,index) in pieList" |
| | | :key="index" |
| | | :chartName="item.menuName" |
| | | :pieData="item.menuData"></pieChart> |
| | | <ColumnarChart |
| | | v-for="(item,index) in columnarList" |
| | | :key="index" |
| | | :chartName="item.menuName" |
| | | :columnarData="item.menuData"></ColumnarChart> |
| | | <mixCart |
| | | v-for="(item,index) in mixList" |
| | | :key="index" |
| | | :chartName="item.menuName" |
| | | :mixData="item.menuData"></mixCart> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | 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 {getList} from "@/api/system/statistic"; |
| | | |
| | | export default { |
| | | components: { |
| | |
| | | name: "statisticPage", |
| | | data() { |
| | | return { |
| | | selectValue: '', |
| | | selectList: [ |
| | | { |
| | | label: '折线图', |
| | | value: '0' |
| | | }, |
| | | { |
| | | label: '饼状图', |
| | | value: '1' |
| | | }, |
| | | { |
| | | label: '柱状图', |
| | | value: '2' |
| | | }, |
| | | { |
| | | label: '堆叠折线图', |
| | | value: '3' |
| | | } |
| | | ], |
| | | menuList: [], |
| | | dataKeyList: [], |
| | | addVisible: false, |
| | | chartName: "", |
| | | lineList: [], |
| | |
| | | columnarList: [], |
| | | mixList: [], |
| | | selectData: [], |
| | | tableData: [ |
| | | { |
| | | menuName: "工艺文件", |
| | | codeType: "1", |
| | | menuData: [ |
| | | [222, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "测试sc", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "产品型号", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "固定资产", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "李航主数据", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "Part", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "人员主数据", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "人员", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "标准", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "物品主数据", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | }, |
| | | { |
| | | menuName: "型号", |
| | | codeType: null, |
| | | menuData: [ |
| | | [220, 232, 301, 334, 290, 330, 410, 330, 212, 322, 200, 234], |
| | | [120, 132, 101, 134, 90, 230, 210, 130, 10, 122, 100, 80], |
| | | ] |
| | | } |
| | | ] |
| | | tableData: [] |
| | | } |
| | | }, |
| | | created() { |
| | | this.getMasterList(); |
| | | this.getEcharts(); |
| | | // deleteChartId({btmname:'zxssaac',chartId:'3'}).then(res=>{ |
| | | // console.log('res',res) |
| | | // }) |
| | | }, |
| | | 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(firstResponse => { |
| | | console.log('btm', firstResponse) |
| | | 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) |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | //新增 |
| | | addHandler() { |
| | | this.addVisible = true; |
| | |
| | | this.addVisible = false; |
| | | }, |
| | | //保存 |
| | | addSaveHandler() { |
| | | async addSaveHandler() { |
| | | if (this.selectData.length <= 0) { |
| | | this.$message.warning('请至少选择一条数据!'); |
| | | return; |
| | | } |
| | | let codeStatus = this.selectData.every(key => key.codeType) |
| | | if (!codeStatus) { |
| | | this.$message.warning("请检查已勾选数据类型是否为空!"); |
| | | return; |
| | | } |
| | | |
| | | 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) |
| | | }); |
| | | }, |
| | | nextSave() { |
| | | const typeList = { |
| | | "0": "lineList", |
| | | "1": "pieList", |
| | |
| | | }; |
| | | |
| | | let hasValidData = false; // 添加一个标志来记录是否有有效的选择数据 |
| | | let codeStatus = this.selectData.every(key => key.codeType) |
| | | if (!codeStatus) { |
| | | this.$message.warning("请检查已勾选数据类型是否为空!"); |
| | | return; |
| | | } |
| | | this.selectData.forEach(item => { |
| | | |
| | | this.selectData.forEach((item, index) => { |
| | | item.menuData = this.menuList[index].menuData; |
| | | const dataKey = typeList[item.codeType]; |
| | | if (dataKey) { |
| | | this[dataKey].push(item); |
| | | hasValidData = true; // 标记有有效数据被添加 |
| | | this[dataKey].forEach(res => { |
| | | }) |
| | | hasValidData = true; |
| | | } |
| | | }); |
| | | |
| | | if (hasValidData) { |
| | | // this.$refs.table.clearSelection(); |
| | | this.addVisible = false; |
| | | } |
| | | }, |
| | | //表格多选 |
| | | selectChange(selection, row) { |
| | | // console.log(selection, row) |
| | | selectChange(selection) { |
| | | this.selectData = selection; |
| | | }, |
| | | } |
| | | } |
| | | |
| | | </script> |
| | | |
| | | <style scoped> |
| | | <style lang="scss" scoped> |
| | | |
| | | </style> |