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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
<template>
  <div class="pricing_main">
    <el-row v-if="!isView" class="add-button">
      <el-col :span="24">
        <el-button
          type="primary"
          size="small"
          icon="el-icon-circle-plus-outline"
          @click="handleAddPage"
          class="add-btn"
          >新增定价</el-button
        >
      </el-col>
    </el-row>
    <ProTable
      :pageInfo="pageInfo"
      @doAction="doAction"
      @handleCurrentChange="handleCurrentChange"
      @handleSizeChange="handleSizeChange"
      :noHistory="noHistory"
      :isAutoIndex="true"
      :list="pricingList"
      :header="tableHeader"
      :loading="loading"
    />
    <el-dialog
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      width="1000"
      center
      custom-class="pricing_dialog"
    >
      <CreateForms
        v-if="dialogVisible"
        :screenWidth="screenWidth"
        :isShowOld="showOld"
        :oldVal="oldVal"
        :isView="isView"
        :formItems="formItems"
        :isShowBorder="isShowBorder"
        ref="pricingSetting"
        :defValues="defValues"
        :formRules="formRules"
        @handleSelOnChange="handleSelOnChange"
      />
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">{{
          isView ? "关 闭" : "取 消"
        }}</el-button>
        <el-button
          type="primary"
          v-if="!isView"
          @click="savePricingConfiguration"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      title="定价配置删除确认"
      :visible.sync="dialogDelVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      width="1000"
      center
      custom-class="pricing_dialog del_dialog"
    >
      <div style="text-align: justify;">{{ tipContent }}</div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogDelVisible = false">取 消</el-button>
        <el-button type="primary" @click="deletePricingConfiguration"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { DIMENSIONPRICINGSETTINGCOLUMN } from "./config/tableConfig.js";
