no message
							parent
							
								
									e830796e40
								
							
						
					
					
						commit
						0531a03026
					
				| 
						 | 
					@ -204,25 +204,39 @@ export default {
 | 
				
			||||||
          this.showcolumn();
 | 
					          this.showcolumn();
 | 
				
			||||||
        }, 200)
 | 
					        }, 200)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					 | 
				
			||||||
      //vm.owner.store.commit('insertColumn', columnConfig, newIndex+myindex + 1 , null)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    showcolumn() {
 | 
					    showcolumn() {
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
 | 
					        // 从sessionStorage安全地获取并解析hiddenColumns
 | 
				
			||||||
        const strHidden = sessionStorage.getItem(this.tableKey)
 | 
					        const strHidden = sessionStorage.getItem(this.tableKey)
 | 
				
			||||||
 | 
					        if (strHidden) {
 | 
				
			||||||
          this.hiddenColumns = JSON.parse(strHidden);
 | 
					          this.hiddenColumns = JSON.parse(strHidden);
 | 
				
			||||||
      const table = this.crud.props.table
 | 
					        } else {
 | 
				
			||||||
      this.hiddenColumns.forEach((column, index) => {
 | 
					          // 如果没有找到相应的存储信息,可以初始化为空数组或相应的默认值
 | 
				
			||||||
        const vm = table.$children.find(e => e.prop === column.property)
 | 
					          this.hiddenColumns = [];
 | 
				
			||||||
        const columnConfig = vm.columnConfig
 | 
					 | 
				
			||||||
        if (column.visible) {
 | 
					 | 
				
			||||||
          columnConfig.width = column.width
 | 
					 | 
				
			||||||
          columnConfig.visible = column.visible
 | 
					 | 
				
			||||||
          vm.owner.store.commit('insertColumn', columnConfig, index + 1, null)
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      })
 | 
					
 | 
				
			||||||
 | 
					        const table = this.crud.props.table
 | 
				
			||||||
 | 
					        // 优化循环中的条件判断和错误处理
 | 
				
			||||||
 | 
					        this.hiddenColumns.forEach((column, index) => {
 | 
				
			||||||
 | 
					          const vm = table.$children.find(e => e && e.prop === column.property)
 | 
				
			||||||
 | 
					          if (vm) {
 | 
				
			||||||
 | 
					            const columnConfig = vm.columnConfig;
 | 
				
			||||||
 | 
					            // 确保columnConfig存在
 | 
				
			||||||
 | 
					            if (columnConfig) {
 | 
				
			||||||
 | 
					              if (column.visible) {
 | 
				
			||||||
 | 
					                // 仅当列需要显示时,才更新其配置
 | 
				
			||||||
 | 
					                columnConfig.width = column.width;
 | 
				
			||||||
 | 
					                columnConfig.visible = column.visible;
 | 
				
			||||||
 | 
					                vm.owner.store.commit('insertColumn', columnConfig, index + 1, null);
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
        this.updateTableColumns();
 | 
					        this.updateTableColumns();
 | 
				
			||||||
 | 
					      } catch (error) {
 | 
				
			||||||
 | 
					        console.error("处理列配置时发生错误:", error);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    //列拖拽
 | 
					    //列拖拽
 | 
				
			||||||
    columnDrop() {
 | 
					    columnDrop() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue