From 5067f424788866b48e6b155231d7a8df4fd961fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com> Date: Mon, 18 Apr 2022 15:25:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8E=A8=E8=8D=90=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/operation/limit/limitProduct.js | 22 ++ .../operation/recommend/recommendProduct.js | 29 +++ src/router/modules/operation.js | 4 +- .../modules/operation/limit/limitProduct.js | 44 ++-- .../recommendProduct.js} | 39 ++-- src/views/operation/limit/product.vue | 112 +++++----- src/views/operation/recommand/product.vue | 195 ------------------ src/views/operation/recommand/time.vue | 150 -------------- .../{recommand => recommend}/index.vue | 33 +-- src/views/sales/product/index.vue | 4 +- 10 files changed, 149 insertions(+), 483 deletions(-) create mode 100644 src/api/operation/limit/limitProduct.js create mode 100644 src/api/operation/recommend/recommendProduct.js rename src/store/modules/operation/{recommand/recommandActivity.js => recommend/recommendProduct.js} (69%) delete mode 100644 src/views/operation/recommand/product.vue delete mode 100644 src/views/operation/recommand/time.vue rename src/views/operation/{recommand => recommend}/index.vue (78%) diff --git a/src/api/operation/limit/limitProduct.js b/src/api/operation/limit/limitProduct.js new file mode 100644 index 0000000..0c47d54 --- /dev/null +++ b/src/api/operation/limit/limitProduct.js @@ -0,0 +1,22 @@ +import request from '@/utils/request.js'; +export const search = (params) => { + return request({ + url: '/mall/marketing/activityProduct', + method: 'get', + params, + }); +}; +export const create = (data) => { + return request({ + url: '/mall/marketing/activityProduct', + method: 'post', + data, + }); +}; +export const remove = (idList) => { + return request({ + url: '/mall/marketing/activityProduct', + method: 'delete', + params: { idList }, + }); +}; diff --git a/src/api/operation/recommend/recommendProduct.js b/src/api/operation/recommend/recommendProduct.js new file mode 100644 index 0000000..85b07ee --- /dev/null +++ b/src/api/operation/recommend/recommendProduct.js @@ -0,0 +1,29 @@ +import request from '@/utils/request.js'; +export const search = (params) => { + return request({ + url: '/mall/marketing/productRecommended', + method: 'get', + params, + }); +}; +export const create = (data) => { + return request({ + url: '/mall/marketing/productRecommended', + method: 'post', + data, + }); +}; +export const enable = (data) => { + return request({ + url: '/mall/marketing/productRecommended', + method: 'put', + data, + }); +}; +export const remove = (idList) => { + return request({ + url: '/mall/marketing/productRecommended', + method: 'delete', + params: { idList }, + }); +}; diff --git a/src/router/modules/operation.js b/src/router/modules/operation.js index cc62a12..7aea860 100644 --- a/src/router/modules/operation.js +++ b/src/router/modules/operation.js @@ -41,9 +41,9 @@ export default [ ], }, { - path: 'recommand', + path: 'recommend', name: 'RecommandActivity', - component: () => import('@/views/operation/recommand/index.vue'), + component: () => import('@/views/operation/recommend/index.vue'), meta: { title: '商品推荐', icon: 'Checked', diff --git a/src/store/modules/operation/limit/limitProduct.js b/src/store/modules/operation/limit/limitProduct.js index f73c67d..96d957d 100644 --- a/src/store/modules/operation/limit/limitProduct.js +++ b/src/store/modules/operation/limit/limitProduct.js @@ -1,11 +1,11 @@ -import * as api from '@/api/sales/category.js'; +import * as api from '@/api/operation/limit/limitProduct.js'; +import * as limitTimeAPI from '@/api/operation/limit/limitTime.js'; import { ElMessage, ElMessageBox } from '@/plugins/element-plus'; const state = () => ({ - code: 'LimitActivity', + code: 'LimitProduct', condition: {}, list: [], total: 0, - summary: [], opts: { init: false, timeRange: [], @@ -18,37 +18,28 @@ const mutations = { setCondition: (state, data) => (state.condition = data), setList: (state, data) => (state.list = data), setTotal: (state, data) => (state.total = data), - setSummary: (state, data) => (state.summary = data), setOpts: (state, data) => (state.opts = data), }; const actions = { - search: async ({ state, commit }) => { - let res = await api.search(state.condition); - commit('setList', res); + search: async ({ state, commit, rootGetters }) => { + let data = { ...state.condition }; + let res = await api.search({ ...rootGetters['local/page'](state.code), ...data }); + commit('setList', res?.records || []); + commit('setTotal', res?.total || 0); if (!res) { - ElMessage.error('查询商品分类列表失败'); + ElMessage.error('查询秒杀商品列表失败'); } return res; }, - load: async ({ commit, state }) => { + load: async ({ commit, state }, activityId) => { commit('setOpts', { ...state.opts, init: true, + timeRange: await limitTimeAPI.search({ activityId }), }); }, - detail: async ({ state, dispatch }, id) => { - if (!state.list.length) { - await dispatch('search'); - } - let res = state.list.find((item) => item.id === id); - if (!res) { - ElMessage.error('加载详情失败'); - } - return res; - }, save: async ({ dispatch }, data) => { - let save = data.id ? api.update : api.create; - let res = await save(data); + let res = await api.create(data); if (res) { ElMessage.success('保存成功'); dispatch('search'); @@ -57,22 +48,13 @@ const actions = { } return res; }, - sort: async (context, data) => { - let res = await api.sort(data); - if (res) { - ElMessage.success(`移动前序号:${data.oldSort + 1};移动后序号:${data.currentSort + 1}`); - } else { - ElMessage.error('保存排序失败'); - } - return res; - }, remove: async ({ dispatch }, ids) => { if (!ids.length) { ElMessage.warning('请选择要删除的数据'); } else { try { await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作'); - let res = await api.remove({ id: ids.join(',') }); + let res = await api.remove(ids.join(',')); if (res) { ElMessage.success('删除成功'); dispatch('search'); diff --git a/src/store/modules/operation/recommand/recommandActivity.js b/src/store/modules/operation/recommend/recommendProduct.js similarity index 69% rename from src/store/modules/operation/recommand/recommandActivity.js rename to src/store/modules/operation/recommend/recommendProduct.js index 86aea52..069e09f 100644 --- a/src/store/modules/operation/recommand/recommandActivity.js +++ b/src/store/modules/operation/recommend/recommendProduct.js @@ -1,7 +1,7 @@ -import * as api from '@/api/sales/category.js'; +import * as api from '@/api/operation/recommend/recommendProduct.js'; import { ElMessage, ElMessageBox } from '@/plugins/element-plus'; const state = () => ({ - code: 'LimitActivity', + code: 'RecommendProductManagement', condition: {}, list: [], total: 0, @@ -24,11 +24,13 @@ const mutations = { setOpts: (state, data) => (state.opts = data), }; const actions = { - search: async ({ state, commit }) => { - let res = await api.search(state.condition); - commit('setList', res); + search: async ({ state, commit, rootGetters }) => { + let data = { ...state.condition }; + let res = await api.search({ ...rootGetters['local/page'](state.code), ...data }); + commit('setList', res?.records || []); + commit('setTotal', res?.total || 0); if (!res) { - ElMessage.error('查询商品分类列表失败'); + ElMessage.error('查询推荐商品列表失败'); } return res; }, @@ -38,13 +40,13 @@ const actions = { init: true, }); }, - detail: async ({ state, dispatch }, id) => { - if (!state.list.length) { - await dispatch('search'); - } - let res = state.list.find((item) => item.id === id); - if (!res) { - ElMessage.error('加载详情失败'); + enable: async ({ dispatch }, data) => { + let res = await api.enable({ id: data.id, isEnable: data.isEnable }); + if (res) { + ElMessage.success('保存成功'); + dispatch('search'); + } else { + ElMessage.error('保存失败'); } return res; }, @@ -59,22 +61,13 @@ const actions = { } return res; }, - sort: async (context, data) => { - let res = await api.sort(data); - if (res) { - ElMessage.success(`移动前序号:${data.oldSort + 1};移动后序号:${data.currentSort + 1}`); - } else { - ElMessage.error('保存排序失败'); - } - return res; - }, remove: async ({ dispatch }, ids) => { if (!ids.length) { ElMessage.warning('请选择要删除的数据'); } else { try { await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作'); - let res = await api.remove({ id: ids.join(',') }); + let res = await api.remove(ids.join(',')); if (res) { ElMessage.success('删除成功'); dispatch('search'); diff --git a/src/views/operation/limit/product.vue b/src/views/operation/limit/product.vue index db608de..3d9d166 100644 --- a/src/views/operation/limit/product.vue +++ b/src/views/operation/limit/product.vue @@ -3,15 +3,10 @@