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
<template>
  <div class="list_main">
    <SearchCondition
      :info="formItems"
      ref="condRef"
      :conForm="conForm"
      :screenWidth="screenWidth"
      :isShowDetail="isShowDetail"
      @handleOnSeach="handleOnSeach"
      @handleOnRest="handleOnRest"
      @handleClick="isShowDetail = !isShowDetail"
    />
    <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="openAddPage"
          class="add-btn"
          >新增维度</el-button
        >
      </el-col>
    </el-row>
    <ProTable
      :pageInfo="pageInfo"
      @doAction="doAction"
      @handleCurrentChange="handleCurrentChange"
      @handleSizeChange="handleSizeChange"
      :noHistory="noHistory"
      :isAutoIndex="true"
      :screenWidth="screenWidth"
      :list="records"
      :header="tableHeader"
      :loading="loading"
    />
    <el-dialog
      title="维度删除确认"
      :visible.sync="dialogDelVisible"
      width="1000"
      center
      custom-class="pricing_dialog del_dialog"
    >
      <div>{{ delTipContent }}</div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogDelVisible = false">取 消</el-button>
        <el-button type="primary" @click="deleteProductDimensions"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      title="维度复制确认"
      :visible.sync="copyDialogVisible"
      width="500"
      center
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      custom-class="pricing_dialog copy_dialog"
    >
      <CreateForms
        ref="copyDim"
        v-if="copyDialogVisible"
        :screenWidth="900"
        :formItems="copyFormItems"
        :defValues="copyDefValues"
        :formRules="copyFormRules"
      />
      <span slot="footer" class="dialog-footer">
        <el-button @click="copyDialogVisible = false" :disabled="btnLoading"
          >取 消</el-button
        >
        <el-button
          type="primary"
          @click="copyProductDimensions"
          :loading="btnLoading"
        >
          确 定
        </el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import {
  PRODIMENSIONLISTCON,
  PRODIMENSIONLISTDEF
} from '../../../utils/condtionConfig';
import { PRODIMENSIONLISTCOLUMN } from '../../../utils/columnConfig';
import { COPYDIMENSIONFORM } from '../../../utils/formsConfig';
import { COPYDIMENSIONDEFVALUE } from '../../../utils/defValueConfig';
import { COPYDIMENSIONRULES } from '../../../utils/formRulesConfig';
import {
  qryProductDimensionsList,
  delProductDimensions,
  copyProductDimensions,
  qryCondition
} from '../../../api/productManage.api';
import ProTable from '../../../components/ProTable.vue';
import CreateForms from '../../../components/CreateForms.vue';
import SearchCondition from '../../../components/SearchCondition.vue';
 
