@ctzy-web-client/plugin-component-vue 1.0.53 → 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({
@@ -331,7 +349,8 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
331
349
  key: item.attrName,
332
350
  label: item.title,
333
351
  prop: item.fullAttrName,
334
- "min-width": item.width,
352
+ "min-width": calculateNameLengthPx(item.title),
353
+ width: item.width,
335
354
  fixed: item.fixed,
336
355
  align: item.align
337
356
  }, { ref_for: true }, item.componentProps, {
@@ -357,7 +376,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
357
376
  ]) : createCommentVNode("v-if", true)
358
377
  ]),
359
378
  _: 2
360
- }, 1040, ["column-key", "label", "prop", "min-width", "fixed", "align", "sortable"]);
379
+ }, 1040, ["column-key", "label", "prop", "min-width", "width", "fixed", "align", "sortable"]);
361
380
  }), 128))
362
381
  ]),
363
382
  renderSlot(_ctx.$slots, "column-append")
@@ -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}
@@ -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({
@@ -335,7 +353,8 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
335
353
  key: item.attrName,
336
354
  label: item.title,
337
355
  prop: item.fullAttrName,
338
- "min-width": item.width,
356
+ "min-width": calculateNameLengthPx(item.title),
357
+ width: item.width,
339
358
  fixed: item.fixed,
340
359
  align: item.align
341
360
  }, { ref_for: true }, item.componentProps, {
@@ -361,7 +380,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
361
380
  ]) : vue.createCommentVNode("v-if", true)
362
381
  ]),
363
382
  _: 2
364
- }, 1040, ["column-key", "label", "prop", "min-width", "fixed", "align", "sortable"]);
383
+ }, 1040, ["column-key", "label", "prop", "min-width", "width", "fixed", "align", "sortable"]);
365
384
  }), 128))
366
385
  ]),
367
386
  vue.renderSlot(_ctx.$slots, "column-append")
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzy-web-client/plugin-component-vue",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "exports": {
@@ -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.width"
47
- :fixed="item.fixed"
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,
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}