@ctzy-web-client/plugin-component-vue 1.0.53 → 1.0.55
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/es/data-table/data-table-column.mjs +3 -2
- package/es/data-table/data-table.mjs +44 -5
- package/es/utils.css +1 -0
- package/lib/data-table/data-table-column.js +2 -1
- package/lib/data-table/data-table.js +43 -4
- package/lib/utils.css +1 -0
- package/package.json +1 -1
- package/src/data-table/data-table-column.vue +5 -1
- package/src/data-table/data-table.vue +55 -5
- package/es/index.css +0 -1
- package/lib/index.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, useAttrs, inject, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot,
|
|
1
|
+
import { defineComponent, useAttrs, inject, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot, createElementVNode, toDisplayString, createCommentVNode } from 'vue';
|
|
2
2
|
import { ElTableColumn } from 'element-plus';
|
|
3
3
|
import { dataTableKey } from '@ctzy-web-client/web-base-client-vue';
|
|
4
4
|
import _export_sfc from '../_virtual/_plugin-vue_export-helper.mjs';
|
|
@@ -12,6 +12,7 @@ if (typeof __name === 'undefined') {
|
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
const _hoisted_1 = { style: { "white-space": "nowrap", "display": "inline-block" } };
|
|
15
16
|
const __default__ = defineComponent({ name: "BwaDataTableColumn" });
|
|
16
17
|
const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
17
18
|
props: {
|
|
@@ -44,7 +45,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
44
45
|
column: column2,
|
|
45
46
|
$index
|
|
46
47
|
}, () => [
|
|
47
|
-
|
|
48
|
+
createElementVNode("span", _hoisted_1, toDisplayString(column2.label), 1)
|
|
48
49
|
])
|
|
49
50
|
]),
|
|
50
51
|
default: withCtx(({ row, $index }) => [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, useAttrs, ref, computed, unref, watch, provide, reactive, nextTick, onUnmounted, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot, createVNode, mergeProps, withCtx, createBlock, createElementVNode, createCommentVNode, Fragment, renderList,
|
|
1
|
+
import { defineComponent, useAttrs, ref, computed, unref, watch, provide, reactive, nextTick, onUnmounted, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot, createVNode, mergeProps, withCtx, createBlock, createElementVNode, createCommentVNode, Fragment, renderList, toDisplayString } from 'vue';
|
|
2
2
|
import { ElMessage, ElTable, ElTableColumn, ElPagination } from 'element-plus';
|
|
3
3
|
import { useService, useGlobalConfig, dataTableKey, useNamespace, useEventDispatcher } from '@ctzy-web-client/web-base-client-vue';
|
|
4
4
|
import DynamicComponent from './dynamic-component.mjs';
|
|
@@ -17,6 +17,7 @@ if (typeof __name === 'undefined') {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
const _hoisted_1 = { style: { "white-space": "nowrap", "display": "inline-block" } };
|
|
20
21
|
const __default__ = defineComponent({ name: "BwaDataTable" });
|
|
21
22
|
const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
22
23
|
props: {
|
|
@@ -95,6 +96,43 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
95
96
|
const searchParams = computed(() => props.searchParams);
|
|
96
97
|
const emit = __emit;
|
|
97
98
|
const debounceDelay = useGlobalConfig("debounceDelay", 500);
|
|
99
|
+
const calculateNameLengthPx = (name, hasSort = false, cnCharSize = 20, enCharSize = 6, padding = 30) => {
|
|
100
|
+
const str = String(name != null ? name : "").trim();
|
|
101
|
+
if (!str)
|
|
102
|
+
return 80;
|
|
103
|
+
let cnCount = 0;
|
|
104
|
+
let enCount = 0;
|
|
105
|
+
for (const char of str) {
|
|
106
|
+
const isCn = /[\u4e00-\u9fa5\uff00-\uffff]/.test(char);
|
|
107
|
+
isCn ? cnCount++ : enCount++;
|
|
108
|
+
}
|
|
109
|
+
let textWidth = cnCount * cnCharSize + enCount * enCharSize;
|
|
110
|
+
if (hasSort)
|
|
111
|
+
textWidth += 32;
|
|
112
|
+
const totalPx = Math.max(90, textWidth + padding);
|
|
113
|
+
return totalPx;
|
|
114
|
+
};
|
|
115
|
+
const parseWidthNum = (width) => {
|
|
116
|
+
if (width === void 0 || width === null || width === "" || width === "auto")
|
|
117
|
+
return null;
|
|
118
|
+
let num;
|
|
119
|
+
if (typeof width === "string") {
|
|
120
|
+
const pureStr = width.replace(/px$/gi, "");
|
|
121
|
+
num = Number(pureStr);
|
|
122
|
+
} else {
|
|
123
|
+
num = Number(width);
|
|
124
|
+
}
|
|
125
|
+
if (isNaN(num) || num <= 0)
|
|
126
|
+
return null;
|
|
127
|
+
return num;
|
|
128
|
+
};
|
|
129
|
+
const getColumnWidth = (item) => {
|
|
130
|
+
const minW = calculateNameLengthPx(item.title, item.sortable === "custom");
|
|
131
|
+
const customW = parseWidthNum(item.width);
|
|
132
|
+
if (customW === null)
|
|
133
|
+
return minW;
|
|
134
|
+
return Math.max(customW, minW);
|
|
135
|
+
};
|
|
98
136
|
provide(
|
|
99
137
|
dataTableKey,
|
|
100
138
|
reactive({
|
|
@@ -281,7 +319,8 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
281
319
|
data: data.value,
|
|
282
320
|
"row-key": unref(dataTable).primaryKey,
|
|
283
321
|
"show-header": "",
|
|
284
|
-
stripe: ""
|
|
322
|
+
stripe: "",
|
|
323
|
+
fit: ""
|
|
285
324
|
}, unref(attrs), {
|
|
286
325
|
onHeaderDragend: headerDragend,
|
|
287
326
|
onSelectionChange: unref(selectionChange),
|
|
@@ -331,7 +370,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
331
370
|
key: item.attrName,
|
|
332
371
|
label: item.title,
|
|
333
372
|
prop: item.fullAttrName,
|
|
334
|
-
|
|
373
|
+
width: getColumnWidth(item),
|
|
335
374
|
fixed: item.fixed,
|
|
336
375
|
align: item.align
|
|
337
376
|
}, { ref_for: true }, item.componentProps, {
|
|
@@ -339,7 +378,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
339
378
|
}), {
|
|
340
379
|
header: withCtx(() => [
|
|
341
380
|
renderSlot(_ctx.$slots, `table-header-col-${item.attrName}`, {}, () => [
|
|
342
|
-
|
|
381
|
+
createElementVNode("span", _hoisted_1, toDisplayString(item.title), 1)
|
|
343
382
|
])
|
|
344
383
|
]),
|
|
345
384
|
default: withCtx(({ row, $index }) => [
|
|
@@ -357,7 +396,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
357
396
|
]) : createCommentVNode("v-if", true)
|
|
358
397
|
]),
|
|
359
398
|
_: 2
|
|
360
|
-
}, 1040, ["column-key", "label", "prop", "
|
|
399
|
+
}, 1040, ["column-key", "label", "prop", "width", "fixed", "align", "sortable"]);
|
|
361
400
|
}), 128))
|
|
362
401
|
]),
|
|
363
402
|
renderSlot(_ctx.$slots, "column-append")
|
package/es/utils.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.letter-circle[data-v-9ba46efc]{align-items:center;border-radius:50%;color:#fff;display:flex;font-size:14px;height:24px;justify-content:center;margin-right:8px;width:24px}.pct-select-ellipsis .el-select-dropdown__item{box-sizing:border-box!important;overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important;width:100%!important}.letter-circle[data-v-c1065f11]{align-items:center;border-radius:50%;color:#fff;display:flex;flex-shrink:0;font-size:12px;height:22px;justify-content:center;width:22px}.option-container[data-v-c1065f11]{align-items:center;display:flex;width:100%}.option-text[data-v-c1065f11]{flex:1;margin-left:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
@@ -16,6 +16,7 @@ if (typeof __name === 'undefined') {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
const _hoisted_1 = { style: { "white-space": "nowrap", "display": "inline-block" } };
|
|
19
20
|
const __default__ = vue.defineComponent({ name: "BwaDataTableColumn" });
|
|
20
21
|
const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
21
22
|
props: {
|
|
@@ -48,7 +49,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
48
49
|
column: column2,
|
|
49
50
|
$index
|
|
50
51
|
}, () => [
|
|
51
|
-
vue.
|
|
52
|
+
vue.createElementVNode("span", _hoisted_1, vue.toDisplayString(column2.label), 1)
|
|
52
53
|
])
|
|
53
54
|
]),
|
|
54
55
|
default: vue.withCtx(({ row, $index }) => [
|
|
@@ -21,6 +21,7 @@ if (typeof __name === 'undefined') {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
const _hoisted_1 = { style: { "white-space": "nowrap", "display": "inline-block" } };
|
|
24
25
|
const __default__ = vue.defineComponent({ name: "BwaDataTable" });
|
|
25
26
|
const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
26
27
|
props: {
|
|
@@ -99,6 +100,43 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
99
100
|
const searchParams = vue.computed(() => props.searchParams);
|
|
100
101
|
const emit = __emit;
|
|
101
102
|
const debounceDelay = webBaseClientVue.useGlobalConfig("debounceDelay", 500);
|
|
103
|
+
const calculateNameLengthPx = (name, hasSort = false, cnCharSize = 20, enCharSize = 6, padding = 30) => {
|
|
104
|
+
const str = String(name != null ? name : "").trim();
|
|
105
|
+
if (!str)
|
|
106
|
+
return 80;
|
|
107
|
+
let cnCount = 0;
|
|
108
|
+
let enCount = 0;
|
|
109
|
+
for (const char of str) {
|
|
110
|
+
const isCn = /[\u4e00-\u9fa5\uff00-\uffff]/.test(char);
|
|
111
|
+
isCn ? cnCount++ : enCount++;
|
|
112
|
+
}
|
|
113
|
+
let textWidth = cnCount * cnCharSize + enCount * enCharSize;
|
|
114
|
+
if (hasSort)
|
|
115
|
+
textWidth += 32;
|
|
116
|
+
const totalPx = Math.max(90, textWidth + padding);
|
|
117
|
+
return totalPx;
|
|
118
|
+
};
|
|
119
|
+
const parseWidthNum = (width) => {
|
|
120
|
+
if (width === void 0 || width === null || width === "" || width === "auto")
|
|
121
|
+
return null;
|
|
122
|
+
let num;
|
|
123
|
+
if (typeof width === "string") {
|
|
124
|
+
const pureStr = width.replace(/px$/gi, "");
|
|
125
|
+
num = Number(pureStr);
|
|
126
|
+
} else {
|
|
127
|
+
num = Number(width);
|
|
128
|
+
}
|
|
129
|
+
if (isNaN(num) || num <= 0)
|
|
130
|
+
return null;
|
|
131
|
+
return num;
|
|
132
|
+
};
|
|
133
|
+
const getColumnWidth = (item) => {
|
|
134
|
+
const minW = calculateNameLengthPx(item.title, item.sortable === "custom");
|
|
135
|
+
const customW = parseWidthNum(item.width);
|
|
136
|
+
if (customW === null)
|
|
137
|
+
return minW;
|
|
138
|
+
return Math.max(customW, minW);
|
|
139
|
+
};
|
|
102
140
|
vue.provide(
|
|
103
141
|
webBaseClientVue.dataTableKey,
|
|
104
142
|
vue.reactive({
|
|
@@ -285,7 +323,8 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
285
323
|
data: data.value,
|
|
286
324
|
"row-key": vue.unref(dataTable).primaryKey,
|
|
287
325
|
"show-header": "",
|
|
288
|
-
stripe: ""
|
|
326
|
+
stripe: "",
|
|
327
|
+
fit: ""
|
|
289
328
|
}, vue.unref(attrs), {
|
|
290
329
|
onHeaderDragend: headerDragend,
|
|
291
330
|
onSelectionChange: vue.unref(selectionChange),
|
|
@@ -335,7 +374,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
335
374
|
key: item.attrName,
|
|
336
375
|
label: item.title,
|
|
337
376
|
prop: item.fullAttrName,
|
|
338
|
-
|
|
377
|
+
width: getColumnWidth(item),
|
|
339
378
|
fixed: item.fixed,
|
|
340
379
|
align: item.align
|
|
341
380
|
}, { ref_for: true }, item.componentProps, {
|
|
@@ -343,7 +382,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
343
382
|
}), {
|
|
344
383
|
header: vue.withCtx(() => [
|
|
345
384
|
vue.renderSlot(_ctx.$slots, `table-header-col-${item.attrName}`, {}, () => [
|
|
346
|
-
vue.
|
|
385
|
+
vue.createElementVNode("span", _hoisted_1, vue.toDisplayString(item.title), 1)
|
|
347
386
|
])
|
|
348
387
|
]),
|
|
349
388
|
default: vue.withCtx(({ row, $index }) => [
|
|
@@ -361,7 +400,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
361
400
|
]) : vue.createCommentVNode("v-if", true)
|
|
362
401
|
]),
|
|
363
402
|
_: 2
|
|
364
|
-
}, 1040, ["column-key", "label", "prop", "
|
|
403
|
+
}, 1040, ["column-key", "label", "prop", "width", "fixed", "align", "sortable"]);
|
|
365
404
|
}), 128))
|
|
366
405
|
]),
|
|
367
406
|
vue.renderSlot(_ctx.$slots, "column-append")
|
package/lib/utils.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.letter-circle[data-v-9ba46efc]{align-items:center;border-radius:50%;color:#fff;display:flex;font-size:14px;height:24px;justify-content:center;margin-right:8px;width:24px}.pct-select-ellipsis .el-select-dropdown__item{box-sizing:border-box!important;overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important;width:100%!important}.letter-circle[data-v-c1065f11]{align-items:center;border-radius:50%;color:#fff;display:flex;flex-shrink:0;font-size:12px;height:22px;justify-content:center;width:22px}.option-container[data-v-c1065f11]{align-items:center;display:flex;width:100%}.option-text[data-v-c1065f11]{flex:1;margin-left:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
package/package.json
CHANGED
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
v-bind="attrs"
|
|
6
6
|
>
|
|
7
7
|
<template #header="{ column, $index }">
|
|
8
|
-
<slot name="header" :column="column" :$index="$index">
|
|
8
|
+
<slot name="header" :column="column" :$index="$index">
|
|
9
|
+
<span style="white-space: nowrap; display: inline-block;">
|
|
10
|
+
{{ column.label }}
|
|
11
|
+
</span>
|
|
12
|
+
</slot>
|
|
9
13
|
</template>
|
|
10
14
|
|
|
11
15
|
<template #default="{ row, $index }">
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<ElTable
|
|
6
6
|
class="content"
|
|
7
7
|
:height="realHeight"
|
|
8
|
-
|
|
9
8
|
ref="elTable"
|
|
10
9
|
:data="data"
|
|
11
10
|
:row-key="dataTable.primaryKey"
|
|
12
11
|
show-header
|
|
13
12
|
stripe
|
|
13
|
+
fit
|
|
14
14
|
v-bind="attrs"
|
|
15
15
|
@header-dragend='headerDragend'
|
|
16
16
|
@selection-change="selectionChange"
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
:key="item.attrName"
|
|
44
44
|
:label="item.title"
|
|
45
45
|
:prop="item.fullAttrName"
|
|
46
|
-
:
|
|
47
|
-
|
|
46
|
+
:width="getColumnWidth(item)"
|
|
47
|
+
:fixed="item.fixed"
|
|
48
48
|
:align="item.align"
|
|
49
49
|
v-bind="item.componentProps"
|
|
50
50
|
:sortable="item.sortable=='custom'"
|
|
51
51
|
>
|
|
52
52
|
<template #header>
|
|
53
53
|
<slot :name="`table-header-col-${item.attrName}`">
|
|
54
|
-
{{ item.title }}
|
|
54
|
+
<span style="white-space: nowrap; display: inline-block;"> {{ item.title }}</span>
|
|
55
55
|
</slot>
|
|
56
56
|
</template>
|
|
57
57
|
<template #default="{ row, $index }">
|
|
@@ -223,8 +223,58 @@ const searchParams = computed(() => props.searchParams);
|
|
|
223
223
|
|
|
224
224
|
const emit = defineEmits(['drag','headerWidthChange']);
|
|
225
225
|
|
|
226
|
-
const debounceDelay = useGlobalConfig('debounceDelay', 500);
|
|
226
|
+
const debounceDelay = useGlobalConfig('debounceDelay', 500);const calculateNameLengthPx = (
|
|
227
|
+
name,
|
|
228
|
+
hasSort = false,
|
|
229
|
+
cnCharSize = 20,
|
|
230
|
+
enCharSize = 6,
|
|
231
|
+
padding = 30
|
|
232
|
+
) => {
|
|
233
|
+
const str = String(name ?? '').trim();
|
|
234
|
+
if (!str) return 80;
|
|
235
|
+
let cnCount = 0;
|
|
236
|
+
let enCount = 0;
|
|
237
|
+
|
|
238
|
+
for (const char of str) {
|
|
239
|
+
const isCn = /[\u4e00-\u9fa5\uff00-\uffff]/.test(char);
|
|
240
|
+
isCn ? cnCount++ : enCount++;
|
|
241
|
+
}
|
|
227
242
|
|
|
243
|
+
let textWidth = cnCount * cnCharSize + enCount * enCharSize;
|
|
244
|
+
if (hasSort) textWidth += 32;
|
|
245
|
+
const totalPx = Math.max(90, textWidth + padding);
|
|
246
|
+
return totalPx;
|
|
247
|
+
};
|
|
248
|
+
const parseWidthNum = (width) => {
|
|
249
|
+
// 空值、auto 标记为无自定义宽度
|
|
250
|
+
if (width === undefined || width === null || width === '' || width === 'auto') return null;
|
|
251
|
+
let num;
|
|
252
|
+
if (typeof width === 'string') {
|
|
253
|
+
// 统一去掉末尾px,忽略大小写 PX/Px
|
|
254
|
+
const pureStr = width.replace(/px$/gi, '');
|
|
255
|
+
num = Number(pureStr);
|
|
256
|
+
} else {
|
|
257
|
+
num = Number(width);
|
|
258
|
+
}
|
|
259
|
+
// 非法数字、负数直接返回null,走最小宽度兜底
|
|
260
|
+
if (isNaN(num) || num <= 0) return null;
|
|
261
|
+
return num;
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* 获取最终列宽度
|
|
265
|
+
* @param item 列配置项
|
|
266
|
+
* @returns 最终生效宽度
|
|
267
|
+
*/
|
|
268
|
+
const getColumnWidth = (item) => {
|
|
269
|
+
const minW = calculateNameLengthPx(item.title, item.sortable === 'custom');
|
|
270
|
+
// 无自定义宽度直接返回计算最小值
|
|
271
|
+
|
|
272
|
+
const customW = parseWidthNum(item.width);
|
|
273
|
+
|
|
274
|
+
// 无合法自定义宽度,直接用自适应最小宽度
|
|
275
|
+
if (customW === null) return minW;
|
|
276
|
+
return Math.max(customW, minW);
|
|
277
|
+
};
|
|
228
278
|
//当前data table 上下文对象
|
|
229
279
|
provide(
|
|
230
280
|
dataTableKey,
|
package/es/index.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.letter-circle[data-v-9ba46efc]{font-size:14px;height:24px;margin-right:8px;width:24px}.letter-circle[data-v-9ba46efc],.letter-circle[data-v-c1065f11]{align-items:center;border-radius:50%;color:#fff;display:flex;justify-content:center}.letter-circle[data-v-c1065f11]{flex-shrink:0;font-size:12px;height:22px;width:22px}.option-container[data-v-c1065f11]{align-items:center;display:flex;width:100%}.option-text[data-v-c1065f11]{flex:1;margin-left:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pct-select-ellipsis .el-select-dropdown__item{box-sizing:border-box!important;overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important;width:100%!important}
|
package/lib/index.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.letter-circle[data-v-9ba46efc]{font-size:14px;height:24px;margin-right:8px;width:24px}.letter-circle[data-v-9ba46efc],.letter-circle[data-v-c1065f11]{align-items:center;border-radius:50%;color:#fff;display:flex;justify-content:center}.letter-circle[data-v-c1065f11]{flex-shrink:0;font-size:12px;height:22px;width:22px}.option-container[data-v-c1065f11]{align-items:center;display:flex;width:100%}.option-text[data-v-c1065f11]{flex:1;margin-left:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pct-select-ellipsis .el-select-dropdown__item{box-sizing:border-box!important;overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important;width:100%!important}
|