export default {
  props: {
    edit: {
      type: Boolean,
      default: () => {
        return false
      }
    },
    screenWidth: {
      type: Number,
      default: () => {
        return 1280
      }
    },
    isView: {
      type: Boolean,
      default: () => {
        return false
      }
    },
    isShowBorder: {
      type: Boolean,
      default: () => {
        return true
      }
    },
    noHistory: {
      type: Boolean,
      default: () => {
        return false
      }
    }
  },
  watch: {
    isView: {
      handler(val) {
        if (val) {
          this.isView = val
        }
      },
      deep: true
    },
    edit: {
      handler(val) {
        this.getProductDimensionsList()
      },
      deep: true
    }
  },
  data() {
    return {
      formItems: [...PRODIMENSIONLISTCON],
      conForm: { ...PRODIMENSIONLISTDEF },
      tableHeader: [...PRODIMENSIONLISTCOLUMN].filter(item => !item.filter),
      copyFormItems: [...COPYDIMENSIONFORM],
      copyDefValues: { ...COPYDIMENSIONDEFVALUE },
      copyFormRules: { ...COPYDIMENSIONRULES },
      pageInfo: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      records: [],
      condtionValue: {}, // 表单value集合
      btnLoading: false,
      isShowDetail: false, // 是否显示所有表单项
      loading: false,
      listSerialno: '',
      dialogDelVisible: false,
      delTipContent: '',
      copyDialogVisible: false
    }
  },
  components: {
    SearchCondition,
    ProTable,
    CreateForms
  },
  mounted() {
    this.initColumns();
    (this.isView || this.edit) && this.getProductDimensionsList()
    const opyionItems = [
      { name: 'dimensionStatus', code: 'EffStatus' },
      { name: 'tradeType', code: 'DimensionTradeType' }
    ]
    opyionItems.forEach(item => {
      this.getCondition(item.name, item.code)
    })
  },
  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)
    },
    restTable(elments) {
      const showCloums = [...PRODIMENSIONLISTCOLUMN].filter(obj => !obj.filter)
      const newTableHeader = []
      const showOtherCloums = PRODIMENSIONLISTCOLUMN.concat().filter(
        obj => obj.filter
      )
      elments &&
        elments
          .filter(el => el !== '*DFT')
          .forEach(ele => {
            const eleCloums = showOtherCloums.filter(
              forms => forms && forms.prop.toLocaleUpperCase() === ele
            )
            const orgIdCloums = showOtherCloums.filter(
              forms => forms && forms.prop === 'orgId'
            )
            const hasOrgIdClounm = ele === 'CHANNELNO';
            if (hasOrgIdClounm) {
              newTableHeader.push(orgIdCloums[0])
            } else {
              newTableHeader.push(eleCloums[0])
            }
          })
      this.$set(this, 'tableHeader', [...showCloums, ...newTableHeader])
      setTimeout(() => {
        this.initColumns()
      }, 100)
    },
    /**
     * 获取下拉选择项
     */
    async getCondition(name, conditionName) {
      const params = { conditionName }
      const re = await qryCondition(params)
      if (re.code && re.code === '00') {
        const newForms = [...this.formItems].map(forms => {
          const newForm = { ...forms }
          if (newForm.name === name) {
            newForm.options = re.result
          }
          return newForm
        })
        this.$set(this, 'formItems', newForms)
      }
    },
    // 获取产品维度列表
    async getProductDimensionsList() {
      const { currentPage, pageSize } = this.pageInfo
      const { productid, serialno } = this.$parent._data
      const {
        dimensionsName,
        dimensionStatus,
        tradeType,
        orgId,
        cityNo,
        areaNo,
        projectNo,
        customersNo,
        dimensionscode,
        minStartBusinessSum,
        minEndBusinessSum,
        maxStartBusinessSum,
        maxEndBusinessSum
      } = this.condtionValue
      const params = {
        areano: areaNo,
        channelno: orgId,
        cityno: cityNo,
        currentPage,
        productid,
        pageSize,
        dimensionscode,
        customersno: customersNo,
        dimensionsname: dimensionsName,
        dimensionstatus: dimensionStatus,
        maxBusinessSumSearch: {
          min: maxStartBusinessSum,
          max: maxEndBusinessSum
        },
        minBusinessSumSearch: {
          min: minStartBusinessSum,
          max: minEndBusinessSum
        },
        objectno: serialno,
        projectno: projectNo,
        tradetype: tradeType
      }
      const res = await qryProductDimensionsList(params)
      if (res.code && res.code === '00') {
        const list =
          res.result &&
          res.result.records.map(item => {
            const newitem = { ...item }
            newitem.operationOption = this.isView
              ? [{ key: 'details', label: '详情', value: true }]
              : [
                { key: 'edit', label: '修改', value: true },
                { key: 'copy', label: '复制', value: true },
                { key: 'delete', label: '删除', value: true }
              ]
            return newitem
          })
        this.$set(this, 'records', list)
        this.$set(this.pageInfo, 'total', res.result && res.result.total)
      }
    },
    // 删除维度信息
    async deleteProductDimensions() {
      const res = await delProductDimensions({ serialno: this.listSerialno })
      this.dialogDelVisible = false
      if (res && res.code === '00') {
        this.$message.success('删除成功!')
        this.getProductDimensionsList()
      }
    },
    // 维度信息复制
    async copyProductDimensions(serialno) {
      const copyDimForm = this.$refs.copyDim
      this.btnLoading = true
      copyDimForm.$refs['createForm'].validate(async valid => {
        if (valid) {
          const { productid, serialno, objecttype } = this.$parent._data
          const { newdimensionsname, olddimensionno } = copyDimForm.formValues
          const params = {
            newdimensionsname,
            objectno: serialno,
            olddimensionno,
            typeno: productid
          }
          const loading = this.$loading({
            lock: true,
            text: '正在复制,请耐心等待!',
            background: 'hsla(0,0%,100%,.9)'
          })
          setTimeout(() => {
            loading.close()
          }, 30000)
          const copyRes = await copyProductDimensions(params)
          loading.close()
          this.copyDialogVisible = false
          this.btnLoading = false
          if (!copyRes || copyRes.code !== '00') {
            return false
          }
          this.$router.push({
            name: 'dimensionEdit',
            query: {
              type: 'edit',
              objecttype,
              dimensionno: copyRes.result.dimensionno,
              objectno: copyRes.result.objectno,
              productid: copyRes.result.productid
            }
          })
        } else {
          this.$message.error('请输入新的维度名称!')
          return false
        }
      })
    },
    // 更新数据
    updateValue(value, item) {
      const { name } = item
      this.setOrGetFormInfo(name, { value })
    },
 
    // 搜索列表
    handleOnSeach() {
      const conRef = this.$refs.condRef
      this.$set(this, 'condtionValue', conRef.$refs['conform'].model)
      this.$set(this, 'pageInfo', { currentPage: 1, pageSize: 10, total: 0 })
      this.getProductDimensionsList()
    },
    // 重置
    handleOnRest(proListForm) {
      this.$set(this, 'condtionValue', {})
      // this.$set(this, 'pageInfo', { currentPage: 1, pageSize: 10, total: 0 })
      // this.getProductDimensionsList()
    },
 
    // 表单事件回调
    doAction(name, item, { key, label }) {
      const { productid, serialno, objecttype } = this.$parent._data
      const { noHistory, isShowBorder } = this
      if (key === 'details') {
        const { dimensionCode } = item
        this.$router.push({
          name: 'dimensionDetail',
          query: {
            dimensionno: dimensionCode,
            objectno: serialno,
            productid,
            objecttype,
            type: 'detail',
            isShowBorder,
            noHistory
          }
        })
        return false
      }
      if (key === 'edit') {
        const { dimensionCode } = item
        this.$router.push({
          name: 'dimensionEdit',
          query: {
            type: 'edit',
            dimensionno: dimensionCode,
            objecttype,
            objectno: serialno,
            productid
          }
        })
        return false
      }
      if (key === 'delete') {
        this.delTipContent = `请确认是否需要删除${item.dimensionCode}-${item.dimensionsName}`
        this.listSerialno = item.relativeSerialNo
        this.dialogDelVisible = true
      }
      if (key === 'copy') {
        this.copyDialogVisible = true
        this.listSerialno = item.relativeSerialNo
        setTimeout(() => {
          const copyDimForm = this.$refs.copyDim
          copyDimForm.formValues.newdimensionsname = '';
          copyDimForm.formValues.olddimensionno = item.dimensionCode
          copyDimForm.formValues.dimensionsName = item.dimensionsName
          copyDimForm.update()
        }, 10)
      }
    },
    // 修改翻页条数
    handleSizeChange(val) {
      this.pageInfo.pageSize = val
      this.getProductDimensionsList()
    },
 
    // 修改翻页数
    handleCurrentChange(val) {
      this.pageInfo.currentPage = val
      this.getProductDimensionsList()
    },
    async initProduct() {
      if (!this.$parent.serialno) {
        await this.$parent.handleSave('init', 'dimension')
        if (!this.$parent.typeno) {
          return false
        }
        return false
      }
      return true
    },
    async openAddPage() {
      const isInit = await this.initProduct()
      isInit &&
        this.$router.push({
          name: 'dimensionAdd',
          query: {
            typeno: this.$parent.typeno,
            objectno: this.$parent.serialno
          }
        })
    }
  }
}
</script>
<style lang="postcss" scoped>
.list_main {
  background: #fff;
  padding: 16px 0px 0px 20px;
  & .add-button {
    padding: 2px 0 30px 0;
  }
  & >>> .pricing_dialog {
    width: 500px;
    & .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;
        }
      }
    }
  }
  & >>> .copy_dialog {
    width: 900px !important;
    & .el-dialog__body {
      & .form_main {
        & .el-form--inline {
          & .el-form-item {
            & .el-form-item__label {
              line-height: 32px;
            }
          }
        }
      }
    }
  }
  & >>> .del_dialog {
    width: 450px !important;
    & .el-dialog__body {
      text-align: center;
    }
  }
}
</style>