feat(system): 优化菜单管理功能

- 修改菜单查询接口,增加按名称搜索功能
- 更新消息管理相关接口路径
- 优化菜单编辑组件,使用树形结构选择父级菜单
- 移除产品 TSL 组件中的冗余代码
This commit is contained in:
Kven 2025-01-13 20:30:03 +08:00
parent 8421ce2836
commit 9f98fe832a
6 changed files with 277 additions and 263 deletions

View File

@ -23,8 +23,14 @@ export interface MenuCreateRecord extends MenuRecord{
type: string; type: string;
} }
export const queryMenuList = () => { export const queryMenuList = (data: string) => {
return axios.get('/api/rest/menu'); return axios({
url: '/api/rest/menu/tree',
method: 'get',
params: {
name: data,
},
});
}; };
export const createMenu = (data: MenuCreateRecord) => { export const createMenu = (data: MenuCreateRecord) => {

View File

@ -56,27 +56,27 @@ export type MessageListType = MessagesList[];
// 查看详情 // 查看详情
export function queryMessage(id: number) { export function queryMessage(id: number) {
return axios.get(`/api/rest/message/self/${id}`); return axios.get(`/api/rest/notice/self/${id}`);
} }
// 分页查询 // 分页查询
export function queryMessagesList(data: MessagesRecord) { export function queryMessagesList(data: MessagesRecord) {
return axios({ return axios({
url: '/api/rest/message/self', url: '/api/rest/notice/self',
method: 'get', method: 'get',
params: data, params: data,
}); });
} }
// 未读消息数量 // 未读消息数量
export function queryMessagesCount() { export function queryMessagesCount() {
return axios.get('/api/rest/message/count-unread'); return axios.get('/api/rest/notice/count-unread');
} }
// 已读消息数量 // 已读消息数量
export function queryMessagesReadCount() { export function queryMessagesReadCount() {
return axios.get('/api/rest/message/acknowledge'); return axios.get('/api/rest/notice/acknowledge');
} }
// 批量设置消息已读 // 批量设置消息已读
export function setMessageStatus(data: MessageStatus) { export function setMessageStatus(data: MessageStatus) {
return axios.patch<MessageListType>('/api/rest/message/read', data); return axios.patch<MessageListType>('/api/rest/notice/read', data);
} }

View File

@ -71,256 +71,253 @@
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</a-card> </a-card>
<a-modal
width="900px"
height="500px"
:visible="visible && keyValue==='1'"
@cancel="handleCancel"
>
<template #title>新建属性</template>
<a-form
ref="propertyCreateRef"
:model="propertyAddData"
:style="{ width: '800px', height: '420px' }"
>
<!-- 设备名称 -->
<a-form-item
field="name"
label="属性名称"
:rules="[{ required: true, message: '设备名称不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="propertyAddData.name"
placeholder='请输入设备名称'
/>
</a-form-item>
<!-- 标识 -->
<a-form-item
field="identifier"
label="标识"
:rules="[{ required: true, message: '标识不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="propertyAddData.identifier"
placeholder='请输入标识'
/>
</a-form-item>
<!-- 数据类型 -->
<a-form-item
field="dataType"
label="数据类型"
:rules="[{ required: true, message: '数据类型不能为空' }]"
:validate-trigger="['change']"
>
<a-select v-model="propertyAddData.dataType" :options="dataTypeOptions" allow-search placeholder="请选择数据类型"/>
</a-form-item>
<!-- 读写类型 -->
<a-form-item
field="ioType"
label="读写类型"
>
<a-radio-group v-model="propertyAddData.ioType">
<a-radio value="1">读写</a-radio>
<a-radio value="2">只读</a-radio>
</a-radio-group>
</a-form-item>
<!-- 备注 -->
<a-form-item
field="remark"
label="备注"
>
<a-textarea
v-model="propertyAddData.remark"
placeholder='请输入备注'
/>
</a-form-item>
</a-form>
<template #footer>
<a-button class="editor-button" @click="handleCancel">取消</a-button>
<a-button class="editor-button" type="primary" @click="handleSubmit">确定</a-button>
</template>
</a-modal>
<a-modal
width="900px"
height="500px"
:visible="visible && keyValue==='2'"
@cancel="handleCancel"
>
<template #title>新建服务</template>
<a-form
ref="serveCreateRef"
:model="serveAddData"
:style="{ width: '800px', height: '420px' }"
>
<!-- 服务名称 -->
<a-form-item
field="name"
label="服务名称"
:rules="[{ required: true, message: '服务名称不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="serveAddData.name"
placeholder='请输入服务名称'
/>
</a-form-item>
<!-- 标识 -->
<a-form-item
field="identifier"
label="标识"
:rules="[{ required: true, message: '标识不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="serveAddData.identifier"
placeholder='请输入标识'
/>
</a-form-item>
<!-- 输入参数 -->
<a-form-item
field="inputs"
label="输入参数"
>
<div style="width: 100%">
<div style="width: 100%;margin-bottom: 5px; ">
<a-space v-for="(param,index) in serveInputData" :key="index" style="margin-bottom: 5px">
<a-input v-model="param.name" placeholder="名称" allow-clear />
<a-input v-model="param.identifier" placeholder="标识" allow-clear />
<a-select v-model="param.dataType" :options="dataTypeOptions" allow-search placeholder="数据类型" style="width: 140px"/>
<a-select v-model="param.type" :options="typeOptions" allow-search placeholder="类型" style="width: 140px"/>
<a-button type="text" @click="handleDeleteParams(index,'serveInputData')"><icon-minus-circle /></a-button>
</a-space>
</div>
<a-button @click="handleAddParams('serveInputData')" style="width: 100%" type="outline">
<icon-plus />
</a-button>
</div>
</a-form-item>
<!-- 输出参数 -->
<a-form-item
field="outputs"
label="输出参数"
>
<div style="width: 100%">
<div style="width: 100%;margin-bottom: 5px; ">
<a-space v-for="(param,index) in serveOutputData" :key="index" style="margin-bottom: 5px">
<a-input v-model="param.name" placeholder="名称" allow-clear />
<a-input v-model="param.identifier" placeholder="标识" allow-clear />
<a-select v-model="param.dataType" :options="dataTypeOptions" allow-search placeholder="数据类型" style="width: 140px"/>
<a-select v-model="param.type" :options="typeOptions" allow-search placeholder="类型" style="width: 140px"/>
<a-button type="text" @click="handleDeleteParams(index,'serveOutputData')"><icon-minus-circle /></a-button>
</a-space>
</div>
<a-button @click="handleAddParams('serveOutputData')" style="width: 100%" type="outline">
<icon-plus />
</a-button>
</div>
</a-form-item>
<!-- 备注 -->
<a-form-item
field="remark"
label="备注"
>
<a-textarea
v-model="serveInputData.remark"
placeholder='请输入备注'
/>
</a-form-item>
</a-form>
<template #footer>
<a-button class="editor-button" @click="handleCancel">取消</a-button>
<a-button class="editor-button" type="primary" @click="handleSubmit">确定</a-button>
</template>
</a-modal>
<a-modal
width="900px"
height="500px"
:visible="visible && keyValue==='3'"
@cancel="handleCancel"
>
<template #title>新建事件</template>
<a-form
ref="eventCreateRef"
:model="eventAddData"
:style="{ width: '800px', height: '420px' }"
>
<!-- 事件名称 -->
<a-form-item
field="name"
label="服务名称"
:rules="[{ required: true, message: '服务名称不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="eventAddData.name"
placeholder='请输入服务名称'
/>
</a-form-item>
<!-- 标识 -->
<a-form-item
field="identifier"
label="标识"
:rules="[{ required: true, message: '标识不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="eventAddData.identifier"
placeholder='请输入标识'
/>
</a-form-item>
<!-- 类型 -->
<a-form-item
field="type"
label="类型"
:rules="[{ required: true, message: '类型不能为空' }]"
:validate-trigger="['change']"
>
<a-select v-model="eventAddData.type" :options="eventTypeOptions" allow-search placeholder="请选择类型"/>
</a-form-item>
<!-- 输出参数 -->
<a-form-item
field="outputs"
label="输出参数"
>
<div style="width: 100%">
<div style="width: 100%;margin-bottom: 5px; ">
<a-space v-for="(param,index) in eventOutputData" :key="index" style="margin-bottom: 5px">
<a-input v-model="param.name" placeholder="名称" allow-clear />
<a-input v-model="param.identifier" placeholder="标识" allow-clear />
<a-select v-model="param.dataType" :options="dataTypeOptions" allow-search placeholder="数据类型" style="width: 140px"/>
<a-select v-model="param.type" :options="typeOptions" allow-search placeholder="类型" style="width: 140px"/>
<a-button type="text" @click="handleDeleteParams(index,'eventOutputData')"><icon-minus-circle /></a-button>
</a-space>
</div>
<a-button @click="handleAddParams('eventOutputData')" style="width: 100%" type="outline">
<icon-plus />
</a-button>
</div>
</a-form-item>
<!-- 备注 -->
<a-form-item
field="remark"
label="备注"
>
<a-textarea
v-model="eventAddData.remark"
placeholder='请输入备注'
/>
</a-form-item>
</a-form>
<template #footer>
<a-button class="editor-button" @click="handleCancel">取消</a-button>
<a-button class="editor-button" type="primary" @click="handleSubmit">确定</a-button>
</template>
</a-modal>
</div> </div>
<a-modal
width="900px"
height="500px"
:visible="visible && keyValue==='1'"
@cancel="handleCancel"
>
<template #title>新建属性</template>
<a-form
ref="propertyCreateRef"
:model="propertyAddData"
:style="{ width: '800px', height: '420px' }"
>
<!-- 设备名称 -->
<a-form-item
field="name"
label="属性名称"
:rules="[{ required: true, message: '设备名称不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="propertyAddData.name"
placeholder='请输入设备名称'
/>
</a-form-item>
<!-- 标识 -->
<a-form-item
field="identifier"
label="标识"
:rules="[{ required: true, message: '标识不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="propertyAddData.identifier"
placeholder='请输入标识'
/>
</a-form-item>
<!-- 数据类型 -->
<a-form-item
field="dataType"
label="数据类型"
:rules="[{ required: true, message: '数据类型不能为空' }]"
:validate-trigger="['change']"
>
<a-select v-model="propertyAddData.dataType" :options="dataTypeOptions" allow-search placeholder="请选择数据类型"/>
</a-form-item>
<!-- 读写类型 -->
<a-form-item
field="ioType"
label="读写类型"
>
<a-radio-group v-model="propertyAddData.ioType">
<a-radio value="1">读写</a-radio>
<a-radio value="2">只读</a-radio>
</a-radio-group>
</a-form-item>
<!-- 备注 -->
<a-form-item
field="remark"
label="备注"
>
<a-textarea
v-model="propertyAddData.remark"
placeholder='请输入备注'
/>
</a-form-item>
</a-form>
<template #footer>
<a-button class="editor-button" @click="handleCancel">取消</a-button>
<a-button class="editor-button" type="primary" @click="handleSubmit">确定</a-button>
</template>
</a-modal>
<a-modal
width="900px"
height="500px"
:visible="visible && keyValue==='2'"
@cancel="handleCancel"
>
<template #title>新建服务</template>
<a-form
ref="serveCreateRef"
:model="serveAddData"
:style="{ width: '800px', height: '420px' }"
>
<!-- 服务名称 -->
<a-form-item
field="name"
label="服务名称"
:rules="[{ required: true, message: '服务名称不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="serveAddData.name"
placeholder='请输入服务名称'
/>
</a-form-item>
<!-- 标识 -->
<a-form-item
field="identifier"
label="标识"
:rules="[{ required: true, message: '标识不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="serveAddData.identifier"
placeholder='请输入标识'
/>
</a-form-item>
<!-- 输入参数 -->
<a-form-item
field="inputs"
label="输入参数"
>
<div style="width: 100%">
<div style="width: 100%;margin-bottom: 5px; ">
<a-space v-for="(param,index) in serveInputData" :key="index" style="margin-bottom: 5px">
<a-input v-model="param.name" placeholder="名称" allow-clear />
<a-input v-model="param.identifier" placeholder="标识" allow-clear />
<a-select v-model="param.dataType" :options="dataTypeOptions" allow-search placeholder="数据类型" style="width: 140px"/>
<a-select v-model="param.type" :options="typeOptions" allow-search placeholder="类型" style="width: 140px"/>
<a-button type="text" @click="handleDeleteParams(index,'serveInputData')"><icon-minus-circle /></a-button>
</a-space>
</div>
<a-button @click="handleAddParams('serveInputData')" style="width: 100%" type="outline">
<icon-plus />
</a-button>
</div>
</a-form-item>
<!-- 输出参数 -->
<a-form-item
field="outputs"
label="输出参数"
>
<div style="width: 100%">
<div style="width: 100%;margin-bottom: 5px; ">
<a-space v-for="(param,index) in serveOutputData" :key="index" style="margin-bottom: 5px">
<a-input v-model="param.name" placeholder="名称" allow-clear />
<a-input v-model="param.identifier" placeholder="标识" allow-clear />
<a-select v-model="param.dataType" :options="dataTypeOptions" allow-search placeholder="数据类型" style="width: 140px"/>
<a-select v-model="param.type" :options="typeOptions" allow-search placeholder="类型" style="width: 140px"/>
<a-button type="text" @click="handleDeleteParams(index,'serveOutputData')"><icon-minus-circle /></a-button>
</a-space>
</div>
<a-button @click="handleAddParams('serveOutputData')" style="width: 100%" type="outline">
<icon-plus />
</a-button>
</div>
</a-form-item>
<!-- 备注 -->
<a-form-item
field="remark"
label="备注"
>
<a-textarea
v-model="serveInputData.remark"
placeholder='请输入备注'
/>
</a-form-item>
</a-form>
<template #footer>
<a-button class="editor-button" @click="handleCancel">取消</a-button>
<a-button class="editor-button" type="primary" @click="handleSubmit">确定</a-button>
</template>
</a-modal>
<a-modal
width="900px"
height="500px"
:visible="visible && keyValue==='3'"
@cancel="handleCancel"
>
<template #title>新建事件</template>
<a-form
ref="eventCreateRef"
:model="eventAddData"
:style="{ width: '800px', height: '420px' }"
>
<!-- 事件名称 -->
<a-form-item
field="name"
label="服务名称"
:rules="[{ required: true, message: '服务名称不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="eventAddData.name"
placeholder='请输入服务名称'
/>
</a-form-item>
<!-- 标识 -->
<a-form-item
field="identifier"
label="标识"
:rules="[{ required: true, message: '标识不能为空' }]"
:validate-trigger="['change']"
>
<a-input
v-model="eventAddData.identifier"
placeholder='请输入标识'
/>
</a-form-item>
<!-- 类型 -->
<a-form-item
field="type"
label="类型"
:rules="[{ required: true, message: '类型不能为空' }]"
:validate-trigger="['change']"
>
<a-select v-model="eventAddData.type" :options="eventTypeOptions" allow-search placeholder="请选择类型"/>
</a-form-item>
<!-- 输出参数 -->
<a-form-item
field="outputs"
label="输出参数"
>
<div style="width: 100%">
<div style="width: 100%;margin-bottom: 5px; ">
<a-space v-for="(param,index) in eventOutputData" :key="index" style="margin-bottom: 5px">
<a-input v-model="param.name" placeholder="名称" allow-clear />
<a-input v-model="param.identifier" placeholder="标识" allow-clear />
<a-select v-model="param.dataType" :options="dataTypeOptions" allow-search placeholder="数据类型" style="width: 140px"/>
<a-select v-model="param.type" :options="typeOptions" allow-search placeholder="类型" style="width: 140px"/>
<a-button type="text" @click="handleDeleteParams(index,'eventOutputData')"><icon-minus-circle /></a-button>
</a-space>
</div>
<a-button @click="handleAddParams('eventOutputData')" style="width: 100%" type="outline">
<icon-plus />
</a-button>
</div>
</a-form-item>
<!-- 备注 -->
<a-form-item
field="remark"
label="备注"
>
<a-textarea
v-model="eventAddData.remark"
placeholder='请输入备注'
/>
</a-form-item>
</a-form>
<template #footer>
<a-button class="editor-button" @click="handleCancel">取消</a-button>
<a-button class="editor-button" type="primary" @click="handleSubmit">确定</a-button>
</template>
</a-modal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -371,7 +368,6 @@
const propertyData = ref([]); const propertyData = ref([]);
const eventData = ref([]); const eventData = ref([]);
const keyValue = ref('1'); const keyValue = ref('1');
const paramsData = ref([]);
const dataTypeOptions = computed<SelectOptionData[]>(() => [ const dataTypeOptions = computed<SelectOptionData[]>(() => [
{ {
label: '整型', label: '整型',

View File

@ -26,8 +26,15 @@
field="pid" field="pid"
label="父级菜单名称" label="父级菜单名称"
> >
<a-input <a-tree-select
v-model="formData.pid" v-model="formData.pid"
:data="props.menuData"
:field-names="{
key: 'id',
title: 'name',
children: 'children',
}"
:allow-clear="true"
placeholder='请输入父级菜单名称' placeholder='请输入父级菜单名称'
/> />
</a-form-item> </a-form-item>
@ -144,6 +151,9 @@
menu: { menu: {
type: Object as PropType<MenuRecord>, type: Object as PropType<MenuRecord>,
}, },
menuData: {
type: Object as PropType<MenuRecord>,
},
isCreate: Boolean, isCreate: Boolean,
}); });
const modalTitle = computed(() => { const modalTitle = computed(() => {
@ -185,6 +195,8 @@
// //
const handleClick = () => { const handleClick = () => {
setVisible(true); setVisible(true);
console.log(props.menuData);
console.log(props.menu);
}; };
// //

View File

@ -13,7 +13,7 @@
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :span="12"> <a-col :span="12">
<a-form-item <a-form-item
field="title" field="name"
label="菜单名称" label="菜单名称"
> >
<a-input <a-input
@ -47,7 +47,7 @@
<a-row style="margin-bottom: 16px"> <a-row style="margin-bottom: 16px">
<a-col :span="12"> <a-col :span="12">
<a-space> <a-space>
<MenuEdit ref="createRef" :is-create="true" @refresh="search" /> <MenuEdit ref="createRef" :is-create="true" :menuData="renderData" @refresh="search" />
</a-space> </a-space>
</a-col> </a-col>
<a-col <a-col
@ -132,6 +132,7 @@
<MenuEdit <MenuEdit
ref="editRef" ref="editRef"
:menu="record" :menu="record"
:menuData="renderData"
:is-create="false" :is-create="false"
@refresh="search" @refresh="search"
/> />
@ -181,7 +182,6 @@
const generateFormModel = () => { const generateFormModel = () => {
return { return {
name: '', name: '',
type: '',
}; };
}; };
@ -221,7 +221,7 @@
const fetchData = async () => { const fetchData = async () => {
setLoading(true); setLoading(true);
try { try {
const res = await queryMenuList(); const res = await queryMenuList(formModel.value.name || 'all');
renderData.value = res.data; renderData.value = res.data;
} catch (err) { } catch (err) {
// you can report use errorHandler or other // you can report use errorHandler or other

View File

@ -193,7 +193,7 @@
}, },
]); ]);
// //
const fetchData = async ( const fetchData = async (
params: BulletinsRecord = { size: 10, current: 1 } params: BulletinsRecord = { size: 10, current: 1 }
) => { ) => {