From 31567461f52e3cdc5d9c559541d46adc7c239dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com> Date: Wed, 27 Apr 2022 16:38:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B3=BB=E7=BB=9F=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/notify.js | 28 +++++ src/router/modules/system.js | 9 ++ src/store/modules/system/notify.js | 83 +++++++++++++ src/views/system/customer/form.vue | 113 ------------------ src/views/system/notify/index.vue | 185 +++++++++++++++++++++++++++++ 5 files changed, 305 insertions(+), 113 deletions(-) create mode 100644 src/api/system/notify.js create mode 100644 src/store/modules/system/notify.js delete mode 100644 src/views/system/customer/form.vue create mode 100644 src/views/system/notify/index.vue diff --git a/src/api/system/notify.js b/src/api/system/notify.js new file mode 100644 index 0000000..a33d92d --- /dev/null +++ b/src/api/system/notify.js @@ -0,0 +1,28 @@ +import request from '@/utils/request.js'; +export const search = (params) => { + return request({ + url: '/mall/marketing/appMessagePush', + method: 'get', + params, + }); +}; +export const detail = (id) => { + return request({ + url: '/mall/marketing/appMessagePush' + id, + method: 'get', + }); +}; +export const create = (data) => { + return request({ + url: '/mall/marketing/appMessagePush', + method: 'post', + data, + }); +}; +export const remove = (idList) => { + return request({ + url: '/mall/marketing/appMessagePush', + method: 'delete', + params: { idList }, + }); +}; diff --git a/src/router/modules/system.js b/src/router/modules/system.js index 2d95ec3..1b3b9fb 100644 --- a/src/router/modules/system.js +++ b/src/router/modules/system.js @@ -49,6 +49,15 @@ export default [ icon: 'UserFilled', }, }, + { + path: 'notify', + name: 'NotifyManagement', + component: () => import('@/views/system/notify/index.vue'), + meta: { + title: '系统通知', + icon: 'AlarmClock', + }, + }, ], }, ]; diff --git a/src/store/modules/system/notify.js b/src/store/modules/system/notify.js new file mode 100644 index 0000000..535c033 --- /dev/null +++ b/src/store/modules/system/notify.js @@ -0,0 +1,83 @@ +import * as api from '@/api/system/notify.js'; +import { ElMessage, ElMessageBox } from '@/plugins/element-plus'; +const state = () => ({ + code: 'NotifyManagement', + condition: {}, + list: [], + total: 0, + opts: { + init: false, + }, +}); +const getters = {}; +const mutations = { + setCode: (state, data) => (state.code = data), + setCondition: (state, data) => (state.condition = data), + setList: (state, data) => (state.list = data), + setTotal: (state, data) => (state.total = data), + setOpts: (state, data) => (state.opts = data), +}; +const actions = { + search: async ({ state, commit, rootGetters }) => { + let data = { ...state.condition }; + data.startReleaseTime = data.dateRange?.[0]; + data.endReleaseTime = data.dateRange?.[1]; + delete data.dateRange; + let res = await api.search({ ...rootGetters['local/page'](state.code), ...state.condition }); + if (res) { + commit('setList', res.records); + commit('setTotal', res.total); + } else { + ElMessage.error('查询失败'); + commit('setList', []); + } + return res; + }, + load: async ({ commit }) => { + commit('setOpts', { + init: true, + }); + }, + detail: async (context, id) => { + let res = await api.detail(id); + if (!res) { + ElMessage.error('加载详情失败'); + } + return res; + }, + save: async ({ dispatch }, data) => { + let save = data.id ? api.update : api.create; + let res = await save(data); + if (res) { + ElMessage.success('保存成功'); + dispatch('search'); + } else { + ElMessage.error('保存失败'); + } + return res; + }, + remove: async ({ dispatch }, idList) => { + if (!idList.length) { + ElMessage.warning('请选择要删除的数据'); + } else { + try { + await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作'); + let res = await api.remove(idList.join(',')); + if (res) { + ElMessage.success('删除成功'); + dispatch('search'); + } else { + ElMessage.error('删除失败'); + } + } catch (e) { + console.info('取消删除', e); + } + } + }, +}; +export default { + state, + getters, + mutations, + actions, +}; diff --git a/src/views/system/customer/form.vue b/src/views/system/customer/form.vue deleted file mode 100644 index 5c0ab3e..0000000 --- a/src/views/system/customer/form.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - - - diff --git a/src/views/system/notify/index.vue b/src/views/system/notify/index.vue new file mode 100644 index 0000000..05dcc84 --- /dev/null +++ b/src/views/system/notify/index.vue @@ -0,0 +1,185 @@ + + + + +