feat: 高级筛选-自定义字段-支持CASCADER类型

This commit is contained in:
teukkk 2024-11-17 20:27:36 +08:00 committed by Craftsman
parent 613fb5541b
commit 08e847d14e
3 changed files with 22 additions and 0 deletions

View File

@ -136,6 +136,19 @@
:placeholder="t('common.pleaseSelect')" :placeholder="t('common.pleaseSelect')"
:field-names="item.treeSelectProps?.fieldNames" :field-names="item.treeSelectProps?.fieldNames"
/> />
<MsCascader
v-else-if="item.type === FilterType.CASCADER"
v-model:model-value="item.value"
:options="item.cascaderProps?.options || []"
mode="native"
option-size="small"
strictly
label-path-mode
v-bind="item.cascaderProps"
:placeholder="t('common.pleaseSelect')"
:disabled="isValueDisabled(item)"
:virtual-list-props="{ height: 200 }"
/>
<a-date-picker <a-date-picker
v-else-if="item.type === FilterType.DATE_PICKER && item.operator !== OperatorEnum.BETWEEN" v-else-if="item.type === FilterType.DATE_PICKER && item.operator !== OperatorEnum.BETWEEN"
v-model:model-value="item.value" v-model:model-value="item.value"
@ -225,6 +238,7 @@
import MsDrawer from '@/components/pure/ms-drawer/index.vue'; import MsDrawer from '@/components/pure/ms-drawer/index.vue';
import MsTagsInput from '@/components/pure/ms-tags-input/index.vue'; import MsTagsInput from '@/components/pure/ms-tags-input/index.vue';
import MsTreeSelect from '@/components/pure/ms-tree-select/index.vue'; import MsTreeSelect from '@/components/pure/ms-tree-select/index.vue';
import MsCascader from '@/components/business/ms-cascader/index.vue';
import MsSelect from '@/components/business/ms-select'; import MsSelect from '@/components/business/ms-select';
import ViewNameInput from './components/viewNameInput.vue'; import ViewNameInput from './components/viewNameInput.vue';
@ -350,6 +364,7 @@
function valueIsArray(listItem: FilterFormItem) { function valueIsArray(listItem: FilterFormItem) {
return ( return (
listItem.selectProps?.multiple || listItem.selectProps?.multiple ||
listItem.cascaderProps?.multiple ||
(listItem.type === FilterType.TAGS_INPUT && (listItem.type === FilterType.TAGS_INPUT &&
![OperatorEnum.COUNT_LT, OperatorEnum.COUNT_GT].includes(listItem.operator as OperatorEnum)) || ![OperatorEnum.COUNT_LT, OperatorEnum.COUNT_GT].includes(listItem.operator as OperatorEnum)) ||
(listItem.type === FilterType.DATE_PICKER && listItem.operator === OperatorEnum.BETWEEN) (listItem.type === FilterType.DATE_PICKER && listItem.operator === OperatorEnum.BETWEEN)

View File

@ -36,6 +36,7 @@ export const operatorOptionsMap: Record<string, { value: string; label: string }
[FilterType.TEXTAREA]: COMMON_TEXT_OPERATORS, [FilterType.TEXTAREA]: COMMON_TEXT_OPERATORS,
[FilterType.NUMBER]: [GT, LT, EQUAL, EMPTY, NOT_EMPTY], [FilterType.NUMBER]: [GT, LT, EQUAL, EMPTY, NOT_EMPTY],
[FilterType.SELECT]: COMMON_SELECTION_OPERATORS, [FilterType.SELECT]: COMMON_SELECTION_OPERATORS,
[FilterType.CASCADER]: COMMON_SELECTION_OPERATORS,
[FilterType.BOOLEAN]: [EQUAL], [FilterType.BOOLEAN]: [EQUAL],
[FilterType.MEMBER]: COMMON_SELECTION_OPERATORS, [FilterType.MEMBER]: COMMON_SELECTION_OPERATORS,
[FilterType.TAGS_INPUT]: [EMPTY, CONTAINS, NO_CONTAINS, COUNT_LT, COUNT_GT], [FilterType.TAGS_INPUT]: [EMPTY, CONTAINS, NO_CONTAINS, COUNT_LT, COUNT_GT],
@ -79,6 +80,11 @@ export const CustomTypeMaps: Record<string, any> = {
INPUT: { INPUT: {
type: 'INPUT', type: 'INPUT',
}, },
CASCADER: {
type: 'CASCADER',
propsKey: 'cascaderProps',
props: { multiple: true, valueKey: 'value', labelKey: 'text', options: [] },
},
SELECT: { SELECT: {
type: 'SELECT', type: 'SELECT',
propsKey: 'selectProps', propsKey: 'selectProps',

View File

@ -24,6 +24,7 @@ export enum FilterType {
TREE_SELECT = 'TreeSelect', TREE_SELECT = 'TreeSelect',
TEXTAREA = 'textArea', TEXTAREA = 'textArea',
BOOLEAN = 'boolean', BOOLEAN = 'boolean',
CASCADER = 'Cascader',
} }
export enum ViewTypeEnum { export enum ViewTypeEnum {