Files
guofu-admin/src/views/cms/mpDesign/components/search.vue

74 lines
1.5 KiB
Vue

<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加图标</span>
</a-button>
<SelectDict
dict-code="mpGroup"
:placeholder="`选择分组`"
v-model:value="where.groupName"
@done="chooseGroupId"
/>
<a-button @click="reset">重置</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import { watch } from 'vue';
import useSearch from '@/utils/use-search';
import { MpMenu, MpMenuParam } from '@/api/cms/mp-menu/model';
import { DictData } from '@/api/system/dict-data/model';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: MpMenuParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 表单数据
const { where } = useSearch<MpMenu>({
parentId: undefined,
groupName: ''
});
const handleSearch = () => {
emit('search', where);
};
/* 重置 */
const reset = () => {
where.parentId = undefined;
handleSearch();
};
// 新增
const add = () => {
emit('add');
};
const chooseGroupId = (item: DictData) => {
where.parentId = item.dictDataId;
where.groupName = item.dictDataName;
handleSearch();
};
watch(
() => props.selection,
() => {}
);
</script>