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
<template>
  <div class="borrower">
    <p class="title" >
      <span></span>
      贷款合同信息
    </p>
    <div style="margin-bottom:10px;margin-top: -20px;" 
        v-if="applyInfo.phaseNo == '0060' &&  applyInfo.flowno !='CreditFlowCase'">
      <el-button size="small" type="primary" @click="genLoanContract" >重新生成</el-button>
      <el-button size="small" type="primary" @click="submit" >小贷签章</el-button>
      <el-button size="small" type="primary" @click="customerSign" >客户签章</el-button>
      <el-button size="small" type="primary" @click="refresh" >刷新</el-button>
      <el-button size="small" type="primary" @click="addContract" v-if="isAdmin" >新增</el-button>
    </div>
    <el-table stripe highlight-current-row :data="loanContactList" v-loading="loading"
      :header-cell-style="{ background: '#f5f5f5', color: '#222222' }" style="width: 100%">
      
      <el-table-column min-width="200" v-for="(item, idx) in tableColumn1" :key="idx" :prop="item.prop" :label="item.label">
          <template slot="header">
            <span>
              <span style="padding-left: 8px">{{item.label}}</span>
            </span>
          </template>
          <template slot-scope="{ row }">
            <span style="padding-left: 8px" v-show="!row.isEdit">{{
              row[item.prop]
            }}</span>
            <!-- <el-input v-if="item.prop == 'contractNo'"
              style="padding-left: 15px"
              maxlength="50"
              size="small"
              v-show="row.isEdit"
              v-model="row.contractNo"
              placeholder="请输入合同编号"
            ></el-input>
 
            <el-input v-if="item.prop == 'contractName'"
              style="padding-left: 15px"
              maxlength="50"
              size="small"
              v-show="row.isEdit"
              v-model="row.contractName"
              placeholder="请输入合同名称"
            ></el-input> -->
          </template>
      </el-table-column>
 
      <!-- <el-table-column v-for="(item, idx) in tableColumn1" :key="idx" :prop="item.prop" :label="item.label">
      </el-table-column> -->
      <el-table-column label="管理" width="330">
        <template slot-scope="scope">
          <!-- <el-link
            size="mini"
            type="primary"
            style="margin-right: 8px;"
            :underline="false"
            @click="handleSingStatus(scope.row)"
            >重新生成</el-link
          >
          <el-popover
            placement="bottom"
            popper-class="table-buttons-popover"
            trigger="hover"
            @show="
              scope.row.isSwitch = true;
              $set(loanContactList, scope.$index, scope.row);
            "
            @hide="
              scope.row.isSwitch = false;
              $set(loanContactList, scope.$index, scope.row);
            "
          >
            <div style="text-align: right; margin: 0">
              <el-link
                size="mini"
                type="primary"
                style="margin: 0 8px 0 12px;"
                :underline="false"
                :disabled="scope.row.contractBucket && scope.row.contractKey"
                @click="handleContractView(scope.$index)"
                >查看影像资料</el-link
              >
              <el-link
                size="mini"
                type="primary"
                :underline="false"
                @click="handleSignStateView(scope.row, scope.$index)"
                >查看签署状态</el-link
              >
            </div>
            <el-link
              slot="reference"
              type="primary"
              size="mini"
              :underline="false"
              >查看
              <i
                :class="[
                  { 'e
            style="margin-right: 8px;"l-icon-arrow-down': !scope.row.isSwitch },
                  { 'el-icon-arrow-up': scope.row.isSwitch }
                ]"
              ></i>
            </el-link> 
          </el-popover> -->
 
          <template v-if="!scope.row.isEdit"> 
            <el-link size="mini" type="primary" style="margin-right: 8px;" :underline="false"
              :disabled="!(scope.row.contractBucket && scope.row.contractKey)" @click="handleContractView(scope.row)">
              查看影像资料</el-link>
            <el-link size="mini" type="primary" style="margin-right: 8px;" :underline="false" @click="handleSignStateView(scope.row, scope.$index)">
              查看签署状态</el-link>
            <el-link size="mini" type="primary" style="margin-right: 8px;"  v-if="isAdmin"  @click="editContract(scope.row, scope.$index)">
              变更</el-link>
            <el-link size="mini" type="primary"  v-if="isAdmin" @click="deleteContract(scope.row, scope.$index)">
              删除</el-link>
          </template>
          <!-- <template v-else>
 
            <el-upload
              class="upload-main"
              action=""
              :headers="uploadHeader"
              :http-request="handleUpload"
              :show-file-list="false"
            >上传
            </el-upload>
            <el-button
              type="text"
              @click.native="handleSave(scope.row, scope.$index)"
              >保存</el-button
            >
            <el-button
              type="text"
              @click.native="handleCancel(scope.row, scope.$index)"
              v-if="scope.row.isCancel"
              >删除</el-button
            >
          </template> -->
          <!-- <el-link
            size="mini"
            type="primary"
            style="margin-left: 8px;"
            :underline="false"
            v-if="scope.row.signStatus == '签章失败'"
            @click="handleSingStatus(scope.row)"
            >重新生成</el-link
          > -->
        </template>
      </el-table-column>
    </el-table>
 
    <el-dialog :visible.sync="dialogTableVisible">
      <el-table :data="signStateList">
        <el-table-column v-for="(item, idx) in tableColumn2" :key="idx" :prop="item.prop" :label="item.label">
        </el-table-column>
      </el-table>
    </el-dialog>
 
    <el-dialog class="contractAddManage" center width="600px" :visible.sync="addShow" :close-on-click-modal="false" :title="title"
      @close="handleClose1" inlinel>
      <el-form label-width="100px" ref="formData" :rules="rules" :model="form">
        <el-form-item label="合同编号">
          <el-input v-model="form.contractNo" :disabled="title == '修改'"></el-input>
        </el-form-item>
        <el-form-item label="合同名称">
          <el-input v-model="form.contractName" :disabled="title == '修改'"></el-input>
        </el-form-item>
        <el-form-item label="附件" prop="fileData">
          <el-upload class="upload-main" action=""  :http-request="handleUpload"
            :show-file-list="true" :file-list="fileList">
            <el-button size="small" type="primary">点击上传</el-button>
          </el-upload>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button plain @click="handleClose1">取消</el-button>
        <el-button type="primary" @click="submitContract(form)">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
