diff --git a/frontend/src/components/pure/ms-advance-filter/filterDrawer.vue b/frontend/src/components/pure/ms-advance-filter/filterDrawer.vue index c5ac9ae0f4..9f969ccbb1 100644 --- a/frontend/src/components/pure/ms-advance-filter/filterDrawer.vue +++ b/frontend/src/components/pure/ms-advance-filter/filterDrawer.vue @@ -13,7 +13,7 @@
{{ formModel.name }}
@@ -100,10 +100,11 @@ allow-search :placeholder="t('common.pleaseSelect')" :disabled="isValueDisabled(item)" - :options="props.memberOptions" - multiple :search-keys="['label']" - :max-tag-count="1" + v-bind="{ + options: props.memberOptions, + multiple: true, + }" /> {{ t('common.filter') }} {{ t('common.reset') }} {{ t('common.save') }} - + {{ t('advanceFilter.saveAsView') }} @@ -240,8 +246,8 @@ import { SelectValue } from '@/models/projectManagement/menuManagement'; import { FilterType, OperatorEnum, ViewTypeEnum } from '@/enums/advancedFilterEnum'; - import { operatorOptionsMap } from './index'; - import { ConditionsItem, FilterForm, FilterFormItem, FilterResult } from './type'; + import { getAllDataDefaultConditions, internalViewsHiddenConditionsMap, operatorOptionsMap } from './index'; + import { ConditionsItem, FilterForm, FilterFormItem, FilterResult, ViewItem } from './type'; const props = defineProps<{ configList: FilterFormItem[]; // 系统字段 @@ -250,6 +256,7 @@ currentView: string; // 当前视图 allViewNames: string[]; canNotAddView: boolean; + internalViews: ViewItem[]; // 系统视图 memberOptions: { label: string; value: string }[]; }>(); const emit = defineEmits<{ @@ -268,12 +275,26 @@ }; const formModel = ref(cloneDeep(defaultFormModel)); const savedFormModel = ref(cloneDeep(formModel.value)); + + const currentConfigList = computed(() => + props.configList.filter( + (item) => !(internalViewsHiddenConditionsMap[props.currentView] ?? []).includes(item.dataIndex as string) + ) + ); + function isInternalViews(id?: string): boolean { + return props.internalViews.some((item) => item.id === id); + } + function getListItemByDataIndex(dataIndex: string) { - return [...props.configList, ...(props.customList || [])].find((item) => item.dataIndex === dataIndex); + return [...currentConfigList.value, ...(props.customList || [])].find((item) => item.dataIndex === dataIndex); } async function getUserViewDetail(id: string) { try { const res = await getViewDetail(props.viewType, id); + // 全部数据默认显示搜索条件 + if (res?.id === 'all_data') { + res.conditions = [...getAllDataDefaultConditions(props.viewType)]; + } const list: FilterFormItem[] = (res.conditions ?? [])?.map((item: ConditionsItem) => { const listItem = getListItemByDataIndex(item.name ?? '') as FilterFormItem; return { @@ -289,6 +310,15 @@ console.log(error); } } + watch( + () => visible.value, + async (val) => { + // 新建视图关闭后重新获取数据 + if (!val && formModel.value?.id !== props.currentView) { + await getUserViewDetail(props.currentView); + } + } + ); const isShowNameInput = ref(false); const viewNameInputRef = ref>(); @@ -319,7 +349,7 @@ const otherDataIndices = formModel.value.list .filter((listItem) => listItem.dataIndex !== currentDataIndex) .map((item: FilterFormItem) => item.dataIndex); - return [...props.configList, ...(props.customList || [])] + return [...currentConfigList.value, ...(props.customList || [])] .filter(({ dataIndex }) => !otherDataIndices.includes(dataIndex)) .map((item) => ({ ...item, label: t(item.title as string) })); }; @@ -392,20 +422,12 @@ } watch( () => props.currentView, - async (val) => { + async (val, oldValue) => { await getUserViewDetail(val); + if (!oldValue.length) return; handleFilter(); } ); - watch( - () => visible.value, - async (val) => { - // 新建视图关闭后重新获取数据 - if (!val && formModel.value?.id !== props.currentView) { - await getUserViewDetail(props.currentView); - } - } - ); // 数据改为新建视图的空数据 function resetToNewViewForm() { @@ -424,6 +446,7 @@ }; savedFormModel.value = cloneDeep(formModel.value); } + // 保存视图 const saveLoading = ref(false); function realSaveView() { @@ -460,6 +483,7 @@ realSaveView(); } } + // 开启另存为视图模式 const isSaveAsView = ref(false); const saveAsViewForm = ref({ name: '' }); diff --git a/frontend/src/components/pure/ms-advance-filter/index.ts b/frontend/src/components/pure/ms-advance-filter/index.ts index 93d3c02bbe..b0c2022c88 100644 --- a/frontend/src/components/pure/ms-advance-filter/index.ts +++ b/frontend/src/components/pure/ms-advance-filter/index.ts @@ -1,4 +1,4 @@ -import { FilterType, OperatorEnum } from '@/enums/advancedFilterEnum'; +import { FilterType, OperatorEnum, ViewTypeEnum } from '@/enums/advancedFilterEnum'; export { default as MsAdvanceFilter } from './index.vue'; @@ -167,26 +167,18 @@ export const CustomTypeMaps: Record = { }, }; -export const defaultFormModelList = [ - { - dataIndex: 'id', - title: 'caseManagement.featureCase.tableColumnID', - type: FilterType.INPUT, - operator: OperatorEnum.CONTAINS, - value: '', - }, - { - dataIndex: 'name', - label: 'common.name', - type: FilterType.INPUT, - operator: OperatorEnum.CONTAINS, - value: '', - }, - { - dataIndex: 'moduleId', - label: 'common.belongModule', - type: FilterType.TREE_SELECT, - operator: OperatorEnum.BELONG_TO, - value: '', - }, -]; +// 全部数据默认显示搜索条件:ID、名称、模块; +// TODO lmy 计划详情功能用例增加:测试点;接口定义、计划详情接口用例增加:协议; +export function getAllDataDefaultConditions(viewType: ViewTypeEnum) { + const conditions = [ + { name: 'id', operator: OperatorEnum.CONTAINS }, + { name: 'name', operator: OperatorEnum.CONTAINS }, + { name: 'moduleId', operator: OperatorEnum.BELONG_TO }, + ]; + return conditions; +} + +// 系统视图对应不显示的第一列下拉条件 +export const internalViewsHiddenConditionsMap: Record = { + my_create: ['createUser'], +}; diff --git a/frontend/src/components/pure/ms-advance-filter/index.vue b/frontend/src/components/pure/ms-advance-filter/index.vue index 986caebb06..8675bd5583 100644 --- a/frontend/src/components/pure/ms-advance-filter/index.vue +++ b/frontend/src/components/pure/ms-advance-filter/index.vue @@ -113,11 +113,13 @@ + (); @@ -273,7 +275,7 @@ // 开启高级筛选:非默认视图或有筛选条件 isAdvancedSearchMode.value = currentView.value !== internalViews.value[0].id || haveConditions; filterResult.value = filter; - emit('advSearch', filter); + emit('advSearch', filter, currentView.value); }; const handleRefresh = () => { diff --git a/frontend/src/components/pure/ms-advance-filter/type.ts b/frontend/src/components/pure/ms-advance-filter/type.ts index 8aa8f728ed..211398eac8 100644 --- a/frontend/src/components/pure/ms-advance-filter/type.ts +++ b/frontend/src/components/pure/ms-advance-filter/type.ts @@ -84,7 +84,6 @@ export interface ViewDetail extends ViewParams { userId?: string; viewType?: string; internal?: boolean; // 是否为内置视图 - internalViewKey?: string; createTime?: number; updateTime?: number; } diff --git a/frontend/src/components/pure/ms-table/useTable.ts b/frontend/src/components/pure/ms-table/useTable.ts index 710f06f5ee..b0b4e79787 100644 --- a/frontend/src/components/pure/ms-table/useTable.ts +++ b/frontend/src/components/pure/ms-table/useTable.ts @@ -89,6 +89,8 @@ export default function useTableProps( const keyword = ref(''); // 高级筛选 const advanceFilter = reactive({ searchMode: 'AND', conditions: [] }); + // 视图Id + const viewId = ref(''); // 表格请求参数集合 const tableQueryParams = ref({}); @@ -165,9 +167,10 @@ export default function useTableProps( }; // 设置 advanceFilter - const setAdvanceFilter = (v: FilterResult) => { + const setAdvanceFilter = (v: FilterResult, id: string) => { advanceFilter.searchMode = v.searchMode; advanceFilter.conditions = v.conditions; + viewId.value = id; // 基础筛选都清空 loadListParams.value.filter = {}; keyword.value = ''; @@ -234,6 +237,7 @@ export default function useTableProps( pageSize: currentPageSize, sort: sortItem.value, keyword: keyword.value, + viewId: viewId.value, combineSearch: advanceFilter, ...loadListParams.value, filter: { @@ -608,6 +612,7 @@ export default function useTableProps( propsRes, propsEvent, advanceFilter, + viewId, setProps, setLoading, loadList, diff --git a/frontend/src/views/case-management/caseManagementFeature/components/caseTable.vue b/frontend/src/views/case-management/caseManagementFeature/components/caseTable.vue index 7af22508a6..9d9aac455e 100644 --- a/frontend/src/views/case-management/caseManagementFeature/components/caseTable.vue +++ b/frontend/src/views/case-management/caseManagementFeature/components/caseTable.vue @@ -936,6 +936,7 @@ const { propsRes, propsEvent, + viewId, advanceFilter, loadList, setLoadListParams, @@ -985,6 +986,7 @@ return { keyword: keyword.value, filter: propsRes.value.filter, + viewId: viewId.value, combineSearch: advanceFilter, }; }); @@ -1625,12 +1627,12 @@ } } // 高级检索 - const handleAdvSearch = async (filter: FilterResult) => { + const handleAdvSearch = async (filter: FilterResult, id: string) => { resetSelector(); emit('setActiveFolder'); keyword.value = ''; await getLoadListParams(); // 基础筛选都清空 - setAdvanceFilter(filter); + setAdvanceFilter(filter, id); loadList(); }; // 更新用例等级 diff --git a/frontend/src/views/case-management/caseManagementFeature/components/recycleCaseTable.vue b/frontend/src/views/case-management/caseManagementFeature/components/recycleCaseTable.vue index f82e1ed7e0..1253f1f933 100644 --- a/frontend/src/views/case-management/caseManagementFeature/components/recycleCaseTable.vue +++ b/frontend/src/views/case-management/caseManagementFeature/components/recycleCaseTable.vue @@ -223,7 +223,7 @@ const currentProjectId = computed(() => appStore.currentProjectId); const scrollWidth = ref(3400); - const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector, setAdvanceFilter, setKeyword } = useTable( + const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector, setKeyword } = useTable( getRecycleListRequest, { tableKey: TableKeyEnum.CASE_MANAGEMENT_RECYCLE_TABLE,