mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-11-30 11:08:38 +08:00
refactor(测试用例): 高级筛选-修改批量操作的参数
This commit is contained in:
parent
93cee2b8b9
commit
b56994d56c
@ -62,18 +62,7 @@
|
||||
</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
class="flex-1 overflow-hidden"
|
||||
:field="`list[${listIndex}].value`"
|
||||
hide-asterisk
|
||||
:rules="[
|
||||
{
|
||||
validator: (value, callback) => {
|
||||
validateFilterValue(item, value, callback);
|
||||
},
|
||||
},
|
||||
]"
|
||||
>
|
||||
<a-form-item class="flex-1 overflow-hidden" :field="`list[${listIndex}].value`" hide-asterisk>
|
||||
<a-input
|
||||
v-if="item.type === FilterType.INPUT"
|
||||
v-model:model-value="item.value"
|
||||
@ -264,16 +253,6 @@
|
||||
];
|
||||
|
||||
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) {
|
||||
return [...props.configList, ...(props.customList || [])].find((item) => item.dataIndex === dataIndex);
|
||||
}
|
||||
@ -301,7 +280,7 @@
|
||||
const listItem = getListItemByDataIndex(dataIndex as string);
|
||||
if (!listItem) return;
|
||||
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) {
|
||||
@ -319,10 +298,7 @@
|
||||
}
|
||||
// 改变第二列值
|
||||
function operatorChange(item: FilterFormItem, index: number) {
|
||||
formModel.value.list[index].value = valueIsArray(item) ? [] : '';
|
||||
if (['EMPTY', 'NOT_EMPTY'].includes(formModel.value.list[index].operator as string)) {
|
||||
formRef.value?.validate();
|
||||
}
|
||||
formModel.value.list[index].value = valueIsArray(item) ? [] : undefined;
|
||||
}
|
||||
function isValueDisabled(item: FilterFormItem) {
|
||||
return !item.dataIndex || ['EMPTY', 'NOT_EMPTY'].includes(item.operator as string);
|
||||
@ -346,7 +322,7 @@
|
||||
value,
|
||||
operator,
|
||||
customField: customField ?? false,
|
||||
key: dataIndex,
|
||||
name: dataIndex,
|
||||
}));
|
||||
return { searchMode: formModel.value.searchMode, conditions };
|
||||
}
|
||||
@ -354,7 +330,6 @@
|
||||
// TODO lmy 根据视图重置
|
||||
function handleReset() {
|
||||
formModel.value = cloneDeep(savedFormModel.value);
|
||||
emit('handleFilter', { searchMode: formModel.value.searchMode, conditions: [] });
|
||||
}
|
||||
|
||||
function handleFilter() {
|
||||
|
@ -27,8 +27,8 @@
|
||||
:placeholder="props.searchPlaceholder"
|
||||
class="w-[240px]"
|
||||
allow-clear
|
||||
@press-enter="emit('keywordSearch', keyword, filterResult)"
|
||||
@search="emit('keywordSearch', keyword, filterResult)"
|
||||
@press-enter="emit('keywordSearch', keyword)"
|
||||
@search="emit('keywordSearch', keyword)"
|
||||
@clear="handleClear"
|
||||
></a-input-search>
|
||||
<a-button
|
||||
@ -88,7 +88,7 @@
|
||||
}>();
|
||||
|
||||
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: 'refresh', value: FilterResult): void;
|
||||
}>();
|
||||
@ -113,7 +113,7 @@
|
||||
|
||||
const handleClear = () => {
|
||||
keyword.value = '';
|
||||
emit('keywordSearch', '', filterResult.value);
|
||||
emit('keywordSearch', '');
|
||||
};
|
||||
|
||||
const handleOpenFilter = () => {
|
||||
|
@ -47,7 +47,7 @@ export type AccordBelowType = 'AND' | 'OR';
|
||||
|
||||
export type CombineItem = Pick<FilterFormItem, 'value' | 'operator' | 'customField'>;
|
||||
export interface ConditionsItem extends CombineItem {
|
||||
key?: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface FilterResult {
|
||||
|
@ -180,7 +180,3 @@ export interface BatchActionQueryParams {
|
||||
currentSelectCount?: number; // 当前选中的数量
|
||||
condition?: any; // 查询条件
|
||||
}
|
||||
|
||||
export interface CombineParams {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
@ -11,14 +11,7 @@ import type { CommonList, TableQueryParams } from '@/models/common';
|
||||
import { SelectAllEnum } from '@/enums/tableEnum';
|
||||
|
||||
import { FilterResult } from '../ms-advance-filter/type';
|
||||
import type {
|
||||
CombineParams,
|
||||
MsTableColumn,
|
||||
MsTableDataItem,
|
||||
MsTableErrorStatus,
|
||||
MsTableProps,
|
||||
SetPaginationPrams,
|
||||
} from './type';
|
||||
import type { MsTableColumn, MsTableDataItem, MsTableErrorStatus, MsTableProps, SetPaginationPrams } from './type';
|
||||
import { getCurrentRecordChildrenIds } from './utils';
|
||||
import type { TableData } from '@arco-design/web-vue';
|
||||
|
||||
@ -172,7 +165,7 @@ export default function useTableProps<T>(
|
||||
};
|
||||
|
||||
// 设置 advanceFilter
|
||||
const setAdvanceFilter = (v: CombineParams) => {
|
||||
const setAdvanceFilter = (v: FilterResult) => {
|
||||
advanceFilter.searchMode = v.searchMode;
|
||||
advanceFilter.conditions = v.conditions;
|
||||
// 基础筛选都清空
|
||||
@ -597,6 +590,7 @@ export default function useTableProps<T>(
|
||||
return {
|
||||
propsRes,
|
||||
propsEvent,
|
||||
advanceFilter,
|
||||
setProps,
|
||||
setLoading,
|
||||
loadList,
|
||||
|
@ -468,6 +468,7 @@
|
||||
const emit = defineEmits<{
|
||||
(e: 'init', params: CaseModuleQueryParams, refreshModule?: boolean): void;
|
||||
(e: 'initModules'): void;
|
||||
(e: 'setActiveFolder'): void;
|
||||
}>();
|
||||
|
||||
const minderStore = useMinderStore();
|
||||
@ -856,6 +857,7 @@
|
||||
title: item.name,
|
||||
dataIndex: item.id,
|
||||
type: formType,
|
||||
customField: true,
|
||||
};
|
||||
|
||||
if (formObject.propsKey && formProps.options) {
|
||||
@ -919,7 +921,16 @@
|
||||
draggableCondition: true,
|
||||
});
|
||||
|
||||
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector, setKeyword, setAdvanceFilter } = useTable(
|
||||
const {
|
||||
propsRes,
|
||||
propsEvent,
|
||||
advanceFilter,
|
||||
loadList,
|
||||
setLoadListParams,
|
||||
resetSelector,
|
||||
setKeyword,
|
||||
setAdvanceFilter,
|
||||
} = useTable(
|
||||
getCaseList,
|
||||
tableProps.value,
|
||||
(record) => {
|
||||
@ -962,7 +973,7 @@
|
||||
return {
|
||||
keyword: keyword.value,
|
||||
filter: propsRes.value.filter,
|
||||
combine: batchParams.value.condition,
|
||||
combineSearch: advanceFilter,
|
||||
};
|
||||
});
|
||||
|
||||
@ -983,7 +994,7 @@
|
||||
excludeIds: batchParams.value.excludeIds || [],
|
||||
selectAll: batchParams.value.selectAll,
|
||||
selectIds: batchParams.value.selectedIds || [],
|
||||
keyword: isAdvancedSearchMode.value ? '' : keyword.value,
|
||||
keyword: keyword.value,
|
||||
};
|
||||
}
|
||||
// 获取父组件模块数量
|
||||
@ -1253,11 +1264,7 @@
|
||||
selectIds: selectAll ? [] : selectedIds,
|
||||
excludeIds: excludeIds || [],
|
||||
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
|
||||
condition: {
|
||||
keyword: keyword.value,
|
||||
filter: propsRes.value.filter,
|
||||
combine: batchParams.value.condition,
|
||||
},
|
||||
condition: conditionParams.value,
|
||||
selectAll,
|
||||
systemFields: getConfirmFields(option, 'system'),
|
||||
customFields: getConfirmFields(option, 'custom'),
|
||||
@ -1329,11 +1336,7 @@
|
||||
selectIds: batchParams.value.selectedIds || [],
|
||||
selectAll: !!batchParams.value?.selectAll,
|
||||
excludeIds: batchParams.value?.excludeIds || [],
|
||||
condition: {
|
||||
keyword: keyword.value,
|
||||
filter: propsRes.value.filter,
|
||||
combine: batchParams.value.condition,
|
||||
},
|
||||
condition: conditionParams.value,
|
||||
projectId: currentProjectId.value,
|
||||
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
|
||||
moduleId: selectedModuleKeys.value[0],
|
||||
@ -1409,11 +1412,7 @@
|
||||
selectIds: selectAll ? [] : selectedIds,
|
||||
excludeIds: excludeIds || [],
|
||||
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
|
||||
condition: {
|
||||
keyword: keyword.value,
|
||||
filter: propsRes.value.filter,
|
||||
combine: batchParams.value.condition,
|
||||
},
|
||||
condition: conditionParams.value,
|
||||
selectAll,
|
||||
});
|
||||
resetSelector();
|
||||
@ -1615,6 +1614,9 @@
|
||||
// 高级检索
|
||||
const handleAdvSearch = async (filter: FilterResult) => {
|
||||
isAdvancedSearchMode.value = !!filter.conditions?.length;
|
||||
resetSelector();
|
||||
emit('setActiveFolder');
|
||||
keyword.value = '';
|
||||
await getLoadListParams(); // 基础筛选都清空
|
||||
setAdvanceFilter(filter);
|
||||
loadList();
|
||||
@ -1698,7 +1700,7 @@
|
||||
selectIds: batchParams.value?.selectAll ? [] : batchParams.value.selectedIds,
|
||||
selectAll: !!batchParams.value?.selectAll,
|
||||
excludeIds: batchParams.value?.excludeIds || [],
|
||||
condition: { keyword: keyword.value },
|
||||
condition: conditionParams.value,
|
||||
projectId: currentProjectId.value,
|
||||
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
|
||||
moduleId: selectedModuleKeys.value[0],
|
||||
@ -1736,11 +1738,7 @@
|
||||
demandPlatform,
|
||||
demandList,
|
||||
filter: propsRes.value.filter,
|
||||
condition: {
|
||||
keyword: keyword.value,
|
||||
filter: propsRes.value.filter,
|
||||
combine: batchParams.value.condition,
|
||||
},
|
||||
condition: conditionParams.value,
|
||||
functionalDemandBatchRequest,
|
||||
};
|
||||
await batchAssociationDemand(batchAddParams);
|
||||
@ -1798,7 +1796,7 @@
|
||||
watch(
|
||||
() => props.activeFolder,
|
||||
(val) => {
|
||||
if (props.activeFolder !== 'recycle' && val) {
|
||||
if (props.activeFolder !== 'recycle' && val && !isAdvancedSearchMode.value) {
|
||||
initData();
|
||||
resetSelector();
|
||||
}
|
||||
|
@ -141,7 +141,7 @@
|
||||
});
|
||||
|
||||
const platName = computed(() => {
|
||||
return getPlatName(props.platformInfo.value.platform_key);
|
||||
return getPlatName(props.platformInfo.platform_key);
|
||||
});
|
||||
|
||||
async function handleDrawerConfirm() {
|
||||
|
@ -86,6 +86,7 @@
|
||||
:module-name="activeFolderName"
|
||||
@init="initModulesCount"
|
||||
@init-modules="initModules"
|
||||
@set-active-folder="setActiveFolder('all')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -9,7 +9,7 @@
|
||||
:name="moduleNamePath"
|
||||
:not-show-input-search="showType !== 'list'"
|
||||
:search-placeholder="t('caseManagement.caseReview.searchPlaceholder')"
|
||||
@keyword-search="(val, filter) => searchCase(filter)"
|
||||
@keyword-search="searchCase()"
|
||||
@adv-search="searchCase"
|
||||
@refresh="handleRefreshAll"
|
||||
>
|
||||
@ -593,18 +593,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
function searchCase(filter?: FilterResult) {
|
||||
function searchCase() {
|
||||
tableParams.value = {
|
||||
projectId: appStore.currentProjectId,
|
||||
reviewId: route.query.id,
|
||||
moduleIds: props.activeFolder === 'all' ? [] : [props.activeFolder, ...props.offspringIds],
|
||||
keyword: keyword.value,
|
||||
viewFlag: props.onlyMine,
|
||||
combine: filter
|
||||
? {
|
||||
...filter.combine,
|
||||
}
|
||||
: {},
|
||||
};
|
||||
setLoadListParams(tableParams.value);
|
||||
resetSelector();
|
||||
|
@ -6,7 +6,7 @@
|
||||
:filter-config-list="filterConfigList"
|
||||
:row-count="filterRowCount"
|
||||
:search-placeholder="t('caseManagement.caseReview.list.searchPlaceholder')"
|
||||
@keyword-search="(val, filter) => searchReview(filter)"
|
||||
@keyword-search="searchReview()"
|
||||
@adv-search="searchReview"
|
||||
@refresh="searchReview"
|
||||
>
|
||||
@ -545,7 +545,7 @@
|
||||
};
|
||||
|
||||
const tableQueryParams = ref<any>();
|
||||
async function searchReview(filter?: FilterResult) {
|
||||
async function searchReview() {
|
||||
let moduleIds: string[] = [];
|
||||
if (props.activeFolder && props.activeFolder !== 'all') {
|
||||
moduleIds = [props.activeFolder];
|
||||
|
Loading…
Reference in New Issue
Block a user