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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
import Api from '~/service/Api';
import Utils from "~/utils/index"
import commonFunctions from '~/mixin/commonFunctions.js';
import operationFunc from "~/mixin/commonDepend";
export default {
mixins: [commonFunctions, operationFunc],
methods: {
file2XLSX(file) {
return new Promise(function (resolve, reject) {
// 通过FileReader对象读取文件
const reader = new FileReader()
// 读取为二进制字符串
reader.readAsBinaryString(file)
reader.onload = function (e) {
console.log(e, '读取文件成功的e');
// 获取读取文件成功的结果值
const data = e.target.result
// XLSX.read解析数据,按照type 的类型解析
const XLSX = require('xlsx')
let wb = XLSX.read(data, {
type: 'binary' // 二进制
})
console.log(wb, '---->解析后的数据')
// 存储获取到的数据
const result = []
// 工作表名称的有序列表
wb.SheetNames.forEach(sheetName => {
result.push({
// 工作表名称
sheetName: sheetName,
// 利用 sheet_to_json 方法将 excel 转成 json 数据
sheet: XLSX.utils.sheet_to_json(wb.Sheets[sheetName])
})
})
resolve(result)
}
})
},
queryOwnref() {
Api.post(`/Financing/dbeblc/getRef`, this.model).then(res => {
if (res.respCode == "AAAAAA") {
this.model.recgrp.rec.ownref = res.data;
}
});
},
async edit() {
// 前端检验
this.$refs['modelForm'].clearValidate();
this.$refs['modelForm'].validate(async (validStatic) => {
if (validStatic) {
const loading = this.loading();
this.$store.commit('setLoadingSubmit', true);
if (this.model.recpan.danlst.length == 0) {
this.$alert('至少输入一条关单信息!', '提示');
} else {
const res = await Api.post(`/Financing/dbeblc/edit`, this.model);
if (res.respCode === "AAAAAA") {
loading.close();
if (!res.fieldErrors || (res.fieldErrors && Object.keys(res.fieldErrors).length == 0)) {
this.$notify({
title: '成功',
message: '提交成功',
type: 'success',
});
this.$nextTick(() => {
this.$store.commit('delTagsArry', this.$route.path);
this.$router.back()
})
} else {
const tab = this.showBackendErrors(res.fieldErrors);
if (tab) {
// 判断校验失败的表单不属于当前的tab,则切换tab到对应报错的tab页面
if (tab.name !== this.tabVal) {
this.tabClick(tab, '1');
}
}
}
} else {
this.$notify({
title: "错误",
message: res.respMsg,
type: "error",
});
}
}
loading.close();
this.$store.commit('setLoadingSubmit', false)
} else {
// 前端校验失败
this.$notify({
title: '失败',
message: '校验失败',
type: 'error',
});
this.showFrontendErrors()
}
})
},
async init(params) {
const loading = this.loading();
const rtnmsg = await Api.post(`/${this.moduleRouter()}/${this.trnName}/init`, params);
if (rtnmsg.respCode === SUCCESS) {
loading.close();
this.model = rtnmsg.data;
} else if (rtnmsg.respCode === '400001') {
loading.close();
this.$store.commit('delTagsArry', this.$route.path);
this.$router.back()
}
},
exit() {
this.$confirm("确认退出?", "提示", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
Api.post(`/Financing/dbeblc/exit`, this.model);
this.$store.commit('delTagsArry', this.$route.path)
this.$router.back()
})
},
pend() {
const loading = this.loading('正在暂存数据');
Api.post(`/Financing/dbeblc/pend`, this.model).then((res) => {
if (res.respCode == "AAAAAA") {
loading.close();
this.$notify({
title: '成功',
message: '暂存成功',
type: 'success',
});
this.$store.commit('delTagsArry', this.$route.path)
this.$router.back()
} else {
this.$message.info(res.respMsg)
}
loading.close();
})
},
async getdbCode(codeType, uil, codeNam) {
let params = {
codeType: codeType,
uil: uil ? uil : "EN"
};
let rtnmsg = await Api.post("/manager/dic/listDicInfo", params);
if (rtnmsg.respCode === SUCCESS) {
let curList = rtnmsg.data.map(item => ({
value: item.codeValue,
label: item.codeName
}));
this.dbCodes[codeNam] = curList;
}
},
// 检核
async check() {
// 前端检验
this.$refs['modelForm'].clearValidate()
this.$refs['modelForm'].validate(async (validStatic) => {
if (validStatic) {
const loading = this.loading('正在校验数据');
this.$store.commit('setLoadingCheck', true);
if (this.model.recpan.danlst.length == 0) {
this.$alert('至少输入一条关单信息!', '提示');
} else {
const res = await Api.post(`/Financing/dbeblc/checkAll`, this.model);
if (res.respCode === SUCCESS) {
loading.close();
if (!res.fieldErrors || (res.fieldErrors && Object.keys(res.fieldErrors).length == 0)) {
// 清除之前的校验状态
this.$refs.modelForm.clearValidate();
this.$notify({
title: "成功",
message: "校验成功",
type: "success",
});
} else {
const tab = this.showBackendErrors(res.fieldErrors);
if (tab) {
// 判断校验失败的表单不属于当前的tab,则切换tab到对应报错的tab页面
if (tab.name !== this.tabVal) {
this.tabClick(tab, '1');
}
}
}
} else {
this.$notify({
title: "错误",
message: res.respMsg,
type: "error",
});
}
}
loading.close();
this.$store.commit('setLoadingCheck', false)
} else {
// 前端校验失败
this.$notify({
title: '失败',
message: '校验失败',
type: 'error',
});
this.showFrontendErrors()
}
})
},
// 前端校验失败时候,tab和Collapse组件效果处理
showFrontendErrors() {
this.$nextTick(() => {
let fields = this.$refs['modelForm'].fields;
let parentVC = null;
for (let i = 0; i < fields.length; i++) {
let fieldItem = fields[i];
if (fieldItem.validateState === 'error') {
parentVC = fieldItem;
break;
}
}
let firstErrorTab = null;
let collapsePanel = null;
// while循环找出哪个tab和Collapse中报出的校验失败
while (true) {
const vcName = parentVC.$options.componentName;
// 没有Tabs的表单
if (vcName === "ElForm") {
break;
}
if (vcName === "ElTabPane") {
firstErrorTab = parentVC;
break;
}
if (vcName === "ElCollapseItem") {
collapsePanel = parentVC;
}
parentVC = parentVC.$parent;
}
if (firstErrorTab && firstErrorTab.name !== this.tabVal) {
const tabs = firstErrorTab.$parent;
tabs.currentName = firstErrorTab.name;
}
if (collapsePanel && collapsePanel.collapse.activeNames.indexOf(collapsePanel.name) < 0) {
collapsePanel.collapse.activeNames.push(collapsePanel.name)
}
setTimeout(() => {
let isError = document.querySelectorAll('.is-error');
isError[0].scrollIntoView({
block: 'center',
behavior: 'smooth'
})
}, 0);
})
},
refreshLnelstAndCuslst() {
Api.post(`/Financing/dbeblc/calDanlst`, this.model).then((res) => {
if (res.respCode == "AAAAAA") {
if (res.data != null) {
this.model.recgrp.rec.inenum = res.data.recgrp.inelst.length;
this.model.recgrp.rec.cusnum = res.data.recgrp.cuslst.length;
this.model.recpan.totamt = res.data.recpan.totamt;
this.model.recpan.bgdamt = res.data.recpan.bgdamt;
this.model.recgrp.rec.rcvtotamt = res.data.recpan.totamt;
this.model.recgrp.rec.amt = res.data.recpan.bgdamt;
this.model.recgrp.inelst = res.data.recgrp.inelst;
this.model.recgrp.cuslst = res.data.recgrp.cuslst;
}
}
})
},
},
};