zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<template>
  <div class="customers-white-main">
    <TableList
      ref="commontable"
      :condtionConfig="condtionConfig"
      :columnConfig="columnConfig"
      :condformdefConfig="condformdefConfig"
      :operateBtns="operateBtns"
      :formItemsConfig="formItemsConfig"
      :defValuesConfig="defValuesConfig"
      :formRulesConfig="formRulesConfig"
      :userDefined="false"
      :isAutoIndex="false"
      :isMultipleSelect="true"
      :buttonsArr="buttonsArr"
      dialogTitle="白名单信息"
      rowKeyName="serialno"
      @handleSelectionChange="handleSelectionChange"
      @handleBtnClick="handleBtnClick"
      @handleSelFocus="handleSelFocus"
      @handleSelOnChange="handleSelOnChange"
      listApiName="qryWhiteCustomerList"
      delApiName="deleteWhiteCustomer"
      saveApiName="saveWhiteCusInfo"
      updateApiName="updateWhiteCusInfo"
      deleteKey="serialno"
      deleteType="ARRAY"
      :isListEdit="true"
    />
    <el-dialog
      title="批量导入"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      :show-close="false"
      width="450"
      center
      custom-class="school_dialog_footer_set"
    >
      <el-upload
        class="upload-main"
        drag
        action=""
        :headers="uploadHeader"
        :http-request="handleUpload"
        :show-file-list="false"
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">
          <a @click="downloadFile">模板下载</a>
        </div>
      </el-upload>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="批量删除确认"
      :visible.sync="delDialogVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      :show-close="false"
      width="450"
      center
      custom-class="cusm_dialog_footer_set del_dialog"
    >
      <div style="text-align: center">
        请确认是否删除客户白名单数据:{{ deleteSum }}条,是否继续?
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="delDialogVisible = false">否</el-button>
        <el-button type="primary" @click="deleteListItem">是</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { mapState, mapGetters, mapActions } from "vuex";
