zxl
2025-03-25 6ae0fcef149ddbe614746023a58a3885b3ac4bde
src/components/VisibilityToolbar/index.vue
@@ -23,10 +23,10 @@
        <span>信息显隐筛选</span>
      </div>
      <div slot="default" style="margin-left: 20px;margin-top: 20px">
        <el-table :data="getPage" style="width: 95%; height: 80%;;margin-bottom: 40px;">
        <el-table :row-key="row => { return row.id }" :data="getPage" style="width: 95%; height: 80%;;margin-bottom: 40px;" >
          <el-table-column prop="index" label="序号" width="80"></el-table-column>
          <el-table-column prop="label" label="数据名称"></el-table-column>
          <el-table-column prop="visible" label="是否显示">
          <el-table-column prop="visible" label="是否显示" >
            <template slot-scope="scope">
              <el-switch
                v-model="scope.row.visible"
@@ -37,9 +37,10 @@
              ></el-switch>
            </template>
          </el-table-column>
          <el-table-column prop="date" label="排序">
          <el-table-column prop="sort" label="排序">
            <template slot-scope="scope">
              <el-input-number v-model="scope.row.serialNumber" :min="0" style="width: 120px" @change="sortChange(scope.row, $event)"></el-input-number>
              <el-input-number v-model="scope.row.sort" :min="0" style="width: 120px"
                               @change="sortChange(scope.row, $event)"></el-input-number>
            </template>
          </el-table-column>
        </el-table>
@@ -129,7 +130,6 @@
      this.table = true;
    },
    switchChange(row) {
      row.sort = row.serialNumber;
      if (row.visible === true){
        row.display = "1"
      }else {
@@ -139,17 +139,17 @@
        this.saveList.push(row)
      }else {
        let have = true;
        this.saveList.forEach((item ,index)=>{
          if (item.id === row.id){
              item[index] =item;
        let index = this.saveList.findIndex(item => item.id === row.id);
        if (index !== -1){
            this.saveList[index] = row;
            have =false;
          }
        })
        }
        if (have){
          this.saveList.push(row)
        }
      }
      console.log(this.saveList)
      console
      this.$emit('update:columns', row);
    },
    handlePageChange(page) {
@@ -185,11 +185,12 @@
      if (this.saveList.length !== 0){
        saveHiddenList(CircularJSON.stringify(this.saveList)).then(res =>{
          this.$modal.msgSuccess("保存成功");
          //刷新页面
          this.$emit('update:resetSort');
        });
      }
    },
    sortChange(row, val) {
      row.sort = row.serialNumber;
      if (row.visible === true){
        row.display = "1"
      }else {
@@ -199,12 +200,11 @@
        this.saveList.push(row)
      }else {
        let have = true;
        this.saveList.forEach((item ,index)=>{
          if (item.id === row.id){
            item[index] =item;
            have =false;
          }
        })
        let index = this.saveList.findIndex(item => item.id === row.id);
        if (index !== -1){
          this.saveList[index] = row;
          have =false;
        }
        if (have){
          this.saveList.push(row)
        }
@@ -221,7 +221,6 @@
      //
      // // 根据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);