cloud-web-corejs 1.0.54-dev.757 → 1.0.54-dev.759
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/jsonImport/mixins.js +350 -350
- package/src/components/langImport/mixins.js +502 -502
- package/src/components/wf/wf.js +2221 -2221
- package/src/components/xform/form-designer/designer.js +2027 -2027
- package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin.js +1774 -1774
- package/src/components/xform/form-designer/setting-panel/form-setting.vue +1553 -1553
- package/src/components/xform/form-designer/setting-panel/indexMixin.js +370 -370
- package/src/components/xform/form-designer/toolbar-panel/indexMixin.js +655 -655
- package/src/components/xform/form-render/container-item/detail-h5-item.vue +173 -173
- package/src/components/xform/form-render/container-item/detail-item.vue +287 -287
- package/src/components/xform/form-render/indexMixin.js +23 -23
- package/src/components/xform/utils/util.js +5 -5
- package/src/index.js +2 -0
- package/src/microRouter/index.js +68 -7
- package/src/store/modules/micro.js +5 -0
- package/src/store/modules/permission.js +46 -1
- package/src/views/user/home/default2.vue +1158 -1158
- package/src/views/user/login/indexMixin.js +661 -661
|
@@ -1,350 +1,350 @@
|
|
|
1
|
-
/**version-1.0*/
|
|
2
|
-
import {read, utils} from 'xlsx'
|
|
3
|
-
|
|
4
|
-
let tmixins = {};
|
|
5
|
-
var XLSX = window.XLSX || {read, utils};
|
|
6
|
-
import {
|
|
7
|
-
getToken
|
|
8
|
-
} from '../../utils/auth';
|
|
9
|
-
import { getErrorMsg } from '@base/utils/index.js'
|
|
10
|
-
|
|
11
|
-
let configUtil = {
|
|
12
|
-
baseUrl: process.env.VUE_APP_BASE_API,
|
|
13
|
-
XLSX,
|
|
14
|
-
getToken
|
|
15
|
-
};
|
|
16
|
-
// importTimer / loadingObj 原为模块级单例:两个导入弹窗并存时后者覆盖前者引用,
|
|
17
|
-
// 前一个 interval(100ms/次)与 loading 永久失控——已改为实例属性 this.importTimer / this.loadingObj
|
|
18
|
-
tmixins = {
|
|
19
|
-
name: 'excelImport',
|
|
20
|
-
props: ['param'],
|
|
21
|
-
data() {
|
|
22
|
-
return {
|
|
23
|
-
excTime: 0,
|
|
24
|
-
showImportDialog: false,
|
|
25
|
-
showImportDialog2: false,
|
|
26
|
-
falseValue: false,
|
|
27
|
-
fileRaw: false,
|
|
28
|
-
isEnd: false,
|
|
29
|
-
currentIndex: 0,
|
|
30
|
-
excelTemplate: "",
|
|
31
|
-
prefix: '/user',
|
|
32
|
-
dataSize: 0,
|
|
33
|
-
totalSuccessNum: 0,
|
|
34
|
-
totalErrorNum: 0,
|
|
35
|
-
percentageNum: 0,
|
|
36
|
-
successRows: [],
|
|
37
|
-
failRows: [],
|
|
38
|
-
oriCols: [],
|
|
39
|
-
showImportResult: false,
|
|
40
|
-
resultType: '',
|
|
41
|
-
option: {},
|
|
42
|
-
showContent: false,
|
|
43
|
-
resOption: {},
|
|
44
|
-
abc: "A"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
created() {
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
beforeDestroy() {
|
|
51
|
-
// this.clearImportTimer()
|
|
52
|
-
},
|
|
53
|
-
methods: {
|
|
54
|
-
initResGird() {
|
|
55
|
-
var that = this;
|
|
56
|
-
let tableRef = 'resGrid';
|
|
57
|
-
let resultColumns = this.param.resultColumns || [];
|
|
58
|
-
let columns = [
|
|
59
|
-
{
|
|
60
|
-
type: 'checkbox',
|
|
61
|
-
fixed: 'left',
|
|
62
|
-
width: 48,
|
|
63
|
-
resizable: false,
|
|
64
|
-
headerClassName: 'vxe-hcs',
|
|
65
|
-
className: 'vxe-hcs'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
field: '_resultContent',
|
|
69
|
-
title: this.$t1('结果'),
|
|
70
|
-
width: 250,
|
|
71
|
-
fixed: 'left',
|
|
72
|
-
slots: {
|
|
73
|
-
default: ({
|
|
74
|
-
row,
|
|
75
|
-
$rowIndex,
|
|
76
|
-
$table
|
|
77
|
-
}) => {
|
|
78
|
-
return that.handleRes(row._impReturnMsg);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
...resultColumns
|
|
83
|
-
];
|
|
84
|
-
let cCols = this.oriCols.map((oriCol, index) => {
|
|
85
|
-
let col = {
|
|
86
|
-
field: oriCol.field,
|
|
87
|
-
title: oriCol.title,
|
|
88
|
-
width: 150
|
|
89
|
-
};
|
|
90
|
-
if (index == 0) {
|
|
91
|
-
col.fixed = 'left';
|
|
92
|
-
}
|
|
93
|
-
return col;
|
|
94
|
-
});
|
|
95
|
-
columns = columns.concat(cCols);
|
|
96
|
-
|
|
97
|
-
let tableOption = {
|
|
98
|
-
vue: this,
|
|
99
|
-
tableRef: tableRef,
|
|
100
|
-
tableNameRequired: false,
|
|
101
|
-
columns: columns,
|
|
102
|
-
config: {
|
|
103
|
-
toolbarConfig: {
|
|
104
|
-
custom: false
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
|
|
110
|
-
this.resOption = opts;
|
|
111
|
-
this.$nextTick(() => {
|
|
112
|
-
let rows = this.resultType == 1 ? this.successRows : this.failRows;
|
|
113
|
-
let tDatas = rows.map((item, index) => {
|
|
114
|
-
return item;
|
|
115
|
-
});
|
|
116
|
-
this.$refs.resGrid.loadData(tDatas);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
exc() {
|
|
121
|
-
this.option = this.param;
|
|
122
|
-
this.showContent = true;
|
|
123
|
-
this.showImportDialog = true;
|
|
124
|
-
this.showImportDialog2 = false;
|
|
125
|
-
},
|
|
126
|
-
showSuccessResult() {
|
|
127
|
-
this.showImportResult = true;
|
|
128
|
-
this.resultType = 1;
|
|
129
|
-
setTimeout(() => {
|
|
130
|
-
this.$nextTick(() => {
|
|
131
|
-
this.initResGird();
|
|
132
|
-
});
|
|
133
|
-
}, 0)
|
|
134
|
-
},
|
|
135
|
-
showErrorResult() {
|
|
136
|
-
this.showImportResult = true;
|
|
137
|
-
this.resultType = 0;
|
|
138
|
-
setTimeout(() => {
|
|
139
|
-
this.$nextTick(() => {
|
|
140
|
-
this.initResGird();
|
|
141
|
-
});
|
|
142
|
-
}, 0)
|
|
143
|
-
},
|
|
144
|
-
fileChange(file) {
|
|
145
|
-
if (file) {
|
|
146
|
-
this.fileRaw = file.raw;
|
|
147
|
-
} else {
|
|
148
|
-
this.fileRaw = false;
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
dialogClose1() {
|
|
152
|
-
this.$emit("update:visiable", false);
|
|
153
|
-
this.showContent = false;
|
|
154
|
-
},
|
|
155
|
-
openImportDialog() {
|
|
156
|
-
this.showImportDialog = true;
|
|
157
|
-
},
|
|
158
|
-
confirmExport() {
|
|
159
|
-
|
|
160
|
-
},
|
|
161
|
-
async dialogPrimary1() {
|
|
162
|
-
let that = this;
|
|
163
|
-
let option = this.option;
|
|
164
|
-
let saveUrl = option.saveUrl;
|
|
165
|
-
if (!saveUrl) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (!(this.fileRaw)) {
|
|
170
|
-
this.$baseAlert(this.$t2('请上传附件', 'components.excelImport.warmMsg1'));
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
this.showImportDialog = false;
|
|
174
|
-
if (!option.onConfirm) {
|
|
175
|
-
this.showImportDialog2 = true;
|
|
176
|
-
}
|
|
177
|
-
this.$nextTick(() => {
|
|
178
|
-
this.readExcel(this.fileRaw, function (resultData) {
|
|
179
|
-
if (option.onConfirm) {
|
|
180
|
-
option.onConfirm(resultData, that.fileRaw);
|
|
181
|
-
} else {
|
|
182
|
-
that.syncDataForImport({
|
|
183
|
-
multi: false,
|
|
184
|
-
data: resultData,
|
|
185
|
-
saveUrl: saveUrl
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
});
|
|
191
|
-
},
|
|
192
|
-
dialogClose2() {
|
|
193
|
-
this.clearImportTimer();
|
|
194
|
-
this.showImportDialog2 = false;
|
|
195
|
-
this.showContent = false;
|
|
196
|
-
this.option.callback && this.option.callback();
|
|
197
|
-
},
|
|
198
|
-
dialogPrimary2() {
|
|
199
|
-
this.clearImportTimer();
|
|
200
|
-
this.showImportDialog2 = false;
|
|
201
|
-
this.showContent = false;
|
|
202
|
-
this.option.callback && this.option.callback(this.resultData);
|
|
203
|
-
},
|
|
204
|
-
async readExcel(file, callback) {
|
|
205
|
-
let that = this;
|
|
206
|
-
let option = this.option;
|
|
207
|
-
|
|
208
|
-
const fileReader = new FileReader();
|
|
209
|
-
fileReader.onload = async (ev) => {
|
|
210
|
-
var resultData;
|
|
211
|
-
try {
|
|
212
|
-
let fileContent = ev.target.result
|
|
213
|
-
callback(fileContent);
|
|
214
|
-
} catch (et) {
|
|
215
|
-
that.showContent = false;
|
|
216
|
-
console.error(et)
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
fileReader.readAsText(file, 'UTF-8');
|
|
220
|
-
},
|
|
221
|
-
syncDataForImport(opts) {
|
|
222
|
-
let showResult = this.param.showResult;
|
|
223
|
-
if (!showResult) {
|
|
224
|
-
this.dialogClose1();
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
let option = this.option
|
|
228
|
-
this.$http({
|
|
229
|
-
url: opts.saveUrl,
|
|
230
|
-
method: `post`,
|
|
231
|
-
data: {
|
|
232
|
-
data: opts.data
|
|
233
|
-
},
|
|
234
|
-
isLoading: true,
|
|
235
|
-
success: res => {
|
|
236
|
-
var successNum = 0;
|
|
237
|
-
var failNum = 0;
|
|
238
|
-
var multiRows = res.objx;
|
|
239
|
-
this.dataSize = multiRows.length;
|
|
240
|
-
for (let i = 0; i < multiRows.length; i++) {
|
|
241
|
-
let row = multiRows[i];
|
|
242
|
-
if (row.impReturnType == "success") {
|
|
243
|
-
row._impReturnMsg = this.$t1('导入成功')
|
|
244
|
-
successNum++;
|
|
245
|
-
this.successRows.push(row);
|
|
246
|
-
} else {
|
|
247
|
-
row._impReturnMsg = row.impReturnMsg
|
|
248
|
-
failNum++;
|
|
249
|
-
this.failRows.push(row);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
this.totalSuccessNum = successNum;
|
|
253
|
-
this.totalErrorNum = failNum;
|
|
254
|
-
|
|
255
|
-
if (!showResult) {
|
|
256
|
-
this.$message({
|
|
257
|
-
message: res.content,
|
|
258
|
-
type: 'success',
|
|
259
|
-
duration: 500,
|
|
260
|
-
onClose: t => {
|
|
261
|
-
option.callback && option.callback(res)
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
} else {
|
|
265
|
-
this.showImportDialog = false;
|
|
266
|
-
this.showImportDialog2 = true;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
},
|
|
272
|
-
handleRes(val) {
|
|
273
|
-
/* var content = val;
|
|
274
|
-
var text = content;
|
|
275
|
-
if (content && content.indexOf("Exception") >= 0) {
|
|
276
|
-
var index0 = content.lastIndexOf("*]");
|
|
277
|
-
if (index0 >= 0) {
|
|
278
|
-
text = content.substr(index0);
|
|
279
|
-
if (text) {
|
|
280
|
-
var index1 = text.indexOf("Exception:");
|
|
281
|
-
if (index1 >= 0) {
|
|
282
|
-
text = text.substr(index1 + 10);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
} */
|
|
287
|
-
let text = getErrorMsg(val)
|
|
288
|
-
return text;
|
|
289
|
-
},
|
|
290
|
-
exportToExcel() {
|
|
291
|
-
let str = this.resultType === 1 ? this.$t2('成功', 'components.excelImport.success') : this.$t2('失败', 'components.excelImport.fail');
|
|
292
|
-
let fileName = this.$t2('导入结果导出', 'components.excelImport.exportFileName') + '(' + str + ')';
|
|
293
|
-
let $grid = this.$refs.resGrid;
|
|
294
|
-
let columns = $grid.getColumns();
|
|
295
|
-
if (columns && columns.length) {
|
|
296
|
-
let fields = columns.filter((item, index) => {
|
|
297
|
-
return index > 0 && item.property;
|
|
298
|
-
}).map((item, index) => {
|
|
299
|
-
return item.property;
|
|
300
|
-
});
|
|
301
|
-
this.$refs.resGrid.exportData({
|
|
302
|
-
filename: fileName,
|
|
303
|
-
mode: 'all',
|
|
304
|
-
type: 'csv',
|
|
305
|
-
columns: fields
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
createImportTimer() {
|
|
310
|
-
this.excTime = 0;
|
|
311
|
-
let beginTime = new Date().getTime();
|
|
312
|
-
this.importTimer = setInterval(() => {
|
|
313
|
-
let nowTime = new Date().getTime();
|
|
314
|
-
let diffTime = (nowTime - beginTime) / 1000;
|
|
315
|
-
this.$set(this, 'excTime', this.$baseLodash.round(diffTime, 2));
|
|
316
|
-
}, 100);
|
|
317
|
-
},
|
|
318
|
-
clearImportTimer() {
|
|
319
|
-
clearInterval(this.importTimer);
|
|
320
|
-
this.importTimer = null;
|
|
321
|
-
this.loadingObj && this.loadingObj.close();
|
|
322
|
-
this.loadingObj = null;
|
|
323
|
-
},
|
|
324
|
-
async dialogPrimary3() {
|
|
325
|
-
if (!(this.fileRaw)) {
|
|
326
|
-
this.$baseAlert(this.$t2('请上传附件', 'components.excelImport.warmMsg1'));
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
let that = this;
|
|
330
|
-
let option = this.option;
|
|
331
|
-
this.loadingObj = this.$baseLoading({
|
|
332
|
-
target: document.body,
|
|
333
|
-
background: 'unset'
|
|
334
|
-
});
|
|
335
|
-
this.readExcel(this.fileRaw, function (resultData) {
|
|
336
|
-
try {
|
|
337
|
-
if (option.callback && option.callback(resultData) !== false) {
|
|
338
|
-
that.showImportDialog = false;
|
|
339
|
-
}
|
|
340
|
-
} catch (et) {
|
|
341
|
-
console.error(et);
|
|
342
|
-
}
|
|
343
|
-
setTimeout(function () {
|
|
344
|
-
that.loadingObj && that.loadingObj.close();
|
|
345
|
-
}, 200);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
export const mixins = tmixins;
|
|
1
|
+
/**version-1.0*/
|
|
2
|
+
import {read, utils} from 'xlsx'
|
|
3
|
+
|
|
4
|
+
let tmixins = {};
|
|
5
|
+
var XLSX = window.XLSX || {read, utils};
|
|
6
|
+
import {
|
|
7
|
+
getToken
|
|
8
|
+
} from '../../utils/auth';
|
|
9
|
+
import { getErrorMsg } from '@base/utils/index.js'
|
|
10
|
+
|
|
11
|
+
let configUtil = {
|
|
12
|
+
baseUrl: process.env.VUE_APP_BASE_API,
|
|
13
|
+
XLSX,
|
|
14
|
+
getToken
|
|
15
|
+
};
|
|
16
|
+
// importTimer / loadingObj 原为模块级单例:两个导入弹窗并存时后者覆盖前者引用,
|
|
17
|
+
// 前一个 interval(100ms/次)与 loading 永久失控——已改为实例属性 this.importTimer / this.loadingObj
|
|
18
|
+
tmixins = {
|
|
19
|
+
name: 'excelImport',
|
|
20
|
+
props: ['param'],
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
excTime: 0,
|
|
24
|
+
showImportDialog: false,
|
|
25
|
+
showImportDialog2: false,
|
|
26
|
+
falseValue: false,
|
|
27
|
+
fileRaw: false,
|
|
28
|
+
isEnd: false,
|
|
29
|
+
currentIndex: 0,
|
|
30
|
+
excelTemplate: "",
|
|
31
|
+
prefix: '/user',
|
|
32
|
+
dataSize: 0,
|
|
33
|
+
totalSuccessNum: 0,
|
|
34
|
+
totalErrorNum: 0,
|
|
35
|
+
percentageNum: 0,
|
|
36
|
+
successRows: [],
|
|
37
|
+
failRows: [],
|
|
38
|
+
oriCols: [],
|
|
39
|
+
showImportResult: false,
|
|
40
|
+
resultType: '',
|
|
41
|
+
option: {},
|
|
42
|
+
showContent: false,
|
|
43
|
+
resOption: {},
|
|
44
|
+
abc: "A"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
created() {
|
|
48
|
+
|
|
49
|
+
},
|
|
50
|
+
beforeDestroy() {
|
|
51
|
+
// this.clearImportTimer()
|
|
52
|
+
},
|
|
53
|
+
methods: {
|
|
54
|
+
initResGird() {
|
|
55
|
+
var that = this;
|
|
56
|
+
let tableRef = 'resGrid';
|
|
57
|
+
let resultColumns = this.param.resultColumns || [];
|
|
58
|
+
let columns = [
|
|
59
|
+
{
|
|
60
|
+
type: 'checkbox',
|
|
61
|
+
fixed: 'left',
|
|
62
|
+
width: 48,
|
|
63
|
+
resizable: false,
|
|
64
|
+
headerClassName: 'vxe-hcs',
|
|
65
|
+
className: 'vxe-hcs'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
field: '_resultContent',
|
|
69
|
+
title: this.$t1('结果'),
|
|
70
|
+
width: 250,
|
|
71
|
+
fixed: 'left',
|
|
72
|
+
slots: {
|
|
73
|
+
default: ({
|
|
74
|
+
row,
|
|
75
|
+
$rowIndex,
|
|
76
|
+
$table
|
|
77
|
+
}) => {
|
|
78
|
+
return that.handleRes(row._impReturnMsg);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
...resultColumns
|
|
83
|
+
];
|
|
84
|
+
let cCols = this.oriCols.map((oriCol, index) => {
|
|
85
|
+
let col = {
|
|
86
|
+
field: oriCol.field,
|
|
87
|
+
title: oriCol.title,
|
|
88
|
+
width: 150
|
|
89
|
+
};
|
|
90
|
+
if (index == 0) {
|
|
91
|
+
col.fixed = 'left';
|
|
92
|
+
}
|
|
93
|
+
return col;
|
|
94
|
+
});
|
|
95
|
+
columns = columns.concat(cCols);
|
|
96
|
+
|
|
97
|
+
let tableOption = {
|
|
98
|
+
vue: this,
|
|
99
|
+
tableRef: tableRef,
|
|
100
|
+
tableNameRequired: false,
|
|
101
|
+
columns: columns,
|
|
102
|
+
config: {
|
|
103
|
+
toolbarConfig: {
|
|
104
|
+
custom: false
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
|
|
110
|
+
this.resOption = opts;
|
|
111
|
+
this.$nextTick(() => {
|
|
112
|
+
let rows = this.resultType == 1 ? this.successRows : this.failRows;
|
|
113
|
+
let tDatas = rows.map((item, index) => {
|
|
114
|
+
return item;
|
|
115
|
+
});
|
|
116
|
+
this.$refs.resGrid.loadData(tDatas);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
exc() {
|
|
121
|
+
this.option = this.param;
|
|
122
|
+
this.showContent = true;
|
|
123
|
+
this.showImportDialog = true;
|
|
124
|
+
this.showImportDialog2 = false;
|
|
125
|
+
},
|
|
126
|
+
showSuccessResult() {
|
|
127
|
+
this.showImportResult = true;
|
|
128
|
+
this.resultType = 1;
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
this.$nextTick(() => {
|
|
131
|
+
this.initResGird();
|
|
132
|
+
});
|
|
133
|
+
}, 0)
|
|
134
|
+
},
|
|
135
|
+
showErrorResult() {
|
|
136
|
+
this.showImportResult = true;
|
|
137
|
+
this.resultType = 0;
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
this.$nextTick(() => {
|
|
140
|
+
this.initResGird();
|
|
141
|
+
});
|
|
142
|
+
}, 0)
|
|
143
|
+
},
|
|
144
|
+
fileChange(file) {
|
|
145
|
+
if (file) {
|
|
146
|
+
this.fileRaw = file.raw;
|
|
147
|
+
} else {
|
|
148
|
+
this.fileRaw = false;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
dialogClose1() {
|
|
152
|
+
this.$emit("update:visiable", false);
|
|
153
|
+
this.showContent = false;
|
|
154
|
+
},
|
|
155
|
+
openImportDialog() {
|
|
156
|
+
this.showImportDialog = true;
|
|
157
|
+
},
|
|
158
|
+
confirmExport() {
|
|
159
|
+
|
|
160
|
+
},
|
|
161
|
+
async dialogPrimary1() {
|
|
162
|
+
let that = this;
|
|
163
|
+
let option = this.option;
|
|
164
|
+
let saveUrl = option.saveUrl;
|
|
165
|
+
if (!saveUrl) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!(this.fileRaw)) {
|
|
170
|
+
this.$baseAlert(this.$t2('请上传附件', 'components.excelImport.warmMsg1'));
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
this.showImportDialog = false;
|
|
174
|
+
if (!option.onConfirm) {
|
|
175
|
+
this.showImportDialog2 = true;
|
|
176
|
+
}
|
|
177
|
+
this.$nextTick(() => {
|
|
178
|
+
this.readExcel(this.fileRaw, function (resultData) {
|
|
179
|
+
if (option.onConfirm) {
|
|
180
|
+
option.onConfirm(resultData, that.fileRaw);
|
|
181
|
+
} else {
|
|
182
|
+
that.syncDataForImport({
|
|
183
|
+
multi: false,
|
|
184
|
+
data: resultData,
|
|
185
|
+
saveUrl: saveUrl
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
dialogClose2() {
|
|
193
|
+
this.clearImportTimer();
|
|
194
|
+
this.showImportDialog2 = false;
|
|
195
|
+
this.showContent = false;
|
|
196
|
+
this.option.callback && this.option.callback();
|
|
197
|
+
},
|
|
198
|
+
dialogPrimary2() {
|
|
199
|
+
this.clearImportTimer();
|
|
200
|
+
this.showImportDialog2 = false;
|
|
201
|
+
this.showContent = false;
|
|
202
|
+
this.option.callback && this.option.callback(this.resultData);
|
|
203
|
+
},
|
|
204
|
+
async readExcel(file, callback) {
|
|
205
|
+
let that = this;
|
|
206
|
+
let option = this.option;
|
|
207
|
+
|
|
208
|
+
const fileReader = new FileReader();
|
|
209
|
+
fileReader.onload = async (ev) => {
|
|
210
|
+
var resultData;
|
|
211
|
+
try {
|
|
212
|
+
let fileContent = ev.target.result
|
|
213
|
+
callback(fileContent);
|
|
214
|
+
} catch (et) {
|
|
215
|
+
that.showContent = false;
|
|
216
|
+
console.error(et)
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
fileReader.readAsText(file, 'UTF-8');
|
|
220
|
+
},
|
|
221
|
+
syncDataForImport(opts) {
|
|
222
|
+
let showResult = this.param.showResult;
|
|
223
|
+
if (!showResult) {
|
|
224
|
+
this.dialogClose1();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
let option = this.option
|
|
228
|
+
this.$http({
|
|
229
|
+
url: opts.saveUrl,
|
|
230
|
+
method: `post`,
|
|
231
|
+
data: {
|
|
232
|
+
data: opts.data
|
|
233
|
+
},
|
|
234
|
+
isLoading: true,
|
|
235
|
+
success: res => {
|
|
236
|
+
var successNum = 0;
|
|
237
|
+
var failNum = 0;
|
|
238
|
+
var multiRows = res.objx;
|
|
239
|
+
this.dataSize = multiRows.length;
|
|
240
|
+
for (let i = 0; i < multiRows.length; i++) {
|
|
241
|
+
let row = multiRows[i];
|
|
242
|
+
if (row.impReturnType == "success") {
|
|
243
|
+
row._impReturnMsg = this.$t1('导入成功')
|
|
244
|
+
successNum++;
|
|
245
|
+
this.successRows.push(row);
|
|
246
|
+
} else {
|
|
247
|
+
row._impReturnMsg = row.impReturnMsg
|
|
248
|
+
failNum++;
|
|
249
|
+
this.failRows.push(row);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
this.totalSuccessNum = successNum;
|
|
253
|
+
this.totalErrorNum = failNum;
|
|
254
|
+
|
|
255
|
+
if (!showResult) {
|
|
256
|
+
this.$message({
|
|
257
|
+
message: res.content,
|
|
258
|
+
type: 'success',
|
|
259
|
+
duration: 500,
|
|
260
|
+
onClose: t => {
|
|
261
|
+
option.callback && option.callback(res)
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
} else {
|
|
265
|
+
this.showImportDialog = false;
|
|
266
|
+
this.showImportDialog2 = true;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
},
|
|
272
|
+
handleRes(val) {
|
|
273
|
+
/* var content = val;
|
|
274
|
+
var text = content;
|
|
275
|
+
if (content && content.indexOf("Exception") >= 0) {
|
|
276
|
+
var index0 = content.lastIndexOf("*]");
|
|
277
|
+
if (index0 >= 0) {
|
|
278
|
+
text = content.substr(index0);
|
|
279
|
+
if (text) {
|
|
280
|
+
var index1 = text.indexOf("Exception:");
|
|
281
|
+
if (index1 >= 0) {
|
|
282
|
+
text = text.substr(index1 + 10);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
} */
|
|
287
|
+
let text = getErrorMsg(val)
|
|
288
|
+
return text;
|
|
289
|
+
},
|
|
290
|
+
exportToExcel() {
|
|
291
|
+
let str = this.resultType === 1 ? this.$t2('成功', 'components.excelImport.success') : this.$t2('失败', 'components.excelImport.fail');
|
|
292
|
+
let fileName = this.$t2('导入结果导出', 'components.excelImport.exportFileName') + '(' + str + ')';
|
|
293
|
+
let $grid = this.$refs.resGrid;
|
|
294
|
+
let columns = $grid.getColumns();
|
|
295
|
+
if (columns && columns.length) {
|
|
296
|
+
let fields = columns.filter((item, index) => {
|
|
297
|
+
return index > 0 && item.property;
|
|
298
|
+
}).map((item, index) => {
|
|
299
|
+
return item.property;
|
|
300
|
+
});
|
|
301
|
+
this.$refs.resGrid.exportData({
|
|
302
|
+
filename: fileName,
|
|
303
|
+
mode: 'all',
|
|
304
|
+
type: 'csv',
|
|
305
|
+
columns: fields
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
createImportTimer() {
|
|
310
|
+
this.excTime = 0;
|
|
311
|
+
let beginTime = new Date().getTime();
|
|
312
|
+
this.importTimer = setInterval(() => {
|
|
313
|
+
let nowTime = new Date().getTime();
|
|
314
|
+
let diffTime = (nowTime - beginTime) / 1000;
|
|
315
|
+
this.$set(this, 'excTime', this.$baseLodash.round(diffTime, 2));
|
|
316
|
+
}, 100);
|
|
317
|
+
},
|
|
318
|
+
clearImportTimer() {
|
|
319
|
+
clearInterval(this.importTimer);
|
|
320
|
+
this.importTimer = null;
|
|
321
|
+
this.loadingObj && this.loadingObj.close();
|
|
322
|
+
this.loadingObj = null;
|
|
323
|
+
},
|
|
324
|
+
async dialogPrimary3() {
|
|
325
|
+
if (!(this.fileRaw)) {
|
|
326
|
+
this.$baseAlert(this.$t2('请上传附件', 'components.excelImport.warmMsg1'));
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
let that = this;
|
|
330
|
+
let option = this.option;
|
|
331
|
+
this.loadingObj = this.$baseLoading({
|
|
332
|
+
target: document.body,
|
|
333
|
+
background: 'unset'
|
|
334
|
+
});
|
|
335
|
+
this.readExcel(this.fileRaw, function (resultData) {
|
|
336
|
+
try {
|
|
337
|
+
if (option.callback && option.callback(resultData) !== false) {
|
|
338
|
+
that.showImportDialog = false;
|
|
339
|
+
}
|
|
340
|
+
} catch (et) {
|
|
341
|
+
console.error(et);
|
|
342
|
+
}
|
|
343
|
+
setTimeout(function () {
|
|
344
|
+
that.loadingObj && that.loadingObj.close();
|
|
345
|
+
}, 200);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
export const mixins = tmixins;
|