- 调整 import 语句格式,统一空格和引号风格 - 修复函数参数跨行时的格式对齐问题 - 清理多余空行和注释中的空白字符 - 统一对象属性结尾逗号的使用规范 - 规范化字符串拼接和模板语法的格式 - 优化长参数列表的换行和缩进格式
108 lines
2.6 KiB
Vue
108 lines
2.6 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>
|
|
<a-tree-select
|
|
allow-clear
|
|
:tree-data="navigationList"
|
|
tree-default-expand-all
|
|
style="width: 240px"
|
|
:listHeight="700"
|
|
placeholder="请选择栏目"
|
|
:value="where.categoryId || undefined"
|
|
:dropdown-style="{ overflow: 'auto' }"
|
|
@update:value="(value?: number) => (where.categoryId = value)"
|
|
@change="onCategoryId"
|
|
/>
|
|
<a-input-search
|
|
allow-clear
|
|
placeholder="请输入关键词"
|
|
style="width: 240px"
|
|
v-model:value="where.keywords"
|
|
@search="reload"
|
|
/>
|
|
<a-button @click="resetFields">重置</a-button>
|
|
</a-space>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { PlusOutlined } from '@ant-design/icons-vue';
|
|
import { ref, watch } from 'vue';
|
|
import { listCmsNavigation } from '@/api/cms/cmsNavigation';
|
|
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
|
|
import { toTreeData } from 'ele-admin-pro';
|
|
import useSearch from '@/utils/use-search';
|
|
import type { CmsDesignParam } from '@/api/cms/cmsDesign/model';
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
// 选中的数据
|
|
selection?: [];
|
|
}>(),
|
|
{}
|
|
);
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'search', where?: CmsDesignParam): void;
|
|
(e: 'add'): void;
|
|
(e: 'remove'): void;
|
|
(e: 'batchMove'): void;
|
|
}>();
|
|
|
|
// 栏目数据
|
|
const navigationList = ref<CmsNavigation[]>([]);
|
|
|
|
// 表单数据
|
|
const { where, resetFields } = useSearch<CmsDesignParam>({
|
|
keywords: '',
|
|
categoryId: undefined
|
|
});
|
|
|
|
// 新增
|
|
const add = () => {
|
|
emit('add');
|
|
};
|
|
|
|
// 搜索
|
|
const reload = () => {
|
|
emit('search', where);
|
|
};
|
|
|
|
// 按分类查询
|
|
const onCategoryId = (id: number) => {
|
|
where.categoryId = id;
|
|
emit('search', where);
|
|
};
|
|
|
|
// 加载栏目数据
|
|
if (!navigationList.value.length) {
|
|
listCmsNavigation({}).then((res) => {
|
|
navigationList.value = toTreeData({
|
|
data: res?.map((d) => {
|
|
d.value = d.navigationId;
|
|
d.label = d.title;
|
|
if (!d.component) {
|
|
d.disabled = true;
|
|
}
|
|
if (d.model == 'index' || d.model == 'page' || d.model == 'order') {
|
|
d.disabled = true;
|
|
}
|
|
return d;
|
|
}),
|
|
idField: 'navigationId',
|
|
parentIdField: 'parentId'
|
|
});
|
|
});
|
|
}
|
|
|
|
watch(
|
|
() => props.selection,
|
|
() => {}
|
|
);
|
|
</script>
|