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
<template>
  <div class="roll_plan_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="rolltList"
      :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
        ref="rollPlan"
        v-if="dialogVisible"
        :isShowOld="showOld"
        :oldVal="oldVal"
        :isView="isView"
        :isShowBorder="isShowBorder"
        :screenWidth="screenWidth"
        :formItems="formItems"
        :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="saveRollOverConfig"
          >确 定</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="deleteRollOverConfig"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { ROLLPLANSETTINGCOLUMN } from "./config/tableConfig.js";
import {
  addOrUpdateRollOverConfig,
  qryRollOverConfigList,
  delRollOverConfig,
  qryRollOverConfigDetail
} from "../../../../api/productManage.api";
import { DIMENSIONENUM } from "../../../../utils/optionsQueryConfig.js";
import ProTable from "../../../../components/ProTable.vue";
import CreateForms from "../../../../components/CreateForms.vue";
import { ROLLPLANSETTINGFORMS } from "../../../../utils/formsConfig.js";
import { ROLLPLANSETTINGDEFVALUE } from "../../../../utils/defValueConfig.js";
import { ROLLPLANSETTINGRULES } from "../../../../utils/formRulesConfig.js";
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 {};
      }
    }
  },
  components: {
    ProTable,
    CreateForms
  },
  mounted() {
    this.initColumns();
    (this.isView || this.edit) && this.getRollOverConfigList();
  },
  watch: {
    edit: {
      type: Boolean,
      default: () => {
        return false;
      }
    },
    isView: {
      type: Boolean,
      default: () => {
        return false;
      }
    },
    options: {
      handler(val, oldVal) {
        this.optionsData = val;
        this.getOptionItems(val);
      },
      deep: true
    }
  },
  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);
    },
    async doAction(name, item, { key, label }) {
      if (key === "edit") {
        this.dialogTitle = "展期方案配置修改";
        this.serialno = item.serialno;
        this.dialogVisible = true;
        const infos = await this.getRollOverConfigDetail(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.getRollOverConfigDetail(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);
            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.paymenttype})`;
        this.dialogDelVisible = true;
      }
    },
    // 获取下拉选择项
    getOptionItems(optionsMap) {
      const { formItems } = this;
      formItems.forEach(item => {
        if (item.type === "select") {
          item.options = optionsMap[DIMENSIONENUM[item.name]];
        }
      });
    },
    // 获取展期方案列表
    async getRollOverConfigList() {
      const { currentPage, pageSize } = this.pageInfo;
      const { dimensionno, objectno, productid } = this.$parent._data;
      const params = {
        currentPage,
        dimensionno,
        objectno,
        pageSize,
        productid
      };
      const listRes = await qryRollOverConfigList(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, "rolltList", list);
      this.pageInfo.total = listRes.result.total;
    },
    // 下拉选择事件处理
    handleSelOnChange(formName, value) {
      let newFormItems = [...this.formItems];
      if (formName === "rollovertype") {
        newFormItems.forEach(form => {
          if (form.name === "rollovermonth") {
            form.show = value === "1";
          }
        });
      }
      if (formName === "rollinteresttype") {
        newFormItems.forEach(form => {
          if (form.name === "rolloverrate") {
            form.show = value === "1";
          }
          if (form.name === "rolloversum") {
            form.show = value === "2";
          }
        });
      }
      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";
          }
        });
      }
      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;
    },
    // 新增
    handleAddPage() {
      this.formItems = [...ROLLPLANSETTINGFORMS];
      this.defValues = {
        ...ROLLPLANSETTINGDEFVALUE
      };
      this.formRules = {
        ...ROLLPLANSETTINGRULES(!this.isView)
      };
      this.dialogTitle = "展期方案配置新增";
      this.screenWidth = 1000;
      this.tipContent = "";
      this.serialno = "";
      this.dialogDelVisible = false;
      this.loading = false;
      this.setFormsItemConfig();
      this.dialogVisible = true;
    },
    // 校验基本信息
    validateForms() {
      const rollPlanForm = this.$refs.rollPlan;
      rollPlanForm.$refs["createForm"].validate(async valid => {
        if (valid) {
          this.isValidate = true;
        } else {
          this.isValidate = false;
          this.$message.error("请完必填项!");
          return false;
        }
      });
    },
    // 获取显示表单对应的value值
    getFormItemsValue(forms, values, defvalue) {
      const showForms = forms.filter(form => form.show !== false);
      let formsValue = {};
      showForms.forEach(form => {
        formsValue[form.name] = values[form.name];
      });
      return { ...defvalue, ...formsValue };
    },
    // 保存展期方案配置新增
    async saveRollOverConfig() {
      await this.validateForms();
      const { isValidate } = this;
      if (!isValidate) {
        return false;
      }
      const rollPlanForm = this.$refs.rollPlan;
      const { dimensionno, objectno, productid } = this.$parent._data;
      const params = {
        ...this.getFormItemsValue(
          rollPlanForm.formItems,
          rollPlanForm.formValues,
          ROLLPLANSETTINGDEFVALUE
        ),
        dimensionno,
        objectno,
        productid,
        serialno: this.serialno
      };
      const res = await addOrUpdateRollOverConfig(params);
      if (!res || res.code !== "00") {
        return false;
      }
      this.$message({
        message: "保存成功!",
        type: "success"
      });
      this.getRollOverConfigList();
      this.dialogVisible = false;
    },
    // 查询产品维度流程配置信息
    async getRollOverConfigDetail(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 qryRollOverConfigDetail(params);
      if (!detailRes || detailRes.code !== "00") {
        return;
      }
      return detailRes.result;
    },
    // 删除产品维度流程配置信息
    async deleteRollOverConfig() {
      const deleteRes = await delRollOverConfig({ serialno: this.serialno });
      if (!deleteRes || deleteRes.code !== "00") {
        return;
      }
      this.dialogDelVisible = false;
      this.$message.success("删除成功");
      this.getRollOverConfigList();
      return deleteRes.result;
    },
    // 修改翻页条数
    handleSizeChange(val) {
      this.pageInfo.pageSize = val;
      this.getRollOverConfigList();
    },
 
    // 修改翻页数
    handleCurrentChange(val) {
      this.pageInfo.currentPage = val;
      this.getRollOverConfigList();
    }
  },
  data() {
    return {
      rolltList: [],
      tableHeader: [...ROLLPLANSETTINGCOLUMN],
      formItems: [...ROLLPLANSETTINGFORMS],
      defValues: {
        ...ROLLPLANSETTINGDEFVALUE
      },
      formRules: {
        ...ROLLPLANSETTINGRULES(!this.isView)
      },
      dialogTitle: "展期方案配置新增",
      screenWidth: 1000,
      tipContent: "",
      serialno: "",
      showOld:
        this.$parent._data.objecttype === "jbo.app.BUSINESS_TYPE_CHANGE" &&
        this.isView,
      oldVal: {},
      dialogDelVisible: false,
      loading: false,
      dialogVisible: false,
      pageInfo: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      }
    };
  }
};
</script>
<style lang="stylus" scoped>
.roll_plan_main {
  padding: 20px 0 0 20px;
  & .add-button {
    padding: 10px 0 30px 0;
  }
  & >>> .pricing_dialog {
    width: 1000px;
    & .el-dialog__body {
      & .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: 500px !important;
  }
}
</style>