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
<template>
  <div class="mask">
    <el-dialog
      width="700px"
      :visible.sync="showMask"
      :close-on-click-modal="false"
      @close="cancel"
    >
      <p slot="title">手工放款</p>
      <div>
        <el-form
          :model="formData"
          :rules="rules"
          ref="ruleForm"
          label-width="150px"
          class="demo-ruleForm"
        >
          <el-form-item class="formItem" label="客户名称" prop="acctName">
            <el-input
              v-model="formData.acctName"
              placeholder="请输入客户名称"
              style="width: 197px"
            ></el-input>
          </el-form-item>
          <el-form-item class="formItem" label="证件号码" prop="idNo">
            <el-input
              v-model="formData.idNo"
              placeholder="请输入"
              style="width: 197px"
            ></el-input>
          </el-form-item>
          <el-form-item class="formItem" label="银行" prop="bankId">
            <el-select
              v-model="formData.bankId"
              placeholder="请选择"
              clearable
              filterable
            >
              <el-option
                v-for="(item, index) in bankList"
                :key="index"
                :label="item.BANK_NAME"
                :value="item.BANK_ID"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="formItem" label="放款银行账号" prop="acctNo">
            <el-input
              v-model="formData.acctNo"
              placeholder="请输入"
              style="width: 197px"
              @blur.self="
                formData.acctNo = formatBC(formData.acctNo);
              "
            ></el-input>
          </el-form-item>
          <el-form-item class="formItem unit" label="放款金额" prop="amount">
            <span class="unit" v-show="isShowUnit">{{ unitZH }}</span>
            <el-input
              style="width: 170px"
              placeholder="请输入"
              v-model="formData.amount"
              :maxlength="15"
              @blur.self="
                formData.amount = maxNumFilter(300000);
                formData.amount = formatMoney(formData.amount);
              "
            >
              <template slot="append">元</template>
            </el-input>
          </el-form-item>
        </el-form>
        <div class="formBtn">
          <div>
            <el-button :disabled="keyed" type="primary" @click="submit('ruleForm')"
              >提交</el-button
            >
            <el-button @click="cancel">取消</el-button>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import { mapGetters, mapMutations } from "vuex";
import utils from "@/assets/js/utils.js";
 
