mirror of https://gitee.com/xiaonuobase/snowy
【更新】更新移动端菜单管理(待完善)
parent
647e7de72b
commit
61b969b2f1
|
@ -0,0 +1,40 @@
|
||||||
|
import { baseRequest } from '@/utils/request'
|
||||||
|
|
||||||
|
const request = (url, ...arg) => baseRequest(`/mobile/menu/` + url, ...arg)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动端菜单Api接口管理器
|
||||||
|
*
|
||||||
|
* @author yubaoshan
|
||||||
|
* @date 2023/01/28 22:42
|
||||||
|
**/
|
||||||
|
export default {
|
||||||
|
// 获取移动端菜单tree
|
||||||
|
mobileMenuTree(data) {
|
||||||
|
return request('tree', data, 'get')
|
||||||
|
},
|
||||||
|
// 获取移动端菜单列表
|
||||||
|
mobileMenuList(data) {
|
||||||
|
return request('list', data, 'get')
|
||||||
|
},
|
||||||
|
// 提交移动端菜单表单 edit为true时为编辑,默认为新增
|
||||||
|
mobileMenuSubmitForm(data, edit = false) {
|
||||||
|
return request(edit ? 'add' : 'edit', data)
|
||||||
|
},
|
||||||
|
// 删除移动端菜单
|
||||||
|
mobileMenuDelete(data) {
|
||||||
|
return request('delete', data)
|
||||||
|
},
|
||||||
|
// 获取移动端菜单详情
|
||||||
|
mobileMenuDetail(data) {
|
||||||
|
return request('detail', data, 'get')
|
||||||
|
},
|
||||||
|
// 获取类别选择器
|
||||||
|
mobileMenuModuleSelector(data) {
|
||||||
|
return request('moduleSelector', data, 'get')
|
||||||
|
},
|
||||||
|
// 获取菜单树选择器
|
||||||
|
mobileMenuTreeSelector(data) {
|
||||||
|
return request('menuTreeSelector', data, 'get')
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**
|
||||||
|
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||||
|
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||||
|
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||||
|
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||||
|
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||||
|
*/
|
||||||
|
import { baseRequest } from '@/utils/request'
|
||||||
|
|
||||||
|
const request = (url, ...arg) => baseRequest(`/mobile/module/${url}`, ...arg)
|
||||||
|
/**
|
||||||
|
* 类别
|
||||||
|
*
|
||||||
|
* @author yubaoshan
|
||||||
|
* @date 2022-09-22 22:33:20
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
// 获取类别分页
|
||||||
|
modulePage(data) {
|
||||||
|
return request('page', data, 'get')
|
||||||
|
},
|
||||||
|
// 提交表单 edit为true时为编辑,默认为新增
|
||||||
|
submitForm(data, edit = false) {
|
||||||
|
return request(edit ? 'add' : 'edit', data)
|
||||||
|
},
|
||||||
|
// 删除类别
|
||||||
|
moduleDelete(data) {
|
||||||
|
return request('delete', data)
|
||||||
|
},
|
||||||
|
// 获取类别详情
|
||||||
|
moduleDetail(data) {
|
||||||
|
return request('detail', data, 'get')
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,8 +10,25 @@
|
||||||
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
|
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="父ID:" name="parentId">
|
<a-form-item label="上级菜单:" name="parentId">
|
||||||
<a-input v-model:value="formData.parentId" placeholder="请输入父ID" allow-clear />
|
<a-tree-select
|
||||||
|
v-model:value="formData.parentId"
|
||||||
|
v-model:treeExpandedKeys="defaultExpandedKeys"
|
||||||
|
style="width: 100%"
|
||||||
|
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
||||||
|
placeholder="请选择上级菜单"
|
||||||
|
allow-clear
|
||||||
|
tree-default-expand-all
|
||||||
|
:tree-data="treeData"
|
||||||
|
:field-names="{
|
||||||
|
children: 'children',
|
||||||
|
label: 'title',
|
||||||
|
value: 'id'
|
||||||
|
}"
|
||||||
|
selectable="false"
|
||||||
|
tree-line
|
||||||
|
@change="parentChange(formData.parentId)"
|
||||||
|
></a-tree-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
|
@ -24,24 +41,20 @@
|
||||||
<a-input v-model:value="formData.pages" placeholder="请输入界面路径" allow-clear />
|
<a-input v-model:value="formData.pages" placeholder="请输入界面路径" allow-clear />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
|
||||||
<a-form-item label="分类:" name="category">
|
|
||||||
<a-select v-model:value="formData.category" placeholder="请选择分类" :options="categoryOptions" />
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="图标:" name="icon">
|
<a-form-item label="图标:" name="icon">
|
||||||
<a-input v-model:value="formData.icon" placeholder="请输入图标" allow-clear />
|
<a-input v-model:value="formData.icon" style="width: calc(100% - 70px)" placeholder="请选择图标" allow-clear />
|
||||||
|
<a-button type="primary" @click="iconSelector.showIconModal(formData.icon)">选择</a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="颜色:" name="color">
|
<a-form-item label="颜色:" name="color">
|
||||||
<a-input v-model:value="formData.color" placeholder="请输入颜色" allow-clear />
|
<color-picker v-model:value="formData.color" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="是否正规则:" name="isRegExp">
|
<a-form-item label="是否正规则:" name="regType">
|
||||||
<a-radio-group v-model:value="formData.isRegExp" placeholder="请选择正规则" :options="isRegExpOptions" />
|
<a-radio-group v-model:value="formData.regType" placeholder="请选择正规则" :options="regTypeOptions" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
|
@ -58,6 +71,7 @@
|
||||||
<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
|
<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
|
||||||
<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
|
<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
|
||||||
</template>
|
</template>
|
||||||
|
<Icon-selector ref="iconSelector" @iconCallBack="iconCallBack" />
|
||||||
</a-drawer>
|
</a-drawer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -65,27 +79,53 @@
|
||||||
import tool from '@/utils/tool'
|
import tool from '@/utils/tool'
|
||||||
import { cloneDeep } from 'lodash-es'
|
import { cloneDeep } from 'lodash-es'
|
||||||
import { required } from '@/utils/formRules'
|
import { required } from '@/utils/formRules'
|
||||||
import mobileMenuApi from '@/api/mobile/mobileMenuApi'
|
import mobileMenuApi from '@/api/mobile/resource/menuApi'
|
||||||
|
import ColorPicker from '@/components/ColorPicker/index.vue'
|
||||||
|
import IconSelector from '@/components/Selector/iconSelector.vue'
|
||||||
// 抽屉状态
|
// 抽屉状态
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
const emit = defineEmits({ successful: null })
|
const emit = defineEmits({ successful: null })
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
// 表单数据
|
let iconSelector = ref()
|
||||||
|
// 默认展开的节点(顶级)
|
||||||
|
const defaultExpandedKeys = ref([0])
|
||||||
|
const treeData = ref([])
|
||||||
const formData = ref({})
|
const formData = ref({})
|
||||||
|
// 类别
|
||||||
|
const moduleId = ref('')
|
||||||
const submitLoading = ref(false)
|
const submitLoading = ref(false)
|
||||||
const categoryOptions = ref([])
|
const regTypeOptions = ref([])
|
||||||
const isRegExpOptions = ref([])
|
|
||||||
const statusOptions = ref([])
|
const statusOptions = ref([])
|
||||||
|
|
||||||
// 打开抽屉
|
// 打开抽屉
|
||||||
const onOpen = (record) => {
|
const onOpen = (record, module) => {
|
||||||
|
moduleId.value = module
|
||||||
visible.value = true
|
visible.value = true
|
||||||
|
// 设置默认的
|
||||||
|
formData.value = {
|
||||||
|
regType: 'YES',
|
||||||
|
status: 'ENABLE',
|
||||||
|
category: 'MENU'
|
||||||
|
}
|
||||||
if (record) {
|
if (record) {
|
||||||
let recordData = cloneDeep(record)
|
let recordData = cloneDeep(record)
|
||||||
formData.value = Object.assign({}, recordData)
|
formData.value = Object.assign({}, recordData)
|
||||||
}
|
}
|
||||||
categoryOptions.value = tool.dictList('MOBILE_CATEGORY')
|
// 获取菜单树并加入顶级
|
||||||
isRegExpOptions.value = tool.dictList('MOBILE_IS_REG_EXP')
|
const treeParam = {
|
||||||
|
module: module
|
||||||
|
}
|
||||||
|
mobileMenuApi.mobileMenuTreeSelector(treeParam).then((res) => {
|
||||||
|
treeData.value = [
|
||||||
|
{
|
||||||
|
id: 0,
|
||||||
|
parentId: '-1',
|
||||||
|
title: '顶级',
|
||||||
|
children: res
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
regTypeOptions.value = tool.dictList('MOBILE_REG_TYPE')
|
||||||
statusOptions.value = tool.dictList('MOBILE_STATUS')
|
statusOptions.value = tool.dictList('MOBILE_STATUS')
|
||||||
}
|
}
|
||||||
// 关闭抽屉
|
// 关闭抽屉
|
||||||
|
@ -94,16 +134,33 @@
|
||||||
formData.value = {}
|
formData.value = {}
|
||||||
visible.value = false
|
visible.value = false
|
||||||
}
|
}
|
||||||
|
// 选择上级加载模块的选择框
|
||||||
|
const parentChange = (value) => {
|
||||||
|
if (value > 0) {
|
||||||
|
// 执行接口去查询选择的上级是哪个类别,吧对应的也置为一样的
|
||||||
|
const param = {
|
||||||
|
id: value
|
||||||
|
}
|
||||||
|
mobileMenuApi.mobileMenuDetail(param).then((res) => {
|
||||||
|
formData.value.module = res.module
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
formData.value.module = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 图标选择器回调
|
||||||
|
const iconCallBack = (value) => {
|
||||||
|
formData.value.icon = value
|
||||||
|
}
|
||||||
// 默认要校验的
|
// 默认要校验的
|
||||||
const formRules = {
|
const formRules = {
|
||||||
parentId: [required('请输入父ID')],
|
parentId: [required('请选择上级')],
|
||||||
title: [required('请输入名称')],
|
title: [required('请输入名称')],
|
||||||
pages: [required('请输入界面路径')],
|
pages: [required('请输入界面路径')],
|
||||||
category: [required('请输入分类')],
|
icon: [required('请选择图标')],
|
||||||
icon: [required('请输入图标')],
|
color: [required('请选择颜色')],
|
||||||
color: [required('请输入颜色')],
|
regType: [required('请选择规则类型')],
|
||||||
isRegExp: [required('请输入正规则')],
|
status: [required('请选择可用状态')]
|
||||||
status: [required('请输入可用状态')],
|
|
||||||
}
|
}
|
||||||
// 验证并提交数据
|
// 验证并提交数据
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
|
@ -112,6 +169,7 @@
|
||||||
.then(() => {
|
.then(() => {
|
||||||
submitLoading.value = true
|
submitLoading.value = true
|
||||||
const formDataParam = cloneDeep(formData.value)
|
const formDataParam = cloneDeep(formData.value)
|
||||||
|
formDataParam.module = moduleId.value
|
||||||
mobileMenuApi
|
mobileMenuApi
|
||||||
.mobileMenuSubmitForm(formDataParam, !formDataParam.id)
|
.mobileMenuSubmitForm(formDataParam, !formDataParam.id)
|
||||||
.then(() => {
|
.then(() => {
|
|
@ -1,28 +1,26 @@
|
||||||
<template>
|
<template>
|
||||||
<a-card :bordered="false">
|
<a-card :bordered="false">
|
||||||
<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form mb-4">
|
<a-space class="mb-3">
|
||||||
<a-row :gutter="24">
|
<a-radio-group v-model:value="module" button-style="solid">
|
||||||
<a-col :span="6">
|
<a-radio-button
|
||||||
<a-form-item label="关键词" name="searchKey">
|
v-for="module in moduleList"
|
||||||
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入关键词" />
|
:key="module.id"
|
||||||
</a-form-item>
|
:value="module.id"
|
||||||
</a-col>
|
@click="moduleClock(module.id)"
|
||||||
<a-col :span="6">
|
>
|
||||||
<a-form-item label="分类" name="category">
|
<component :is="module.icon" />
|
||||||
<a-select v-model:value="searchFormState.category" placeholder="请选择分类" :options="categoryOptions" />
|
{{ module.title }}</a-radio-button
|
||||||
</a-form-item>
|
>
|
||||||
</a-col>
|
</a-radio-group>
|
||||||
<a-col :span="6">
|
|
||||||
<a-form-item label="可用状态" name="status">
|
<a-input-search
|
||||||
<a-select v-model:value="searchFormState.status" placeholder="请选择可用状态" :options="statusOptions" />
|
v-model:value="searchFormState.searchKey"
|
||||||
</a-form-item>
|
placeholder="请输入菜单名称关键词"
|
||||||
</a-col>
|
enter-button
|
||||||
<a-col :span="6">
|
allowClear
|
||||||
<a-button type="primary" @click="table.refresh(true)">查询</a-button>
|
@search="onSearch"
|
||||||
<a-button style="margin: 0 8px" @click="() => searchFormRef.resetFields()">重置</a-button>
|
/>
|
||||||
</a-col>
|
</a-space>
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
<s-table
|
<s-table
|
||||||
ref="table"
|
ref="table"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
|
@ -36,7 +34,7 @@
|
||||||
>
|
>
|
||||||
<template #operator class="table-operator">
|
<template #operator class="table-operator">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-button type="primary" @click="formRef.onOpen()">
|
<a-button type="primary" @click="formRef.onOpen(undefined, module)">
|
||||||
<template #icon><plus-outlined /></template>
|
<template #icon><plus-outlined /></template>
|
||||||
新增
|
新增
|
||||||
</a-button>
|
</a-button>
|
||||||
|
@ -44,18 +42,15 @@
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<template v-if="column.dataIndex === 'category'">
|
<template v-if="column.dataIndex === 'regType'">
|
||||||
{{ $TOOL.dictTypeData('MOBILE_CATEGORY', record.category) }}
|
{{ $TOOL.dictTypeData('MOBILE_REG_TYPE', record.regType) }}
|
||||||
</template>
|
|
||||||
<template v-if="column.dataIndex === 'isRegExp'">
|
|
||||||
{{ $TOOL.dictTypeData('MOBILE_IS_REG_EXP', record.isRegExp) }}
|
|
||||||
</template>
|
</template>
|
||||||
<template v-if="column.dataIndex === 'status'">
|
<template v-if="column.dataIndex === 'status'">
|
||||||
{{ $TOOL.dictTypeData('MOBILE_STATUS', record.status) }}
|
{{ $TOOL.dictTypeData('MOBILE_STATUS', record.status) }}
|
||||||
</template>
|
</template>
|
||||||
<template v-if="column.dataIndex === 'action'">
|
<template v-if="column.dataIndex === 'action'">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a @click="formRef.onOpen(record)">编辑</a>
|
<a @click="formRef.onOpen(record, module)">编辑</a>
|
||||||
<a-divider type="vertical" />
|
<a-divider type="vertical" />
|
||||||
<a-popconfirm title="确定要删除吗?" @confirm="deleteMobileMenu(record)">
|
<a-popconfirm title="确定要删除吗?" @confirm="deleteMobileMenu(record)">
|
||||||
<a-button type="link" danger size="small">删除</a-button>
|
<a-button type="link" danger size="small">删除</a-button>
|
||||||
|
@ -70,10 +65,11 @@
|
||||||
|
|
||||||
<script setup name="mobileMenuIndex">
|
<script setup name="mobileMenuIndex">
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import tool from '@/utils/tool'
|
|
||||||
import Form from './form.vue'
|
import Form from './form.vue'
|
||||||
import mobileMenuApi from '@/api/mobile/mobileMenuApi'
|
import mobileMenuApi from '@/api/mobile/resource/menuApi'
|
||||||
let searchFormState = reactive({})
|
let searchFormState = reactive({})
|
||||||
|
let moduleList = ref([])
|
||||||
|
const module = ref()
|
||||||
const searchFormRef = ref()
|
const searchFormRef = ref()
|
||||||
const table = ref()
|
const table = ref()
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
|
@ -88,26 +84,18 @@
|
||||||
dataIndex: 'pages',
|
dataIndex: 'pages',
|
||||||
ellipsis: true
|
ellipsis: true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: '分类',
|
|
||||||
dataIndex: 'category'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '图标',
|
title: '图标',
|
||||||
dataIndex: 'icon'
|
dataIndex: 'icon'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '正规则',
|
title: '正规则',
|
||||||
dataIndex: 'isRegExp'
|
dataIndex: 'regType'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '可用状态',
|
title: '可用状态',
|
||||||
dataIndex: 'status'
|
dataIndex: 'status'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: '排序码',
|
|
||||||
dataIndex: 'sortCode'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
dataIndex: 'createTime',
|
dataIndex: 'createTime',
|
||||||
|
@ -136,13 +124,45 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const loadData = (parameter) => {
|
const loadData = (parameter) => {
|
||||||
const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
|
if (!module.value) {
|
||||||
return mobileMenuApi.mobileMenuTree(Object.assign(parameter, searchFormParam)).then((data) => {
|
return mobileMenuApi.mobileMenuModuleSelector().then((data) => {
|
||||||
|
moduleList.value = data
|
||||||
|
module.value = data.length > 0 ? data[0].id : ''
|
||||||
|
searchFormState.module = module.value
|
||||||
|
return mobileMenuApi.mobileMenuTree(Object.assign(parameter, searchFormState)).then((data) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return mobileMenuApi.mobileMenuTree(Object.assign(parameter, searchFormState)).then((data) => {
|
||||||
|
if (data) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/*const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
|
||||||
|
return mobileMenuApi.mobileMenuTree(Object.assign(parameter, searchFormParam)).then((data) => {
|
||||||
|
if (data) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
})*/
|
||||||
|
}
|
||||||
|
// 切换模块标签查询菜单列表
|
||||||
|
const moduleClock = (value) => {
|
||||||
|
searchFormState.module = value
|
||||||
|
table.value.refresh(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询
|
||||||
|
const onSearch = () => {
|
||||||
|
if (searchFormState.searchKey) {
|
||||||
|
table.value.refresh(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 删除
|
// 删除
|
||||||
const deleteMobileMenu = (record) => {
|
const deleteMobileMenu = (record) => {
|
||||||
|
@ -170,6 +190,4 @@
|
||||||
table.value.clearRefreshSelected()
|
table.value.clearRefreshSelected()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const categoryOptions = tool.dictList('MOBILE_CATEGORY')
|
|
||||||
const statusOptions = tool.dictList('MOBILE_STATUS')
|
|
||||||
</script>
|
</script>
|
|
@ -0,0 +1,91 @@
|
||||||
|
<template>
|
||||||
|
<a-drawer
|
||||||
|
:title="formData.id ? '编辑菜单模块' : '增加菜单模块'"
|
||||||
|
:width="600"
|
||||||
|
:visible="visible"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
:body-style="{ paddingBottom: '80px' }"
|
||||||
|
:footer-style="{ textAlign: 'right' }"
|
||||||
|
@close="onClose"
|
||||||
|
>
|
||||||
|
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
|
||||||
|
<a-form-item label="模块名称:" name="title">
|
||||||
|
<a-input v-model:value="formData.title" placeholder="请输入模块名称" allow-clear />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="图标:" name="icon">
|
||||||
|
<a-input v-model:value="formData.icon" style="width: calc(100% - 70px)" placeholder="请选择图标" allow-clear />
|
||||||
|
<a-button type="primary" @click="iconSelector.showIconModal(formData.icon)">选择</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="颜色:" name="color">
|
||||||
|
<color-picker v-model:value="formData.color" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="排序:" name="sortCode">
|
||||||
|
<a-slider v-model:value="formData.sortCode" :max="100" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
<template #footer>
|
||||||
|
<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
|
||||||
|
<a-button type="primary" @click="onSubmit">保存</a-button>
|
||||||
|
</template>
|
||||||
|
<Icon-selector ref="iconSelector" @iconCallBack="iconCallBack" />
|
||||||
|
</a-drawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import ColorPicker from '@/components/ColorPicker/index.vue'
|
||||||
|
import { required } from '@/utils/formRules'
|
||||||
|
import moduleApi from '@/api/mobile/resource/moduleApi'
|
||||||
|
import IconSelector from '@/components/Selector/iconSelector.vue'
|
||||||
|
// 默认是关闭状态
|
||||||
|
let visible = $ref(false)
|
||||||
|
const emit = defineEmits({ successful: null })
|
||||||
|
const formRef = ref()
|
||||||
|
const treeData = ref([])
|
||||||
|
let iconSelector = ref()
|
||||||
|
// 表单数据
|
||||||
|
const formData = ref({})
|
||||||
|
|
||||||
|
// 打开抽屉
|
||||||
|
const onOpen = (record) => {
|
||||||
|
visible = true
|
||||||
|
formData.value = {
|
||||||
|
sortCode: 99
|
||||||
|
}
|
||||||
|
if (record) {
|
||||||
|
formData.value = Object.assign({}, record)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 关闭抽屉
|
||||||
|
const onClose = () => {
|
||||||
|
formRef.value.resetFields()
|
||||||
|
visible = false
|
||||||
|
}
|
||||||
|
// 图标选择器回调
|
||||||
|
const iconCallBack = (value) => {
|
||||||
|
formData.value.icon = value
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认要校验的
|
||||||
|
const formRules = {
|
||||||
|
title: [required('请输入模块名称')],
|
||||||
|
icon: [required('请选择图标')],
|
||||||
|
color: [required('请选择颜色')]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证并提交数据
|
||||||
|
const onSubmit = () => {
|
||||||
|
formRef.value
|
||||||
|
.validate()
|
||||||
|
.then(() => {
|
||||||
|
moduleApi.submitForm(formData.value, !formData.value.id).then(() => {
|
||||||
|
onClose()
|
||||||
|
emit('successful')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调用这个函数将子组件的一些数据和方法暴露出去
|
||||||
|
defineExpose({
|
||||||
|
onOpen
|
||||||
|
})
|
||||||
|
</script>
|
|
@ -0,0 +1,139 @@
|
||||||
|
<template>
|
||||||
|
<a-card :bordered="false" :body-style="{ 'padding-bottom': '0px' }" class="mb-2">
|
||||||
|
<a-form ref="formRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
|
||||||
|
<a-row :gutter="24">
|
||||||
|
<a-col :span="8">
|
||||||
|
<a-form-item label="名称关键词" name="searchKey">
|
||||||
|
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入模块名称关键词"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="8">
|
||||||
|
<a-button type="primary" @click="table.refresh(true)">查询</a-button>
|
||||||
|
<a-button style="margin: 0 8px" @click="() => formRef.resetFields()">重置</a-button>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
</a-card>
|
||||||
|
<a-card :bordered="false">
|
||||||
|
<s-table
|
||||||
|
ref="table"
|
||||||
|
:columns="columns"
|
||||||
|
:data="loadData"
|
||||||
|
:alert="options.alert.show"
|
||||||
|
bordered
|
||||||
|
:row-key="(record) => record.id"
|
||||||
|
:tool-config="toolConfig"
|
||||||
|
:row-selection="options.rowSelection"
|
||||||
|
>
|
||||||
|
<template #operator class="table-operator">
|
||||||
|
<a-space>
|
||||||
|
<a-button type="primary" @click="form.onOpen()">
|
||||||
|
<template #icon><plus-outlined /></template>
|
||||||
|
新增模块
|
||||||
|
</a-button>
|
||||||
|
<a-button danger @click="deleteBatchModule()">删除</a-button>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.dataIndex === 'icon'">
|
||||||
|
<a-tag :color="record.color">
|
||||||
|
<component :is="record.icon" />
|
||||||
|
</a-tag>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'action'">
|
||||||
|
<a-space>
|
||||||
|
<a @click="form.onOpen(record)">编辑</a>
|
||||||
|
<a-divider type="vertical" />
|
||||||
|
<a-popconfirm title="确定要删除此模块吗?" @confirm="deleteModule(record)">
|
||||||
|
<a-button type="link" danger size="small">删除</a-button>
|
||||||
|
</a-popconfirm>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</s-table>
|
||||||
|
</a-card>
|
||||||
|
<Form ref="form" @successful="table.refresh(true)" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="mobileModule">
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import Form from './form.vue'
|
||||||
|
import moduleApi from '@/api/mobile/resource/moduleApi'
|
||||||
|
let searchFormState = reactive({})
|
||||||
|
const formRef = ref()
|
||||||
|
const table = ref()
|
||||||
|
let form = ref()
|
||||||
|
const toolConfig = { refresh: true, height: true, columnSetting: false, striped: false }
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: '显示名称',
|
||||||
|
dataIndex: 'title'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '图标',
|
||||||
|
dataIndex: 'icon'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '排序',
|
||||||
|
dataIndex: 'sortCode',
|
||||||
|
sorter: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
sorter: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
dataIndex: 'action',
|
||||||
|
align: 'center',
|
||||||
|
width: '200px'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
let selectedRowKeys = ref([])
|
||||||
|
// 列表选择配置
|
||||||
|
const options = {
|
||||||
|
alert: {
|
||||||
|
show: false,
|
||||||
|
clear: () => {
|
||||||
|
selectedRowKeys = ref([])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rowSelection: {
|
||||||
|
onChange: (selectedRowKey, selectedRows) => {
|
||||||
|
selectedRowKeys.value = selectedRowKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const loadData = (parameter) => {
|
||||||
|
return moduleApi.modulePage(Object.assign(parameter, searchFormState)).then((res) => {
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
const deleteModule = (record) => {
|
||||||
|
let params = [
|
||||||
|
{
|
||||||
|
id: record.id
|
||||||
|
}
|
||||||
|
]
|
||||||
|
moduleApi.moduleDelete(params).then(() => {
|
||||||
|
table.value.refresh(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 批量删除
|
||||||
|
const deleteBatchModule = () => {
|
||||||
|
if (selectedRowKeys.value.length < 1) {
|
||||||
|
message.warning('请选择一条或多条数据')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const params = selectedRowKeys.value.map((m) => {
|
||||||
|
return {
|
||||||
|
id: m
|
||||||
|
}
|
||||||
|
})
|
||||||
|
moduleApi.moduleDelete(params).then(() => {
|
||||||
|
table.value.clearRefreshSelected()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -85,13 +85,13 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
|
||||||
|
|
||||||
private static final String DB_PASSWORD_KEY = "spring.datasource.dynamic.datasource.master.password";
|
private static final String DB_PASSWORD_KEY = "spring.datasource.dynamic.datasource.master.password";
|
||||||
|
|
||||||
private static final String MODULE_KEY = "biz";
|
private static final String MODULE_KEY = "mobile";
|
||||||
|
|
||||||
private static final String GEN_PROJECT_FRONT_PLUGIN_KEY = "snowy-admin-web";
|
private static final String GEN_PROJECT_FRONT_PLUGIN_KEY = "snowy-admin-web";
|
||||||
|
|
||||||
private static final String GEN_PROJECT_PLUGIN_KEY = "snowy-plugin";
|
private static final String GEN_PROJECT_PLUGIN_KEY = "snowy-plugin";
|
||||||
|
|
||||||
private static final String GEN_PROJECT_PLUGIN_BIZ_KEY = GEN_PROJECT_PLUGIN_KEY + File.separator + "snowy-plugin-biz";
|
private static final String GEN_PROJECT_PLUGIN_BIZ_KEY = GEN_PROJECT_PLUGIN_KEY + File.separator + "snowy-plugin-mobile";
|
||||||
|
|
||||||
private static final List<JSONObject> GEN_SQL_FILE_LIST = CollectionUtil.newArrayList(
|
private static final List<JSONObject> GEN_SQL_FILE_LIST = CollectionUtil.newArrayList(
|
||||||
JSONUtil.createObj().set("name", "Mysql.sql.btl"),
|
JSONUtil.createObj().set("name", "Mysql.sql.btl"),
|
||||||
|
|
|
@ -26,10 +26,8 @@ import vip.xiaonuo.common.annotation.CommonLog;
|
||||||
import vip.xiaonuo.common.pojo.CommonResult;
|
import vip.xiaonuo.common.pojo.CommonResult;
|
||||||
import vip.xiaonuo.common.pojo.CommonValidList;
|
import vip.xiaonuo.common.pojo.CommonValidList;
|
||||||
import vip.xiaonuo.mobile.modular.resource.entity.MobileMenu;
|
import vip.xiaonuo.mobile.modular.resource.entity.MobileMenu;
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuAddParam;
|
import vip.xiaonuo.mobile.modular.resource.entity.MobileModule;
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuEditParam;
|
import vip.xiaonuo.mobile.modular.resource.param.menu.*;
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuIdParam;
|
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuTreeParam;
|
|
||||||
import vip.xiaonuo.mobile.modular.resource.service.MobileMenuService;
|
import vip.xiaonuo.mobile.modular.resource.service.MobileMenuService;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -123,4 +121,32 @@ public class MobileMenuController {
|
||||||
public CommonResult<MobileMenu> detail(@Valid MobileMenuIdParam mobileMenuIdParam) {
|
public CommonResult<MobileMenu> detail(@Valid MobileMenuIdParam mobileMenuIdParam) {
|
||||||
return CommonResult.data(mobileMenuService.detail(mobileMenuIdParam));
|
return CommonResult.data(mobileMenuService.detail(mobileMenuIdParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ====菜单部分所需要用到的选择器==== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模块选择器
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/4/24 20:00
|
||||||
|
*/
|
||||||
|
@ApiOperationSupport(order = 8)
|
||||||
|
@ApiOperation("获取模块选择器")
|
||||||
|
@GetMapping("/mobile/menu/moduleSelector")
|
||||||
|
public CommonResult<List<MobileModule>> moduleSelector(MobileMenuSelectorModuleParam mobileMenuSelectorModuleParam) {
|
||||||
|
return CommonResult.data(mobileMenuService.moduleSelector(mobileMenuSelectorModuleParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单树选择器
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/4/24 20:00
|
||||||
|
*/
|
||||||
|
@ApiOperationSupport(order = 9)
|
||||||
|
@ApiOperation("获取菜单树选择器")
|
||||||
|
@GetMapping("/mobile/menu/menuTreeSelector")
|
||||||
|
public CommonResult<List<Tree<String>>> menuTreeSelector(MobileMenuSelectorMenuParam mobileMenuSelectorMenuParam) {
|
||||||
|
return CommonResult.data(mobileMenuService.menuTreeSelector(mobileMenuSelectorMenuParam));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,47 +29,52 @@ import javax.validation.constraints.NotBlank;
|
||||||
public class MobileMenuAddParam {
|
public class MobileMenuAddParam {
|
||||||
|
|
||||||
/** 父ID */
|
/** 父ID */
|
||||||
@ApiModelProperty(value = "父ID", required = true, position = 2)
|
@ApiModelProperty(value = "父ID", required = true, position = 1)
|
||||||
@NotBlank(message = "parentId不能为空")
|
@NotBlank(message = "parentId不能为空")
|
||||||
private String parentId;
|
private String parentId;
|
||||||
|
|
||||||
/** 名称 */
|
/** 名称 */
|
||||||
@ApiModelProperty(value = "名称", required = true, position = 3)
|
@ApiModelProperty(value = "名称", required = true, position = 2)
|
||||||
@NotBlank(message = "title不能为空")
|
@NotBlank(message = "title不能为空")
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
/** 界面路径 */
|
/** 界面路径 */
|
||||||
@ApiModelProperty(value = "界面路径", required = true, position = 5)
|
@ApiModelProperty(value = "界面路径", required = true, position = 3)
|
||||||
@NotBlank(message = "pages不能为空")
|
@NotBlank(message = "pages不能为空")
|
||||||
private String pages;
|
private String pages;
|
||||||
|
|
||||||
/** 分类 */
|
/** 分类 */
|
||||||
@ApiModelProperty(value = "分类", required = true, position = 6)
|
@ApiModelProperty(value = "分类", required = true, position = 4)
|
||||||
@NotBlank(message = "category不能为空")
|
@NotBlank(message = "category不能为空")
|
||||||
private String category;
|
private String category;
|
||||||
|
|
||||||
|
/** 模块 */
|
||||||
|
@ApiModelProperty(value = "模块", required = true, position = 5)
|
||||||
|
@NotBlank(message = "module不能为空")
|
||||||
|
private String module;
|
||||||
|
|
||||||
/** 图标 */
|
/** 图标 */
|
||||||
@ApiModelProperty(value = "图标", required = true, position = 7)
|
@ApiModelProperty(value = "图标", required = true, position = 6)
|
||||||
@NotBlank(message = "icon不能为空")
|
@NotBlank(message = "icon不能为空")
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
/** 颜色 */
|
/** 颜色 */
|
||||||
@ApiModelProperty(value = "颜色", required = true, position = 8)
|
@ApiModelProperty(value = "颜色", required = true, position = 7)
|
||||||
@NotBlank(message = "color不能为空")
|
@NotBlank(message = "color不能为空")
|
||||||
private String color;
|
private String color;
|
||||||
|
|
||||||
/** 规则类型 */
|
/** 规则类型 */
|
||||||
@ApiModelProperty(value = "规则类型", required = true, position = 9)
|
@ApiModelProperty(value = "规则类型", required = true, position = 8)
|
||||||
@NotBlank(message = "regType不能为空")
|
@NotBlank(message = "regType不能为空")
|
||||||
private String regType;
|
private String regType;
|
||||||
|
|
||||||
/** 可用状态 */
|
/** 可用状态 */
|
||||||
@ApiModelProperty(value = "可用状态", required = true, position = 10)
|
@ApiModelProperty(value = "可用状态", required = true, position = 9)
|
||||||
@NotBlank(message = "status不能为空")
|
@NotBlank(message = "status不能为空")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 排序码 */
|
/** 排序码 */
|
||||||
@ApiModelProperty(value = "排序码", position = 11)
|
@ApiModelProperty(value = "排序码", position = 10)
|
||||||
private Integer sortCode;
|
private Integer sortCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,28 +53,33 @@ public class MobileMenuEditParam {
|
||||||
@NotBlank(message = "category不能为空")
|
@NotBlank(message = "category不能为空")
|
||||||
private String category;
|
private String category;
|
||||||
|
|
||||||
|
/** 模块 */
|
||||||
|
@ApiModelProperty(value = "模块", required = true, position = 7)
|
||||||
|
@NotBlank(message = "module不能为空")
|
||||||
|
private String module;
|
||||||
|
|
||||||
/** 图标 */
|
/** 图标 */
|
||||||
@ApiModelProperty(value = "图标", required = true, position = 7)
|
@ApiModelProperty(value = "图标", required = true, position = 8)
|
||||||
@NotBlank(message = "icon不能为空")
|
@NotBlank(message = "icon不能为空")
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
/** 颜色 */
|
/** 颜色 */
|
||||||
@ApiModelProperty(value = "颜色", required = true, position = 8)
|
@ApiModelProperty(value = "颜色", required = true, position = 9)
|
||||||
@NotBlank(message = "color不能为空")
|
@NotBlank(message = "color不能为空")
|
||||||
private String color;
|
private String color;
|
||||||
|
|
||||||
/** 规则类型 */
|
/** 规则类型 */
|
||||||
@ApiModelProperty(value = "规则类型", required = true, position = 9)
|
@ApiModelProperty(value = "规则类型", required = true, position = 10)
|
||||||
@NotBlank(message = "regType不能为空")
|
@NotBlank(message = "regType不能为空")
|
||||||
private String regType;
|
private String regType;
|
||||||
|
|
||||||
/** 可用状态 */
|
/** 可用状态 */
|
||||||
@ApiModelProperty(value = "可用状态", required = true, position = 10)
|
@ApiModelProperty(value = "可用状态", required = true, position = 11)
|
||||||
@NotBlank(message = "status不能为空")
|
@NotBlank(message = "status不能为空")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 排序码 */
|
/** 排序码 */
|
||||||
@ApiModelProperty(value = "排序码", position = 11)
|
@ApiModelProperty(value = "排序码", position = 12)
|
||||||
private Integer sortCode;
|
private Integer sortCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||||
|
*
|
||||||
|
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||||
|
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||||
|
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||||
|
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||||
|
*/
|
||||||
|
package vip.xiaonuo.mobile.modular.resource.param.menu;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动端菜单选择器参数
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/7/27 18:40
|
||||||
|
**/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class MobileMenuSelectorMenuParam {
|
||||||
|
|
||||||
|
/** 模块 */
|
||||||
|
@ApiModelProperty(value = "模块")
|
||||||
|
private String module;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||||
|
*
|
||||||
|
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||||
|
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||||
|
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||||
|
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||||
|
*/
|
||||||
|
package vip.xiaonuo.mobile.modular.resource.param.menu;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动端菜单类别选择器参数
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2022/7/27 18:40
|
||||||
|
**/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class MobileMenuSelectorModuleParam {
|
||||||
|
|
||||||
|
/** 名称关键词 */
|
||||||
|
@ApiModelProperty(value = "名称关键词")
|
||||||
|
private String searchKey;
|
||||||
|
}
|
|
@ -30,12 +30,8 @@ public class MobileMenuTreeParam {
|
||||||
@ApiModelProperty(value = "关键词")
|
@ApiModelProperty(value = "关键词")
|
||||||
private String searchKey;
|
private String searchKey;
|
||||||
|
|
||||||
/** 分类 */
|
/** 模块 */
|
||||||
@ApiModelProperty(value = "分类")
|
@ApiModelProperty(value = "模块")
|
||||||
private String category;
|
private String module;
|
||||||
|
|
||||||
/** 可用状态 */
|
|
||||||
@ApiModelProperty(value = "可用状态")
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,8 @@ package vip.xiaonuo.mobile.modular.resource.service;
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import vip.xiaonuo.mobile.modular.resource.entity.MobileMenu;
|
import vip.xiaonuo.mobile.modular.resource.entity.MobileMenu;
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuAddParam;
|
import vip.xiaonuo.mobile.modular.resource.entity.MobileModule;
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuEditParam;
|
import vip.xiaonuo.mobile.modular.resource.param.menu.*;
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuIdParam;
|
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuTreeParam;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -77,4 +75,20 @@ public interface MobileMenuService extends IService<MobileMenu> {
|
||||||
* @date 2023/01/28 22:42
|
* @date 2023/01/28 22:42
|
||||||
**/
|
**/
|
||||||
MobileMenu queryEntity(String id);
|
MobileMenu queryEntity(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模块选择器
|
||||||
|
*
|
||||||
|
* @author yubaoshan
|
||||||
|
* @date 2023/01/28 22:42
|
||||||
|
**/
|
||||||
|
List<MobileModule> moduleSelector(MobileMenuSelectorModuleParam mobileMenuSelectorModuleParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单树选择器
|
||||||
|
*
|
||||||
|
* @author yubaoshan
|
||||||
|
* @date 2023/01/28 22:42
|
||||||
|
**/
|
||||||
|
List<Tree<String>> menuTreeSelector(MobileMenuSelectorMenuParam mobileMenuSelectorMenuParam);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,14 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import vip.xiaonuo.common.exception.CommonException;
|
import vip.xiaonuo.common.exception.CommonException;
|
||||||
import vip.xiaonuo.mobile.modular.resource.entity.MobileMenu;
|
import vip.xiaonuo.mobile.modular.resource.entity.MobileMenu;
|
||||||
|
import vip.xiaonuo.mobile.modular.resource.entity.MobileModule;
|
||||||
|
import vip.xiaonuo.mobile.modular.resource.enums.MobileResourceCategoryEnum;
|
||||||
import vip.xiaonuo.mobile.modular.resource.mapper.MobileMenuMapper;
|
import vip.xiaonuo.mobile.modular.resource.mapper.MobileMenuMapper;
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuAddParam;
|
import vip.xiaonuo.mobile.modular.resource.param.menu.*;
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuEditParam;
|
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuIdParam;
|
|
||||||
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuTreeParam;
|
|
||||||
import vip.xiaonuo.mobile.modular.resource.service.MobileMenuService;
|
import vip.xiaonuo.mobile.modular.resource.service.MobileMenuService;
|
||||||
|
import vip.xiaonuo.mobile.modular.resource.service.MobileModuleService;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -44,18 +45,19 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
public class MobileMenuServiceImpl extends ServiceImpl<MobileMenuMapper, MobileMenu> implements MobileMenuService {
|
public class MobileMenuServiceImpl extends ServiceImpl<MobileMenuMapper, MobileMenu> implements MobileMenuService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MobileModuleService mobileModuleService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Tree<String>> tree(MobileMenuTreeParam mobileMenuTreeParam) {
|
public List<Tree<String>> tree(MobileMenuTreeParam mobileMenuTreeParam) {
|
||||||
LambdaQueryWrapper<MobileMenu> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<MobileMenu> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
if(ObjectUtil.isNotEmpty(mobileMenuTreeParam.getCategory())) {
|
if(ObjectUtil.isNotEmpty(mobileMenuTreeParam.getModule())) {
|
||||||
lambdaQueryWrapper.eq(MobileMenu::getCategory, mobileMenuTreeParam.getCategory());
|
lambdaQueryWrapper.eq(MobileMenu::getModule, mobileMenuTreeParam.getModule());
|
||||||
}
|
}
|
||||||
if(ObjectUtil.isNotEmpty(mobileMenuTreeParam.getSearchKey())) {
|
if(ObjectUtil.isNotEmpty(mobileMenuTreeParam.getSearchKey())) {
|
||||||
lambdaQueryWrapper.like(MobileMenu::getTitle, mobileMenuTreeParam.getSearchKey());
|
lambdaQueryWrapper.like(MobileMenu::getTitle, mobileMenuTreeParam.getSearchKey());
|
||||||
}
|
}
|
||||||
if(ObjectUtil.isNotEmpty(mobileMenuTreeParam.getStatus())) {
|
lambdaQueryWrapper.eq(MobileMenu::getCategory, MobileResourceCategoryEnum.MENU.getValue());
|
||||||
lambdaQueryWrapper.like(MobileMenu::getStatus, mobileMenuTreeParam.getStatus());
|
|
||||||
}
|
|
||||||
lambdaQueryWrapper.orderByDesc(MobileMenu::getSortCode);
|
lambdaQueryWrapper.orderByDesc(MobileMenu::getSortCode);
|
||||||
List<MobileMenu> mobileMenuList = this.list(lambdaQueryWrapper);
|
List<MobileMenu> mobileMenuList = this.list(lambdaQueryWrapper);
|
||||||
List<TreeNode<String>> treeNodeList = mobileMenuList.stream().map(mobileMenu ->
|
List<TreeNode<String>> treeNodeList = mobileMenuList.stream().map(mobileMenu ->
|
||||||
|
@ -98,4 +100,30 @@ public class MobileMenuServiceImpl extends ServiceImpl<MobileMenuMapper, MobileM
|
||||||
}
|
}
|
||||||
return mobileMenu;
|
return mobileMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MobileModule> moduleSelector(MobileMenuSelectorModuleParam mobileMenuSelectorModuleParam) {
|
||||||
|
LambdaQueryWrapper<MobileModule> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if(ObjectUtil.isNotEmpty(mobileMenuSelectorModuleParam.getSearchKey())) {
|
||||||
|
lambdaQueryWrapper.like(MobileModule::getTitle, mobileMenuSelectorModuleParam.getSearchKey());
|
||||||
|
}
|
||||||
|
lambdaQueryWrapper.eq(MobileModule::getCategory, MobileResourceCategoryEnum.MODULE.getValue());
|
||||||
|
return mobileModuleService.list(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Tree<String>> menuTreeSelector(MobileMenuSelectorMenuParam mobileMenuSelectorMenuParam) {
|
||||||
|
LambdaQueryWrapper<MobileMenu> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
// 查询类型为菜单的
|
||||||
|
lambdaQueryWrapper.eq(MobileMenu::getCategory, MobileResourceCategoryEnum.MENU.getValue());
|
||||||
|
if(ObjectUtil.isNotEmpty(mobileMenuSelectorMenuParam.getModule())) {
|
||||||
|
lambdaQueryWrapper.eq(MobileMenu::getModule, mobileMenuSelectorMenuParam.getModule());
|
||||||
|
}
|
||||||
|
List<MobileMenu> resourceList = this.list(lambdaQueryWrapper);
|
||||||
|
List<TreeNode<String>> treeNodeList = resourceList.stream().map(sysMenu ->
|
||||||
|
new TreeNode<>(sysMenu.getId(), sysMenu.getParentId(),
|
||||||
|
sysMenu.getTitle(), sysMenu.getSortCode()).setExtra(JSONUtil.parseObj(sysMenu)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return TreeUtil.build(treeNodeList, "0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,10 @@ public class MobileModuleServiceImpl extends ServiceImpl<MobileModuleMapper, Mob
|
||||||
@Resource
|
@Resource
|
||||||
private MobileMenuService mobileMenuService;
|
private MobileMenuService mobileMenuService;
|
||||||
|
|
||||||
|
/*
|
||||||
@Resource
|
@Resource
|
||||||
/*private MobileRelationService mobileRelationService;*/
|
private MobileRelationService mobileRelationService;
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<MobileModule> page(MobileModulePageParam mobileModulePageParam) {
|
public Page<MobileModule> page(MobileModulePageParam mobileModulePageParam) {
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
SET NAMES utf8mb4;
|
|
||||||
SET FOREIGN_KEY_CHECKS = 0;
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- Records of dev_dict
|
|
||||||
-- ----------------------------
|
|
||||||
INSERT INTO `dev_dict` VALUES ('1619343323218432002', '0', '移动菜单状态', 'MOBILE_STATUS', 'FRM', 93, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
|
||||||
INSERT INTO `dev_dict` VALUES ('1619343680636047362', '1619343323218432002', '可用', 'ENABLE', 'FRM', 94, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
|
||||||
INSERT INTO `dev_dict` VALUES ('1619343846382358529', '1619343323218432002', '不可用', 'DISABLED', 'FRM', 96, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
|
||||||
INSERT INTO `dev_dict` VALUES ('1619344256295882753', '0', '移动菜单规则', 'MOBILE_IS_REG_EXP', 'FRM', 97, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
|
||||||
INSERT INTO `dev_dict` VALUES ('1619344428111351809', '1619344256295882753', '正规则', 'YES', 'FRM', 98, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
|
||||||
INSERT INTO `dev_dict` VALUES ('1619344504456073218', '1619344256295882753', '反规则', 'NO', 'FRM', 98, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- Records of sys_relation
|
|
||||||
-- ----------------------------
|
|
||||||
INSERT INTO `sys_relation` VALUES ('1619345262266142721', '1570687866138206208', '1619345262001901569', 'SYS_ROLE_HAS_RESOURCE', '{\"menuId\":\"1619345262001901569\",\"buttonInfo\":[\"1619345262085787650\",\"1619345262131924994\",\"1619345262131924995\",\"1619345262131924996\"]}');
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- Records of sys_resource
|
|
||||||
-- ----------------------------
|
|
||||||
INSERT INTO `sys_resource` VALUES ('1619345262001901569', '0', '移动管理', NULL, 'gsnnmdy8yi', 'MENU', '1548901111999770525', 'CATALOG', '/a0l7fxfq3m', NULL, 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
|
||||||
INSERT INTO `sys_resource` VALUES ('1619345262001901570', '1619345262001901569', '菜单类别', 'category', 'psf3uj3q90', 'MENU', '1548901111999770525', 'MENU', '/mobile/category', 'mobile/category/index', 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
|
||||||
INSERT INTO `sys_resource` VALUES ('1619345262001901571', '1619345262001901569', '移动菜单', 'menu', '4a84jeju7l', 'MENU', '1548901111999770525', 'MENU', '/mobile/menu', 'mobile/menu/index', 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
|
|
@ -1,19 +1,3 @@
|
||||||
/*
|
|
||||||
Navicat Premium Data Transfer
|
|
||||||
|
|
||||||
Source Server : 本地Mysql
|
|
||||||
Source Server Type : MySQL
|
|
||||||
Source Server Version : 80026
|
|
||||||
Source Host : localhost:3306
|
|
||||||
Source Schema : snowy
|
|
||||||
|
|
||||||
Target Server Type : MySQL
|
|
||||||
Target Server Version : 80026
|
|
||||||
File Encoding : 65001
|
|
||||||
|
|
||||||
Date: 30/01/2023 16:50:05
|
|
||||||
*/
|
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
SET FOREIGN_KEY_CHECKS = 0;
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
@ -44,7 +28,25 @@ CREATE TABLE `mobile_resource` (
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '移动资源' ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '移动资源' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of mobile_resource
|
-- Records of dev_dict
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
INSERT INTO `dev_dict` VALUES ('1619343323218432002', '0', '移动菜单状态', 'MOBILE_STATUS', 'FRM', 93, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `dev_dict` VALUES ('1619343680636047362', '1619343323218432002', '可用', 'ENABLE', 'FRM', 94, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `dev_dict` VALUES ('1619343846382358529', '1619343323218432002', '不可用', 'DISABLED', 'FRM', 96, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `dev_dict` VALUES ('1619344256295882753', '0', '移动菜单规则', 'MOBILE_REG_TYPE', 'FRM', 97, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `dev_dict` VALUES ('1619344428111351809', '1619344256295882753', '正规则', 'YES', 'FRM', 98, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `dev_dict` VALUES ('1619344504456073218', '1619344256295882753', '反规则', 'NO', 'FRM', 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of sys_relation
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `sys_relation` VALUES ('1619345262266142721', '1570687866138206208', '1619345262001901569', 'SYS_ROLE_HAS_RESOURCE', '{\"menuId\":\"1619345262001901569\",\"buttonInfo\":[\"1619345262085787650\",\"1619345262131924994\",\"1619345262131924995\",\"1619345262131924996\"]}');
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of sys_resource
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `sys_resource` VALUES ('1619345262001901569', '0', '移动管理', NULL, 'gsnnmdy8yj', 'MENU', '1548901111999770525', 'CATALOG', '/a0l7fxfq3n', NULL, 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `sys_resource` VALUES ('1619345262001901570', '1619345262001901569', '菜单类别', 'module', 'psf3uj3q90', 'MENU', '1548901111999770525', 'MENU', '/mobile/module', 'mobile/resource/module/index', 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `sys_resource` VALUES ('1619345262001901571', '1619345262001901569', '移动菜单', 'menu', '4a84jeju7l', 'MENU', '1548901111999770525', 'MENU', '/mobile/menu', 'mobile/resource/menu/index', 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
Loading…
Reference in New Issue