管理、商家,添加删除秒杀商品接口,管理端切换账号菜单权限不生效问题,代码优化

master
mabo 2021-08-11 18:47:59 +08:00
parent 3e505a8a4e
commit e9163e4247
13 changed files with 433 additions and 844 deletions

View File

@ -38,7 +38,7 @@
<TabPane label="已选商品" name="goodsChecked"> <TabPane label="已选商品" name="goodsChecked">
<Table stripe :columns="goodsColumns" :data="goodsData.records"> <Table stripe :columns="goodsColumns" :data="goodsData.records">
<template slot-scope="{ row }" slot="name"> <template slot-scope="{ row }" slot="name">
<div class="goods-msg" @click="linkTo(`/goodsDetail?skuId=${row.skuId}&goodsId=${row.id}`)"><img style="vertical-align:top;" :src="row.thumbnail" width="60" height="60" alt="">&nbsp; {{row.goodsName}}</div> <div class="goods-msg" @click="linkTo(`/goodsDetail?skuId=${row.skuId}&goodsId=${row.goodsId}`)"><img style="vertical-align:top;" :src="row.thumbnail" width="60" height="60" alt="">&nbsp; {{row.goodsName}}</div>
</template> </template>
<template slot-scope="{ row }" slot="price"> <template slot-scope="{ row }" slot="price">
<span> {{ row.price | unitPrice }}</span> <span> {{ row.price | unitPrice }}</span>
@ -66,7 +66,7 @@
<TabPane label="未选商品" name="goodsUncheck"> <TabPane label="未选商品" name="goodsUncheck">
<Table stripe :columns="goodsColumns" :data="goodsData.records"> <Table stripe :columns="goodsColumns" :data="goodsData.records">
<template slot-scope="{ row }" slot="name"> <template slot-scope="{ row }" slot="name">
<div class="goods-msg" @click="linkTo(`/goodsDetail?skuId=${row.skuId}&goodsId=${row.id}`)"><img style="vertical-align:top;" :src="row.thumbnail" width="60" height="60" alt="">&nbsp; {{row.goodsName}}</div> <div class="goods-msg" @click="linkTo(`/goodsDetail?skuId=${row.skuId}&goodsId=${row.goodsId}`)"><img style="vertical-align:top;" :src="row.thumbnail" width="60" height="60" alt="">&nbsp; {{row.goodsName}}</div>
</template> </template>
<template slot-scope="{ row }" slot="price"> <template slot-scope="{ row }" slot="price">
<span> {{ row.price | unitPrice }}</span> <span> {{ row.price | unitPrice }}</span>
@ -289,7 +289,7 @@ export default {
}) })
}, },
fenxiao (row) { // fenxiao (row) { //
this.qrcode = `${location.origin}/goodsDetail?skuId=${row.skuId}&goodsId=${row.id}&distributionId=${this.result.id}` this.qrcode = `${location.origin}/goodsDetail?skuId=${row.skuId}&goodsId=${row.goodsId}&distributionId=${this.result.id}`
this.goodsNameCurr = row.goodsName this.goodsNameCurr = row.goodsName
this.qrcodeShow = true; this.qrcodeShow = true;
}, },

View File

