@weitutech/by-components 1.1.43 → 1.1.45

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.
@@ -60752,8 +60752,8 @@ var component = normalizeComponent(
60752
60752
  )
60753
60753
 
60754
60754
  /* harmony default export */ var pager = (component.exports);
60755
- ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"72942c6c-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/table/index.vue?vue&type=template&id=58d17823
60756
- var tablevue_type_template_id_58d17823_render = function render() {
60755
+ ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"72942c6c-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/table/index.vue?vue&type=template&id=4926859a
60756
+ var tablevue_type_template_id_4926859a_render = function render() {
60757
60757
  var _vm = this,
60758
60758
  _c = _vm._self._c;
60759
60759
  return _c('div', [_c('vxe-grid', _vm._g(_vm._b({
@@ -60817,6 +60817,7 @@ var tablevue_type_template_id_58d17823_render = function render() {
60817
60817
  attrs: {
60818
60818
  "info-method": _vm.gridOptions.customColumnConfig.infoMethod,
60819
60819
  "submit-method": _vm.gridOptions.customColumnConfig.submitMethod,
60820
+ "fixed-max-count": _vm.gridOptions.customColumnConfig.fixedMaxCount,
60820
60821
  "dialog-visible": _vm.customTableVisible
60821
60822
  },
60822
60823
  on: {
@@ -60826,7 +60827,7 @@ var tablevue_type_template_id_58d17823_render = function render() {
60826
60827
  }
60827
60828
  }) : _vm._e()], 1);
60828
60829
  };
60829
- var tablevue_type_template_id_58d17823_staticRenderFns = [];
60830
+ var tablevue_type_template_id_4926859a_staticRenderFns = [];
60830
60831
 
60831
60832
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
60832
60833
  var es_array_push = __webpack_require__(4114);
@@ -60846,8 +60847,8 @@ var es_set_is_superset_of_v2 = __webpack_require__(2475);
60846
60847
  var es_set_symmetric_difference_v2 = __webpack_require__(5024);
60847
60848
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.set.union.v2.js
60848
60849
  var es_set_union_v2 = __webpack_require__(1698);
60849
- ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"72942c6c-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/custom-column/index.vue?vue&type=template&id=7a5f2115
60850
- var custom_columnvue_type_template_id_7a5f2115_render = function render() {
60850
+ ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"72942c6c-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/custom-column/index.vue?vue&type=template&id=22c5acce
60851
+ var custom_columnvue_type_template_id_22c5acce_render = function render() {
60851
60852
  var _vm = this,
60852
60853
  _c = _vm._self._c;
60853
60854
  return _c('div', {
@@ -61048,7 +61049,7 @@ var custom_columnvue_type_template_id_7a5f2115_render = function render() {
61048
61049
  }) : _vm._e()]);
61049
61050
  }), 0)], 1)], 1)], 1)])])])], 1);
61050
61051
  };
61051
- var custom_columnvue_type_template_id_7a5f2115_staticRenderFns = [];
61052
+ var custom_columnvue_type_template_id_22c5acce_staticRenderFns = [];
61052
61053
 
61053
61054
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.filter.js
61054
61055
  var es_iterator_filter = __webpack_require__(2489);
@@ -61097,6 +61098,304 @@ const deepClone = target => {
61097
61098
  // 返回最终结果
61098
61099
  return result;
61099
61100
  };
