diff --git a/jsconfig.json b/jsconfig.json
index 079a150..6386598 100644
--- a/jsconfig.json
+++ b/jsconfig.json
@@ -7,7 +7,8 @@
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
- }
+ },
+ "jsx": "preserve"
},
"exclude": ["node_modules"]
}
diff --git a/src/plugins/global-api.js b/src/plugins/global-api.js
index 1fecb3d..dcbeffe 100644
--- a/src/plugins/global-api.js
+++ b/src/plugins/global-api.js
@@ -72,8 +72,18 @@ export const excel = (fileName, data) => {
* @returns 字典标签
*/
export const dict = (dict, value, opts = {}) => {
+ value = value || [];
+ value = value instanceof Array ? value : [value];
opts = { label: 'label', value: 'value', default: '未知', ...opts };
- return (dict ? dict.value || dict : []).find((item) => item[opts.value] === value)?.[opts.label] || opts.default;
+ return (
+ value
+ .map(
+ (v) =>
+ (dict ? dict.value || dict : []).find((item) => item[opts.value] === v)?.[opts.label] ||
+ opts.default
+ )
+ .join(',') || opts.default
+ );
};
/**
* 显示姓名
diff --git a/src/router/index.js b/src/router/index.js
index 40a8c9e..9ef5fde 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -130,6 +130,7 @@ const flatRoutes = (routes, parent = { path: '/', meta: {} }) =>
}
route.path = parent.path + route.path;
}
+ route.meta = route.meta || {};
route.meta.menu = route.path.replaceAll(/\/:[^?]+\?/g, '');
let activeMenu = route.meta.activeMenu;
if (!activeMenu && route.meta.hidden) {
diff --git a/src/router/modules/operation.js b/src/router/modules/operation.js
new file mode 100644
index 0000000..68be07d
--- /dev/null
+++ b/src/router/modules/operation.js
@@ -0,0 +1,45 @@
+export default [
+ {
+ path: '/operation',
+ name: 'OperationCenter',
+ component: () => import('@/layouts/default.vue'),
+ meta: {
+ title: '运营中心',
+ icon: 'computer-fill',
+ layout: true,
+ },
+ children: [
+ {
+ path: 'limit',
+ name: 'LimitActivity',
+ component: () => import('@/views/operation/limit/index.vue'),
+ meta: {
+ title: '秒杀活动',
+ icon: 'fire-fill',
+ },
+ children: [
+ {
+ path: 'time/:id',
+ name: 'UpdateLimitTime',
+ component: () => import('@/views/operation/limit/time.vue'),
+ meta: {
+ title: '设置时段',
+ icon: 'fire-fill',
+ hidden: true,
+ },
+ },
+ {
+ path: 'product/:id',
+ name: 'UpdateLimitProduct',
+ component: () => import('@/views/operation/limit/product.vue'),
+ meta: {
+ title: '设置商品',
+ icon: 'fire-fill',
+ hidden: true,
+ },
+ },
+ ],
+ },
+ ],
+ },
+];
diff --git a/src/store/modules/operation/limit/limitActivity.js b/src/store/modules/operation/limit/limitActivity.js
new file mode 100644
index 0000000..4939aaf
--- /dev/null
+++ b/src/store/modules/operation/limit/limitActivity.js
@@ -0,0 +1,96 @@
+import * as api from '@/api/sales/category.js';
+import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
+const state = () => ({
+ code: 'LimitActivity',
+ condition: {},
+ list: [],
+ total: 0,
+ summary: [],
+ opts: {
+ init: false,
+ status: [
+ { label: '活动未开始', value: 1 },
+ { label: '活动进行中', value: 2 },
+ { label: '活动已结束', value: 3 },
+ ],
+ },
+});
+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),
+ 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);
+ if (!res) {
+ ElMessage.error('查询商品分类列表失败');
+ }
+ return res;
+ },
+ load: async ({ commit, state }) => {
+ commit('setOpts', {
+ ...state.opts,
+ 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('加载详情失败');
+ }
+ 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;
+ },
+ 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(',') });
+ if (res) {
+ ElMessage.success('删除成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('删除失败');
+ }
+ } catch (e) {
+ console.info('取消删除', e);
+ }
+ }
+ },
+};
+export default {
+ state,
+ getters,
+ mutations,
+ actions,
+};
diff --git a/src/store/modules/operation/limit/limitProduct.js b/src/store/modules/operation/limit/limitProduct.js
new file mode 100644
index 0000000..f73c67d
--- /dev/null
+++ b/src/store/modules/operation/limit/limitProduct.js
@@ -0,0 +1,93 @@
+import * as api from '@/api/sales/category.js';
+import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
+const state = () => ({
+ code: 'LimitActivity',
+ condition: {},
+ list: [],
+ total: 0,
+ summary: [],
+ opts: {
+ init: false,
+ timeRange: [],
+ category: [],
+ },
+});
+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),
+ 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);
+ if (!res) {
+ ElMessage.error('查询商品分类列表失败');
+ }
+ return res;
+ },
+ load: async ({ commit, state }) => {
+ commit('setOpts', {
+ ...state.opts,
+ 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('加载详情失败');
+ }
+ 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;
+ },
+ 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(',') });
+ if (res) {
+ ElMessage.success('删除成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('删除失败');
+ }
+ } catch (e) {
+ console.info('取消删除', e);
+ }
+ }
+ },
+};
+export default {
+ state,
+ getters,
+ mutations,
+ actions,
+};
diff --git a/src/store/modules/operation/limit/limitTime.js b/src/store/modules/operation/limit/limitTime.js
new file mode 100644
index 0000000..8503473
--- /dev/null
+++ b/src/store/modules/operation/limit/limitTime.js
@@ -0,0 +1,96 @@
+import * as api from '@/api/sales/category.js';
+import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
+const state = () => ({
+ code: 'LimitTime',
+ condition: {},
+ list: [],
+ total: 0,
+ summary: [],
+ opts: {
+ init: false,
+ status: [
+ { label: '活动未开始', value: 1 },
+ { label: '活动进行中', value: 2 },
+ { label: '活动已结束', value: 3 },
+ ],
+ },
+});
+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),
+ 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);
+ if (!res) {
+ ElMessage.error('查询商品分类列表失败');
+ }
+ return res;
+ },
+ load: async ({ commit, state }) => {
+ commit('setOpts', {
+ ...state.opts,
+ 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('加载详情失败');
+ }
+ 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;
+ },
+ 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(',') });
+ 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/operation/limit/index.vue b/src/views/operation/limit/index.vue
new file mode 100644
index 0000000..b5294c1
--- /dev/null
+++ b/src/views/operation/limit/index.vue
@@ -0,0 +1,209 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 保存
+
+
+
+
+
+
+
+
diff --git a/src/views/operation/limit/product.vue b/src/views/operation/limit/product.vue
new file mode 100644
index 0000000..db608de
--- /dev/null
+++ b/src/views/operation/limit/product.vue
@@ -0,0 +1,195 @@
+
+
+
+ -
+
+
+ {{ item.label }}
+
+ (
+ {{ summary[index] || 0 }}
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/operation/limit/time.vue b/src/views/operation/limit/time.vue
new file mode 100644
index 0000000..197a3e3
--- /dev/null
+++ b/src/views/operation/limit/time.vue
@@ -0,0 +1,150 @@
+
+
+
+
+
+
+
diff --git a/vite.config.js b/vite.config.js
index 5656347..fa34567 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -20,8 +20,9 @@ export default (configEnv) => {
open: false,
proxy: {
'/api': {
- target: 'http://192.168.10.52:8090/',
- // target: 'https://gateway-test.mashibing.cn', // 测试地址
+ // target: 'http://192.168.10.52:8090/', // 显雨
+ // target: 'http://192.168.10.252:8090', // 高玉
+ target: 'http://k8s-horse-gateway.mashibing.cn/', // 测试地址
// target: 'https://gateway.mashibing.cn', // 预发地址
// target: 'https://gateway.mashibing.com', // 生产环境
changeOrigin: true,