export default {
  props: ["clickType", "bankList", "bankMap"],
  data() {
    var checkNum = (rule, value, callback) => {
      if (this.amount > 300000 || this.amount <= 0) {
        callback(new Error("请输入大于且0小于30万的数字入"));
      } else if (!this.amount) {
        callback(new Error("请输入"));
      } else {
        callback();
      }
    };
    return {
      showMask: false,
      isShowUnit: false,
      keyed: false,
      loading: null,
      amount: "",
      formData: {
        // acctName: "张三",
        // idNo: "37078119890914437X",
        amount: "",
        // bankId: "CCB",
        // acctNo: "370781198909144370",
      },
      rules: {
        acctName: [
          {
            required: true,
            message: "请输入",
            trigger: "blur",
          },
        ],
 
        idNo: [
          {
            required: true,
            message: "请输入",
            trigger: "blur",
          },
          {
            // pattern:
            //   /(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/,
            // message: "请输入合法身份证号",
            trigger: "blur",
            validator: utils.checkIdCode,
          },
        ],
        bankId: [
          {
            required: true,
            message: "请选择",
            trigger: "change",
          },
        ],
        acctNo: [
          {
            required: true,
            trigger: "blur",
            validator: utils.bankAccountValid,
          },
        ],
        amount: [
          {
            required: true,
            validator: checkNum,
          },
        ],
      },
    };
  },
  computed: {
    unitZH() {
      const { amount } = this;
 
      let num = amount.toString();
      if (num.includes(".")) {
        num = num.split(".")[0];
      }
 
      const unitMap = {2: "十",3: "百",4: "千",5: "万",6: "十万",7: "百万",8: "千万",9: "亿",10: "十亿",11: "百亿",12: "千亿",13: "万亿",14: "十万亿",15: "百万亿" };
      return unitMap[num.length];
    },
  },
  watch: {
    "formData.amount"(newValue) {
      let amount = '';
      if (!this.formData.amount.length) {
        return "";
      }
      this.formData.amount.split(",").map((item) => {
        amount += item;
      });
      amount = Number(amount);
      this.amount = amount;
      this.isShowUnit = amount.toString().split(".")[0].length > 1
 
    },
  },
  methods: {
    initData(type = "add", data) {
      data = JSON.parse(JSON.stringify(data))
      if (type != "add") {
        data.amount = this.formatMoney(data.amount);
        data.acctNo = this.formatBC(data.acctNo);
        this.formData = data
      }
      this.isShowUnit = false;
      this.showMask = true;
    },
    // 取消
    cancel() {
      this.$refs.ruleForm.resetFields();
      this.formData = { amount: "" };
      this.amount = ""
      this.showMask = false;
    },
    // 提交
    submit(formname) {
      this.$refs[formname].validate((valid) => {
        if (valid) {
          const { formData, bankMap } = this;
          this.$confirm(
            `<div class="confirm-block">
                <p><span class="label">客户名称:</span><span class="txt">${formData.acctName}</span></p>
                <p><span class="label">证件号码:</span><span class="txt">${formData.idNo}</span></p>
                <p><span class="label">银行:</span><span class="txt">${bankMap[formData.bankId]}</span></p>
                <p><span class="label">放款银行账户:</span><span class="txt">${formData.acctNo}</span></p>
                <p><span class="label">放款金额:</span><span class="txt red">${formData.amount}</span></p>
              </div>`,
            "请确认放款信息",
            {
              closeOnClickModal: false,
              dangerouslyUseHTMLString: true,
              confirmButtonText: "确定提交",
              cancelButtonText: "返回修改",
            }
          )
            .then(() => {
              if (this.keyed) return;
              this.addChannel();
            })
            .catch((action) => {
              setTimeout(() => {
                // this.showMask = true;
              }, 400);
            });
        }
      });
    },
    // 确认放款
    addChannel() {
      this.keyed = true;
      this.showLoading()
      let { formData, amount } = this;
      const acctNo = formData.acctNo.replace(/\s+/g,"")
      let params = {
        acctName: formData.acctName,
        idNo: formData.idNo,
        amount: amount,
        bankId: formData.bankId,
        acctNo: acctNo,
      };
      // let params = {
      //   acctName: '张三',
      //   idNo: '37078119890914437X',
      //   amount: '100',
      //   bankId: 'CCB',
      //   acctNo: '370781198909144370',
      // }
      // return;
      this.$http
        .post(
          "handPutout/create",
          this.clickType == "add"
            ? { ...params }
            : { ...params, id: formData.id }
        )
        .then((response) => {
          const retHeader = response.data.retHeader;
          this.keyed = false;
          this.closeLoading()
          if (retHeader.retCode === "0000") {
            this.$refs.ruleForm.resetFields();
            this.showMask = false;
            setTimeout(() => {
              this.$message.success(retHeader.retMessage);
              this.$emit("hide", true);
            }, 0);
          } else {
            this.$message.error(retHeader.retMessage);
          }
        })
        .catch((err) => {
          this.keyed = false;
          this.closeLoading()
          console.log(err);
        });
    },
    maxNumFilter(maxNum = 10000) {
      let num = this.amount;
      if (this.amount > maxNum) {
        num = maxNum;
      }
      return num.toString();
    },
    formatMoney(val) {
      val = utils.formatMoney(val);
      return val;
    },
    formatBC(val) {
      val = utils.formatBC(val);
      return val;
    },
    showLoading() {
      this.loading = this.$loading({
        background: 'rgba(0, 0, 0, 0.1)'
      });
    },
    closeLoading() {
      this.loading && this.loading.close()
    }
  },
};
</script>
 
 
<style lang="less" scoped>
.mask {
  background-color: #fff;
  padding: 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  > form {
    border-bottom: 1px solid #ccc;
    margin-bottom: 12px;
  }
  .formBtn {
    border-top: 1px solid #f5f5f5;
    width: 100%;
    // height: 30px;
    text-align: center;
    padding: 20px 0 10px;
    > div {
      display: inline-block;
      button {
        padding: 8px 20px;
      }
    }
  }
  .formItem {
    width: 100%;
    height: 50px;
    padding: 8px 0px;
    /deep/label {
      // display: inline-block;
      // width: 15%;
      // text-align: right;
      // font-size: 14px;
    }
    /deep/input {
      width: 300px;
      &::-webkit-outer-spin-button,
      &::-webkit-inner-spin-button {
        -webkit-appearance: none;
      }
    }
    input:disabled {
      background-color: #fff;
    }
    input.width {
      border: 1px solid #ccc;
      border-radius: 4px;
    }
    .unit {
      position: absolute;
      top: -20px;
      font-size: 10px;
      color: #929292;
      left: 22px;
      border-left: 1px solid #dcdcdc;
      height: 16px;
      line-height: 16px;
      padding-left: 3px;
    }
 
    &.unit {
      /deep/input {
        width: 245px;
      }
    }
  }
  .canEdit {
    border-top: 1px solid #ccc;
    padding-top: 6px;
  }
 
}
 
</style>
<style lang="less">
.confirm-block {
  p {
    margin-bottom: 6px;
  }
  .label {
    display: inline-block;
    width: 100px;
    text-align: right;
    margin-right: 4px;
    color: #828282;
  }
  .txt{
    color: #000;
    font-weight: bold;
    font-size: 16px;
  }
  .red  {
    color: red;
  }
}
</style>