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
<template>
  <el-dialog class="mask" :visible.sync="dialogVisible" width="80%" ref="dialog" @close="close">
    <div class="viewLayer">
      <h5>{{title}}</h5>
      <el-form
        :model="Data"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item class="textItem" label="支付通道" prop="channelId">
          <input
            type="text"
            v-if="!addShow"
            v-model="Data.channelName"
            class="myText"
            :disabled="selectShow&&editShow"
          />
          <el-select placeholder="请选择" v-model="Data.channelId" clearable v-if="addShow&&editShow">
            <el-option
              v-for="(item,index) in channelData"
              :key="index"
              :label="item.channelName"
              :value="item.channelId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item class="textItem" label="交易类型" prop="transType">
          <input
            type="text"
            v-if="!addShow"
            class="myText"
            v-model="Data.transType"
            :disabled="selectShow&&editShow"
          />
          <el-select placeholder="请选择" clearable v-if="addShow&&editShow" v-model="Data.transType">
            <el-option
              v-for="(item,index) in transType"
              :key="index"
              :label="item.value"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item class="textItem" label="成功率要求" prop="successRate">
          <input
            type="text"
            v-if="!selectShow"
            v-model="Data.successRate"
            class="myText"
            :disabled="!selectShow"
          />
          <el-input
            placeholder="请输入内容"
            v-model.number="Data.successRate"
            v-if="addShow || editShow"
          ></el-input>
          <span class="notes">(0至1)</span>
        </el-form-item>
        <span class="line"></span>
        <h5>通道限额</h5>
        <p>支付公司对商户接入商户号的成功订单金额限制</p>
        <el-form-item class="textItem" label="单笔限额" prop="amountPt">
          <input
            type="text"
            v-if="!selectShow"
            class="myText"
            :disabled="!selectShow"
            v-model="Data.amountPt"
          />
          <el-input placeholder="请输入内容" v-model="Data.amountPt" v-if="addShow || editShow"></el-input>
        </el-form-item>
        <el-form-item class="textItem" label="单日限额" prop="amountPd">
          <input
            type="text"
            v-if="!selectShow"
            v-model="Data.amountPd"
            class="myText"
            :disabled="!selectShow"
          />
          <el-input placeholder="请输入内容" v-model="Data.amountPd" v-if="addShow || editShow"></el-input>
        </el-form-item>
        <el-form-item class="textItem" label="单月限额" prop="amountPm">
          <input
            type="text"
            v-if="!selectShow"
            v-model="Data.amountPm"
            class="myText"
            :disabled="!selectShow"
          />
          <el-input placeholder="请输入内容" v-model="Data.amountPm" v-if="addShow || editShow"></el-input>
        </el-form-item>
        <span class="line"></span>
        <h5>通道限次</h5>
        <p>支付公司对商户接入商户号的成功订单限制</p>
        <el-form-item class="textItem" label="单日限次" prop="timesPd">
          <input
            type="text"
            v-if="!selectShow"
            v-model="Data.timesPd"
            class="myText"
            :disabled="!selectShow"
          />
          <el-input placeholder="请输入内容" v-model="Data.timesPd" v-if="addShow || editShow"></el-input>
        </el-form-item>
        <el-form-item class="textItem" label="单月限次" prop="timesPm">
          <input
            type="text"
            v-if="!selectShow"
            v-model="Data.timesPm"
            class="myText"
            :disabled="!selectShow"
          />
          <el-input placeholder="请输入内容" v-model="Data.timesPm" v-if="addShow || editShow"></el-input>
          <!-- <span class="notes">(0为不限制)</span> -->
        </el-form-item>
        <span class="line"></span>
      </el-form>
      <div class="btnGroup">
        <el-button @click="submit('ruleForm')" v-if="showBtn">提交</el-button>
        <el-button @click="cancel">取消</el-button>
      </div>
    </div>
  </el-dialog>
</template>
 
<script>
import { mapGetters } from "vuex";
 