@ -6,7 +6,7 @@ import {
deleteRequest deleteRequest
} from "@/libs/axios"; } from "@/libs/axios";
// 获取限时抢购申请列表 // 获取秒杀活动申请列表
export const getPromotionSeckill = params => { export const getPromotionSeckill = params => {
return getRequest(`/promotion/seckill/apply`, params); return getRequest(`/promotion/seckill/apply`, params);
@ -118,10 +118,12 @@ export const getActivityCouponList = params => {
export const getCouponActivityList = params => { export const getCouponActivityList = params => {
return getRequest("/promotion/couponActivity", params); return getRequest("/promotion/couponActivity", params);
}; };
// 作废优惠券 // 关闭优惠券活动
export const closeActivity = id => { export const closeActivity = id => {
return deleteRequest(`/promotion/couponActivity/${id}`); return deleteRequest(`/promotion/couponActivity/${id}`);
}; };
// 更新优惠券活动 // 更新优惠券活动
export const updateCouponActivity = params => { export const updateCouponActivity = params => {
return putRequest(`/promotion/couponActivity/status`, params); return putRequest(`/promotion/couponActivity/status`, params);
@ -131,42 +133,45 @@ export const getCouponActivity = id => {
return getRequest(`/promotion/couponActivity/${id}`); return getRequest(`/promotion/couponActivity/${id}`);
}; };
// 获取限时抢购数据 // 获取秒杀活动数据
export const getSeckillList = params => { export const getSeckillList = params => {
return getRequest("/promotion/seckill", params); return getRequest("/promotion/seckill", params);
}; };
// 获取限时抢购审核列表 // 获取秒杀活动审核列表
export const seckillGoodsList = params => { export const seckillGoodsList = params => {
return getRequest("/promotion/seckill/apply", params); return getRequest("/promotion/seckill/apply", params);
}; };
// 获取限时抢购详情数据 // 获取秒杀活动详情数据
export const seckillDetail = (id, params) => { export const seckillDetail = (id, params) => {
return getRequest(`/promotion/seckill/${id}`, params); return getRequest(`/promotion/seckill/${id}`, params);
}; };
// 删除限时抢购 // 删除秒杀活动
export const delSeckill = id => { export const delSeckill = id => {
return deleteRequest(`/promotion/seckill/${id}`); return deleteRequest(`/promotion/seckill/${id}`);
}; };
// 保存限时抢购 // 保存秒杀活动
export const saveSeckill = params => { export const saveSeckill = params => {
return postRequest("/promotion/seckill", params); return postRequest("/promotion/seckill", params);
}; };
// 修改限时抢购 // 修改秒杀活动
export const updateSeckill = params => { export const updateSeckill = params => {
return putRequest("/promotion/seckill", params); return putRequest("/promotion/seckill", params);
}; };
// 关闭限时抢购 // 关闭秒杀活动
export const closeSeckill = id => { export const closeSeckill = id => {
return putRequest(`/promotion/seckill/close/${id}`); return putRequest(`/promotion/seckill/close/${id}`);
}; };
// 删除秒杀商品
// 审核限时抢购 export const delSeckillGoods = params => {
return deleteRequest(`/promotion/seckill/apply/${params.seckillId}/${params.id}`);
};
// 审核秒杀活动
export const auditApplySeckill = params => { export const auditApplySeckill = params => {
return putRequest(`/promotion/seckill/apply/audit/${params.ids}`, params); return putRequest(`/promotion/seckill/apply/audit/${params.ids}`, params);
}; };

View File

@ -1,5 +1,7 @@
import axios from 'axios'; import axios from 'axios';
import { getCurrentPermissionList } from '@/api/index'; import {
getCurrentPermissionList
} from '@/api/index';
import lazyLoading from './lazyLoading.js'; import lazyLoading from './lazyLoading.js';
import router from '@/router/index'; import router from '@/router/index';
import Cookies from "js-cookie"; import Cookies from "js-cookie";
@ -9,462 +11,238 @@ let util = {
}; };
util.title = function (title) { util.title = function (title) {
title = title || 'lili 运营后台'; title = title || 'lili 运营后台';
window.document.title = title; window.document.title = title;
}; };
// 判断元素是否存在于数组中
util.millsToTime = function (mills) {
if (!mills) {
return "";
}
let s = mills / 1000;
if (s < 60) {
return s.toFixed(0) + " 秒"
}
let m = s / 60;
if (m < 60) {
return m.toFixed(0) + " 分钟"
}
let h = m / 60;
if (h < 24) {
return h.toFixed(0) + " 小时"
}
let d = h / 24;
if (d < 30) {
return d.toFixed(0) + " 天"
}
let month = d / 30
if (month < 12) {
return month.toFixed(0) + " 个月"
}
let year = month / 12
return year.toFixed(0) + " 年"
};
util.inOf = function (arr, targetArr) {
let res = true;
arr.forEach(item => {
if (targetArr.indexOf(item) < 0) {
res = false;
}
});
return res;
};
util.oneOf = function (ele, targetArr) { util.oneOf = function (ele, targetArr) {
if (targetArr.indexOf(ele) >= 0) { if (targetArr.indexOf(ele) >= 0) {
return true; return true;
} else { } else {
return false; return false;
} }
};
util.getRouterObjByName = function (routers, name) {
if (!name || !routers || !routers.length) {
return null;
}
let routerObj = null;
for (let item of routers) {
if (item.name == name) {
return item;
}
routerObj = util.getRouterObjByName(item.children, name);
if (routerObj) {
return routerObj;
}
}
return null;
};
util.handleTitle = function (vm, item) {
if (typeof item.title == 'object') {
return vm.$t(item.title.i18n);
} else {
return item.title;
}
};
util.setCurrentPath = function (vm, name) {
let title = '';
let isOtherRouter = false;
vm.$store.state.app.routers.forEach(item => {
if (item.children.length == 1) {
if (item.children[0].name == name) {
title = util.handleTitle(vm, item);
if (item.name == 'otherRouter') {
isOtherRouter = true;
}
}
} else {
item.children.forEach(child => {
if (child.name == name) {
title = util.handleTitle(vm, child);
if (item.name == 'otherRouter') {
isOtherRouter = true;
}
}
});
}
});
let currentPathArr = [];
if (name == 'home_index') {
currentPathArr = [
{
title: util.handleTitle(vm, util.getRouterObjByName(vm.$store.state.app.routers, 'home_index')),
path: '',
name: 'home_index'
}
];
} else if ((name.indexOf('_index') >= 0 || isOtherRouter) && name !== 'home_index') {
currentPathArr = [
{
title: util.handleTitle(vm, util.getRouterObjByName(vm.$store.state.app.routers, 'home_index')),
path: '/home',
name: 'home_index'
},
{
title: title,
path: '',
name: name
}
];
} else {
let currentPathObj = vm.$store.state.app.routers.filter(item => {
if (item.children.length <= 1) {
return item.children[0].name == name;
} else {
let i = 0;
let childArr = item.children;
let len = childArr.length;
while (i < len) {
if (childArr[i].name == name) {
return true;
}
i++;
}
return false;
}
})[0];
if (currentPathObj.children.length <= 1 && currentPathObj.name == 'home') {
currentPathArr = [
{
title: '首页',
path: '',
name: 'home_index'
}
];
} else if (currentPathObj.children.length <= 1 && currentPathObj.name !== 'home') {
currentPathArr = [
{
title: '首页',
path: '/home',
name: 'home_index'
},
{
title: currentPathObj.title,
path: '',
name: name
}
];
} else {
let childObj = currentPathObj.children.filter((child) => {
return child.name == name;
})[0];
currentPathArr = [
{
title: '首页',
path: '/home',
name: 'home_index'
},
{
title: currentPathObj.title,
path: '',
name: currentPathObj.name
},
{
title: childObj.title,
path: currentPathObj.path + '/' + childObj.path,
name: name
}
];
}
}
vm.$store.commit('setCurrentPath', currentPathArr);
return currentPathArr;
}; };
// 打开新的页面
util.openNewPage = function (vm, name, argu, query) { util.openNewPage = function (vm, name, argu, query) {
if (!vm.$store) { if (!vm.$store) {
return; return;
} }
let pageOpenedList = vm.$store.state.app.pageOpenedList; let pageOpenedList = vm.$store.state.app.pageOpenedList;
let openedPageLen = pageOpenedList.length; let openedPageLen = pageOpenedList.length;
let i = 0; let i = 0;
let tagHasOpened = false; let tagHasOpened = false;
while (i < openedPageLen) { while (i < openedPageLen) {
if (name == pageOpenedList[i].name) { // 页面已经打开 if (name == pageOpenedList[i].name) { // 页面已经打开
vm.$store.commit('pageOpenedList', { vm.$store.commit('pageOpenedList', {
index: i, index: i,
argu: argu, argu: argu,
query: query query: query
}); });
tagHasOpened = true; tagHasOpened = true;
break; break;
} }
i++; i++;
} }
if (!tagHasOpened) { if (!tagHasOpened) {
let tag = vm.$store.state.app.tagsList.filter((item) => { let tag = vm.$store.state.app.tagsList.filter((item) => {
if (item.children) { if (item.children) {
return name == item.children[0].name; return name == item.children[0].name;
} else { } else {
return name == item.name; return name == item.name;
}
});
tag = tag[0];
if (tag) {
tag = tag.children ? tag.children[0] : tag;
if (argu) {
tag.argu = argu;
}
if (query) {
tag.query = query;
}
vm.$store.commit('increateTag', tag);
} }
});
tag = tag[0];
if (tag) {
tag = tag.children ? tag.children[0] : tag;
if (argu) {
tag.argu = argu;
}
if (query) {
tag.query = query;
}
vm.$store.commit('increateTag', tag);
}
} }
vm.$store.commit('setCurrentPageName', name);
}; };
util.toDefaultPage = function (routers, name, route, next) { util.toDefaultPage = function (routers, name, route, next) {
let len = routers.length; let len = routers.length;
let i = 0; let i = 0;
let notHandle = true; let notHandle = true;
while (i < len) { while (i < len) {
if (routers[i].name == name && routers[i].children && routers[i].redirect == undefined) { if (routers[i].name == name && routers[i].children && routers[i].redirect == undefined) {
route.replace({ route.replace({
name: routers[i].children[0].name name: routers[i].children[0].name
}); });
notHandle = false; notHandle = false;
next(); next();
break; break;
}
i++;
}
if (notHandle) {
next();
} }
i++;
}
if (notHandle) {
next();
}
}; };
// 将Csv文件解析为二维数组
export const getArrayFromFile = (file) => {
let nameSplit = file.name.split('.')
let format = nameSplit[nameSplit.length - 1]
return new Promise((resolve, reject) => {
let reader = new FileReader()
reader.readAsText(file) // 以文本格式读取
let arr = []
reader.onload = function (evt) {
let data = evt.target.result // 读到的数据
let pasteData = data.trim()
arr = pasteData.split((/[\n\u0085\u2028\u2029]|\r\n?/g)).map(row => {
return row.split('\t')
}).map(item => {
return item[0].split(',')
})
if (format == 'csv') resolve(arr)
else reject(new Error('[Format Error]:不是Csv文件'))
}
})
}
// 将二维数组转为表格数据
export const getTableDataFromArray = (array) => {
let columns = []
let tableData = []
if (array.length > 1) {
let titles = array.shift()
columns = titles.map(item => {
return {
title: item,
key: item
}
})
tableData = array.map(item => {
let res = {}
item.forEach((col, i) => {
res[titles[i]] = col
})
return res
})
}
return {
columns,
tableData
}
}
util.initRouter = function (vm) { // 初始化路由 util.initRouter = function (vm) { // 初始化路由
const constRoutes = []; const constRoutes = [];
const otherRoutes = []; const otherRoutes = [];
// 404路由需要和动态路由一起加载 // 404路由需要和动态路由一起加载
const otherRouter = [{ const otherRouter = [{
path: '/*', path: '/*',
name: 'error-404', name: 'error-404',
meta: { meta: {
title: '404-页面不存在' title: '404-页面不存在'
}, },
frontRoute: 'error-page/404' frontRoute: 'error-page/404'
}]; }];
// 判断用户是否登录 // 判断用户是否登录
let userInfo = Cookies.get('userInfoManager') let userInfo = Cookies.get('userInfoManager')
if (!userInfo) { if (!userInfo) {
// 未登录 // 未登录
return; return;
} }
if (!vm.$store.state.app.added) { if (!vm.$store.state.app.added) {
// 第一次加载 读取数据 // 第一次加载 读取数据
// 加载菜单 // 加载菜单
getCurrentPermissionList().then(res => { getCurrentPermissionList().then(res => {
if (!res.success) return false; if (!res.success) return false;
let menuData = res.result; let menuData = res.result;
// 格式化数据,设置 空children 为 null // 格式化数据,设置 空children 为 null
for(let i =0;i<menuData.length;i++){ for (let i = 0; i < menuData.length; i++) {
let t = menuData[i].children let t = menuData[i].children
for(let k = 0;k<t.length;k++){ for (let k = 0; k < t.length; k++) {
let tt = t[k].children; let tt = t[k].children;
for(let z = 0;z<tt.length;z++){ for (let z = 0; z < tt.length; z++) {
tt[z].children = null tt[z].children = null
// 给所有三级路由添加字段显示一级菜单name方便点击页签时的选中筛选 // 给所有三级路由添加字段显示一级菜单name方便点击页签时的选中筛选
tt[z].firstRouterName = menuData[i].name tt[z].firstRouterName = menuData[i].name
} }
}
}
if (!menuData) {
return;
}
util.initAllMenuData(constRoutes, menuData);
util.initRouterNode(otherRoutes, otherRouter);
// 添加所有主界面路由
vm.$store.commit('updateAppRouter', constRoutes.filter(item => item.children.length > 0));
// 添加全局路由
vm.$store.commit('updateDefaultRouter', otherRoutes);
// 添加菜单路由
util.initMenuData(vm, menuData);
// 缓存数据 修改加载标识
window.localStorage.setItem('menuData', JSON.stringify(menuData));
vm.$store.commit('setAdded', true);
});
} else {
// 读取缓存数据
let data = window.localStorage.getItem('menuData');
if (!data) {
vm.$store.commit('setAdded', false);
return;
} }
let menuData = JSON.parse(data); }
// 添加菜单路由
util.initMenuData(vm, menuData); if (!menuData) {
return;
}
util.initAllMenuData(constRoutes, menuData);
util.initRouterNode(otherRoutes, otherRouter);
// 添加所有主界面路由
vm.$store.commit('updateAppRouter', constRoutes.filter(item => item.children.length > 0));
// 添加全局路由
vm.$store.commit('updateDefaultRouter', otherRoutes);
// 添加菜单路由
util.initMenuData(vm, menuData);
// 缓存数据 修改加载标识
window.localStorage.setItem('menuData', JSON.stringify(menuData));
vm.$store.commit('setAdded', true);
});
} else {
// 读取缓存数据
let data = window.localStorage.getItem('menuData');
if (!data) {
vm.$store.commit('setAdded', false);
return;
} }
let menuData = JSON.parse(data);
// 添加菜单路由
util.initMenuData(vm, menuData);
}
}; };
// 添加所有顶部导航栏下的菜单路由 // 添加所有顶部导航栏下的菜单路由
util.initAllMenuData = function (constRoutes, data) { util.initAllMenuData = function (constRoutes, data) {
let allMenuData = []; let allMenuData = [];
data.forEach(e => { data.forEach(e => {
if (e.level == 0) { if (e.level == 0) {
e.children.forEach(item => { e.children.forEach(item => {
allMenuData.push(item); allMenuData.push(item);
}) })
} }
}) })
util.initRouterNode(constRoutes, allMenuData); util.initRouterNode(constRoutes, allMenuData);
} }
// 生成菜单格式数据 // 生成菜单格式数据
util.initMenuData = function (vm, data) { util.initMenuData = function (vm, data) {
const menuRoutes = []; const menuRoutes = [];
let menuData = data; let menuData = data;
// 顶部菜单 // 顶部菜单
let navList = []; let navList = [];
menuData.forEach(e => { menuData.forEach(e => {
let nav = { let nav = {
name: e.name, name: e.name,
title: e.title title: e.title
}
navList.push(nav);
})
if (navList.length < 1) {
return;
} }
// 存入vuex navList.push(nav);
vm.$store.commit('setNavList', navList); })
let currNav = window.localStorage.getItem('currNav') if (navList.length < 1) {
if (currNav) { return;
// 读取缓存title }
for (var item of navList) { // 存入vuex
if (item.name == currNav) { vm.$store.commit('setNavList', navList);
vm.$store.commit('setCurrNavTitle', item.title); let currNav = window.localStorage.getItem('currNav')
break; if (currNav) {
} // 读取缓存title
} for (var item of navList) {
} else { if (item.name == currNav) {
// 默认第一个 vm.$store.commit('setCurrNavTitle', item.title);
currNav = navList[0].name; break;
vm.$store.commit('setCurrNavTitle', navList[0].title); }
} }
vm.$store.commit('setCurrNav', currNav); } else {
for (let item of menuData) { // 默认第一个
if (item.name == currNav) { currNav = navList[0].name;
// 过滤 vm.$store.commit('setCurrNavTitle', navList[0].title);
menuData = item.children; }
break; vm.$store.commit('setCurrNav', currNav);
} for (let item of menuData) {
if (item.name == currNav) {
// 过滤
menuData = item.children;
break;
} }
util.initRouterNode(menuRoutes, menuData); }
// 刷新界面菜单 util.initRouterNode(menuRoutes, menuData);
vm.$store.commit('updateMenulist', menuRoutes.filter(item => item.children.length > 0)); // 刷新界面菜单
vm.$store.commit('updateMenulist', menuRoutes.filter(item => item.children.length > 0));
let tagsList = []; let tagsList = [];
vm.$store.state.app.routers.map((item) => { vm.$store.state.app.routers.map((item) => {
if (item.children.length <= 1) { if (item.children.length <= 1) {
tagsList.push(item.children[0]); tagsList.push(item.children[0]);
} else { } else {
tagsList.push(...item.children); tagsList.push(...item.children);
} }
}); });
vm.$store.commit('setTagsList', tagsList); vm.$store.commit('setTagsList', tagsList);
}; };
// 生成路由节点 // 生成路由节点
util.initRouterNode = function (routers, data) { // data为所有子菜单数据 util.initRouterNode = function (routers, data) { // data为所有子菜单数据
for (let item of data) { for (let item of data) {
let menu = Object.assign({}, item); let menu = Object.assign({}, item);
menu.component = lazyLoading(menu.frontRoute); menu.component = lazyLoading(menu.frontRoute);
if (item.children && item.children.length > 0) { if (item.children && item.children.length > 0) {
menu.children = []; menu.children = [];
util.initRouterNode(menu.children, item.children); util.initRouterNode(menu.children, item.children);
}
let meta = {};
// 给页面添加权限、标题、第三方网页链接
meta.permTypes = menu.permTypes ? menu.permTypes : null;
meta.title = menu.title ? menu.title + " - lilishop 运营后台" : null;
meta.url = menu.url ? menu.url : null;
meta.firstRouterName = item.firstRouterName
menu.meta = meta;
routers.push(menu);
} }
let meta = {};
// 给页面添加标题、父级菜单name方便左侧菜单选中
meta.title = menu.title ? menu.title + " - lilishop 运营后台" : null;
meta.firstRouterName = item.firstRouterName
menu.meta = meta;
routers.push(menu);
}
}; };
export default util; export default util;

