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