import {
  addOrUpdatePricingConfiguration,
  qryPricingConfigurationList,
  delPricingConfiguration,
  qryPricingConfigurationDetail
} from "../../../../api/productManage.api";
import { DIMENSIONENUM } from "../../../../utils/optionsQueryConfig.js";
import ProTable from "../../../../components/ProTable.vue";
import CreateForms from "../../../../components/CreateForms.vue";
import { DIMENSIONPRICINGSETTINGFORMS } from "../../../../utils/formsConfig.js";
import { DIMENSIONPRICINGSETTINGDEFVALUE } from "../../../../utils/defValueConfig.js";
import { DIMENSIONPRICINGSETTINGRULES } from "../../../../utils/formRulesConfig.js";
let otherParams = {};
export default {
  props: {
    edit: {
      type: Boolean,
      default: () => {
        return false;
      }
    },
    isView: {
      type: Boolean,
      default: () => {
        return false;
      }
    },
    noHistory: {
      type: Boolean,
      default: () => {
        return false;
      }
    },
    isShowBorder: {
      type: Boolean,
      default: () => {
        return true;
      }
    },
    options: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  watch: {
    options: {
      handler(val, oldVal) {
        this.optionsData = val;
        this.getOptionItems(val);
      },
      deep: true
    }
  },
  components: {
    ProTable,
    CreateForms
  },
  mounted() {
    this.initColumns();
    (this.isView || this.edit) && this.getPricingConfigurationList();
  },
  methods: {
    // 处理变更标志显示
    initColumns() {
      const { objecttype } = this.$parent._data;
      const { tableHeader, noHistory } = this;
      const isModify = objecttype === "jbo.app.BUSINESS_TYPE_CHANGE";
      const newTableHeader =
        isModify && !noHistory
          ? tableHeader
          : tableHeader.filter(col => col.prop !== "changeflag");
      this.$set(this, "tableHeader", newTableHeader);
    },
    // 下拉选择事件处理
    handleSelOnChange(formName, value, label) {
      let newFormItems = [...this.formItems];
      if (formName === "rateinteresttype") {
        const showFoelds = [
          "interestperiod",
          "interesttype",
          "rateunit",
          "rate"
        ];
        newFormItems.forEach(form => {
          if (showFoelds.includes(form.name)) {
            form.show = value === "1";
          }
          if (form.name === "eachratefixed") {
            form.show = value === "2";
          }
        });
      }
      if (formName === "poundagetype") {
        const showFoelds = ["poundagerate", "minpoundage", "maxpoundage"];
        newFormItems.forEach(form => {
          if (showFoelds.includes(form.name)) {
            form.show = value === "1";
          }
          if (form.name === "poundagefixed") {
            form.show = value === "2";
          }
          if (form.name === "poundagecharge") {
            form.show = value !== "0";
          }
          if (form.name === "poundagemonth") {
            form.show = value !== "0";
          }
        });
      }
      if (formName === "poundagecharge") {
        newFormItems.forEach(form => {
          if (form.name === "poundagemonth") {
            form.show = value === "5";
          }
        });
      }
      if (formName === "platformtype") {
        const showFoelds = ["platformrate", "minplatform", "maxplatform"];
        newFormItems.forEach(form => {
          if (showFoelds.includes(form.name)) {
            form.show = value === "1";
          }
          if (form.name === "platformfixed") {
            form.show = value === "2";
          }
          if (form.name === "platformcharge") {
            form.show = value !== "0";
          }
          if (form.name === "platformmonth") {
            form.show = value !== "0";
          }
        });
      }
      if (formName === "platformcharge") {
        newFormItems.forEach(form => {
          if (form.name === "platformmonth") {
            form.show = value === "5";
          }
        });
      }
      if (formName === "guarantycalculation") {
        const showFoelds = [
          "guarantyrate",
          "minguaranty",
          "maxguaranty",
          "totalrate"
        ];
        newFormItems.forEach(form => {
          if (showFoelds.includes(form.name)) {
            form.show = value === "1";
          }
          if (form.name === "guarantyfixed") {
            form.show = value === "2";
          }
          if (form.name === "guarantycharge") {
            form.show = value !== "0";
          }
          if (form.name === "guarantymonth") {
            form.show = value !== "0";
          }
        });
      }
      if (formName === "guarantycharge") {
        newFormItems.forEach(form => {
          if (form.name === "guarantymonth") {
            form.show = value === "5";
          }
          if (form.name === "totalrate") {
            form.show = value === "7";
          }
        });
      }
      if (formName === "termunit") {
        newFormItems.forEach(form => {
          if (
            form.name === "mindcreditterm" ||
            form.name === "maxdcreditterm"
          ) {
            form.show = value === "D";
          }
          if (
            form.name === "minmcreditterm" ||
            form.name === "maxmcreditterm"
          ) {
            form.show = value === "M";
          }
        });
      }
      if (formName === "paymenttype") {
        otherParams["paymenname"] = label;
      }
      this.formItems = newFormItems;
    },
    // 重置表单配置项
    setFormsItemConfig() {
      const { showData } = this.$parent._data;
      const newFormItems = [...this.formItems].map(form => {
        const newForm = { ...form };
        if (
          newForm.name === "minmcreditterm" ||
          newForm.name === "maxmcreditterm"
        ) {
          newForm.show = showData.attribute3 === "M";
        }
        if (
          newForm.name === "mindcreditterm" ||
          newForm.name === "maxdcreditterm"
        ) {
          newForm.show = showData.attribute3 === "D";
        }
        return newForm;
      });
      this.formItems = newFormItems;
    },
    async doAction(name, item, { key, label }) {
      if (key === "edit") {
        this.dialogTitle = "定价配置修改";
        this.serialno = item.serialno;
        this.dialogVisible = true;
        const infos = await this.getPricingConfigurationDetail(item.serialno);
        let editData = {};
        let visibleArry = [];
        Object.getOwnPropertyNames(infos).forEach(key => {
          editData[key] = infos[key].value;
          if (infos[key].visible) {
            visibleArry.push(key);
          }
        });
        const newEditFormItems = [...this.formItems].map(items => {
          const newItem = { ...items };
          newItem.show = visibleArry.includes(newItem.name);
          if (
            newItem.name === "mindcreditterm" ||
            newItem.name === "maxdcreditterm"
          ) {
            newItem.show = editData.termunit === "D";
          }
          if (
            newItem.name === "minmcreditterm" ||
            newItem.name === "maxmcreditterm"
          ) {
            newItem.show = editData.termunit === "M";
          }
          return newItem;
        });
 
        this.formItems = newEditFormItems;
        setTimeout(() => {
          this.defValues = { ...editData };
        }, 0);
      }
      if (key === "details") {
        this.dialogTitle = "定价配置详情";
        this.serialno = item.serialno;
        this.dialogVisible = true;
        const infos = await this.getPricingConfigurationDetail(item.serialno);
        let editData = {};
        let visibleArry = [];
        let oldValue = {};
        Object.getOwnPropertyNames(infos).forEach(key => {
          editData[key] = infos[key].value;
          oldValue[key] = infos[key].oldValue;
          if (infos[key].visible) {
            visibleArry.push(key);
          }
        });
        setTimeout(() => {
          const newFormItems = [...this.formItems].map(items => {
            const newForms = { ...items };
            newForms.placeholder = "";
            newForms.readonly = true;
            newForms.show = visibleArry.includes(newForms.name);
            if (
              newForms.name === "mindcreditterm" ||
              newForms.name === "maxdcreditterm"
            ) {
              newForms.show = editData.termunit === "D";
            }
            if (
              newForms.name === "minmcreditterm" ||
              newForms.name === "maxmcreditterm"
            ) {
              newForms.show = editData.termunit === "M";
            }
            return newForms;
          });
          this.formItems = newFormItems;
          this.defValues = { ...editData };
          this.oldVal = oldValue;
        }, 0);
      }
      if (key === "delete") {
        this.serialno = item.serialno;
        this.tipContent = `请确认是否需要删除定价配置
        (最低贷款期限:${item.mincreditterm},最高贷款期限:${item.maxcreditterm},还款方式:${item.paymentname})`;
        this.dialogDelVisible = true;
      }
    },
    // 获取下拉选择项
    getOptionItems(optionsMap) {
      const { formItems } = this;
      formItems.forEach(item => {
        if (item.type === "select") {
          item.options = optionsMap[DIMENSIONENUM[item.name]];
        }
      });
    },
    // 获取定价配置列表
    async getPricingConfigurationList() {
      const { currentPage, pageSize } = this.pageInfo;
      const { dimensionno, objectno, productid } = this.$parent._data;
      const params = {
        currentPage,
        dimensionno,
        objectno,
        pageSize,
        productid
      };
      const listRes = await qryPricingConfigurationList(params);
      if (!listRes || listRes.code !== "00") {
        return;
      }
      const list =
        listRes.result &&
        listRes.result.records.map(item => {
          const newitem = { ...item };
          newitem.operationOption = this.isView
            ? [{ key: "details", label: "详情", value: true }]
            : [
                { key: "edit", label: "修改", value: true },
                { key: "delete", label: "删除", value: true }
              ];
          return newitem;
        });
 
      this.$set(this, "pricingList", list);
      this.pageInfo.total = listRes.result.total;
    },
    // 查询产品维度定价配置信息
    async getPricingConfigurationDetail(serialno) {
      const {
        dimensionno,
        objectno,
        productid,
        objecttype
      } = this.$parent._data;
      const params = {
        dimensionno,
        objectno,
        productid,
        serialno,
        showoldvalue: objecttype === "jbo.app.BUSINESS_TYPE_CHANGE"
      };
      const detailRes = await qryPricingConfigurationDetail(params);
      if (!detailRes || detailRes.code !== "00") {
        return;
      }
      return detailRes.result;
    },
    // 删除产品维度定价配置信息
    async deletePricingConfiguration() {
      const deleteRes = await delPricingConfiguration({
        serialno: this.serialno
      });
      if (!deleteRes || deleteRes.code !== "00") {
        return;
      }
      this.dialogDelVisible = false;
      this.$message.success("删除成功");
      this.getPricingConfigurationList();
      return deleteRes.result;
    },
    // 新增定价
    handleAddPage() {
      this.formItems = [...DIMENSIONPRICINGSETTINGFORMS];
      this.defValues = {
        ...DIMENSIONPRICINGSETTINGDEFVALUE
      };
      this.formRules = {
        ...DIMENSIONPRICINGSETTINGRULES(!this.isView)
      };
      this.dialogTitle = "定价配置新增";
      this.optionsData = {};
      this.screenWidth = 1000;
      this.tipContent = "";
      this.loading = false;
      this.serialno = "";
      this.dialogVisible = false;
      this.dialogDelVisible = false;
      this.pageInfo = {
        currentPage: 1,
        pageSize: 10,
        total: 0
      };
      this.setFormsItemConfig();
      this.dialogVisible = true;
    },
    // 校验基本信息
    validateForms() {
      const pricingSettingForm = this.$refs.pricingSetting;
      pricingSettingForm.$refs["createForm"].validate(async valid => {
        if (valid) {
          this.isValidate = true;
        } else {
          this.isValidate = false;
          this.$message.error("请完必填项!");
          return false;
        }
      });
    },
    // 获取显示表单对应的value值
    getFormItemsValue(forms, values, defvalue) {
      let newDfvalue = {};
      Object.getOwnPropertyNames(defvalue).forEach(key => {
        newDfvalue[key] = "";
      });
      const showForms = forms.filter(form => form.show !== false);
      let formsValue = {};
      showForms.forEach(form => {
        formsValue[form.name] = values[form.name];
      });
      return { ...newDfvalue, ...formsValue };
    },
    // 保存定价配置
    async savePricingConfiguration() {
      await this.validateForms();
      const { isValidate } = this;
      if (!isValidate) {
        return false;
      }
      const pricingSettingForm = this.$refs.pricingSetting;
      const { dimensionno, objectno, productid } = this.$parent._data;
      const params = {
        ...this.getFormItemsValue(
          pricingSettingForm.formItems,
          pricingSettingForm.formValues,
          DIMENSIONPRICINGSETTINGDEFVALUE
        ),
        dimensionno,
        objectno,
        productid,
        serialno: this.serialno,
        ...otherParams
      };
      const res = await addOrUpdatePricingConfiguration(params);
      this.getPricingConfigurationList();
      if (!res || res.code !== "00") {
        return false;
      }
      this.$message({
        message: "保存成功!",
        type: "success"
      });
      this.dialogVisible = false;
    },
    // 修改翻页条数
    handleSizeChange(val) {
      this.pageInfo.pageSize = val;
      this.getPricingConfigurationList();
    },
 
    // 修改翻页数
    handleCurrentChange(val) {
      this.pageInfo.currentPage = val;
      this.getPricingConfigurationList();
    }
  },
  data() {
    return {
      pricingList: [],
      tableHeader: [...DIMENSIONPRICINGSETTINGCOLUMN],
      formItems: [...DIMENSIONPRICINGSETTINGFORMS],
      defValues: {
        ...DIMENSIONPRICINGSETTINGDEFVALUE
      },
      formRules: {
        ...DIMENSIONPRICINGSETTINGRULES(!this.isView)
      },
      dialogTitle: "定价配置新增",
      showOld:
        this.$parent._data.objecttype === "jbo.app.BUSINESS_TYPE_CHANGE" &&
        this.isView,
      oldVal: {},
      optionsData: {},
      screenWidth: 1000,
      tipContent: "",
      loading: false,
      serialno: "",
      dialogVisible: false,
      dialogDelVisible: false,
      pageInfo: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      }
    };
  }
};
</script>
<style lang="stylus" scoped>
.pricing_main {
  padding: 20px 0 0 20px;
  & .add-button {
    padding: 10px 0 30px 0;
  }
  background: #fff;
  & >>> .pricing_dialog {
    width: 1000px;
    height: 650px;
    & .el-dialog__body {
      height: 460px;
      overflow-y: auto;
      overflow-x: hidden;
      & .form_main {
        & .el-form {
          & .el-form-item {
            & .el-form-item__label {
              line-height: 32px;
            }
          }
        }
      }
    }
    & .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;
        }
      }
    }
  }
  & >>> .del_dialog {
    width: 540px !important;
    height: 250px !important;
    & .el-dialog__body {
      height: 80px;
      overflow-y: auto;
      overflow-x: hidden;
    }
  }
}
</style>