View File

@ -1,154 +1,140 @@
import { otherRouter } from '@/router/router'; import {
import { router } from '@/router/index'; otherRouter
} from '@/router/router';
import {
router
} from '@/router/index';
import Util from '@/libs/util'; import Util from '@/libs/util';
import Vue from 'vue'; import Vue from 'vue';
const app = { const app = {
state: { state: {
styleStore:"", //移动端楼层装修中选择风格存储 styleStore: "", // 移动端楼层装修中选择风格存储
loading: false, // 全局加载动画 added: false, // 加载路由标识
added: false, // 加载路由标识 navList: [], // 顶部菜单
navList: [], // 顶部菜单 currNav: "", // 当前顶部菜单name
currNav: "", // 当前顶部菜单name currNavTitle: "", // 当前顶部菜单标题
currNavTitle: "", // 当前顶部菜单标题 cachePage: [],
cachePage: [], lang: '',
lang: '', pageOpenedList: [{ // 打开过的页面,顶部历史菜单项
pageOpenedList: [{ // 打开过的页面,顶部历史菜单项 title: '首页',
title: '首页', path: '',
path: '', name: 'home_index'
name: 'home_index' }],
}], // 面包屑数组 左侧菜单
currentPageName: '', menuList: [],
currentPath: [ tagsList: [...otherRouter.children], //这块是面包屑的内容不能删除
{ routers: [otherRouter],
title: '首页', messageCount: 0,
path: '', // 在这里定义你不想要缓存的页面的name属性值(参见路由配置router.js)
name: 'home_index' dontCache: ['test', 'test']
} },
], mutations: {
// 面包屑数组 左侧菜单 // 动态添加主界面路由,需要缓存
menuList: [], updateAppRouter(state, routes) {
tagsList: [...otherRouter.children], //这块是面包屑的内容不能删除 state.routers.push(...routes);
routers: [otherRouter], router.addRoutes(routes);
messageCount: 0,
// 在这里定义你不想要缓存的页面的name属性值(参见路由配置router.js)
dontCache: ['test', 'test']
}, },
mutations: { // 动态添加全局路由404、500等页面不需要缓存
// 动态添加主界面路由,需要缓存 updateDefaultRouter(state, routes) {
updateAppRouter(state, routes) { router.addRoutes(routes);
state.routers.push(...routes); },
router.addRoutes(routes); setAdded(state, v) {
}, state.added = v;
// 动态添加全局路由404、500等页面不需要缓存 },
updateDefaultRouter(state, routes) { setNavList(state, list) {
router.addRoutes(routes); state.navList = list;
}, },
setLoading(state, v) { setCurrNav(state, v) {
state.loading = v; state.currNav = v;
}, },
setAdded(state, v) { setCurrNavTitle(state, v) {
state.added = v; state.currNavTitle = v;
}, },
setNavList(state, list) { setTagsList(state, list) {
state.navList = list; state.tagsList.push(...list);
}, },
setCurrNav(state, v) { updateMenulist(state, routes) {
state.currNav = v; state.menuList = routes;
}, },
setCurrNavTitle(state, v) { closePage(state, name) {
state.currNavTitle = v; state.cachePage.forEach((item, index) => {
}, if (item == name) {
setTagsList(state, list) { state.cachePage.splice(index, 1);
state.tagsList.push(...list);
},
updateMenulist(state, routes) {
state.menuList = routes;
},
closePage(state, name) {
state.cachePage.forEach((item, index) => {
if (item == name) {
state.cachePage.splice(index, 1);
}
});
},
initCachePage(state) {
if (localStorage.cachePage) {
state.cachePage = JSON.parse(localStorage.cachePage);
}
},
removeTag(state, name) {
state.pageOpenedList.map((item, index) => {
if (item.name == name) {
state.pageOpenedList.splice(index, 1);
}
});
},
pageOpenedList(state, get) {
let openedPage = state.pageOpenedList[get.index];
if (get.argu) {
openedPage.argu = get.argu;
}
if (get.query) {
openedPage.query = get.query;
}
state.pageOpenedList.splice(get.index, 1, openedPage);
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
},
clearAllTags(state) {
state.pageOpenedList.splice(1);
state.cachePage.length = 0;
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
},
clearOtherTags(state, vm) {
let currentName = vm.$route.name;
let currentIndex = 0;
state.pageOpenedList.forEach((item, index) => {
if (item.name == currentName) {
currentIndex = index;
}
});
if (currentIndex == 0) {
state.pageOpenedList.splice(1);
} else {
state.pageOpenedList.splice(currentIndex + 1);
state.pageOpenedList.splice(1, currentIndex - 1);
}
let newCachepage = state.cachePage.filter(item => {
return item == currentName;
});
state.cachePage = newCachepage;
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
},
setOpenedList(state) {
state.pageOpenedList = localStorage.pageOpenedList ? JSON.parse(localStorage.pageOpenedList) : [otherRouter.children[0]];
},
setCurrentPath(state, pathArr) {
state.currentPath = pathArr;
},
setCurrentPageName(state, name) {
state.currentPageName = name;
},
setAvatarPath(state, path) {
localStorage.avatorImgPath = path;
},
switchLang(state, lang) {
state.lang = lang;
localStorage.lang = lang;
Vue.config.lang = lang;
},
setMessageCount(state, count) {
state.messageCount = count;
},
increateTag(state, tagObj) {
if (!Util.oneOf(tagObj.name, state.dontCache)) {
state.cachePage.push(tagObj.name);
localStorage.cachePage = JSON.stringify(state.cachePage);
}
state.pageOpenedList.push(tagObj);
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
} }
});
},
initCachePage(state) {
if (localStorage.cachePage) {
state.cachePage = JSON.parse(localStorage.cachePage);
}
},
removeTag(state, name) {
state.pageOpenedList.map((item, index) => {
if (item.name == name) {
state.pageOpenedList.splice(index, 1);
}
});
},
pageOpenedList(state, get) {
let openedPage = state.pageOpenedList[get.index];
if (get.argu) {
openedPage.argu = get.argu;
}
if (get.query) {
openedPage.query = get.query;
}
state.pageOpenedList.splice(get.index, 1, openedPage);
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
},
clearAllTags(state) {
state.pageOpenedList.splice(1);
state.cachePage.length = 0;
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
},
clearOtherTags(state, vm) {
let currentName = vm.$route.name;
let currentIndex = 0;
state.pageOpenedList.forEach((item, index) => {
if (item.name == currentName) {
currentIndex = index;
}
});
if (currentIndex == 0) {
state.pageOpenedList.splice(1);
} else {
state.pageOpenedList.splice(currentIndex + 1);
state.pageOpenedList.splice(1, currentIndex - 1);
}
let newCachepage = state.cachePage.filter(item => {
return item == currentName;
});
state.cachePage = newCachepage;
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
},
setOpenedList(state) {
state.pageOpenedList = localStorage.pageOpenedList ? JSON.parse(localStorage.pageOpenedList) : [otherRouter.children[0]];
},
setAvatarPath(state, path) {
localStorage.avatorImgPath = path;
},
switchLang(state, lang) {
state.lang = lang;
localStorage.lang = lang;
Vue.config.lang = lang;
},
setMessageCount(state, count) {
state.messageCount = count;
},
increateTag(state, tagObj) {
if (!Util.oneOf(tagObj.name, state.dontCache)) {
state.cachePage.push(tagObj.name);
localStorage.cachePage = JSON.stringify(state.cachePage);
}
state.pageOpenedList.push(tagObj);
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
} }
}
}; };
export default app; export default app;

