1.增加网络判断刷新页面,防止没网无法连接ws
2.商品增加上下架、售罄、修改库存登操作
This commit is contained in:
@@ -3,10 +3,10 @@ ENV = development
|
|||||||
|
|
||||||
|
|
||||||
# 正式ws
|
# 正式ws
|
||||||
VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
|
# VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
|
||||||
|
|
||||||
#测试ws
|
#测试ws
|
||||||
# VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client'
|
VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client'
|
||||||
|
|
||||||
# 阿伟本地ws
|
# 阿伟本地ws
|
||||||
# VITE_API_WSS = 'ws://192.168.2.17:9998/client'
|
# VITE_API_WSS = 'ws://192.168.2.17:9998/client'
|
||||||
@@ -27,7 +27,7 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
|||||||
# VITE_API_URL = 'http://192.168.1.106:10589/cashier-client'
|
# VITE_API_URL = 'http://192.168.1.106:10589/cashier-client'
|
||||||
|
|
||||||
# 测试
|
# 测试
|
||||||
# VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'
|
VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'
|
||||||
|
|
||||||
# 正式
|
# 正式
|
||||||
VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'
|
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'
|
||||||
@@ -1,115 +1 @@
|
|||||||
"use strict";
|
"use strict";const s=require("path"),e=require("electron"),a=require("os");let n;e.app.whenReady().then(()=>{n=new e.BrowserWindow({title:"银收客",width:1024,height:768,fullscreenable:!0,fullscreen:!process.env.VITE_DEV_SERVER_URL,simpleFullscreen:!0,frame:!!process.env.VITE_DEV_SERVER_URL,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}),process.env.VITE_DEV_SERVER_URL?n.loadURL(process.env.VITE_DEV_SERVER_URL):n.loadFile(s.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(t,o)=>{n=null,e.app.exit()}),e.ipcMain.on("getPrintList",()=>{n.webContents.getPrintersAsync().then(t=>{n.webContents.send("printList",t)})}),e.ipcMain.on("getOSmacSync",()=>{let t="";a.networkInterfaces().WLAN?(t=a.networkInterfaces().WLAN[0].mac,console.log("wlan.mac===",t)):(t=a.networkInterfaces().以太网[0].mac,console.log("以太网.mac===",t)),n.webContents.send("getOSmacRes",t)});const i=new e.BrowserWindow({show:!1,width:360,height:240,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?i.loadFile(s.join(__dirname,"../public/tag_print.html")):i.loadFile(s.resolve(__dirname,"../dist/tag_print.html")),e.ipcMain.on("printerTagSync",(t,o)=>{console.log(o),i.webContents.send("getParams",o)}),e.ipcMain.on("printTagStart",(t,o)=>{let l=JSON.parse(o).deviceName;i.webContents.print({silent:!0,deviceName:l,pageSize:{width:45e3,height:3e4},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})}),e.app.requestSingleInstanceLock()?e.app.on("second-instance",(t,o,r)=>{n&&(n.isMinimized()&&n.restore(),n.focus(),n.show())}):e.app.quit(),n.on("close",t=>{t.preventDefault(),n.webContents.send("showCloseDialog")})});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()});
|
||||||
const path = require("path");
|
|
||||||
const electron = require("electron");
|
|
||||||
const os = require("os");
|
|
||||||
let win;
|
|
||||||
electron.app.whenReady().then(() => {
|
|
||||||
win = new electron.BrowserWindow({
|
|
||||||
title: "银收客",
|
|
||||||
width: 1024,
|
|
||||||
height: 768,
|
|
||||||
fullscreenable: true,
|
|
||||||
fullscreen: process.env.VITE_DEV_SERVER_URL ? false : true,
|
|
||||||
simpleFullscreen: true,
|
|
||||||
frame: process.env.VITE_DEV_SERVER_URL ? true : false,
|
|
||||||
webPreferences: {
|
|
||||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
|
||||||
nodeIntegration: true,
|
|
||||||
contextIsolation: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (process.env.VITE_DEV_SERVER_URL) {
|
|
||||||
win.loadURL(process.env.VITE_DEV_SERVER_URL);
|
|
||||||
} else {
|
|
||||||
win.loadFile(path.resolve(__dirname, "../dist/index.html"));
|
|
||||||
}
|
|
||||||
electron.app.on("activate", () => {
|
|
||||||
if (electron.BrowserWindow.getAllWindows().length === 0) {
|
|
||||||
createWindow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
electron.ipcMain.on("quitHandler", (_, msg) => {
|
|
||||||
win = null;
|
|
||||||
electron.app.exit();
|
|
||||||
});
|
|
||||||
electron.ipcMain.on("getPrintList", () => {
|
|
||||||
win.webContents.getPrintersAsync().then((res) => {
|
|
||||||
win.webContents.send("printList", res);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
electron.ipcMain.on("getOSmacSync", () => {
|
|
||||||
let mac = "";
|
|
||||||
if (os.networkInterfaces().WLAN) {
|
|
||||||
mac = os.networkInterfaces().WLAN[0].mac;
|
|
||||||
console.log("wlan.mac===", mac);
|
|
||||||
} else {
|
|
||||||
mac = os.networkInterfaces()["以太网"][0].mac;
|
|
||||||
console.log("以太网.mac===", mac);
|
|
||||||
}
|
|
||||||
win.webContents.send("getOSmacRes", mac);
|
|
||||||
});
|
|
||||||
const tagPrintWin = new electron.BrowserWindow({
|
|
||||||
show: false,
|
|
||||||
width: 360,
|
|
||||||
height: 240,
|
|
||||||
webPreferences: {
|
|
||||||
nodeIntegration: true,
|
|
||||||
contextIsolation: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (process.env.VITE_DEV_SERVER_URL) {
|
|
||||||
tagPrintWin.loadFile(path.join(__dirname, "../public/tag_print.html"));
|
|
||||||
} else {
|
|
||||||
tagPrintWin.loadFile(path.resolve(__dirname, "../dist/tag_print.html"));
|
|
||||||
}
|
|
||||||
electron.ipcMain.on("printerTagSync", (event, arg) => {
|
|
||||||
console.log(arg);
|
|
||||||
tagPrintWin.webContents.send("getParams", arg);
|
|
||||||
});
|
|
||||||
electron.ipcMain.on("printTagStart", (event, arg) => {
|
|
||||||
const _parmas = JSON.parse(arg);
|
|
||||||
let name = _parmas.deviceName;
|
|
||||||
tagPrintWin.webContents.print({
|
|
||||||
silent: true,
|
|
||||||
deviceName: name,
|
|
||||||
pageSize: {
|
|
||||||
width: 45e3,
|
|
||||||
height: 3e4
|
|
||||||
},
|
|
||||||
scaleFactor: 80,
|
|
||||||
landscape: false,
|
|
||||||
margins: {
|
|
||||||
marginType: "none",
|
|
||||||
top: 0,
|
|
||||||
bottom: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0
|
|
||||||
},
|
|
||||||
dpi: {
|
|
||||||
horizontal: 203,
|
|
||||||
vertical: 203
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const gotTheLock = electron.app.requestSingleInstanceLock();
|
|
||||||
if (!gotTheLock) {
|
|
||||||
electron.app.quit();
|
|
||||||
} else {
|
|
||||||
electron.app.on("second-instance", (event, commandLine, workingDirectory) => {
|
|
||||||
if (win) {
|
|
||||||
if (win.isMinimized())
|
|
||||||
win.restore();
|
|
||||||
win.focus();
|
|
||||||
win.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
win.on("close", (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
win.webContents.send("showCloseDialog");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
electron.app.on("window-all-closed", () => {
|
|
||||||
if (process.platform !== "darwin")
|
|
||||||
electron.app.quit();
|
|
||||||
});
|
|
||||||
|
|||||||
34
src/App.vue
34
src/App.vue
@@ -164,24 +164,6 @@ async function getBarCode(e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取网络状态
|
|
||||||
const updateInfo = _.throttle(function () {
|
|
||||||
let isOnLine = navigator.onLine
|
|
||||||
// // 获取网络信息
|
|
||||||
// let info = navigator.connection
|
|
||||||
console.log(isOnLine);
|
|
||||||
// console.log(info);
|
|
||||||
if (store.userInfo && store.userInfo.shopId) {
|
|
||||||
if (isOnLine) {
|
|
||||||
console.log('有网了重新连接ws~');
|
|
||||||
socket.init();
|
|
||||||
} else {
|
|
||||||
socket.close();
|
|
||||||
console.log('网络连接失败~');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 100, { leading: true, trailing: false })
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.addEventListener("keydown", (e) => {
|
document.addEventListener("keydown", (e) => {
|
||||||
getBarCode(e);
|
getBarCode(e);
|
||||||
@@ -200,14 +182,16 @@ onMounted(() => {
|
|||||||
.catch(() => { });
|
.catch(() => { });
|
||||||
})
|
})
|
||||||
|
|
||||||
// listnerCloseDialog()
|
|
||||||
|
|
||||||
// // 监听网络在线状态
|
window.addEventListener('online', function () {
|
||||||
// window.addEventListener("onLine", updateInfo)
|
console.log('有网络了');
|
||||||
// // 监听网络离线
|
this.location.reload()
|
||||||
// window.addEventListener("offLine", updateInfo)
|
})
|
||||||
// 监听网络信息变化
|
|
||||||
// navigator.connection.addEventListener('change', updateInfo)
|
window.addEventListener('offline', function () {
|
||||||
|
ElMessage.warning('网络异常')
|
||||||
|
socket.close()
|
||||||
|
})
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -2,171 +2,195 @@ import request from "@/utils/request.js";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询分类信息
|
* 查询分类信息
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function queryCategory(params) {
|
export function queryCategory(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "product/queryCategory",
|
url: "product/queryCategory",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品信息
|
* 查询商品信息
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function productqueryCommodityInfo(params) {
|
export function productqueryCommodityInfo(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "product/queryCommodityInfo",
|
url: "product/queryCommodityInfo",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品信息
|
* 查询商品信息
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function queryNewCommodityInfo(params) {
|
export function queryNewCommodityInfo(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "product/queryNewCommodityInfo",
|
url: "product/queryNewCommodityInfo",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过选中的商品规格查询价格
|
* 通过选中的商品规格查询价格
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function queryProductSku(params) {
|
export function queryProductSku(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "product/queryProductSku",
|
url: "product/queryProductSku",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加购物车
|
* 添加购物车
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function createCart(data) {
|
export function createCart(data) {
|
||||||
return request({
|
return request({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: "/order/createCart",
|
url: "/order/createCart",
|
||||||
data
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取购物车商品
|
* 获取购物车商品
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function queryCart(params) {
|
export function queryCart(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "order/queryCart",
|
url: "order/queryCart",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取取件码
|
* 获取取件码
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function createCode(params) {
|
export function createCode(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/order/createCode",
|
url: "/order/createCode",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全部打包
|
* 全部打包
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function packall(data) {
|
export function packall(data) {
|
||||||
return request({
|
return request({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: "/order/packall",
|
url: "/order/packall",
|
||||||
data
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除购物车
|
* 删除购物车
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function delCart(params) {
|
export function delCart(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/order/delCart",
|
url: "/order/delCart",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 挂单/j激活购物车
|
* 挂单/j激活购物车
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function cartStatus(data) {
|
export function cartStatus(data) {
|
||||||
return request({
|
return request({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: "/order/cartStatus",
|
url: "/order/cartStatus",
|
||||||
data
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取挂起购物车列表
|
* 获取挂起购物车列表
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function getCartList(params) {
|
export function getCartList(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/order/getCartList",
|
url: "/order/getCartList",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空购物车
|
* 清空购物车
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function clearCart(data) {
|
export function clearCart(data) {
|
||||||
return request({
|
return request({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: "/order/clearCart",
|
url: "/order/clearCart",
|
||||||
data
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建订单
|
* 创建订单
|
||||||
* @param {*} data
|
* @param {*} data
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function createOrder(data) {
|
export function createOrder(data) {
|
||||||
return request({
|
return request({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: "/order/createOrder",
|
url: "/order/createOrder",
|
||||||
data
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上下架售罄
|
||||||
|
* @param {*} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function productStatus(data) {
|
||||||
|
return request({
|
||||||
|
method: "PUT",
|
||||||
|
url: "/product/productStatus",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改库存
|
||||||
|
* @param {*} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function productStock(data) {
|
||||||
|
return request({
|
||||||
|
method: "PUT",
|
||||||
|
url: "/product/productStock",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
BIN
src/assets/icon_xq.png
Normal file
BIN
src/assets/icon_xq.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 58 KiB |
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="left_menu_wrap">
|
<div class="left_menu_wrap">
|
||||||
<div class="item" :class="{ online: socketStore.online }" @click="connectWsHandle">
|
<div class="item first" :class="{ online: socketStore.online }" @click="connectWsHandle">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
<Monitor />
|
<Monitor />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<el-text :type="socketStore.online ? 'success' : ''">
|
<el-text :type="socketStore.online ? 'success' : 'danger'">
|
||||||
<template v-if="socketStore.online">
|
<template v-if="socketStore.online">
|
||||||
在线
|
在线
|
||||||
</template>
|
</template>
|
||||||
@@ -106,7 +106,7 @@ function openCall() {
|
|||||||
// 手动重新连接ws
|
// 手动重新连接ws
|
||||||
function connectWsHandle() {
|
function connectWsHandle() {
|
||||||
if (socketStore.online) return
|
if (socketStore.online) return
|
||||||
window.onload()
|
location.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export const useSocket = defineStore({
|
|||||||
// 关闭ws
|
// 关闭ws
|
||||||
close() {
|
close() {
|
||||||
console.log("关闭ws");
|
console.log("关闭ws");
|
||||||
|
this.online = false;
|
||||||
this.ws.close(1000);
|
this.ws.close(1000);
|
||||||
this.ws = null;
|
this.ws = null;
|
||||||
this.clearHeartBeat();
|
this.clearHeartBeat();
|
||||||
|
|||||||
@@ -26,11 +26,15 @@
|
|||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
<div class="search_wrap">
|
<div class="search_wrap">
|
||||||
<div class="input">
|
<el-button :type="showEditor ? 'warning' : ''" @click="showEditorChange">{{ showEditor ? '关闭编辑' : '编辑'
|
||||||
<el-input placeholder="请输入商品名称查询" v-model="commdityName" clearable @focus="
|
}}</el-button>
|
||||||
global.updateData(false)" @blur="global.updateData(true)" @input="inputChange"></el-input>
|
<div class="right">
|
||||||
|
<div class="input">
|
||||||
|
<el-input placeholder="请输入商品名称查询" v-model="commdityName" clearable @focus="
|
||||||
|
global.updateData(false)" @blur="global.updateData(true)" @input="inputChange"></el-input>
|
||||||
|
</div>
|
||||||
|
<el-button :loading="searchLoading" :icon="Search" @click="searchHandle">搜索</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-button :loading="searchLoading" :icon="Search" @click="searchHandle">搜索</el-button>
|
|
||||||
<!-- <el-button :icon="shopListType == 'text' ? 'PictureRounded' : 'PriceTag'"
|
<!-- <el-button :icon="shopListType == 'text' ? 'PictureRounded' : 'PriceTag'"
|
||||||
@click="changeShopListType"></el-button> -->
|
@click="changeShopListType"></el-button> -->
|
||||||
</div>
|
</div>
|
||||||
@@ -40,15 +44,38 @@
|
|||||||
<swiper-slide class="slide_item" v-for="(goods, index) in goodsList" :key="index">
|
<swiper-slide class="slide_item" v-for="(goods, index) in goodsList" :key="index">
|
||||||
<div class="item_wrap" v-for="item in goods" :key="item.id" @click="showSkuHandle(item)">
|
<div class="item_wrap" v-for="item in goods" :key="item.id" @click="showSkuHandle(item)">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
|
<transition name="el-fade-in">
|
||||||
|
<div class="more" v-if="item.showMore" @click.stop>
|
||||||
|
<div class="ul">
|
||||||
|
<template v-if="categorys[categorysActive].id == '-1'">
|
||||||
|
<div class="li" @click.stop="showPutawayHandle(item)">上架</div>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div class="li" @click.stop="goodEditor(item, 0)">下架</div>
|
||||||
|
<div class="li" @click.stop="goodEditor(item, 1)">售罄</div>
|
||||||
|
<div class="li" @click.stop="goodStockNumberHandle(item)">修改库存</div>
|
||||||
|
</template>
|
||||||
|
<div class="li" @click.stop="item.showMore = false">取消</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
<div class="dot" v-if="item.orderCount">{{ item.orderCount }}</div>
|
<div class="dot" v-if="item.orderCount">{{ item.orderCount }}</div>
|
||||||
<div class="cover" v-if="shopListType == 'img'">
|
<div class="cover" v-if="shopListType == 'img'">
|
||||||
<el-image :src="`${item.coverImg}?x-oss-process=image/resize,m_lfit,w_150,h_150`"
|
<el-image :src="`${item.coverImg}?x-oss-process=image/resize,m_lfit,w_150,h_150`"
|
||||||
class="el_img" fit="cover"></el-image>
|
class="el_img" fit="cover"></el-image>
|
||||||
|
<div class="sell_out" v-if="item.isPauseSale == 1">
|
||||||
|
<img class="sell_out_icon" src="../../../assets/icon_xq.png">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="name"><el-text line-clamp="1">{{ item.name }}</el-text></div>
|
<div class="name"><el-text line-clamp="1">{{ item.name }}</el-text></div>
|
||||||
<div class="item_empty" v-if="shopListType == 'text'"></div>
|
<div class="item_empty" v-if="shopListType == 'text'"></div>
|
||||||
<div class="price">
|
<div class="price">
|
||||||
<el-text>¥{{ item.lowPrice }}</el-text>
|
<el-text>¥{{ item.lowPrice }}</el-text>
|
||||||
|
<div class="show_more_btn" v-if="showEditor">
|
||||||
|
<el-icon>
|
||||||
|
<MoreFilled />
|
||||||
|
</el-icon>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,9 +87,83 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- 选择规格 -->
|
<!-- 选择规格 -->
|
||||||
<skuModal ref="skuModalRef" @success="skuConfirm" />
|
<skuModal ref="skuModalRef" @success="skuConfirm" />
|
||||||
|
<!-- 编辑商品 -->
|
||||||
|
<el-dialog v-model="showGoodEditor" :title="`${goodEditorEmun[goodEditorType]}商品`">
|
||||||
|
<div class="dialog">
|
||||||
|
<div class="el-popover__title content">
|
||||||
|
确定要{{ `${goodEditorEmun[goodEditorType]}商品:${goodEditorItem.name}?` }}
|
||||||
|
</div>
|
||||||
|
<div class="footer_wrap">
|
||||||
|
<div class="btn">
|
||||||
|
<el-button style="width: 100%;" @click="showGoodEditor = false">取消</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="btn">
|
||||||
|
<el-button type="primary" style="width: 100%;" :loading="goodEditorLoading"
|
||||||
|
@click="goodEditorConfirm">确认</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
<!-- 修改库存 -->
|
||||||
|
<el-dialog v-model="showGoodsEditorStock" title="修改库存" width="400px">
|
||||||
|
<div class="dialog">
|
||||||
|
<el-form>
|
||||||
|
<el-form-item label="库存">
|
||||||
|
<div>
|
||||||
|
<el-input-number v-model="goodsEditorStockNumber" :min="0"></el-input-number>
|
||||||
|
<div class="tips">修改前库存:{{ goodsEditorStockItem.stockNumber }}</div>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div class="footer_wrap">
|
||||||
|
<div class="btn">
|
||||||
|
<el-button style="width: 100%;" @click="showGoodsEditorStock = false">取消</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="btn">
|
||||||
|
<el-button type="primary" style="width: 100%;" :loading="goodsEditorStockLoading"
|
||||||
|
@click="goodsEditorStockConfirm">确认</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
<!-- 关闭售罄 -->
|
||||||
|
<el-dialog v-model="showCloseSell" title="关闭售罄">
|
||||||
|
<div class="dialog">
|
||||||
|
<div class="el-popover__title content">
|
||||||
|
确定要将{{ `【${goodEditorItem.name}】` }}关闭售罄吗?
|
||||||
|
</div>
|
||||||
|
<div class="footer_wrap">
|
||||||
|
<div class="btn">
|
||||||
|
<el-button style="width: 100%;" @click="showCloseSell = false">取消</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="btn">
|
||||||
|
<el-button type="primary" style="width: 100%;" :loading="closeSellLoading"
|
||||||
|
@click="closeSellHandle">确认</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
<!-- 上架商品 -->
|
||||||
|
<el-dialog v-model="showPutaway" title="上架商品">
|
||||||
|
<div class="dialog">
|
||||||
|
<div class="el-popover__title content">
|
||||||
|
确定要上架商品:{{ `${goodEditorItem.name}` }}吗?
|
||||||
|
</div>
|
||||||
|
<div class="footer_wrap">
|
||||||
|
<div class="btn">
|
||||||
|
<el-button style="width: 100%;" @click="showPutaway = false">取消</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="btn">
|
||||||
|
<el-button type="primary" style="width: 100%;" :loading="showPutawayLoading"
|
||||||
|
@click="putawayHandle">确认</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
import { Search } from '@element-plus/icons-vue'
|
import { Search } from '@element-plus/icons-vue'
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
@@ -70,7 +171,7 @@ import useStorage from "@/utils/useStorage";
|
|||||||
|
|
||||||
import skuModal from '@/components/skuModal.vue'
|
import skuModal from '@/components/skuModal.vue'
|
||||||
|
|
||||||
import { queryCategory, queryNewCommodityInfo, queryProductSku } from '@/api/product'
|
import { queryCategory, queryNewCommodityInfo, queryProductSku, productStatus, productStock } from '@/api/product'
|
||||||
import { useUser } from "@/store/user.js"
|
import { useUser } from "@/store/user.js"
|
||||||
|
|
||||||
import { Swiper, SwiperSlide } from 'swiper/vue'
|
import { Swiper, SwiperSlide } from 'swiper/vue'
|
||||||
@@ -140,14 +241,58 @@ function showMoreMenu() {
|
|||||||
showPopover.value = !showPopover.value
|
showPopover.value = !showPopover.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 显示/隐藏编辑
|
||||||
|
function showEditorChange() {
|
||||||
|
if (showEditor.value) {
|
||||||
|
showEditor.value = false
|
||||||
|
goodsList.value.map(item => {
|
||||||
|
item.map(val => {
|
||||||
|
val.showMore = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
showEditor.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 显示sku
|
// 显示sku
|
||||||
function showSkuHandle(item) {
|
function showSkuHandle(item) {
|
||||||
if (item.typeEnum == 'sku') {
|
if (showEditor.value) {
|
||||||
// 多规格
|
if (item.isPauseSale == 1) {
|
||||||
skuModalRef.value.show({ ...item })
|
goodEditorItem.value = item
|
||||||
|
showCloseSell.value = true
|
||||||
|
} else {
|
||||||
|
goodsList.value.map(item => {
|
||||||
|
item.map(val => {
|
||||||
|
val.showMore = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
item.showMore = true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 单规格
|
if (item.isPauseSale == 1) {
|
||||||
queryProductSkuAjax(item)
|
ElMessage({
|
||||||
|
type: 'error',
|
||||||
|
message: '该商品已售罄',
|
||||||
|
showClose: true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (categorys.value[categorysActive.value].id == '-1') {
|
||||||
|
ElMessage({
|
||||||
|
type: 'error',
|
||||||
|
message: '该商品已下架,请上架后操作',
|
||||||
|
showClose: true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (item.typeEnum == 'sku') {
|
||||||
|
// 多规格
|
||||||
|
skuModalRef.value.show({ ...item })
|
||||||
|
} else {
|
||||||
|
// 单规格
|
||||||
|
queryProductSkuAjax(item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +373,10 @@ async function queryCategoryAjax() {
|
|||||||
name: '全部',
|
name: '全部',
|
||||||
id: ''
|
id: ''
|
||||||
})
|
})
|
||||||
|
categorys.value.push({
|
||||||
|
name: '已下架',
|
||||||
|
id: '-1'
|
||||||
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
@@ -259,6 +408,9 @@ async function productqueryCommodityInfoAjax() {
|
|||||||
// clearInterval(loopTimer.value)
|
// clearInterval(loopTimer.value)
|
||||||
// loopTimer.value = null
|
// loopTimer.value = null
|
||||||
// }
|
// }
|
||||||
|
res.list.map((val, index) => {
|
||||||
|
val.showMore = false
|
||||||
|
})
|
||||||
return res
|
return res
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@@ -337,6 +489,148 @@ function clearDot() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showEditor = ref(false)
|
||||||
|
const goodEditorType = ref(0) // 0 上下架 1售罄
|
||||||
|
const goodEditorItem = ref({})
|
||||||
|
const goodEditorLoading = ref(false)
|
||||||
|
const showGoodEditor = ref(false)
|
||||||
|
|
||||||
|
const goodEditorEmun = ref({
|
||||||
|
0: '下架',
|
||||||
|
1: '售罄'
|
||||||
|
})
|
||||||
|
|
||||||
|
// 编辑商品
|
||||||
|
function goodEditor(item, t) {
|
||||||
|
goodEditorItem.value = item
|
||||||
|
if (item.isPauseSale == 1) {
|
||||||
|
} else {
|
||||||
|
goodEditorType.value = t
|
||||||
|
showGoodEditor.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭售罄
|
||||||
|
const showCloseSell = ref(false)
|
||||||
|
const closeSellLoading = ref(false)
|
||||||
|
async function closeSellHandle() {
|
||||||
|
try {
|
||||||
|
closeSellLoading.value = true
|
||||||
|
const res = await productStatus({
|
||||||
|
shopId: store.userInfo.shopId,
|
||||||
|
productId: goodEditorItem.value.id,
|
||||||
|
type: 1,
|
||||||
|
state: 0
|
||||||
|
})
|
||||||
|
closeSellLoading.value = false
|
||||||
|
showCloseSell.value = false
|
||||||
|
ElMessage({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功',
|
||||||
|
showClose: true,
|
||||||
|
})
|
||||||
|
updateData()
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上架商品
|
||||||
|
const showPutaway = ref(false)
|
||||||
|
const showPutawayLoading = ref(false)
|
||||||
|
|
||||||
|
function showPutawayHandle(item) {
|
||||||
|
goodEditorItem.value = item
|
||||||
|
showPutaway.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function putawayHandle(item) {
|
||||||
|
try {
|
||||||
|
showPutawayLoading.value = true
|
||||||
|
const res = await productStatus({
|
||||||
|
shopId: store.userInfo.shopId,
|
||||||
|
productId: goodEditorItem.value.id,
|
||||||
|
type: 0,
|
||||||
|
state: 1
|
||||||
|
})
|
||||||
|
showPutawayLoading.value = false
|
||||||
|
showPutaway.value = false
|
||||||
|
ElMessage({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功',
|
||||||
|
showClose: true,
|
||||||
|
})
|
||||||
|
updateData()
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认操作
|
||||||
|
async function goodEditorConfirm() {
|
||||||
|
try {
|
||||||
|
goodEditorLoading.value = true
|
||||||
|
const res = await productStatus({
|
||||||
|
shopId: store.userInfo.shopId,
|
||||||
|
productId: goodEditorItem.value.id,
|
||||||
|
type: goodEditorType.value,
|
||||||
|
state: goodEditorType.value == 0 ? 0 : 1
|
||||||
|
})
|
||||||
|
goodEditorLoading.value = false
|
||||||
|
showGoodEditor.value = false
|
||||||
|
ElMessage({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功',
|
||||||
|
showClose: true,
|
||||||
|
})
|
||||||
|
updateData()
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示修改库存
|
||||||
|
const goodsEditorStockItem = ref(0)
|
||||||
|
const showGoodsEditorStock = ref(false)
|
||||||
|
const goodsEditorStockNumber = ref(0)
|
||||||
|
const goodsEditorStockLoading = ref(false)
|
||||||
|
function goodStockNumberHandle(item) {
|
||||||
|
if (item.isDistribute == 0 && item.typeEnum == 'sku') {
|
||||||
|
ElMessage({
|
||||||
|
type: 'warning',
|
||||||
|
message: '未开启共享库存无法修改',
|
||||||
|
|
||||||
|
showClose: true,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
goodsEditorStockItem.value = item
|
||||||
|
goodsEditorStockNumber.value = item.stockNumber
|
||||||
|
showGoodsEditorStock.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认修改库存
|
||||||
|
async function goodsEditorStockConfirm() {
|
||||||
|
try {
|
||||||
|
goodsEditorStockLoading.value = true
|
||||||
|
const res = await productStock({
|
||||||
|
shopId: store.userInfo.shopId,
|
||||||
|
productId: goodsEditorStockItem.value.id,
|
||||||
|
stock: goodsEditorStockNumber.value
|
||||||
|
})
|
||||||
|
goodsEditorStockLoading.value = false
|
||||||
|
showGoodsEditorStock.value = false
|
||||||
|
ElMessage({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功',
|
||||||
|
showClose: true,
|
||||||
|
})
|
||||||
|
updateData()
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
updateData,
|
updateData,
|
||||||
clearDot
|
clearDot
|
||||||
@@ -456,9 +750,13 @@ onMounted(async () => {
|
|||||||
|
|
||||||
.search_wrap {
|
.search_wrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: space-between;
|
||||||
gap: 10px;
|
|
||||||
padding: var(--el-font-size-base);
|
padding: var(--el-font-size-base);
|
||||||
|
|
||||||
|
.right {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.shop_list {
|
.shop_list {
|
||||||
@@ -489,6 +787,38 @@ onMounted(async () => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.more {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 10;
|
||||||
|
background-color: rgba(0, 0, 0, .6);
|
||||||
|
backdrop-filter: blur(2px);
|
||||||
|
border-radius: 10px;
|
||||||
|
|
||||||
|
.ul {
|
||||||
|
height: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.li {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
color: #fff;
|
||||||
|
padding: 8px 0;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-top: 1px solid rgba(255 255 255 / 20%);
|
||||||
|
color: #ececec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@@ -518,6 +848,27 @@ onMounted(async () => {
|
|||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sell_out {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
|
// backdrop-filter: blur(2px);
|
||||||
|
z-index: 10;
|
||||||
|
|
||||||
|
.sell_out_icon {
|
||||||
|
$size: 60px;
|
||||||
|
width: $size;
|
||||||
|
height: $size;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
@@ -540,13 +891,43 @@ onMounted(async () => {
|
|||||||
height: 20%;
|
height: 20%;
|
||||||
padding: 6px 10px;
|
padding: 6px 10px;
|
||||||
background-color: var(--primary-color);
|
background-color: var(--primary-color);
|
||||||
|
position: relative;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.show_more_btn {
|
||||||
|
width: 40px;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 1;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dialog {
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer_wrap {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user