538 lines
20 KiB
JavaScript
538 lines
20 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_selectOperation2 = common_vendor.resolveComponent("selectOperation");
|
|
const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
|
|
const _easycom_selectComponentType2 = common_vendor.resolveComponent("selectComponentType");
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
const _easycom_uni_swipe_action_item2 = common_vendor.resolveComponent("uni-swipe-action-item");
|
|
const _easycom_uni_swipe_action2 = common_vendor.resolveComponent("uni-swipe-action");
|
|
const _easycom_uni_section2 = common_vendor.resolveComponent("uni-section");
|
|
const _easycom_uni_number_box2 = common_vendor.resolveComponent("uni-number-box");
|
|
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
|
|
const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
|
|
const _easycom_c_uni_goods_nav2 = common_vendor.resolveComponent("c-uni-goods-nav");
|
|
(_easycom_selectOperation2 + _easycom_uni_forms_item2 + _easycom_selectComponentType2 + _easycom_uni_icons2 + _easycom_uni_swipe_action_item2 + _easycom_uni_swipe_action2 + _easycom_uni_section2 + _easycom_uni_number_box2 + _easycom_uni_easyinput2 + _easycom_uni_forms2 + _easycom_c_uni_goods_nav2)();
|
|
}
|
|
const _easycom_selectOperation = () => "../../../components/selectOperation/selectOperation.js";
|
|
const _easycom_uni_forms_item = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-forms-item/uni-forms-item.js";
|
|
const _easycom_selectComponentType = () => "../../../components/selectComponentType/selectComponentType.js";
|
|
const _easycom_uni_icons = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-icons/uni-icons.js";
|
|
const _easycom_uni_swipe_action_item = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.js";
|
|
const _easycom_uni_swipe_action = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-swipe-action/uni-swipe-action.js";
|
|
const _easycom_uni_section = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-section/uni-section.js";
|
|
const _easycom_uni_number_box = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-number-box/uni-number-box.js";
|
|
const _easycom_uni_easyinput = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-easyinput/uni-easyinput.js";
|
|
const _easycom_uni_forms = () => "../../../node-modules/@dcloudio/uni-ui/lib/uni-forms/uni-forms.js";
|
|
const _easycom_c_uni_goods_nav = () => "../../../components/c-uni-goods-nav/c-uni-goods-nav.js";
|
|
if (!Math) {
|
|
(_easycom_selectOperation + _easycom_uni_forms_item + _easycom_selectComponentType + _easycom_uni_icons + _easycom_uni_swipe_action_item + _easycom_uni_swipe_action + _easycom_uni_section + _easycom_uni_number_box + _easycom_uni_easyinput + _easycom_uni_forms + _easycom_c_uni_goods_nav)();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "enterdetails",
|
|
setup(__props) {
|
|
const scancode = stores_scancode.useScanCodeStore();
|
|
const baseForm = common_vendor.ref(null);
|
|
const readOnly = common_vendor.ref(false);
|
|
const userInfo = common_vendor.ref(null);
|
|
const componentEnterRecordId = common_vendor.ref("");
|
|
const baseFormData = common_vendor.ref({
|
|
"componentEnterRecordId": "",
|
|
"owningRegion": "",
|
|
"componentType": "",
|
|
"enterQuantity": 0,
|
|
"componentPrice": "",
|
|
"createdUser": "",
|
|
"createdAt": "",
|
|
"state": "0",
|
|
"updateUser": "",
|
|
"updateAt": ""
|
|
});
|
|
const navOptions = common_vendor.reactive([{
|
|
icon: "download",
|
|
text: "暂存",
|
|
disable: false
|
|
}, {
|
|
icon: "closeempty",
|
|
text: "取消",
|
|
disable: false
|
|
}]);
|
|
const navButtonGroup = common_vendor.reactive([{
|
|
text: "入库",
|
|
backgroundColor: "#0078D4",
|
|
color: "#fff",
|
|
disable: false
|
|
}]);
|
|
common_vendor.onMounted(() => {
|
|
if (!utils_tools.isNullOrEmpty(componentEnterRecordId.value)) {
|
|
loadData();
|
|
}
|
|
});
|
|
common_vendor.onLoad((options) => {
|
|
if (options.componentEnterRecordId) {
|
|
componentEnterRecordId.value = options.componentEnterRecordId;
|
|
}
|
|
userInfo.value = common_vendor.index.getStorageSync("userInfo");
|
|
});
|
|
common_vendor.onShow(() => {
|
|
if (!utils_tools.isNullOrEmpty(scancode.code)) {
|
|
const arr = scancode.code;
|
|
for (let i = 0; i < arr.length; i++) {
|
|
if (scancode.type == "inBattery") {
|
|
const oneBattery = {
|
|
"batteryEnterRecordId": "",
|
|
"componentEnterRecordId": componentEnterRecordId.value,
|
|
"batteryCode": arr[i]
|
|
};
|
|
listBatteryData.value.push(oneBattery);
|
|
baseFormData.value.enterQuantity = listBatteryData.value.length;
|
|
} else if (scancode.type == "inHelmet") {
|
|
const oneHelmet = {
|
|
"helmetEnterRecordId": "",
|
|
"componentEnterRecordId": componentEnterRecordId.value,
|
|
"helmetCode": arr[i]
|
|
};
|
|
listHelmetData.value.push(oneHelmet);
|
|
baseFormData.value.enterQuantity = listHelmetData.value.length;
|
|
} else
|
|
break;
|
|
}
|
|
scancode.clearCode();
|
|
}
|
|
});
|
|
const loadData = () => {
|
|
utils_api.callOperateApi("ebikeComponentEnterRecords/getInfo?id=" + componentEnterRecordId.value, {}, "get").then((res) => {
|
|
if (res.code === 200) {
|
|
baseFormData.value = res.data;
|
|
if (baseFormData.value.componentType == "262711452730000") {
|
|
getBatteryList(baseFormData.value.componentEnterRecordId);
|
|
} else if (baseFormData.value.componentType == "262711452730001") {
|
|
getHelmetList(baseFormData.value.componentEnterRecordId);
|
|
}
|
|
if (baseFormData.value.state != "0") {
|
|
readOnly.value = true;
|
|
navOptions[0].disable = true;
|
|
navOptions[1].disable = true;
|
|
navButtonGroup[0].disable = true;
|
|
}
|
|
}
|
|
});
|
|
};
|
|
const listBatteryData = common_vendor.ref([]);
|
|
const listHelmetData = common_vendor.ref([]);
|
|
const getBatteryList = (componentEnterRecordId2, pageNo = 1, pageSize = 100) => {
|
|
const params = {
|
|
"componentEnterRecordId": componentEnterRecordId2,
|
|
"pageParam": {
|
|
"pageNum": pageNo,
|
|
"pageSize": pageSize
|
|
}
|
|
};
|
|
utils_api.callOperateApi("ebikeBatteryEnterRecords/list", params).then((res) => {
|
|
if (res.code === 200) {
|
|
listBatteryData.value.push(...res.data.records);
|
|
baseFormData.value.enterQuantity = listBatteryData.value.length;
|
|
if (res.data.totalRow > pageNo * pageSize) {
|
|
pageNo += 1;
|
|
getBatteryList(componentEnterRecordId2, pageNo, pageSize);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
const getHelmetList = (componentEnterRecordId2, pageNo = 1, pageSize = 100) => {
|
|
const params = {
|
|
"componentEnterRecordId": componentEnterRecordId2,
|
|
"pageParam": {
|
|
"pageNum": pageNo,
|
|
"pageSize": pageSize
|
|
}
|
|
};
|
|
utils_api.callOperateApi("ebikeHelmetEnterRecords/list", params).then((res) => {
|
|
if (res.code === 200) {
|
|
listHelmetData.value.push(...res.data.records);
|
|
baseFormData.value.enterQuantity = listHelmetData.value.length;
|
|
if (res.data.totalRow > pageNo * pageSize) {
|
|
pageNo += 1;
|
|
getHelmetList(componentEnterRecordId2, pageNo, pageSize);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
const navOptionsClick = (e) => {
|
|
const index = e.index;
|
|
if (index == 0) {
|
|
handleSubmit("0");
|
|
} else if (index == 1) {
|
|
handleSubmit("-1");
|
|
}
|
|
};
|
|
const navButtonClick = (e) => {
|
|
const index = e.index;
|
|
if (index == 0) {
|
|
if (baseForm.value) {
|
|
baseForm.value.validate().then((res) => {
|
|
if (baseFormData.value.componentType == "262711452730000") {
|
|
if (listBatteryData.value.length == 0) {
|
|
utils_tools.showModelMessage("电池列表不能为空!");
|
|
return false;
|
|
}
|
|
}
|
|
if (baseFormData.value.componentType == "262711452730001") {
|
|
if (listHelmetData.value.length == 0) {
|
|
utils_tools.showModelMessage("头盔列表不能为空!");
|
|
return false;
|
|
}
|
|
}
|
|
handleSubmit("1");
|
|
}).catch((err) => {
|
|
});
|
|
}
|
|
}
|
|
};
|
|
const handleSubmit = (state) => {
|
|
let sucessMsg = "保存成功";
|
|
let errorMsg = "保存失败";
|
|
if (state == "-1") {
|
|
sucessMsg = "取消成功";
|
|
errorMsg = "取消失败";
|
|
baseFormData.value.state = "-1";
|
|
} else if (state == "1") {
|
|
sucessMsg = "入库成功";
|
|
errorMsg = "入库失败";
|
|
baseFormData.value.state = "1";
|
|
}
|
|
const params = baseFormData.value;
|
|
saveBaseInfo((bresult) => {
|
|
if (!bresult) {
|
|
common_vendor.index.showToast({
|
|
title: errorMsg,
|
|
icon: "error",
|
|
duration: 5e3
|
|
});
|
|
} else {
|
|
if (params.componentType == "262711452730000") {
|
|
saveBatteryData((bresult1) => {
|
|
if (!bresult1) {
|
|
common_vendor.index.showToast({
|
|
title: errorMsg,
|
|
icon: "error",
|
|
duration: 5e3
|
|
});
|
|
} else {
|
|
common_vendor.index.showToast({
|
|
title: sucessMsg,
|
|
icon: "success",
|
|
duration: 1e3,
|
|
success: (res) => {
|
|
if (params.state != "0") {
|
|
setTimeout(function() {
|
|
common_vendor.index.navigateBack();
|
|
}, 1e3);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
} else if (params.componentType == "262711452730001") {
|
|
saveHelmetData((bresult1) => {
|
|
if (!bresult1) {
|
|
common_vendor.index.showToast({
|
|
title: errorMsg,
|
|
icon: "error",
|
|
duration: 5e3
|
|
});
|
|
} else {
|
|
common_vendor.index.showToast({
|
|
title: sucessMsg,
|
|
icon: "success",
|
|
duration: 1e3,
|
|
success: (res) => {
|
|
if (params.state != "0") {
|
|
setTimeout(function() {
|
|
common_vendor.index.navigateBack();
|
|
}, 1e3);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
common_vendor.index.showToast({
|
|
title: sucessMsg,
|
|
icon: "success",
|
|
duration: 1e3,
|
|
success: (res) => {
|
|
if (params.state != "0") {
|
|
setTimeout(function() {
|
|
common_vendor.index.navigateBack();
|
|
}, 1e3);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
};
|
|
const saveBaseInfo = (callback) => {
|
|
const params = baseFormData.value;
|
|
if (utils_tools.isNullOrEmpty(baseFormData.value.createdUser))
|
|
baseFormData.value.createdUser = userInfo.value.username;
|
|
if (utils_tools.isNullOrEmpty(baseFormData.value.createdAt))
|
|
baseFormData.value.createdAt = utils_tools.dataFormat(/* @__PURE__ */ new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
if (!utils_tools.isNullOrEmpty(componentEnterRecordId.value)) {
|
|
baseFormData.value.updateUser = userInfo.value.username;
|
|
baseFormData.value.updateAt = utils_tools.dataFormat(/* @__PURE__ */ new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
utils_api.callOperateApi("ebikeComponentEnterRecords/update", params).then((res) => {
|
|
if (res.code == "200")
|
|
callback(true);
|
|
else
|
|
callback(false);
|
|
});
|
|
} else {
|
|
utils_api.callOperateApi("ebikeComponentEnterRecords/save", params).then((res) => {
|
|
if (res.code == "200") {
|
|
componentEnterRecordId.value = res.data;
|
|
callback(true);
|
|
} else
|
|
callback(false);
|
|
});
|
|
}
|
|
};
|
|
const saveBatteryData = (callback) => {
|
|
const listdatas = [];
|
|
listBatteryData.value.forEach((item, index) => {
|
|
listdatas.push(item.batteryCode);
|
|
});
|
|
const params = {
|
|
componentEnterRecordId: componentEnterRecordId.value,
|
|
batteryCodes: listdatas
|
|
};
|
|
utils_api.callOperateApi("ebikeBatteryEnterRecords/batchSaveByComponentEnterRecordId", params).then((res) => {
|
|
if (res.code == "200") {
|
|
if (baseFormData.value.state == "1") {
|
|
utils_api.callEbikeInfo("saveBatteryInfo", listdatas).then((res2) => {
|
|
if (res2.code == "200") {
|
|
callback(true);
|
|
} else {
|
|
callback(false);
|
|
}
|
|
});
|
|
} else {
|
|
callback(true);
|
|
}
|
|
} else {
|
|
callback(false);
|
|
}
|
|
});
|
|
};
|
|
const saveHelmetData = (callback) => {
|
|
const listdatas = [];
|
|
listHelmetData.value.forEach((item, index) => {
|
|
listdatas.push(item.helmetCode);
|
|
});
|
|
const params = {
|
|
componentEnterRecordId: componentEnterRecordId.value,
|
|
helmetCodes: listdatas
|
|
};
|
|
utils_api.callOperateApi("ebikeHelmetEnterRecords/batchSaveByComponentEnterRecordId", params).then((res) => {
|
|
if (res.code == "200") {
|
|
if (baseFormData.value.state == "1") {
|
|
utils_api.callEbikeInfo("saveHelmetInfo", listdatas).then((res2) => {
|
|
if (res2.code == "200") {
|
|
callback(true);
|
|
} else {
|
|
callback(false);
|
|
}
|
|
});
|
|
} else {
|
|
callback(true);
|
|
}
|
|
} else {
|
|
callback(false);
|
|
}
|
|
});
|
|
};
|
|
const listBatteryOptions = common_vendor.reactive([{
|
|
text: "删除",
|
|
style: {
|
|
backgroundColor: "#007aff"
|
|
}
|
|
}]);
|
|
const listHelmetOptions = common_vendor.reactive([{
|
|
text: "删除",
|
|
style: {
|
|
backgroundColor: "#007aff"
|
|
}
|
|
}]);
|
|
const onBatteryListClick = (e, index, item) => {
|
|
if (e.position == "right") {
|
|
if (e.index == 0) {
|
|
if (index != -1) {
|
|
listBatteryData.value.splice(index, 1);
|
|
baseFormData.value.enterQuantity = listBatteryData.value.length;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
const onHelmetListClick = (e, index, item) => {
|
|
if (e.position == "right") {
|
|
if (e.index == 0) {
|
|
if (index != -1) {
|
|
listHelmetData.value.splice(index, 1);
|
|
baseFormData.value.enterQuantity = listHelmetData.value.length;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
const onBatteryScanClick = (e) => {
|
|
common_vendor.index.navigateTo({
|
|
url: `/pages/common/batchscancode?type=inBattery`
|
|
//
|
|
});
|
|
};
|
|
const onHelmetScanClick = (e) => {
|
|
common_vendor.index.navigateTo({
|
|
url: `/pages/common/batchscancode?type=inHelmet`
|
|
//
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.o(($event) => baseFormData.value.owningRegion = $event),
|
|
b: common_vendor.p({
|
|
placeholder: "请选择所属区域",
|
|
disabled: readOnly.value,
|
|
modelValue: baseFormData.value.owningRegion
|
|
}),
|
|
c: common_vendor.p({
|
|
label: "所属区域",
|
|
required: true,
|
|
name: "owningRegion",
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: "请选择所属区域"
|
|
}]
|
|
}),
|
|
d: common_vendor.o(($event) => baseFormData.value.componentType = $event),
|
|
e: common_vendor.p({
|
|
placeholder: "请选择部件",
|
|
disabled: readOnly.value,
|
|
modelValue: baseFormData.value.componentType
|
|
}),
|
|
f: common_vendor.p({
|
|
label: "选择部件",
|
|
required: true,
|
|
name: "componentType",
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: "请选择部件"
|
|
}]
|
|
}),
|
|
g: baseFormData.value.componentType == "262711452730000"
|
|
}, baseFormData.value.componentType == "262711452730000" ? common_vendor.e({
|
|
h: !readOnly.value
|
|
}, !readOnly.value ? {
|
|
i: common_vendor.o(onBatteryScanClick),
|
|
j: common_vendor.p({
|
|
type: "scan",
|
|
size: "20"
|
|
})
|
|
} : {}, {
|
|
k: common_vendor.f(listBatteryData.value, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.batteryCode),
|
|
b: index,
|
|
c: common_vendor.o(($event) => onBatteryListClick($event, index), index),
|
|
d: "407dab56-9-" + i0 + ",407dab56-8"
|
|
};
|
|
}),
|
|
l: common_vendor.p({
|
|
["right-options"]: listBatteryOptions,
|
|
disabled: readOnly.value
|
|
}),
|
|
m: common_vendor.p({
|
|
title: "电池列表",
|
|
type: "line"
|
|
})
|
|
}) : {}, {
|
|
n: baseFormData.value.componentType == "262711452730001"
|
|
}, baseFormData.value.componentType == "262711452730001" ? common_vendor.e({
|
|
o: !readOnly.value
|
|
}, !readOnly.value ? {
|
|
p: common_vendor.o(onHelmetScanClick),
|
|
q: common_vendor.p({
|
|
type: "scan",
|
|
size: "20"
|
|
})
|
|
} : {}, {
|
|
r: common_vendor.f(listHelmetData.value, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.helmetCode),
|
|
b: index,
|
|
c: common_vendor.o(($event) => onHelmetListClick($event, index), index),
|
|
d: "407dab56-13-" + i0 + ",407dab56-12"
|
|
};
|
|
}),
|
|
s: common_vendor.p({
|
|
["right-options"]: listHelmetOptions,
|
|
disabled: readOnly.value
|
|
}),
|
|
t: common_vendor.p({
|
|
title: "头盔列表",
|
|
type: "line"
|
|
})
|
|
}) : {}, {
|
|
v: common_vendor.o(($event) => baseFormData.value.enterQuantity = $event),
|
|
w: common_vendor.p({
|
|
placeholder: "请输入入库数量",
|
|
disabled: readOnly.value,
|
|
modelValue: baseFormData.value.enterQuantity
|
|
}),
|
|
x: common_vendor.p({
|
|
label: "入库数量",
|
|
required: true,
|
|
name: "enterQuantity",
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: "请输入入库数量"
|
|
}]
|
|
}),
|
|
y: common_vendor.o(($event) => baseFormData.value.componentPrice = $event),
|
|
z: common_vendor.p({
|
|
placeholder: "请输入部件单价,单位:元",
|
|
disabled: readOnly.value,
|
|
modelValue: baseFormData.value.componentPrice
|
|
}),
|
|
A: common_vendor.p({
|
|
label: "部件单价(元)"
|
|
}),
|
|
B: common_vendor.sr(baseForm, "407dab56-1,407dab56-0", {
|
|
"k": "baseForm"
|
|
}),
|
|
C: common_vendor.p({
|
|
modelValue: baseFormData.value,
|
|
labelWidth: "100px"
|
|
}),
|
|
D: common_vendor.p({
|
|
title: "部件入库",
|
|
type: "line"
|
|
}),
|
|
E: baseFormData.value.state == "0"
|
|
}, baseFormData.value.state == "0" ? {
|
|
F: common_vendor.o(navOptionsClick),
|
|
G: common_vendor.o(navButtonClick),
|
|
H: common_vendor.p({
|
|
fill: true,
|
|
options: navOptions,
|
|
buttonGroup: navButtonGroup
|
|
})
|
|
} : {});
|
|
};
|
|
}
|
|
};
|
|
wx.createPage(_sfc_main);
|
|
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/warehouse/component/enterdetails.js.map
|