61101
+ ;// ./src/utils/tableUtils.js
61102
+
61103
+
61104
+
61105
+
61106
+
61107
+
61108
+ /**
61109
+ * 判断是否缓存了表格列宽
61110
+ * @param {*} name 表格名称
61111
+ * @returns
61112
+ */
61113
+ const isCachedTableColumns = name => {
61114
+ if (!name) return false;
61115
+ return !!localStorage.getItem(name);
61116
+ };
61117
+
61118
+ /**
61119
+ * 删除表格列宽缓存
61120
+ * @param {*} name 表格名称
61121
+ */
61122
+ const removeCachedTableColumns = name => {
61123
+ localStorage.removeItem(name);
61124
+ };
61125
+
61126
+ /**
61127
+ * 缓存列宽
61128
+ * @param {*} name 表格名称
61129
+ * @param {*} context
61130
+ */
61131
+ const saveCachedColumns = (name, context) => {
61132
+ if (!name) return;
61133
+ // 获取列宽信息
61134
+ const collectColumn = context.$table.collectColumn;
61135
+ // 获取已缓存的列宽数据
61136
+ const cachedColumns = getCachedColumns(name);
61137
+
61138
+ // 递归查找并更新列宽
61139
+ const updateColumnWidth = (columns, targetField, newWidth) => {
61140
+ const result = [];
61141
+ for (const col of columns) {
61142
+ if (col.children) {
61143
+ const updatedChildren = updateColumnWidth(col.children, targetField, newWidth);
61144
+ if (updatedChildren.length > 0) {
61145
+ result.push({
61146
+ field: col.field,
61147
+ width: newWidth,
61148
+ children: updatedChildren
61149
+ });
61150
+ }
61151
+ } else if (targetField && targetField !== '' && col.field === targetField) {
61152
+ //如果没设置field不缓存
61153
+ result.push({
61154
+ field: col.field,
61155
+ width: newWidth
61156
+ });
61157
+ }
61158
+ }
61159
+ return result;
61160
+ };
61161
+
61162
+ //当前拖动的列
61163
+ const currentColumn = context.column;
61164
+
61165
+ // 更新被拖动列的宽度(只缓存被拖动的列)
61166
+ const updatedColumns = updateColumnWidth(collectColumn, currentColumn.field, currentColumn.renderWidth);
61167
+
61168
+ // 合并新的列宽信息到缓存中
61169
+ const mergeColumns = (newColumns, cachedColumns) => {
61170
+ const result = [...cachedColumns];
61171
+ for (const newCol of newColumns) {
61172
+ const existingIndex = result.findIndex(col => col.field === newCol.field);
61173
+ if (existingIndex !== -1) {
61174
+ // 如果存在子列,递归合并
61175
+ if (newCol.children && result[existingIndex].children) {
61176
+ result[existingIndex].children = mergeColumns(newCol.children, result[existingIndex].children);
61177
+ } else {
61178
+ // 更新宽度
61179
+ result[existingIndex].width = newCol.width;
61180
+ }
61181
+ } else {
61182
+ // 添加新的列信息
61183
+ result.push(newCol);
61184
+ }
61185
+ }
61186
+ return result;
61187
+ };
61188
+
61189
+ // 合并并保存更新后的列宽数据
61190
+ const finalColumns = mergeColumns(updatedColumns, cachedColumns);
61191
+
61192
+ //缓存列宽
61193
+ localStorage.setItem(name, JSON.stringify(finalColumns));
61194
+ };
61195
+
61196
+ /**
61197
+ * 获取列宽缓存
61198
+ * @param {*} name 表格名称
61199
+ * @returns
61200
+ */
61201
+ const getCachedColumns = name => {
61202
+ return JSON.parse(localStorage.getItem(name) || '[]');
61203
+ };
61204
+
61205
+ /**
61206
+ * 替换列宽 - 表格列数据替换成缓存中的列宽(若有列宽缓存)
61207
+ * @param {*} name
61208
+ * @param {*} columns
61209
+ * @returns
61210
+ */
61211
+ const replaceColumnWidthToColumns = (name, columns) => {
61212
+ if (!name) {
61213
+ return columns;
61214
+ }
61215
+ const cacheColumns = getCachedColumns(name);
61216
+ if (!cacheColumns) {
61217
+ return columns;
61218
+ }
61219
+
61220
+ // 递归处理多级表头的列宽
61221
+ const processColumnWidth = (columns, cacheColumns) => {
61222
+ return columns.map(column => {
61223
+ if (column.children) {
61224
+ const cacheColumn = cacheColumns.find(col => col.field === column.field);
61225
+ return {
61226
+ ...column,
61227
+ ...((cacheColumn === null || cacheColumn === void 0 ? void 0 : cacheColumn.width) && {
61228
+ width: cacheColumn.width
61229
+ }),
61230
+ children: processColumnWidth(column.children, (cacheColumn === null || cacheColumn === void 0 ? void 0 : cacheColumn.children) || [])
61231
+ };
61232
+ }
61233
+ const cacheColumn = cacheColumns.filter(col => col.field && col.field !== '') //有设置field才替换width给列
61234
+ .find(col => col.field === column.field);
61235
+ return {
61236
+ ...column,
61237
+ ...((cacheColumn === null || cacheColumn === void 0 ? void 0 : cacheColumn.width) && {
61238
+ width: cacheColumn.width
61239
+ })
61240
+ };
61241
+ });
61242
+ };
61243
+ return processColumnWidth(columns, cacheColumns);
61244
+ };
61245
+
61246
+ /**
61247
+ * 重写列宽 (v3是否要替换这个方法的逻辑???)
61248
+ * @param fromColumns 原始列
61249
+ * @param toColumns 目标列
61250
+ * @returns 重写后的列
61251
+ */
61252
+ const rewriteWidthColumns = (fromColumns, toColumns) => {
61253
+ if (!fromColumns || !toColumns) return [];
61254
+ if (!fromColumns || fromColumns.length === 0) return toColumns;
61255
+ const result = [];
61256
+ for (const col of toColumns) {
61257
+ const fromCol = fromColumns.find(from => from.field === col.field);
61258
+ if (col.children) {
61259
+ // 递归处理子列
61260
+ const newCol = {
61261
+ ...col,
61262
+ children: rewriteWidthColumns((fromCol === null || fromCol === void 0 ? void 0 : fromCol.children) || [], col.children)
61263
+ };
61264
+ // 如果 fromCol 有 width,则添加 width,否则不添加 width 字段
61265
+ if (fromCol) {
61266
+ if (fromCol !== null && fromCol !== void 0 && fromCol.width) {
61267
+ newCol.width = fromCol.width;
61268
+ } else {
61269
+ delete newCol.width;
61270
+ }
61271
+ }
61272
+ result.push(newCol);
61273
+ } else {
61274
+ const newCol = {
61275
+ ...col
61276
+ };
61277
+ // 如果 fromCol 有 width,则添加 width,否则不添加 width 字段
61278
+ if (fromCol) {
61279
+ if (fromCol !== null && fromCol !== void 0 && fromCol.width) {
61280
+ newCol.width = fromCol.width;
61281
+ } else {
61282
+ delete newCol.width;
61283
+ }
61284
+ }
61285
+ result.push(newCol);
61286
+ }
61287
+ }
61288
+ return result;
61289
+ };
61290
+
61291
+ /**
61292
+ * 递归增加slot
61293
+ * @param {*} fields 字段信息
61294
+ * @param {*} slotSet 收集的slot
61295
+ */
61296
+ const recursiveSlot = (fields, slotSet) => {
61297
+ if (!fields || !Array.isArray(fields)) {
61298
+ return;
61299
+ }
61300
+ fields.forEach(col => {
61301
+ if (col.slots) {
61302
+ const slots = Object.values(col.slots);
61303
+ slots.forEach(slot => slotSet.add(slot));
61304
+ }
61305
+ if (col.children) {
61306
+ recursiveSlot(col.children, slotSet);
61307
+ }
61308
+ });
61309
+ };
61310
+
61311
+ /**
61312
+ * 为表格创建分组列结构(将固定列按一级表头分组) -- 有二级表头情况
61313
+ * @param columns 原始列分组数据
61314
+ * @param fixed_max_count 固定列最大数量
61315
+ */
61316
+ const groupedColumnsForTable = (columns, fixed_max_count = 6) => {
61317
+ let fixedCount = 0; // 先统计所有固定列的数量
61318
+ columns.forEach(group => {
61319
+ group.data.forEach(col => {
61320
+ if (col.fixed === 'left' && ['true', true, '1', 1].includes(col.type)) {
61321
+ fixedCount++;
61322
+ }
61323
+ });
61324
+ });
61325
+
61326
+ //如果固定列数量>固定列最大数量,直接返回原始分组结构,但去除所有fixed属性
61327
+ if (fixedCount > fixed_max_count) {
61328
+ //超过fixed_max_count个固定列,取消所有固定
61329
+ const result = columns.map(group => ({
61330
+ ...group,
61331
+ fixed: undefined,
61332
+ data: group.data.map(col => ({
61333
+ ...col,
61334
+ fixed: undefined
61335
+ }))
61336
+ }));
61337
+ return result;
61338
+ }
61339
+
61340
+ // 固定列数量<=6个时,才进行重新分组
61341
+ const fixedGroups = [];
61342
+ const normalGroups = [];
61343
+ columns.forEach(group => {
61344
+ const fixedItems = [];
61345
+ const normalItems = [];
61346
+ group.data.forEach(col => {
61347
+ if (col.fixed === 'left') {
61348
+ fixedItems.push(col);
61349
+ } else {
61350
+ normalItems.push(col);
61351
+ }
61352
+ });
61353
+
61354
+ // 如果有固定的列,加入固定分组
61355
+ if (fixedItems.length > 0) {
61356
+ fixedGroups.push({
61357
+ label: group.label,
61358
+ fixed: 'left',
61359
+ data: fixedItems
61360
+ });
61361
+ }
61362
+
61363
+ // 如果有普通列,加入普通分组
61364
+ if (normalItems.length > 0) {
61365
+ normalGroups.push({
61366
+ label: group.label,
61367
+ data: normalItems
61368
+ });
61369
+ }
61370
+ });
61371
+ const result = [...fixedGroups, ...normalGroups];
61372
+
61373
+ // 将固定分组添加到最前面
61374
+ return result;
61375
+ };
61376
+
61377
+ /**
61378
+ * 判断左侧固定个数,决定是否左侧固定还是取消固定 -- 无二级表头情况
61379
+ * @param {*} cols 列数据
61380
+ * @param {*} fixed_max_count 固定列最大数量
61381
+ * @returns
61382
+ */
61383
+ const resetFixedColumns = (cols, fixed_max_count = 6) => {
61384
+ if (!cols) return [];
61385
+ let fixedCount = 0;
61386
+ cols.forEach(col => {
61387
+ if (col.fixed === 'left' && ['true', true, '1', 1].includes(col.type)) {
61388
+ fixedCount++;
61389
+ }
61390
+ });
61391
+ if (fixedCount > fixed_max_count) {
61392
+ cols.map(item => {
61393
+ item.fixed = false;
61394
+ });
61395
+ }
61396
+ return cols;
61397
+ };
61398
+
61100
61399
  ;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/custom-column/index.vue?vue&type=script&lang=js
