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

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">
<Table stripe :columns="goodsColumns" :data="goodsData.records">
<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 slot-scope="{ row }" slot="price">
<span> {{ row.price | unitPrice }}</span>
@ -66,7 +66,7 @@
<TabPane label="未选商品" name="goodsUncheck">
<Table stripe :columns="goodsColumns" :data="goodsData.records">
<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 slot-scope="{ row }" slot="price">
<span> {{ row.price | unitPrice }}</span>
@ -289,7 +289,7 @@ export default {
})
},
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.qrcodeShow = true;
},

View File

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

View File

@ -1,5 +1,7 @@
import axios from 'axios';
import { getCurrentPermissionList } from '@/api/index';
import {
getCurrentPermissionList
} from '@/api/index';
import lazyLoading from './lazyLoading.js';
import router from '@/router/index';
import Cookies from "js-cookie";
@ -9,462 +11,238 @@ let util = {
};
util.title = function (title) {
title = title || 'lili 运营后台';
window.document.title = title;
title = title || 'lili 运营后台';
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) {
if (targetArr.indexOf(ele) >= 0) {
return true;
} else {
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;
if (targetArr.indexOf(ele) >= 0) {
return true;
} else {
return false;
}
};
// 打开新的页面
util.openNewPage = function (vm, name, argu, query) {
if (!vm.$store) {
return;
return;
}
let pageOpenedList = vm.$store.state.app.pageOpenedList;
let openedPageLen = pageOpenedList.length;
let i = 0;
let tagHasOpened = false;
while (i < openedPageLen) {
if (name == pageOpenedList[i].name) { // 页面已经打开
vm.$store.commit('pageOpenedList', {
index: i,
argu: argu,
query: query
});
tagHasOpened = true;
break;
}
i++;
if (name == pageOpenedList[i].name) { // 页面已经打开
vm.$store.commit('pageOpenedList', {
index: i,
argu: argu,
query: query
});
tagHasOpened = true;
break;
}
i++;
}
if (!tagHasOpened) {
let tag = vm.$store.state.app.tagsList.filter((item) => {
if (item.children) {
return name == item.children[0].name;
} else {
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);
let tag = vm.$store.state.app.tagsList.filter((item) => {
if (item.children) {
return name == item.children[0].name;
} else {
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);
}
}
vm.$store.commit('setCurrentPageName', name);
};
util.toDefaultPage = function (routers, name, route, next) {
let len = routers.length;
let i = 0;
let notHandle = true;
while (i < len) {
if (routers[i].name == name && routers[i].children && routers[i].redirect == undefined) {
route.replace({
name: routers[i].children[0].name
});
notHandle = false;
next();
break;
}
i++;
}
if (notHandle) {
next();
let len = routers.length;
let i = 0;
let notHandle = true;
while (i < len) {
if (routers[i].name == name && routers[i].children && routers[i].redirect == undefined) {
route.replace({
name: routers[i].children[0].name
});
notHandle = false;
next();
break;
}
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) { // 初始化路由
const constRoutes = [];
const otherRoutes = [];
const constRoutes = [];
const otherRoutes = [];
// 404路由需要和动态路由一起加载
const otherRouter = [{
path: '/*',
name: 'error-404',
meta: {
title: '404-页面不存在'
},
frontRoute: 'error-page/404'
}];
// 判断用户是否登录
let userInfo = Cookies.get('userInfoManager')
if (!userInfo) {
// 未登录
return;
}
if (!vm.$store.state.app.added) {
// 第一次加载 读取数据
// 加载菜单
getCurrentPermissionList().then(res => {
if (!res.success) return false;
let menuData = res.result;
// 404路由需要和动态路由一起加载
const otherRouter = [{
path: '/*',
name: 'error-404',
meta: {
title: '404-页面不存在'
},
frontRoute: 'error-page/404'
}];
// 判断用户是否登录
let userInfo = Cookies.get('userInfoManager')
if (!userInfo) {
// 未登录
return;
}
if (!vm.$store.state.app.added) {
// 第一次加载 读取数据
// 加载菜单
getCurrentPermissionList().then(res => {
if (!res.success) return false;
let menuData = res.result;
// 格式化数据,设置 空children 为 null
for(let i =0;i<menuData.length;i++){
let t = menuData[i].children
for(let k = 0;k<t.length;k++){
let tt = t[k].children;
for(let z = 0;z<tt.length;z++){
tt[z].children = null
// 给所有三级路由添加字段显示一级菜单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;
// 格式化数据,设置 空children 为 null
for (let i = 0; i < menuData.length; i++) {
let t = menuData[i].children
for (let k = 0; k < t.length; k++) {
let tt = t[k].children;
for (let z = 0; z < tt.length; z++) {
tt[z].children = null
// 给所有三级路由添加字段显示一级菜单name方便点击页签时的选中筛选
tt[z].firstRouterName = menuData[i].name
}
}
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) {
let allMenuData = [];
data.forEach(e => {
if (e.level == 0) {
e.children.forEach(item => {
allMenuData.push(item);
})
}
})
util.initRouterNode(constRoutes, allMenuData);
let allMenuData = [];
data.forEach(e => {
if (e.level == 0) {
e.children.forEach(item => {
allMenuData.push(item);
})
}
})
util.initRouterNode(constRoutes, allMenuData);
}
// 生成菜单格式数据
util.initMenuData = function (vm, data) {
const menuRoutes = [];
let menuData = data;
// 顶部菜单
let navList = [];
menuData.forEach(e => {
let nav = {
name: e.name,
title: e.title
}
navList.push(nav);
})
if (navList.length < 1) {
return;
const menuRoutes = [];
let menuData = data;
// 顶部菜单
let navList = [];
menuData.forEach(e => {
let nav = {
name: e.name,
title: e.title
}
// 存入vuex
vm.$store.commit('setNavList', navList);
let currNav = window.localStorage.getItem('currNav')
if (currNav) {
// 读取缓存title
for (var item of navList) {
if (item.name == currNav) {
vm.$store.commit('setCurrNavTitle', item.title);
break;
}
}
} else {
// 默认第一个
currNav = navList[0].name;
vm.$store.commit('setCurrNavTitle', navList[0].title);
navList.push(nav);
})
if (navList.length < 1) {
return;
}
// 存入vuex
vm.$store.commit('setNavList', navList);
let currNav = window.localStorage.getItem('currNav')
if (currNav) {
// 读取缓存title
for (var item of navList) {
if (item.name == currNav) {
vm.$store.commit('setCurrNavTitle', item.title);
break;
}
}
vm.$store.commit('setCurrNav', currNav);
for (let item of menuData) {
if (item.name == currNav) {
// 过滤
menuData = item.children;
break;
}
} else {
// 默认第一个
currNav = navList[0].name;
vm.$store.commit('setCurrNavTitle', navList[0].title);
}
vm.$store.commit('setCurrNav', currNav);
for (let item of menuData) {
if (item.name == currNav) {
// 过滤
menuData = item.children;
break;
}
util.initRouterNode(menuRoutes, menuData);
// 刷新界面菜单
vm.$store.commit('updateMenulist', menuRoutes.filter(item => item.children.length > 0));
}
util.initRouterNode(menuRoutes, menuData);
// 刷新界面菜单
vm.$store.commit('updateMenulist', menuRoutes.filter(item => item.children.length > 0));
let tagsList = [];
vm.$store.state.app.routers.map((item) => {
if (item.children.length <= 1) {
tagsList.push(item.children[0]);
} else {
tagsList.push(...item.children);
}
});
vm.$store.commit('setTagsList', tagsList);
let tagsList = [];
vm.$store.state.app.routers.map((item) => {
if (item.children.length <= 1) {
tagsList.push(item.children[0]);
} else {
tagsList.push(...item.children);
}
});
vm.$store.commit('setTagsList', tagsList);
};
// 生成路由节点
util.initRouterNode = function (routers, data) { // data为所有子菜单数据
util.initRouterNode = function (routers, data) { // data为所有子菜单数据
for (let item of data) {
let menu = Object.assign({}, item);
for (let item of data) {
let menu = Object.assign({}, item);
menu.component = lazyLoading(menu.frontRoute);
menu.component = lazyLoading(menu.frontRoute);
if (item.children && item.children.length > 0) {
menu.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);
if (item.children && item.children.length > 0) {
menu.children = [];
util.initRouterNode(menu.children, item.children);
}
let meta = {};
// 给页面添加标题、父级菜单name方便左侧菜单选中
meta.title = menu.title ? menu.title + " - lilishop 运营后台" : null;
meta.firstRouterName = item.firstRouterName
menu.meta = meta;
routers.push(menu);
}
};
export default util;

View File

@ -1,154 +1,140 @@
import { otherRouter } from '@/router/router';
import { router } from '@/router/index';
import {
otherRouter
} from '@/router/router';
import {
router
} from '@/router/index';
import Util from '@/libs/util';
import Vue from 'vue';
const app = {
state: {
styleStore:"", //移动端楼层装修中选择风格存储
loading: false, // 全局加载动画
added: false, // 加载路由标识
navList: [], // 顶部菜单
currNav: "", // 当前顶部菜单name
currNavTitle: "", // 当前顶部菜单标题
cachePage: [],
lang: '',
pageOpenedList: [{ // 打开过的页面,顶部历史菜单项
title: '首页',
path: '',
name: 'home_index'
}],
currentPageName: '',
currentPath: [
{
title: '首页',
path: '',
name: 'home_index'
}
],
// 面包屑数组 左侧菜单
menuList: [],
tagsList: [...otherRouter.children], //这块是面包屑的内容不能删除
routers: [otherRouter],
messageCount: 0,
// 在这里定义你不想要缓存的页面的name属性值(参见路由配置router.js)
dontCache: ['test', 'test']
state: {
styleStore: "", // 移动端楼层装修中选择风格存储
added: false, // 加载路由标识
navList: [], // 顶部菜单
currNav: "", // 当前顶部菜单name
currNavTitle: "", // 当前顶部菜单标题
cachePage: [],
lang: '',
pageOpenedList: [{ // 打开过的页面,顶部历史菜单项
title: '首页',
path: '',
name: 'home_index'
}],
// 面包屑数组 左侧菜单
menuList: [],
tagsList: [...otherRouter.children], //这块是面包屑的内容不能删除
routers: [otherRouter],
messageCount: 0,
// 在这里定义你不想要缓存的页面的name属性值(参见路由配置router.js)
dontCache: ['test', 'test']
},
mutations: {
// 动态添加主界面路由,需要缓存
updateAppRouter(state, routes) {
state.routers.push(...routes);
router.addRoutes(routes);
},
mutations: {
// 动态添加主界面路由,需要缓存
updateAppRouter(state, routes) {
state.routers.push(...routes);
router.addRoutes(routes);
},
// 动态添加全局路由404、500等页面不需要缓存
updateDefaultRouter(state, routes) {
router.addRoutes(routes);
},
setLoading(state, v) {
state.loading = v;
},
setAdded(state, v) {
state.added = v;
},
setNavList(state, list) {
state.navList = list;
},
setCurrNav(state, v) {
state.currNav = v;
},
setCurrNavTitle(state, v) {
state.currNavTitle = v;
},
setTagsList(state, list) {
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);
// 动态添加全局路由404、500等页面不需要缓存
updateDefaultRouter(state, routes) {
router.addRoutes(routes);
},
setAdded(state, v) {
state.added = v;
},
setNavList(state, list) {
state.navList = list;
},
setCurrNav(state, v) {
state.currNav = v;
},
setCurrNavTitle(state, v) {
state.currNavTitle = v;
},
setTagsList(state, list) {
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]];
},
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;

View File

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

View File

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

View File

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

View File

@ -9,103 +9,47 @@
<Tag v-for="item in unixHours(row.hours)" :key="item">{{ item }}</Tag>
</template>
</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">
<Button @click="auditAll"></Button>
<Button
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">
<div>{{ row.quantity }}</div>
</template>
<template slot-scope="{ row }" slot="quantity">
<div>{{ row.quantity }}</div>
</template>
<template slot-scope="{ row }" slot="price">
<div>{{ row.price | unitPrice("¥") }}</div>
</template>
<template slot-scope="{ row }" slot="price">
<div>{{ row.price | unitPrice("¥") }}</div>
</template>
<template slot-scope="{ row }" slot="promotionApplyStatus">
<Badge
status="success"
v-if="row.promotionApplyStatus == 'PASS'"
:text="promotionApplyStatus(row.promotionApplyStatus)"
/>
<Badge
status="blue"
v-if="row.promotionApplyStatus == 'APPLY'"
:text="promotionApplyStatus(row.promotionApplyStatus)"
/>
<Badge
status="error"
v-if="row.promotionApplyStatus == 'REFUSE'"
:text="promotionApplyStatus(row.promotionApplyStatus)"
/>
<span
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>
<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, index }" slot="action">
<Button
type="error"
size="small"
@click="delGoods(index,row)"
>删除
</Button>
</template>
</Table>
<Row type="flex" justify="end" class="mt_10">
<Page
:current="searchForm.pageNumber + 1"
@ -121,40 +65,6 @@
></Page>
</Row>
</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>
</template>
<script>
@ -162,6 +72,7 @@
seckillGoodsList,
seckillDetail,
auditApplySeckill,
delSeckillGoods
} from "@/api/promotion.js";
export default {
@ -246,7 +157,6 @@
},
],
goodsColumns: [ //
{type: "selection", width: 60, align: "center"},
{
title: "商品名称",
key: "goodsName",
@ -281,13 +191,11 @@
width: 100,
slot: "time",
},
{
title: "状态",
slot: "promotionApplyStatus",
minWidth: 30,
width: 90,
},
// {
// title: "",
// slot: "promotionApplyStatus",
// width: 90,
// },
{
title: "操作",
slot: "action",
@ -328,16 +236,6 @@
clearSelectAll() {
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() {
//
@ -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) {
//
return this.$options.filters.unixToDate(new Date(time) / 1000);
@ -379,87 +291,7 @@
hourArr[i] += ":00";
}
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() {
this.init();

View File

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

View File

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

View File

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

View File

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

View File

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