diff --git a/src/components/FilterableCheckboxes.vue b/src/components/FilterableCheckboxes.vue index cfeed84c3dd79071773b2d40fbd9451f660e2b4b..d5566c21b7d8dc3c744e8e29b501dd164772bfe9 100644 --- a/src/components/FilterableCheckboxes.vue +++ b/src/components/FilterableCheckboxes.vue @@ -59,7 +59,7 @@ const filteredValues = computed(() => { return rawValues.value.filter((val) => val.label.toLowerCase().includes(search)); }); -watch(() => filteredValues.value.length, (len) => empty.value = len <= 0) +watch(() => filteredValues.value.length, (len) => empty.value = len <= 0, { immediate: true }); const displayCount = ref(30); const displayValues = computed(() => { diff --git a/src/views/collaboration/TheCollaboration.vue b/src/views/collaboration/TheCollaboration.vue index 450bc9edd7c83abacbddc1b08922f99e2d69db4b..bbe24b602f447ae677508c831b369f48fa188b42 100644 --- a/src/views/collaboration/TheCollaboration.vue +++ b/src/views/collaboration/TheCollaboration.vue @@ -40,10 +40,16 @@ const filterIconRefs = ref(new Array(columns.length)); /** 筛选组件是否显示的开关 */ const filterSwitches = ref(columns.map(() => false)); +let clickOutsideStopFns: (() => void)[] = []; + const setPopupClickoutSideFn = (el: any, index: number) => { - onClickOutside(el, () => { + if (clickOutsideStopFns.length) { + clickOutsideStopFns.forEach((fn) => fn()); + clickOutsideStopFns = []; + } + clickOutsideStopFns.push(onClickOutside(el, () => { filterSwitches.value[index] = false; - }); + }) as (() => void)); }; const repoFilterLoading = ref(false); @@ -239,149 +245,151 @@ watch( -
- 状态指标说明 - -
-
- - diff --git a/src/views/todo/ApprovalTable.vue b/src/views/todo/ApprovalTable.vue index 6d69d3a7f5bb02e71c3474f7fe6edf2e07c09ec5..4f46bffaf39c0e89edb24de1f4e97398006d1be8 100644 --- a/src/views/todo/ApprovalTable.vue +++ b/src/views/todo/ApprovalTable.vue @@ -22,10 +22,10 @@ interface ColumnsT { } const props = defineProps({ - filterableColumns: { + /* filterableColumns: { type: Array as PropType, default: () => [], - }, + }, */ data: { type: Array, default: () => [], @@ -42,6 +42,10 @@ const props = defineProps({ type: Boolean, default: () => false, }, + filterParams: { + type: Object, + default: () => ({}), + }, }); const router = useRouter(); @@ -62,19 +66,9 @@ const getRepoList = () => { } }; -const filterParams = reactive( - props.filterableColumns.reduce( - (obj, col) => { - obj[col] = ''; - return obj; - }, - {} as Record - ) -); - -watch(filterParams, (params) => emits('queryData', params)); +const innerFilterParams = ref(props.filterParams); +const filterableColumns = ref(Object.keys(props.filterParams)); -const filterableColSet = computed(() => new Set(props.filterableColumns)); const applyTypes = applicationTypeCurrent.map((item) => ({ label: item.label, value: item.id })); const filterIconRefs = ref(new Array(props.columns.length)); @@ -88,6 +82,15 @@ const setPopupClickoutSideFn = (el: any, index: number) => { }); }; +onMounted(() => { + Object.entries(props.filterParams).forEach((entry, index) => { + if (entry[1]) { + currentActiveFilterIndices.value.add(index); + activeFilterValues.value[props.columns.findIndex((item) => item.key === entry[0])] = entry[1]; + } + }); +}); + /** 当前有选中筛选项的表格列的数组下标 */ const currentActiveFilterIndices = ref(new Set()); @@ -118,6 +121,7 @@ const onFilterChange = (type: string, index: number, val: string) => { activeFilterValues.value[index] = ''; currentActiveFilterIndices.value.delete(index); } + emits('queryData', innerFilterParams.value); }; const userInfoStore = useUserInfoStore(); @@ -153,7 +157,7 @@ const revoke = () => {