61101
61400
 
61102
61401
 
@@ -61108,6 +61407,7 @@ const deepClone = target => {
61108
61407
 
61109
61408
 
61110
61409
 
61410
+
61111
61411
  /* harmony default export */ var custom_columnvue_type_script_lang_js = ({
61112
61412
  name: 'CustomColumn',
61113
61413
  components: {
@@ -61127,6 +61427,14 @@ const deepClone = target => {
61127
61427
  type: Function,
61128
61428
  required: true,
61129
61429
  default: () => {}
61430
+ },
61431
+ //左侧固定列最多个数 - 默认6个 (超出个数时,左侧固定失效)
61432
+ fixedMaxCount: {
61433
+ type: Number,
61434
+ default: 6,
61435
+ validator: value => {
61436
+ return value >= 0;
61437
+ }
61130
61438
  }
61131
61439
  },
61132
61440
  data() {
@@ -61233,7 +61541,7 @@ const deepClone = target => {
61233
61541
  this.checkBoxMenu = this.deepClone(initColumn);
61234
61542
  this.draggableMenu = setDraggableMenu(this.checkBoxMenu);
61235
61543
  } else {
61236
- console.log('==========从未被保存过', initColumn);
61544
+ // console.log('==========从未被保存过', initColumn)
61237
61545
 
61238
61546
  // 从未被保存过
61239
61547
  let num = 0;
@@ -61255,12 +61563,8 @@ const deepClone = target => {
61255
61563
  this.checkBoxMenu = this.deepClone(initColumn);
61256
61564
  this.draggableMenu = setDraggableMenu(this.checkBoxMenu);
61257
61565
  }
61258
- this.$emit('changeTable', this.draggableMenu.filter(item => item.key !== 'sort-cut-off').sort((a, b) => a.sort - b.sort));
61259
-
61260
- // changeTableGroup 回调:对固定列进行重新分组
61261
- const groupedColumns = this.createGroupedColumnsForTable(this.checkBoxMenu);
61262
- this.$emit('changeTableGroup', groupedColumns);
61263
- // this.$emit('changeTableGroup', this.checkBoxMenu)
61566
+ this.emitChangeTable(this.draggableMenu.filter(item => item.key !== 'sort-cut-off').sort((a, b) => a.sort - b.sort));
61567
+ this.emitChangeTableGroup(this.checkBoxMenu);
61264
61568
  },
61265
61569
  // 全不选
61266
61570
  selectNone() {
@@ -61364,82 +61668,21 @@ const deepClone = target => {
61364
61668
  params.column.forEach(item => {
61365
61669
  cols.push(...item.data);
61366
61670
  });
61367
- this.$emit('changeTable', cols.sort((a, b) => a.sort - b.sort));
61368
-
61369
- // changeTableGroup 回调:对固定列进行重新分组
61370
- const groupedColumns = this.createGroupedColumnsForTable(params.column);
61371
- this.$emit('changeTableGroup', groupedColumns);
61671
+ this.emitChangeTable(cols.sort((a, b) => a.sort - b.sort));
61672
+ this.emitChangeTableGroup(params.column);
61372
61673
  this.closeDialog();
61373
61674
  },
61374
- /**
61375
- * 为表格创建分组列结构(将固定列按一级表头分组)
61376
- * @param columns 原始列分组数据
61377
- */
61378
- createGroupedColumnsForTable(columns) {
61379
- console.log('==========columns', columns);
61380
-
61381
- // 先统计所有固定列的数量
61382
- let fixedCount = 0;
61383
- columns.forEach(group => {
61384
- group.data.forEach(col => {
61385
- if (col.fixed === 'left') {
61386
- fixedCount++;
61387
- }
61388
- });
61389
- });
61390
- console.log('==========固定列个数:', fixedCount);
61391
-
61392
- // *** 如果固定列数量>6个,直接返回原始分组结构,但去除所有fixed属性 start
61393
- if (fixedCount > 6) {
61394
- const result = columns.map(group => ({
61395
- ...group,
61396
- fixed: undefined,
61397
- data: group.data.map(col => ({
61398
- ...col,
61399
- fixed: undefined
61400
- }))
61401
- }));
61402
- console.log('==========超过6个固定列,取消所有固定:', result);
61403
- return result;
61404
- }
61405
- // *** 如果固定列数量>6个,直接返回原始分组结构,但去除所有fixed属性 end
61406
-
61407
- // 固定列数量<=6个时,才进行重新分组
61408
- const fixedGroups = [];
61409
- const normalGroups = [];
61410
- columns.forEach(group => {
61411
- const fixedItems = [];
61412
- const normalItems = [];
61413
- group.data.forEach(col => {
61414
- if (col.fixed === 'left') {
61415
- fixedItems.push(col);
61416
- } else {
61417
- normalItems.push(col);
61418
- }
61419
- });
61420
-
61421
- // 如果有固定的列,加入固定分组
61422
- if (fixedItems.length > 0) {
61423
- fixedGroups.push({
61424
- label: group.label,
61425
- fixed: 'left',
61426
- data: fixedItems
61427
- });
61428
- }
61429
-
61430
- // 如果有普通列,加入普通分组
61431
- if (normalItems.length > 0) {
61432
- normalGroups.push({
61433
- label: group.label,
61434
- data: normalItems
61435
- });
61436
- }
61437
- });
61438
- const result = [...fixedGroups, ...normalGroups];
61439
- console.log('==========<=6个固定列,正常分组:', result);
61440
-
61441
- // 将固定分组添加到最前面
61442
- return result;
61675
+ // changeTable
61676
+ emitChangeTable(cols) {
61677
+ //表头左侧固定逻辑(对固定列fixed重新赋值)
61678
+ const reCols = resetFixedColumns(cols, this.fixedMaxCount);
61679
+ this.$emit('changeTable', reCols);
61680
+ },
61681
+ // changeTableGroup
61682
+ emitChangeTableGroup(cols) {
61683
+ //表头左侧固定逻辑(对固定列进行重新分组)
61684
+ const groupedCols = groupedColumnsForTable(cols, this.fixedMaxCount);
61685
+ this.$emit('changeTableGroup', groupedCols);
61443
61686
  },
61444
61687
  // 关闭弹窗
61445
61688
  closeDialog() {
@@ -61462,8 +61705,8 @@ const deepClone = target => {
61462
61705
  ;
61463
61706
  var custom_column_component = normalizeComponent(
61464
61707
  components_custom_columnvue_type_script_lang_js,
61465
- custom_columnvue_type_template_id_7a5f2115_render,
61466
- custom_columnvue_type_template_id_7a5f2115_staticRenderFns,
61708
+ custom_columnvue_type_template_id_22c5acce_render,
61709
+ custom_columnvue_type_template_id_22c5acce_staticRenderFns,
61467
61710
  false,
61468
61711
  null,
61469
61712
  null,
@@ -61472,216 +61715,6 @@ var custom_column_component = normalizeComponent(
61472
61715
  )
61473
61716
 
61474
61717
  /* harmony default export */ var custom_column = (custom_column_component.exports);
61475
- ;// ./src/utils/tableUtils.js
61476
-
61477
-
61478
-
61479
-
61480
-
61481
-
61482
- /**
61483
- * 判断是否缓存了表格列宽
61484
- * @param {*} name 表格名称
61485
- * @returns
61486
- */
61487
- const isCachedTableColumns = name => {
61488
- if (!name) return false;
61489
- return !!localStorage.getItem(name);
61490
- };
61491
-
61492
- /**
61493
- * 删除表格列宽缓存
61494
- * @param {*} name 表格名称
61495
- */
61496
- const removeCachedTableColumns = name => {
61497
- localStorage.removeItem(name);
61498
- };
61499
-
61500
- /**
61501
- * 缓存列宽
61502
- * @param {*} name 表格名称
61503
- * @param {*} context
61504
- */
61505
- const saveCachedColumns = (name, context) => {
61506
- if (!name) return;
61507
- // 获取列宽信息
61508
- const collectColumn = context.$table.collectColumn;
61509
- // 获取已缓存的列宽数据
61510
- const cachedColumns = getCachedColumns(name);
61511
-
61512
- // 递归查找并更新列宽
61513
- const updateColumnWidth = (columns, targetField, newWidth) => {
61514
- const result = [];
61515
- for (const col of columns) {
61516
- if (col.children) {
61517
- const updatedChildren = updateColumnWidth(col.children, targetField, newWidth);
61518
- if (updatedChildren.length > 0) {
61519
- result.push({
61520
- field: col.field,
61521
- width: newWidth,
61522
- children: updatedChildren
61523
- });
61524
- }
61525
- } else if (targetField && targetField !== '' && col.field === targetField) {
61526
- //如果没设置field不缓存
61527
- result.push({
61528
- field: col.field,
61529
- width: newWidth
61530
- });
61531
- }
61532
- }
61533
- return result;
61534
- };
61535
-
61536
- //当前拖动的列
61537
- const currentColumn = context.column;
61538
-
61539
- // 更新被拖动列的宽度(只缓存被拖动的列)
61540
- const updatedColumns = updateColumnWidth(collectColumn, currentColumn.field, currentColumn.renderWidth);
61541
-
61542
- // 合并新的列宽信息到缓存中
61543
- const mergeColumns = (newColumns, cachedColumns) => {
61544
- const result = [...cachedColumns];
61545
- for (const newCol of newColumns) {
61546
- const existingIndex = result.findIndex(col => col.field === newCol.field);
61547
- if (existingIndex !== -1) {
61548
- // 如果存在子列,递归合并
61549
- if (newCol.children && result[existingIndex].children) {
61550
- result[existingIndex].children = mergeColumns(newCol.children, result[existingIndex].children);
61551
- } else {
61552
- // 更新宽度
61553
- result[existingIndex].width = newCol.width;
61554
- }
61555
- } else {
61556
- // 添加新的列信息
61557
- result.push(newCol);
61558
- }
61559
- }
61560
- return result;
61561
- };
61562
-
61563
- // 合并并保存更新后的列宽数据
61564
- const finalColumns = mergeColumns(updatedColumns, cachedColumns);
61565
-
61566
- //缓存列宽
61567
- localStorage.setItem(name, JSON.stringify(finalColumns));
61568
- };
61569
-
61570
- /**
61571
- * 获取列宽缓存
61572
- * @param {*} name 表格名称
61573
- * @returns
61574
- */
61575
- const getCachedColumns = name => {
61576
- return JSON.parse(localStorage.getItem(name) || '[]');
61577
- };
61578
-
61579
- /**
61580
- * 替换列宽 - 表格列数据替换成缓存中的列宽(若有列宽缓存)
61581
- * @param {*} name
61582
- * @param {*} columns
61583
- * @returns
61584
- */
61585
- const replaceColumnWidthToColumns = (name, columns) => {
61586
- if (!name) {
61587
- return columns;
61588
- }
61589
- const cacheColumns = getCachedColumns(name);
61590
- if (!cacheColumns) {
61591
- return columns;
61592
- }
61593
-
61594
- // 递归处理多级表头的列宽
61595
- const processColumnWidth = (columns, cacheColumns) => {
61596
- return columns.map(column => {
61597
- if (column.children) {
61598
- const cacheColumn = cacheColumns.find(col => col.field === column.field);
61599
- return {
61600
- ...column,
61601
- ...((cacheColumn === null || cacheColumn === void 0 ? void 0 : cacheColumn.width) && {
61602
- width: cacheColumn.width
61603
- }),
61604
- children: processColumnWidth(column.children, (cacheColumn === null || cacheColumn === void 0 ? void 0 : cacheColumn.children) || [])
61605
- };
61606
- }
61607
- const cacheColumn = cacheColumns.filter(col => col.field && col.field !== '') //有设置field才替换width给列
61608
- .find(col => col.field === column.field);
61609
- return {
61610
- ...column,
61611
- ...((cacheColumn === null || cacheColumn === void 0 ? void 0 : cacheColumn.width) && {
61612
- width: cacheColumn.width
61613
- })
61614
- };
61615
- });
61616
- };
61617
- return processColumnWidth(columns, cacheColumns);
61618
- };
61619
-
61620
- /**
61621
- * 重写列宽 (v3是否要替换这个方法的逻辑???)
61622
- * @param fromColumns 原始列
61623
- * @param toColumns 目标列
61624
- * @returns 重写后的列
61625
- */
61626
- const rewriteWidthColumns = (fromColumns, toColumns) => {
61627
- if (!fromColumns || !toColumns) return [];
61628
- if (!fromColumns || fromColumns.length === 0) return toColumns;
61629
- const result = [];
61630
- for (const col of toColumns) {
61631
- const fromCol = fromColumns.find(from => from.field === col.field);
61632
- if (col.children) {
61633
- // 递归处理子列
61634
- const newCol = {
61635
- ...col,
61636
- children: rewriteWidthColumns((fromCol === null || fromCol === void 0 ? void 0 : fromCol.children) || [], col.children)
61637
- };
61638
- // 如果 fromCol 有 width,则添加 width,否则不添加 width 字段
61639
- if (fromCol) {
61640
- if (fromCol !== null && fromCol !== void 0 && fromCol.width) {
61641
- newCol.width = fromCol.width;
61642
- } else {
61643
- delete newCol.width;
61644
- }
61645
- }
61646
- result.push(newCol);
61647
- } else {
61648
- const newCol = {
61649
- ...col
61650
- };
61651
- // 如果 fromCol 有 width,则添加 width,否则不添加 width 字段
61652
- if (fromCol) {
61653
- if (fromCol !== null && fromCol !== void 0 && fromCol.width) {
61654
- newCol.width = fromCol.width;
61655
- } else {
61656
- delete newCol.width;
61657
- }
61658
- }
61659
- result.push(newCol);
61660
- }
61661
- }
61662
- return result;
61663
- };
61664
-
61665
- /**
61666
- * 递归增加slot
61667
- * @param {*} fields 字段信息
61668
- * @param {*} slotSet 收集的slot
61669
- */
61670
- const recursiveSlot = (fields, slotSet) => {
61671
- if (!fields || !Array.isArray(fields)) {
61672
- return;
61673
- }
61674
- fields.forEach(col => {
61675
- if (col.slots) {
61676
- const slots = Object.values(col.slots);
61677
- slots.forEach(slot => slotSet.add(slot));
61678
- }
61679
- if (col.children) {
61680
- recursiveSlot(col.children, slotSet);
61681
- }
61682
- });
61683
- };
61684
-
61685
61718
  ;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/table/index.vue?vue&type=script&lang=js
61686
61719
 
61687
61720
 
@@ -61954,8 +61987,8 @@ const recursiveSlot = (fields, slotSet) => {
61954
61987
  ;
61955
61988
  var table_component = normalizeComponent(
61956
61989
  components_tablevue_type_script_lang_js,
61957
- tablevue_type_template_id_58d17823_render,
61958
- tablevue_type_template_id_58d17823_staticRenderFns,
61990
+ tablevue_type_template_id_4926859a_render,
61991
+ tablevue_type_template_id_4926859a_staticRenderFns,
61959
61992
  false,
61960
61993
  null,
61961
61994
  null,