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
<template>
  <div class="apply-info">   
    <CommForm
      :inline="true"
      :list="tempFormList"
      ref="basicForm"
      title="基本信息"
      @updateValue="updateValue"
      :formValues="formValues"
      :formRules="formRules"
      :formType="formType"
    >
      <!-- formType="info" -->
    </CommForm>
    <!-- <div class="tab-form-buttons" v-if="isShowFooterBtn">
      <p>
        <el-button class="comm-button" @click="$router.go(-1)">返回</el-button>
      </p>
      <p>
        <el-button class="comm-button" @click="resetForm">重置</el-button>
      </p>
      <p>
        <el-button class="comm-button" @click="checkData">核对</el-button>
      </p>
      <p>
        <el-button class="comm-button" type="primary" @click="submit" :disabled="isCheck">提交</el-button>
      </p>
    </div>-->
    <Dialog
      v-model="isShowDialog"
      icon="succ"
      iconText="提交成功"
      :buttons="[{text: '确定', type: 'primary'}]"
      @handleClick="commitSuccess"
    ></Dialog>
  </div>
</template>
<script>
import { mapMutations } from 'vuex'
import CommForm from '@/components/CommForm'
import Dialog from '@/components/Dialog'
import voucherDetailCheck from '@/controller/voucherDetailCheck' // 核对
import voucherDetailSubmit from '@/controller/voucherDetailSubmit' // 提交
import voucherDetailDetails from '@/controller/voucherDetailDetails' // 详情
import voucherDetailDelete from '@/controller/voucherDetailDelete' // 删除
// 下拉options
import queryCodeValueList from '@/controller/queryCodeValueList' // 公共下拉列表接口
import queryCodeObject from '@/controller/queryCodeObject' // 公共下拉列表接口
 
