three-trees-ui 1.0.65 → 1.0.66
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/lib/three-trees-ui.common.js +1234 -732
- package/lib/three-trees-ui.css +1 -1
- package/lib/three-trees-ui.umd.js +1234 -732
- package/lib/three-trees-ui.umd.min.js +1 -1
- package/package.json +1 -1
- package/packages/File/src/main.vue +3 -1
- package/packages/Subtable/src/SubExportDialog.vue +90 -1
- package/packages/Subtable/src/SubImportDialog.vue +169 -8
- package/src/directive/formulas.js +1 -1
- package/src/mixins/onlineSubtable.js +301 -0
- package/src/services/SubPagination.js +40 -1
- package/src/utils.js +32 -1
package/package.json
CHANGED
|
@@ -317,7 +317,9 @@
|
|
|
317
317
|
if (
|
|
318
318
|
file.name &&
|
|
319
319
|
this.accept &&
|
|
320
|
-
!this.accept
|
|
320
|
+
!this.accept
|
|
321
|
+
.split(',')
|
|
322
|
+
.includes(file.name.split('.')[file.name.split('.').length - 1])
|
|
321
323
|
) {
|
|
322
324
|
this.$message('请选择规定范围的文件进行上传!')
|
|
323
325
|
return false
|
|
@@ -35,6 +35,16 @@
|
|
|
35
35
|
type: String,
|
|
36
36
|
default: '子表数据',
|
|
37
37
|
},
|
|
38
|
+
exportMaxRow: {
|
|
39
|
+
type: [String, Number],
|
|
40
|
+
},
|
|
41
|
+
exportField: {
|
|
42
|
+
// 禁止导出的字段集合
|
|
43
|
+
type: String,
|
|
44
|
+
},
|
|
45
|
+
exportFieldTransformData: {
|
|
46
|
+
type: String,
|
|
47
|
+
},
|
|
38
48
|
},
|
|
39
49
|
computed: {
|
|
40
50
|
columns: function() {
|
|
@@ -47,6 +57,44 @@
|
|
|
47
57
|
}
|
|
48
58
|
},
|
|
49
59
|
methods: {
|
|
60
|
+
async sqlChange(config, value = '') {
|
|
61
|
+
return new Promise((resolve) => {
|
|
62
|
+
let params = {
|
|
63
|
+
dsName: config.dataSource,
|
|
64
|
+
sql: config.relevancyValue
|
|
65
|
+
? config.relevancyValue.replace(/{val}/g, value)
|
|
66
|
+
: '',
|
|
67
|
+
}
|
|
68
|
+
this.$requestConfig.getValueBySql(params).then((res) => {
|
|
69
|
+
resolve(res)
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
transformFieldData(data) {
|
|
74
|
+
return new Promise(async (resolve) => {
|
|
75
|
+
let fieldTransformData = JSON.parse(
|
|
76
|
+
decode(this.exportFieldTransformData)
|
|
77
|
+
)
|
|
78
|
+
for (let i = 0; i < data.length; i++) {
|
|
79
|
+
for (let j = 0; j < fieldTransformData.length; j++) {
|
|
80
|
+
if (fieldTransformData[j].relevancyType == 'value') {
|
|
81
|
+
data[i][fieldTransformData[j].field] =
|
|
82
|
+
fieldTransformData[j].relevancyValue
|
|
83
|
+
} else {
|
|
84
|
+
// 动态时 请求接口修改数据
|
|
85
|
+
let result = await this.sqlChange(
|
|
86
|
+
fieldTransformData[j],
|
|
87
|
+
data[i][fieldTransformData[j].field]
|
|
88
|
+
)
|
|
89
|
+
if (result) {
|
|
90
|
+
data[i][fieldTransformData[j].field] = result
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
resolve(data)
|
|
96
|
+
})
|
|
97
|
+
},
|
|
50
98
|
// 配置的数据字典 导出时翻译为汉字
|
|
51
99
|
changeDictionary(data) {
|
|
52
100
|
return new Promise(async (resolve, reject) => {
|
|
@@ -76,10 +124,18 @@
|
|
|
76
124
|
},
|
|
77
125
|
changeRowKey(rows) {
|
|
78
126
|
var exportData = []
|
|
127
|
+
let exportFieldArr = null
|
|
128
|
+
if (this.exportField) {
|
|
129
|
+
exportFieldArr = this.exportField.split(',')
|
|
130
|
+
}
|
|
79
131
|
rows.forEach((row) => {
|
|
80
132
|
var exportRow = {}
|
|
81
133
|
this.columns.forEach((col) => {
|
|
82
|
-
if (
|
|
134
|
+
if (
|
|
135
|
+
col.ctrlType != 'suntable' &&
|
|
136
|
+
(!exportFieldArr ||
|
|
137
|
+
(exportFieldArr && !exportFieldArr.includes(col.name)))
|
|
138
|
+
) {
|
|
83
139
|
exportRow[col.desc] = row[col.name]
|
|
84
140
|
}
|
|
85
141
|
})
|
|
@@ -87,6 +143,25 @@
|
|
|
87
143
|
})
|
|
88
144
|
return exportData
|
|
89
145
|
},
|
|
146
|
+
getConfirmValue(rows, count) {
|
|
147
|
+
return new Promise((resolve) => {
|
|
148
|
+
this.$confirm(
|
|
149
|
+
`导出数据量超出导出限制【${count}】,将导出${count}条,是否继续?`,
|
|
150
|
+
'提示',
|
|
151
|
+
{
|
|
152
|
+
confirmButtonText: '确定',
|
|
153
|
+
cancelButtonText: '取消',
|
|
154
|
+
type: 'warning',
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
.then(() => {
|
|
158
|
+
resolve(rows.slice(0, count))
|
|
159
|
+
})
|
|
160
|
+
.catch(() => {
|
|
161
|
+
resolve(false)
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
},
|
|
90
165
|
handleCommand(type) {
|
|
91
166
|
const pInst = utils.getOnlineFormInstance(this)
|
|
92
167
|
SubPagination.exportData(
|
|
@@ -97,6 +172,20 @@
|
|
|
97
172
|
)
|
|
98
173
|
.then(async (data) => {
|
|
99
174
|
data = JSON.parse(JSON.stringify(data))
|
|
175
|
+
if (this.exportMaxRow && Number(this.exportMaxRow) < data.length) {
|
|
176
|
+
let result = await this.getConfirmValue(
|
|
177
|
+
data,
|
|
178
|
+
Number(this.exportMaxRow)
|
|
179
|
+
)
|
|
180
|
+
if (result === false) {
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
data = result
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (this.exportFieldTransformData) {
|
|
187
|
+
data = await this.transformFieldData(data)
|
|
188
|
+
}
|
|
100
189
|
// 导出时 字典转换
|
|
101
190
|
await this.changeDictionary(data)
|
|
102
191
|
let exportData = this.changeRowKey(data)
|
|
@@ -102,6 +102,45 @@
|
|
|
102
102
|
type: String,
|
|
103
103
|
required: true,
|
|
104
104
|
},
|
|
105
|
+
importMaxRow: {
|
|
106
|
+
type: [String, Number],
|
|
107
|
+
default: null,
|
|
108
|
+
},
|
|
109
|
+
templateType: {
|
|
110
|
+
// 导入模板类型 default 系统默认 custom 自定义
|
|
111
|
+
type: String,
|
|
112
|
+
default: 'default',
|
|
113
|
+
},
|
|
114
|
+
customTemplate: {
|
|
115
|
+
// 自定义的导入模板文件
|
|
116
|
+
type: String,
|
|
117
|
+
default: '',
|
|
118
|
+
},
|
|
119
|
+
importTransform: {
|
|
120
|
+
// 是否有转换字段
|
|
121
|
+
type: String,
|
|
122
|
+
default: '0',
|
|
123
|
+
},
|
|
124
|
+
importModes: {
|
|
125
|
+
// 导入模式选项显示
|
|
126
|
+
type: String,
|
|
127
|
+
default: 'append,override,merge',
|
|
128
|
+
},
|
|
129
|
+
fieldTransformData: {
|
|
130
|
+
// 转换字段配置
|
|
131
|
+
type: String,
|
|
132
|
+
default: '',
|
|
133
|
+
},
|
|
134
|
+
conditionRule: {
|
|
135
|
+
// 条件模式配置
|
|
136
|
+
type: String,
|
|
137
|
+
default: '',
|
|
138
|
+
},
|
|
139
|
+
conditionType: {
|
|
140
|
+
// 条件模式配置
|
|
141
|
+
type: String,
|
|
142
|
+
default: 'cover',
|
|
143
|
+
},
|
|
105
144
|
},
|
|
106
145
|
data() {
|
|
107
146
|
return {
|
|
@@ -110,11 +149,6 @@
|
|
|
110
149
|
showRowData: false,
|
|
111
150
|
mergeFunc: null,
|
|
112
151
|
mode: 'append',
|
|
113
|
-
modeOptions: [
|
|
114
|
-
{ mode: 'append', desc: '追加导入' },
|
|
115
|
-
{ mode: 'override', desc: '覆盖导入' },
|
|
116
|
-
{ mode: 'merge', desc: '合并导入', disabled: true },
|
|
117
|
-
],
|
|
118
152
|
cacheDicData: {}, // 缓存字典数据
|
|
119
153
|
}
|
|
120
154
|
},
|
|
@@ -122,6 +156,30 @@
|
|
|
122
156
|
columns: function() {
|
|
123
157
|
return eval(decode(this.dataColumns))
|
|
124
158
|
},
|
|
159
|
+
modeOptions() {
|
|
160
|
+
let options = [
|
|
161
|
+
{ mode: 'append', desc: '追加导入' },
|
|
162
|
+
{ mode: 'override', desc: '覆盖导入' },
|
|
163
|
+
{ mode: 'merge', desc: '合并导入' },
|
|
164
|
+
{ mode: 'condition', desc: '条件导入' },
|
|
165
|
+
]
|
|
166
|
+
return options.filter((k) => {
|
|
167
|
+
return this.importModes.includes(k.mode)
|
|
168
|
+
})
|
|
169
|
+
},
|
|
170
|
+
conditionConfig() {
|
|
171
|
+
let config = {}
|
|
172
|
+
if (this.conditionRule) {
|
|
173
|
+
config = JSON.parse(decode(this.conditionRule))
|
|
174
|
+
config.conditionArr.forEach((k) => {
|
|
175
|
+
k.exportField = this.getNameByDesc(k.exportField)
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
conditionType: this.conditionType,
|
|
180
|
+
...config,
|
|
181
|
+
}
|
|
182
|
+
},
|
|
125
183
|
},
|
|
126
184
|
watch: {
|
|
127
185
|
dialogVisible: {
|
|
@@ -139,7 +197,7 @@
|
|
|
139
197
|
handler: function(newVal) {
|
|
140
198
|
if (newVal) {
|
|
141
199
|
// 如果有导入合并的代码,则允许选择合并导入模式
|
|
142
|
-
this.$set(this.modeOptions[2], 'disabled', false)
|
|
200
|
+
// this.$set(this.modeOptions[2], 'disabled', false)
|
|
143
201
|
// 并设置默认为 合并导入
|
|
144
202
|
this.mode = 'merge'
|
|
145
203
|
// 解码合并的代码
|
|
@@ -156,6 +214,9 @@
|
|
|
156
214
|
}
|
|
157
215
|
},
|
|
158
216
|
mounted() {
|
|
217
|
+
if (this.importModes) {
|
|
218
|
+
this.mode = this.importModes.split(',')[0]
|
|
219
|
+
}
|
|
159
220
|
// 初始化导入时需要的参数
|
|
160
221
|
const pInst = utils.getOnlineFormInstance(this)
|
|
161
222
|
let formUid = pInst && pInst._uid ? pInst._uid : ''
|
|
@@ -174,6 +235,46 @@
|
|
|
174
235
|
SubPagination.clear(this.dataSubname, this)
|
|
175
236
|
},
|
|
176
237
|
methods: {
|
|
238
|
+
transformFieldData(data) {
|
|
239
|
+
return new Promise(async (resolve) => {
|
|
240
|
+
if (this.importTransform === '0') {
|
|
241
|
+
resolve(data)
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
let fieldTransformData = JSON.parse(decode(this.fieldTransformData))
|
|
245
|
+
for (let i = 0; i < data.length; i++) {
|
|
246
|
+
for (let j = 0; j < fieldTransformData.length; j++) {
|
|
247
|
+
if (fieldTransformData[j].relevancyType == 'value') {
|
|
248
|
+
data[i][fieldTransformData[j].field] =
|
|
249
|
+
fieldTransformData[j].relevancyValue
|
|
250
|
+
} else {
|
|
251
|
+
// 动态时 请求接口修改数据
|
|
252
|
+
let result = await this.sqlChange(
|
|
253
|
+
fieldTransformData[j],
|
|
254
|
+
data[i][fieldTransformData[j].field]
|
|
255
|
+
)
|
|
256
|
+
if (result) {
|
|
257
|
+
data[i][fieldTransformData[j].field] = result
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
resolve(data)
|
|
263
|
+
})
|
|
264
|
+
},
|
|
265
|
+
async sqlChange(config, value = '') {
|
|
266
|
+
return new Promise((resolve) => {
|
|
267
|
+
let params = {
|
|
268
|
+
dsName: config.dataSource,
|
|
269
|
+
sql: config.relevancyValue
|
|
270
|
+
? config.relevancyValue.replace(/{val}/g, value)
|
|
271
|
+
: '',
|
|
272
|
+
}
|
|
273
|
+
this.$requestConfig.getValueBySql(params).then((res) => {
|
|
274
|
+
resolve(res)
|
|
275
|
+
})
|
|
276
|
+
})
|
|
277
|
+
},
|
|
177
278
|
changeDictionary(data) {
|
|
178
279
|
return new Promise(async (resolve) => {
|
|
179
280
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -214,6 +315,28 @@
|
|
|
214
315
|
},
|
|
215
316
|
//子表模板导出
|
|
216
317
|
exportFormSub() {
|
|
318
|
+
// 如果是自定义模板
|
|
319
|
+
if (this.templateType == 'custom' && this.customTemplate) {
|
|
320
|
+
let file = JSON.parse(decode(this.customTemplate))[0]
|
|
321
|
+
this.$requestConfig
|
|
322
|
+
.download(file.response.fileId)
|
|
323
|
+
.then(({ data, headers }) => {
|
|
324
|
+
if (data && headers) {
|
|
325
|
+
// 附件下载
|
|
326
|
+
const fileName = decodeURIComponent(
|
|
327
|
+
headers['content-disposition']
|
|
328
|
+
.split(';')[1]
|
|
329
|
+
.split('filename=')[1]
|
|
330
|
+
)
|
|
331
|
+
const blob = new Blob([data])
|
|
332
|
+
saveAs(blob, fileName)
|
|
333
|
+
}
|
|
334
|
+
})
|
|
335
|
+
.catch((err) => {
|
|
336
|
+
this.$message.error(`附件下载失败:${err}`)
|
|
337
|
+
})
|
|
338
|
+
return
|
|
339
|
+
}
|
|
217
340
|
let columns = this.columns.filter((item) => {
|
|
218
341
|
return !(
|
|
219
342
|
item.ctrlType &&
|
|
@@ -263,6 +386,7 @@
|
|
|
263
386
|
let count = this.importRows.length
|
|
264
387
|
if (count > maxRowInt && maxRowInt != 0) {
|
|
265
388
|
this.$message.error('子表数据已超过最大行数【' + maxRowInt + '】')
|
|
389
|
+
this.$refs.selectFile.value = ''
|
|
266
390
|
return
|
|
267
391
|
}
|
|
268
392
|
} else if (this.mode == 'append') {
|
|
@@ -291,17 +415,21 @@
|
|
|
291
415
|
}
|
|
292
416
|
}
|
|
293
417
|
let importRows = await this.changeDictionary(this.importRows)
|
|
418
|
+
// 导入如果有数据转换的此处做转换
|
|
419
|
+
importRows = await this.transformFieldData(importRows)
|
|
294
420
|
SubPagination.importData(
|
|
295
421
|
this.dataSubname,
|
|
296
422
|
importRows,
|
|
297
423
|
this.mode,
|
|
298
|
-
this.mergeFunc
|
|
424
|
+
this.mergeFunc,
|
|
425
|
+
this.conditionConfig
|
|
299
426
|
)
|
|
300
427
|
.then(() => {
|
|
301
428
|
this.$message.success('导入成功!')
|
|
302
429
|
this.dialogVisible = false
|
|
303
430
|
})
|
|
304
431
|
.catch((err) => {
|
|
432
|
+
this.$refs.selectFile.value = ''
|
|
305
433
|
this.$message.error(`数据导入失败:${err}`)
|
|
306
434
|
})
|
|
307
435
|
},
|
|
@@ -310,10 +438,43 @@
|
|
|
310
438
|
return
|
|
311
439
|
}
|
|
312
440
|
this.importRows = []
|
|
313
|
-
this.readWorkbookFromLocalFile(m.target.files[0], (rows) => {
|
|
441
|
+
this.readWorkbookFromLocalFile(m.target.files[0], async (rows) => {
|
|
442
|
+
if (this.importMaxRow) {
|
|
443
|
+
let count = rows.length
|
|
444
|
+
if (count > parseInt(this.importMaxRow)) {
|
|
445
|
+
let result = await this.getConfirmValue(
|
|
446
|
+
rows,
|
|
447
|
+
parseInt(this.importMaxRow)
|
|
448
|
+
)
|
|
449
|
+
if (result === false) {
|
|
450
|
+
this.$refs.selectFile.value = ''
|
|
451
|
+
return
|
|
452
|
+
}
|
|
453
|
+
rows = result
|
|
454
|
+
}
|
|
455
|
+
}
|
|
314
456
|
this.importRows = this.changeRowKey(rows)
|
|
315
457
|
})
|
|
316
458
|
},
|
|
459
|
+
getConfirmValue(rows, count) {
|
|
460
|
+
return new Promise((resolve) => {
|
|
461
|
+
this.$confirm(
|
|
462
|
+
`导入数据量已超过最大限制,将默认导入前【${count}】条,是否继续?`,
|
|
463
|
+
'提示',
|
|
464
|
+
{
|
|
465
|
+
confirmButtonText: '确定',
|
|
466
|
+
cancelButtonText: '取消',
|
|
467
|
+
type: 'warning',
|
|
468
|
+
}
|
|
469
|
+
)
|
|
470
|
+
.then(() => {
|
|
471
|
+
resolve(rows.slice(0, count))
|
|
472
|
+
})
|
|
473
|
+
.catch(() => {
|
|
474
|
+
resolve(false)
|
|
475
|
+
})
|
|
476
|
+
})
|
|
477
|
+
},
|
|
317
478
|
// 读取本地excel文件
|
|
318
479
|
readWorkbookFromLocalFile(file, callback) {
|
|
319
480
|
const reader = new FileReader()
|