init project

This commit is contained in:
tao
2025-11-17 10:01:33 +08:00
commit 77c123408d
1018 changed files with 136951 additions and 0 deletions

View File

@@ -0,0 +1,217 @@
<template>
<view>
<uni-collapse>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<!-- <uni-forms-item label="生产领料任务单" :labelWidth='90' name="drawTaskCode">
<uni-combox :candidates="drawTaskCodeList" emptyTips="无" @input="scanBarCode" v-model="formData.drawTaskCode"></uni-combox>
</uni-forms-item> -->
<uni-forms-item label="生产领料任务单" :labelWidth='90' name="drawTaskCode">
<uni-easyinput ref="myInput" suffixIcon="scan" @iconClick="scanBar" @confirm="scanBarCode"
v-model="formData.drawTaskCode" type="text" />
</uni-forms-item>
<!-- <uni-section title="确认生产领料出库单明细单" type="line" padding style="">
<uni-data-picker :localdata="dataTree" v-model="formData.drawOutDetailCode"
@change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened" @popupclosed="onpopupclosed">
</uni-data-picker>
</uni-section> -->
<uni-forms-item label="生产领料出库单" :labelWidth='90' name="drawOutCode">
<uni-combox :candidates="drawOutCodeList" emptyTips="无" @input="scanBarCodeOut"
v-model="formData.drawOutCode"></uni-combox>
</uni-forms-item>
<uni-forms-item label="生产领料出库单明细编码" :labelWidth='90' name="drawOutDetailCode" style="">
<view style="overflow: visible;z-index: 200;">
<uni-combox :candidates="drawOutDetailCodeList" style="z-index: 200px;" emptyTips="无"
@input="selectDetail" v-model="formData.drawOutDetailCode"></uni-combox>
</view>
<!-- <scroll-view style="overflow: visible;z-index: 200px;"> -->
<!-- <uni-combox :candidates="drawOutDetailCodeList" :z-index="100" emptyTips="无" @input="selectDetail" v-model="formData.drawOutDetailCode"></uni-combox> -->
<!-- </scroll-view> -->
</uni-forms-item>
<uni-forms-item>
</uni-forms-item>
</uni-forms>
<!-- <uni-collapse-item title="领料确认数量单明细" :open="true" > -->
<uni-collapse-item title="出库确认数量单明细" :open="true">
<uni-swipe-action :open="true">
<uni-swipe-action-item :rightOptions="rightOptions" :key="index"
v-for="(item, index) in formData.details" @click="(data) => clickDetail(index,data)"
@change="swipChange">
<uni-badge :text="index+1" type="primary"></uni-badge>
<uni-forms-item label="物料编码" :labelWidth='90' :name="'details.'+ index +'.materialCode'">
<uni-easyinput type="text" disabled v-model="item.materialCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料名称" :labelWidth='90' :name="'details.'+ index +'.materialName'">
<uni-easyinput type="text" disabled v-model="item.materialName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90' :name="'details.'+ index +'.materialBatchNo'">
<uni-easyinput disabled type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="物料箱号" :labelWidth='90' :name="'details.'+ index +'.materialLotNo'">
<uni-easyinput disabled type="number" v-model="item.materialLotNo" />
</uni-forms-item>
<uni-forms-item label="数量" :labelWidth='90' :name="'details.'+ index +'number'">
<uni-easyinput disabled type="number" v-model="item.pickNumber" />
</uni-forms-item>
<u-button type="primary" @click="submit(index)">数量正确</u-button>
</uni-swipe-action-item>
</uni-swipe-action>
</uni-collapse-item>
</uni-collapse>
</view>
</template>
<script>
import {
listOut,
getOut,
listPick,
addOut,
listTask,
getDetails,
getListDetail,
updatePick
} from "@/api/wms/pdcMaterial.js";
export default {
mounted() {
let myInput = this.$refs.myInput;
let inputWidth = myInput.$el.offsetWidth; // 获取元素宽度
console.log(inputWidth); // 输出宽度
},
data() {
return {
formData: {
drawTaskCode: null,
drawOutCode: '',
drawOutDetailCode: '',
details: [],
},
drawOutCode: null,
drawOutDetailCodeList: [],
drawOutCodeList: [],
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
rules: {
drawTaskCode: {
rules: [{
required: true,
errorMessage: '请输入领料任务单!'
}]
}
}
}
},
methods: {
collapseChange(isOpen) {
if (isOpen) {
this.showCombox = true;
} else {
this.showCombox = false;
this.$refs.combox.close(); // 使combox组件关闭
}
},
selectDetail() {
if (this.formData.drawOutDetailCode) {
this.formData.details = []
let obj = this.detailsList.find(item => item.drawOutDetailCode == this.formData.drawOutDetailCode)
obj.drawTaskCode = this.formData.drawTaskCode;
getListDetail(obj).then(response => {
this.formData.details = response.drawPickDetailList.map(obj => {
obj.storageLocationCode = null;
if (obj.pickArea) {
obj.storageLocationCode = obj.pickArea;
}
return obj;
});
})
}
},
scanBarCodeOut() {
this.detailsList = [];
this.drawOutDetailCodeList = [];
if (this.formData.drawOutCode) {
listOut({
drawOutCode: this.formData.drawOutCode
}).then(async res => {
getOut(res.rows[0].id).then(async response => {
if (response.data.wmsDrawOutDetailList.length > 0) {
this.detailsList = response.data.wmsDrawOutDetailList;
for (var i in response.data.wmsDrawOutDetailList) {
this.drawOutDetailCodeList.push(response.data
.wmsDrawOutDetailList[i].drawOutDetailCode);
}
}
})
});
}
// this.$nextTick(() => {
// this.$refs.collapse.resize();
// });
},
scanBarCode() {
this.drawOutCodeList = [];
if (this.formData.drawTaskCode) {
let data = {
drawTaskCode: this.formData.drawTaskCode
}
listOut(data).then(async res => {
if (res.rows.length > 0) {
for (var i = 0; i < res.rows.length; i++) {
this.drawOutCodeList.push(res.rows[i].drawOutCode);
}
}
});
} else {
this.$modal.msg("请输入生产领料任务单!")
}
},
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.drawTaskCode = res.result;
_this.scanBarCode();
}
});
},
submit(index) {
const _this = this;
_this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定数量正确吗?',
success: function(res) {
if (res.confirm) {
if (_this.formData.details[index].checkStatus == '2') {
_this.$modal.msg("该条明细数量已检验!")
} else {
_this.formData.details[index].drawOutCode = _this.formData
.drawOutCode;
_this.formData.details[index].checkStatus = "2";
updatePick(_this.formData.details[index]).then(response => {
_this.$modal.msgSuccess("检验完成!");
});
}
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,489 @@
<template>
<view>
<uni-collapse>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-collapse-item title="直接出库单" :open="true">
<uni-forms-item label="工单" :labelWidth='90' name="workOrderCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarPwo" @change="clearPwo"
v-model="workOrderCode" @confirm="scanBarPwoCode" type="text" />
</uni-forms-item>
<!-- <view class="example-body"> -->
<uni-forms-item label="生产领料任务单" :labelWidth='90' name="drawTaskCode">
<uni-combox :candidates="drawTaskCodeList" emptyTips="无" @input="scanBarCode"
v-model="formData.drawTaskCode"></uni-combox>
</uni-forms-item>
<!-- </view> -->
<!-- <uni-forms-item label="生产领料任务单" :labelWidth='90' name="drawTaskCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" @confirm="scanBarCode" v-model="formData.drawTaskCode" type="text" />
</uni-forms-item> -->
<uni-forms-item label="领料员" :labelWidth='90' name="drawBy">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar1" v-model="formData.drawBy" type="text" />
<uni-data-picker popup-title="请选择领料员" :localdata="dataTree" v-model="pickerData1"
@change="onchange1" @nodeclick="onnodeclick1" @popupopened="onpopupopened"
@popupclosed="onpopupclosed" style="margin-top: 5px;" :preload="true">
</uni-data-picker>
</uni-forms-item>
<uni-forms-item label="出库员" :labelWidth='90' name="warehouseOutBy">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar2" v-model="formData.warehouseOutBy"
type="text" />
<uni-data-picker popup-title="请选择出库员" :localdata="dataTree" v-model="pickerData2"
@change="onchange2" @nodeclick="onnodeclick2" @popupopened="onpopupopened"
@popupclosed="onpopupclosed" style="margin-top: 5px;" :preload="true">
</uni-data-picker>
</uni-forms-item>
<uni-forms-item label="仓库编码" :labelWidth='90' name="warehouseCode">
<uni-easyinput v-model="formData.warehouseCode" type="text" />
</uni-forms-item>
</uni-collapse-item>
<uni-collapse-item title="直接出库单明细" :open="true">
<uni-swipe-action>
<uni-swipe-action-item :rightOptions="rightOptions" :key="index"
v-for="(item, index) in formData.wmsDrawOutDetailList"
@click="(data) => clickDetail(index,data)" @change="swipChange">
<uni-badge :text="index+1" type="primary"></uni-badge>
<uni-forms-item label="领料出库单明细编码" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.drawOutDetailCode'">
<uni-easyinput type="text" disabled v-model="item.drawOutDetailCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料编码" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.materialCode'">
<uni-easyinput type="text" disabled v-model="item.materialCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料名称" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.materialName'">
<uni-easyinput type="text" disabled v-model="item.materialName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.materialBatchNo'">
<uni-easyinput disabled type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="物料箱号" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.materialLotNo'">
<uni-easyinput disabled type="number" v-model="item.materialLotNo" />
</uni-forms-item>
<uni-forms-item label="库位条码" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.storageLocationBarcode'">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarstorageLocationBarcode(index)"
@change="(data) => splitStlBarcode(index,data)" type="text"
v-model="item.storageLocationBarcode" />
</uni-forms-item>
<uni-forms-item label="出库数量" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'secondNumber'">
<u-number-box inputWidth="120" button-size="36" v-model="item.secondNumber"
min="0"></u-number-box>
</uni-forms-item>
<uni-forms-item label="单位" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'unitText'">
<uni-easyinput type="text" disabled v-model="item.unitText" />
</uni-forms-item>
</uni-swipe-action-item>
</uni-swipe-action>
</uni-collapse-item>
</uni-forms>
</uni-collapse>
<u-button type="primary" @click="submit">提交</u-button>
</view>
</template>
<script>
import {
listTask,
listPick,
addOut,
getDetails,
getDrawOutDirectlyByTaskCode
} from "@/api/wms/pdcMaterial.js";
import {
listEmployee
} from "@/api/mes/jobIn.js";
import {
listUnit
} from "@/api/basic/unit";
import {
listDepartment
} from "@/api/basic/department";
export default {
mounted() {
// this.test();
listUnit().then((res) => {
this.unitList = res.rows.map(item => {
let obj = {
text: item.unitCode + ":" + item.unitName,
value: item.id
}
return obj
})
})
this.selectTypeList();
listEmployee().then((res) => {
this.empList = res.rows
})
listDepartment().then((res) => {
this.dptList = res.rows
})
},
data() {
return {
dptList: [],
unitList: [],
empList: [],
item: '',
dataTree: [],
pickerData1: '',
pickerData2: '',
workOrderCode: '',
drawTaskCodeList: [],
checkStorageLocationBarcode: true,
formData: {
drawTaskCode: '',
billType: '2',
status: '1',
wmsDrawOutDetailList: [],
drawBy: null,
warehouseCode: null,
warehouseOutBy: null
},
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
rules: {
drawTaskCode: {
rules: [{
required: true,
errorMessage: '请输入生产领料任务单!'
}]
},
drawBy: {
rules: [{
required: true,
errorMessage: '请输入领料员编码!'
}]
},
warehouseOutBy: {
rules: [{
required: true,
errorMessage: '请输入出库员编码!'
}]
},
// warehouseCode:{
// rules:[
// {required:true,errorMessage:'请输入仓库编码!'}
// ]
// },
}
}
},
methods: {
onnodeclick1(e) {
console.log(e)
this.item = e
this.onchange1(this.item)
},
onnodeclick2(e) {
console.log(e)
this.item = e
this.onchange2(this.item)
},
onpopupopened(e) {
this.dataTree = []
this.empList.filter(item => item.deptId).forEach(item => {
item.departmentTitle = this.dptList.find(item2 => item2.id == item.deptId).departmentTitle
// 检查dataTree中是否已存在相同部门
let existingDept = this.dataTree.find(dept => dept.value === item.deptId);
if (existingDept) {
// 如果已存在相同部门则将员工信息push进该部门的children数组
existingDept.children.push({
text: item.name,
value: item.empCode
});
} else {
// 如果不存在相同部门则创建一个新部门对象包括children数组并将员工信息push进去
let newDept = {
text: item.departmentTitle,
value: item.deptId,
children: [{
text: item.name,
// value: item.empCode + '/'
value: item.empCode
}]
};
this.dataTree.push(newDept);
}
})
console.log(this.dataTree)
},
onpopupclosed() {
//处理不同步
// this.$nextTick(() => {
// this.pickerData = this.item.value;
// this.formData.pickerData = this.item.value;
// if (!this.item) return
// this.onchange(this.item)
// });
},
onchange2(e) {
console.log(e)
this.formData.warehouseOutBy = null
this.$set(this.formData, 'warehouseOutBy', e.value.split('/')[0])
// if (e.value.includes('/')) {
// this.$set(this.formData, 'warehouseOutBy', e.value.split('/')[0])
// }
},
onchange1(e) {
console.log(e)
this.formData.drawBy = null
this.$set(this.formData, 'drawBy', e.value.split('/')[0])
// if (e.value.includes('/')) {
// this.$set(this.formData, 'drawBy', e.value.split('/')[0])
// }
},
clickDetail(e, index) {
console.log('返回:', e);
this.formData.wmsDrawOutDetailList.splice(e, 1);
},
splitStlBarcode(i) {
// this.formData.wmsDrawOutDetailList[i].whCode = null;
// this.formData.wmsDrawOutDetailList[i].storageAreaCode = null;
// this.formData.wmsDrawOutDetailList[i].shelvesCode = null;
// this.formData.wmsDrawOutDetailList[i].storageLocationCode = null;
// let array = this.formData.wmsDrawOutDetailList[i].storageLocationBarcode.split('-');
// let [whCode, storageAreaCode, shelvesCode, storageLocationCode, extra] = array;
// this.formData.wmsDrawOutDetailList[i].whCode = whCode || null;
// this.formData.wmsDrawOutDetailList[i].storageAreaCode = storageAreaCode || null;
// this.formData.wmsDrawOutDetailList[i].shelvesCode = shelvesCode || null;
// this.formData.wmsDrawOutDetailList[i].storageLocationCode = extra ? `${storageLocationCode}-${extra}` :
// storageLocationCode || null;
const _this = this;
const detail = _this.formData.wmsDrawOutDetailList[i];
detail.whCode = null;
detail.storageAreaCode = null;
detail.shelvesCode = null;
detail.storageLocationCode = null;
let barcode = detail.storageLocationBarcode;
if (!barcode) {
return; // 如果没有条码,不做任何处理
}
let [whCode, storageAreaCode, shelvesCode, storageLocationCode, extra] = barcode.split('-');
// const checkAndSetField = (obj, field, value, msg) => {
// if (!value) {
// _this.$modal.msg(msg);
// _this.$set(obj, field, null);
// _this.$nextTick(() => {
// _this.$set(obj, "storageLocationBarcode", null);
// });
// obj.storageLocationBarcode = null
// return false;
// }
// return true;
// };
if (whCode) {
let warehouseObj = _this.$store.getters.warehouseOptions.find(item => item.warehouseCode == whCode);
if (!warehouseObj) {
_this.checkStorageLocationBarcode = false;
_this.$modal.msg("货架不存在!");
return;
}
if (storageAreaCode) {
let areaObj = _this.$store.getters.areaOptions.find(item => item.storageAreaCode ==
storageAreaCode);
if (!areaObj) {
_this.checkStorageLocationBarcode = false;
_this.$modal.msg("库区不存在!");
return;
}
if (shelvesCode) {
let shelvesObj = _this.$store.getters.shelvesOptions.find(item => item.storageShelvesCode ==
shelvesCode);
if (!shelvesObj) {
_this.checkStorageLocationBarcode = false;
_this.$modal.msg("货架不存在!");
return;
};
if (storageLocationCode) {
let locationObj = _this.$store.getters.locationOptions.find(item => item
.storageLocationCode == (extra ?
(storageLocationCode + '-' + extra) : storageLocationCode));
if (!locationObj) {
_this.checkStorageLocationBarcode = false;
_this.$modal.msg("库位不存在!");
return;
};
}
}
}
}
_this.checkStorageLocationBarcode = true;
detail.whCode = whCode || null;
detail.storageAreaCode = storageAreaCode || null;
detail.shelvesCode = shelvesCode || null;
detail.storageLocationCode = extra ? `${storageLocationCode}-${extra}` : storageLocationCode || null;
},
scanBarstorageLocationBarcode(i) {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.$set(_this.formData.wmsDrawOutDetailList[i], "storageLocationBarcode",
res
.result);
_this.splitStlBarcode(i);
}
});
},
clearPwo() {
if (this.workOrderCode == '' || !this.workOrderCode) {
this.selectTypeList();
}
},
scanBarPwo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.workOrderCode = res.result;
_this.scanBarPwoCode();
}
});
},
scanBarPwoCode() {
this.drawTaskCodeList = [];
if (this.workOrderCode) {
listTask({
workOrderCode: this.workOrderCode
}).then(async response => {
for (var i = 0; i < response.rows.length; i++) {
this.drawTaskCodeList.push(response.rows[i].drawTaskCode);
}
});
}
},
selectTypeList() {
listTask().then(async res => {
for (var i in res.rows) {
this.drawTaskCodeList.push(res.rows[i].drawTaskCode);
}
});
},
test() {
},
scanBarCode() {
if (this.formData.drawTaskCode) {
let data = {
drawTaskCode: this.formData.drawTaskCode
}
//换成直接出库调用的明细接口
getDrawOutDirectlyByTaskCode(this.formData).then((res) => {
console.log(res);
this.formData = res.wmsDrawOut;
this.formData.wmsDrawOutDetailList = res.wmsDrawOut.wmsDrawOutDetailList.map(
item => {
let unitobj = this.unitList.find(i => i.value == item.secondUnitId)
if (unitobj) {
item.unitText = unitobj.text
}
item.storageLocationBarcode = item.whCode ? (item.storageAreaCode ? (
item.shelvesCode ? (item.storageLocationCode ? (item
.whCode + '-' + item.storageAreaCode + '-' + item
.shelvesCode +
'-' + item.storageLocationCode) : (item.whCode +
'-' + item.storageAreaCode + '-' + item
.shelvesCode
)) : (item.whCode + '-' + item.storageAreaCode)) : item
.whCode) : ''
return item
})
});
} else {
this.$modal.msg("请输入生产领料任务单!")
}
},
//生产领料任务单
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.drawTaskCode = res.result;
_this.scanBarCode(_this.formData.drawTaskCode);
}
});
},
//领料员
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.drawBy = res.result;
console.log(res.result);
}
});
},
//出库员
scanBar2() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.warehouseOutBy = res.result;
}
});
},
//仓库编码
scanBar3() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.warehouseCode = res.result;
}
});
},
submit() {
const _this = this;
this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定完成直接出库吗?',
success: function(res) {
if (res.confirm) {
if (!_this.checkStorageLocationBarcode) {
_this.$modal.msg("库位条码校验错误,请重新输入!")
return;
}
_this.$modal.loading('提交中')
addOut(_this.formData).then(async res => {
_this.$modal.closeLoading();
_this.$modal.msgSuccess("直接出库成功!");
setTimeout(() => {
_this.$tab.switchTab(
"/pages/work/index");
}, 500);
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
}
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,452 @@
<template>
<view>
<uni-collapse>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-collapse-item title="领料出库单" :open="true">
<!-- <view class="example-body"> -->
<uni-forms-item label="工单" :labelWidth='90' name="workOrderCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarPwo" @change="clearPwo"
v-model="workOrderCode" @confirm="scanBarPwoCode" type="text" />
</uni-forms-item>
<uni-forms-item label="生产领料任务单" :labelWidth='90' name="drawTaskCode">
<uni-combox :candidates="drawTaskCodeList" emptyTips="无" @input="scanBarCode"
v-model="formData.drawTaskCode"></uni-combox>
</uni-forms-item>
<!-- </view> -->
<!-- <uni-forms-item label="生产领料任务单" :labelWidth='90' name="drawTaskCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" @confirm="scanBarCode" v-model="formData.drawTaskCode" type="text" />
</uni-forms-item> -->
<uni-forms-item label="领料员" :labelWidth='90' name="drawBy">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar1" v-model="formData.drawBy" type="text" />
<uni-data-picker popup-title="请选择领料员" :localdata="dataTree" v-model="pickerData1"
@change="onchange1" @nodeclick="onnodeclick1" @popupopened="onpopupopened"
@popupclosed="onpopupclosed" style="margin-top: 5px;" :preload="true">
</uni-data-picker>
</uni-forms-item>
<uni-forms-item label="出库员" :labelWidth='90' name="warehouseOutBy">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar2" v-model="formData.warehouseOutBy"
type="text" />
<uni-data-picker popup-title="请选择出库员" :localdata="dataTree" v-model="pickerData2"
@change="onchange2" @nodeclick="onnodeclick2" @popupopened="onpopupopened"
@popupclosed="onpopupclosed" style="margin-top: 5px;" :preload="true">
</uni-data-picker>
</uni-forms-item>
<uni-forms-item label="仓库编码" :labelWidth='90' name="warehouseCode">
<uni-easyinput v-model="formData.warehouseCode" type="text" />
</uni-forms-item>
</uni-collapse-item>
<uni-collapse-item title="领料出库单明细" :open="true">
<uni-swipe-action>
<uni-swipe-action-item :rightOptions="rightOptions" :key="index"
v-for="(item, index) in formData.wmsDrawOutDetailList"
@click="(data) => clickDetail(index,data)" @change="swipChange">
<uni-badge :text="index+1" type="primary"></uni-badge>
<uni-forms-item label="领料出库单明细编码" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.drawOutDetailCode'">
<uni-easyinput type="text" disabled v-model="item.drawOutDetailCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料编码" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.materialCode'">
<uni-easyinput type="text" disabled v-model="item.materialCode"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料名称" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.materialName'">
<uni-easyinput type="text" disabled v-model="item.materialName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="物料批号" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.materialBatchNo'">
<uni-easyinput disabled type="text" v-model="item.materialBatchNo" />
</uni-forms-item>
<uni-forms-item label="物料箱号" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'.materialLotNo'">
<uni-easyinput disabled type="number" v-model="item.materialLotNo" />
</uni-forms-item>
<uni-forms-item label="库位条码" :labelWidth='90'
name="'wmsProductInDetailList.'+ index +'.storageLocationBarcode'">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarstorageLocationBarcode(index)"
@change="splitStlBarcode(index)" type="text"
v-model="item.storageLocationBarcode" />
</uni-forms-item>
<uni-forms-item label="出库数量" :labelWidth='90'
:name="'wmsDrawOutDetailList.'+ index +'number'">
<u-number-box inputWidth="120" button-size="36" v-model="item.number"
min="0"></u-number-box>
</uni-forms-item>
</uni-swipe-action-item>
</uni-swipe-action>
</uni-collapse-item>
</uni-forms>
</uni-collapse>
<u-button type="primary" @click="submit">提交</u-button>
<view>
<!-- 提示窗示例 -->
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog type="success" cancelText="取消" confirmText="确定" title="数量检验" content="是否检验数量"
@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
</uni-popup>
</view>
</view>
</template>
<script>
import {
listPick,
addOut,
listTask,
getDetails
} from "@/api/wms/pdcMaterial.js";
import {
listEmployee
} from "@/api/mes/jobIn.js";
import {
listDepartment
} from "@/api/basic/department";
export default {
mounted() {
this.selectTypeList();
listDepartment().then((res) => {
this.dptList = res.rows
})
listEmployee().then((res) => {
this.empList = res.rows
})
},
data() {
return {
dptList: [],
empList: [],
item: '',
dataTree: [],
pickerData1: '',
pickerData2: '',
workOrderCode: '',
drawTaskCodeList: [],
checkStorageLocationBarcode: true,
formData: {
drawTaskCode: '',
warehouseCode: null,
drawBy: null,
warehouseOutBy: null,
wmsDrawOutDetailList: [],
billType: '1'
},
rightOptions: [{
text: '删除',
style: {
backgroundColor: '#ff2a17'
}
}, ],
rules: {
drawTaskCode: {
rules: [{
required: true,
errorMessage: '请输入领料任务单!'
}]
},
materialCode: {
rules: [{
required: true,
errorMessage: '请输入物料编码!'
}]
},
number: {
rules: [{
required: true,
errorMessage: '请输入出库数量!'
}]
},
drawBy: {
rules: [{
required: true,
errorMessage: '请输入领料员!'
}]
},
warehouseOutBy: {
rules: [{
required: true,
errorMessage: '请输入出库员!'
}]
},
}
}
},
methods: {
onnodeclick1(e) {
console.log(e)
this.item = e
this.onchange1(this.item)
},
onnodeclick2(e) {
console.log(e)
this.item = e
this.onchange2(this.item)
},
onpopupopened(e) {
this.dataTree = []
this.empList.filter(item => item.deptId).forEach(item => {
item.departmentTitle = this.dptList.find(item2 => item2.id == item.deptId).departmentTitle
// 检查dataTree中是否已存在相同部门
let existingDept = this.dataTree.find(dept => dept.value === item.deptId);
if (existingDept) {
// 如果已存在相同部门则将员工信息push进该部门的children数组
existingDept.children.push({
text: item.name,
value: item.empCode
});
} else {
// 如果不存在相同部门则创建一个新部门对象包括children数组并将员工信息push进去
let newDept = {
text: item.departmentTitle,
value: item.deptId,
children: [{
text: item.name,
// value: item.empCode + '/'
value: item.empCode
}]
};
this.dataTree.push(newDept);
}
})
console.log(this.dataTree)
},
onpopupclosed() {
//处理不同步
// this.$nextTick(() => {
// this.pickerData = this.item.value;
// this.formData.pickerData = this.item.value;
// if (!this.item) return
// this.onchange(this.item)
// });
},
onchange2(e) {
console.log(e)
this.formData.warehouseOutBy = null
this.$set(this.formData, 'warehouseOutBy', e.value.split('/')[0])
// if (e.value.includes('/')) {
// this.$set(this.formData, 'warehouseOutBy', e.value.split('/')[0])
// }
},
onchange1(e) {
console.log(e)
this.formData.drawBy = null
this.$set(this.formData, 'drawBy', e.value.split('/')[0])
// if (e.value.includes('/')) {
// this.$set(this.formData, 'drawBy', e.value.split('/')[0])
// }
},
splitStlBarcode(i) {
const _this = this;
const detail = _this.formData.wmsDrawOutDetailList[i];
detail.whCode = null;
detail.storageAreaCode = null;
detail.shelvesCode = null;
detail.storageLocationCode = null;
let barcode = detail.storageLocationBarcode;
if (!barcode) {
return; // 如果没有条码,不做任何处理
}
let [whCode, storageAreaCode, shelvesCode, storageLocationCode, extra] = barcode.split('-');
if (whCode) {
let warehouseObj = _this.$store.getters.warehouseOptions.find(item => item.warehouseCode == whCode);
if (!warehouseObj) {
_this.checkStorageLocationBarcode = false;
_this.$modal.msg("货架不存在!");
return;
}
if (storageAreaCode) {
let areaObj = _this.$store.getters.areaOptions.find(item => item.storageAreaCode ==
storageAreaCode);
if (!areaObj) {
_this.checkStorageLocationBarcode = false;
_this.$modal.msg("库区不存在!");
return;
}
if (shelvesCode) {
let shelvesObj = _this.$store.getters.shelvesOptions.find(item => item.storageShelvesCode ==
shelvesCode);
if (!shelvesObj) {
_this.checkStorageLocationBarcode = false;
_this.$modal.msg("货架不存在!");
return;
};
if (storageLocationCode) {
let locationObj = _this.$store.getters.locationOptions.find(item => item
.storageLocationCode == (extra ?
(storageLocationCode + '-' + extra) : storageLocationCode));
if (!locationObj) {
_this.checkStorageLocationBarcode = false;
_this.$modal.msg("库位不存在!");
return;
};
}
}
}
}
_this.checkStorageLocationBarcode = true;
detail.whCode = whCode || null;
detail.storageAreaCode = storageAreaCode || null;
detail.shelvesCode = shelvesCode || null;
detail.storageLocationCode = extra ? `${storageLocationCode}-${extra}` : storageLocationCode || null;
},
scanBarstorageLocationBarcode(i) {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.$set(_this.formData.wmsDrawOutDetailList[i], "storageLocationBarcode", res
.result);
// _this.formData.wmsDrawOutDetailList[i].storageLocationBarcode = res.result;
_this.splitStlBarcode(i);
}
});
},
swipChange(e, index) {
console.log('返回:', e);
console.log('当前索引:', index);
},
clickDetail(e, index) {
console.log('返回:', e);
this.formData.wmsDrawOutDetailList.splice(e, 1);
// console.log('当前索引:', index);
},
clearPwo() {
if (this.workOrderCode == '' || !this.workOrderCode) {
this.selectTypeList();
}
},
scanBarPwo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.workOrderCode = res.result;
_this.scanBarPwoCode();
}
});
},
scanBarPwoCode() {
this.drawTaskCodeList = [];
if (this.workOrderCode) {
listTask({
workOrderCode: this.workOrderCode
}).then(async response => {
for (var i = 0; i < response.rows.length; i++) {
this.drawTaskCodeList.push(response.rows[i].drawTaskCode);
}
});
}
},
selectTypeList() {
listTask().then(async res => {
this.drawTaskCodeList = res.rows.map(item => {
return item.drawTaskCode
});
});
},
scanBarCode() {
if (this.formData.drawTaskCode) {
let data = {
drawTaskCode: this.formData.drawTaskCode
}
getDetails(data).then(async res => {
console.log(res);
if (res.details.length > 0) {
this.formData.wmsDrawOutDetailList = res.details.map(item => {
item.storageLocationBarcode = item.whCode ? (item.storageAreaCode ? (
item.shelvesCode ? (item.storageLocationCode ? (item
.whCode + '-' + item.storageAreaCode + '-' + item
.shelvesCode +
'-' + item.storageLocationCode) : (item.whCode +
'-' + item.storageAreaCode + '-' + item
.shelvesCode
)) : (item.whCode + '-' + item.storageAreaCode)) : item
.whCode) : ''
return item
});
}
});
} else {
this.$modal.msg("请输入生产领料任务单!")
}
},
//领料员
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.drawBy = res.result;
// _this.scanBarCode(_this.formData.drawBy);
console.log(res.result);
}
});
},
//出库员
scanBar2() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.warehouseOutBy = res.result;
// _this.scanBarCode(_this.formData.warehouseOutBy);
}
});
},
//仓库编码
scanBar3() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.warehouseCode = res.result;
}
});
},
submit() {
const _this = this;
_this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定出库该物料吗?',
success: function(res) {
if (res.confirm) {
console.log(_this.formData)
if (!_this.checkStorageLocationBarcode) {
_this.$modal.msg("库位条码校验错误,请重新输入!")
return;
}
_this.$modal.loading('提交中')
addOut(_this.formData).then(async res => {
_this.$modal.msgSuccess("出库成功!");
_this.$modal.closeLoading();
// _this.$refs.alertDialog.open()
setTimeout(() => {
_this.$tab.switchTab("/pages/work/index");
}, 500);
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
// dialogConfirm() {
// uni.redirectTo({
// url: '/pages/target/?param1=xxx&param2=yyy'
// });
// this.$tab.navigateTo('/pages/wms/pdcMaterial/confirmNum');
// },
// dialogClose() {
// this.$tab.switchTab('/pages/work/index');
// },
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,66 @@
<template>
<view class="uni-padding-wrap uni-common-mt" >
<view class="grid-body">
<uni-grid :column="2" :showBorder="false" @change="changeGrid1">
<uni-grid-item :index="1" style="line-height: 100px;margin-top:100px;margin-left:37.5%;width: 100%;">
<view class="grid-item-box">
<uni-icons custom-prefix="iconfont" type="icon-lingliaodan" size="30"></uni-icons>
<text class="text">领料拣货</text>
</view>
</uni-grid-item>
<uni-grid-item :index="2" style="line-height: 100px;margin-left:37.5%;width: 100%;">
<view class="grid-item-box">
<uni-icons custom-prefix="iconfont" type="icon-navicon-ckd" size="30"></uni-icons>
<text class="text">领料出库</text>
</view>
</uni-grid-item>
</uni-grid>
</view>
</view>
</view>
</template>
<script>
export default {
onLoad: function() {
},
methods: {
changeGrid1(e) {
console.log(e.detail.index);
if (e.detail.index == 1) {
this.$tab.navigateTo('/pages/wms/pdcMaterial/pdcPick');
} else if (e.detail.index == 2) {
this.$tab.navigateTo('/pages/wms/pdcMaterial/pdcCk');
}
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>

View File

@@ -0,0 +1,723 @@
<template>
<view>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="工单" :labelWidth='90' name="workOrderCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarPwo" v-model="formData.workOrderCode"
@confirm="scanBarPwoCode" type="text" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="领料任务单" :labelWidth='90' name="drawTaskCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" v-model="formData.drawTaskCode"
@confirm="scanBarCode" type="text" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="拣货单" :labelWidth='90' name="pickCode">
<uni-easyinput suffixIcon="scan" @confirm="scanBarCode" @iconClick="scanBar4"
v-model="formData.pickCode" type="text" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="物料编码" :labelWidth='90' name="materialCode">
<uni-easyinput disabled v-model="formData.materialCode" type="text" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="物料名称" :labelWidth='90' name="materialName">
<uni-easyinput type="text" v-model="formData.materialName" disabled />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="物料批号" :labelWidth='90' name="materialBatchNo">
<uni-easyinput disabled type="text" v-model="formData.materialBatchNo" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="库位编码" :labelWidth='90' name="storageLocationCode">
<uni-easyinput disabled type="text" v-model="formData.storageLocationCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="原有数量" :labelWidth='90' name="originNumber">
<uni-easyinput disabled type="number" v-model="formData.originNumber" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="拣货数量" :labelWidth='90' name="pickNumber">
<uni-easyinput disabled type="number" v-model="formData.pickNumber" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="现有数量" :labelWidth='90' name="xyNum">
<uni-easyinput disabled type="number" v-model="xyNum" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="拣货区" :labelWidth='90' :name="pickerData" :rules="[{'required': true,
errorMessage: '请输入拣货区!'}]">
<uni-data-picker popup-title="请选择所在货区" :localdata="dataTree" v-model="pickerData"
@change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened"
@popupclosed="onpopupclosed">
</uni-data-picker>
<!-- <uni-easyinput type="text" v-model="formData.pickArea" /> -->
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="拣货时间" :labelWidth='90' name="pickTime">
<!-- <view class="uni-list-cell-db"> -->
<!-- <u-datetime-picker ref="datetimePicker" @cancel="close" @confirm="confirm" :show="show"
v-model="value1" @change="bindDateChange" mode="datetime">
<view class="uni-input" v-model="formData.pickTime">{{formData.pickTime}}</view>
</u-datetime-picker> -->
<!-- <picker style="padding-top: 10px;" mode="time" :value="formData.pickTime" :start="startDate"
:end="endDate" @change="bindDateChange">
<view class="uni-input" v-model="formData.pickTime">{{formData.pickTime}}</view>
</picker> -->
<!-- <uni-datetime-picker></uni-datetime-picker> -->
<!-- <u-datetime-picker :show="show" v-model="value1" @change="bindDateChange"
mode="datetime"></u-datetime-picker>
<view class="uni-input" @click="show=true" v-model="formData.pickTime">
{{formData.pickTime}}
</view> -->
<!-- </view> -->
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.pickTime" />
</view>
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit">提交</u-button>
</view>
</template>
<script>
import {
addPick,
getTask,
updatePick,
listPick
} from "@/api/wms/pdcMaterial.js";
import {
listMaterial
} from "@/api/wms/request.js";
import {
listArea
} from "@/api/wms/area.js";
import {
listLocation
} from "@/api/wms/location.js";
import {
listShelves
} from "@/api/wms/shelves.js";
import {
listWarehouse
} from "@/api/wms/warehouse.js";
export default {
onLoad: function(option) {
// this.test();
// this.getPickArea();
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
var hours = ("0" + currentDate.getHours()).slice(-2);
var minutes = ("0" + currentDate.getMinutes()).slice(-2);
var seconds = ("0" + currentDate.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
// 将当前时间赋值给 formData.updateTime
this.formData.pickTime = formattedDate;
},
data() {
return {
show: false,
item: '',
dataTree: [],
pickerData: '',
value1: Number(new Date()),
xyNum: null,
formData: {
pickTime: null,
workOrderCode: null,
drawTaskCode: null,
materialCode: null,
materialName: null,
materialBatchNo: null,
whCode: null,
areaCode: null,
shelvesCode: null,
storageLocationCode: null,
originNumber: null,
pickNumber: null,
pickTime: null,
pickCode: null,
pickArea: null,
},
rules: {
drawTaskCode: {
rules: [{
required: true,
errorMessage: '请输入领料任务单!'
}]
},
pickCode: {
rules: [{
required: true,
errorMessage: '请输入拣货单!'
}]
},
}
}
},
computed: {
// startDate() {
// return this.getDate('start');
// },
// endDate() {
// return this.getDate('end');
// }
},
// onReady() {
// // 微信小程序需要用此写法
// this.$refs.datetimePicker.setFormatter(this.formatter)
// },
methods: {
getPickArea() {
let data = new Array();
listWarehouse().then((response) => {
let obj = response.rows.map(({
warehouseName,
warehouseCode,
id
}) => ({
warehouseName,
warehouseCode,
id
}));
for (var i = 0; i < obj.length; i++) {
this.dataTree.push({
text: obj[i].warehouseName,
value: obj[i].warehouseCode + '/' + obj[i].warehouseName + '/' + obj[i]
.id,
});
}
listArea().then((response) => {
let aobj = response.rows.map(
({
storageAreaName,
storageAreaCode,
id,
warehouseCode
}) => ({
storageAreaName,
storageAreaCode,
id,
warehouseCode
})
);
for (var i = 0; i < aobj.length; i++) {
const atemp = this.dataTree.find(
(item) => item.value.split('/')[0] == aobj[i].warehouseCode
);
if (atemp) {
if (!atemp.children) {
atemp.children = [];
}
atemp.children.push({
text: aobj[i].storageAreaName,
// value: aobj[i].storageAreaCode,
value: aobj[i].storageAreaCode + '/' + aobj[i]
.storageAreaName + '/' + aobj[i].id + '/' +
aobj[i]
.warehouseCode,
});
}
}
listShelves().then((response) => {
let sobj = response.rows.map(
({
storageShelvesCode,
storageShelvesName,
id,
storageAreaCode,
warehouseCode
}) => ({
storageShelvesCode,
storageShelvesName,
id,
storageAreaCode,
warehouseCode
})
);
const stemp = this.dataTree.filter((item) => item
.children);
for (var i = 0; i < sobj.length; i++) {
for (var j = 0; j < stemp.length; j++) {
const temp = stemp[j].children.find(
(item) => item.value.split('/')[0] ==
sobj[i]
.storageAreaCode
);
if (temp) {
if (!temp.children) {
temp.children = [];
}
temp.children.push({
text: sobj[i]
.storageShelvesName,
// value: sobj[i].storageShelvesCode,
value: sobj[i]
.storageShelvesCode +
'/' +
sobj[
i].storageShelvesName +
'/' +
sobj[
i]
.id + '/' + sobj[i]
.storageAreaCode +
'/' +
sobj[i].warehouseCode,
});
}
}
}
listLocation().then((response) => {
let lobj = response.rows.map(({
storageLocationCode,
storageLocationName,
id,
storageShelvesCode,
storageAreaCode,
warehouseCode
}) => ({
storageLocationCode,
storageLocationName,
id,
storageShelvesCode,
storageAreaCode,
warehouseCode
}));
const lItem = this.dataTree.filter(
(parentItem) =>
parentItem.children &&
parentItem.children.find((
childItem) =>
childItem
.children)
);
for (var i = 0; i < lobj.length; i++) {
for (var j = 0; j < lItem
.length; j++) {
for (var k = 0; k < lItem[j]
.children
.length; k++) {
if (lItem[j].children[k]
.children) {
const temp = lItem[j]
.children[k]
.children
.find(
(item) => item
.value.split(
'/')[
0] == lobj[
i]
.storageShelvesCode
);
if (temp) {
if (!temp
.children) {
temp
.children = [];
}
temp.children
.push({
text: lobj[
i
]
.storageLocationName,
// value: lobj[i]
// .storageLocationCode,
value: lobj[
i
]
.storageLocationCode +
'/' +
lobj[
i
]
.storageLocationName +
'/' +
lobj[
i
]
.id +
'/' +
lobj[
i
]
.storageShelvesCode +
'/' +
lobj[
i
]
.storageAreaCode +
'/' +
lobj[
i
]
.warehouseCode,
});
}
}
}
}
}
// if (this.formData.status == '2') {
// }
this.dataTree = JSON.parse(JSON
.stringify(this
.dataTree))
//状态为拣货完成时,默认为原来的仓库,否则默认拣货仓
if (this.formData.status != '2') {
//默认进入拣货仓
// if (!this.formData.whCode) {
if (this.dataTree.find(item => item
.text ==
'拣货仓')) {
let data = this.dataTree.find(
item => item
.text == '拣货仓')
this.item = data
this.pickerData = this.item.value;
if (!this.item) return
this.onchange(this.item)
this.onpopupclosed();
}
// }
} else {
this.getDataPicker(this.formData
.whCode, this
.formData
.areaCode, this.formData
.shelvesCode, this.formData
.storageLocationCode
)
}
});
});
});
});
},
onnodeclick(e) {
this.item = e
},
onpopupopened(e) {
console.log('popupopened');
},
onpopupclosed(e) {
//处理不同步
this.$nextTick(() => {
this.pickerData = this.item.value;
if (!this.item) return
this.onchange(this.item)
});
},
onpopupclosed2(e) {
this.pickerData = this.item.value;
if (!this.item) return
this.onchange(this.item)
},
onchange(e) {
let array = e.value.split('/');
switch (array.length) {
case 3:
this.formData.storageLocationCode = null;
this.formData.shelvesCode = null;
this.formData.areaCode = null;
this.formData.whCode = array[0];
break;
case 4:
this.formData.storageLocationCode = null;
this.formData.shelvesCode = null;
this.formData.areaCode = array[0];
this.formData.whCode = array[3];
break;
case 5:
this.formData.storageLocationCode = null;
this.formData.shelvesCode = array[0];
this.formData.areaCode = array[3];
this.formData.whCode = array[4];
break;
case 6:
this.formData.storageLocationCode = array[0];
this.formData.shelvesCode = array[3];
this.formData.areaCode = array[4];
this.formData.whCode = array[5];
break;
default:
break;
}
},
//如果已填写拣货仓,则回显到级联选择器上
getDataPicker(wh, area, shelve, stoLot) {
if (wh) {
if (area) {
if (shelve) {
if (stoLot) {
let data = this.dataTree.find(item => item.value.split('/')[0] == wh)
if (data) {
let areadata = data.children.find(item => item.value.split('/')[0] == area)
if (areadata) {
let shelvedata = areadata.children.find(item => item.value.split('/')[0] ==
shelve)
if (shelvedata) {
let stoLotdata = shelvedata.children.find(item => item.value.split('/')[
0] == stoLot)
if (stoLotdata) {
this.item = stoLotdata;
this.onpopupclosed2();
}
}
}
}
} else {
//只有仓库,库区和货架
let data = this.dataTree.find(item => item.value.split('/')[0] == wh)
if (data) {
let areadata = data.children.find(item => item.value.split('/')[0] == area)
if (areadata) {
let shelvedata = areadata.children.find(item => item.value.split('/')[
0] ==
shelve)
if (shelvedata) {
this.item = shelvedata;
this.onpopupclosed2();
}
}
}
}
} else {
//只有仓库和库区
let data = this.dataTree.find(item => item.value.split('/')[0] == wh)
if (data) {
let areadata = data.children.find(item => item.value.split('/')[0] == area)
if (areadata) {
this.item = areadata;
this.onpopupclosed2()
}
}
}
} else {
//只有仓库
let data = this.dataTree.find(item => item.value.split('/')[0] == wh)
if (data) {
this.item = data;
this.onpopupclosed2()
}
}
}
},
formatter(type, value) {
if (type === 'year') {
return `${value}`
}
if (type === 'month') {
return `${value}`
}
if (type === 'day') {
return `${value}`
}
if (type === 'hour') {
return `${value}`
}
if (type === 'minute') {
return `${value}`
}
if (type === 'second') {
return `${value}`
}
return value
},
bindDateChange(e) {
console.log(e)
this.formData.pickTime = e.detail.value
},
close() {
this.show = false;
},
confirm(e) {
this.show = false;
const date = new Date(e.value);
console.log(date.toLocaleString()); // 使用 toLocaleString() 方法将时间戳转换为可读的日期和时间格式
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
scanBarCode() {
// if (this.formData.pickCode) {
let obj = {
drawTaskCode: this.formData.drawTaskCode,
pickCode: this.formData.pickCode
}
console.log(obj);
this.$modal.loading('提交中')
listPick(
obj
).then(async res => {
this.$modal.closeLoading();
console.log(res);
if (res.rows.length != 0) {
// arry = res.rows[0];
// console.log(arry);
this.formData = res.rows[0];
// this.formData.wlBatchNum = res.rows[0].materialBatchNo,
// this.formData.wlName = res.rows[0].materialName,
// this.formData.wlCode = res.rows[0].materialCode,
// this.formData.ckCode = res.rows[0].storageLocationCode,
// this.formData.yyNum = res.rows[0].originNumber,
// this.formData.jhNum = res.rows[0].pickNumber,
this.xyNum = this.formData.originNumber - this.formData.pickNumber
this.formData.pickTime = this.getDate();
await this.getPickArea();
console.log(this.formData.pickTime)
} else {
this.$modal.msgError("未检索到该拣货信息!");
}
});
// } else if (!this.formData.drawTaskCode || this.formData.drawTaskCode == "" || this.formData.drawTaskCode ==
// null) {
// this.$modal.msg("请输入领料任务单!");
// } else if (!this.formData.pickCode || this.formData.pickCode == "" || this.formData.pickCode == null) {
// this.$modal.msg("请输入拣货单!");
// }
},
// scanBarCode1(){
// if(!this.formData.pickCode || this.formData.pickCode == "" || this.formData.pickCode == null){
// this.$modal.msgError("请输入拣货单!");
// }
// },
scanBarPwo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.workOrderCode = res.result;
_this.scanBarPwoCode();
}
});
},
scanBarPwoCode() {
if (this.formData.workOrderCode) {
listPick({
workOrderCode: this.formData.workOrderCode
}).then(response => {
console.log(response);
if (response.rows.length > 1) {
this.$modal.msg("该工单检索到的拣货单超过1条请去电脑端操作");
} else if (response.rows.length == 0) {
this.$modal.msg("该工单未检索到拣货单!");
} else if (response.rows.length == 1) {
console.log("success");
this.formData = response.rows[0];
this.xyNum = this.formData.originNumber - this.formData.pickNumber;
this.formData.pickTime = this.getDate();
this.getPickArea();
console.log(this.formData.pickTime)
}
});
}
},
//领料任务单
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.drawTaskCode = res.result;
_this.scanBarCode();
}
});
},
//拣货单
scanBar4() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pickCode = res.result;
_this.scanBarCode();
}
});
},
submit() {
const _this = this;
_this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定拣货该物料吗?',
success: function(res) {
if (res.confirm) {
_this.formData.status = '2';
console.log(_this.formData);
_this.$modal.loading('提交中')
updatePick(_this.formData).then(async res => {
_this.formData.inStatus = '2'
updatePick(_this.formData).then(
async res => {
_this.$modal.msgSuccess(
"拣货完成!");
setTimeout(() => {
_this.$modal
.closeLoading();
_this.$tab
.switchTab(
"/pages/work/index"
);
}, 500);
});
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
});
},
}
}
</script>
<style>
</style>