Commit c89d8dfd by 潘际乾

规则校验

parent 854557dc
......@@ -8,10 +8,10 @@ export default {
defFlag:true
}
},
// created: function () {},
created() {
mounted() {
if(!this.isInDisplay){
this.ruleWatcher()
// this.ruleWatcher()
this.changeFormValidateDisabled(true);
this.ruleCheck()
}
},
......@@ -25,7 +25,7 @@ export default {
const that = this;
Object.keys(that.defaultRules).forEach(key => {
let func = function(){
if(!that.defFlag){
if(that.defFlag){
that.defaultRules[key].apply(that)
}
}
......@@ -35,26 +35,47 @@ export default {
ruleCheck() {
if(!this.pattern)
return
const keySet = new Set(Object.keys(this.pattern).concat(Object.keys(this.checkRules)))
const keySet = new Set(Object.keys(this.pattern).concat(Object.keys(this.checkRules).concat(Object.keys(this.defaultRules))))
const res = {};
const that = this;
for (let key of keySet.keys()) {
const rule = []
if(this.pattern[key]){
rule.push(...this.pattern[key])
if(that.pattern[key]){
rule.push(...that.pattern[key])
}
if(this.checkRules[key]){
for (let j = 0; j < this.checkRules[key].length; j++) {
const check = this.checkRules[key][j];
const triggerType = that.getTriggerType(key)
if(that.checkRules[key]){
for (let j = 0; j < that.checkRules[key].length; j++) {
const check = that.checkRules[key][j];
rule.push({
validator: check.bind(this)
validator: check.bind(that),
trigger: triggerType
})
}
}
if (that.defaultRules[key]) {
rule.push({
validator: that.defaultRules[key].bind(that),
trigger: triggerType
})
}
if(rule.length > 0) {
res[key] = rule;
}
}
this.rules = res;
that.rules = res;
},
getTriggerType(prop) {
const fields = this.$refs.modelForm.fields;
for (let i = 0; i < fields.length; i++) {
const field = fields[i];
if (field.prop === prop) {
if (field.$children[1].$children[0].$el.className.startsWith("el-select")) {
return "change";
}
return "blur";
}
}
},
changeFormValidateDisabled(flag) {
const fields = this.$refs.modelForm.fields
......
......@@ -214,16 +214,16 @@ function defaultLiaallButmissig() {
}
function defaultDitpRevclauseButtxmsel() {
}
function defaultDidgrpCbsNom1Cur(newVal, oldVal)
function defaultDidgrpCbsNom1Cur(rule, value, callback)
{
const that = this;
that.model.didgrp.cbs.max.cur = newVal;
// 摘要
that.executeDefault("didgrp.rec.nam").then(res => {
that.model.didgrp.cbs.max.cur = value;
that.model.didgrp.rec.nam = res.data.didgrp_rec_nam;
})
}
function defaultDidgrpCbsNom1Amt(newVal, oldVal) {
function defaultDidgrpCbsNom1Amt(rule, value, callback) {
const that = this;
// 信用证最大金额
caculateMaxAmt(that)
......
......@@ -41,8 +41,9 @@ export default {
{type: "string", required: false, message: "必输项"},
{max: 3,message:"长度不能超过3"}
],
"didgrp.cbs.nom1.cur": [
{required: true, message: "必输项"},
],
"didgrp.cbs.nom1.amt":[
{required: true, message: "必输项"},
{max: 18,message:"整数位不能超过14位"},
......@@ -88,7 +89,7 @@ export default {
"didgrp.cbs.max.amt":[
{type: "number", required: false, message: "必输项"},
{max: 18,message:"整数位不能超过14位"},
// {max: 18,message:"整数位不能超过14位"},
{pattern: /(^\d+$)|(^\.\d{1,3}$)|(^\d+\.\d{1,3}$)/, message: "小数位不能超过3位" }
],
"didgrp.apb.pts.bankno":[
......
......@@ -54,7 +54,7 @@
<el-col :span="6">
<el-form-item label="信用证金额" prop="didgrp.cbs.nom1.cur">
<c-select v-model="model.didgrp.cbs.nom1.cur" style="width:100%" :readonly="true" placeholder="请选择Currency">
<c-select v-model="model.didgrp.cbs.nom1.cur" style="width:100%" placeholder="请选择Currency" @blur="selectBlur">
<el-option v-for="item in codes.cur" :key="item.value" :label="item.label"
:value="item.value">
</el-option>
......@@ -417,6 +417,9 @@ export default {
this.model.didgrp.ben.adrelc = data.didgrp_ben_adrelc;
this.model.didgrp.ben.pts.extkey = data.didgrp_ben_pts_extkey;
})
},
selectBlur(e) {
console.log(e)
}
},
created:function(){
......
......@@ -198,8 +198,8 @@ export default {
}
},
mounted:async function(){
this.changeFormValidateDisabled(true);
console.log("进入ditopn交易");
this.changeFormValidateDisabled(true);
let rtnmsg = await this.init()
if(rtnmsg.respCode == SUCCESS)
{
......@@ -210,10 +210,6 @@ export default {
if(this.isInDisplay){
this.restoreDisplay()
}
const that = this;
this.$nextTick(() => {
that.openWatch(false);
})
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment