Commit 873e0b0c by fukai

完善setValues支持

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