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
<template>
  <div class="opinion">
    <div v-for="(item,index) in opinionArr" :key="index">
      <p>
        <span></span>
        审批意见
      </p>
      <el-form :model="opinionForm[index]" :rules="rules" ref="opinionForm" size="small" label-width="165px">
        <el-form-item label="审批结果" prop="phasechoice">
          <el-select 
            v-model="opinionForm[index].phasechoice" 
            :disabled="!opinionArr[index].phasechoice.writeAble" 
            clearable 
            filterable 
            placeholder="支持输入搜索选择" 
            @change="selPhasechoice"
          >
            <el-option
              v-for="(item,index) in results"
              :key="index"
              :label="item.itemname"
              :value="item.itemno"
              :disabled="item.disabled">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="外部审批意见分类" :prop="isShow?'phaseopinion':''" v-if="showPhaseopinion">
          <el-select 
            v-model="opinionForm[index].phaseopinion" 
            :disabled="!opinionArr[index].phaseopinion.writeAble" 
            filterable 
            clearable 
            placeholder="支持输入搜索选择"
          >
            <el-option
              v-for="(item,index) in outApprovalOpinions"
              :key="index"
              :label="item.itemname"
              :value="item.itemno">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="外部审批意见" :prop="isShow?'phaseopinion2':''">
          <el-input
            type="textarea"
            :rows="10"
            maxlength="1000"
            v-model="opinionForm[index].phaseopinion2"
            :disabled="!opinionArr[index].phaseopinion2.writeAble"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="内部审批意见分类" :prop="required&&isShow?'opiniontype':''" v-if="opinionArr[index].opiniontype.visible">
          <el-select 
            v-model="opinionForm[index].opiniontype"
            :disabled="!opinionArr[index].opiniontype.writeAble" 
            clearable 
            filterable 
            placeholder="支持输入搜索选择"
           >
            <el-option
              v-for="(item,index) in insideResultApproveOpinions"
              :key="index"
              :label="item.itemname"
              :value="item.itemno">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="内部审批意见" :prop="required&&isShow?'phaseopinion3':''" v-if="opinionArr[index].phaseopinion3.visible">
          <el-input 
            type="textarea" 
            :rows="10" 
            maxlength="1000" 
            v-model="opinionForm[index].phaseopinion3" 
            :disabled="!opinionArr[index].phaseopinion3.writeAble"
          >
          </el-input>
        </el-form-item>
      </el-form>
    </div>
    <div class="fixedBtn">
      <el-button size="medium" plain @click="save(opinionForm)">保存</el-button>
      <el-button size="medium" plain @click="prevStep()">上一页</el-button>
      <el-button size="medium" type="primary" @click="submit(opinionForm)">提交</el-button>
    </div>
    <Success :visible='success' v-on:closeDialog="closeDialog"></Success>
    <Fail :visible='fail' :reason='reason' v-on:closeDialog="closeDialog"></Fail>
  </div>