export default {
  data() {
    var checkFloat = (rule, value, callback) => {
      if (!/^0+(?:\.\d{1,2})?$/.test(value)) {
        callback(new Error("请输入0-1之间的数字,保留两位小数"));
      } else {
        callback();
      }
    };
    var validateNumber = (rule, value, callback) => {
      if (/^[0-9]*(\.[0-9]{0,2})?$/.test(value)) {
        callback();
      } else {
        callback(new Error("请输入除数字以外的内容(小数点仅保留两位)"));
      }
    };
    var validateNumber1 = (rule, value, callback) => {
      if (/^[0-9]*$/.test(value)) {
        callback();
      } else {
        callback(new Error("请输入整数"));
      }
    };
    return {
      selectShow: true,
      showBtn: true,
      editShow: true,
      addShow: false,
      title: "",
      Data: {},
      institution: "",
      channelData: [],
      transType: [
        {
          value: "鉴权",
          id: "100"
        },
        {
          value: "代扣",
          id: "300"
        },
        {
          value: "代付",
          id: "200"
        }
      ],
      success: ["1", "2", "3", "4", "5", "6"],
      rules: {
        channelId: [
          { required: true, message: "该项为必选项", trigger: "change" }
        ],
        transType: [
          { required: true, message: "该项为必选项", trigger: "change" }
        ],
        successRate: [
          { type: "number", message: "输入内容必须为数字" },
          { validator: checkFloat, trigger: "blur" }
        ],
        amountPt: [
          {
            validator: validateNumber,
            trigger: "blur"
          }
        ],
        amountPd: [
          {
            validator: validateNumber,
            trigger: "blur"
          }
        ],
        amountPm: [
          {
            validator: validateNumber,
            trigger: "blur"
          }
        ],
        timesPd: [
          {
            validator: validateNumber1,
            trigger: "blur"
          }
        ],
        timesPm: [
          {
            validator: validateNumber1,
            trigger: "blur"
          }
        ]
      },
      dialogVisible: this.value
    };
  },
 
  props: {
    detailData: {
      type: [Object, String],
      default() {
        return {};
      }
    },
    clickType: {
      type: String,
      default: "view"
    },
 
    value: {
      type: Boolean,
      default: false
    }
  },
 
  watch: {
    value: function (n) {
      this.dialogVisible = n;
      if (n) {
        this.getClickType();
      }
    }
  },
 
  created() {
    this.getChannelData();
  },
  methods: {
    // 提交
    submit(formName) {
      for (var i = 0; i < this.detailData.length; i++) {
        if (this.Data.channelId == this.detailData[i].channelId) {
          this.Data.payCompany = this.detailData[i].payCompany;
          this.Data.companyId = this.detailData[i].companyId;
          this.Data.institution = this.detailData[i].institution;
          this.Data.institutionId = this.detailData[i].institutionId;
          this.Data.channelName = this.detailData[i].channelName;
        }
      }
      this.$anti(this.Data);
      if (this.clickType == "edit") {
        this.$refs[formName].validate(valid => {
          if (valid) {
            this.$http
              .post("/channelLimit/updateChannelLimit", this.Data)
              .then(response => {
                if (response.data.retHeader.retCode === '0000') {
                  this.$message.success("编辑成功");
                  this.close();
                } else {
                  this.$message.warning(response.data.retHeader.retMessage);
                }
              })
              .catch(err => {
                this.close();
                console.log(err);
              });
          } else {
            return false;
          }
        });
      } else if (this.clickType == "add") {
        this.$refs[formName].validate(valid => {
          if (valid) {
            this.$http
              .post("/channelLimit/addChannelLimit", this.Data)
              .then(response => {
                if (response.data.retHeader.retCode === '0000') {
                  this.$message.success("新增成功");
                  this.close();
                } else {
                  this.$message.warning(response.data.retHeader.retMessage);
                }
              })
              .catch(err => {
                this.close();
              });
          } else {
            return false;
          }
        });
      }
    },
    // 取消
    cancel() {
      this.$emit("showMask");
    },
    // 获取点击类型
    getClickType() {
      if (this.clickType == "view") {
        this.title = "查看";
        this.showBtn = false;
        this.editShow = false;
        this.selectShow = false;
        this.addShow = false;
        this.Data = this.detailData;
        this.$mapData([this.Data]);
      } else if (this.clickType == "add") {
        this.title = "新增";
        this.selectShow = true;
        this.editShow = true;
        this.showBtn = true;
        this.addShow = true;
        this.Data = {
          channelLimid: null,
          successRate: null,
          amountPt: null,
          amountPd: null,
          amountPm: null,
          timesPd: null,
          timesPm: null,
          transType: null,
          channelId: null,
          channelName: null,
          institution: null,
          payCompany: null,
          companyId: null,
          institutionId: ""
        };
      } else if (this.clickType == "edit") {
        this.title = "编辑";
        this.selectShow = true;
        this.editShow = true;
        this.showBtn = true;
        this.addShow = false;
        this.Data = this.detailData;
        this.$mapData([this.Data]);
      }
    },
    // 获取机构数据
    getChannelData() {
      this.$http
        .post("/channel/getChannels", { institutionId: "", companyId: "" })
        .then(response => {
          if (response.data.retHeader.retCode === '0000') {
            this.channelData = response.data.retBody;
          } else {
            this.$message.error(response.data.retHeader.retMessage)
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
 
    // 关闭
    close() {
      this.$refs["ruleForm"].resetFields();
      this.$emit("input", false);
    }
  }
};
</script>
 
<style lang="less" scoped>
.el-input {
  width: 217px;
  height: 40px;
}
.mask {
  width: 100%;
  height: 100%;
  z-index: 5;
  overflow: auto;
  .viewLayer {
    width: 100%;
    margin: 30px auto 0px;
    background-color: #fff;
    border-radius: 6px;
    padding: 16px;
    font-size: 14px;
    .textItem {
      height: 56px;
      width: 100%;
      padding: 8px;
      > label {
        display: inline-block;
        width: 100px;
        height: 40px;
        text-align: right;
        line-height: 40px;
      }
      .myText {
        width: 217px;
        padding: 0px 20px;
        height: 36px;
        border: none;
        outline: none;
      }
      .myText[disabled] {
        background-color: #fff;
      }
      .inputBorder {
        border: 1px solid #ccc;
        border-radius: 6px;
      }
    }
    .line {
      display: block;
      width: 100%;
      height: 1px;
      background-color: black;
    }
    > h5 {
      font-size: 18px;
      margin: 6px 0px;
    }
    .notes {
      margin-left: 8px;
    }
    .btnGroup {
      width: 160px;
      height: 72px;
      padding: 16px 0px;
      margin-left: 50%;
      transform: translateX(-60%);
    }
  }
}
</style>