田源
2023-10-18 4aef25f2a55460040a72a73b8ec0cbb6bec0691d
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
<template>
  <div>
      <div style="display: flex; justify-content: flex-end;margin-bottom: 10px">
        <el-button icon="el-icon-more" type="primary" plain size="small" @click="MoreHandler">更多</el-button>
    </div>
    <avue-data-box :option="option" :animation="true">
      <template>
        <el-switch></el-switch>
      </template>
    </avue-data-box>
    <el-dialog title="主数据配置" :visible.sync="dialogTableVisible" append-to-body class="avue-dialog avue-dialog--top" top="0">
      <avue-crud ref="crud"
                 v-model="Crud.form"
                 :data="Crud.data"
                 @selection-change="selectionChange"
                 :option="Crud.option">
      </avue-crud>
      <div slot="footer" class="dialog-footer">
        <el-button  type="primary" plain @click="SaveHandler">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import {validatenull} from "@/util/validate";
import {getList,save} from "@/api/system/statistic";
import {flowRoute} from "@/util/flow";
 
export default {
name: "Statistic",
  data(){
  return {
    Crud:{
      form:'',
      data:[],
      option:{
        calcHeight: 80,
        tip: false,
        searchShow: false,
        addBtn:false,
        columnBtn:false,
        header:false,
        menu:false,
        border: true,
        index: true,
        selection: true,
        column:[
          {
            label: "主数据名称",
            prop: "menuName",
          },
          {
            label: "待办数据",
            prop: "mdmCount",
          },
          {
            label: "icon图标",
            prop: "icon",
            overHidden:true,
          },
          {
            label: "路由地址",
            prop: "menuRoute",
            overHidden:true,
          },
          {
            label: "code",
            prop: "code",
            overHidden:true,
          },
        ]
      }
    },
    userId:'',
    hexColor:'',
    newData:[],
    SelectRow:[],
    countByServer:true,
    dialogTableVisible:false,
    // listMyTask:[]
    option: {
      span:6,
      data: []
    },
  }
  },
  created() {
    this.MasterGetList()
  },
  computed(){
 
  },
  methods: {
    selectionChange(row){
      // console.log(row)
      this.SelectRow=row;
    },
    SaveHandler(){
      if(this.SelectRow.length <= 0){
        this.$message.warning('请选择一条数据!')
        return
      }
      let mdmNameList=[];
      mdmNameList=this.SelectRow.map(item=>{return item.code})
        console.log(mdmNameList)
      save(this.userId,mdmNameList).then(res=>{
        console.log(res)
        if(res.data.code === 200){
          this.$message.success('保存成功!')
          this.option.data=[];
          this.MasterGetList()
          this.dialogTableVisible=false;
        }
      })
    },
    MoreHandler(){
      this.dialogTableVisible=true
    },
    // 随机色
    randomColor() {
      const r = Math.floor(Math.random() * 256); // 生成 0 到 255 之间的随机数
      const g = Math.floor(Math.random() * 256);
      const b = Math.floor(Math.random() * 256);
      // 将 RGB 值转换为十六进制表示形式
      const hexColor = "#" + r.toString(16).padStart(2, '0') + g.toString(16).padStart(2, '0') + b.toString(16).padStart(2, '0');
      return hexColor;
    },
    MasterGetList() {
      this.userId = localStorage.getItem('userId');
      getList({ userId: this.userId }).then(res => {
        res.data.data.filter(item => {
          if (item.isDefault === 1) {
            this.hexColor = this.randomColor();
            this.option.data.push({
              click: (item) => {
                this.$router.push({ path: item.uiUrl });
              },
              title: item.menuName,
              count: parseInt(item.mdmCount),
              icon: item.icon,
              code: item.code,
              isDefault: item.isDefault,
              color:this.hexColor,
              uiUrl: item.menuRoute,
            });
          } else if (item.isDefault === 0) {
            this.newData.push(item);
            this.Crud.data=this.newData;
          }
        });
        // console.log(this.option.data);
        // console.log(this.newData);
      });
    }
  }
}
</script>
 
<style scoped>
 
</style>