</template>
<script>
import './index.styl'
import {
  qryOpinionDetailByApplySerialNo,
  qryOutOpinionCodeDetail,
  qryOutOpinionCodeList,
  getDictionaryList,
  updOpinion,
  nextSubmit,
  qryAuthStatus,
  saveFieldMarkData,
  qryProductDetail
} from '@api/product'
import Success from '../../components/Success'
import Fail from '../../components/Fail'
import { setStorage,getStorage,removeStorage } from '@/utils/storage'
import common from '@/utils/common'
export default {
  data () {
    return {
      opinionForm:[],
      opinionArr:[],
      initialArr:[],
      applyInfo:this.$store.state.product.applyInfo,
      applyMenu:this.$store.state.product.applyMenu,
      results:[],
      outApprovalOpinions:[],
      insideResultApproveOpinions:[],
      rules:{
        phasechoice:[
          { required: true, message: '请选择审批结果', trigger: 'change' },
        ],
        phaseopinion:[
          { required: true, message: '请选择外部审批意见分类', trigger: 'change' },
        ],
        opiniontype:[
          { required: true, message: '请选择内部审批意见分类', trigger: 'change' },
        ],
        phaseopinion2:[
          { required: true, message: '请输入外部审批意见', trigger: 'change' },
        ],
        phaseopinion3:[
          { required: true, message: '请输入内部审批意见', trigger: 'change' },
        ]
      },
      isShow:true,
      success:false,
      fail:false,
      showPhaseopinion:true,
      required:true,
      reason:'',
    }
  },
  watch: {
    opinionForm(options) {
      const { phasechoice } = options[0]
      if (phasechoice === '03' || phasechoice === '05') {
        // 审批结果为驳回申请人,驳回上一级时,内部审批意见非必填,否则不变
        this.required = false
      } else {
        this.required = true
      }
    },
    deep: true
  },
  async created () {
    this.$parent._data.loading = true
    // 查询审批意见列表
    const result = await this.qryOpinion()
    this.qryOpinionData(result)
    // 获取审批结果
    this.results = await this.qryOutOpinionList()
    // 案场产品判断如果是上个阶段点击拒绝驳回进来,审判结果禁选通过
    if(this.$parent._data.showCredit&&this.applyInfo.flowno == 'CreditFlowCase'){
      this.results.forEach(val => {
        if(val.itemno == '01'){
          val.disabled = true
        }
      });
    }
    // 获取内部审批意见分类下拉
    this.insideResultApproveOpinions = await this.qryDictionaryList('InsideResultApproveOpinion')
    // 获取外部审批意见分类
    if(result.phasechoice.value){
      this.outApprovalOpinions = await this.qryOutOpinionDetail(result.phasechoice.value)
      if(!this.outApprovalOpinions.length){
        this.isShow = false
      }else{
        this.isShow = true
      }
    }
    this.$parent._data.loading = false
  },
  methods: {
    // 处理数据,将数据重新排列
    qryOpinionData(result){
      this.opinionForm = []
      this.initialArr = []
      this.opinionArr = []
      this.opinionArr.push(result)
      this.opinionArr.forEach((val,index) => {
        // 将数据重新排列
        const obj = {}
        for (const key in val) {
          obj[key]=val[key].value
        }
        this.opinionForm.push(obj)
        this.initialArr.push(Object.assign({},obj))
      });
    },
    // 查询审批意见
    qryOpinion(){
      return new Promise(resolve=>{
        qryOpinionDetailByApplySerialNo({
          applySerialNo:this.applyInfo.serialNo,
          objectType:this.applyInfo.objectType
        }).then(res=>{
          resolve(res.result)
        })
      })
    },
    qryDictionaryList(code) {
      return new Promise(resolve => {
        getDictionaryList({
          codeNo: code
        }).then(res => {
          resolve(res.result);
        });
      });
    },
    // 审批结果
    qryOutOpinionList(){
      return new Promise(resolve=>{
        qryOutOpinionCodeList({
          applySerialNo: this.applyInfo.serialNo
        }).then(res=>{
          resolve(res.result)
        })
      })
    },
    // 获取审批结果进行对应操作
    async selPhasechoice(val){
      if(val == '01'){
        // 审批结果为通过时,外部审批意见非必填,否则不变
        this.isShow = false
      }else{
        this.isShow = true
      }
      if(val=='03'||val=='05'){
        // 审批结果为驳回申请人,驳回上一级时,内部审批意见非必填,否则不变
        this.required = false
      }else{
        this.required = true
      }
      if(val == 15){
        // 审批结果为取消赎楼,外部审批意见分类要隐藏
        this.showPhaseopinion = false
      }else{
        this.showPhaseopinion = true
      }
      this.opinionForm[0].phaseopinion = ''
      this.outApprovalOpinions = await this.qryOutOpinionDetail(val)
    },
    // 根据审批结果查询外部审批意见
    qryOutOpinionDetail(code){
      return new Promise(resolve=>{
        qryOutOpinionCodeDetail({
          "applySerialNo": this.applyInfo.serialNo,
          "typeCodeValue": code
        }).then(res=>{
          resolve(res.result)
        })
      })
    },
    saveOpinion(form){
      return new Promise(resolve=>{
        updOpinion(form).then(res=>{
          resolve(res)
        })
      })
    },
    submitOpinion(form){
      this.$parent._data.loading = true;
      const { applyInfo } = this
      const { ftSerialNo, serialNo, objectType, phaseNo, productID} = applyInfo
      const { phasechoice } = form
      form.ftSerialNo = ftSerialNo;
      form.objectno = serialNo;
      form.channel = '00';
      nextSubmit(form).then(async res=>{
        this.$parent._data.loading = false;
        if(res.code=='00'){
          // 打开提交成功弹窗
          this.success = true
          const isLD = ( phaseNo == '0060' || phaseNo == '0070' || phaseNo == '0080' ) && productID == 'LD'
          const isZBD = phaseNo == '0060' && productID == 'ZBD'
          const isPhasechoice = phasechoice === '03' || phasechoice === '05'
          if( ( isLD || isZBD ) && isPhasechoice ){
            const obj = {}
            obj.ftSerialNo = ftSerialNo
            obj.objectNo = serialNo
            obj.objectType = objectType
            obj.phaseNo = phaseNo
            obj.opinionCode = form.phasechoice
            const res = await saveFieldMarkData(obj)
            const { code } = res
            if(code == '00'){
              removeStorage(`${serialNo}`)
            }
          }
        }else{
          // 审批意见提交失败
          this.reason = res.msg
          this.fail = true
        }
      })
    },
    // 保存
    async save(arr){
      const { applyInfo } = this
      arr[0].serialno = applyInfo.ftSerialNo;
      arr[0].objectno = applyInfo.serialNo;
      this.$parent._data.loading = true
      const res = await this.saveOpinion(arr[0])
      if(res.code == '00'){
        this.$message.success('保存成功')
      }
      this.$parent._data.loading = false
    },
    // 提交
    submit(arr){
      this.$refs.opinionForm[0].validate(async valid => {
        if (valid) {
          const { phaseNo, serialNo, customerid, customerName, amountloan, businesssum, flowno, productID } = this.applyInfo
          const { phasechoice } = arr[0]
          // 当前节点是面签且审批结果为通过的时候,需要查询用户是否认证
          if(phaseNo=='0100'&&!this.isShow){
            // this.$parent._data.loading = true
            // const { code, result } = await qryAuthStatus({
            //   applySerialno: serialNo,
            //   customerId: customerid
            // })
            // this.$parent._data.loading = false
            // if(code=='00'){
            //   let msg = ''
            //   if(result.carrierState!=2||result.carrierState!=4){
            //     msg += msg ? ',运营商认证':'运营商认证'
            //   }
            //   if(result.taobaoState!=2||result.taobaoState!=4){
            //     msg += msg ? ',淘宝认证':'淘宝认证'
            //   }
            //   if(result.jdState!=2||result.jdState!=4){
            //     msg += msg ? ',京东认证':'京东认证'
            //   }
            //   if(result.chiscState!=2||result.chiscState!=4){
            //     msg += msg ? ',学信网学历认证':'学信网学历认证'
            //   }
            //   common.comfirm('提示',`${msg}未完成,可能影响客户贷款申请审批,是否继续?`,()=>{
            //     this.submitOpinion(arr[0])
            //   })
            // }
            this.submitOpinion(arr[0])
          }else if (phaseNo=='0130'){
            // 财务放款阶段提交先弹框确认
            common.comfirm('提示',`请确认是否需要提交放款,客户名: ${customerName},放款金额: ${amountloan},是否继续?`,()=>{
              this.submitOpinion(arr[0])
            })
          }else if (
            (phaseNo == "0060" || phaseNo == "0070" || phaseNo == "0080") && 
            (flowno == 'CreditFlowCase' || flowno == 'CreditFlowCommon' ) &&
            phasechoice == 1
          ){
            const { result } = await qryProductDetail({
              productCode: productID,
              applySerialno: serialNo
            })
            const { productRemanentAmt, mergeCreditLoan } = result
            if( parseInt(businesssum) > parseInt(productRemanentAmt) && mergeCreditLoan == 1){
              common.comfirm(
                "提示",
                `申请单的“贷款金额”【${ this.formatMoney(businesssum) }】大于 “产品剩余可用额度”【${ this.formatMoney(productRemanentAmt) }】,请确认是否继续提交?`,
                () => {
                  this.submitOpinion(arr[0])
                }
              );
            }else{
              this.submitOpinion(arr[0])
            }
          }else{
            this.submitOpinion(arr[0])
          }
        } else {
          return false;
        }
      });
    },
    // 金额格式化
    formatMoney(value) {
      if (value) {
        value =
          parseFloat((value + "").replace(/[^\d\.-]/g, "")).toFixed(2) + "";
        if (value == "NaN") return;
        let l = value
          .split(".")[0]
          .split("")
          .reverse();
        let r = value.split(".")[1];
        let t = "";
        for (let i = 0; i < l.length; i++) {
          t += l[i] + ((i + 1) % 3 === 0 && i + 1 !== l.length ? "," : "");
        }
        return (
          t
            .split("")
            .reverse()
            .join("") +
          "." +
          r
        );
      }
    },
    // 上一页
    prevStep(){
      this.applyMenu.forEach((val,index) => {
        if(val.tabname=='审批意见'){
          common.tabInfo(this.applyMenu[index-1].tabname,this.applyInfo.flowno,this)
        }
      });
    },
    closeDialog(state){
      this.success = state
      this.fail = state
    }
  },
  components: {
    Success,
    Fail
  }
}
</script>