import TableList from "../components/TableList.vue";
import {
  CUSTOMERSWHITECOND,
  CUSTOMERSWHITECONDDEF
} from "./config/condtion.config";
import { CUSTOMERSWHITECOLUMN } from "./config/column.config";
import { CUSTOMERSWHITEFORMS } from "./config/formItem.config";
import { CUSTOMERSWHITEDEFVALUES } from "./config/defValues.config";
import { CUSTOMERSWHITERULES } from "./config/rules.config";
import {
  downloadTemplateForWhiteCus,
  whiteCustomerBatchImport,
  deleteWhiteCustomer,
  qryCustomerBaseList,
  getAllProjectList
} from "@/http/api";
import { Message } from "element-ui";
export default {
  props: {},
  provide() {
    return {
      getconfigInfo: this.getconfigInfo,
      getconfigForm: this.getconfigForm
    };
  },
  data() {
    return {
      condtionConfig: [...CUSTOMERSWHITECOND],
      columnConfig: [...CUSTOMERSWHITECOLUMN],
      condformdefConfig: { ...CUSTOMERSWHITECONDDEF },
      formItemsConfig: [...CUSTOMERSWHITEFORMS],
      defValuesConfig: { ...CUSTOMERSWHITEDEFVALUES },
      formRulesConfig: { ...CUSTOMERSWHITERULES(true) },
      buttonsArr: [
        { type: "import", value: "批量导入", icon: "el-icon-upload" },
        { type: "delete", value: "批量删除", icon: "el-icon-delete-solid" }
      ],
      operateBtns: [
        { label: "详情", type: "DETAIL", value: true },
        { label: "修改", type: "EDIT", value: true },
        { label: "删除", type: "DELETE", value: true }
      ],
      selecteData: [],
      deleteSum: 0,
      delDialogVisible: false,
      optionsArr: ["productNames", "DataSource", "productList", "projectList"],
      dialogVisible: false,
      YesNoOption: [
        { value: "0", label: "有效" },
        { value: "1", label: "无效" }
      ],
      uploadHeader: {
        "Content-Type": "multipart/form-data; boundary=ReaquestHeader"
      }
    };
  },
  watch: {
    optionsMap: {
      handler(options) {
        this.optionsData = options;
        this.getconfigInfo(options);
      },
      deep: true
    }
  },
  computed: {
    // 获取state值
    ...mapState("rlc", {
      optionsMap: state => state.OPTIONSMAP
    }),
    // 通过getters获取值
    ...mapGetters("rlc", ["getOptionsMap"])
  },
  async created() {
    this.getOptionsData(this.optionsArr);
    this.getUserInfo();
  },
  mounted() {},
  methods: {
    ...mapActions("rlc", [
      // 将 `this.setOptionsMap()` 映射为 `this.$store.dispatch('setOptionsMap')`
      "getOptionsData",
      "getUserInfo"
    ]),
    async getconfigInfo(opts = this.optionsData) {
      const items = {
        productnames: "productNames",
        datasource: "DataSource",
        productno: "productList",
        isDelete: "YesNoOption",
        projectserialno: "AllProject"
      };
      if (!opts || opts.length < 1) {
        return;
      }
      if (!this.AllProject) {
        let { result } = await getAllProjectList({});
        this.AllProject = result.map(res => {
          return {
            label: res.projectname,
            value: res.serialno
          };
        });
      }
      const options = {
        ...opts,
        YesNoOption: this.YesNoOption,
        AllProject: this.AllProject
      };
      this.condtionConfig = [...CUSTOMERSWHITECOND].map(form => {
        const newForm = { ...form };
        if (newForm.type === "select" || newForm.type === "multipleSelect") {
          newForm.options = options[items[newForm.name]];
        }
        return newForm;
      });
      this.formItemsConfig = [...CUSTOMERSWHITEFORMS].map(form => {
        const newForm = { ...form };
        if (newForm.type === "select" || newForm.type === "multipleSelect") {
          newForm.options = options[items[newForm.name]];
        }
        return newForm;
      });
      this.formRulesConfig = { ...CUSTOMERSWHITERULES(true) };
    },
    getconfigForm(opts = this.optionsData) {
      const items = {
        datasource: "DataSource",
        productno: "productList",
        isDelete: "YesNoOption",
        projectserialno: "AllProject"
      };
      if (!opts || opts.length < 1) {
        return;
      }
      const options = {
        ...opts,
        YesNoOption: this.YesNoOption,
        AllProject: this.AllProject
      };
      this.formItemsConfig = [...CUSTOMERSWHITEFORMS].map(form => {
        const newForm = { ...form };
        // newForm.readonly = true;
        newForm.placeholder = "";
        if (newForm.type === "select" || newForm.type === "multipleSelect") {
          newForm.options = options[items[newForm.name]];
        }
        return newForm;
      });
      this.formRulesConfig = { ...CUSTOMERSWHITERULES(false) };
    },
    async qryCustomerBaseList(productid) {
      const customRes = await qryCustomerBaseList({ productid });
      if (customRes && customRes.code === "00") {
        this.formItemsConfig = [...this.formItemsConfig].map(form => {
          const newForm = { ...form };
          if (newForm.name === "productcustomerbasenameSel") {
            newForm.options = customRes.result;
          }
          return newForm;
        });
      }
    },
    handleSelOnChange(name, value, label) {
      const refForm = this.$refs.commontable.$refs.dialogForm.$refs[
        "createForm"
      ];
      if (name === "productno") {
        refForm.model.productname = label;
        refForm.model.productno = value;
        this.qryCustomerBaseList(value);
      }
      if (name === "projectserialno") {
        refForm.model.projectname = label;
        refForm.model.projectserialno = value;
      }
      if (name === "isDelete") {
        refForm.model.isDelete = value;
      }
      if (name === "productCustomerBase") {
        refForm.model.productcustomerbasename = label;
        refForm.model.productCustomerBase = value;
      }
    },
    handleSelFocus(name, options = []) {
      const refForm = this.$refs.commontable.$refs.dialogForm.$refs[
        "createForm"
      ];
      const roductnoVal = refForm.model.productno;
      if (options.length < 1 && !roductnoVal) {
        refForm.validateField("productno", errorMessage => {
          this.$message.warning(errorMessage);
        });
      }
    },
    operateHandleClick() {
      this.$router.push({ name: "addImageDataConfig" });
    },
    async handleBtnClick(type) {
      if (type === "import") {
        this.dialogVisible = true;
      }
      if (type === "delete") {
        const { selecteData } = this;
        if (selecteData.length < 1) {
          this.$message.warning("请选择需要删除的白名单");
          return false;
        }
        this.deleteSum = selecteData.length;
        this.delDialogVisible = true;
      }
    },
    async deleteListItem() {
      const { selecteData } = this;
      const deleteSelectRes = await deleteWhiteCustomer({
        serialno: selecteData.map(({ serialno }) => {
          return serialno;
        })
      });
      if (deleteSelectRes && deleteSelectRes.code === "00") {
        this.$refs.commontable.getTableList();
        this.delDialogVisible = false;
        setTimeout(() => {
          this.$message.success("删除成功");
        }, 10);
      }
    },
    handleSelectionChange(val) {
      this.selecteData = val;
    },
    async handleUpload(file) {
      if (file.file) {
        const formData = new FormData();
        formData.append("file", file.file);
        await whiteCustomerBatchImport(formData).then(res => {
          if (res.code === "00") {
            this.$message.success("导入成功");
            this.dialogVisible = false;
            this.$refs.commontable.getTableList();
          }
        });
      }
    },
    handleUploadFile() {},
    async downloadFile() {
      await downloadTemplateForWhiteCus({ fileName: "批量导入白名单模板" });
      Message.closeAll();
    }
  },
  components: { TableList }
};
</script>
 
<style lang="less">
.customers-white-main {
  & .el-upload__tip {
    color: #409eff;
    & a {
      cursor: pointer;
    }
  }
  & .cusm_dialog_footer_set {
    width: 400px;
    & .el-dialog__footer {
      & .dialog-footer {
        & .el-button--default {
          width: 120px;
          height: 30px;
          line-height: 7px;
          border-radius: 4px;
          border: 1px solid rgba(204, 204, 204, 1);
        }
        & .el-button--primary {
          width: 120px;
          height: 30px;
          line-height: 7px;
          background: #0081f0;
          border-color: #0081f0;
          border-radius: 4px;
          margin-left: 40px;
        }
      }
    }
  }
  & .school_dialog_footer_set {
    & .el-dialog__body {
      text-align: center;
    }
  }
  & .del_dialog {
    width: 450px;
  }
}
</style>