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
import Vue from "vue"
import Api from "~/service/Api"
import Utils from "../utils"
export default {
data() {
},
created(){
if(this.root){
//非顶级vue实例,不需要执行
return;
}
if(this.codes){
Vue.set(this.codes,"codeSet",{})
}
},
mounted() {
//this.restoreDisplay()
},
methods: {
updapteValueSet(values){
if(!values){
return
}
//顶级实例,进入设置
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 = this.codes.codeSet[key]
if(!arr)
return undefined
return arr.map(item=>{
let itemArr = item.split("\t")
if(itemArr.length > 1)
return {label:item,value:itemArr[0]}
else
return {label:itemArr[0],value:itemArr[0]}
})
},
showBackendErrors(fieldErrors){
// 清除之前的校验状态
if(!this.getRoot().$refs.modelForm){
return
}
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){
this.updapteValueSet(rtnmsg.codeSet)
}
return rtnmsg
},
save(params) {
return Api.post(this.declareParams.trnName + "/saveData", this.wrapper(params))
},
async executeCheck(rulePath,params){
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
},
async executeDefault(rulePath, params) {
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
},
async executeRule(rulePath, params,delayCb) {
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
},
async checkAll(params) {
const rtnmsg = await Api.post(this.declareParams.trnName + "/checkAll", this.wrapper(params))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
}
return rtnmsg
},
pedding(params) {
return Api.post(this.declareParams.trnName + "/pending", this.wrapper(params))
},
async restoreDisplay() {
let inr = this.$route.query.trn
if (!inr)
return
let data = await Api.post("display/" + inr)
Utils.copyValueFromVO(this.model, JSON.parse(data.data))
},
async executeNotify(params) {
const rtnmsg = await Api.post(this.declareParams.trnName + "/executeNotify", this.wrapper(params))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
}
return rtnmsg
},
}
}