| | |
| | | }); |
| | | |
| | | const colCheckChange = (option: CheckOption) => { |
| | | const { key, value } = option; |
| | | const { key } = option; |
| | | if (key === allCheckKey) { |
| | | if (option.indeterminate) { |
| | | option.indeterminate = false; |
| | |
| | | } |
| | | } |
| | | }; |
| | | 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() { |
| | |
| | | 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> |