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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import Vue from "vue"
import Api from "~/service/Api"
import { display } from "~/service/business/file"
import { getTrnNameByInr } from "~/service/business/common"
import Utils from "../utils"
import CodeTable from "~/config/CodeTable";
export default {
data() {
},
created() {
if (this.root) {
//非顶级vue实例,不需要执行
return;
}
if (this.codes) {
Vue.set(this.codes, "codeSet", {})
}
},
mounted() {
//this.restoreDisplay()
},
methods: {
updateValueSet(values) {
if (!values) {
return
}
//顶级实例,进入设置
if (!this.root) {
for (let key in values) {
Vue.set(this.codes.codeSet, key, values[key])
}
}
else {
this.root.updateValueSet(values)
}
},
/*
获取后台setValues、setCodeValues传来的动态码,并自动转为码表值。
key:为后端传来的CodeSet的字段path,如'bddgrp.rec.docprbrol'
tableName:src下的全局静态码表中的码表名称,如'rolall'
如后端传来的CodeSet下该字段值为"value+lable",则不用传参数tableName
如后端传来的CodeSet下该字段值仅有"value",则需传参数tableName,去全局静态码表中找到相应码表,根据value值找到lable值
*/
getValues(key, tableName) {
let arr = this.codes.codeSet && this.codes.codeSet[key]
if (!arr)
return undefined
return arr.map(item => {
let itemArr = item.split("\t")
if (itemArr.length > 1) {
return { label: itemArr[1], value: itemArr[0] }
} else {
if (tableName && CodeTable[tableName]) {
const r = CodeTable[tableName].find(code => code.value === itemArr[0])
if (r) {
return { label: r.label, value: itemArr[0] }
}
}
return { label: itemArr[0], value: itemArr[0] }
}
})
},
showBackendErrors(fieldErrors) {
// 清除之前的校验状态
if (!this.getRoot().$refs.modelForm) {
return
}
if (!this.isChecking) {
this.getRoot().$refs.modelForm.clearValidate();
} else {
// 当 checkAll 操作时,由面板切换所触发的 executeRule 请求时,不清空 checkAll 的错误信息
this.isChecking = false;
}
const fields = this.getRoot().$refs.modelForm.fields;
const tab = Utils.positioningErrorMsg(fieldErrors, fields);
return tab;
},
loading(text) {
const loading = this.$loading({
lock: true,
text,
spinner: 'el-icon-loading',
background: 'rgba(200, 200, 200, 0.3)'
});
return loading
},
getRoot() {
return (this.root || this)
},
async init(params) {
const loading = this.loading("交易加载中")
let prePageId = this.$route.params.prePageId || "";
console.log("init/prePageId:"+prePageId);
let data = { params,prePageId };
let rtnmsg = await Api.post(this.requestPrefix + "/init", data)
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
//添加pageId
if(rtnmsg.data.pageId)
window.GLOBAL_CACHE.PAGEID_CACHE.add(rtnmsg.data.pageId);
}
loading.close()
return rtnmsg
},
async save(params) {
const loading = this.loading("正在保存交易")
let rtnmsg = await Api.post(this.requestPrefix + "/saveData", this.wrapper(params))
loading.close()
return rtnmsg
},
async confirm(params) {
const loading = this.loading("正在保存交易")
let rtnmsg = await Api.post(this.requestPrefix + "/confirmData", this.wrapper(params))
loading.close()
return rtnmsg
},
async executeCheck(rulePath, params) {
const loading = this.loading("校验进行中")
let rtnmsg = await Api.post(this.requestPrefix + "/executeCheck/" + rulePath, this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
loading.close()
return rtnmsg
},
async executeDefault(rulePath, params) {
let rtnmsg = await Api.post(this.requestPrefix + "/executeDefault/" + rulePath, this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
return rtnmsg
},
async executeRule(rulePath, params, delayCb) {
const loading = this.loading("正在请求数据")
let rtnmsg = await Api.post(this.requestPrefix + "/executeRule/" + rulePath, this.wrapper(params, delayCb))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
loading.close()
return rtnmsg
},
async executeCustomRule(rulePath, params, delayCb) {
const loading = this.loading("正在请求数据")
//copy
Utils.copyCustomFromModel(this.customModel, this.model)
console.log(this.customModel)
let rtnmsg = await Api.post(this.requestPrefix + "/executeRule/" + rulePath, this.wrapperCustom(params, delayCb))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
loading.close()
return rtnmsg
},
async checkAll(params) {
const loading = this.loading("正在校验数据")
const rtnmsg = await Api.post(this.requestPrefix + "/checkAll", this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
}
loading.close()
return rtnmsg
},
async pedding(params) {
const loading = this.loading("正在暂存数据")
const rtnmsg = await Api.post(this.requestPrefix + "/pending", this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
}
loading.close()
return rtnmsg
},
async restoreDisplay() {
let inr = this.$route.query.trn
if (!inr)
return
const loading = this.loading("快照数据加载中")
let data = await display(inr)
if (data.data) {
Utils.copyValueFromVO(this.model, JSON.parse(data.data))
} else {
this.$notify.error({ title: '错误', message: '快照文件加载失败!' });
}
loading.close()
},
/**
*
* @param {Object} params 额外参数
* @param {Boolean} updateModel 是否更新model
* @returns
*/
async executeNotify(params, updateModel) {
const rtnmsg = await Api.post(this.requestPrefix + "/executeNotify", this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
if (arguments.length > 1 && arguments[1]) {
this.updateModel(rtnmsg.data)
}
}
return rtnmsg
},
/**
* 打开详情页面
* @param {string} inr
*/
display(inr) {
getTrnNameByInr({ inr }).then((res) => {
if (res.respCode == SUCCESS) {
const trnName = res.data.toLowerCase();
let viewurl = "/#/display/" + trnName + "?trn=" + inr
window.open(viewurl, 'newwindow', 'height=1500,width=1200,top=100,left=100,toolbar=no,resizable=no,menubar=no,location=no, status=no');
}
});
}
},
async beforeDestroy(){
if(!this.root && this.model && this.model.pageId){
//回收pageId
window.GLOBAL_CACHE.PAGEID_CACHE.delete(this.model.pageId);
}
}
}