@ctzy-web-client/plugin-component-vue 1.0.52 → 1.0.54
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.
|
@@ -95,6 +95,24 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
95
95
|
const searchParams = computed(() => props.searchParams);
|
|
96
96
|
const emit = __emit;
|
|
97
97
|
const debounceDelay = useGlobalConfig("debounceDelay", 500);
|
|
98
|
+
const calculateNameLengthPx = (name, cnCharSize = 20, enCharSize = 6, padding = 15) => {
|
|
99
|
+
const str = String(name != null ? name : "").trim();
|
|
100
|
+
if (!str)
|
|
101
|
+
return 60;
|
|
102
|
+
let cnCount = 0;
|
|
103
|
+
let enCount = 0;
|
|
104
|
+
for (const char of str) {
|
|
105
|
+
const isCn = /[\u4e00-\u9fa5\uff00-\uffff]/.test(char);
|
|
106
|
+
if (isCn) {
|
|
107
|
+
cnCount++;
|
|
108
|
+
} else {
|
|
109
|
+
enCount++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const textWidth = cnCount * cnCharSize + enCount * enCharSize;
|
|
113
|
+
const totalPx = Math.max(60, textWidth + padding);
|
|
114
|
+
return totalPx;
|
|
115
|
+
};
|
|
98
116
|
provide(
|
|
99
117
|
dataTableKey,
|
|
100
118
|
reactive({
|
|
@@ -117,7 +135,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
117
135
|
if (res.code != 0) {
|
|
118
136
|
return;
|
|
119
137
|
}
|
|
120
|
-
updateMaxHeight(res.data);
|
|
121
138
|
const _userService = unref(userService);
|
|
122
139
|
if (!_userService) {
|
|
123
140
|
return;
|
|
@@ -183,7 +200,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
183
200
|
if (res.code != 0) {
|
|
184
201
|
ElMessage.error(res.msg);
|
|
185
202
|
}
|
|
186
|
-
updateMaxHeight(res.data);
|
|
187
203
|
});
|
|
188
204
|
function sortColumn(array) {
|
|
189
205
|
array.forEach((item) => {
|
|
@@ -333,7 +349,8 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
333
349
|
key: item.attrName,
|
|
334
350
|
label: item.title,
|
|
335
351
|
prop: item.fullAttrName,
|
|
336
|
-
"min-width": item.
|
|
352
|
+
"min-width": calculateNameLengthPx(item.title),
|
|
353
|
+
width: item.width,
|
|
337
354
|
fixed: item.fixed,
|
|
338
355
|
align: item.align
|
|
339
356
|
}, { ref_for: true }, item.componentProps, {
|
|
@@ -359,7 +376,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
359
376
|
]) : createCommentVNode("v-if", true)
|
|
360
377
|
]),
|
|
361
378
|
_: 2
|
|
362
|
-
}, 1040, ["column-key", "label", "prop", "min-width", "fixed", "align", "sortable"]);
|
|
379
|
+
}, 1040, ["column-key", "label", "prop", "min-width", "width", "fixed", "align", "sortable"]);
|
|
363
380
|
}), 128))
|
|
364
381
|
]),
|
|
365
382
|
renderSlot(_ctx.$slots, "column-append")
|
|
@@ -99,6 +99,24 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
99
99
|
const searchParams = vue.computed(() => props.searchParams);
|
|
100
100
|
const emit = __emit;
|
|
101
101
|
const debounceDelay = webBaseClientVue.useGlobalConfig("debounceDelay", 500);
|
|
102
|
+
const calculateNameLengthPx = (name, cnCharSize = 20, enCharSize = 6, padding = 15) => {
|
|
103
|
+
const str = String(name != null ? name : "").trim();
|
|
104
|
+
if (!str)
|
|
105
|
+
return 60;
|
|
106
|
+
let cnCount = 0;
|
|
107
|
+
let enCount = 0;
|
|
108
|
+
for (const char of str) {
|
|
109
|
+
const isCn = /[\u4e00-\u9fa5\uff00-\uffff]/.test(char);
|
|
110
|
+
if (isCn) {
|
|
111
|
+
cnCount++;
|
|
112
|
+
} else {
|
|
113
|
+
enCount++;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const textWidth = cnCount * cnCharSize + enCount * enCharSize;
|
|
117
|
+
const totalPx = Math.max(60, textWidth + padding);
|
|
118
|
+
return totalPx;
|
|
119
|
+
};
|
|
102
120
|
vue.provide(
|
|
103
121
|
webBaseClientVue.dataTableKey,
|
|
104
122
|
vue.reactive({
|
|
@@ -121,7 +139,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
121
139
|
if (res.code != 0) {
|
|
122
140
|
return;
|
|
123
141
|
}
|
|
124
|
-
updateMaxHeight(res.data);
|
|
125
142
|
const _userService = vue.unref(userService);
|
|
126
143
|
if (!_userService) {
|
|
127
144
|
return;
|
|
@@ -187,7 +204,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
187
204
|
if (res.code != 0) {
|
|
188
205
|
ElementPlus.ElMessage.error(res.msg);
|
|
189
206
|
}
|
|
190
|
-
updateMaxHeight(res.data);
|
|
191
207
|
});
|
|
192
208
|
function sortColumn(array) {
|
|
193
209
|
array.forEach((item) => {
|
|
@@ -337,7 +353,8 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
337
353
|
key: item.attrName,
|
|
338
354
|
label: item.title,
|
|
339
355
|
prop: item.fullAttrName,
|
|
340
|
-
"min-width": item.
|
|
356
|
+
"min-width": calculateNameLengthPx(item.title),
|
|
357
|
+
width: item.width,
|
|
341
358
|
fixed: item.fixed,
|
|
342
359
|
align: item.align
|
|
343
360
|
}, { ref_for: true }, item.componentProps, {
|
|
@@ -363,7 +380,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
363
380
|
]) : vue.createCommentVNode("v-if", true)
|
|
364
381
|
]),
|
|
365
382
|
_: 2
|
|
366
|
-
}, 1040, ["column-key", "label", "prop", "min-width", "fixed", "align", "sortable"]);
|
|
383
|
+
}, 1040, ["column-key", "label", "prop", "min-width", "width", "fixed", "align", "sortable"]);
|
|
367
384
|
}), 128))
|
|
368
385
|
]),
|
|
369
386
|
vue.renderSlot(_ctx.$slots, "column-append")
|
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
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"
|
|
@@ -43,8 +42,9 @@
|
|
|
43
42
|
:key="item.attrName"
|
|
44
43
|
:label="item.title"
|
|
45
44
|
:prop="item.fullAttrName"
|
|
46
|
-
:min-width="item.
|
|
47
|
-
|
|
45
|
+
:min-width="calculateNameLengthPx(item.title)"
|
|
46
|
+
:width="item.width"
|
|
47
|
+
:fixed="item.fixed"
|
|
48
48
|
:align="item.align"
|
|
49
49
|
v-bind="item.componentProps"
|
|
50
50
|
:sortable="item.sortable=='custom'"
|
|
@@ -224,7 +224,26 @@ const searchParams = computed(() => props.searchParams);
|
|
|
224
224
|
const emit = defineEmits(['drag','headerWidthChange']);
|
|
225
225
|
|
|
226
226
|
const debounceDelay = useGlobalConfig('debounceDelay', 500);
|
|
227
|
-
|
|
227
|
+
const calculateNameLengthPx = (name, cnCharSize = 20, enCharSize = 6, padding = 15) => {
|
|
228
|
+
const str = String(name ?? '').trim();
|
|
229
|
+
if (!str) return 60;
|
|
230
|
+
let cnCount = 0; // 中文字符、全角符号计数
|
|
231
|
+
let enCount = 0; // 英文、数字、半角符号计数
|
|
232
|
+
// 正则匹配区分字符
|
|
233
|
+
for (const char of str) {
|
|
234
|
+
// 判断是否为中文/全角字符
|
|
235
|
+
const isCn = /[\u4e00-\u9fa5\uff00-\uffff]/.test(char);
|
|
236
|
+
if (isCn) {
|
|
237
|
+
cnCount++;
|
|
238
|
+
} else {
|
|
239
|
+
enCount++;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// 分别计算字符总宽度,再加两边内边距
|
|
243
|
+
const textWidth = cnCount * cnCharSize + enCount * enCharSize;
|
|
244
|
+
const totalPx = Math.max(60, textWidth + padding);
|
|
245
|
+
return totalPx;
|
|
246
|
+
}
|
|
228
247
|
//当前data table 上下文对象
|
|
229
248
|
provide(
|
|
230
249
|
dataTableKey,
|
|
@@ -253,7 +272,7 @@ useEventDispatcher(dataTable, 'load-successfully', async (res) => {
|
|
|
253
272
|
if (res.code != 0) {
|
|
254
273
|
return;
|
|
255
274
|
}
|
|
256
|
-
|
|
275
|
+
|
|
257
276
|
const _userService = unref(userService);
|
|
258
277
|
|
|
259
278
|
if (!_userService) {
|
|
@@ -347,7 +366,7 @@ useEventDispatcher(dataTable, 'load-successfully', (res) => {
|
|
|
347
366
|
if (res.code != 0) {
|
|
348
367
|
ElMessage.error(res.msg);
|
|
349
368
|
}
|
|
350
|
-
|
|
369
|
+
|
|
351
370
|
});
|
|
352
371
|
|
|
353
372
|
function sortColumn(array) {
|
|
File without changes
|
|
File without changes
|