ludc
2024-01-18 296f034c06ca8542b39878f860ffa5b909914338
Source/UBCS-WEB/src/components/Theme/ClassifyAuthDialog.vue
@@ -113,6 +113,11 @@
      currentRow: {}
    };
  },
  computed: {},
  mounted() {
  },
  created() {
  },
  watch: {
    // 监听父组件传的窗口显示隐藏的值
    visible() {
@@ -176,19 +181,14 @@
                });
                this.classifyAuthData.push(item);
                this.addIndex = this.classifyAuthData.length - 1; //添加行下标等于classifyAuthData的长度-1
                this.roleHandlerMethods(authData.roleId, 'create', this.addIndex)
                this.roleHandlerMethods(authData.roleId, 'create', index)
                // console.log('index', index)
              })
            }
          });
          console.log('created', this.classifyAuthData)
        });
      }
    },
  },
  computed: {},
  mounted() {
  },
  created() {
  },
  methods: {
    roleHandlerMethods(id, type, index) {
@@ -201,16 +201,33 @@
        const filteredItems = this.classifyAuthButton.filter(item => {
          return !res.data.data.find(x => x.id === item.id);
        });
        // console.log('禁用按钮',filteredItems)
        // console.log('不禁用按钮',res.data.data)
        //拿表格列头循环和没有对应的属性进行比较
        this.classifyAuthHeader.forEach((item) => {
          if (filteredItems.some(x => x.id === item.prop)) {
          const isMatched = filteredItems.some(x => x.id === item.prop);
          if (isMatched) {
            this.$nextTick(() => {
              if (this.classifyAuthData[index] !== undefined && this.classifyAuthData[index] !== null) {
              if (this.classifyAuthData[index]) {
                Object.keys(this.classifyAuthData[index]).forEach((key) => {
                    if (this.classifyAuthData[index].classify_view) {
                      this.$set(this.classifyAuthData[index], item.code, true);
                    } else {
                      this.classifyAuthData[index][item.code] = false;
                    }
                    // console.log(item.code)
                    // this.$set(this.classifyAuthData[index], item.code, true);
                });
              }
            })
          } else {
            this.$nextTick(() => {
              if (this.classifyAuthData[index]) {
                Object.keys(this.classifyAuthData[index]).forEach((key) => {
                  if (item.prop === key) {
                    // this.classifyAuthData[index] = Object.assign({}, this.classifyAuthData[index], {[key]: undefined});
                    this.$set(this.classifyAuthData[index], item.code, true);
                    this.$set(this.classifyAuthData[index], item.code, false);
                  }
                });
              }
@@ -222,9 +239,11 @@
        this.classifyAuthData.forEach((classkey, classIndex) => {
          if (classkey.classify_view) {
            this.$set(this.classifyAuthData[classIndex], 'allDisabled', true)
          } else {
            this.classifyAuthData[classIndex].allDisabled = false;
          }
        });
        // console.log('classifyAuthData',this.classifyAuthData)
        //强制刷新表格
        this.itemKey = uuidv4();
      })
@@ -276,7 +295,7 @@
        this.$message.warning("当前租户不存在角色信息!");
        return;
      }
      console.log('this.roleList', this.roleList)
      // console.log('this.roleList', this.roleList)
      this.addIndex++; //自定义生成添加行下标
      let item = {
        roleData: this.roleList[0].id,
@@ -288,7 +307,6 @@
      this.classifyAuthButton.forEach(data => {
        Vue.set(item, data.id, false);
      })
      //console.log(item)
      this.classifyAuthData.push(item);
      this.roleHandlerMethods(this.roleList[0].id, 'add', this.addIndex)
    },
@@ -359,6 +377,7 @@
          roleId: item.roleData,
          classifyId: this.classifyData.oid,
          buttonIds: itemButtonList.join(","),
          authType: "classify_auth",
        }
        form.push(data);
      });