bri-components 1.0.2 → 1.0.5
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/0.bri-components.min.js +1 -1
- package/lib/1.bri-components.min.js +1 -1
- package/lib/3.bri-components.min.js +1 -1
- package/lib/4.bri-components.min.js +1 -1
- package/lib/5.bri-components.min.js +1 -1
- package/lib/6.bri-components.min.js +1 -1
- package/lib/bri-components.min.js +8 -6
- package/package.json +3 -2
- package/src/.DS_Store +0 -0
- package/src/components/controls/base/DshCascader.vue +1 -1
- package/src/components/controls/base/DshCascaderMultiple.vue +1 -1
- package/src/components/controls/base/DshCheckbox.vue +1 -1
- package/src/components/controls/base/DshSelect.vue +1 -1
- package/src/components/controls/controlMixin.js +10 -15
- package/src/components/form/DshForm.vue +1 -27
- package/src/components/list/DshBox/DshPanel.vue +66 -77
- package/src/components/list/DshFlatTable.vue +16 -18
- package/src/components/list/ZTree.vue +5 -2
- package/src/components/unit/DshFormItem.vue +11 -4
- package/src/components/unit/DshUnit.vue +0 -2
- package/src/index.js +10 -2
- package/src/utils/index.js +5 -0
- package/src/utils/table.js +1002 -0
- package/src/datas/.DS_Store +0 -0
- package/src/datas/common/region.json +0 -1
- package/src/datas/common/resourceData.json +0 -20
- package/src/datas/index.js +0 -11
|
@@ -0,0 +1,1002 @@
|
|
|
1
|
+
import { regionData, resourceData } from "bri-datas";
|
|
2
|
+
|
|
3
|
+
const transformToColumns = function (form, filterTag = false) {
|
|
4
|
+
const themeColor = "#3DB8C5";
|
|
5
|
+
// 转换为十进制
|
|
6
|
+
const toDecimal = function (x) {
|
|
7
|
+
let f = parseFloat(x);
|
|
8
|
+
if (isNaN(f)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
f = Math.round(x * 100) / 100;
|
|
12
|
+
return f;
|
|
13
|
+
};
|
|
14
|
+
let columns = [];
|
|
15
|
+
form.filter((item) => item._type !== "tag" || filterTag).map((item) => {
|
|
16
|
+
let col = {
|
|
17
|
+
...item,
|
|
18
|
+
title: item._name,
|
|
19
|
+
field: item._key,
|
|
20
|
+
width: item._width,
|
|
21
|
+
titleAlign: item._align || "left",
|
|
22
|
+
columnAlign: item._align || "left",
|
|
23
|
+
isResize: true
|
|
24
|
+
};
|
|
25
|
+
let titleWidth = (col.title ? col.title.length * 16 : 36) + 40;
|
|
26
|
+
if (["text", "textarea"].includes(col._type)) {
|
|
27
|
+
col.width = col._width || 200;
|
|
28
|
+
col.componentName = "dsh-td-render";
|
|
29
|
+
col.render = (h, params) => {
|
|
30
|
+
if (params.row[col._key]) {
|
|
31
|
+
return h(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
domProps: {
|
|
35
|
+
innerHTML: params.row[col._key]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
// return h(
|
|
40
|
+
// "Ctooltip",
|
|
41
|
+
// {
|
|
42
|
+
// props: {
|
|
43
|
+
// placement: "top",
|
|
44
|
+
// transfer: true,
|
|
45
|
+
// maxWidth: "200",
|
|
46
|
+
// content: params.row[col._key]
|
|
47
|
+
// },
|
|
48
|
+
// style: {
|
|
49
|
+
// width: "100%"
|
|
50
|
+
// }
|
|
51
|
+
// },
|
|
52
|
+
// [
|
|
53
|
+
// h(
|
|
54
|
+
// "span",
|
|
55
|
+
// {
|
|
56
|
+
// class: "dsh-ellipsis",
|
|
57
|
+
// domProps: {
|
|
58
|
+
// innerHTML: params.row[col._key]
|
|
59
|
+
// }
|
|
60
|
+
// }
|
|
61
|
+
// )
|
|
62
|
+
// ]
|
|
63
|
+
// );
|
|
64
|
+
} else {
|
|
65
|
+
return h("span", "暂无数据");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
} else if (["idcard", "email", "phone", "serialNumber"].includes(col._type)) {
|
|
69
|
+
// 205, 110, 165
|
|
70
|
+
if (["idcard"].includes(col._type)) {
|
|
71
|
+
col.width = col._width || 190;
|
|
72
|
+
} else if (["serialNumber"].includes(col._type)) {
|
|
73
|
+
col.width = col._width || 140;
|
|
74
|
+
} else if (["email"].includes(col._type)) {
|
|
75
|
+
col.width = col._width || 200;
|
|
76
|
+
} else {
|
|
77
|
+
col.width = col._width || 130;
|
|
78
|
+
}
|
|
79
|
+
col.formatter = (row, index) => {
|
|
80
|
+
return row[col._key] ? `<i class="dsh-margin-right5"></i>${row[col._key]}` : "暂无数据";
|
|
81
|
+
};
|
|
82
|
+
} else if (["number"].includes(col._type)) {
|
|
83
|
+
col.width = col._width || 120;
|
|
84
|
+
col.columnAlign = item._align || "right";
|
|
85
|
+
col.titleAlign = item._align || "right";
|
|
86
|
+
col.orderBy = "";
|
|
87
|
+
col.componentName = "dsh-td-render";
|
|
88
|
+
|
|
89
|
+
if (col._numberFormat == "percent") {
|
|
90
|
+
col.render = (h, params) => {
|
|
91
|
+
let content = params.row[col._key];
|
|
92
|
+
content = content || content === 0
|
|
93
|
+
? `${content}%`
|
|
94
|
+
: "暂无数据";
|
|
95
|
+
|
|
96
|
+
return h(
|
|
97
|
+
"Ctooltip",
|
|
98
|
+
{
|
|
99
|
+
props: {
|
|
100
|
+
placement: "top",
|
|
101
|
+
transfer: true,
|
|
102
|
+
content: String(content)
|
|
103
|
+
},
|
|
104
|
+
style: {
|
|
105
|
+
// width: "100%"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
[
|
|
109
|
+
h(
|
|
110
|
+
"span",
|
|
111
|
+
{
|
|
112
|
+
class: "dsh-ellipsis"
|
|
113
|
+
},
|
|
114
|
+
content
|
|
115
|
+
)
|
|
116
|
+
]
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
} else {
|
|
120
|
+
col.render = (h, params) => {
|
|
121
|
+
let content = params.row[col._key];
|
|
122
|
+
content = content || content === 0
|
|
123
|
+
? this.$numToStrAndUnit(content, col)
|
|
124
|
+
: "暂无数据";
|
|
125
|
+
|
|
126
|
+
return h(
|
|
127
|
+
"Ctooltip",
|
|
128
|
+
{
|
|
129
|
+
props: {
|
|
130
|
+
placement: "top",
|
|
131
|
+
transfer: true,
|
|
132
|
+
content
|
|
133
|
+
},
|
|
134
|
+
style: {
|
|
135
|
+
width: "100%"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[
|
|
139
|
+
h(
|
|
140
|
+
"span",
|
|
141
|
+
{
|
|
142
|
+
class: "dsh-ellipsis"
|
|
143
|
+
},
|
|
144
|
+
content
|
|
145
|
+
)
|
|
146
|
+
]
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (col._showProgress) {
|
|
152
|
+
col.render = (h, params) => {
|
|
153
|
+
return h("Progress", {
|
|
154
|
+
props: {
|
|
155
|
+
percent: params.row[col._key] > 100 ? 100 : toDecimal(params.row[col._key]),
|
|
156
|
+
textInside: true,
|
|
157
|
+
strokeWidth: 20
|
|
158
|
+
},
|
|
159
|
+
style: {
|
|
160
|
+
lineHeight: "20px",
|
|
161
|
+
width: "100%",
|
|
162
|
+
overflow: "hidden"
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
} else if (["date"].includes(col._type)) {
|
|
168
|
+
switch (col._dateType) {
|
|
169
|
+
case "date":
|
|
170
|
+
col.width = col._width || 120;
|
|
171
|
+
break;
|
|
172
|
+
case "year":
|
|
173
|
+
col.width = col._width || 96;
|
|
174
|
+
break;
|
|
175
|
+
case "month":
|
|
176
|
+
col.width = col._width || 120;
|
|
177
|
+
break;
|
|
178
|
+
case "time":
|
|
179
|
+
col.width = col._width || 120;
|
|
180
|
+
break;
|
|
181
|
+
case "datetime":
|
|
182
|
+
col.width = col._width || 180;
|
|
183
|
+
break;
|
|
184
|
+
default:
|
|
185
|
+
col.width = col._width || 120;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
col.columnAlign = item._align || "center";
|
|
189
|
+
col.titleAlign = item._align || "center";
|
|
190
|
+
col.orderBy = "";
|
|
191
|
+
col.componentName = "dsh-td-render";
|
|
192
|
+
col.render = (h, params) => {
|
|
193
|
+
let content = params.row[col._key];
|
|
194
|
+
content = col._formate && content ? this.$dateFormat(content, col._formate) : content;
|
|
195
|
+
if (params.row[col._key]) {
|
|
196
|
+
return h(
|
|
197
|
+
"Ctooltip",
|
|
198
|
+
{
|
|
199
|
+
props: {
|
|
200
|
+
content,
|
|
201
|
+
transfer: true
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
[
|
|
205
|
+
h(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
class: "dsh-ellipsis"
|
|
209
|
+
},
|
|
210
|
+
content
|
|
211
|
+
)
|
|
212
|
+
]
|
|
213
|
+
);
|
|
214
|
+
} else {
|
|
215
|
+
return h(
|
|
216
|
+
"span",
|
|
217
|
+
{
|
|
218
|
+
style: {}
|
|
219
|
+
},
|
|
220
|
+
"暂无数据"
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
};
|
|
225
|
+
} else if (["switch"].includes(col._type)) {
|
|
226
|
+
col.width = col._width || 80;
|
|
227
|
+
col.columnAlign = item._align || "center";
|
|
228
|
+
col.titleAlign = item._align || "center";
|
|
229
|
+
col.formatter = (row, index) => {
|
|
230
|
+
return row[col._key] == undefined ? null : row[col._key] === false ? col._closeText : col._openText;
|
|
231
|
+
};
|
|
232
|
+
col.componentName = "dsh-td-render";
|
|
233
|
+
col.render = (h, params) => {
|
|
234
|
+
return h("i-switch", {
|
|
235
|
+
props: {
|
|
236
|
+
size: "small",
|
|
237
|
+
disabled: true,
|
|
238
|
+
value: params.row[col._key]
|
|
239
|
+
},
|
|
240
|
+
style: {
|
|
241
|
+
textAlign: "center"
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
} else if (["select"].includes(col._type)) {
|
|
246
|
+
col.width = col._width || 120;
|
|
247
|
+
col.columnAlign = item._align || "center";
|
|
248
|
+
col.titleAlign = item._align || "center";
|
|
249
|
+
col.componentName = "dsh-td-render";
|
|
250
|
+
let colorMap = col.colorMap || resourceData.colorMap;
|
|
251
|
+
col.render = (h, params) => {
|
|
252
|
+
let data = col._data.find((item) => item._key === params.row[col._key]) || { name: "暂无数据" };
|
|
253
|
+
if (data.name || params.row[col._key]) {
|
|
254
|
+
return h(
|
|
255
|
+
"Ctooltip",
|
|
256
|
+
{
|
|
257
|
+
props: {
|
|
258
|
+
placement: "top",
|
|
259
|
+
transfer: true,
|
|
260
|
+
content: data.name || params.row[col._key]
|
|
261
|
+
},
|
|
262
|
+
style: {
|
|
263
|
+
display: "flex",
|
|
264
|
+
alignItems: "center",
|
|
265
|
+
width: "100%"
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
[
|
|
269
|
+
h(
|
|
270
|
+
"div",
|
|
271
|
+
{
|
|
272
|
+
style: {
|
|
273
|
+
width: "100%"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
[
|
|
277
|
+
h(
|
|
278
|
+
"span",
|
|
279
|
+
{
|
|
280
|
+
style: {
|
|
281
|
+
backgroundColor: col._useColor ? this.$getColor(colorMap[data.color] || colorMap["color-1"], 0.1) : "",
|
|
282
|
+
color: col._useColor ? colorMap[data.color] || colorMap["color-1"] : "#666"
|
|
283
|
+
},
|
|
284
|
+
class: "table-select-common dsh-ellipsis"
|
|
285
|
+
},
|
|
286
|
+
data.name || params.row[col._key]
|
|
287
|
+
)
|
|
288
|
+
]
|
|
289
|
+
)
|
|
290
|
+
]
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
} else if (["checkbox"].includes(col._type)) {
|
|
295
|
+
col.componentName = "dsh-td-render";
|
|
296
|
+
col.width = col._width || 180;
|
|
297
|
+
let colorMap = col.colorMap || resourceData.colorMap;
|
|
298
|
+
col.render = (h, params) => {
|
|
299
|
+
if (col._data && col._data.length === 0) {
|
|
300
|
+
return h(
|
|
301
|
+
"span",
|
|
302
|
+
{
|
|
303
|
+
style: {}
|
|
304
|
+
},
|
|
305
|
+
"未配置资源库"
|
|
306
|
+
);
|
|
307
|
+
} else if (params.row[col._key] && params.row[col._key].length === 0) {
|
|
308
|
+
return h(
|
|
309
|
+
"span",
|
|
310
|
+
{
|
|
311
|
+
style: {}
|
|
312
|
+
},
|
|
313
|
+
"暂无数据"
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
else if (col._data && col._data.length > 0 && params.row[col._key] && params.row[col._key].length > 0) {
|
|
317
|
+
let colArr = col._data.filter((item) => params.row[col._key].includes(item._key));
|
|
318
|
+
return h(
|
|
319
|
+
"div",
|
|
320
|
+
{
|
|
321
|
+
style: {
|
|
322
|
+
display: "flex",
|
|
323
|
+
overflow: "hidden"
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
[
|
|
327
|
+
...colArr.map((item) => {
|
|
328
|
+
return h(
|
|
329
|
+
"Ctooltip",
|
|
330
|
+
{
|
|
331
|
+
props: {
|
|
332
|
+
placement: "top",
|
|
333
|
+
transfer: true,
|
|
334
|
+
content: item.name
|
|
335
|
+
},
|
|
336
|
+
style: {
|
|
337
|
+
minWidth: "35px",
|
|
338
|
+
marginLeft: "3px"
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
[
|
|
342
|
+
h(
|
|
343
|
+
"div",
|
|
344
|
+
{
|
|
345
|
+
style: {
|
|
346
|
+
background: col._useColor ? this.$getColor(colorMap[item.color] || colorMap["color-1"], 0.1) : "",
|
|
347
|
+
color: col._useColor ? colorMap[item.color] || colorMap["color-1"] : "666"
|
|
348
|
+
},
|
|
349
|
+
class: "table-select-common dsh-ellipsis"
|
|
350
|
+
},
|
|
351
|
+
item.name
|
|
352
|
+
)
|
|
353
|
+
]
|
|
354
|
+
);
|
|
355
|
+
})
|
|
356
|
+
]
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
} else if (["cascader", "region"].includes(col._type)) {
|
|
361
|
+
col.width = col._type === "cascader" ? col._width || 150 : col._width || 212;
|
|
362
|
+
col.componentName = "dsh-td-render";
|
|
363
|
+
col.render = (h, params) => {
|
|
364
|
+
if (params.row[col._key] && params.row[col._key].length > 0) {
|
|
365
|
+
let content = this.$getTreeLinealDatas(params.row[col._key], col._type === "cascader" ? col._data : regionData, "name").join("/");
|
|
366
|
+
return h(
|
|
367
|
+
"Ctooltip",
|
|
368
|
+
{
|
|
369
|
+
props: {
|
|
370
|
+
content,
|
|
371
|
+
transfer: true
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
[
|
|
375
|
+
h(
|
|
376
|
+
"div",
|
|
377
|
+
{
|
|
378
|
+
class: "dsh-ellipsis"
|
|
379
|
+
},
|
|
380
|
+
content
|
|
381
|
+
)
|
|
382
|
+
]
|
|
383
|
+
);
|
|
384
|
+
} else {
|
|
385
|
+
if (params.row[col._key] === null) {
|
|
386
|
+
console.log(`${col._name}字段${col._type}类型,值却为null,这是数据bug!`);
|
|
387
|
+
}
|
|
388
|
+
return h("span", "暂无数据");
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
} else if (["cascaders", "regions"].includes(col._type)) {
|
|
392
|
+
col.width = col._width || 250;
|
|
393
|
+
col.componentName = "dsh-td-render";
|
|
394
|
+
|
|
395
|
+
const cascaderData = ["regions"].includes(col._type) ? regionData : col._data;
|
|
396
|
+
col.render = (h, params) => {
|
|
397
|
+
if (params.row[col._key] && params.row[col._key].length > 0) {
|
|
398
|
+
let colArr = (params.row[col._key] || []).map((item) => this.$getTreeLinealDatas(item, cascaderData, "name").join("/"));
|
|
399
|
+
return h(
|
|
400
|
+
"div",
|
|
401
|
+
{
|
|
402
|
+
style: {
|
|
403
|
+
display: "flex",
|
|
404
|
+
overflow: "hidden"
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
[
|
|
408
|
+
...colArr.map((item) => {
|
|
409
|
+
return h(
|
|
410
|
+
"Ctooltip",
|
|
411
|
+
{
|
|
412
|
+
props: {
|
|
413
|
+
placement: "top",
|
|
414
|
+
transfer: true,
|
|
415
|
+
content: item
|
|
416
|
+
},
|
|
417
|
+
style: {
|
|
418
|
+
minWidth: "35px",
|
|
419
|
+
marginLeft: "3px"
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
[
|
|
423
|
+
h(
|
|
424
|
+
"div",
|
|
425
|
+
{
|
|
426
|
+
style: {
|
|
427
|
+
maxWidth: "100%",
|
|
428
|
+
background: "#ECF3FD",
|
|
429
|
+
color: "#3D84EE"
|
|
430
|
+
},
|
|
431
|
+
class: "table-select-common dsh-ellipsis"
|
|
432
|
+
},
|
|
433
|
+
item
|
|
434
|
+
)
|
|
435
|
+
]
|
|
436
|
+
);
|
|
437
|
+
})
|
|
438
|
+
]
|
|
439
|
+
);
|
|
440
|
+
} else {
|
|
441
|
+
if (params.row[col._key] === null) {
|
|
442
|
+
console.log(`${col._name}字段${col._type}类型,值却为null,这是数据bug!`);
|
|
443
|
+
}
|
|
444
|
+
return h("span", "暂无数据");
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
} else if (["file", "image"].includes(col._type)) {
|
|
448
|
+
col.width = col._width || 150;
|
|
449
|
+
col.titleAlign = item._align || "center";
|
|
450
|
+
col.columnAlign = item._align || "center";
|
|
451
|
+
col.componentName = "dsh-td-render";
|
|
452
|
+
|
|
453
|
+
// 缩略图展示模式 和 默认展示模式
|
|
454
|
+
col.render = col._listShowMode === "thumbnail"
|
|
455
|
+
? (h, params) => {
|
|
456
|
+
return params.row[col._key] && params.row[col._key].length
|
|
457
|
+
? h(
|
|
458
|
+
"dsh-file-show",
|
|
459
|
+
{
|
|
460
|
+
props: {
|
|
461
|
+
list: params.row[col._key]
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
)
|
|
465
|
+
: h("div", {
|
|
466
|
+
style: {
|
|
467
|
+
textAlign: "center"
|
|
468
|
+
}
|
|
469
|
+
}, "--");
|
|
470
|
+
}
|
|
471
|
+
: (h, params) => {
|
|
472
|
+
return h(
|
|
473
|
+
"div",
|
|
474
|
+
{
|
|
475
|
+
style: {
|
|
476
|
+
textAlign: "center"
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
[
|
|
480
|
+
h("Icon", {
|
|
481
|
+
props: {
|
|
482
|
+
custom: col._fileType == "file" ? "bico-font bico-file" : "bico-font bico-img"
|
|
483
|
+
},
|
|
484
|
+
class: "table-icon-common dsh-margin-right5"
|
|
485
|
+
}),
|
|
486
|
+
h(
|
|
487
|
+
"span",
|
|
488
|
+
{
|
|
489
|
+
class: "table-text-common"
|
|
490
|
+
},
|
|
491
|
+
col._fileType == "file"
|
|
492
|
+
? `${params.row[col._key] ? params.row[col._key].length : 0}个`
|
|
493
|
+
: `${params.row[col._key] ? params.row[col._key].length : 0}张`
|
|
494
|
+
)
|
|
495
|
+
]
|
|
496
|
+
);
|
|
497
|
+
};
|
|
498
|
+
} else if (["flatTable", "cascaderTable"].includes(col._type)) {
|
|
499
|
+
col.width = col._width || 100;
|
|
500
|
+
col.columnAlign = item._align || "center";
|
|
501
|
+
col.titleAlign = item._align || "center";
|
|
502
|
+
col.componentName = "dsh-td-render";
|
|
503
|
+
col.render = (h, params) => {
|
|
504
|
+
return h(
|
|
505
|
+
"div",
|
|
506
|
+
{
|
|
507
|
+
style: {
|
|
508
|
+
width: "100%",
|
|
509
|
+
overflow: "hidden"
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
[
|
|
513
|
+
h(
|
|
514
|
+
"span",
|
|
515
|
+
{
|
|
516
|
+
style: {
|
|
517
|
+
display: "inline-block",
|
|
518
|
+
height: "24px",
|
|
519
|
+
lineHeight: "24px",
|
|
520
|
+
padding: "0 5px",
|
|
521
|
+
margin: "auto",
|
|
522
|
+
background: "rgba(96, 144, 237, 0.15)",
|
|
523
|
+
borderRadius: "12px",
|
|
524
|
+
textAlign: "center",
|
|
525
|
+
color: themeColor
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
[
|
|
529
|
+
h("Icon", {
|
|
530
|
+
props: {
|
|
531
|
+
custom: col._type == "cascaderTable" ? "bico-font bico-Cascadetable" : "bico-font bico-internaltable"
|
|
532
|
+
},
|
|
533
|
+
class: "table-icon-common dsh-margin-right5"
|
|
534
|
+
}),
|
|
535
|
+
h(
|
|
536
|
+
"span",
|
|
537
|
+
{
|
|
538
|
+
class: "table-text-common"
|
|
539
|
+
},
|
|
540
|
+
col._type == "flatTable"
|
|
541
|
+
? `${params.row[col._key] ? params.row[col._key].list.length : 0}行`
|
|
542
|
+
: `${params.row[col._key] ? this.$getTreeLeafTotal(params.row[col._key].tree) : 0} 行`
|
|
543
|
+
)
|
|
544
|
+
]
|
|
545
|
+
)
|
|
546
|
+
]
|
|
547
|
+
);
|
|
548
|
+
};
|
|
549
|
+
} else if (["editor"].includes(col._type)) {
|
|
550
|
+
col.width = col._width || 110;
|
|
551
|
+
col.componentName = "dsh-td-render";
|
|
552
|
+
col.render = (h, params) => {
|
|
553
|
+
return h(
|
|
554
|
+
"div",
|
|
555
|
+
{
|
|
556
|
+
style: {
|
|
557
|
+
width: "100%",
|
|
558
|
+
overflow: "hidden",
|
|
559
|
+
textAlign: "center"
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
[
|
|
563
|
+
h(
|
|
564
|
+
"span",
|
|
565
|
+
{
|
|
566
|
+
style: {
|
|
567
|
+
display: "inline-block",
|
|
568
|
+
height: "24px",
|
|
569
|
+
lineHeight: "24px",
|
|
570
|
+
padding: "0 5px",
|
|
571
|
+
margin: "auto",
|
|
572
|
+
border: `1px solid ${themeColor}`,
|
|
573
|
+
textAlign: "center",
|
|
574
|
+
color: themeColor
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
[
|
|
578
|
+
h(
|
|
579
|
+
"span",
|
|
580
|
+
{
|
|
581
|
+
class: "table-text-common"
|
|
582
|
+
},
|
|
583
|
+
col.title
|
|
584
|
+
)
|
|
585
|
+
]
|
|
586
|
+
)
|
|
587
|
+
]
|
|
588
|
+
);
|
|
589
|
+
};
|
|
590
|
+
} else if (["departments"].includes(col._type)) {
|
|
591
|
+
col.width = col._width || 100;
|
|
592
|
+
col.componentName = "dsh-td-render";
|
|
593
|
+
col.render = (h, params) => {
|
|
594
|
+
let departStr = "";
|
|
595
|
+
if (params.row[col._key] && params.row[col._key].length > 0) {
|
|
596
|
+
params.row[col._key].forEach((ele) => {
|
|
597
|
+
departStr += (ele && (ele.name || ele.realname || ele.mobile || ele)) + ",";
|
|
598
|
+
});
|
|
599
|
+
departStr = departStr.substring(0, departStr.length - 1);
|
|
600
|
+
} else {
|
|
601
|
+
departStr = "暂无数据";
|
|
602
|
+
}
|
|
603
|
+
return departStr
|
|
604
|
+
? h(
|
|
605
|
+
"Ctooltip",
|
|
606
|
+
{
|
|
607
|
+
props: {
|
|
608
|
+
content: departStr,
|
|
609
|
+
transfer: true
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
[
|
|
613
|
+
h(
|
|
614
|
+
"div",
|
|
615
|
+
{
|
|
616
|
+
class: "dsh-ellipsis"
|
|
617
|
+
},
|
|
618
|
+
departStr
|
|
619
|
+
)
|
|
620
|
+
]
|
|
621
|
+
)
|
|
622
|
+
: departStr;
|
|
623
|
+
};
|
|
624
|
+
} else if (["users"].includes(col._type)) {
|
|
625
|
+
col.width = col._width || Math.max(titleWidth, 120);
|
|
626
|
+
col.componentName = "dsh-td-render";
|
|
627
|
+
col.render = (h, params) => {
|
|
628
|
+
// 兼容对对象形势下的处理
|
|
629
|
+
if (this.$dataType(params.row[col._key], "object")) {
|
|
630
|
+
params.row[col._key] = [params.row[col._key]];
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
if (params.row[col._key] && params.row[col._key].length > 0) {
|
|
634
|
+
return h(
|
|
635
|
+
"div",
|
|
636
|
+
{
|
|
637
|
+
class: "dsh-ellipsis",
|
|
638
|
+
style: {
|
|
639
|
+
paddingLeft: "5px"
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
params.row[col._key]
|
|
643
|
+
.filter((item) => !!item)
|
|
644
|
+
.map((item) => {
|
|
645
|
+
return h("img", {
|
|
646
|
+
attrs: {
|
|
647
|
+
src: item.avatarurl || this.$imageSrcMap.system.boy
|
|
648
|
+
},
|
|
649
|
+
style: {
|
|
650
|
+
width: "18px",
|
|
651
|
+
height: "18px",
|
|
652
|
+
marginLeft: "-5px",
|
|
653
|
+
borderRadius: "50%",
|
|
654
|
+
verticalAlign: "middle"
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
})
|
|
658
|
+
.concat(
|
|
659
|
+
h(
|
|
660
|
+
"span",
|
|
661
|
+
{
|
|
662
|
+
style: {
|
|
663
|
+
width: "18px",
|
|
664
|
+
height: "18px",
|
|
665
|
+
verticalAlign: "middle",
|
|
666
|
+
marginLeft: "7px"
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
params.row[col._key][0] &&
|
|
670
|
+
(params.row[col._key][0].name ||
|
|
671
|
+
params.row[col._key][0].realname ||
|
|
672
|
+
params.row[col._key][0].mobile ||
|
|
673
|
+
params.row[col._key][0])
|
|
674
|
+
)
|
|
675
|
+
)
|
|
676
|
+
);
|
|
677
|
+
} else {
|
|
678
|
+
return h("span", "暂无数据");
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
} else if (["reference"].includes(col._type)) {
|
|
682
|
+
col.width = col._width || 250;
|
|
683
|
+
col.componentName = "dsh-td-render";
|
|
684
|
+
col.titleAlign = item._align || "center";
|
|
685
|
+
col.columnAlign = item._align || "center";
|
|
686
|
+
col.render = (h, params) => {
|
|
687
|
+
if (!params.row[col._key]) {
|
|
688
|
+
return h("span", "暂无数据");
|
|
689
|
+
}
|
|
690
|
+
let content = params.row[col._key] && params.row[col._key]._name;
|
|
691
|
+
while (content && content._name) {
|
|
692
|
+
content = content._name;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (Array.isArray(content)) {
|
|
696
|
+
content = (content[0] && content[0].name) || "";
|
|
697
|
+
}
|
|
698
|
+
return h(
|
|
699
|
+
"Ctooltip",
|
|
700
|
+
{
|
|
701
|
+
props: {
|
|
702
|
+
placement: "top",
|
|
703
|
+
transfer: true,
|
|
704
|
+
content: String(content) || "单条关联"
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
[
|
|
708
|
+
h(
|
|
709
|
+
"span",
|
|
710
|
+
{
|
|
711
|
+
style: {
|
|
712
|
+
height: "24px",
|
|
713
|
+
lineHeight: 1.6,
|
|
714
|
+
display: "inline-block",
|
|
715
|
+
width: "fit-content",
|
|
716
|
+
maxWidth: "100%",
|
|
717
|
+
verticalAlign: "middle",
|
|
718
|
+
margin: "auto",
|
|
719
|
+
background: "#f2f8ff",
|
|
720
|
+
border: "1px solid #3DB8C5",
|
|
721
|
+
borderRadius: "4px",
|
|
722
|
+
color: themeColor,
|
|
723
|
+
padding: "0 5px"
|
|
724
|
+
},
|
|
725
|
+
class: "dsh-ellipsis"
|
|
726
|
+
},
|
|
727
|
+
[
|
|
728
|
+
h("Icon", {
|
|
729
|
+
props: {
|
|
730
|
+
type: "ios-link"
|
|
731
|
+
},
|
|
732
|
+
class: "table-reference-icon"
|
|
733
|
+
}),
|
|
734
|
+
h("span", {}, content || "单条关联")
|
|
735
|
+
]
|
|
736
|
+
)
|
|
737
|
+
]
|
|
738
|
+
);
|
|
739
|
+
};
|
|
740
|
+
} else if (["referenceBy"].includes(col._type)) {
|
|
741
|
+
col.titleAlign = item._align || "center";
|
|
742
|
+
col.columnAlign = item._align || "center";
|
|
743
|
+
col.width = col._width || 100;
|
|
744
|
+
col.componentName = "dsh-td-render";
|
|
745
|
+
col.render = (h, params) => {
|
|
746
|
+
let count = (params.row[col._key] && params.row[col._key].count) || 0;
|
|
747
|
+
return h(
|
|
748
|
+
"span",
|
|
749
|
+
{
|
|
750
|
+
style: {
|
|
751
|
+
display: "inline-block",
|
|
752
|
+
width: "54px",
|
|
753
|
+
height: "24px",
|
|
754
|
+
lineHeight: "24px",
|
|
755
|
+
// marginLeft: "50%",
|
|
756
|
+
// transform: "translateX(-50%)",
|
|
757
|
+
background: "rgba(96, 144, 237, 0.15)",
|
|
758
|
+
borderRadius: "12px",
|
|
759
|
+
textAlign: "center",
|
|
760
|
+
color: themeColor
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
[
|
|
764
|
+
h("Icon", {
|
|
765
|
+
props: {
|
|
766
|
+
type: "ios-link"
|
|
767
|
+
},
|
|
768
|
+
class: "table-icon-common dsh-margin-right5"
|
|
769
|
+
}),
|
|
770
|
+
h(
|
|
771
|
+
"span",
|
|
772
|
+
{
|
|
773
|
+
class: "table-text-common"
|
|
774
|
+
},
|
|
775
|
+
`${count}条`
|
|
776
|
+
)
|
|
777
|
+
]
|
|
778
|
+
);
|
|
779
|
+
};
|
|
780
|
+
} else if (["link"].includes(col._type)) {
|
|
781
|
+
col.width = col._width || Math.max(titleWidth, 100);
|
|
782
|
+
col.componentName = "dsh-td-render";
|
|
783
|
+
col.render = (h, params) => {
|
|
784
|
+
return h(
|
|
785
|
+
"div",
|
|
786
|
+
{
|
|
787
|
+
class: "dsh-ellipsis"
|
|
788
|
+
},
|
|
789
|
+
[
|
|
790
|
+
h("Icon", {
|
|
791
|
+
props: {
|
|
792
|
+
type: "ios-link"
|
|
793
|
+
},
|
|
794
|
+
class: "table-icon-common dsh-margin-right5"
|
|
795
|
+
}),
|
|
796
|
+
h(
|
|
797
|
+
"span",
|
|
798
|
+
{
|
|
799
|
+
class: "table-text-common"
|
|
800
|
+
},
|
|
801
|
+
params.row[col._key]
|
|
802
|
+
)
|
|
803
|
+
]
|
|
804
|
+
);
|
|
805
|
+
};
|
|
806
|
+
} else if (["render"].includes(col._type)) {
|
|
807
|
+
col.width = col._width || Math.max(titleWidth, 100);
|
|
808
|
+
col.componentName = "dsh-td-render";
|
|
809
|
+
col.render = col._render;
|
|
810
|
+
} else if (["action"].includes(col._type)) {
|
|
811
|
+
col.type = "expane";
|
|
812
|
+
// col.isFrozenRight = col._isFrozenRight;
|
|
813
|
+
col.componentName = "dsh-td-render";
|
|
814
|
+
col.titleAlign = item._align || "center";
|
|
815
|
+
col.columnAlign = item._align || "center";
|
|
816
|
+
col.render = (h, params) => {
|
|
817
|
+
return h("dsh-buttons", {
|
|
818
|
+
props: {
|
|
819
|
+
list: col._getBtnList ? col._getBtnList.call(this, params.row) : this.$getOperationList(col._list),
|
|
820
|
+
itemClass: "table-operation-btn"
|
|
821
|
+
},
|
|
822
|
+
on: {
|
|
823
|
+
click: (operationItem) => {
|
|
824
|
+
this.$dispatchEvent(operationItem, params);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
};
|
|
829
|
+
} else if (["coordinates"].includes(col._type)) {
|
|
830
|
+
col.width = col._width || 110;
|
|
831
|
+
col.columnAlign = item._align || "center";
|
|
832
|
+
col.titleAlign = item._align || "center";
|
|
833
|
+
col.componentName = "dsh-td-render";
|
|
834
|
+
col.render = (h, params) => {
|
|
835
|
+
return h(
|
|
836
|
+
"div",
|
|
837
|
+
{
|
|
838
|
+
style: {
|
|
839
|
+
width: "100%",
|
|
840
|
+
overflow: "hidden"
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
[
|
|
844
|
+
h(
|
|
845
|
+
"span",
|
|
846
|
+
{
|
|
847
|
+
style: {
|
|
848
|
+
display: "inline-block",
|
|
849
|
+
height: "24px",
|
|
850
|
+
lineHeight: "24px",
|
|
851
|
+
padding: "0 5px",
|
|
852
|
+
margin: "auto",
|
|
853
|
+
background: "rgba(96, 144, 237, 0.15)",
|
|
854
|
+
borderRadius: "12px",
|
|
855
|
+
textAlign: "center",
|
|
856
|
+
color: themeColor
|
|
857
|
+
}
|
|
858
|
+
},
|
|
859
|
+
[
|
|
860
|
+
h("Icon", {
|
|
861
|
+
props: {
|
|
862
|
+
custom: "bico-font bico-position"
|
|
863
|
+
},
|
|
864
|
+
style: {
|
|
865
|
+
fontSize: "18px",
|
|
866
|
+
color: themeColor
|
|
867
|
+
}
|
|
868
|
+
}),
|
|
869
|
+
h(
|
|
870
|
+
"span",
|
|
871
|
+
{
|
|
872
|
+
style: {
|
|
873
|
+
fontSize: "14px",
|
|
874
|
+
color: themeColor
|
|
875
|
+
}
|
|
876
|
+
},
|
|
877
|
+
params.row[col._key] && params.row[col._key].name || "暂无数据"
|
|
878
|
+
)
|
|
879
|
+
]
|
|
880
|
+
)
|
|
881
|
+
]
|
|
882
|
+
);
|
|
883
|
+
};
|
|
884
|
+
} else if (["labels"].includes(col._type)) {
|
|
885
|
+
col.width = col._width || 250;
|
|
886
|
+
col.columnAlign = item._align || "center";
|
|
887
|
+
col.titleAlign = item._align || "center";
|
|
888
|
+
col.componentName = "dsh-td-render";
|
|
889
|
+
|
|
890
|
+
col.render = (h, params) => {
|
|
891
|
+
if (params.row[col._key] && params.row[col._key].length > 0) {
|
|
892
|
+
return h(
|
|
893
|
+
"div",
|
|
894
|
+
{
|
|
895
|
+
style: {
|
|
896
|
+
display: "flex",
|
|
897
|
+
overflow: "hidden"
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
[
|
|
901
|
+
...params.row[col._key].map((item) => {
|
|
902
|
+
return h(
|
|
903
|
+
"Ctooltip",
|
|
904
|
+
{
|
|
905
|
+
props: {
|
|
906
|
+
placement: "top",
|
|
907
|
+
transfer: true,
|
|
908
|
+
content: item.name
|
|
909
|
+
},
|
|
910
|
+
style: {
|
|
911
|
+
minWidth: "35px",
|
|
912
|
+
marginLeft: "3px"
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
[
|
|
916
|
+
h(
|
|
917
|
+
"div",
|
|
918
|
+
{
|
|
919
|
+
style: {
|
|
920
|
+
maxWidth: "100%",
|
|
921
|
+
background: "#ECF3FD",
|
|
922
|
+
color: "#3D84EE"
|
|
923
|
+
},
|
|
924
|
+
class: "table-select-common dsh-ellipsis"
|
|
925
|
+
},
|
|
926
|
+
item.name
|
|
927
|
+
)
|
|
928
|
+
]
|
|
929
|
+
);
|
|
930
|
+
})
|
|
931
|
+
]
|
|
932
|
+
);
|
|
933
|
+
} else {
|
|
934
|
+
return h("span", "暂无数据");
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
} else if (["package"].includes(col._type)) {
|
|
938
|
+
col.width = col._width || 100;
|
|
939
|
+
col.columnAlign = item._align || "center";
|
|
940
|
+
col.titleAlign = item._align || "center";
|
|
941
|
+
col.componentName = "dsh-td-render";
|
|
942
|
+
col.render = (h, params) => {
|
|
943
|
+
if (params.row[col._key] && params.row[col._key].length > 0) {
|
|
944
|
+
return h(
|
|
945
|
+
"div",
|
|
946
|
+
{
|
|
947
|
+
style: {
|
|
948
|
+
width: "100%",
|
|
949
|
+
overflow: "hidden"
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
[
|
|
953
|
+
h(
|
|
954
|
+
"span",
|
|
955
|
+
{
|
|
956
|
+
style: {
|
|
957
|
+
display: "inline-block",
|
|
958
|
+
height: "24px",
|
|
959
|
+
lineHeight: "24px",
|
|
960
|
+
padding: "0 5px",
|
|
961
|
+
margin: "auto",
|
|
962
|
+
background: "rgba(96, 144, 237, 0.15)",
|
|
963
|
+
borderRadius: "12px",
|
|
964
|
+
textAlign: "center",
|
|
965
|
+
color: themeColor
|
|
966
|
+
}
|
|
967
|
+
},
|
|
968
|
+
[
|
|
969
|
+
h("Icon", {
|
|
970
|
+
props: {
|
|
971
|
+
custom: "bico-font bico-Cascadetable"
|
|
972
|
+
},
|
|
973
|
+
class: "table-icon-common dsh-margin-right5"
|
|
974
|
+
}),
|
|
975
|
+
h(
|
|
976
|
+
"span",
|
|
977
|
+
{
|
|
978
|
+
class: "table-text-common"
|
|
979
|
+
},
|
|
980
|
+
`${params.row[col._key] ? params.row[col._key].form.length : 0}项`
|
|
981
|
+
)
|
|
982
|
+
]
|
|
983
|
+
)
|
|
984
|
+
]
|
|
985
|
+
);
|
|
986
|
+
} else {
|
|
987
|
+
return h("span", "暂无数据");
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
columns.push(col);
|
|
993
|
+
});
|
|
994
|
+
return columns;
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
export default {
|
|
998
|
+
transformToColumns
|
|
999
|
+
};
|
|
1000
|
+
export {
|
|
1001
|
+
transformToColumns
|
|
1002
|
+
};
|