653 lines
20 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<u-navbar back-text="返回" title="其他入库" :background="background"></u-navbar>
<u-form ref="testForm" style="margin: 10px;">
<u-form-item :border-bottom="false">
<p>单据:</p>
<u-select v-model="dlistShow" mode="single-column" value-name="id" :list="dlist" @confirm="selConfirm"
confirm-text="确认选择" />
<u-input :border="true" v-model="ReceiveRequestName" placeholder="请选择单据" :focus="focusReceiveRequest"
@confirm="checkReceiveRequest" style="background: #ffffff; margin-right: 10rpx" />
<u-button @click="selectReceiveRequest" type="primary" size="mini">选择单号</u-button>
</u-form-item>
<u-row v-if='false'>
<u-form-item :border-bottom="false">
<picker @change="bindPickerChange" :range="array">
<label>选择行:</label>
<label class="">{{array[index]}}</label>
</picker>
</u-form-item>
<u-row>
<u-col span="2"><label>料号:</label> </u-col>
<u-col span="10"><label>{{MATERIALSPECNAME}}</label> </u-col>
</u-row>
<br />
<u-row>
<u-col span="2"><label>品名:</label> </u-col>
<u-col span="10"><label>{{DESC_CN}}</label> </u-col>
</u-row>
<br />
<u-row>
<u-col span="2"><label>规格:</label> </u-col>
<u-col span="10"><label>{{SPECNAME}}</label> </u-col>
</u-row>
<br />
<u-row>
<u-col span="2"><label>阶段:</label> </u-col>
<u-col span="10"><label>{{PHASE}}</label> </u-col>
</u-row>
<br />
<u-row>
<u-col span="2"><label>单号:</label> </u-col>
<u-col span="4"><label>{{ReceiveRequestNAME}}</label> </u-col>
<u-col span="2"><label>行号:</label> </u-col>
<u-col span="4"><label>{{ReceiveRequestDETAILNAME}}</label> </u-col>
</u-row>
<br />
<u-row>
<u-col span="2"><label>组织:</label> </u-col>
<u-col span="4"><label>{{ERPFACTORY}}</label> </u-col>
<u-col span="2"><label>仓库:</label> </u-col>
<u-col span="4"><label>{{ERPLOCATION}}</label> </u-col>
</u-row>
<br />
<u-row>
<u-col span="3"><label>入库单:</label> </u-col>
<u-col span="9"><label>{{RECEIVEACTNO}}</label> </u-col>
</u-row>
</u-row>
<u-card style="border: 1rpx solid #0081ff" :show-head="false" :full="true"
:body-style="{ height: '140rpx' }">
<view slot="body">
<u-row>
<u-col span="6">
<view>单据应收数量:{{ REQUESTQUANTITY || '0' }}</view>
</u-col>
<u-col span="6">
<view>累计接收数量:{{ RECEIVEDQUANTITY || '0' }}</view>
</u-col>
</u-row>
<u-row style="padding: 10rpx 0;">
<u-col span="6">
<view>当次扫描支数:{{ ScanNumber || '0' }}</view>
</u-col>
<u-col span="6">
<view>当次扫描数量:{{ ScanNumber2 || '0' }}</view>
</u-col>
</u-row>
</view>
</u-card>
<u-row>
<label>选择仓库:</label>&nbsp;&nbsp;&nbsp;&nbsp;
<!-- <uni-data-select v-model="ERPLOCATION" :localdata="items" @change="change"></uni-data-select> -->
<zxzUniDataSelect filterable v-model="ERPLOCATION" :localdata="items" @change="change">
</zxzUniDataSelect>
</u-row>
<br />
<u-row>
<label>选择库位:</label>&nbsp;&nbsp;&nbsp;&nbsp;
<!-- <uni-data-select v-model="LOCATIONNAME" :localdata="items_Location" @change="change2"></uni-data-select> -->
<zxzUniDataSelect filterable v-model="LOCATIONNAME" :localdata="items_Location"
:disabled="Locatiaon_state"></zxzUniDataSelect>
</u-row>
<!-- <u-row>
<u-col span="3">
<p>货位条码:</p>
</u-col>
<u-col span="7">
<u-input :border="true" v-model="LOCATIONNAME" placeholder="请扫描货位" style="background: #ffffff;" />
</u-col>
<u-col span="2">
<u-button @click="clearLocationName" type="primary" size="mini">清空货位</u-button>
</u-col>
</u-row> -->
<u-row>
<u-col span="3">
<p>来料条码:</p>
</u-col>
<u-col span="7">
<u-input :border="true" v-model="MATERIALPACKINGNAME" @confirm="AnalyBarCode" placeholder="请扫描条码"
:focus="focusPalletName" style="background: #ffffff;" />
</u-col>
</u-row>
</u-form>
<uni-table ref="BoxList" border stripe type="false" style="height: 350rpx;">
<uni-tr>
<uni-th align="center">标签</uni-th>
<uni-th align="center">批次</uni-th>
<uni-th align="center">品名</uni-th>
<uni-th align="center">料号</uni-th>
<uni-th align="center">规格</uni-th>
<uni-th align="center">阶段</uni-th>
<uni-th align="center">数量</uni-th>
<uni-th align="center">组织</uni-th>
<uni-th align="center">仓库</uni-th>
<uni-th align="center">货位</uni-th>
</uni-tr>
<uni-tr v-for="(item, index) in BoxListInfo" :key="index">
<!-- :style="getStyle(index)"-->
<!--:style="{ backgroundColor: item.color === 0 ? 'white' : 'blue' }" -->
<uni-td align="center">{{ item.MATERIALPACKINGNAME}}</uni-td>
<uni-td align="center">{{ item.CHARGE}}</uni-td>
<uni-td align="center">{{ item.DESC_CN}}</uni-td>
<uni-td align="center">{{ item.MATERIALSPECNAME }}</uni-td>
<uni-td align="center">{{ item.SPECNAME }}</uni-td>
<uni-td align="center">{{ item.PHASE }}</uni-td>
<uni-td align="center">{{ item.MATERIALQUANTITY }}</uni-td>
<uni-td align="center">{{ item.ERPFACTORY }}</uni-td>
<uni-td align="center">{{ item.ERPLOCATION }}</uni-td>
<uni-td align="center">{{ item.LOCATIONNAME }}</uni-td>
</uni-tr>
</uni-table>
<view class="tabbar_bottom">
<u-input v-if="false" v-model="opCode" />
<uni-datetime-picker style="align-items: center;" type="date" :clear-icon="false" v-model="commitDate"
@maskClick="maskClick" />
<u-button @click="CommitOtherInInvoice" style="background: #0081ff; color: #ffffff" :loading="loading">确认提交
</u-button>
</view>
</view>
</template>
<script>
import zxzUniDataSelect from "@/components/zxz-uni-data-select/zxz-uni-data-select.vue"
import {
print
} from '../../../../common/BluetoothPrint.js';
import {
getOpCode
} from '@/common/api.js';
import { cals } from '@/utils/cal'
export default {
components: {
zxzUniDataSelect
},
data() {
return {
items_Location: [],
items: [],
array: ['请选择行号'],
background: {
backgroundImage: 'linear-gradient(45deg, rgb(28, 187, 180), rgb(141, 198, 63))'
},
index: 0,
REQUESTQUANTITY: 0,
RECEIVEDQUANTITY: 0,
ScanNumber: 0,
ScanNumber2: 0,
BOX_QTY: "",
focusPalletName: false,
ReceiveRequestName: "",
ReceiveRequestNAME: '',
ReceiveRequestDETAILNAME: "",
focusReceiveRequest: "",
dlist: [], //选择内容
dlistShow: false, //是否显示选择框
description: "描述",
loading: false,
BoxListInfo: [],
jg: "",
zpl: "",
focusBoxQty: false,
Locatiaon_state: false,
rangedata: [],
DESC_CN: "",
SPECNAME: "",
MATERIALSPECNAME: "",
PHASE: "",
LOCATIONNAME: "",
MATERIALPACKINGNAME: "",
ReceiveRequestType: "",
userId: "",
ERPLOCATION: "",
ERPFACTORY: JSON.parse(uni.getStorageSync('orgObject')).ERPFACTORY,
RECEIVEACTNO: "",
commitDate: '',
opCode: '',
}
},
created() {
let that = this
uni.getStorage({
key: "sitename",
success(res) {
that.siteName = res.data
}
})
uni.getStorage({
key: "userid",
success(res) {
that.userId = res.data
}
})
},
computed: {},
mounted() {
this.tabH = this.$GetRemainingHeight(4, 0); //定义表格的高度
let that = this
uni.getStorage({
key: "sitename",
success(res) {
that.siteName = res.data
}
})
uni.getStorage({
key: "userid",
success(res) {
that.userId = res.data
}
})
this.orgObject = JSON.parse(uni.getStorageSync('orgObject'))
this.getTimeData();
this.getERPLocation();
this.getLocationName();
},
methods: {
getTimeData() {
var year = new Date().getFullYear(); //年
if (year < 1900) year = year + 1900;
var month = new Date().getMonth() + 1; //月
if (month < 10) month = '0' + month;
var day = new Date().getDate(); //日
if (day < 10) day = '0' + day;
const calendar1 = year + '-' + month + '-' + day
this.commitDate = calendar1
console.log(this.getTimeData)
},
maskClick(e) {
console.log('maskClick事件:', e);
},
change(e) {
this.ERPLOCATION = e.value;
/* this.LOCATIONNAME = ""
this.Huowei = e.Huowei
if (e.Huowei == 'Y') {
this.Locatiaon_state = false
this.getLocationName();
} else {
this.$showMessage(e.text + "仓库没有启用货位管理")
this.Locatiaon_state = true
this.focusPalletName = true
} */
},
getERPLocation() {
this.items = [];
this.$MyRequest('/api/storage/getERPLocation', {
ERPFACTORYNAME: this.ERPFACTORY
}).then(res => {
if (res.data.success) {
for (let i = 0; i < res.data.resultObj.length; i++) {
var _Arr = res.data.resultObj[i];
this.items.push({
text: _Arr.DESCRIPTION,
value: _Arr.ERPLOCATIONNAME,
Huowei: _Arr.USE_LOCATION,
});
}
} else {
this.$showMessage(res.data.message)
}
});
},
getLocationName() {
this.items_Location = []
let ERPFACTORY = JSON.parse(uni.getStorageSync('orgObject')).ERPFACTORY;
this.$MyRequest('/api/storage/getLocationNameForERPLocation', {
ERPLocation: ERPFACTORY
}).then(res => {
if (res.data.success) {
for (let i = 0; i < res.data.resultObj.length; i++) {
var _Arr = res.data.resultObj[i];
this.items_Location.push({
text: _Arr.DESCRIPTION,
value: _Arr.STORAGENAME
});
}
} else {
this.$showMessage(res.data.message)
}
this.focusBarCode = true
this.focusShipRequest = false
}).catch(err => {
this.$showMessage(err)
});
},
selConfirm(e) {
this.ReceiveRequestName = e[0].value;
this.checkReceiveRequest();
},
bindPickerChange: function(e) { //改变的事件名
console.log('picker发送选择改变携带值为', e.target.value) // 用于输出改变索引值
this.index = e.target.value //将数组改变索引赋给定义的index变量
this.jg = this.array[this.index] //将array【改变索引】的值赋给定义的jg变量
this.$MyRequest('/invoice/getOtherInLineInfo', {
ReceiveRequestName: this.jg
}).then(res => {
if (res.data.success) {
var _Arr = res.data.resultObj;
for (let i = 0; i < _Arr.length; ++i) {
this.DESC_CN = _Arr[i]['DESC_CN'];
this.REQUESTQUANTITY = _Arr[i]['REQUESTQUANTITY'];
this.RECEIVEDQUANTITY = _Arr[i]['RECEIVEDQUANTITY'];
this.SPCNAME = _Arr[i]['SPCNAME'];
this.MATERIALSPECNAME = _Arr[i]['MATERIALSPECNAME'];
this.ReceiveRequestNAME = _Arr[i]['RECEIVEREQUESTNAME'];
this.ReceiveRequestDETAILNAME = _Arr[i]['RECEIVEREQUESTDETAILNAME'];
this.PHASE = _Arr[i]['PHASE'];
this.ERPLOCATION = _Arr[i]['ERPLOCATION'];
this.ERPFACTORY = _Arr[i]['ERPFACTORY'];
this.RECEIVEACTNO = _Arr[i]['RECEIVEACTNO'];
this.getBarCode();
}
}
}).catch(err => {
this.$showMessage(err)
})
},
//查找待操作的调拨入库单集合
selectReceiveRequest() {
this.dlist = [];
this.BoxListInfo = [];
this.$MyRequest('/invoice/getOtherInList', {
ReceiveRequestName: this.ReceiveRequestName,
ReceiveRequestType: "ZK4A"
}).then(res => {
console.log(res.data)
if (res.data.success) {
console.log(res.data.resultObj.length)
for (var i = 0; i <= res.data.resultObj.length; i++) {
console.log(res.data.resultObj[i].ReceiveRequestNAME)
this.dlist.push({
id: res.data.resultObj[i].RECEIVEREQUESTNAME,
label: res.data.resultObj[i].RECEIVEREQUESTNAME
});
console.log(this.dlist);
this.dlistShow = true;
//this.checkReceiveRequest();
}
} else {
this.$showMessage(res.data.message)
}
}).catch(err => {
this.$showMessage(err)
})
},
checkReceiveRequest() {
this.resetValue();
this.REQUESTQUANTITY = 0
this.RECEIVEDQUANTITY = 0
this.$MyRequest('/invoice/getOtherInLine', {
ReceiveRequestName: this.ReceiveRequestName,
ReceiveRequestType: "ZK4A"
}).then(res => {
if (res.data.success) {
var _Arr = res.data.resultObj;
for (let i = 0; i < _Arr.length; ++i) {
console.log(_Arr[i])
this.array[i] = _Arr[i]['WL'];
this.REQUESTQUANTITY = (cals.add(this.REQUESTQUANTITY, _Arr[i]['REQUESTQUANTITY'])).toNumber()
this.RECEIVEDQUANTITY = (cals.add(this.RECEIVEDQUANTITY,_Arr[i]['RECEIVEDQUANTITY'])).toNumber()
}
}
this.focusBarCode = true
this.focusReceiveRequest = false
}).catch(err => {
this.$showMessage(err)
});
this.getBarCode();
},
//创建条码信息
createActNo() {
this.$MyRequest('/FGStockIn/createActNo', {
//MATERIALPACKINGNAME: this.MATERIALPACKINGNAME
}).then(res => {
if (res.data.success) {
console.log(res.data.resultObj + "*****************************")
var _Arr = res.data.resultObj;
this.RECEIVEACTNO = _Arr[0].ReceiveActNo;
} else {
this.$showMessage(res.data.message)
}
}).catch(err => {
this.$showMessage(err)
});
},
async AnalyBarCode() {
this.focusPalletName = false
if (this.BoxListInfo.some(box => box.MATERIALPACKING === this.palletName)) {
this.$showMessage("改标签已扫描,请不要重复扫描!");
this.$nextTick(() => {
this.MATERIALPACKINGNAME = ""
this.focusPalletName = true
})
return;
}
if (parseFloat(this.REQUESTQUANTITY) * 1.05 < parseFloat(this.RECEIVEDQUANTITY)) {
this.$showMessage("标签数量大于最大接收数量!");
this.$nextTick(() => {
this.MATERIALPACKINGNAME = ""
this.focusPalletName = true
})
return;
}
var barCodeArr = this.MATERIALPACKINGNAME.split("|");
// 470110856|1|C|75mm*1000m|SHBP01JT1202305240009|20230524|11|75
if (barCodeArr.length < 7) {
this.$showMessage("条码规则不符合需求!")
this.$nextTick(() => {
this.MATERIALPACKINGNAME = ""
this.focusPalletName = true
})
return;
}
if (barCodeArr.length != 8) return;
var materialSpecName = barCodeArr[0];
var phase = barCodeArr[2];
var description = barCodeArr[3];
var materialPackingName = barCodeArr[4];
var makeDate = barCodeArr[5];
var materialUnit = barCodeArr[6];
var materialQuantity = barCodeArr[7];
if (Number(this.RECEIVEDQUANTITY) + Number(materialQuantity) > Number(this.REQUESTQUANTITY)) {
this.$showMessage("可接收数量不足")
this.$nextTick(() => {
this.MATERIALPACKINGNAME = ""
this.focusPalletName = true
})
return;
}
// if (this.MATERIALSPECNAME != materialSpecName) {
// this.$showMessage("物料号和单据行明细物料不一致!")
// return;
// }
// console.log(barCodeArr)
// if (this.PHASE != phase) {
// this.$showMessage("阶段和单据行明细阶段不一致!")
// return;
// }
// if (!(this.MATERIALSPECNAME == materialSpecName)) {
// this.$showMessage("该标签物料与到货单明细物料不相同!")
// return;
// }
// if ((this.LOCATIONNAME == null || this.LOCATIONNAME == "") && (this.Huowei == 'Y')) {
// this.$showMessage("货位信息不能为空!")
// this.$nextTick(() => {
// this.MATERIALPACKINGNAME = ""
// this.focusPalletName = true
// })
// return;
// }
//判断标签是否扫过了
if (this.RECEIVEACTNO == '') {
//this.createActNo()
await this.$MyRequest('/FGStockIn/createActNo', {
//MATERIALPACKINGNAME: this.MATERIALPACKINGNAME
}).then(res => {
if (res.data.success) {
console.log(res.data.resultObj + "*****************************")
var _Arr = res.data.resultObj;
this.RECEIVEACTNO = _Arr[0].ReceiveActNo;
this.$nextTick(() => {
this.focusPalletName = true
})
this.$showMessage(res.data.message)
try {
Vue.prototype.$playSuccess()
} catch (e) {}
} else {
this.$nextTick(() => {
this.focusPalletName = true
})
this.$showMessage(res.data.message)
this.$playFail()
}
}).catch(err => {
this.$nextTick(() => {
this.focusPalletName = true
})
this.$showMessage(err)
this.$playFail()
});
}
//发信息到后端绑定条码和条码关系
// this.RECEIVEDQUANTITY = Number(this.RECEIVEDQUANTITY) + Number(materialQuantity);
// this.focusBoxQty = true;
this.$MyRequest('/OtherIn/createBoxInfo', {
MATERIALPACKINGNAME: this.MATERIALPACKINGNAME,
charge: materialPackingName,
locationName: this.LOCATIONNAME,
materialSpecName: materialSpecName,
ReceiveRequestName: this.ReceiveRequestName,
ReceiveRequestDetailName: this.ReceiveRequestDETAILNAME,
ERPLocation: this.ERPLOCATION,
RECEIVEACTNO: this.RECEIVEACTNO,
ERPFactory: this.ERPFACTORY,
user: this.userId == "" ? "101867" : this.userId
}).then(res => {
console.log("************" + res.data.status)
if (res.data.success) {
//this.RECEIVEDQUANTITY = Number(this.RECEIVEDQUANTITY) + Number(materialQuantity);
this.ScanNumber2 = this.ScanNumber2 + parseFloat(materialQuantity)
this.focusBoxQty = true;
this.$nextTick(() => {
this.MATERIALPACKINGNAME = ""
this.focusPalletName = true
})
this.getBarCode();
} else {
this.$showMessage(res.data.message)
this.$nextTick(() => {
this.MATERIALPACKINGNAME = ""
this.focusPalletName = true
})
}
}).catch(err => {
this.$showMessage(err)
this.$nextTick(() => {
this.MATERIALPACKINGNAME = ""
this.focusPalletName = true
})
})
},
//获取绑定条码信息
getBarCode() {
this.resetValue();
//this.RECEIVEDQUANTITY = 0
this.$MyRequest('/invoice/getOtherInBindBarCode', {
RECEIVEACTNO: this.RECEIVEACTNO
}).then(res => {
if (res.data.success) {
this.ScanNumber = res.data.resultObj.length
this.BoxListInfo = res.data.resultObj;
this.ScanNumber = this.BoxListInfo.length
this.RECEIVEDQUANTITY = this.RECEIVEDQUANTITY + this.BoxListInfo.reduce((accumulator,
currentValue) => {
return accumulator + currentValue.MATERIALQUANTITY;
}, 0); // 第二个参数是累加器的初始值
this.focusPalletName = true
} else {
this.focusPalletName = true
this.$showMessage(res.data)
}
}).catch(err => {
this.focusPalletName = true
this.$showMessage(err)
})
},
CommitOtherInInvoice() {
console.log(this.commitDate)
if (this.BoxListInfo.length == 0) {
this.$showMessage("没有要提交的信息,请确认")
return;
}
this.loading = true;
getOpCode({
opcode: this.opCode,
user: this.userId
}).then((res) => {
this.$MyRequest('/OtherIn/OtherInCommit', {
ReceiveRequestName: this.ReceiveRequestName,
commitDate: this.commitDate,
opcode: this.opCode,
RECEIVEACTNO: this.RECEIVEACTNO,
user: this.userId == "" ? "101867" : this.userId
}).then(res => {
if (res.data.success) {
this.loading = false;
this.ScanNumber = 0
this.ScanNumber2 = 0
this.resetValue();
this.$showMessage(res.data.message)
} else {
this.loading = false;
this.$showMessage(res.data.message)
}
}).catch(err => {
this.loading = false;
this.$showMessage(err)
})
})
},
/**
* 清空货位信息
*/
clearLocationName() {
this.LOCATIONNAME = '';
},
resetValue() {
this.opCode = "";
this.BoxListInfo = [];
this.palletName = "";
this.BOX_QTY = "";
this.PLAN_QTY = 0;
this.PRTBARCODEQTY = 0;
this.description = "";
this.array = [];
}
}
}
</script>
<style>
</style>