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