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
<template>
  <div class="apply-info">
    <CommForm
      :inline="true"
      :column="1"
      :list="formList"
      @updateValue="updateValue"
      ref="opiniopForm"
      :formValues="formValues"
      :formRules="formRules"
      title="审批意见"
      formType="info"
    ></CommForm>
    <Dialog
      v-model="isShowDialog"
      icon="succ"
      iconText="提交成功"
      :buttons="[{text: '确定', type: 'primary'}]"
      @handleClick="commitSuccess"
    ></Dialog>
  </div>
</template>
<script>
// 审批意见
import { mapState } from 'vuex'
import CommForm from '@/components/CommForm'
import Dialog from '@/components/Dialog'
import queryCodeValueList from '@/controller/queryCodeValueList'
import queryApproveOpinionInfo from '@/controller/queryApproveOpinionInfo'
import approveSubmit from '@/controller/approveSubmit'
import submitCommon from '@/controller/submitCommon'
import publicSubmit from '@/controller/publicSubmit'
import loanCancelClaimSubmit from '@/controller/loanCancelClaimSubmit'
import approveSubmitDiscountInvoice from '@/controller/approveSubmitDiscountInvoice'
import submitDiscountInvoice from '@/controller/submitDiscountInvoice'
 
export default {
  components: {
    CommForm,
    Dialog
  },
  props: {
    conf: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      info: {},
      query: {},
      formList: [],
      invoiceRequiredItems: [],
      detailModel: null,
      model: null,
      selectModel: null,
      isShowDialog: false
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      const { query } = this.$route
      this.query = query
      const { pageId, transCode } = this.query
      this.selectModel = queryCodeValueList()
      this.detailModel = queryApproveOpinionInfo()
      // 开票基本信息必填项
      this.invoiceRequiredItems = submitDiscountInvoice({ pageId, transCode })
        .getFormList()
        .filter(({ rules = [] }) =>
          rules.some(rule =>
            typeof rule === 'object' ? rule.required : rule === 'required'
          )
        )
        .map(({ name, label }) => ({ name, label }))
      let model = null
      if (pageId === '30' || pageId === '35') {
        model = submitCommon()
      }
 
      if (pageId === '36' || pageId === '62') {
        model = publicSubmit()
      }
 
      if (pageId === '60') {
        model = loanCancelClaimSubmit()
      }
 
      if (pageId === '101' || pageId === '102') {
        model = approveSubmitDiscountInvoice()
      }
 
      if (!model) {
        model = approveSubmit()
      }
 
      this.model = model
 
      this.getDetail()
    },
    async getDetail() {
      const { query, detailModel } = this
      const { transLogSerialno } = query
      const info = await detailModel.request({
        transLogSerialno
      })
      this.info = { ...info }
      this.setForm(info)
    },
 
    setForm(initValue) {
      const { model, conf } = this
      const formList = model.getFormList(initValue)
      const { edit } = conf
      if (edit === 'Y') {
        this.formList = formList
        // this.formRules = model.getFormRules()
        // this.model = model
        this.setSelectOptions()
      } else {
        this.formList = formList.map(item => ({ ...item, type: 'text' }))
      }
    },
 
    // 更新表单数据
    updateValue(index, info) {
      const { formList } = this
      if (isNaN(index)) {
        // index is name
        index = formList.findIndex(({ name }) => name === index)
      }
      const approveOpinionIndex = formList.findIndex(
        ({ name }) => name === 'approveOpinion'
      )
      if (!isNaN(index) && index > -1) {
        const preInfo = formList[index]
        this.$set(formList, index, { ...preInfo, ...info })
 
        if (preInfo.name === 'approveCode' && approveOpinionIndex > -1) {
          const tempItem = formList[approveOpinionIndex] || {}
          let { rules = [] } = tempItem
 
          rules = rules.filter(
            item =>
              (typeof item === 'string' && item !== 'required') ||
              (typeof item === 'object' &&
                !Object.keys(item).includes('required'))
          )
 
          if (info.value === '01') {
            rules = [...rules]
          } else {
            rules = [...rules, 'required']
          }
          this.$set(formList, approveOpinionIndex, { ...tempItem, rules })
        }
      }
    },
 
    // 表单按钮事件处理
    async submit() {
      const {
        model,
        query,
        info,
        conf,
        trxnbrArray,
        invoiceInfo,
        refundApplicationInfo,
        invoiceRequiredItems
      } = this
      const { edit } = conf
      if (edit !== 'Y') {
        return false
      }
      const {
        transLogSerialno,
        transCode,
        pageId,
        objectNo,
        objectType,
        phaseNo,
        transCodeOne,
        stageNum
      } = query
      const values = this.$refs.opiniopForm.validate()
      if (values) {
        // const loading = this.$loading({
        //   fullscreen: true
        // })
 
        let baseInfo = {
          ...values,
          objectNo,
          objectType,
          transCode,
          phaseNo
        }
 
        if (pageId === '60' && trxnbrArray.length === 0) {
          this.$message.warning('认领流水为空,请选择待认领银行流水!')
          return false
        }
 
        if (pageId === '35') {
          baseInfo = {
            ...baseInfo,
            objectType: 'TransactionApply',
            transCode: transCodeOne
          }
        }
 
        if (pageId === '60') {
          baseInfo.trxnbrArray = trxnbrArray
        }
        if (pageId === '101' || pageId === '102') {
          const noRequireItem = invoiceRequiredItems.find(
            ({ name }) => !invoiceInfo[name] || invoiceInfo[name] === ''
          )
          if (noRequireItem) {
            this.$message.warning(`请先输入${noRequireItem.label}`)
            return false
          }
          baseInfo = {
            ...baseInfo,
            ...invoiceInfo
          }
        }
 
        if (parseInt(stageNum) === 3) {
          baseInfo = {
            ...baseInfo,
            refundtWay: refundApplicationInfo.refundType,
            name: refundApplicationInfo.name,
            accountType: refundApplicationInfo.accountingChannel,
            accountNo: refundApplicationInfo.accountNo
          }
        }
 
        try {
          await model.request({
            ...info,
            logSerialno: transLogSerialno,
            ...baseInfo
          })
 
          this.isShowDialog = true
          // this.getDetail()
          // loading.close()
        } catch (e) {
          // loading.close()
        }
      } else {
        // this.$message.warning('当前页面存在必填项未录入或数据录取错误,请检查!')
      }
    },
 
    // 设置表单下拉菜单
    setSelectOptions() {
      const { formList, query } = this
      const { pageId } = query
      formList.forEach(({ name, attrs = [] }) => {
        if (
          attrs.some(
            item =>
              (typeof item === 'object' && item.readonly) || item === 'readonly'
          )
        ) {
          return false
        }
        if (name === 'approveCode') {
          this.queryCodeValueList(
            name,
            pageId === '60'
              ? 'ChannelApplicationResult_dkcx'
              : 'ChannelApplicationResult'
          )
        }
      })
    },
 
    // 贷后交易名称下拉列表
    async queryCodeValueList(name, codeNo) {
      const { selectModel } = this
      const { list } = await selectModel.request({ codeNo })
      this.updateValue(name, { options: list })
    },
 
    // 提交成功后返回原列表页
    commitSuccess() {
      this.isShowDialog = false
      this.$router.go(-1)
    }
  },
  computed: {
    // 表单值信息
    formValues() {
      const { model, formList } = this
      return model ? model.getFormValues(formList) : {}
    },
    formRules() {
      const { model, formList } = this
      return model.getFormRules(formList)
    },
    ...mapState({
      invoiceInfo: state => state.tabsModule.invoiceInfo,
      trxnbrArray: state => state.tabsModule.trxnbrArray,
      refundApplicationInfo: state => state.tabsModule.refundApplicationInfo
    })
  },
  watch: {
    $route() {
      const { transLogSerialno, objectNo } = this.$route.query
      if (transLogSerialno) {
        this.init()
      }
      if (objectNo) {
        this.init()
      }
    }
  }
}
</script>
<style lang="postcss" scoped>
.apply-info {
}
</style>