From 61aa2980d0f5bd2a3659bf878e0998728a813be1 Mon Sep 17 00:00:00 2001 From: Jason <5340635+wen-jason@user.noreply.gitee.com> Date: Tue, 30 Aug 2022 19:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=EF=BC=8C=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=EF=BC=8C=E6=B8=A0=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/api/channel/weapp.ts | 11 ++ admin/src/api/channel/wx_dev.ts | 11 ++ .../api/channel/{wechat_oa.ts => wx_oa.ts} | 4 +- admin/src/api/message.ts | 31 ++++ admin/src/install/directives/perms.ts | 1 - .../default/components/sidebar/menu.vue | 3 +- admin/src/router/index.ts | 12 +- admin/src/router/routes.ts | 46 ----- admin/src/stores/modules/user.ts | 4 + admin/src/utils/util.ts | 30 +++- admin/src/views/article/lists/index.vue | 3 +- admin/src/views/channel/h5.vue | 2 +- admin/src/views/channel/weapp.vue | 170 ++++++++++++++++++ admin/src/views/channel/wx_dev.vue | 63 +++++++ .../channel/{wechat_oa => wx_oa}/config.vue | 28 +-- .../{wechat_oa => wx_oa}/default_reply.vue | 0 .../{wechat_oa => wx_oa}/follow_reply.vue | 0 .../{wechat_oa => wx_oa}/keyword_reply.vue | 0 .../channel/{wechat_oa => wx_oa}/menu.vue | 0 admin/src/views/consumer/lists/detail.vue | 95 ++++++++++ admin/src/views/consumer/lists/index.vue | 132 ++++++++++++++ admin/src/views/decoration/pages/index.vue | 0 admin/src/views/decoration/tabbar.vue | 0 admin/src/views/dev_tools/code/index.vue | 3 +- admin/src/views/message/notice/edit.vue | 121 +++++++++++++ admin/src/views/message/notice/index.vue | 91 ++++++++++ admin/src/views/message/short_letter/edit.vue | 120 +++++++++++++ .../src/views/message/short_letter/index.vue | 56 ++++++ admin/src/views/permission/menu/edit.vue | 61 +++++-- admin/src/views/setting/dict/type/index.vue | 3 +- admin/src/views/setting/storage/edit.vue | 2 + admin/src/views/setting/website/filing.vue | 2 +- admin/tailwind.config.js | 1 + admin/typings/router.d.ts | 2 + 34 files changed, 1029 insertions(+), 79 deletions(-) create mode 100644 admin/src/api/channel/weapp.ts create mode 100644 admin/src/api/channel/wx_dev.ts rename admin/src/api/channel/{wechat_oa.ts => wx_oa.ts} (79%) create mode 100644 admin/src/api/message.ts create mode 100644 admin/src/views/channel/weapp.vue create mode 100644 admin/src/views/channel/wx_dev.vue rename admin/src/views/channel/{wechat_oa => wx_oa}/config.vue (91%) rename admin/src/views/channel/{wechat_oa => wx_oa}/default_reply.vue (100%) rename admin/src/views/channel/{wechat_oa => wx_oa}/follow_reply.vue (100%) rename admin/src/views/channel/{wechat_oa => wx_oa}/keyword_reply.vue (100%) rename admin/src/views/channel/{wechat_oa => wx_oa}/menu.vue (100%) create mode 100644 admin/src/views/consumer/lists/detail.vue create mode 100644 admin/src/views/consumer/lists/index.vue create mode 100644 admin/src/views/decoration/pages/index.vue create mode 100644 admin/src/views/decoration/tabbar.vue create mode 100644 admin/src/views/message/notice/edit.vue create mode 100644 admin/src/views/message/notice/index.vue create mode 100644 admin/src/views/message/short_letter/edit.vue create mode 100644 admin/src/views/message/short_letter/index.vue diff --git a/admin/src/api/channel/weapp.ts b/admin/src/api/channel/weapp.ts new file mode 100644 index 00000000..59ce0a7b --- /dev/null +++ b/admin/src/api/channel/weapp.ts @@ -0,0 +1,11 @@ +import request from '@/utils/request' + +// 微信小程序配置保存 +export function setWeappConfig(params: any) { + return request.post({ url: '/channel/mp/save', params }) +} + +// 微信小程序配置详情 +export function getWeappConfig() { + return request.get({ url: '/channel/mp/detail' }) +} diff --git a/admin/src/api/channel/wx_dev.ts b/admin/src/api/channel/wx_dev.ts new file mode 100644 index 00000000..a39ca962 --- /dev/null +++ b/admin/src/api/channel/wx_dev.ts @@ -0,0 +1,11 @@ +import request from '@/utils/request' + +// 微信开发平台配置保存 +export function setWxDevConfig(params: any) { + return request.post({ url: '/channel/wx/save', params }) +} + +// 微信开发平台配置详情 +export function getWxDevConfig() { + return request.get({ url: '/channel/wx/detail' }) +} diff --git a/admin/src/api/channel/wechat_oa.ts b/admin/src/api/channel/wx_oa.ts similarity index 79% rename from admin/src/api/channel/wechat_oa.ts rename to admin/src/api/channel/wx_oa.ts index 6ef645cd..fd770cc7 100644 --- a/admin/src/api/channel/wechat_oa.ts +++ b/admin/src/api/channel/wx_oa.ts @@ -1,11 +1,11 @@ import request from '@/utils/request' -// oa渠道配置保存 +// 微信公众号配置保存 export function setOaConfig(params: any) { return request.post({ url: '/channel/oa/save', params }) } -// oa渠道配置详情 +// 微信公众号配置详情 export function getOaConfig() { return request.get({ url: '/channel/oa/detail' }) } diff --git a/admin/src/api/message.ts b/admin/src/api/message.ts new file mode 100644 index 00000000..8d7ec49e --- /dev/null +++ b/admin/src/api/message.ts @@ -0,0 +1,31 @@ +import request from '@/utils/request' + +// 通知设置列表 +export function noticeLists(params: any) { + return request.get({ url: '/setting/notice/list', params }) +} + +// 通知设置详情 +export function noticeDetail(params: any) { + return request.get({ url: '/setting/notice/detail', params }) +} + +// 通知设置保存 +export function setNoticeConfig(params: any) { + return request.post({ url: '/setting/notice/save', params }) +} + +// 短信设置列表 +export function smsLists() { + return request.get({ url: '/setting/sms/list' }) +} + +// 短信设置详情 +export function smsDetail(params: any) { + return request.get({ url: '/setting/sms/detail', params }) +} + +// 短信设置保存 +export function setSmsConfig(params: any) { + return request.post({ url: '/setting/sms/save', params }) +} diff --git a/admin/src/install/directives/perms.ts b/admin/src/install/directives/perms.ts index 507dbfe4..e62765fb 100644 --- a/admin/src/install/directives/perms.ts +++ b/admin/src/install/directives/perms.ts @@ -5,7 +5,6 @@ */ import useUserStore from '@/stores/modules/user' - export default { mounted: (el: HTMLElement, binding: any) => { const { value } = binding diff --git a/admin/src/layout/default/components/sidebar/menu.vue b/admin/src/layout/default/components/sidebar/menu.vue index 3dcae51f..67c38922 100644 --- a/admin/src/layout/default/components/sidebar/menu.vue +++ b/admin/src/layout/default/components/sidebar/menu.vue @@ -48,7 +48,8 @@ const props = defineProps({ defineEmits(['select']) const route = useRoute() -const activeMenu = computed(() => (route.meta?.activeMenu as string) ?? route.path) +console.log(route) +const activeMenu = computed(() => route.meta?.activeMenu || route.path) const themeClass = computed(() => `theme-${props.theme}`) diff --git a/admin/src/router/index.ts b/admin/src/router/index.ts index 09ac78d3..8227b944 100644 --- a/admin/src/router/index.ts +++ b/admin/src/router/index.ts @@ -7,6 +7,11 @@ import useUserStore from '@/stores/modules/user' // 匹配views里面所有的.vue文件,动态引入 const modules = import.meta.glob('/src/views/**/*.vue') +// +export function getModulesKey() { + return Object.keys(modules).map((item) => item.replace('/src/views/', '').replace('.vue', '')) +} + // 过滤路由所需要的数据 export function filterAsyncRoutes(routes: any[], firstRoute = true) { return routes.map((route) => { @@ -31,7 +36,8 @@ export function createRouteRecord(route: any, firstRoute: boolean): RouteRecordR perms: route.perms, query: route.params, icon: route.menuIcon, - type: route.menuType + type: route.menuType, + activeMenu: route.selected } } switch (route.menuType) { @@ -79,6 +85,10 @@ export function findFirstValidRoute(routes: RouteRecordRaw[]): string | undefine } } +export function getRoutePath(perms: string) { + return router.getRoutes().find((item) => item.meta?.perms == perms)?.path || '' +} + // 重置路由 export function resetRouter() { router.removeRoute(INDEX_ROUTE_NAME) diff --git a/admin/src/router/routes.ts b/admin/src/router/routes.ts index 26503ab9..dc91f60b 100644 --- a/admin/src/router/routes.ts +++ b/admin/src/router/routes.ts @@ -47,52 +47,6 @@ export const constantRoutes: Array = [ } } ] - }, - { - path: '/dev_tools', - component: LAYOUT, - children: [ - { - path: 'code/edit', - name: Symbol(), - component: () => import('@/views/dev_tools/code/edit.vue'), - meta: { - title: '编辑数据表', - activeMenu: '/dev_tools/code', - name: Symbol() - } - } - ] - }, - { - path: '/setting', - component: LAYOUT, - children: [ - { - path: 'dict/data', - name: Symbol(), - component: () => import('@/views/setting/dict/data/index.vue'), - meta: { - title: '数据管理', - activeMenu: '/setting/dict' - } - } - ] - }, - { - path: '/article', - component: LAYOUT, - children: [ - { - path: 'lists/edit', - name: Symbol(), - component: () => import('@/views/article/lists/edit.vue'), - meta: { - title: '文章编辑', - activeMenu: '/article/lists' - } - } - ] } ] diff --git a/admin/src/stores/modules/user.ts b/admin/src/stores/modules/user.ts index dbf52a93..f84da3f6 100644 --- a/admin/src/stores/modules/user.ts +++ b/admin/src/stores/modules/user.ts @@ -10,6 +10,7 @@ export interface UserState { token: string userInfo: Record routes: RouteRecordRaw[] + menu: any[] perms: string[] } @@ -21,6 +22,7 @@ const useUserStore = defineStore({ userInfo: {}, // 路由 routes: [], + menu: [], // 权限 perms: [] }), @@ -30,6 +32,7 @@ const useUserStore = defineStore({ this.token = '' this.userInfo = {} this.perms = [] + this.menu = [] }, login(playload: any) { const { account, password } = playload @@ -78,6 +81,7 @@ const useUserStore = defineStore({ return new Promise((resolve, reject) => { getMenu() .then((data) => { + this.menu = data this.routes = filterAsyncRoutes(data) resolve(data) }) diff --git a/admin/src/utils/util.ts b/admin/src/utils/util.ts index 11e12b7b..119b60bc 100644 --- a/admin/src/utils/util.ts +++ b/admin/src/utils/util.ts @@ -1,4 +1,5 @@ import { isObject } from '@vue/shared' +import { cloneDeep } from 'lodash' /** * @description 添加单位 @@ -25,7 +26,7 @@ export const isEmpty = (value: unknown) => { */ export const treeToArray = (data: any[], props = { children: 'children' }) => { - data = JSON.parse(JSON.stringify(data)) + data = cloneDeep(data) const { children } = props const newData = [] const queue: any[] = [] @@ -41,6 +42,33 @@ export const treeToArray = (data: any[], props = { children: 'children' }) => { return newData } +/** + * @description 数组转 + * @param {Array} data 数据 + * @param {Object} props `{ parent: 'pid', children: 'children' }` + */ + +export const arrayToTree = ( + data: any[], + props = { id: 'id', parentId: 'pid', children: 'children' } +) => { + data = cloneDeep(data) + const { id, parentId, children } = props + const result: any[] = [] + const map = new Map() + data.forEach((item) => { + map.set(item[id], item) + const parent = map.get(item[parentId]) + if (parent) { + parent[children] = parent[children] ?? [] + parent[children].push(item) + } else { + result.push(item) + } + }) + return result +} + /** * @description 获取正确的路经 * @param {String} path 数据 diff --git a/admin/src/views/article/lists/index.vue b/admin/src/views/article/lists/index.vue index 8352b640..b139d188 100644 --- a/admin/src/views/article/lists/index.vue +++ b/admin/src/views/article/lists/index.vue @@ -79,7 +79,7 @@ - +
diff --git a/admin/src/views/channel/weapp.vue b/admin/src/views/channel/weapp.vue new file mode 100644 index 00000000..f9649c9c --- /dev/null +++ b/admin/src/views/channel/weapp.vue @@ -0,0 +1,170 @@ + + diff --git a/admin/src/views/channel/wx_dev.vue b/admin/src/views/channel/wx_dev.vue new file mode 100644 index 00000000..88ae3264 --- /dev/null +++ b/admin/src/views/channel/wx_dev.vue @@ -0,0 +1,63 @@ + + diff --git a/admin/src/views/channel/wechat_oa/config.vue b/admin/src/views/channel/wx_oa/config.vue similarity index 91% rename from admin/src/views/channel/wechat_oa/config.vue rename to admin/src/views/channel/wx_oa/config.vue index fde8fbb9..5c7cccc2 100644 --- a/admin/src/views/channel/wechat_oa/config.vue +++ b/admin/src/views/channel/wx_oa/config.vue @@ -8,7 +8,7 @@ show-icon /> - +
微信公众号
@@ -42,23 +42,27 @@
-
- 登录微信公众平台,点击开发>基本配置>公众号开发信息,设置AppID和AppSecret -
+
+
+ +
+ 小程序账号登录微信公众平台,点击开发>开发设置->开发者ID,设置AppID和AppSecret
服务器配置
-
-
- +
+
+
+ +
+ 复制 +
+
+ 登录微信公众平台,点击开发>基本配置>服务器配置,填写服务器地址(URL)
- 复制 -
-
- 登录微信公众平台,点击开发>基本配置>服务器配置,填写服务器地址(URL)
@@ -150,7 +154,7 @@
diff --git a/admin/src/views/consumer/lists/index.vue b/admin/src/views/consumer/lists/index.vue new file mode 100644 index 00000000..6507111e --- /dev/null +++ b/admin/src/views/consumer/lists/index.vue @@ -0,0 +1,132 @@ + + diff --git a/admin/src/views/decoration/pages/index.vue b/admin/src/views/decoration/pages/index.vue new file mode 100644 index 00000000..e69de29b diff --git a/admin/src/views/decoration/tabbar.vue b/admin/src/views/decoration/tabbar.vue new file mode 100644 index 00000000..e69de29b diff --git a/admin/src/views/dev_tools/code/index.vue b/admin/src/views/dev_tools/code/index.vue index d27fd94e..0b3acd90 100644 --- a/admin/src/views/dev_tools/code/index.vue +++ b/admin/src/views/dev_tools/code/index.vue @@ -73,7 +73,7 @@ + + + + +
通知名称
+ {{ formData.name }} + {{ formData.type }} + {{ formData.remarks }} +
+ +
短信通知
+ + + 关闭 + 开启 + + + +
+ +
+
+ +
+
+ +
+
+ 可选变量 用户昵称:nickname 订单编号:order_sn 支付时间:pay_time +
+ 示例:亲爱的${nickname},您的订单${order_sn}已支付成功,商家正在快马加鞭为您安排发货。 +
+ 生效条件:1、管理后台完成短信设置。2、第三方短信平台申请模板。 +
+
+
+
+
+ + 保存 + +
+ + + diff --git a/admin/src/views/message/notice/index.vue b/admin/src/views/message/notice/index.vue new file mode 100644 index 00000000..8f90fb2a --- /dev/null +++ b/admin/src/views/message/notice/index.vue @@ -0,0 +1,91 @@ + + diff --git a/admin/src/views/message/short_letter/edit.vue b/admin/src/views/message/short_letter/edit.vue new file mode 100644 index 00000000..55dfa86c --- /dev/null +++ b/admin/src/views/message/short_letter/edit.vue @@ -0,0 +1,120 @@ + + diff --git a/admin/src/views/message/short_letter/index.vue b/admin/src/views/message/short_letter/index.vue new file mode 100644 index 00000000..8d890365 --- /dev/null +++ b/admin/src/views/message/short_letter/index.vue @@ -0,0 +1,56 @@ + + diff --git a/admin/src/views/permission/menu/edit.vue b/admin/src/views/permission/menu/edit.vue index 6145c202..271da053 100644 --- a/admin/src/views/permission/menu/edit.vue +++ b/admin/src/views/permission/menu/edit.vue @@ -62,12 +62,31 @@ prop="component" >
- + +
访问的组件路径,如:`permission/admin/index`,默认在`views`目录下
+ +
+ +
+ 访问详情页面,编辑页面时,菜单高亮显示,如`/consumer/lists` +
+
+
- + import type { FormInstance } from 'element-plus' import { menuLists, menuEdit, menuAdd, menuDetail } from '@/api/perms/menu' +import { getModulesKey } from '@/router' import { MenuEnum } from '@/enums/appEnums' import Popup from '@/components/popup/index.vue' import feedback from '@/utils/feedback' +import { arrayToTree, treeToArray } from '@/utils/util' const emit = defineEmits(['success', 'close']) const formRef = shallowRef() @@ -162,6 +188,16 @@ const popupTitle = computed(() => { return mode.value == 'edit' ? '编辑菜单' : '新增菜单' }) +const componentsOptions = ref(getModulesKey()) +const querySearch = (queryString: string, cb: any) => { + const results = queryString + ? componentsOptions.value.filter((item) => + item.toLowerCase().includes(queryString.toLowerCase()) + ) + : componentsOptions.value + cb(results.map((item) => ({ value: item }))) +} + const formData = reactive({ id: '', //父级id @@ -224,9 +260,14 @@ const formRules = { } const menuOptions = ref([]) +const pageOptions = ref([]) + const getMenu = async () => { const data: any = await menuLists() const menu = { id: 0, menuName: '顶级', children: [] } + pageOptions.value = arrayToTree( + treeToArray(data).filter((item) => item.menuType != MenuEnum.BUTTON) + ) menu.children = data menuOptions.value.push(menu) } diff --git a/admin/src/views/setting/dict/type/index.vue b/admin/src/views/setting/dict/type/index.vue index eb1b4884..eea3caa1 100644 --- a/admin/src/views/setting/dict/type/index.vue +++ b/admin/src/views/setting/dict/type/index.vue @@ -76,7 +76,7 @@ link @click=" $router.push({ - path: '/setting/dict/data', + path: getRoutePath('setting:dict:data:list'), query: { type: row.dictType } @@ -109,6 +109,7 @@