xiangpei
2024-11-26 12bf2514c17843aab17c9e3fa5ce8933cfefd7f6
src/components/VisibilityToolbar/index.vue
@@ -68,6 +68,7 @@
      table: false,
      currentPage: 1,
      columnRef: null,
      cpList: []
    };
  },
  props: {
@@ -123,7 +124,22 @@
      this.currentPage = page;
    },
    sortChange(row, val) {
      this.$emit('update:sort', { key: row.key, serialNumber: val });
      // // 创建一个新的columns数组,以避免直接修改原始数组
      // this.cpList = this.columns.map(item => ({ ...item })); // 使用解构来创建对象的浅拷贝
      //
      // // 更新指定项的serialNumber
      // this.cpList.forEach(item => {
      //   if (item.key ===  row.key) {
      //     item.serialNumber =  row.serialNumber;
      //   }
      // });
      //
      // // 根据serialNumber对newColumns进行排序
      // this.cpList = this.cpList.sort((a, b) => a.serialNumber - b.serialNumber);
      //
      // // 触发事件通知父组件columns已更新(如果父组件需要知道这个变化)
      // this.$emit('update:sort', this.cpList);
      this.$emit('update:sort', row);
    },
    resetSort() {
      this.$emit('update:resetSort');