// 贷款合同信息
import {
  qryLoanContactDetail,
  submitGenLoanContract,
  genLoanContract,
  qryLoanContactList,
  sealPublicSign,
  doCustomerSign,
  syncSealResult,
  loanContactInfoAdd,
  loanContactInfoRemove,
  loanContactInfoReplace
} from "@/api/product";
import common from "@/utils/common";
import qs from 'qs'
export default {
  props: ["applyInfo"],
  data() {
    return {
      uploadHeader: {
        "Content-Type": "multipart/form-data; boundary=ReaquestHeader"
      },
      loading: false,
      addShow:false,
      loanContactList: [],
      signStateList: [],
      dialogTableVisible: false,
      haserror: false,
      fileList: [],
      form: {},
      title: '新增',
      isAdmin:false,
      rules: {
        contractNo: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
        contractName: [{ required: true, message: '请输入合同名称', trigger: 'blur' }],
        // signStatus: [{ required: true, message: '请选择签署状态', trigger: 'change' }]
      },
      tableColumn1: [
        { prop: "contractNo", label: "合同编号" },
        { prop: "contractName", label: "合同名称" },
        { prop: "startTime", label: "合同签署发起最新时间" },
        { prop: "signStatusDesc", label: "合同签署状态" }
      ],
      tableColumn2: [
        { prop: "name", label: "签章名称" },
        { prop: "phone", label: "联系方式" },
        { prop: "signTime", label: "签署时间" },
        { prop: "signUrl", label: "签署链接" },
        { prop: "signStatus", label: "签署状态" }
      ]
    };
  },
  async mounted() {
    let userInfo = localStorage.getItem('userInfo') 
    if(userInfo) {
      this.isAdmin = JSON.parse(userInfo).jobNum == 'admin'
    }
    this.loanContactList = await this.getLoanContactList();
  },
  methods: {
    getSignStatusValue(key) {
      let value;
      switch (key) {
        case "1":
          value = '待签章'
          break;
        case "2":
          value = '签章中'
          break;
        case "3":
          value = '签章成功'
          break;
        case "4":
          value = '签章失败'
          break;
      }
      return value
    },
    getSignStateValue(key) {
      let value;
      switch (key) {
        case "0":
          value = '初始化'
          break;
        case "1":
          value = '已签'
          break;
        case "2":
          value = '失败'
          break;
      }
      return value
 
    },
    async refresh() {
      this.loading = true
      const res = await syncSealResult({
        applySerialNo: this.applyInfo.serialNo
      })
      this.loading = false
      if(res.code == "00"){
        this.$message({
          type: "success",
          message: "刷新成功!"
        });
        this.loanContactList = await this.getLoanContactList('refresh');
      }
    },
 
    handleUpload(file, fileList) {
      if (file.file) {
        this.$set(this.form, 'fileData', file.file)
        this.fileList = [file.file]
        this.$nextTick(() => {
          this.$refs.formData.validateField('fileData')
        })
      }
    },
    addContract() {
      this.form = {
        applySerialNo: this.applyInfo.serialNo,
        contractNo: "",
        contractName: "",
        fileData: "",
      }
      this.rules.fileData = [{ required: true, message: '请上传合同附件', trigger: 'change' }]
      this.addShow = true
      this.title = '新增'
    },
    editContract(row) {
      this.title = '修改'
      this.form = row
      this.rules.fileData = [{ required: true, message: '请上传合同附件', trigger: 'change' }]
      this.fileList = []
      this.addShow = true
    },
    submitContract(row,index) {
      this.$refs.formData.validate(async (validate) => {
        if (!validate) return
        let formData = new FormData()
        if (!this.form.contractId) {
          formData.append("applySerialNo", this.form.applySerialNo);
          if (this.form.fileData) formData.append('file', this.form.fileData)
          formData.append('contractNo', this.form.contractNo)
          formData.append('contractName', this.form.contractName)
          await loanContactInfoAdd(formData).then(async res => {
            if (res.code === "00") {
              this.$message.success("保存成功");
              this.loanContactList = await this.getLoanContactList();
              this.handleClose1()
            }
          });
        } else {
          formData.append('id', this.form.contractId)
          if (this.form.fileData) formData.append('file', this.form.fileData)
          await loanContactInfoReplace(formData).then(async res => {
            if (res.code === "00") {
              this.$message.success("保存成功");
              this.loanContactList = await this.getLoanContactList();
              this.handleClose1()
            }
          });
        }
      })
    },
    async deleteContract(row) {
      common.comfirm("提示", "附件删除后不可恢复,请确认是否删除?", () => {
        loanContactInfoRemove({ id: row.contractId }).then(async res => {
          if (res.code === "00") {
            this.$message.success("删除成功");
            this.loanContactList = await this.getLoanContactList();
          }
        });
      });
    },
    handleClose1() {
      this.fileList = []
      this.$refs.formData.clearValidate()
      this.addShow = false
    },
    // 查看合同
    handleContractView(item) {
      const url = `${process.env.VUE_APP_API_ORIGIN}/rlc-cts/server/oss?bucket=${item.contractBucket}&ossKey=${item.contractKey}`;
      var a = document.createElement("a");
      a.setAttribute("href", url);
      a.setAttribute("target", "_blank");
      a.setAttribute("id", "openwin");
      document.body.appendChild(a);
      if (!document.getElementById("openwin")) document.body.appendChild(a);
      a.click();
      document.getElementById("openwin").remove();
    },
    // 查看签署状态
    handleSignStateView(data) {
      qryLoanContactDetail({
        contractId: data.contractId
      }).then(res => {
        res.result.map(item => {
          item.signStatus = this.getSignStateValue(item.signStatus)
        })
        this.signStateList = res.result;
        this.dialogTableVisible = true;
      });
    },
    genLoanContract() {
      this.$confirm("请确定是否重新生成此合同?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          genLoanContract({
            applySerialNo: this.applyInfo.serialNo
          }).then(async res => {
            if (res.code == "00") {
              this.$message({
                type: "success",
                message: "重新生成合同请求发送成功!"
              });
              this.loanContactList = await this.getLoanContactList();
            }
          });
        })
        .catch(() => { });
    },
    // 重新生成
    handleSingStatus(data) {
      this.$confirm("请确定是否重新生成此协议?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          submitGenLoanContract({
            contractId: data.contractId
          }).then(res => {
            res.code == "00" &&
              this.$message({
                type: "success",
                message: "重新生成成功!"
              });
          });
        })
        .catch(() => { });
    },
    async submit() {
      sealPublicSign({
        applySerialNo: this.applyInfo.serialNo
      }).then(res => {
        res.code == "00" &&
          this.$message({
            type: "success",
            message: "发起成功!"
          });
      });
    },
    async customerSign() {
      this.$confirm("请确认是否客户签章?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(async () => {
            const res = await doCustomerSign({
              applySerialNo: this.applyInfo.serialNo
            })
            if(res.code == "00") {
              this.$message({
                type: "success",
                message: "发起成功!"
              }); 
              this.loanContactList = await this.getLoanContactList();
            }
        })
        .catch(() => { });
    },
    // 查询贷款合同信息
    getLoanContactList(type) {
      return new Promise(resolve => {
        let singStatusErroe = false
        let data = {
          applySerialNo: this.applyInfo.serialNo
        }
        this.loading = true
        if(type == 'refresh') {
          data.refresh = '1'
        }
        qryLoanContactList(data).then(res => {
          res.result.map(item => {
            if (item.signStatus == '4') {
              singStatusErroe = true
            }
            // item.signStatus = this.getSignStatusValue(item.signStatus)
          })
          this.haserror = singStatusErroe
 
          this.loading = false
          
          resolve(res.result);
        });
      });
    }
  }
};
</script>