货无忧
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

641 lines
25 KiB

"use strict";
const common_vendor = require("../../../common/vendor.js");
const api_user = require("../../../api/user.js");
const store_useSystemSettingsStore = require("../../../store/useSystemSettingsStore.js");
const store_useStorageStore = require("../../../store/useStorageStore.js");
const utils_utils = require("../../../utils/utils.js");
require("../../../utils/request.js");
require("../../../store/index.js");
require("../../../utils/functions.js");
require("../../../utils/IDCardVerification.js");
require("../../../utils/base64.js");
require("../../../config/host.js");
require("../../../utils/md5.js");
if (!Array) {
const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
const _component_tips = common_vendor.resolveComponent("tips");
const _component_PopUp = common_vendor.resolveComponent("PopUp");
(_easycom_u_navbar2 + _component_tips + _component_PopUp)();
}
const _easycom_u_navbar = () => "../../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
if (!Math) {
_easycom_u_navbar();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "ScanUp",
setup(__props) {
const { HANDLE_ISSTORAGECODE } = store_useStorageStore.useStorageStore();
common_vendor.storeToRefs(store_useSystemSettingsStore.useSystemSettingsStore());
const tip = common_vendor.ref(null);
let details = common_vendor.reactive({
checkstate: 1,
upshelfScanType: "",
scancode: "",
allocationId: "",
//库位id
datalist: [],
reqobj: {},
uplistarr: [],
renderList: [],
// 已扫描的服务号的数组
orderCodeArr: [],
/** 包件list */
orderPackageCodeList: [],
/** 库存品 || 零担 提交数 */
enterNum: 0,
/** 库存品 || 零担被选中的数据 */
stockItem: {}
});
const chooseOrderPackageCodeList = common_vendor.ref([]);
const downLoadByOrder = common_vendor.ref();
const downLoadByStock = common_vendor.ref();
common_vendor.watchEffect(() => {
if (Number(details.upshelfScanType) == 1 || Number(details.upshelfScanType) == 2) {
details.uplistarr = fn2(details.uplistarr, "orderCode");
} else if (Number(details.upshelfScanType) == 3)
;
else if (Number(details.upshelfScanType) == 4) {
details.uplistarr = fn2(details.uplistarr, "orderCode");
}
});
common_vendor.onLoad((op) => {
details.upshelfScanType = op.type;
if (op.pageName)
utils_utils.utils.ttsspke(`当前上架方式为${op.pageName},请先扫描库位码`);
});
common_vendor.onShow(async () => {
});
common_vendor.onPullDownRefresh(() => {
const timer = setTimeout(() => {
details.allocationId = "";
details.reqobj = {};
details.renderList = [];
details.datalist = [];
details.uplistarr = [];
details.orderCodeArr = [];
common_vendor.index.stopPullDownRefresh();
clearTimeout(timer);
}, 300);
});
const scanStorage = async (code) => {
var _a;
try {
let data = {
allocationId: code
};
let res = await api_user.warehouseUpdownTypeupShelfScanAllocation(data);
if (res.code == 200) {
details.reqobj = res.data;
const _positionArr = details.reqobj.allocationTitle.split("-");
details.reqobj.positionInfo = _positionArr[0] + "层" + _positionArr[1] + "列";
details.allocationId = res.data.allocationId;
details.datalist = ((_a = res.data) == null ? void 0 : _a.list) || [];
if (details.checkstate === 2)
details.renderList = details.datalist;
if (Number(details.upshelfScanType) === 4 && details.datalist.length !== 0 && details.uplistarr.length !== 0) {
return utils_utils.utils.handleToast("该库位已有数据, 无法上架");
}
const _arr = [];
for (let i = 0; i < details.datalist.length; i++) {
_arr.push(details.datalist[i].orderCode);
}
for (let i = 0; i < details.uplistarr.length; i++) {
_arr.push(details.uplistarr[i].orderCode);
}
details.orderCodeArr = _arr;
console.log("details.orderCodeArr :>> ", details.orderCodeArr);
}
} catch (err) {
console.log("err :>> ", err);
}
};
const scanOther = async (_code) => {
try {
let content = "";
if (Number(details.upshelfScanType) == 4 && details.datalist.length !== 0) {
content = "该库位已有数据, 无法上架";
}
if (details.upshelfScanType === "3") {
const flag = details.uplistarr.findIndex((val) => val.orderPackageCode === _code);
if (flag !== -1) {
content = "包件重复扫描";
}
}
if (content) {
utils_utils.utils.handleToast(content);
return;
}
let data = {
upshelfScanType: details.upshelfScanType,
code: _code
};
let res = await api_user.warehouseUpdownTypeupShelfScanGoods(data);
if (res.code == 200) {
if (Number(details.upshelfScanType) === 1 || Number(details.upshelfScanType) === 2) {
const _uplistarr = [...details.uplistarr];
const _orderCodeArr = [...details.orderCodeArr];
const _flag = res.data.every((val) => {
if (details.orderCodeArr.includes(val.orderCode)) {
utils_utils.utils.handleToast("订单已存在, 勿重复扫码");
return false;
}
_uplistarr.push(val);
_orderCodeArr.push(val.orderCode);
return true;
});
if (!_flag)
return;
details.uplistarr = _uplistarr;
details.orderCodeArr = _orderCodeArr;
} else if (Number(details.upshelfScanType) === 3) {
if (!res.data)
return;
details.uplistarr = [...details.uplistarr, ...res.data];
} else {
details.uplistarr = res.data;
}
let _content = "";
if (details.upshelfScanType !== "3")
_content = details.uplistarr.reduce((curr, item) => curr + item.shelfNum, 0) + "件";
else
_content = details.uplistarr.length + "件";
utils_utils.utils.ttsspke(_content);
if (details.checkstate === 1)
return details.renderList = details.uplistarr;
} else if (res.code === 3001 && res.audio) {
utils_utils.utils.ttsspke(res.audio);
}
} catch (err) {
console.log("err :>> ", err);
}
};
async function scandata() {
common_vendor.index.showLoading({
mask: true
});
const code = details.scancode;
const isStorageCode = HANDLE_ISSTORAGECODE(code);
common_vendor.index.hideLoading();
if (isStorageCode)
return scanStorage(code);
else
scanOther(code);
}
function goorderdetail(item, type) {
if (type !== 1)
return;
common_vendor.index.navigateTo({
url: "/pagesHome/pages/orderDetails/orderDetails?orderCode=" + item.orderCode
});
}
function uplist() {
let content = "";
if (details.allocationId === "") {
content = "请先扫描库位";
} else if (details.uplistarr.length === 0) {
if (Number(details.upshelfScanType) == 4) {
content = "请先扫描托盘码";
} else {
content = "请先扫描包件数据";
}
}
if (content) {
common_vendor.index.showToast({
title: content,
icon: "none"
});
utils_utils.utils.ttsspke(content);
return;
}
let _totalShelfNum = 0;
if (details.upshelfScanType === "3")
_totalShelfNum = uplistarr.value.length;
else
_totalShelfNum = uplistarr.value.reduce((curr, item) => curr + item.shelfNum, 0);
utils_utils.utils.ttsspke(`待上架${_totalShelfNum}件, 是否进行上架`);
tip.value.setdetails({
title: "提示",
content: "确认上架?",
confirmTxt: "确认",
isshow: true,
isshowcancel: true,
success: async () => {
let res = null;
common_vendor.index.showLoading({
mask: true,
title: "提交中"
});
if (Number(details.upshelfScanType) == 1 || Number(details.upshelfScanType) == 2) {
let data = {
allocationId: details.allocationId,
upShelfOrderList: details.uplistarr
};
res = await api_user.warehouseUpdownTypeupShelfOrder(data);
} else if (Number(details.upshelfScanType) == 3) {
let data = {
allocationId: details.allocationId,
upShelfPackageList: details.uplistarr
};
res = await api_user.warehouseUpdownTypeupShelfPackage(data);
} else if (Number(details.upshelfScanType) == 4) {
let data = {
allocationId: details.allocationId,
trayCode: details.uplistarr[0].trayCode
};
res = await api_user.warehouseUpdownTypeupShelfTray(data);
}
if (res.code == 200) {
const refresh = () => {
details.uplistarr = [];
details.scancode = details.allocationId;
details.allocationId = "";
details.renderList = [];
scandata();
tip.value.setisshow(false);
};
utils_utils.utils.handleToast("是否继续上架");
tip.value.setdetails({
title: "提示",
content: "是否继续上架?",
confirmTxt: "确认",
isshow: true,
isshowcancel: true,
success: async () => {
common_vendor.index.startPullDownRefresh({});
tip.value.setisshow(false);
},
cancel: () => {
refresh();
},
close: () => {
refresh();
}
});
}
common_vendor.index.hideLoading();
},
cancel: () => {
tip.value.setisshow(false);
},
close: () => {
tip.value.setisshow(false);
}
});
}
function fn2(tempArr, fnname) {
let result = [];
tempArr.map((item) => {
if (result.length == 0) {
item.enterNum = Number(item.enterNum);
result.push(item);
} else {
let ckindex = -1;
result.map((ite, index) => {
if (ite[fnname] == item[fnname]) {
ckindex = index;
}
});
if (ckindex != -1) {
result[ckindex].enterNum += Number(item.enterNum);
} else {
item.enterNum = Number(item.enterNum);
result.push(item);
}
}
});
return result;
}
function setstate(state) {
details.checkstate = state;
if (state === 1)
return details.renderList = details.uplistarr;
else if (state === 2)
return details.renderList = details.datalist;
}
function handleScan() {
common_vendor.index.scanCode({
success(res) {
console.log("res :>> ", res);
console.log("res.result :>> ", res.result);
details.scancode = res.result;
scandata();
}
});
}
const handleDownLoadByTray = () => {
if (!details.reqobj.trayCode)
return common_vendor.index.showToast({
title: "托盘数据有存在异常",
icon: "none"
});
tip.value.setdetails({
title: "提示",
content: "确认下架?",
confirmTxt: "确认",
isshow: true,
isshowcancel: true,
success: async () => {
let res = null;
const data = {
trayCode: details.reqobj.trayCode
};
res = await api_user.warehouseUpdownTypedownTrayCode(data, { isShowLoading: true });
if (res.code == 200) {
details.uplistarr = [];
details.scancode = details.allocationId;
details.allocationId = "";
details.renderList = [];
scandata();
}
tip.value.setisshow(false);
},
cancel: () => {
tip.value.setisshow(false);
},
close: () => {
tip.value.setisshow(false);
}
});
};
const handleRemove = (index) => {
utils_utils.utils.handleToast("确认移除数据");
tip.value.setdetails({
title: "提示",
content: "确认移除?",
confirmTxt: "确认",
isshow: true,
isshowcancel: true,
success: async () => {
details.uplistarr.splice(index, 1);
utils_utils.utils.handleToast("移除成功");
tip.value.setisshow(false);
},
cancel: () => {
tip.value.setisshow(false);
},
close: () => {
tip.value.setisshow(false);
}
});
};
const handleCheckAll = () => {
const _arr = [];
for (let iterator of details.orderPackageCodeList) {
iterator.checked = true;
_arr.push(iterator.code);
}
chooseOrderPackageCodeList.value = _arr;
};
const handleCloseCheck = () => {
chooseOrderPackageCodeList.value = [];
for (let iterator of details.orderPackageCodeList) {
iterator.checked = false;
}
};
const handleCheck = (item) => {
if (item.checked)
chooseOrderPackageCodeList.value.splice(chooseOrderPackageCodeList.value.indexOf(item.code), 1);
else
chooseOrderPackageCodeList.value.push(item.code);
item.checked = !item.checked;
};
const handleDownLoadByOrder = async (item) => {
console.log("item :>> ", item);
const res = await api_user.postorderUpshelfDetailByAllocationId({
orderCode: item.orderCode,
allocationId: details.allocationId
});
if (res.code !== 200)
return;
details.orderPackageCodeList = res.data && res.data.map((val) => {
return {
code: val,
checked: true
};
}) || [];
chooseOrderPackageCodeList.value = res.data || [];
downLoadByOrder.value.setDetails({
title: "包件下架",
showPopUp: true,
async success() {
if (details.orderPackageCodeList.length === 0)
return common_vendor.index.showToast({
title: "没有需要下架的数据",
icon: "none"
});
if (chooseOrderPackageCodeList.value.length === 0)
return common_vendor.index.showToast({
title: "最少选择一条需要下架的数据",
icon: "none"
});
const submitData = {
upShelfPackageList: chooseOrderPackageCodeList.value.map((val) => {
return { orderPackageCode: val };
})
};
const res2 = await api_user.warehouseUpdownTypedownPackage(submitData);
if (res2.code !== 200)
return;
details.scancode = details.allocationId;
scandata();
downLoadByOrder.value.details.showPopUp = false;
}
});
};
const handleDownLoadByStock = async (item) => {
const content = item.goodsType === 2 ? "零担下架" : "库存品下架";
details.stockItem = item;
details.enterNum = item.shelfNum;
downLoadByStock.value.setDetails({
title: content,
showPopUp: true,
async success() {
let content2 = "";
if (!utils_utils.utils.isNumber(details.enterNum)) {
content2 = "请输入数字";
} else {
details.enterNum = Math.floor(details.enterNum);
if (details.enterNum <= 0)
content2 = "请输入大于0的数量";
else if (details.enterNum > details.stockItem.shelfNum)
content2 = "不能大于上架数量";
}
if (content2)
return common_vendor.index.showToast({
title: content2,
icon: "none"
});
let res = {};
if (details.stockItem.goodsType === 2) {
const data = {
upShelfZeroOrderList: [
{
waybillCode: details.stockItem.waybillNo,
orderCode: details.stockItem.orderCode,
enterNum: details.enterNum,
allocationId: details.allocationId
}
]
};
res = await api_user.warehouseUpdownTypedownZeroOrder(data);
} else {
const data = {
upShelfStockList: [{
marketId: details.stockItem.marketId,
materialCode: details.stockItem.materialCode,
incomingBatch: details.stockItem.incomingBatch,
enterNum: details.enterNum,
allocationId: details.allocationId
}]
};
res = await api_user.warehouseUpdownTypedownStock(data);
}
console.log("res :>> ", res);
if (res.code !== 200)
return;
details.scancode = details.allocationId;
scandata();
downLoadByStock.value.details.showPopUp = false;
}
});
};
const handleDownLoad = (item) => {
const { goodsType } = item;
if (goodsType === 0 || goodsType === 1)
handleDownLoadByOrder(item);
else if (goodsType === 2)
handleDownLoadByStock(item);
else if (goodsType === 3)
handleDownLoadByStock(item);
};
const {
uplistarr,
checkstate,
reqobj,
renderList
} = common_vendor.toRefs(details);
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.p({
title: "扫描上架",
bgColor: "#D3832A",
leftIconColor: "#ffffff",
titleStyle: "color:#ffffff",
placeholder: true,
autoBack: true,
leftIconSize: "35"
}),
b: common_vendor.t((common_vendor.unref(reqobj).warehouseName || "") + "-" + (common_vendor.unref(reqobj).areaTitle || "") + "-" + (common_vendor.unref(reqobj).shelfTitle || "") + "排" + (common_vendor.unref(reqobj).positionInfo || "")),
c: common_vendor.t(common_vendor.unref(reqobj).warehouseName),
d: common_vendor.t(common_vendor.unref(reqobj).areaTitle),
e: common_vendor.t(common_vendor.unref(reqobj).totalNum || 0),
f: common_vendor.t(common_vendor.unref(reqobj).orderNum || 0),
g: common_vendor.t(common_vendor.unref(reqobj).stockTotalNum || 0),
h: common_vendor.t(common_vendor.unref(reqobj).stockNum || 0),
i: common_vendor.o(($event) => setstate(1)),
j: common_vendor.n(common_vendor.unref(checkstate) == 1 ? "xz" : ""),
k: common_vendor.o(($event) => setstate(2)),
l: common_vendor.n(common_vendor.unref(checkstate) == 2 ? "xz" : ""),
m: common_vendor.o(($event) => setstate(3)),
n: common_vendor.n(common_vendor.unref(checkstate) == 3 ? "xz" : ""),
o: common_vendor.unref(details).upshelfScanType === "4" && common_vendor.unref(details).renderList.length !== 0
}, common_vendor.unref(details).upshelfScanType === "4" && common_vendor.unref(details).renderList.length !== 0 ? {
p: common_vendor.t(common_vendor.unref(details).renderList[0].trayName),
q: common_vendor.t(common_vendor.unref(details).renderList.reduce((curr, item) => curr + item.shelfNum, 0)),
r: common_vendor.unref(details).checkstate === 1
} : {}, {
s: common_vendor.unref(details).checkstate === 1 || common_vendor.unref(details).checkstate === 2
}, common_vendor.unref(details).checkstate === 1 || common_vendor.unref(details).checkstate === 2 ? {
t: common_vendor.f(common_vendor.unref(renderList), (item, index, i0) => {
return common_vendor.e({
a: item.goodsType == 0
}, item.goodsType == 0 ? {
b: common_vendor.t(item.orderPackageCode),
c: common_vendor.o(($event) => handleRemove(index))
} : {}, {
d: item.goodsType == 0
}, item.goodsType == 0 ? {
e: common_vendor.t(item.orderCode),
f: common_vendor.o(($event) => goorderdetail(item, item.goodsType))
} : {}, {
g: item.goodsType == 0
}, item.goodsType == 0 ? {
h: common_vendor.t(Number(item.conditions) === 1 ? "定制品" : "库存品"),
i: common_vendor.o(($event) => goorderdetail(item, item.goodsType))
} : {}, {
j: item.goodsType === 1
}, item.goodsType === 1 ? {
k: common_vendor.t(item.serviceNum),
l: common_vendor.t(item.orderCode),
m: common_vendor.o(($event) => goorderdetail(item, item.goodsType))
} : {}, {
n: item.goodsType === 2
}, item.goodsType === 2 ? {
o: common_vendor.t(item.waybillNo),
p: common_vendor.t(item.orderCode)
} : {}, {
q: item.goodsType === 3
}, item.goodsType === 3 ? {
r: common_vendor.t(item.materialCode),
s: common_vendor.t(item.materialName),
t: common_vendor.t(item.orderCode),
v: common_vendor.t(item.marketName),
w: common_vendor.t(item.incomingBatch)
} : {}, Number(common_vendor.unref(details).upshelfScanType) === 1 || Number(common_vendor.unref(details).upshelfScanType) === 2 || common_vendor.unref(details).checkstate === 2 ? {
x: common_vendor.t(item.totalNum),
y: common_vendor.t(item.shelfNum)
} : {}, common_vendor.unref(details).checkstate === 2 ? {
z: common_vendor.o(($event) => handleDownLoad(item))
} : {}, Number(common_vendor.unref(details).upshelfScanType) != 3 ? {
A: item.totalNum == item.shelfNum ? "/pagesHome/static/qitao.png" : "/pagesHome/static/weiqitao.png"
} : {});
}),
v: Number(common_vendor.unref(details).upshelfScanType) === 1 || Number(common_vendor.unref(details).upshelfScanType) === 2 || common_vendor.unref(details).checkstate === 2,
w: common_vendor.unref(details).checkstate === 2,
x: Number(common_vendor.unref(details).upshelfScanType) != 3
} : {}, {
y: common_vendor.unref(checkstate) == 3 && common_vendor.unref(reqobj).trayCode
}, common_vendor.unref(checkstate) == 3 && common_vendor.unref(reqobj).trayCode ? {
z: common_vendor.t(common_vendor.unref(reqobj).trayCode + `(${common_vendor.unref(reqobj).trayName})`),
A: common_vendor.t(common_vendor.unref(reqobj).trayNum),
B: common_vendor.o(handleDownLoadByTray)
} : {}, {
C: common_vendor.o(handleScan),
D: common_vendor.o(uplist),
E: common_vendor.sr(tip, "1e3768d4-1", {
"k": "tip"
}),
F: chooseOrderPackageCodeList.value.length === common_vendor.unref(details).orderPackageCodeList.length && chooseOrderPackageCodeList.value.length !== 0,
G: common_vendor.o(handleCloseCheck),
H: chooseOrderPackageCodeList.value.length !== common_vendor.unref(details).orderPackageCodeList.length && chooseOrderPackageCodeList.value.length > 0,
I: common_vendor.o(handleCheckAll),
J: chooseOrderPackageCodeList.value.length === 0,
K: common_vendor.o(handleCheckAll),
L: common_vendor.f(common_vendor.unref(details).orderPackageCodeList, (item, k0, i0) => {
return common_vendor.e({
a: !item.checked
}, !item.checked ? {} : {}, {
b: item.checked
}, item.checked ? {} : {}, {
c: common_vendor.t(item.code),
d: common_vendor.o(($event) => handleCheck(item), item.code),
e: item.code
});
}),
M: common_vendor.sr(downLoadByOrder, "1e3768d4-2", {
"k": "downLoadByOrder"
}),
N: common_vendor.t(common_vendor.unref(details).stockItem.goodsType === 2 ? "运单号" : "物料名称"),
O: common_vendor.t(common_vendor.unref(details).stockItem.goodsType === 2 ? common_vendor.unref(details).stockItem.waybillNo : common_vendor.unref(details).stockItem.materialName),
P: common_vendor.t(common_vendor.unref(details).stockItem.shelfNum),
Q: common_vendor.unref(details).enterNum,
R: common_vendor.o(($event) => common_vendor.unref(details).enterNum = $event.detail.value),
S: common_vendor.sr(downLoadByStock, "1e3768d4-3", {
"k": "downLoadByStock"
})
});
};
}
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1e3768d4"], ["__file", "D:/worksp/logpm/pagesHome/pages/ScanUp/ScanUp.vue"]]);
wx.createPage(MiniProgramPage);