export default {
  components: {
    CommForm,
    Dialog
  },
  props: {
    conf: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      serialNo: '',
      info: {},
      query: {},
      formList: [],
      model: null,
      submitModel: null,
      detailsModel: null,
      deleteModel: null,
      isShowDialog: false,
      isCheck: true
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      let { query } = this.$route
      this.query = query
      // console.log(query)
      query = {
        ...query,
        serialNo: ''
      }
      // console.log(query)
      let model = voucherDetailCheck(query)
      this.model = model
      // this.model = queryCustomerInfoChange()
      this.checkModel = voucherDetailCheck()
      this.submitModel = voucherDetailSubmit()
      this.detailsModel = voucherDetailDetails()
      this.deleteModel = voucherDetailDelete()
      this.getDetail()
      this.setSelectOptions()
    },
    async getDetail() {
      const { query, model, detailsModel } = this
      const { command, serialNo } = query
      if (serialNo) {
        const info = await detailsModel.request({
          serialNo
        })
        info.beginAndEndDate = `${info.beginDate}-${info.endDate}`
        this.formList = model.getFormList(info)
      } else {
        this.formList = model.getFormList(command)
      }
    },
    async setSelectOptions() {
      const { formList } = this
      // formList.forEach(({ name }) => {
      formList.forEach(item => {
        if (item.name === 'checkType') {
          this.queryCodeValueList(item.name, { codeNo: 'VoucherType' })
        }
        if (item.name === 'accountingChannel') {
          this.queryCodeValueList(item.name, { codeNo: 'PutOutAccountType' })
        }
        // 支付通道回款表单信息-支付公司名称
        if (item.label === '支付公司名称') {
          this.queryCodeObject(item.name, { codeno: 'incomeAccountType' })
        }
        if (item.label === '放款账户户名') {
          this.queryCodeObjectIdent(item.name, {
            codeno: 'PutOutAccountType'
          })
        }
        if (item.label === '收款账户账号') {
          this.queryCodeObjectIdentNum(item.name, {
            codeno: 'ContraryAccountType'
          })
        }
      })
    },
 
    // 获取select中options数据
    async queryCodeValueList(name, info = {}) {
      const tempModel = queryCodeValueList()
      const { list } = await tempModel.request(info)
      this.updateValue(name, { options: list })
    },
 
    // 获取select中options数据
    async queryCodeObject(name, info = {}) {
      const tempModel = queryCodeObject()
      const { list } = await tempModel.request(info)
      let listArray = []
      list.forEach(item => {
        let obj = {}
        obj.label = item.itemname
        obj.value = item.itemname
        obj.tempValue = item.attribute4
        listArray.push(obj)
      })
      this.updateValue(name, { options: listArray })
    },
 
    async queryCodeObjectIdent(name, info = {}) {
      const tempModel = queryCodeObject()
      const { list } = await tempModel.request(info)
      let listArray = []
      list.forEach(item => {
        let obj = {}
        obj.label = item.itemname
        obj.value = item.itemname
        obj.tempValue = item.attribute1
        listArray.push(obj)
      })
      this.updateValue(name, { options: listArray })
    },
 
    async queryCodeObjectIdentNum(name, info = {}) {
      const tempModel = queryCodeObject()
      const { list } = await tempModel.request(info)
      let listArray = []
      list.forEach(item => {
        let obj = {}
        obj.label = item.attribute1
        obj.value = item.attribute1
        obj.tempValue = item.attribute3
        listArray.push(obj)
      })
      this.updateValue(name, { options: listArray })
    },
 
    // 重置表单 => 控制核对后的小类消失,基本信息可编辑
    async resetForm() {
      const { deleteModel, serialNo } = this
      if (serialNo) {
        await deleteModel.request({
          serialNo
        })
      }
      this.isCheck = true
      this.$emit('showCheck', true) // 按钮控制
      const { model } = this
      this.serialNo = ''
      this.setSerialNo(this.serialNo)
      this.setBasicInfo({})
      this.formList = model.getFormList()
      this.setSelectOptions()
    },
 
    // 核对 => 表单不可编辑,显示后面的小类信息
    // 测试用
    // async checkData() {
    //   this.isCheck = false
    //   this.serialNo = '201911051637502300597Y3M250000eb'
    //   this.$emit('showCheck', false)
    //   this.setSerialNo(this.serialNo)
    // },
 
    // 核对 => 表单不可编辑,显示后面的小类信息
    async checkData() {
      const { checkModel } = this
      // console.log(this.formList)
      const values = this.$refs.basicForm.validate()
      if (values) {
        try {
          const checkRes = await checkModel.request({
            ...values
          })
          const { serialNo } = checkRes
          this.serialNo = serialNo
          this.$emit('showCheck', false)
          this.setSerialNo(serialNo)
          this.setBasicInfo(checkRes)
          this.isCheck = false
        } catch (error) {
          this.$emit('showCheck', true)
          console.log(error)
        }
      } else {
        this.$message.warning('当前页面有数据未输入!')
      }
    },
    //  提交 => 初始不可点击/核对成功后科点击提交
    async submit() {
      const { submitModel, serialNo } = this
      await submitModel.request({
        serialNo
      })
      this.setSerialNo('')
      this.$emit('showCheck', true) // 按钮控制
      this.isShowDialog = true
    },
 
    // 提交成功后返回原列表页
    commitSuccess() {
      this.isShowDialog = false
      this.$router.go(-1)
    },
 
    // 更新表单数据
    updateValue(index, info) {
      const { formList, $route, tempFormList } = this
      const { command } = $route.query
      // console.log(index, info)
      if (isNaN(index)) {
        // index is name
        index = formList.findIndex(({ name }) => name === index)
      }
      if (!isNaN(index) && index > -1) {
        const preInfo = formList[index]
        this.$set(formList, index, { ...preInfo, ...info })
      }
      // console.log(formList[index].value)
      if (command && formList[index].name === 'checkType') {
        formList[index].value = command
        formList[index].attrs = ['disabled']
      }
      // 联动处理
      if (index === 2 && info.label === '放款账户户名') {
        const { options, value } = info
        const identifierIndex = formList.findIndex(
          item => item.name === 'identifier'
        )
        const targetIndex = options.findIndex(({ label }) => label === value)
        if (identifierIndex > -1) {
          if (value) {
            const { tempValue } = options[targetIndex]
            this.formList[identifierIndex].value = tempValue
          } else {
            this.formList[identifierIndex].value = ''
          }
        }
      }
 
      if (index === 2 && info.label === '收款账户账号') {
        const { options, value } = info
        const identifierIndex = formList.findIndex(
          item => item.name === 'institution'
        )
        const targetIndex = options.findIndex(({ label }) => label === value)
        if (identifierIndex > -1) {
          if (value) {
            const { tempValue } = options[targetIndex]
            this.formList[identifierIndex].value = tempValue
          } else {
            this.formList[identifierIndex].value = ''
          }
        }
      }
      if (info.label === '支付公司名称') {
        const { value, options } = info
        const identifierIndex = formList.findIndex(
          item => item.name === 'identifier'
        )
        const targetIndex = options.findIndex(({ label }) => label === value)
        if (identifierIndex > -1) {
          if (value) {
            const { tempValue } = options[targetIndex]
            this.formList[identifierIndex].value = tempValue
          } else {
            this.formList[identifierIndex].value = ''
          }
        }
      }
    },
    ...mapMutations(['setSerialNo', 'setBasicInfo'])
  },
  computed: {
    // 表单值信息
    formValues() {
      const { model, formList } = this
      if (model) {
        return model.getFormValues(formList)
      }
      return {}
    },
    formRules() {
      const { model, formList } = this
      if (model) {
        return model.getFormRules(formList)
      }
      return {}
    },
    tempFormList() {
      const { isCheck, formList } = this
      if (isCheck) {
        return formList
      } else {
        formList.map(item => {
          if (item.type === 'select' || item.type === 'daterange') {
            item.attrs = [...item.attrs, 'disabled']
          } else {
            if (item.attrs) {
              item.attrs =
                item.attrs.indexOf('readonly') > -1
                  ? item.attrs
                  : [...item.attrs, 'readonly']
            } else {
              item.attrs = ['readonly']
            }
          }
          item.rules = []
        })
        return formList
      }
    },
    formType() {
      const { query } = this.$route
      const { isApplyPhase } = query
      if (isApplyPhase === '2') {
        return 'text'
      } else {
        return ''
      }
    },
    isShowFooterBtn() {
      const { isApplyPhase } = this.$route.query
      if (isApplyPhase === '2') {
        return false
      } else {
        return true
      }
    }
  },
  watch: {
    $route() {
      const { transLogSerialno } = this.$route.query
      if (transLogSerialno) {
        this.init()
      }
    }
    // isCheck(val) {
    //   const { formList } = this
    //   if (!val) {
    //     formList.map(item => {
    //       if (item.attrs) {
    //         item.attrs =
    //           item.attrs.indexOf('readonly') > -1
    //             ? item.attrs
    //             : [...item.attrs, 'readonly']
    //       } else {
    //         item.attrs = ['readonly']
    //       }
    //     })
    //   }
    // }
  }
}
</script>
<style lang="postcss" scoped>
.apply-info {
}
.tab-form-buttons {
  display: flex;
  justify-content: center;
  padding: 20px 0 30px 0;
  & p {
    margin: 0 40px 0 0;
  }
  & p:last-child {
    margin-right: 0;
  }
}
</style>