Commit 873e0b0c by fukai

完善setValues支持

parent b11b2363
......@@ -4,8 +4,15 @@ import Utils from "../utils"
export default {
data() {
return {
codeSet:{} //setvalues的接收码表
},
created(){
if(this.root){
//非顶级vue实例,不需要执行
return;
}
if(this.codes){
Vue.set(this.codes,"codeSet",{})
}
},
mounted() {
......@@ -16,13 +23,19 @@ export default {
if(!values){
return
}
for(let key in values){
Vue.set(this.codeSet,key,values[key])
//顶级实例,进入设置
if(!this.root){
for(let key in values){
Vue.set(this.codes.codeSet,key,values[key])
}
}
else{
this.root.updapteValueSet(values)
}
},
//获取后台setValues、setCodeValues传来的动态码,并自动转为码表值
getValues(key){
let arr = codeSet[key]
let arr = this.codes.codeSet[key]
if(!arr)
return undefined
return arr.map(item=>{
......@@ -33,6 +46,17 @@ export default {
return {label:itemArr[0],value:itemArr[1]}
})
},
showBackendErrors(fieldErrors){
// 清除之前的校验状态
this.getRoot().$refs.modelForm.clearValidate();
const fields = this.getRoot().$refs.modelForm.fields;
Utils.positioningErrorMsg(fieldErrors, fields);
const tab = Utils.positioningErrorMsg(fieldErrors, fields);
return tab;
},
getRoot(){
return (this.root || this)
},
async init(params) {
let rtnmsg = await Api.post(this.declareParams.trnName + "/init", { params })
if(rtnmsg.respCode == SUCCESS){
......@@ -40,6 +64,7 @@ export default {
}
return rtnmsg
},
save(params) {
return Api.post(this.declareParams.trnName + "/saveData", this.wrapper(params))
},
......@@ -47,6 +72,7 @@ export default {
let rtnmsg = await Api.post(this.declareParams.trnName+"/executeCheck/"+rulePath, this.wrapper(params))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
return rtnmsg
},
......@@ -54,6 +80,7 @@ export default {
let rtnmsg = await Api.post(this.declareParams.trnName + "/executeDefault/" + rulePath, this.wrapper(params))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
return rtnmsg
},
......@@ -61,6 +88,7 @@ export default {
let rtnmsg = await Api.post(this.declareParams.trnName + "/executeRule/" + rulePath, this.wrapper(params,delayCb))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
return rtnmsg
},
......
......@@ -51,14 +51,6 @@ export default {
});
}
},
showBackendErrors(fieldErrors){
// 清除之前的校验状态
this.$refs.modelForm.clearValidate();
const fields = this.$refs.modelForm.fields;
Utils.positioningErrorMsg(fieldErrors, fields);
const tab = Utils.positioningErrorMsg(fieldErrors, fields);
return tab;
},
// 表单校验
async handleCheck() {
let result = await this.checkAll();
......
......@@ -62,7 +62,9 @@ export default class Utils {
//给叶子元素赋值
if (tempobj) {
let leafProp = keyArr[keyArr.length - 1];
if (tempobj.hasOwnProperty(leafProp))
if (tempobj.hasOwnProperty(leafProp)
|| "pageId" == leafProp //对pageId开放判断。
)
tempobj[leafProp] = vo[key];
}
}
......
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