wujingjing
2024-10-11 8d07bb29cba4fd6012520fd8d912b64a8f4e596b
src/components/table/colFilter/ColFilter.vue
@@ -34,7 +34,7 @@
});
const colCheckChange = (option: CheckOption) => {
   const { key, value } = option;
   const { key } = option;
   if (key === allCheckKey) {
      if (option.indeterminate) {
         option.indeterminate = false;
@@ -62,17 +62,10 @@
      }
   }
};
const checkOptionList = ref<CheckOption[]>(
   (
      [
         {
            key: allCheckKey,
            label: '全选/不选',
            value: true,
         },
      ] as CheckOption[]
   ).concat(
      props.columnList.map((item) => ({
const checkOptionList = computed<CheckOption[]>(() => {
   let checkedCount = 0;
   const options = props.columnList.map((item) => {
      const result = {
         key: item.prop,
         label: item.label,
         get value() {
@@ -81,7 +74,28 @@
         set value(val) {
            item.isShow = val;
         },
      }))
   )
);
      };
      result.value && checkedCount++;
      return result;
   });
   const total = options.length;
   const firstOption: CheckOption = {
      key: allCheckKey,
      label: '全选/不选',
      value: false,
   };
   if (checkedCount === 0 || total === checkedCount) {
      firstOption.indeterminate = false;
      if (checkedCount === 0) {
         firstOption.value = false;
      } else {
         firstOption.value = true;
      }
   } else {
      firstOption.indeterminate = true;
   }
   options.unshift(firstOption);
   return options;
});
</script>