Commit c89d8dfd by 潘际乾

规则校验

parent 854557dc
...@@ -8,10 +8,10 @@ export default { ...@@ -8,10 +8,10 @@ export default {
defFlag:true defFlag:true
} }
}, },
// created: function () {}, mounted() {
created() {
if(!this.isInDisplay){ if(!this.isInDisplay){
this.ruleWatcher() // this.ruleWatcher()
this.changeFormValidateDisabled(true);
this.ruleCheck() this.ruleCheck()
} }
}, },
...@@ -25,7 +25,7 @@ export default { ...@@ -25,7 +25,7 @@ export default {
const that = this; const that = this;
Object.keys(that.defaultRules).forEach(key => { Object.keys(that.defaultRules).forEach(key => {
let func = function(){ let func = function(){
if(!that.defFlag){ if(that.defFlag){
that.defaultRules[key].apply(that) that.defaultRules[key].apply(that)
} }
} }
...@@ -35,26 +35,47 @@ export default { ...@@ -35,26 +35,47 @@ export default {
ruleCheck() { ruleCheck() {
if(!this.pattern) if(!this.pattern)
return 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 res = {};
const that = this;
for (let key of keySet.keys()) { for (let key of keySet.keys()) {
const rule = [] const rule = []
if(this.pattern[key]){ if(that.pattern[key]){
rule.push(...this.pattern[key]) rule.push(...that.pattern[key])
} }
if(this.checkRules[key]){ const triggerType = that.getTriggerType(key)
for (let j = 0; j < this.checkRules[key].length; j++) { if(that.checkRules[key]){
const check = this.checkRules[key][j]; for (let j = 0; j < that.checkRules[key].length; j++) {
const check = that.checkRules[key][j];
rule.push({ 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) { if(rule.length > 0) {
res[key] = rule; 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) { changeFormValidateDisabled(flag) {
const fields = this.$refs.modelForm.fields const fields = this.$refs.modelForm.fields
......
...@@ -214,16 +214,16 @@ function defaultLiaallButmissig() { ...@@ -214,16 +214,16 @@ function defaultLiaallButmissig() {
} }
function defaultDitpRevclauseButtxmsel() { function defaultDitpRevclauseButtxmsel() {
} }
function defaultDidgrpCbsNom1Cur(newVal, oldVal) function defaultDidgrpCbsNom1Cur(rule, value, callback)
{ {
const that = this; const that = this;
that.model.didgrp.cbs.max.cur = newVal;
// 摘要 // 摘要
that.executeDefault("didgrp.rec.nam").then(res => { that.executeDefault("didgrp.rec.nam").then(res => {
that.model.didgrp.cbs.max.cur = value;
that.model.didgrp.rec.nam = res.data.didgrp_rec_nam; that.model.didgrp.rec.nam = res.data.didgrp_rec_nam;
}) })
} }
function defaultDidgrpCbsNom1Amt(newVal, oldVal) { function defaultDidgrpCbsNom1Amt(rule, value, callback) {
const that = this; const that = this;
// 信用证最大金额 // 信用证最大金额
caculateMaxAmt(that) caculateMaxAmt(that)
......
...@@ -41,8 +41,9 @@ export default { ...@@ -41,8 +41,9 @@ export default {
{type: "string", required: false, message: "必输项"}, {type: "string", required: false, message: "必输项"},
{max: 3,message:"长度不能超过3"} {max: 3,message:"长度不能超过3"}
], ],
"didgrp.cbs.nom1.cur": [
{required: true, message: "必输项"},
],
"didgrp.cbs.nom1.amt":[ "didgrp.cbs.nom1.amt":[
{required: true, message: "必输项"}, {required: true, message: "必输项"},
{max: 18,message:"整数位不能超过14位"}, {max: 18,message:"整数位不能超过14位"},
...@@ -88,7 +89,7 @@ export default { ...@@ -88,7 +89,7 @@ export default {
"didgrp.cbs.max.amt":[ "didgrp.cbs.max.amt":[
{type: "number", required: false, message: "必输项"}, {type: "number", required: false, message: "必输项"},
{max: 18,message:"整数位不能超过14位"}, // {max: 18,message:"整数位不能超过14位"},
{pattern: /(^\d+$)|(^\.\d{1,3}$)|(^\d+\.\d{1,3}$)/, message: "小数位不能超过3位" } {pattern: /(^\d+$)|(^\.\d{1,3}$)|(^\d+\.\d{1,3}$)/, message: "小数位不能超过3位" }
], ],
"didgrp.apb.pts.bankno":[ "didgrp.apb.pts.bankno":[
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<el-col :span="6"> <el-col :span="6">
<el-form-item label="信用证金额" prop="didgrp.cbs.nom1.cur"> <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" <el-option v-for="item in codes.cur" :key="item.value" :label="item.label"
:value="item.value"> :value="item.value">
</el-option> </el-option>
...@@ -417,6 +417,9 @@ export default { ...@@ -417,6 +417,9 @@ export default {
this.model.didgrp.ben.adrelc = data.didgrp_ben_adrelc; this.model.didgrp.ben.adrelc = data.didgrp_ben_adrelc;
this.model.didgrp.ben.pts.extkey = data.didgrp_ben_pts_extkey; this.model.didgrp.ben.pts.extkey = data.didgrp_ben_pts_extkey;
}) })
},
selectBlur(e) {
console.log(e)
} }
}, },
created:function(){ created:function(){
......
...@@ -198,8 +198,8 @@ export default { ...@@ -198,8 +198,8 @@ export default {
} }
}, },
mounted:async function(){ mounted:async function(){
this.changeFormValidateDisabled(true);
console.log("进入ditopn交易"); console.log("进入ditopn交易");
this.changeFormValidateDisabled(true);
let rtnmsg = await this.init() let rtnmsg = await this.init()
if(rtnmsg.respCode == SUCCESS) if(rtnmsg.respCode == SUCCESS)
{ {
...@@ -210,10 +210,6 @@ export default { ...@@ -210,10 +210,6 @@ export default {
if(this.isInDisplay){ if(this.isInDisplay){
this.restoreDisplay() this.restoreDisplay()
} }
const that = this;
this.$nextTick(() => {
that.openWatch(false);
})
} }
else 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