ludc
2023-12-05 25ef4e85586c27433c865b69c67ccf5a380b93a7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<template>
  <!--  新增右侧按钮-->
  <div>
    <div style=" display: flex; justify-content: flex-end;">
      <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">
          <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>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
    <el-button @click="escHandler">取 消</el-button>
    <el-button type="primary" @click="addSaveHandler">保存</el-button>
  </span>
    </el-dialog>
    <!--    echarts组件-->
    <div style="margin-top: 15px">
      <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>
 
<script>
import lineChart from "../../components/StatisticsComponent/lineChart"
import pieChart from "../../components/StatisticsComponent/pieChart"
import ColumnarChart from "../../components/StatisticsComponent/ColumnarChart"
import mixCart from "../../components/StatisticsComponent/mixCart"
import {getStatisticAnalysis} from "@/api/statistic/chart"
export default {
  components: {
    lineChart,
    pieChart,
    ColumnarChart,
    mixCart
  },
  name: "statisticPage",
  data() {
    return {
      addVisible: false,
      chartName: "",
      lineList: [],
      pieList: [],
      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],
          ]
        }
      ]
    }
  },
  methods: {
    //新增
    addHandler() {
      this.addVisible = true;
      getStatisticAnalysis({btmNames:'part'}  ).then(res=>{
        console.log(res)
      })
    },
    //取消
    escHandler() {
      this.addVisible = false;
    },
    //保存
    addSaveHandler() {
      if (this.selectData.length <= 0) {
        this.$message.warning('请至少选择一条数据!');
        return;
      }
 
      const typeList = {
        "0": "lineList",
        "1": "pieList",
        "2": "columnarList",
        "3": "mixList"
      };
 
      let hasValidData = false; // 添加一个标志来记录是否有有效的选择数据
      let codeStatus = this.selectData.every(key => key.codeType)
      if (!codeStatus) {
        this.$message.warning("请检查已勾选数据类型是否为空!");
        return;
      }
      this.selectData.forEach(item => {
        const dataKey = typeList[item.codeType];
        if (dataKey) {
          this[dataKey].push(item);
          hasValidData = true; // 标记有有效数据被添加
        }
      });
 
      if (hasValidData) {
        this.addVisible = false;
      }
    },
    //表格多选
    selectChange(selection, row) {
      // console.log(selection, row)
      this.selectData = selection;
    },
  }
}
</script>
 
<style scoped lang="scss">
 
</style>