View File

@ -132,6 +132,7 @@ export default {
// 退 // 退
else if (name === "loginOut") { else if (name === "loginOut") {
this.$store.commit("logout", this); this.$store.commit("logout", this);
this.$store.commit('setAdded', false);
this.setStore("accessToken", ""); this.setStore("accessToken", "");
this.setStore("refreshToken", ""); this.setStore("refreshToken", "");
this.$router.push({ path: "/login" }); this.$router.push({ path: "/login" });
@ -167,7 +168,6 @@ export default {
}, },
watch: { watch: {
$route(to, from) { $route(to, from) {
this.$store.commit("setCurrentPageName", to.name);
this.checkTag(to.name); this.checkTag(to.name);
localStorage.currentPageName = to.name; localStorage.currentPageName = to.name;
} }

View File

@ -115,7 +115,7 @@ export default {
item.selected = false; item.selected = false;
item.___type = "goods"; //goodspc wap item.___type = "goods"; //goodspc wap
this.selectedWay.forEach(e => { this.selectedWay.forEach(e => {
if (e.id === item.id) { if (e.id && e.id === item.id) {
item.selected = true item.selected = true
} }
}) })

View File

@ -3,11 +3,7 @@
<template v-if="flag"> <template v-if="flag">
<goodsDialog @selected="(val) => {goodsData = val;}" <goodsDialog @selected="(val) => {goodsData = val;}"
v-if="goodsFlag" ref="goodsDialog" :selectedWay='goodsData'/> v-if="goodsFlag" ref="goodsDialog" :selectedWay='goodsData'/>
<linkDialog @selectedLink=" <linkDialog @selectedLink="(val) => { linkData = val; }" v-else class="linkDialog" />
(val) => {
linkData = val;
}
" v-else class="linkDialog" />
</template> </template>
</Modal> </Modal>
</template> </template>

View File

@ -9,103 +9,47 @@
<Tag v-for="item in unixHours(row.hours)" :key="item">{{ item }}</Tag> <Tag v-for="item in unixHours(row.hours)" :key="item">{{ item }}</Tag>
</template> </template>
</Table> </Table>
<Table
:loading="loading"
border
class="operation"
:columns="goodsColumns"
:data="goodsList"
ref="table"
>
<template slot-scope="{ row }" slot="originalPrice">
<div>{{ row.originalPrice | unitPrice("¥") }}</div>
</template>
<Row class="operation"> <template slot-scope="{ row }" slot="quantity">
<Button @click="auditAll"></Button> <div>{{ row.quantity }}</div>
<Button </template>
type="dashed"
@click="
() => {
openTip = !openTip;
}
"
>{{ openTip ? "关闭提示" : "开启提示" }}
</Button
>
</Row>
<Row v-show="openTip">
<Alert show-icon>
已选择 <span class="select-count">{{ selectCount }}</span>
<a class="select-clear" @click="clearSelectAll"></a>
</Alert>
</Row>
<Table
:loading="loading"
border
class="operation"
:columns="goodsColumns"
:data="goodsList"
ref="table"
sortable="custom"
@on-selection-change="changeSelect"
>
<template slot-scope="{ row }" slot="originalPrice">
<div>{{ row.originalPrice | unitPrice("¥") }}</div>
</template>
<template slot-scope="{ row }" slot="quantity"> <template slot-scope="{ row }" slot="price">
<div>{{ row.quantity }}</div> <div>{{ row.price | unitPrice("¥") }}</div>
</template> </template>
<template slot-scope="{ row }" slot="price"> <template slot-scope="{ row }" slot="time">
<div>{{ row.price | unitPrice("¥") }}</div> <Tag>{{ row.timeLine + ":00" }}</Tag>
</template> </template>
<template slot-scope="{ row }" slot="QRCode">
<template slot-scope="{ row }" slot="promotionApplyStatus"> <img
<Badge v-if="row.QRCode"
status="success" :src="row.QRCode || '../../../assets/lili.png'"
v-if="row.promotionApplyStatus == 'PASS'" width="50px"
:text="promotionApplyStatus(row.promotionApplyStatus)" height="50px"
/> alt=""
<Badge />
status="blue" </template>
v-if="row.promotionApplyStatus == 'APPLY'" <template slot-scope="{ row, index }" slot="action">
:text="promotionApplyStatus(row.promotionApplyStatus)" <Button
/> type="error"
<Badge size="small"
status="error" @click="delGoods(index,row)"
v-if="row.promotionApplyStatus == 'REFUSE'" >删除
:text="promotionApplyStatus(row.promotionApplyStatus)" </Button>
/> </template>
<span </Table>
v-if="row.promotionApplyStatus == 'REFUSE'"
@click="showReason(row.failReason)"
class="reason"
>拒绝原因</span
>
</template>
<template slot-scope="{ row }" slot="time">
<Tag>{{ row.timeLine + ":00" }}</Tag>
</template>
<template slot-scope="{ row }" slot="QRCode">
<img
v-if="row.QRCode"
:src="row.QRCode || '../../../assets/lili.png'"
width="50px"
height="50px"
alt=""
/>
</template>
<template slot-scope="{ row }" slot="action">
<Button
type="success"
size="small"
style="margin-right: 10px"
:disabled="row.promotionApplyStatus != 'APPLY'"
@click="pass(row)"
>通过
</Button
>
<Button
type="error"
size="small"
:disabled="row.promotionApplyStatus != 'APPLY'"
@click="refuse(row)"
>拒绝
</Button
>
</template>
</Table>
<Row type="flex" justify="end" class="mt_10"> <Row type="flex" justify="end" class="mt_10">
<Page <Page
:current="searchForm.pageNumber + 1" :current="searchForm.pageNumber + 1"
@ -121,40 +65,6 @@
></Page> ></Page>
</Row> </Row>
</Card> </Card>
<Modal v-model="showModal" title="审核商品">
<Form ref="form" :model="params" :rules="rules">
<FormItem label="审核状态">
<RadioGroup v-model="params.applyStatus" type="button" button-style="solid">
<Radio label="PASS">通过</Radio>
<Radio label="REFUSE">拒绝</Radio>
</RadioGroup>
</FormItem>
<FormItem
label="拒绝原因"
prop="failReason"
v-if="params.applyStatus == 'REFUSE'"
>
<Input
type="textarea"
v-model="params.failReason"
maxlength="50"
style="width: 260px"
show-word-limit
/>
</FormItem>
</Form>
<div slot="footer">
<Button size="small" @click="showModal = false">取消</Button>
<Button
size="small"
type="primary"
:loading="submitLoading"
@click="sureAudit"
>确定
</Button
>
</div>
</Modal>
</div> </div>
</template> </template>
<script> <script>
@ -162,6 +72,7 @@
seckillGoodsList, seckillGoodsList,
seckillDetail, seckillDetail,
auditApplySeckill, auditApplySeckill,
delSeckillGoods
} from "@/api/promotion.js"; } from "@/api/promotion.js";
export default { export default {
@ -246,7 +157,6 @@
}, },
], ],
goodsColumns: [ // goodsColumns: [ //
{type: "selection", width: 60, align: "center"},
{ {
title: "商品名称", title: "商品名称",
key: "goodsName", key: "goodsName",
@ -281,13 +191,11 @@
width: 100, width: 100,
slot: "time", slot: "time",
}, },
{ // {
title: "状态", // title: "",
slot: "promotionApplyStatus", // slot: "promotionApplyStatus",
minWidth: 30, // width: 90,
width: 90, // },
},
{ {
title: "操作", title: "操作",
slot: "action", slot: "action",
@ -328,16 +236,6 @@
clearSelectAll() { clearSelectAll() {
this.$refs.table.selectAll(false); this.$refs.table.selectAll(false);
}, },
changeSelect(e) {
//
this.selectList = e;
this.selectCount = e.length;
let ids = [];
this.selectList.forEach((item) => {
ids.push(e.id);
});
this.params.ids = ids.toString();
},
getDataList() { getDataList() {
// //
@ -363,11 +261,25 @@
} }
}); });
}, },
delGoods(index) { delGoods(index, row) {
// //
this.goodsList.list.splice(index, 1); this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除该商品吗?删除后不可恢复",
onOk: () => {
const params = {
seckillId: row.seckillId,
id: row.id
}
delSeckillGoods(params).then(res => {
if (res.success) {
this.goodsList.splice(index, 1);
this.$Message.success("删除成功!");
}
})
},
});
}, },
unixDate(time) { unixDate(time) {
// //
return this.$options.filters.unixToDate(new Date(time) / 1000); return this.$options.filters.unixToDate(new Date(time) / 1000);
@ -379,87 +291,7 @@
hourArr[i] += ":00"; hourArr[i] += ":00";
} }
return hourArr; return hourArr;
}, }
//
promotionApplyStatus(key) {
switch (key) {
case "APPLY":
return "申请";
case "PASS":
return "通过";
case "REFUSE":
return "拒绝";
}
},
pass(row) {
//
let params = {
seckillId: this.$route.query.id,
applyStatus: "PASS",
failReason: "",
ids: row.id,
};
auditApplySeckill(params).then((res) => {
if (res && res.success) {
this.$Message.success("已通过该商品审核");
this.getDataList();
}
});
},
refuse(row) {
//
this.params.applyStatus = "REFUSE";
this.selectList.push(row);
this.showModal = true;
},
auditAll() {
//
if (this.selectCount <= 0) {
this.$Message.warning("您还未选择要审核的商品");
return;
}
this.showModal = true;
},
//
sureAudit() {
this.selectCount = this.selectList.length;
//
if (this.selectCount <= 0) {
this.$Message.warning("您还未选择要审核的商品");
return;
}
this.params.ids = this.selectList
.filter((i) => i.promotionApplyStatus === "APPLY")
.map((i) => i.id);
if (this.params.ids.length <= 0) {
this.$Message.warning("当前没有可审核的商品");
return;
}
if (
this.params.applyStatus == "REFUSE" &&
this.params.failReason === ""
) {
this.$Message.warning("审核拒绝理由不能为空");
return;
}
this.submitLoading = true;
auditApplySeckill(this.params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.showModal = false;
this.$Message.success("审核成功");
this.selectList = [];
this.getDataList();
}
});
},
//
showReason(reason) {
this.$Modal.info({
title: "拒绝原因",
content: reason,
});
},
}, },
mounted() { mounted() {
this.init(); this.init();

View File

@ -68,8 +68,8 @@
<p class="item"> <p class="item">
<span class="label">公司地址</span> <span class="label">公司地址</span>
<span class="info"> <span class="info">
{{storeInfo.companyAddressPath || storeInfo.companyAddress?storeInfo.companyAddressPath + ' '+storeInfo.companyAddress:"暂未完善"}} {{storeInfo.companyAddressPath || storeInfo.companyAddress?storeInfo.companyAddressPath + ' '+storeInfo.companyAddress:"暂未完善"}}
</span> </span>
</p> </p>
</div> </div>

View File

@ -228,7 +228,7 @@ import {
searchPermission, searchPermission,
} from "@/api/index"; } from "@/api/index";
import util from "@/libs/util.js"; import util from "@/libs/util.js";
import Cookies from "js-cookie";
export default { export default {
name: "menu-manage", name: "menu-manage",
data() { data() {
@ -486,7 +486,7 @@ export default {
if (res.success) { if (res.success) {
this.$Message.success("编辑成功"); this.$Message.success("编辑成功");
// //
this.$store.commit("setAdded", false); this.$store.commit('setAdded', false);
util.initRouter(this); util.initRouter(this);
this.init(); this.init();
this.menuModalVisible = false; this.menuModalVisible = false;
@ -506,7 +506,7 @@ export default {
if (res.success) { if (res.success) {
this.$Message.success("添加成功"); this.$Message.success("添加成功");
// //
this.$store.commit("setAdded", false); this.$store.commit('setAdded', false);
util.initRouter(this); util.initRouter(this);
this.init(); this.init();
this.menuModalVisible = false; this.menuModalVisible = false;
@ -579,7 +579,7 @@ export default {
if (res.success) { if (res.success) {
this.$Message.success("删除成功"); this.$Message.success("删除成功");
// //
this.$store.commit("setAdded", false); this.$store.commit('setAdded', false);
util.initRouter(this); util.initRouter(this);
this.selectList = []; this.selectList = [];
this.selectCount = 0; this.selectCount = 0;

View File

@ -111,7 +111,7 @@ import {
saveRoleMenu, saveRoleMenu,
} from "@/api/index"; } from "@/api/index";
import util from "@/libs/util.js"; import util from "@/libs/util.js";
import Cookies from "js-cookie";
export default { export default {
name: "role-manage", name: "role-manage",
data() { data() {
@ -597,7 +597,7 @@ export default {
if (res.success) { if (res.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
// //
this.$store.commit("setAdded", false); this.$store.commit('setAdded', false);
util.initRouter(this); util.initRouter(this);
this.getRoleList(); this.getRoleList();
this.permModalVisible = false; this.permModalVisible = false;

View File

@ -150,7 +150,10 @@ export const removeSeckillGoods = (seckillId, ids) => {
export const seckillDetail = (seckillId) => { export const seckillDetail = (seckillId) => {
return getRequest(`/promotion/seckill/${seckillId}`) return getRequest(`/promotion/seckill/${seckillId}`)
} }
// 删除秒杀商品
export const delSeckillGoods = params => {
return deleteRequest(`/promotion/seckill/apply/${params.seckillId}/${params.id}`);
};
// 满减满赠活动列表 // 满减满赠活动列表
export const getFullDiscountList = (params) => { export const getFullDiscountList = (params) => {
return getRequest(`/promotion/fullDiscount`,params) return getRequest(`/promotion/fullDiscount`,params)

View File

@ -13,7 +13,7 @@
<Row class="operation"> <Row class="operation">
<template v-if="promotionStatus == 'NEW'"> <template v-if="promotionStatus == 'NEW'">
<Button type="primary" @click="openSkuList"></Button> <Button type="primary" @click="openSkuList"></Button>
<Button @click="delAll"></Button> <!-- <Button @click="delAll"></Button> -->
</template> </template>
</Row> </Row>
<Row class="operation"> <Row class="operation">
@ -98,7 +98,7 @@
v-if="promotionStatus === 'NEW'" v-if="promotionStatus === 'NEW'"
size="small" size="small"
ghost ghost
@click="delGoods(index, row.id)" @click="delGoods(index, row)"
>删除</Button >删除</Button
> >
</template> </template>
@ -130,6 +130,7 @@ import {
seckillGoodsList, seckillGoodsList,
seckillDetail, seckillDetail,
setSeckillGoods, setSeckillGoods,
delSeckillGoods
} from "@/api/promotion.js"; } from "@/api/promotion.js";
import skuSelect from "@/views/lili-dialog"; import skuSelect from "@/views/lili-dialog";
export default { export default {
@ -170,7 +171,6 @@ export default {
}, },
], ],
goodsColumns: [ goodsColumns: [
{ type: "selection", width: 60, align: "center" },
{ {
title: "商品名称", title: "商品名称",
key: "goodsName", key: "goodsName",
@ -245,8 +245,8 @@ export default {
clearSelectAll() { clearSelectAll() {
this.$refs.table.selectAll(false); this.$refs.table.selectAll(false);
}, },
//
changeSelect(e) { changeSelect(e) {
//
this.selectList = e; this.selectList = e;
this.selectCount = e.length; this.selectCount = e.length;
}, },
@ -255,7 +255,6 @@ export default {
// //
this.loading = true; this.loading = true;
this.searchForm.seckillId = this.$route.query.id; this.searchForm.seckillId = this.$route.query.id;
// 1:00 // 1:00
let hours = this.unixHours(this.data[0].hours); let hours = this.unixHours(this.data[0].hours);
hours.forEach((e) => { hours.forEach((e) => {
@ -294,33 +293,23 @@ export default {
} }
}); });
}, },
delGoods(index) { delGoods(index, row) {
// //
this.goodsList[this.tabIndex].list.splice(index, 1); if (row.promotionApplyStatus === 'PASS') {
this.$Message.success("删除成功!"); const params = {
}, seckillId: row.seckillId,
delAll() { // id: row.id
if (this.selectCount <= 0) { }
this.$Message.warning("您还未选择要删除的数据"); delSeckillGoods(params).then(res => {
return; if (res.success) {
this.goodsList[this.tabIndex].list.splice(index, 1);
this.$Message.success("删除成功!");
}
})
} else {
this.goodsList[this.tabIndex].list.splice(index, 1);
this.$Message.success("删除成功!");
} }
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
onOk: () => {
let ids = [];
this.selectList.forEach(function (e) {
if (e.promotionApplyStatus !== 'PASS') {
ids.push(e.id);
}
});
this.goodsList[this.tabIndex].list = this.goodsList[
this.tabIndex
].list.filter((item) => {
return !ids.includes(item.id);
});
},
});
}, },
selectedGoodsData(item) { selectedGoodsData(item) {
// //