diff --git a/snowy-admin-web/src/api/mobile/resource/menuApi.js b/snowy-admin-web/src/api/mobile/resource/menuApi.js new file mode 100644 index 00000000..21fe4bfb --- /dev/null +++ b/snowy-admin-web/src/api/mobile/resource/menuApi.js @@ -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') + } +} diff --git a/snowy-admin-web/src/api/mobile/resource/moduleApi.js b/snowy-admin-web/src/api/mobile/resource/moduleApi.js new file mode 100644 index 00000000..d024e0d7 --- /dev/null +++ b/snowy-admin-web/src/api/mobile/resource/moduleApi.js @@ -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') + } +} diff --git a/snowy-admin-web/src/views/mobile/menu/form.vue b/snowy-admin-web/src/views/mobile/resource/menu/form.vue similarity index 58% rename from snowy-admin-web/src/views/mobile/menu/form.vue rename to snowy-admin-web/src/views/mobile/resource/menu/form.vue index 347920cb..1924fa82 100644 --- a/snowy-admin-web/src/views/mobile/menu/form.vue +++ b/snowy-admin-web/src/views/mobile/resource/menu/form.vue @@ -10,8 +10,25 @@ - - + + @@ -24,24 +41,20 @@ - - - - - - + + 选择 - + - - + + @@ -58,6 +71,7 @@ 关闭 保存 + @@ -65,27 +79,53 @@ import tool from '@/utils/tool' import { cloneDeep } from 'lodash-es' 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 emit = defineEmits({ successful: null }) const formRef = ref() - // 表单数据 + let iconSelector = ref() + // 默认展开的节点(顶级) + const defaultExpandedKeys = ref([0]) + const treeData = ref([]) const formData = ref({}) + // 类别 + const moduleId = ref('') const submitLoading = ref(false) - const categoryOptions = ref([]) - const isRegExpOptions = ref([]) + const regTypeOptions = ref([]) const statusOptions = ref([]) // 打开抽屉 - const onOpen = (record) => { + const onOpen = (record, module) => { + moduleId.value = module visible.value = true + // 设置默认的 + formData.value = { + regType: 'YES', + status: 'ENABLE', + category: 'MENU' + } if (record) { let recordData = cloneDeep(record) 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') } // 关闭抽屉 @@ -94,16 +134,33 @@ formData.value = {} 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 = { - parentId: [required('请输入父ID')], + parentId: [required('请选择上级')], title: [required('请输入名称')], pages: [required('请输入界面路径')], - category: [required('请输入分类')], - icon: [required('请输入图标')], - color: [required('请输入颜色')], - isRegExp: [required('请输入正规则')], - status: [required('请输入可用状态')], + icon: [required('请选择图标')], + color: [required('请选择颜色')], + regType: [required('请选择规则类型')], + status: [required('请选择可用状态')] } // 验证并提交数据 const onSubmit = () => { @@ -112,6 +169,7 @@ .then(() => { submitLoading.value = true const formDataParam = cloneDeep(formData.value) + formDataParam.module = moduleId.value mobileMenuApi .mobileMenuSubmitForm(formDataParam, !formDataParam.id) .then(() => { diff --git a/snowy-admin-web/src/views/mobile/menu/index.vue b/snowy-admin-web/src/views/mobile/resource/menu/index.vue similarity index 63% rename from snowy-admin-web/src/views/mobile/menu/index.vue rename to snowy-admin-web/src/views/mobile/resource/menu/index.vue index 6a815b88..fd462284 100644 --- a/snowy-admin-web/src/views/mobile/menu/index.vue +++ b/snowy-admin-web/src/views/mobile/resource/menu/index.vue @@ -1,29 +1,27 @@