295 lines
10 KiB
JavaScript
295 lines
10 KiB
JavaScript
|
|
"use strict";
|
||
|
|
const common_vendor = require("../../../common/vendor.js");
|
||
|
|
const utils_api = require("../../../utils/api.js");
|
||
|
|
const utils_tools = require("../../../utils/tools.js");
|
||
|
|
const stores_scancode = require("../../../stores/scancode.js");
|
||
|
|
if (!Array) {
|
||
|
|
const _easycom_uni_search_bar2 = common_vendor.resolveComponent("uni-search-bar");
|
||
|
|
const _easycom_uni_col2 = common_vendor.resolveComponent("uni-col");
|
||
|
|
const _easycom_uni_row2 = common_vendor.resolveComponent("uni-row");
|
||
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
||
|
|
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
|
||
|
|
const _easycom_c_uni_goods_nav2 = common_vendor.resolveComponent("c-uni-goods-nav");
|
||
|
|
(_easycom_uni_search_bar2 + _easycom_uni_col2 + _easycom_uni_row2 + _easycom_uni_icons2 + _easycom_uni_easyinput2 + _easycom_c_uni_goods_nav2)();
|
||
|
|
}
|
||
|
|
const _easycom_uni_search_bar = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-search-bar/uni-search-bar.js";
|
||
|
|
const _easycom_uni_col = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-col/uni-col.js";
|
||
|
|
const _easycom_uni_row = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-row/uni-row.js";
|
||
|
|
const _easycom_uni_icons = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-icons/uni-icons.js";
|
||
|
|
const _easycom_uni_easyinput = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-easyinput/uni-easyinput.js";
|
||
|
|
const _easycom_c_uni_goods_nav = () => "../../../components/c-uni-goods-nav/c-uni-goods-nav.js";
|
||
|
|
if (!Math) {
|
||
|
|
(_easycom_uni_search_bar + _easycom_uni_col + _easycom_uni_row + _easycom_uni_icons + _easycom_uni_easyinput + _easycom_c_uni_goods_nav)();
|
||
|
|
}
|
||
|
|
const _sfc_main = {
|
||
|
|
__name: "picking",
|
||
|
|
setup(__props) {
|
||
|
|
const scancode = stores_scancode.useScanCodeStore();
|
||
|
|
const userInfo = common_vendor.ref(null);
|
||
|
|
const userDefultOperation = common_vendor.ref(null);
|
||
|
|
const batteryCode = common_vendor.ref("");
|
||
|
|
const listBatteryCode = common_vendor.ref([]);
|
||
|
|
const listBatteryData = common_vendor.ref([]);
|
||
|
|
const inputState = common_vendor.ref(false);
|
||
|
|
const inputCodeValue = common_vendor.ref("");
|
||
|
|
const componentOutRecordId = common_vendor.ref("");
|
||
|
|
common_vendor.onLoad((options) => {
|
||
|
|
userInfo.value = common_vendor.index.getStorageSync("userInfo");
|
||
|
|
userDefultOperation.value = common_vendor.index.getStorageSync("userDefultOperation");
|
||
|
|
});
|
||
|
|
common_vendor.onShow(() => {
|
||
|
|
if (!utils_tools.isNullOrEmpty(scancode.code)) {
|
||
|
|
const arr = scancode.code;
|
||
|
|
for (let i = 0; i < arr.length; i++) {
|
||
|
|
if (scancode.type == "pickBattery") {
|
||
|
|
const exists = listBatteryData.value.some((item) => item.batteryCode == arr[i]);
|
||
|
|
if (!exists) {
|
||
|
|
const oneBattery = {
|
||
|
|
"batteryCode": arr[i]
|
||
|
|
};
|
||
|
|
listBatteryData.value.push(oneBattery);
|
||
|
|
inputCodeValue.value = "";
|
||
|
|
batteryCode.value = "";
|
||
|
|
searchInfo();
|
||
|
|
}
|
||
|
|
} else
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
scancode.clearCode();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
const searchInfo = (e) => {
|
||
|
|
if (!utils_tools.isNullOrEmpty(batteryCode.value)) {
|
||
|
|
if (listBatteryData.length > 0) {
|
||
|
|
const even = listBatteryData.value.filter((item) => item.batteryCode.indexOf(batteryCode.value) > -1);
|
||
|
|
listBatteryCode.value = even;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
listBatteryCode.value = listBatteryData.value;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const navOptions = common_vendor.reactive([{
|
||
|
|
icon: "scan",
|
||
|
|
text: "扫码新增",
|
||
|
|
disable: false
|
||
|
|
}, {
|
||
|
|
icon: "folder-add",
|
||
|
|
text: "编号新增",
|
||
|
|
disable: false
|
||
|
|
}]);
|
||
|
|
const navButtonGroup = common_vendor.reactive([{
|
||
|
|
text: "确认领取",
|
||
|
|
backgroundColor: "#0078D4",
|
||
|
|
color: "#fff",
|
||
|
|
disable: false
|
||
|
|
}]);
|
||
|
|
const navOptionsClick = (e) => {
|
||
|
|
const index = e.index;
|
||
|
|
if (index == 0) {
|
||
|
|
common_vendor.index.navigateTo({
|
||
|
|
url: `/pages/common/batchscancode?type=pickBattery`
|
||
|
|
//
|
||
|
|
});
|
||
|
|
} else if (index == 1) {
|
||
|
|
inputState.value = true;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const navButtonClick = (e) => {
|
||
|
|
const index = e.index;
|
||
|
|
let sucessMsg = "领取成功";
|
||
|
|
let errorMsg = "领取失败";
|
||
|
|
if (index == 0) {
|
||
|
|
if (listBatteryData.value.length == 0) {
|
||
|
|
utils_tools.showModelMessage("电池列表不能为空!");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
saveBatteryApply((bresult, message) => {
|
||
|
|
if (!bresult) {
|
||
|
|
common_vendor.index.showToast({
|
||
|
|
title: message,
|
||
|
|
icon: "none",
|
||
|
|
duration: 5e3
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
saveBaseInfo((bresult1, message1) => {
|
||
|
|
if (!bresult1) {
|
||
|
|
common_vendor.index.showToast({
|
||
|
|
title: errorMsg,
|
||
|
|
icon: "error",
|
||
|
|
duration: 5e3
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
saveBatteryData((bresult2, message2) => {
|
||
|
|
if (!bresult2) {
|
||
|
|
common_vendor.index.showToast({
|
||
|
|
title: errorMsg,
|
||
|
|
icon: "error",
|
||
|
|
duration: 5e3
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
common_vendor.index.showToast({
|
||
|
|
title: sucessMsg,
|
||
|
|
icon: "success",
|
||
|
|
duration: 1e3,
|
||
|
|
success: (res) => {
|
||
|
|
setTimeout(function() {
|
||
|
|
common_vendor.index.navigateBack();
|
||
|
|
}, 1e3);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const saveBaseInfo = (callback) => {
|
||
|
|
const params = {
|
||
|
|
"componentOutRecordId": "",
|
||
|
|
"owningRegion": userDefultOperation.value.regionId,
|
||
|
|
"componentType": "262711452730000",
|
||
|
|
"outQuantity": listBatteryData.value.length,
|
||
|
|
"createdUser": userInfo.value.username,
|
||
|
|
"createdAt": utils_tools.dataFormat(/* @__PURE__ */ new Date(), "yyyy-MM-dd HH:mm:ss"),
|
||
|
|
"state": "1"
|
||
|
|
};
|
||
|
|
utils_api.callOperateApi("ebikeComponentOutRecords/save", params).then((res) => {
|
||
|
|
if (res.code == "200") {
|
||
|
|
componentOutRecordId.value = res.data;
|
||
|
|
callback(true, "");
|
||
|
|
} else
|
||
|
|
callback(false, res.message);
|
||
|
|
});
|
||
|
|
};
|
||
|
|
const saveBatteryData = (callback) => {
|
||
|
|
const listdatas = [];
|
||
|
|
listBatteryData.value.forEach((item, index) => {
|
||
|
|
listdatas.push(item.batteryCode);
|
||
|
|
});
|
||
|
|
const params = {
|
||
|
|
componentOutRecordId: componentOutRecordId.value,
|
||
|
|
batteryCodes: listdatas
|
||
|
|
};
|
||
|
|
utils_api.callOperateApi("ebikeBatteryOutRecords/batchSaveByComponentOutRecordId", params).then((res) => {
|
||
|
|
if (res.code == "200") {
|
||
|
|
callback(true, "");
|
||
|
|
} else {
|
||
|
|
callback(false, res.message);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
const saveBatteryApply = (callback) => {
|
||
|
|
const listdatas = [];
|
||
|
|
listBatteryData.value.forEach((item, index) => {
|
||
|
|
listdatas.push(item.batteryCode);
|
||
|
|
});
|
||
|
|
const params = {
|
||
|
|
batteryCodes: listdatas
|
||
|
|
};
|
||
|
|
utils_api.callMaintenanceApi("ebikeBatteryApply/apply", params).then((res) => {
|
||
|
|
if (res.code == "200") {
|
||
|
|
callback(true, "");
|
||
|
|
} else {
|
||
|
|
callback(false, res.message);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
const onBatteryDelClick = (dbatteryCode) => {
|
||
|
|
const index = listBatteryData.value.findIndex((item) => item.batteryCode == dbatteryCode);
|
||
|
|
if (index != -1) {
|
||
|
|
listBatteryData.value.splice(index, 1);
|
||
|
|
batteryCode.value = "";
|
||
|
|
searchInfo();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const addCodeData = (lx) => {
|
||
|
|
if (lx == "suffix") {
|
||
|
|
if (utils_tools.isNullOrEmpty(inputCodeValue.value)) {
|
||
|
|
utils_tools.showModelMessage("电池编号不能为空!");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (listBatteryData.value.length > 0) {
|
||
|
|
const exists = listBatteryData.value.some((item) => item.batteryCode == inputCodeValue.value);
|
||
|
|
if (exists) {
|
||
|
|
utils_tools.showModelMessage("电池编号重复录入!");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
const oneBattery = {
|
||
|
|
"batteryCode": inputCodeValue.value
|
||
|
|
};
|
||
|
|
listBatteryData.value.push(oneBattery);
|
||
|
|
inputCodeValue.value = "";
|
||
|
|
inputState.value = false;
|
||
|
|
batteryCode.value = "";
|
||
|
|
searchInfo();
|
||
|
|
} else {
|
||
|
|
inputCodeValue.value = "";
|
||
|
|
inputState.value = false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
return (_ctx, _cache) => {
|
||
|
|
return common_vendor.e({
|
||
|
|
a: common_vendor.o(searchInfo),
|
||
|
|
b: common_vendor.o(searchInfo),
|
||
|
|
c: common_vendor.o(($event) => batteryCode.value = $event),
|
||
|
|
d: common_vendor.p({
|
||
|
|
radius: "5",
|
||
|
|
placeholder: "输入电池编号查询",
|
||
|
|
modelValue: batteryCode.value
|
||
|
|
}),
|
||
|
|
e: common_vendor.p({
|
||
|
|
span: 18
|
||
|
|
}),
|
||
|
|
f: common_vendor.p({
|
||
|
|
span: 6
|
||
|
|
}),
|
||
|
|
g: common_vendor.f(listBatteryCode.value, (item, index, i0) => {
|
||
|
|
return {
|
||
|
|
a: common_vendor.t(item.batteryCode),
|
||
|
|
b: "be1ecec1-5-" + i0 + "," + ("be1ecec1-4-" + i0),
|
||
|
|
c: common_vendor.o(($event) => onBatteryDelClick(item.batteryCode), index),
|
||
|
|
d: "be1ecec1-7-" + i0 + "," + ("be1ecec1-6-" + i0),
|
||
|
|
e: "be1ecec1-6-" + i0 + "," + ("be1ecec1-4-" + i0),
|
||
|
|
f: "be1ecec1-4-" + i0,
|
||
|
|
g: index
|
||
|
|
};
|
||
|
|
}),
|
||
|
|
h: common_vendor.p({
|
||
|
|
span: 18
|
||
|
|
}),
|
||
|
|
i: common_vendor.p({
|
||
|
|
type: "minus-filled",
|
||
|
|
size: "28"
|
||
|
|
}),
|
||
|
|
j: common_vendor.p({
|
||
|
|
span: 6
|
||
|
|
}),
|
||
|
|
k: inputState.value
|
||
|
|
}, inputState.value ? {
|
||
|
|
l: common_vendor.o(addCodeData),
|
||
|
|
m: common_vendor.o(($event) => inputCodeValue.value = $event),
|
||
|
|
n: common_vendor.p({
|
||
|
|
placeholder: "请输入电池编号",
|
||
|
|
prefixIcon: "down",
|
||
|
|
suffixIcon: "plus",
|
||
|
|
modelValue: inputCodeValue.value
|
||
|
|
})
|
||
|
|
} : {}, {
|
||
|
|
o: common_vendor.o(navOptionsClick),
|
||
|
|
p: common_vendor.o(navButtonClick),
|
||
|
|
q: common_vendor.p({
|
||
|
|
fill: true,
|
||
|
|
options: navOptions,
|
||
|
|
buttonGroup: navButtonGroup
|
||
|
|
})
|
||
|
|
});
|
||
|
|
};
|
||
|
|
}
|
||
|
|
};
|
||
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-be1ecec1"]]);
|
||
|
|
wx.createPage(MiniProgramPage);
|
||
|
|
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/warehouse/component/picking.js.map
|