cloud-web-corejs 1.1.0-dev.83 → 1.1.0-dev.84
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/table/vxeFilter/mixin.js +326 -326
- package/src/components/xform/form-designer/form-widget/field-widget/vabUpload2-widget.vue +185 -152
- package/src/components/xform/form-render/container-item/data-table-item.vue +1 -0
- package/src/components/xform/form-render/container-item/data-table-mixin.js +116 -0
package/package.json
CHANGED
|
@@ -1,326 +1,326 @@
|
|
|
1
|
-
// 直接引用工具函数,不走 $table 实例上的补丁方法:
|
|
2
|
-
// initVxeTable 只把 getCellValue/createParams 挂在初始化时的那个 xTable 实例上,
|
|
3
|
-
// 页面若用 v-if 销毁重建 vxe-grid(如 product_problem_record/list.vue),
|
|
4
|
-
// 新实例上没有这两个方法,筛选面板会报 $table.getCellValue is not a function
|
|
5
|
-
// (createParams 已不再直接使用:候选值取值统一走下面 load() 里的 readCellValue 缓存)
|
|
6
|
-
import { getCellValue } from "../util/index";
|
|
7
|
-
|
|
8
|
-
let modules = {};
|
|
9
|
-
|
|
10
|
-
modules = {
|
|
11
|
-
contentMixin: {
|
|
12
|
-
name: "FilterContent",
|
|
13
|
-
props: {
|
|
14
|
-
params: Object,
|
|
15
|
-
},
|
|
16
|
-
data() {
|
|
17
|
-
return {
|
|
18
|
-
size: "mini",
|
|
19
|
-
isAll: false,
|
|
20
|
-
option: null,
|
|
21
|
-
colValList: [],
|
|
22
|
-
valList: [],
|
|
23
|
-
valMap: null,
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
created() {
|
|
27
|
-
this.load();
|
|
28
|
-
},
|
|
29
|
-
methods: {
|
|
30
|
-
getShowValue(val) {
|
|
31
|
-
if (this.valMap && Object.keys(this.valMap).length > 0) {
|
|
32
|
-
return this.valMap[val];
|
|
33
|
-
} else {
|
|
34
|
-
return val;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
load() {
|
|
38
|
-
const { $table, column } = this.params;
|
|
39
|
-
const { fullColumn, tableColumn } = $table.getTableColumn();
|
|
40
|
-
const { fullData } = $table.getTableData();
|
|
41
|
-
const option = column.filters[0];
|
|
42
|
-
if (!option.data) {
|
|
43
|
-
option.data = {
|
|
44
|
-
sVal: "",
|
|
45
|
-
};
|
|
46
|
-
} else if (option.data.sVal == null) {
|
|
47
|
-
option.data.sVal = "";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!option.data.hasFilter) {
|
|
51
|
-
this.isAll = true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let vals = option.data && option.data.vals ? option.data.vals : [];
|
|
55
|
-
let valMap =
|
|
56
|
-
option.data && option.data.valMap ? option.data.valMap : null;
|
|
57
|
-
|
|
58
|
-
// 取值可能落到 getCellValue 的兜底渲染:非 filterVal 白名单的组件列每个单元格
|
|
59
|
-
// 都要 new Vue + $mount + 爬 DOM,还会跑一遍用户的表单脚本。而本方法要把全表
|
|
60
|
-
// 跑三遍(候选值 → 按其他筛选列过滤 → 过滤后计数),行多列宽时打开一次筛选面板
|
|
61
|
-
// 就是几千次同步挂载,主线程直接定住。同一 (列, 行) 只算一次。
|
|
62
|
-
// 注:第三遍原本按过滤后子集的下标取值,改用缓存后统一为整表下标——只有依赖
|
|
63
|
-
// 行下标的自定义渲染列会有差异,而这类列本就不该出现在值列表筛选里。
|
|
64
|
-
let cellValueCache = new Map();
|
|
65
|
-
const readCellValue = (row, col, $rowIndex) => {
|
|
66
|
-
let colCache = cellValueCache.get(col);
|
|
67
|
-
if (!colCache) {
|
|
68
|
-
colCache = new Map();
|
|
69
|
-
cellValueCache.set(col, colCache);
|
|
70
|
-
}
|
|
71
|
-
if (colCache.has(row)) return colCache.get(row);
|
|
72
|
-
let value = getCellValue({
|
|
73
|
-
row,
|
|
74
|
-
$rowIndex,
|
|
75
|
-
$table,
|
|
76
|
-
column: col,
|
|
77
|
-
});
|
|
78
|
-
colCache.set(row, value);
|
|
79
|
-
return value;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
let lsm = {};
|
|
83
|
-
let colValList = [];
|
|
84
|
-
fullData.map((row, $rowIndex) => {
|
|
85
|
-
let cellValue = readCellValue(row, column, $rowIndex);
|
|
86
|
-
let sortValue = cellValue
|
|
87
|
-
let sortField = column.params?.sortField;
|
|
88
|
-
if(sortField){
|
|
89
|
-
sortValue = row[sortField]??null;
|
|
90
|
-
}
|
|
91
|
-
if (lsm[cellValue]) {
|
|
92
|
-
lsm[cellValue].count = lsm[cellValue].count + 1;
|
|
93
|
-
} else {
|
|
94
|
-
lsm[cellValue] = {
|
|
95
|
-
checked: !option.data.hasFilter || vals.includes(cellValue),
|
|
96
|
-
value: cellValue,
|
|
97
|
-
sortValue: sortValue,
|
|
98
|
-
count: 1,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
for (let key in lsm) {
|
|
103
|
-
colValList.push(lsm[key]);
|
|
104
|
-
}
|
|
105
|
-
colValList = this.sortByField(colValList, "sortValue");
|
|
106
|
-
|
|
107
|
-
const columnsArr = [];
|
|
108
|
-
|
|
109
|
-
this.option = option;
|
|
110
|
-
this.colValList = colValList;
|
|
111
|
-
this.valList = colValList;
|
|
112
|
-
this.valMap = valMap;
|
|
113
|
-
|
|
114
|
-
let filterColumns = fullColumn.filter((row, $rowIndex) => {
|
|
115
|
-
return (
|
|
116
|
-
row.filterRender &&
|
|
117
|
-
row.filterRender.name == "FilterContent" &&
|
|
118
|
-
row.field != column.field
|
|
119
|
-
);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
let datas = fullData.filter((row, $rowIndex) => {
|
|
123
|
-
let item = filterColumns.find((filterColumn) => {
|
|
124
|
-
let option1 = filterColumn.filters[0];
|
|
125
|
-
if (!option1.data.hasFilter) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
const vals = option1.data.vals || [];
|
|
129
|
-
let cellValue = readCellValue(row, filterColumn);
|
|
130
|
-
return !vals.includes(cellValue);
|
|
131
|
-
});
|
|
132
|
-
return item == null;
|
|
133
|
-
});
|
|
134
|
-
let lsm2 = {};
|
|
135
|
-
datas.map((row, $rowIndex) => {
|
|
136
|
-
let cellValue = readCellValue(row, column, $rowIndex);
|
|
137
|
-
if (lsm2[cellValue]) {
|
|
138
|
-
lsm2[cellValue].count = lsm2[cellValue].count + 1;
|
|
139
|
-
} else {
|
|
140
|
-
lsm2[cellValue] = {
|
|
141
|
-
value: cellValue,
|
|
142
|
-
count: 1,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
colValList.forEach((colVal) => {
|
|
147
|
-
let item = lsm2[colVal.value];
|
|
148
|
-
if (item) {
|
|
149
|
-
colVal.filterCount = item.count;
|
|
150
|
-
} else {
|
|
151
|
-
colVal.filterCount = 0;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
this.searchEvent();
|
|
156
|
-
},
|
|
157
|
-
sortByField(array, field) {
|
|
158
|
-
return [...array].sort((a, b) => {
|
|
159
|
-
const valA = a[field];
|
|
160
|
-
const valB = b[field];
|
|
161
|
-
|
|
162
|
-
// 处理 null/undefined(视为最小值)
|
|
163
|
-
if (valA == null) return -1;
|
|
164
|
-
if (valB == null) return 1;
|
|
165
|
-
if (valA == null && valB == null) return 0;
|
|
166
|
-
|
|
167
|
-
// 尝试数值比较
|
|
168
|
-
const numA = Number(valA);
|
|
169
|
-
const numB = Number(valB);
|
|
170
|
-
if (!isNaN(numA) && !isNaN(numB)) {
|
|
171
|
-
return numA - numB;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// 字符串比较
|
|
175
|
-
return String(valA).localeCompare(String(valB));
|
|
176
|
-
});
|
|
177
|
-
},
|
|
178
|
-
searchEvent() {
|
|
179
|
-
let that = this;
|
|
180
|
-
const { option, colValList } = this;
|
|
181
|
-
this.valList = option.data.sVal
|
|
182
|
-
? colValList.filter(function (item) {
|
|
183
|
-
let value = item.value;
|
|
184
|
-
// 空单元格的 value 为 null/undefined,数值列为 number,必须转字符串再匹配
|
|
185
|
-
return (
|
|
186
|
-
value != null &&
|
|
187
|
-
String(value).indexOf(option.data.sVal) > -1
|
|
188
|
-
);
|
|
189
|
-
})
|
|
190
|
-
: colValList;
|
|
191
|
-
let isAll = this.valList.every((item) => {
|
|
192
|
-
return item.checked == true;
|
|
193
|
-
});
|
|
194
|
-
this.isAll = isAll;
|
|
195
|
-
},
|
|
196
|
-
changeAllEvent() {
|
|
197
|
-
const { isAll } = this;
|
|
198
|
-
this.valList.forEach((item) => {
|
|
199
|
-
item.checked = isAll;
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
checkItem(checked) {
|
|
203
|
-
if (checked) {
|
|
204
|
-
let isAll = this.valList.every((item) => {
|
|
205
|
-
return item.checked == true;
|
|
206
|
-
});
|
|
207
|
-
this.isAll = isAll;
|
|
208
|
-
} else {
|
|
209
|
-
this.isAll = false;
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
confirmFilterEvent(evnt) {
|
|
213
|
-
const { params, option, valList, colValList } = this;
|
|
214
|
-
const { data } = option;
|
|
215
|
-
const { $panel, $table } = params;
|
|
216
|
-
let vals = valList
|
|
217
|
-
.filter((item) => item.checked)
|
|
218
|
-
.map((item) => item.value);
|
|
219
|
-
if (!option.data.sVal && colValList.length == vals.length) {
|
|
220
|
-
this.resetFilterEvent();
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
data.vals = vals;
|
|
224
|
-
option.data.hasFilter = true;
|
|
225
|
-
$panel.changeOption(evnt, true, option);
|
|
226
|
-
$panel.confirmFilter();
|
|
227
|
-
$table.setAllCheckboxRow(false);
|
|
228
|
-
},
|
|
229
|
-
resetFilterEvent() {
|
|
230
|
-
const { $panel, $table } = this.params;
|
|
231
|
-
this.option.data.hasFilter = false;
|
|
232
|
-
$panel.resetFilter();
|
|
233
|
-
$table.setAllCheckboxRow(false);
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
complexMixin: {
|
|
238
|
-
name: "FilterComplex",
|
|
239
|
-
props: {
|
|
240
|
-
params: Object,
|
|
241
|
-
events: Object,
|
|
242
|
-
},
|
|
243
|
-
data() {
|
|
244
|
-
return {
|
|
245
|
-
size: "mini", // 被所有子组件继承 size
|
|
246
|
-
column: null,
|
|
247
|
-
option: null,
|
|
248
|
-
};
|
|
249
|
-
},
|
|
250
|
-
created() {
|
|
251
|
-
this.load();
|
|
252
|
-
},
|
|
253
|
-
methods: {
|
|
254
|
-
load() {
|
|
255
|
-
const { column } = this.params;
|
|
256
|
-
const option = column.filters[0];
|
|
257
|
-
if (!option.data) {
|
|
258
|
-
option.data = {
|
|
259
|
-
type: "lt",
|
|
260
|
-
};
|
|
261
|
-
} else if (!option.data.type) {
|
|
262
|
-
option.data.type = "lt";
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
this.column = column;
|
|
266
|
-
this.option = option;
|
|
267
|
-
},
|
|
268
|
-
changeOptionEvent() {
|
|
269
|
-
const { params, option } = this;
|
|
270
|
-
const { $panel } = params;
|
|
271
|
-
const checked = !!option.data.name;
|
|
272
|
-
$panel.changeOption(null, checked, option);
|
|
273
|
-
},
|
|
274
|
-
confirmEvent() {
|
|
275
|
-
const { $panel, column } = this.params;
|
|
276
|
-
$panel.confirmFilter();
|
|
277
|
-
},
|
|
278
|
-
resetEvent() {
|
|
279
|
-
// eslint-disable-next-line no-unused-vars
|
|
280
|
-
const { $panel } = this.params;
|
|
281
|
-
$panel.resetFilter();
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
inputMixin: {
|
|
286
|
-
name: "FilterInput",
|
|
287
|
-
props: {
|
|
288
|
-
params: Object,
|
|
289
|
-
},
|
|
290
|
-
data() {
|
|
291
|
-
return {
|
|
292
|
-
column: null,
|
|
293
|
-
option: null,
|
|
294
|
-
};
|
|
295
|
-
},
|
|
296
|
-
created() {
|
|
297
|
-
this.load();
|
|
298
|
-
},
|
|
299
|
-
methods: {
|
|
300
|
-
load() {
|
|
301
|
-
const { column } = this.params;
|
|
302
|
-
const option = column.filters[0];
|
|
303
|
-
this.column = column;
|
|
304
|
-
this.option = option;
|
|
305
|
-
},
|
|
306
|
-
changeOptionEvent() {
|
|
307
|
-
const { params, option } = this;
|
|
308
|
-
const { $panel } = params;
|
|
309
|
-
const checked = !!option.data;
|
|
310
|
-
$panel.changeOption(null, checked, option);
|
|
311
|
-
},
|
|
312
|
-
keyupEvent({ $event }) {
|
|
313
|
-
const { params } = this;
|
|
314
|
-
const { $panel } = params;
|
|
315
|
-
if ($event.keyCode === 13) {
|
|
316
|
-
$panel.confirmFilter();
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
},
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
export const inputMixin = modules.inputMixin;
|
|
324
|
-
export const complexMixin = modules.complexMixin;
|
|
325
|
-
export const contentMixin = modules.contentMixin;
|
|
326
|
-
export default modules;
|
|
1
|
+
// 直接引用工具函数,不走 $table 实例上的补丁方法:
|
|
2
|
+
// initVxeTable 只把 getCellValue/createParams 挂在初始化时的那个 xTable 实例上,
|
|
3
|
+
// 页面若用 v-if 销毁重建 vxe-grid(如 product_problem_record/list.vue),
|
|
4
|
+
// 新实例上没有这两个方法,筛选面板会报 $table.getCellValue is not a function
|
|
5
|
+
// (createParams 已不再直接使用:候选值取值统一走下面 load() 里的 readCellValue 缓存)
|
|
6
|
+
import { getCellValue } from "../util/index";
|
|
7
|
+
|
|
8
|
+
let modules = {};
|
|
9
|
+
|
|
10
|
+
modules = {
|
|
11
|
+
contentMixin: {
|
|
12
|
+
name: "FilterContent",
|
|
13
|
+
props: {
|
|
14
|
+
params: Object,
|
|
15
|
+
},
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
size: "mini",
|
|
19
|
+
isAll: false,
|
|
20
|
+
option: null,
|
|
21
|
+
colValList: [],
|
|
22
|
+
valList: [],
|
|
23
|
+
valMap: null,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
created() {
|
|
27
|
+
this.load();
|
|
28
|
+
},
|
|
29
|
+
methods: {
|
|
30
|
+
getShowValue(val) {
|
|
31
|
+
if (this.valMap && Object.keys(this.valMap).length > 0) {
|
|
32
|
+
return this.valMap[val];
|
|
33
|
+
} else {
|
|
34
|
+
return val;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
load() {
|
|
38
|
+
const { $table, column } = this.params;
|
|
39
|
+
const { fullColumn, tableColumn } = $table.getTableColumn();
|
|
40
|
+
const { fullData } = $table.getTableData();
|
|
41
|
+
const option = column.filters[0];
|
|
42
|
+
if (!option.data) {
|
|
43
|
+
option.data = {
|
|
44
|
+
sVal: "",
|
|
45
|
+
};
|
|
46
|
+
} else if (option.data.sVal == null) {
|
|
47
|
+
option.data.sVal = "";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!option.data.hasFilter) {
|
|
51
|
+
this.isAll = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let vals = option.data && option.data.vals ? option.data.vals : [];
|
|
55
|
+
let valMap =
|
|
56
|
+
option.data && option.data.valMap ? option.data.valMap : null;
|
|
57
|
+
|
|
58
|
+
// 取值可能落到 getCellValue 的兜底渲染:非 filterVal 白名单的组件列每个单元格
|
|
59
|
+
// 都要 new Vue + $mount + 爬 DOM,还会跑一遍用户的表单脚本。而本方法要把全表
|
|
60
|
+
// 跑三遍(候选值 → 按其他筛选列过滤 → 过滤后计数),行多列宽时打开一次筛选面板
|
|
61
|
+
// 就是几千次同步挂载,主线程直接定住。同一 (列, 行) 只算一次。
|
|
62
|
+
// 注:第三遍原本按过滤后子集的下标取值,改用缓存后统一为整表下标——只有依赖
|
|
63
|
+
// 行下标的自定义渲染列会有差异,而这类列本就不该出现在值列表筛选里。
|
|
64
|
+
let cellValueCache = new Map();
|
|
65
|
+
const readCellValue = (row, col, $rowIndex) => {
|
|
66
|
+
let colCache = cellValueCache.get(col);
|
|
67
|
+
if (!colCache) {
|
|
68
|
+
colCache = new Map();
|
|
69
|
+
cellValueCache.set(col, colCache);
|
|
70
|
+
}
|
|
71
|
+
if (colCache.has(row)) return colCache.get(row);
|
|
72
|
+
let value = getCellValue({
|
|
73
|
+
row,
|
|
74
|
+
$rowIndex,
|
|
75
|
+
$table,
|
|
76
|
+
column: col,
|
|
77
|
+
});
|
|
78
|
+
colCache.set(row, value);
|
|
79
|
+
return value;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
let lsm = {};
|
|
83
|
+
let colValList = [];
|
|
84
|
+
fullData.map((row, $rowIndex) => {
|
|
85
|
+
let cellValue = readCellValue(row, column, $rowIndex);
|
|
86
|
+
let sortValue = cellValue
|
|
87
|
+
let sortField = column.params?.sortField;
|
|
88
|
+
if(sortField){
|
|
89
|
+
sortValue = row[sortField]??null;
|
|
90
|
+
}
|
|
91
|
+
if (lsm[cellValue]) {
|
|
92
|
+
lsm[cellValue].count = lsm[cellValue].count + 1;
|
|
93
|
+
} else {
|
|
94
|
+
lsm[cellValue] = {
|
|
95
|
+
checked: !option.data.hasFilter || vals.includes(cellValue),
|
|
96
|
+
value: cellValue,
|
|
97
|
+
sortValue: sortValue,
|
|
98
|
+
count: 1,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
for (let key in lsm) {
|
|
103
|
+
colValList.push(lsm[key]);
|
|
104
|
+
}
|
|
105
|
+
colValList = this.sortByField(colValList, "sortValue");
|
|
106
|
+
|
|
107
|
+
const columnsArr = [];
|
|
108
|
+
|
|
109
|
+
this.option = option;
|
|
110
|
+
this.colValList = colValList;
|
|
111
|
+
this.valList = colValList;
|
|
112
|
+
this.valMap = valMap;
|
|
113
|
+
|
|
114
|
+
let filterColumns = fullColumn.filter((row, $rowIndex) => {
|
|
115
|
+
return (
|
|
116
|
+
row.filterRender &&
|
|
117
|
+
row.filterRender.name == "FilterContent" &&
|
|
118
|
+
row.field != column.field
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
let datas = fullData.filter((row, $rowIndex) => {
|
|
123
|
+
let item = filterColumns.find((filterColumn) => {
|
|
124
|
+
let option1 = filterColumn.filters[0];
|
|
125
|
+
if (!option1.data.hasFilter) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
const vals = option1.data.vals || [];
|
|
129
|
+
let cellValue = readCellValue(row, filterColumn);
|
|
130
|
+
return !vals.includes(cellValue);
|
|
131
|
+
});
|
|
132
|
+
return item == null;
|
|
133
|
+
});
|
|
134
|
+
let lsm2 = {};
|
|
135
|
+
datas.map((row, $rowIndex) => {
|
|
136
|
+
let cellValue = readCellValue(row, column, $rowIndex);
|
|
137
|
+
if (lsm2[cellValue]) {
|
|
138
|
+
lsm2[cellValue].count = lsm2[cellValue].count + 1;
|
|
139
|
+
} else {
|
|
140
|
+
lsm2[cellValue] = {
|
|
141
|
+
value: cellValue,
|
|
142
|
+
count: 1,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
colValList.forEach((colVal) => {
|
|
147
|
+
let item = lsm2[colVal.value];
|
|
148
|
+
if (item) {
|
|
149
|
+
colVal.filterCount = item.count;
|
|
150
|
+
} else {
|
|
151
|
+
colVal.filterCount = 0;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
this.searchEvent();
|
|
156
|
+
},
|
|
157
|
+
sortByField(array, field) {
|
|
158
|
+
return [...array].sort((a, b) => {
|
|
159
|
+
const valA = a[field];
|
|
160
|
+
const valB = b[field];
|
|
161
|
+
|
|
162
|
+
// 处理 null/undefined(视为最小值)
|
|
163
|
+
if (valA == null) return -1;
|
|
164
|
+
if (valB == null) return 1;
|
|
165
|
+
if (valA == null && valB == null) return 0;
|
|
166
|
+
|
|
167
|
+
// 尝试数值比较
|
|
168
|
+
const numA = Number(valA);
|
|
169
|
+
const numB = Number(valB);
|
|
170
|
+
if (!isNaN(numA) && !isNaN(numB)) {
|
|
171
|
+
return numA - numB;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 字符串比较
|
|
175
|
+
return String(valA).localeCompare(String(valB));
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
searchEvent() {
|
|
179
|
+
let that = this;
|
|
180
|
+
const { option, colValList } = this;
|
|
181
|
+
this.valList = option.data.sVal
|
|
182
|
+
? colValList.filter(function (item) {
|
|
183
|
+
let value = item.value;
|
|
184
|
+
// 空单元格的 value 为 null/undefined,数值列为 number,必须转字符串再匹配
|
|
185
|
+
return (
|
|
186
|
+
value != null &&
|
|
187
|
+
String(value).indexOf(option.data.sVal) > -1
|
|
188
|
+
);
|
|
189
|
+
})
|
|
190
|
+
: colValList;
|
|
191
|
+
let isAll = this.valList.every((item) => {
|
|
192
|
+
return item.checked == true;
|
|
193
|
+
});
|
|
194
|
+
this.isAll = isAll;
|
|
195
|
+
},
|
|
196
|
+
changeAllEvent() {
|
|
197
|
+
const { isAll } = this;
|
|
198
|
+
this.valList.forEach((item) => {
|
|
199
|
+
item.checked = isAll;
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
checkItem(checked) {
|
|
203
|
+
if (checked) {
|
|
204
|
+
let isAll = this.valList.every((item) => {
|
|
205
|
+
return item.checked == true;
|
|
206
|
+
});
|
|
207
|
+
this.isAll = isAll;
|
|
208
|
+
} else {
|
|
209
|
+
this.isAll = false;
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
confirmFilterEvent(evnt) {
|
|
213
|
+
const { params, option, valList, colValList } = this;
|
|
214
|
+
const { data } = option;
|
|
215
|
+
const { $panel, $table } = params;
|
|
216
|
+
let vals = valList
|
|
217
|
+
.filter((item) => item.checked)
|
|
218
|
+
.map((item) => item.value);
|
|
219
|
+
if (!option.data.sVal && colValList.length == vals.length) {
|
|
220
|
+
this.resetFilterEvent();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
data.vals = vals;
|
|
224
|
+
option.data.hasFilter = true;
|
|
225
|
+
$panel.changeOption(evnt, true, option);
|
|
226
|
+
$panel.confirmFilter();
|
|
227
|
+
$table.setAllCheckboxRow(false);
|
|
228
|
+
},
|
|
229
|
+
resetFilterEvent() {
|
|
230
|
+
const { $panel, $table } = this.params;
|
|
231
|
+
this.option.data.hasFilter = false;
|
|
232
|
+
$panel.resetFilter();
|
|
233
|
+
$table.setAllCheckboxRow(false);
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
complexMixin: {
|
|
238
|
+
name: "FilterComplex",
|
|
239
|
+
props: {
|
|
240
|
+
params: Object,
|
|
241
|
+
events: Object,
|
|
242
|
+
},
|
|
243
|
+
data() {
|
|
244
|
+
return {
|
|
245
|
+
size: "mini", // 被所有子组件继承 size
|
|
246
|
+
column: null,
|
|
247
|
+
option: null,
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
created() {
|
|
251
|
+
this.load();
|
|
252
|
+
},
|
|
253
|
+
methods: {
|
|
254
|
+
load() {
|
|
255
|
+
const { column } = this.params;
|
|
256
|
+
const option = column.filters[0];
|
|
257
|
+
if (!option.data) {
|
|
258
|
+
option.data = {
|
|
259
|
+
type: "lt",
|
|
260
|
+
};
|
|
261
|
+
} else if (!option.data.type) {
|
|
262
|
+
option.data.type = "lt";
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
this.column = column;
|
|
266
|
+
this.option = option;
|
|
267
|
+
},
|
|
268
|
+
changeOptionEvent() {
|
|
269
|
+
const { params, option } = this;
|
|
270
|
+
const { $panel } = params;
|
|
271
|
+
const checked = !!option.data.name;
|
|
272
|
+
$panel.changeOption(null, checked, option);
|
|
273
|
+
},
|
|
274
|
+
confirmEvent() {
|
|
275
|
+
const { $panel, column } = this.params;
|
|
276
|
+
$panel.confirmFilter();
|
|
277
|
+
},
|
|
278
|
+
resetEvent() {
|
|
279
|
+
// eslint-disable-next-line no-unused-vars
|
|
280
|
+
const { $panel } = this.params;
|
|
281
|
+
$panel.resetFilter();
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
inputMixin: {
|
|
286
|
+
name: "FilterInput",
|
|
287
|
+
props: {
|
|
288
|
+
params: Object,
|
|
289
|
+
},
|
|
290
|
+
data() {
|
|
291
|
+
return {
|
|
292
|
+
column: null,
|
|
293
|
+
option: null,
|
|
294
|
+
};
|
|
295
|
+
},
|
|
296
|
+
created() {
|
|
297
|
+
this.load();
|
|
298
|
+
},
|
|
299
|
+
methods: {
|
|
300
|
+
load() {
|
|
301
|
+
const { column } = this.params;
|
|
302
|
+
const option = column.filters[0];
|
|
303
|
+
this.column = column;
|
|
304
|
+
this.option = option;
|
|
305
|
+
},
|
|
306
|
+
changeOptionEvent() {
|
|
307
|
+
const { params, option } = this;
|
|
308
|
+
const { $panel } = params;
|
|
309
|
+
const checked = !!option.data;
|
|
310
|
+
$panel.changeOption(null, checked, option);
|
|
311
|
+
},
|
|
312
|
+
keyupEvent({ $event }) {
|
|
313
|
+
const { params } = this;
|
|
314
|
+
const { $panel } = params;
|
|
315
|
+
if ($event.keyCode === 13) {
|
|
316
|
+
$panel.confirmFilter();
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export const inputMixin = modules.inputMixin;
|
|
324
|
+
export const complexMixin = modules.complexMixin;
|
|
325
|
+
export const contentMixin = modules.contentMixin;
|
|
326
|
+
export default modules;
|
|
@@ -130,6 +130,7 @@ import i18n from "../../../../../components/xform/utils/i18n";
|
|
|
130
130
|
import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
|
|
131
131
|
import settingConfig from "@/settings.js";
|
|
132
132
|
|
|
133
|
+
const SINGLE_UPLOAD_API = "/api/v1.0/FileOperation/UploadFilesFromPortal";
|
|
133
134
|
const BATCH_UPLOAD_API = "/api/v1.0/FileOperation/BatchUploadFilesFromPortal";
|
|
134
135
|
/** 全部处理完显示 100 后,再停一会儿关闭加载。 */
|
|
135
136
|
const HX_UPLOAD_DONE_DELAY = 200;
|
|
@@ -145,17 +146,31 @@ function parseJsonValue(value) {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
149
|
+
/**
|
|
150
|
+
* 单文件用 UploadFilesFromPortal,多文件用 BatchUploadFilesFromPortal。
|
|
151
|
+
* 配置只返回其中一个时,按名称推出另一个,不互相覆盖。
|
|
152
|
+
*/
|
|
153
|
+
function resolveHisenseUploadUrls(domain, uploadApi) {
|
|
154
|
+
const api = uploadApi || "";
|
|
155
|
+
const base = domain || "";
|
|
156
|
+
const isBatch = /BatchUploadFilesFromPortal/i.test(api);
|
|
157
|
+
const isSingle = !isBatch && /UploadFilesFromPortal/i.test(api);
|
|
158
|
+
let singleApi = api;
|
|
159
|
+
let batchApi = api;
|
|
160
|
+
if (isBatch) {
|
|
161
|
+
singleApi = api.replace(/BatchUploadFilesFromPortal/i, "UploadFilesFromPortal");
|
|
162
|
+
} else if (isSingle) {
|
|
163
|
+
batchApi = api.replace(/UploadFilesFromPortal/i, "BatchUploadFilesFromPortal");
|
|
164
|
+
} else if (!api) {
|
|
165
|
+
singleApi = SINGLE_UPLOAD_API;
|
|
166
|
+
batchApi = BATCH_UPLOAD_API;
|
|
167
|
+
} else {
|
|
168
|
+
batchApi = BATCH_UPLOAD_API;
|
|
157
169
|
}
|
|
158
|
-
return
|
|
170
|
+
return {
|
|
171
|
+
singleUploadUrl: base + singleApi,
|
|
172
|
+
batchUploadUrl: base + batchApi,
|
|
173
|
+
};
|
|
159
174
|
}
|
|
160
175
|
|
|
161
176
|
/** settings.hxFileLocalProxyEnabled 打开且处于 npm run dev 时,把海信绝对地址改写到本地 /hx-file。 */
|
|
@@ -179,17 +194,18 @@ function toDevProxyUrl(absoluteUrl) {
|
|
|
179
194
|
}
|
|
180
195
|
|
|
181
196
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
197
|
+
* 单上传 data 是一个文件对象。
|
|
198
|
+
* 批量上传外层 code=1000 只表示批次受理,再看每条明细的 code;外层非 1000 整批失败。
|
|
184
199
|
*/
|
|
185
200
|
function adaptHisenseBatchUploadResponse(responseData) {
|
|
186
201
|
const body = responseData || {};
|
|
187
202
|
const outerCode = Number(body.code);
|
|
188
203
|
const fail = (message) => ({
|
|
189
204
|
success: false,
|
|
190
|
-
message: message ||
|
|
205
|
+
message: message || "上传失败",
|
|
191
206
|
fullResponse: body,
|
|
192
207
|
data: null,
|
|
208
|
+
files: [],
|
|
193
209
|
});
|
|
194
210
|
if (outerCode !== 1000) {
|
|
195
211
|
return fail(body.message);
|
|
@@ -201,24 +217,35 @@ function adaptHisenseBatchUploadResponse(responseData) {
|
|
|
201
217
|
message: body.message || "ok",
|
|
202
218
|
fullResponse: body,
|
|
203
219
|
data: parsed,
|
|
220
|
+
files: [parsed],
|
|
204
221
|
};
|
|
205
222
|
}
|
|
206
223
|
if (!Array.isArray(parsed) || !parsed.length) {
|
|
207
224
|
return fail(body.message);
|
|
208
225
|
}
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
226
|
+
const files = [];
|
|
227
|
+
const errors = [];
|
|
228
|
+
parsed.forEach((item) => {
|
|
229
|
+
if (Number(item && item.code) !== 1000) {
|
|
230
|
+
errors.push((item && item.message) || body.message || "上传失败");
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const fileInfo = parseJsonValue(item.data);
|
|
234
|
+
if (!fileInfo) {
|
|
235
|
+
errors.push((item && item.message) || body.message || "上传失败");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
files.push(fileInfo);
|
|
239
|
+
});
|
|
240
|
+
if (!files.length) {
|
|
241
|
+
return fail(errors.filter(Boolean).join(";") || body.message);
|
|
216
242
|
}
|
|
217
243
|
return {
|
|
218
|
-
success:
|
|
219
|
-
message:
|
|
244
|
+
success: errors.length === 0,
|
|
245
|
+
message: errors.filter(Boolean).join(";") || "ok",
|
|
220
246
|
fullResponse: body,
|
|
221
|
-
data:
|
|
247
|
+
data: files[0],
|
|
248
|
+
files,
|
|
222
249
|
};
|
|
223
250
|
}
|
|
224
251
|
|
|
@@ -268,6 +295,8 @@ export default {
|
|
|
268
295
|
isH5: false,
|
|
269
296
|
|
|
270
297
|
uploadUrl: null,
|
|
298
|
+
singleUploadUrl: null,
|
|
299
|
+
batchUploadUrl: null,
|
|
271
300
|
|
|
272
301
|
token: null,
|
|
273
302
|
deleteUrl: null,
|
|
@@ -531,9 +560,10 @@ export default {
|
|
|
531
560
|
let token = objx.apiToken;
|
|
532
561
|
if (token) {
|
|
533
562
|
this.token = token;
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
);
|
|
563
|
+
const uploadUrls = resolveHisenseUploadUrls(objx.domain, objx.uploadApi);
|
|
564
|
+
this.singleUploadUrl = toDevProxyUrl(uploadUrls.singleUploadUrl);
|
|
565
|
+
this.batchUploadUrl = toDevProxyUrl(uploadUrls.batchUploadUrl);
|
|
566
|
+
this.uploadUrl = this.singleUploadUrl;
|
|
537
567
|
this.deleteUrl = toDevProxyUrl(objx.domain + objx.deleteApi);
|
|
538
568
|
// https://crm-dev.hisense.com/api/v1.0/fileoperation/GetFile?fileName=e24a1ad9-6821-41c3-957c-0916077bb97f.jpg
|
|
539
569
|
this.viewApiUrl = toDevProxyUrl(objx.domain + objx.viewApi);
|
|
@@ -588,156 +618,159 @@ export default {
|
|
|
588
618
|
Math.random() * 100000 + Math.random() * 20000 + Math.random() * 5000
|
|
589
619
|
);
|
|
590
620
|
},
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
let
|
|
607
|
-
|
|
608
|
-
var form = new FormData();
|
|
609
|
-
// 一个文件一次请求,索引固定为 0
|
|
610
|
-
const fieldPrefix = "requests[0].";
|
|
611
|
-
form.append(fieldPrefix + "File", fileObj);
|
|
612
|
-
|
|
613
|
-
let customParam = {};
|
|
614
|
-
let entityId = this.formDataId;
|
|
615
|
-
customParam = {
|
|
621
|
+
// 同一轮选择的文件先收齐:1 个走单上传,多个走一次批量上传
|
|
622
|
+
uploadSectionFile(param, isCustom, uploadConfig) {
|
|
623
|
+
if (!this.hxPendingUploads) {
|
|
624
|
+
this.hxPendingUploads = [];
|
|
625
|
+
}
|
|
626
|
+
this.hxPendingUploads.push({ param, isCustom, uploadConfig });
|
|
627
|
+
if (this.hxFlushScheduled) return;
|
|
628
|
+
this.hxFlushScheduled = true;
|
|
629
|
+
setTimeout(() => {
|
|
630
|
+
this.hxFlushScheduled = false;
|
|
631
|
+
const pending = this.hxPendingUploads.splice(0);
|
|
632
|
+
this.flushHxUpload(pending);
|
|
633
|
+
}, 0);
|
|
634
|
+
},
|
|
635
|
+
buildHxUploadParam(fileObj) {
|
|
636
|
+
let customParam = {
|
|
616
637
|
fileName: fileObj.name,
|
|
617
638
|
entityName: "msdyn_workorder",
|
|
618
|
-
entityId,
|
|
639
|
+
entityId: this.formDataId,
|
|
619
640
|
backendwriteback: "10",
|
|
620
641
|
fileCategory: "工单",
|
|
621
642
|
user: window.$vueRoot.$store.getters.nickName,
|
|
622
|
-
// user: "1",
|
|
623
643
|
};
|
|
624
644
|
let uploadParam =
|
|
625
645
|
this.handleCustomEvent(this.field.options.vabupload2_uploadParam) || {};
|
|
626
646
|
Object.assign(customParam, uploadParam);
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
let isLoading = uploadConfig?.isLoading === true;
|
|
643
|
-
var uploadUrl = this.uploadUrl;
|
|
647
|
+
return customParam;
|
|
648
|
+
},
|
|
649
|
+
appendHxUploadFields(form, fileObj, prefix) {
|
|
650
|
+
form.append(prefix ? prefix + "File" : "file", fileObj);
|
|
651
|
+
let customParam = this.buildHxUploadParam(fileObj);
|
|
652
|
+
Object.keys(customParam).forEach((key) => {
|
|
653
|
+
if (key === "file" || key === "File") return;
|
|
654
|
+
let fieldKey = prefix && key.indexOf("requests[") !== 0 ? prefix + key : key;
|
|
655
|
+
form.append(fieldKey, customParam[key]);
|
|
656
|
+
});
|
|
657
|
+
},
|
|
658
|
+
flushHxUpload(pending) {
|
|
659
|
+
if (!pending.length || this.componentDestroyed) return;
|
|
660
|
+
let isCustom = !!pending[0].isCustom;
|
|
661
|
+
let target = this.$refs.upload;
|
|
644
662
|
if (!isCustom && !this.showUploadBtn) {
|
|
645
663
|
target && target.clearFiles();
|
|
646
664
|
return;
|
|
647
665
|
}
|
|
648
|
-
target.clearFiles();
|
|
649
|
-
if (uploadUrl) {
|
|
650
|
-
let fileOrder = 0;
|
|
651
|
-
if (!isCustom) {
|
|
652
|
-
if (this.uploadingCount === 0) {
|
|
653
|
-
this.hxUploadTotal = 0;
|
|
654
|
-
this.openHxUploadLoading();
|
|
655
|
-
}
|
|
656
|
-
this.uploadingCount++;
|
|
657
|
-
this.hxUploadTotal++;
|
|
658
|
-
fileOrder = this.hxUploadTotal;
|
|
659
|
-
}
|
|
660
|
-
var abort;
|
|
666
|
+
target && target.clearFiles();
|
|
661
667
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}), */
|
|
676
|
-
onUploadProgress: (progressEvent) => {
|
|
677
|
-
const percent = progressEvent.total
|
|
678
|
-
? Math.floor((progressEvent.loaded * 100) / progressEvent.total)
|
|
679
|
-
: 0;
|
|
680
|
-
if (isCustom || file) {
|
|
681
|
-
progressEvent.percent = percent;
|
|
682
|
-
}
|
|
683
|
-
if (!isCustom) {
|
|
684
|
-
this.setHxUploadProgress(fileOrder, percent);
|
|
685
|
-
}
|
|
686
|
-
},
|
|
687
|
-
failMsg: false,
|
|
688
|
-
}; //添加请求头
|
|
668
|
+
let fileObjs = pending.map((item) => item.param && item.param.file).filter(Boolean);
|
|
669
|
+
if (!isCustom && this.uploadLimit) {
|
|
670
|
+
let remain = this.uploadLimit - this.attachmentCount - this.uploadingCount;
|
|
671
|
+
if (remain <= 0) return;
|
|
672
|
+
fileObjs = fileObjs.slice(0, remain);
|
|
673
|
+
}
|
|
674
|
+
if (!fileObjs.length) return;
|
|
675
|
+
|
|
676
|
+
const batch = fileObjs.length > 1;
|
|
677
|
+
const uploadUrl = batch
|
|
678
|
+
? this.batchUploadUrl
|
|
679
|
+
: this.singleUploadUrl || this.uploadUrl;
|
|
680
|
+
if (!uploadUrl) return;
|
|
689
681
|
|
|
690
|
-
|
|
691
|
-
|
|
682
|
+
let customEnabled = this.customEnabled || false;
|
|
683
|
+
const form = new FormData();
|
|
684
|
+
fileObjs.forEach((fileObj, index) => {
|
|
685
|
+
this.appendHxUploadFields(form, fileObj, batch ? `requests[${index}].` : "");
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
let fileOrder = 0;
|
|
689
|
+
if (!isCustom) {
|
|
690
|
+
if (this.uploadingCount === 0) {
|
|
691
|
+
this.hxUploadTotal = 0;
|
|
692
|
+
this.openHxUploadLoading();
|
|
692
693
|
}
|
|
694
|
+
this.uploadingCount++;
|
|
695
|
+
this.hxUploadTotal++;
|
|
696
|
+
fileOrder = this.hxUploadTotal;
|
|
697
|
+
}
|
|
693
698
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
+
let config = {
|
|
700
|
+
useToken: false,
|
|
701
|
+
isLoading: false,
|
|
702
|
+
headers: {
|
|
703
|
+
"Content-Type": "multipart/form-data",
|
|
704
|
+
Authorization: `Bearer ${this.token}`,
|
|
705
|
+
},
|
|
706
|
+
onUploadProgress: (progressEvent) => {
|
|
707
|
+
const percent = progressEvent.total
|
|
708
|
+
? Math.floor((progressEvent.loaded * 100) / progressEvent.total)
|
|
709
|
+
: 0;
|
|
699
710
|
if (!isCustom) {
|
|
700
|
-
this.setHxUploadProgress(fileOrder,
|
|
711
|
+
this.setHxUploadProgress(fileOrder, percent);
|
|
701
712
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
713
|
+
},
|
|
714
|
+
failMsg: false,
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
if (customEnabled && config?.httpConfig) {
|
|
718
|
+
config = extendDeeply(config, config.httpConfig);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
this.enqueueHxUpload(() => {
|
|
722
|
+
if (this.componentDestroyed || !this.getFormRef()) {
|
|
723
|
+
this.finishHxUpload(!isCustom);
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
if (!isCustom) {
|
|
727
|
+
this.setHxUploadProgress(fileOrder, 0);
|
|
728
|
+
}
|
|
729
|
+
let batchDone = false;
|
|
730
|
+
return this.getFormRef()
|
|
731
|
+
.$http.post(uploadUrl, form, config)
|
|
732
|
+
.then((res1) => {
|
|
733
|
+
if (this.componentDestroyed) return;
|
|
734
|
+
const isLast = !isCustom && this.uploadingCount <= 1;
|
|
735
|
+
if (isLast) {
|
|
736
|
+
this.setHxUploadPercentText(99);
|
|
737
|
+
}
|
|
738
|
+
pending.forEach((item) => {
|
|
739
|
+
item.uploadConfig &&
|
|
740
|
+
item.uploadConfig.callback &&
|
|
741
|
+
item.uploadConfig.callback(res1, item.param && item.param.file);
|
|
742
|
+
});
|
|
712
743
|
|
|
713
|
-
|
|
744
|
+
const adaptedResponse = this.responseAdapter(res1);
|
|
745
|
+
const files = Array.isArray(adaptedResponse.files)
|
|
746
|
+
? adaptedResponse.files
|
|
747
|
+
: adaptedResponse.data
|
|
748
|
+
? [adaptedResponse.data]
|
|
749
|
+
: [];
|
|
714
750
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
this.closeHxUploadLoading();
|
|
730
|
-
}
|
|
731
|
-
// param.onError(new Error(res1.content || '上传异常'));
|
|
751
|
+
if (!isCustom) {
|
|
752
|
+
files.forEach((data) => {
|
|
753
|
+
this.appendUploadedFile({
|
|
754
|
+
...data,
|
|
755
|
+
showUrl: null,
|
|
756
|
+
});
|
|
757
|
+
});
|
|
758
|
+
if (files.length && adaptedResponse.success) {
|
|
759
|
+
batchDone = isLast;
|
|
760
|
+
} else {
|
|
761
|
+
if (isLast) {
|
|
762
|
+
this.closeHxUploadLoading();
|
|
763
|
+
}
|
|
764
|
+
if (adaptedResponse.message) {
|
|
732
765
|
this.$baseAlert(adaptedResponse.message);
|
|
733
766
|
}
|
|
734
767
|
}
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}
|
|
768
|
+
}
|
|
769
|
+
})
|
|
770
|
+
.finally(() => {
|
|
771
|
+
return this.finishHxUpload(!isCustom, batchDone);
|
|
772
|
+
});
|
|
773
|
+
});
|
|
741
774
|
},
|
|
742
775
|
/**
|
|
743
776
|
* 同一控件内串行上传。上一次请求结束后立刻发下一次,
|
|
@@ -348,8 +348,92 @@ modules = {
|
|
|
348
348
|
this.fieldSchemaMap = {};
|
|
349
349
|
this.rowIdData.splice(0, this.rowIdData.length);
|
|
350
350
|
this.unregisterFromRefList();
|
|
351
|
+
this.restoreFilterScroll();
|
|
351
352
|
},
|
|
352
353
|
methods: {
|
|
354
|
+
/**
|
|
355
|
+
* 只在列筛选弹层打开时,把表体撑到弹层底部。
|
|
356
|
+
* 空表不再把弹层裁在滚动区外面,详情区滚动条随之出现;关闭后收回。
|
|
357
|
+
*/
|
|
358
|
+
handleFilterVisible({ visible } = {}) {
|
|
359
|
+
this.restoreFilterScroll();
|
|
360
|
+
if (!visible) return;
|
|
361
|
+
this.$nextTick(() => {
|
|
362
|
+
this.$nextTick(() => this.expandFilterScroll());
|
|
363
|
+
});
|
|
364
|
+
},
|
|
365
|
+
expandFilterScroll() {
|
|
366
|
+
this.restoreFilterScroll();
|
|
367
|
+
let grid = this.getGridTable();
|
|
368
|
+
let panel =
|
|
369
|
+
grid &&
|
|
370
|
+
grid.$el &&
|
|
371
|
+
grid.$el.querySelector(".vxe-table--filter-wrapper.is--active");
|
|
372
|
+
let body =
|
|
373
|
+
grid &&
|
|
374
|
+
grid.$el &&
|
|
375
|
+
grid.$el.querySelector(".vxe-table--main-wrapper > .vxe-table--body-wrapper");
|
|
376
|
+
if (!panel || !body) return;
|
|
377
|
+
let options = this.widget.options || {};
|
|
378
|
+
let bounded = !!(options.tableHeight || options.isQueryTable);
|
|
379
|
+
let prevMinHeight = body.style.minHeight;
|
|
380
|
+
let overflow = Math.ceil(
|
|
381
|
+
panel.getBoundingClientRect().bottom - body.getBoundingClientRect().bottom + 8
|
|
382
|
+
);
|
|
383
|
+
if (!bounded && overflow > 1) {
|
|
384
|
+
body.style.minHeight = body.getBoundingClientRect().height + overflow + "px";
|
|
385
|
+
}
|
|
386
|
+
let scrollEl = null;
|
|
387
|
+
let delta = 0;
|
|
388
|
+
let scroller = this.findFilterScroller(panel);
|
|
389
|
+
if (scroller) {
|
|
390
|
+
let gap = Math.ceil(
|
|
391
|
+
panel.getBoundingClientRect().bottom -
|
|
392
|
+
scroller.getBoundingClientRect().bottom +
|
|
393
|
+
8
|
|
394
|
+
);
|
|
395
|
+
if (gap > 1) {
|
|
396
|
+
let maxScroll = Math.max(0, scroller.scrollHeight - scroller.clientHeight);
|
|
397
|
+
let nextTop = Math.min(scroller.scrollTop + gap, maxScroll);
|
|
398
|
+
delta = nextTop - scroller.scrollTop;
|
|
399
|
+
if (delta > 0) {
|
|
400
|
+
scroller.scrollTop = nextTop;
|
|
401
|
+
scrollEl = scroller;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if ((!bounded && overflow > 1) || delta) {
|
|
406
|
+
this._filterScrollState = { body, prevMinHeight, scrollEl, delta };
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
findFilterScroller(panel) {
|
|
410
|
+
let node = panel.parentElement;
|
|
411
|
+
while (node && node !== document.documentElement) {
|
|
412
|
+
let overflowY = window.getComputedStyle(node).overflowY;
|
|
413
|
+
if (overflowY === "auto" || overflowY === "scroll") {
|
|
414
|
+
let gap =
|
|
415
|
+
panel.getBoundingClientRect().bottom - node.getBoundingClientRect().bottom;
|
|
416
|
+
let canScroll = node.scrollHeight > node.clientHeight + 1;
|
|
417
|
+
if (gap > 1 && canScroll && !this.filterScrollbarClipped(node)) return node;
|
|
418
|
+
}
|
|
419
|
+
node = node.parentElement;
|
|
420
|
+
}
|
|
421
|
+
return null;
|
|
422
|
+
},
|
|
423
|
+
filterScrollbarClipped(el) {
|
|
424
|
+
let parent = el.parentElement;
|
|
425
|
+
if (!parent) return false;
|
|
426
|
+
let overflowX = window.getComputedStyle(parent).overflowX;
|
|
427
|
+
if (overflowX !== "hidden" && overflowX !== "clip") return false;
|
|
428
|
+
return el.getBoundingClientRect().right > parent.getBoundingClientRect().right + 1;
|
|
429
|
+
},
|
|
430
|
+
restoreFilterScroll() {
|
|
431
|
+
let state = this._filterScrollState;
|
|
432
|
+
if (!state) return;
|
|
433
|
+
if (state.delta && state.scrollEl) state.scrollEl.scrollTop -= state.delta;
|
|
434
|
+
state.body.style.minHeight = state.prevMinHeight;
|
|
435
|
+
this._filterScrollState = null;
|
|
436
|
+
},
|
|
353
437
|
/** @param {String} reason 取消原因。取消当前普通查询并使旧响应失效。 */
|
|
354
438
|
cancelActiveTableQuery(reason = "query cancelled") {
|
|
355
439
|
this.tableQuerySeq += 1;
|
|
@@ -2663,6 +2747,33 @@ modules = {
|
|
|
2663
2747
|
}
|
|
2664
2748
|
return conditions;
|
|
2665
2749
|
},
|
|
2750
|
+
/**
|
|
2751
|
+
* 列里有多行输入时,算出能完整放下输入框的行高。
|
|
2752
|
+
* 表格默认行高 36px,多行框会被裁切,边框和拖拽角叠在一起。
|
|
2753
|
+
* @param {Array} columns VXE 列。
|
|
2754
|
+
* @returns {Number|null} 行高(px);没有多行输入列时返回 null。
|
|
2755
|
+
*/
|
|
2756
|
+
getTextareaColumnRowHeight(columns) {
|
|
2757
|
+
let maxRows = 0;
|
|
2758
|
+
const visit = (list) => {
|
|
2759
|
+
(list || []).forEach((col) => {
|
|
2760
|
+
const params = col.params || {};
|
|
2761
|
+
[params.widget, params.editWidget]
|
|
2762
|
+
.concat(params.widgetList || [])
|
|
2763
|
+
.forEach((widget) => {
|
|
2764
|
+
if (!widget || widget.type !== "textarea") return;
|
|
2765
|
+
const rows = Number(widget.options && widget.options.rows);
|
|
2766
|
+
maxRows = Math.max(maxRows, rows > 0 ? rows : 3);
|
|
2767
|
+
});
|
|
2768
|
+
if (col.children && col.children.length) visit(col.children);
|
|
2769
|
+
});
|
|
2770
|
+
};
|
|
2771
|
+
visit(columns);
|
|
2772
|
+
if (!maxRows) return null;
|
|
2773
|
+
// 12px 字、1.4 行高按每行 22px,再加输入框内边距、边框和单元格上下 2px。
|
|
2774
|
+
// 至少 52px:即使只配了 1 行,32px 的最小高度加上留白也放不进 36px 的行。
|
|
2775
|
+
return Math.max(maxRows * 22 + 16, 52);
|
|
2776
|
+
},
|
|
2666
2777
|
/**
|
|
2667
2778
|
* 将设计器列转换成 VXE 列,挂载展示/编辑插槽及列级格式化配置。
|
|
2668
2779
|
* 同时收集行级组件模板,供 fieldSchemaMap 为每行克隆独立 schema。
|
|
@@ -3424,6 +3535,11 @@ modules = {
|
|
|
3424
3535
|
let rowConfig = {};
|
|
3425
3536
|
if (this.widget.options.tableRowHeight) {
|
|
3426
3537
|
rowConfig.height = this.widget.options.tableRowHeight;
|
|
3538
|
+
} else {
|
|
3539
|
+
const textareaRowHeight = this.getTextareaColumnRowHeight(columns);
|
|
3540
|
+
if (textareaRowHeight) {
|
|
3541
|
+
rowConfig.height = textareaRowHeight;
|
|
3542
|
+
}
|
|
3427
3543
|
}
|
|
3428
3544
|
|
|
3429
3545
|
// 宿主经 dataTableOption.config 覆写时,treeConfig 必须深合并而不是整体
|