refactor(测试用例): 高级筛选-修改批量操作的参数

This commit is contained in:
teukkk 2024-09-02 16:16:13 +08:00 committed by Craftsman
parent 93cee2b8b9
commit b56994d56c
10 changed files with 41 additions and 82 deletions

View File

@ -62,18 +62,7 @@
</a-option> </a-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item <a-form-item class="flex-1 overflow-hidden" :field="`list[${listIndex}].value`" hide-asterisk>
class="flex-1 overflow-hidden"
:field="`list[${listIndex}].value`"
hide-asterisk
:rules="[
{
validator: (value, callback) => {
validateFilterValue(item, value, callback);
},
},
]"
>
<a-input <a-input
v-if="item.type === FilterType.INPUT" v-if="item.type === FilterType.INPUT"
v-model:model-value="item.value" v-model:model-value="item.value"
@ -264,16 +253,6 @@
]; ];
const formRef = ref<FormInstance>(); const formRef = ref<FormInstance>();
function validateFilterValue(item: FilterFormItem, value: string | undefined, callback: (error?: string) => void) {
if (
item.dataIndex?.length &&
item.operator?.length &&
!['EMPTY', 'NOT_EMPTY'].includes(item.operator as string) &&
!value?.length
) {
callback(t('advanceFilter.filterContentRequired'));
}
}
function getListItemByDataIndex(dataIndex: string) { function getListItemByDataIndex(dataIndex: string) {
return [...props.configList, ...(props.customList || [])].find((item) => item.dataIndex === dataIndex); return [...props.configList, ...(props.customList || [])].find((item) => item.dataIndex === dataIndex);
} }
@ -301,7 +280,7 @@
const listItem = getListItemByDataIndex(dataIndex as string); const listItem = getListItemByDataIndex(dataIndex as string);
if (!listItem) return; if (!listItem) return;
formModel.value.list[index] = { ...listItem }; formModel.value.list[index] = { ...listItem };
formModel.value.list[index].value = valueIsArray(listItem) ? [] : ''; formModel.value.list[index].value = valueIsArray(listItem) ? [] : undefined;
// // // //
if (!formModel.value.list[index].operator?.length) { if (!formModel.value.list[index].operator?.length) {
@ -319,10 +298,7 @@
} }
// //
function operatorChange(item: FilterFormItem, index: number) { function operatorChange(item: FilterFormItem, index: number) {
formModel.value.list[index].value = valueIsArray(item) ? [] : ''; formModel.value.list[index].value = valueIsArray(item) ? [] : undefined;
if (['EMPTY', 'NOT_EMPTY'].includes(formModel.value.list[index].operator as string)) {
formRef.value?.validate();
}
} }
function isValueDisabled(item: FilterFormItem) { function isValueDisabled(item: FilterFormItem) {
return !item.dataIndex || ['EMPTY', 'NOT_EMPTY'].includes(item.operator as string); return !item.dataIndex || ['EMPTY', 'NOT_EMPTY'].includes(item.operator as string);
@ -346,7 +322,7 @@
value, value,
operator, operator,
customField: customField ?? false, customField: customField ?? false,
key: dataIndex, name: dataIndex,
})); }));
return { searchMode: formModel.value.searchMode, conditions }; return { searchMode: formModel.value.searchMode, conditions };
} }
@ -354,7 +330,6 @@
// TODO lmy // TODO lmy
function handleReset() { function handleReset() {
formModel.value = cloneDeep(savedFormModel.value); formModel.value = cloneDeep(savedFormModel.value);
emit('handleFilter', { searchMode: formModel.value.searchMode, conditions: [] });
} }
function handleFilter() { function handleFilter() {

View File

@ -27,8 +27,8 @@
:placeholder="props.searchPlaceholder" :placeholder="props.searchPlaceholder"
class="w-[240px]" class="w-[240px]"
allow-clear allow-clear
@press-enter="emit('keywordSearch', keyword, filterResult)" @press-enter="emit('keywordSearch', keyword)"
@search="emit('keywordSearch', keyword, filterResult)" @search="emit('keywordSearch', keyword)"
@clear="handleClear" @clear="handleClear"
></a-input-search> ></a-input-search>
<a-button <a-button
@ -88,7 +88,7 @@
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'keywordSearch', value: string | undefined, combine: FilterResult): void; // keyword TODO: v-model:keyword (e: 'keywordSearch', value: string | undefined): void; // keyword TODO: v-model:keyword
(e: 'advSearch', value: FilterResult): void; // (e: 'advSearch', value: FilterResult): void; //
(e: 'refresh', value: FilterResult): void; (e: 'refresh', value: FilterResult): void;
}>(); }>();
@ -113,7 +113,7 @@
const handleClear = () => { const handleClear = () => {
keyword.value = ''; keyword.value = '';
emit('keywordSearch', '', filterResult.value); emit('keywordSearch', '');
}; };
const handleOpenFilter = () => { const handleOpenFilter = () => {

View File

@ -47,7 +47,7 @@ export type AccordBelowType = 'AND' | 'OR';
export type CombineItem = Pick<FilterFormItem, 'value' | 'operator' | 'customField'>; export type CombineItem = Pick<FilterFormItem, 'value' | 'operator' | 'customField'>;
export interface ConditionsItem extends CombineItem { export interface ConditionsItem extends CombineItem {
key?: string; name?: string;
} }
export interface FilterResult { export interface FilterResult {

View File

@ -180,7 +180,3 @@ export interface BatchActionQueryParams {
currentSelectCount?: number; // 当前选中的数量 currentSelectCount?: number; // 当前选中的数量
condition?: any; // 查询条件 condition?: any; // 查询条件
} }
export interface CombineParams {
[key: string]: any;
}

View File

@ -11,14 +11,7 @@ import type { CommonList, TableQueryParams } from '@/models/common';
import { SelectAllEnum } from '@/enums/tableEnum'; import { SelectAllEnum } from '@/enums/tableEnum';
import { FilterResult } from '../ms-advance-filter/type'; import { FilterResult } from '../ms-advance-filter/type';
import type { import type { MsTableColumn, MsTableDataItem, MsTableErrorStatus, MsTableProps, SetPaginationPrams } from './type';
CombineParams,
MsTableColumn,
MsTableDataItem,
MsTableErrorStatus,
MsTableProps,
SetPaginationPrams,
} from './type';
import { getCurrentRecordChildrenIds } from './utils'; import { getCurrentRecordChildrenIds } from './utils';
import type { TableData } from '@arco-design/web-vue'; import type { TableData } from '@arco-design/web-vue';
@ -172,7 +165,7 @@ export default function useTableProps<T>(
}; };
// 设置 advanceFilter // 设置 advanceFilter
const setAdvanceFilter = (v: CombineParams) => { const setAdvanceFilter = (v: FilterResult) => {
advanceFilter.searchMode = v.searchMode; advanceFilter.searchMode = v.searchMode;
advanceFilter.conditions = v.conditions; advanceFilter.conditions = v.conditions;
// 基础筛选都清空 // 基础筛选都清空
@ -597,6 +590,7 @@ export default function useTableProps<T>(
return { return {
propsRes, propsRes,
propsEvent, propsEvent,
advanceFilter,
setProps, setProps,
setLoading, setLoading,
loadList, loadList,

View File

@ -468,6 +468,7 @@
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'init', params: CaseModuleQueryParams, refreshModule?: boolean): void; (e: 'init', params: CaseModuleQueryParams, refreshModule?: boolean): void;
(e: 'initModules'): void; (e: 'initModules'): void;
(e: 'setActiveFolder'): void;
}>(); }>();
const minderStore = useMinderStore(); const minderStore = useMinderStore();
@ -856,6 +857,7 @@
title: item.name, title: item.name,
dataIndex: item.id, dataIndex: item.id,
type: formType, type: formType,
customField: true,
}; };
if (formObject.propsKey && formProps.options) { if (formObject.propsKey && formProps.options) {
@ -919,7 +921,16 @@
draggableCondition: true, draggableCondition: true,
}); });
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector, setKeyword, setAdvanceFilter } = useTable( const {
propsRes,
propsEvent,
advanceFilter,
loadList,
setLoadListParams,
resetSelector,
setKeyword,
setAdvanceFilter,
} = useTable(
getCaseList, getCaseList,
tableProps.value, tableProps.value,
(record) => { (record) => {
@ -962,7 +973,7 @@
return { return {
keyword: keyword.value, keyword: keyword.value,
filter: propsRes.value.filter, filter: propsRes.value.filter,
combine: batchParams.value.condition, combineSearch: advanceFilter,
}; };
}); });
@ -983,7 +994,7 @@
excludeIds: batchParams.value.excludeIds || [], excludeIds: batchParams.value.excludeIds || [],
selectAll: batchParams.value.selectAll, selectAll: batchParams.value.selectAll,
selectIds: batchParams.value.selectedIds || [], selectIds: batchParams.value.selectedIds || [],
keyword: isAdvancedSearchMode.value ? '' : keyword.value, keyword: keyword.value,
}; };
} }
// //
@ -1253,11 +1264,7 @@
selectIds: selectAll ? [] : selectedIds, selectIds: selectAll ? [] : selectedIds,
excludeIds: excludeIds || [], excludeIds: excludeIds || [],
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds], moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
condition: { condition: conditionParams.value,
keyword: keyword.value,
filter: propsRes.value.filter,
combine: batchParams.value.condition,
},
selectAll, selectAll,
systemFields: getConfirmFields(option, 'system'), systemFields: getConfirmFields(option, 'system'),
customFields: getConfirmFields(option, 'custom'), customFields: getConfirmFields(option, 'custom'),
@ -1329,11 +1336,7 @@
selectIds: batchParams.value.selectedIds || [], selectIds: batchParams.value.selectedIds || [],
selectAll: !!batchParams.value?.selectAll, selectAll: !!batchParams.value?.selectAll,
excludeIds: batchParams.value?.excludeIds || [], excludeIds: batchParams.value?.excludeIds || [],
condition: { condition: conditionParams.value,
keyword: keyword.value,
filter: propsRes.value.filter,
combine: batchParams.value.condition,
},
projectId: currentProjectId.value, projectId: currentProjectId.value,
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds], moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
moduleId: selectedModuleKeys.value[0], moduleId: selectedModuleKeys.value[0],
@ -1409,11 +1412,7 @@
selectIds: selectAll ? [] : selectedIds, selectIds: selectAll ? [] : selectedIds,
excludeIds: excludeIds || [], excludeIds: excludeIds || [],
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds], moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
condition: { condition: conditionParams.value,
keyword: keyword.value,
filter: propsRes.value.filter,
combine: batchParams.value.condition,
},
selectAll, selectAll,
}); });
resetSelector(); resetSelector();
@ -1615,6 +1614,9 @@
// //
const handleAdvSearch = async (filter: FilterResult) => { const handleAdvSearch = async (filter: FilterResult) => {
isAdvancedSearchMode.value = !!filter.conditions?.length; isAdvancedSearchMode.value = !!filter.conditions?.length;
resetSelector();
emit('setActiveFolder');
keyword.value = '';
await getLoadListParams(); // await getLoadListParams(); //
setAdvanceFilter(filter); setAdvanceFilter(filter);
loadList(); loadList();
@ -1698,7 +1700,7 @@
selectIds: batchParams.value?.selectAll ? [] : batchParams.value.selectedIds, selectIds: batchParams.value?.selectAll ? [] : batchParams.value.selectedIds,
selectAll: !!batchParams.value?.selectAll, selectAll: !!batchParams.value?.selectAll,
excludeIds: batchParams.value?.excludeIds || [], excludeIds: batchParams.value?.excludeIds || [],
condition: { keyword: keyword.value }, condition: conditionParams.value,
projectId: currentProjectId.value, projectId: currentProjectId.value,
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds], moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
moduleId: selectedModuleKeys.value[0], moduleId: selectedModuleKeys.value[0],
@ -1736,11 +1738,7 @@
demandPlatform, demandPlatform,
demandList, demandList,
filter: propsRes.value.filter, filter: propsRes.value.filter,
condition: { condition: conditionParams.value,
keyword: keyword.value,
filter: propsRes.value.filter,
combine: batchParams.value.condition,
},
functionalDemandBatchRequest, functionalDemandBatchRequest,
}; };
await batchAssociationDemand(batchAddParams); await batchAssociationDemand(batchAddParams);
@ -1798,7 +1796,7 @@
watch( watch(
() => props.activeFolder, () => props.activeFolder,
(val) => { (val) => {
if (props.activeFolder !== 'recycle' && val) { if (props.activeFolder !== 'recycle' && val && !isAdvancedSearchMode.value) {
initData(); initData();
resetSelector(); resetSelector();
} }

View File

@ -141,7 +141,7 @@
}); });
const platName = computed(() => { const platName = computed(() => {
return getPlatName(props.platformInfo.value.platform_key); return getPlatName(props.platformInfo.platform_key);
}); });
async function handleDrawerConfirm() { async function handleDrawerConfirm() {

View File

@ -86,6 +86,7 @@
:module-name="activeFolderName" :module-name="activeFolderName"
@init="initModulesCount" @init="initModulesCount"
@init-modules="initModules" @init-modules="initModules"
@set-active-folder="setActiveFolder('all')"
/> />
</div> </div>
</template> </template>

View File

@ -9,7 +9,7 @@
:name="moduleNamePath" :name="moduleNamePath"
:not-show-input-search="showType !== 'list'" :not-show-input-search="showType !== 'list'"
:search-placeholder="t('caseManagement.caseReview.searchPlaceholder')" :search-placeholder="t('caseManagement.caseReview.searchPlaceholder')"
@keyword-search="(val, filter) => searchCase(filter)" @keyword-search="searchCase()"
@adv-search="searchCase" @adv-search="searchCase"
@refresh="handleRefreshAll" @refresh="handleRefreshAll"
> >
@ -593,18 +593,13 @@
}); });
} }
function searchCase(filter?: FilterResult) { function searchCase() {
tableParams.value = { tableParams.value = {
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
reviewId: route.query.id, reviewId: route.query.id,
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds], moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
keyword: keyword.value, keyword: keyword.value,
viewFlag: props.onlyMine, viewFlag: props.onlyMine,
combine: filter
? {
...filter.combine,
}
: {},
}; };
setLoadListParams(tableParams.value); setLoadListParams(tableParams.value);
resetSelector(); resetSelector();

View File

@ -6,7 +6,7 @@
:filter-config-list="filterConfigList" :filter-config-list="filterConfigList"
:row-count="filterRowCount" :row-count="filterRowCount"
:search-placeholder="t('caseManagement.caseReview.list.searchPlaceholder')" :search-placeholder="t('caseManagement.caseReview.list.searchPlaceholder')"
@keyword-search="(val, filter) => searchReview(filter)" @keyword-search="searchReview()"
@adv-search="searchReview" @adv-search="searchReview"
@refresh="searchReview" @refresh="searchReview"
> >
@ -545,7 +545,7 @@
}; };
const tableQueryParams = ref<any>(); const tableQueryParams = ref<any>();
async function searchReview(filter?: FilterResult) { async function searchReview() {
let moduleIds: string[] = []; let moduleIds: string[] = [];
if (props.activeFolder && props.activeFolder !== 'all') { if (props.activeFolder && props.activeFolder !== 'all') {
moduleIds = [props.activeFolder]; moduleIds = [props.activeFolder];