<template>
|
<view>
|
<view class="form-container">
|
<form :modelValue="formData">
|
<view class="form-group">
|
<label class="form-label">出库单号:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.itemOutNo"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">单据类型:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.billTypeName"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">创建人:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.createBy"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">创建时间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.createDate"/>
|
</view>
|
<view class="uni-form-item uni-column form-item edit">
|
<text class="form-label">退料仓库:</text>
|
<superwei-combox v-if="isUpdate" :candidates="depotNameList" placeholder="请选择或输入"
|
v-model="formData.depotName"
|
@select="onDepotCodeChange"
|
class="picker form-input"
|
style="border: none;"></superwei-combox>
|
<input v-else class="form-input" disabled="true" type="text" v-model="formData.depotName"/>
|
</view>
|
<view class="form-group">
|
<checkbox-group @change="selectfType"
|
style="background-color: white;border-bottom: 1px solid #c7c7c7;">
|
<label v-if="isUpdate">
|
<checkbox value="1" :checked="formData.fType == 1"/>
|
委外退货
|
</label>
|
<label v-else>
|
<checkbox value="0" disabled="true" :checked="formData.fType == 1"/>
|
委外退货
|
</label>
|
</checkbox-group>
|
</view>
|
<view class="uni-form-item uni-column form-item edit">
|
<label class="form-label">退货原因:</label>
|
<superwei-combox v-if="isUpdate" :candidates="reasonCandidates" placeholder="请选择或输入"
|
v-model="formData.reason"
|
@select="onReasonChange"
|
class="picker form-input"
|
style="border: none;"></superwei-combox>
|
<input v-else class="form-input" disabled="true" type="text" v-model="formData.reason"/>
|
</view>
|
<view class="uni-form-item uni-column form-item edit">
|
<view class="form-group">
|
<label class="form-label">退料方式:</label>
|
<superwei-combox v-if="isUpdate" :candidates="fmrmodeCandidates" placeholder="请选择或输入"
|
v-model="formData.fmrmode"
|
@select="onFmrmodeChange"
|
class="picker form-input"
|
style="border: none;"></superwei-combox>
|
<input v-else class="form-input" disabled="true" type="text" v-model="formData.fmrmode"/>
|
</view>
|
</view>
|
<view class="form-group">
|
<label class="form-label">供应商编码:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.suppNo"/>
|
</view>
|
<view class="uni-form-item uni-column form-item edit">
|
<label class="form-label">供应商名称:</label>
|
<superwei-combox v-if="isUpdate" :candidates="supplierNameList" placeholder="请选择或输入"
|
v-model="formData.suppName"
|
@select="onSuppNameChange"
|
class="picker form-input"
|
style="border: none;"></superwei-combox>
|
<input v-else class="form-input" disabled="true" type="text" v-model="formData.suppName"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">审核人:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.checkUserFname"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">审核时间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.checkDate"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">备注:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.remark"/>
|
</view>
|
</form>
|
</view>
|
|
<view class="text" v-if="Message">
|
<text v-text="Message"></text>
|
</view>
|
|
<view class="list-container" v-if="tableData.length > 0">
|
<uni-table ref="table" border emptyText="暂无更多数据">
|
<uni-tr>
|
<uni-th align="center" class="th">采购单号</uni-th>
|
<uni-th align="center" class="th">行号</uni-th>
|
<uni-th align="center" class="th">物料编码</uni-th>
|
<uni-th align="center" class="th">物料名称</uni-th>
|
<uni-th align="center" class="th">规格型号</uni-th>
|
<uni-th v-if="!isUpdate" align="center" class="th">退货数量</uni-th>
|
<uni-th v-else align="center" class="th" style="color: blue">退货数量</uni-th>
|
<uni-th align="center" class="th">已扫数量</uni-th>
|
<uni-th align="center" class="th">ERP收货数量</uni-th>
|
<uni-th align="center" class="th">剩余可退数</uni-th>
|
<uni-th align="center" class="th">已入库数</uni-th>
|
<uni-th align="center" class="th">采购员</uni-th>
|
<uni-th align="center" class="th">仓库编码</uni-th>
|
<uni-th align="center" class="th">库位号</uni-th>
|
<uni-th align="center" class="th">备注</uni-th>
|
</uni-tr>
|
<uni-tr v-for="(item, index) in tableData" :key="index">
|
<uni-td align="center">
|
<input class="form-input" disabled="true" type="text" v-model="item.pbillNo"/>
|
</uni-td>
|
<uni-td align="center">
|
<input class="form-input" disabled="true" type="text" v-model="item.workLine"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemNo"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemName"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemModel"/>
|
</uni-td>
|
<uni-td>
|
<input v-if="!isUpdate" class="form-input" disabled="true" type="number" v-model="item.quantity"/>
|
<input v-else class="form-input" type="number" v-model="item.quantity"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.tlQty"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.cgb014"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.ktQty"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.rkQty"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.staffName"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.depotCode"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.depotSectionCode"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.remark"/>
|
</uni-td>
|
</uni-tr>
|
</uni-table>
|
</view>
|
<view class="list-container" v-if="getMaterials.length > 0">
|
<uni-table ref="table" type="selection" border emptyText="暂无更多数据" @selection-change="selectMaterialsChange">
|
<uni-tr>
|
<uni-th align="center" class="th">采购单号</uni-th>
|
<uni-th align="center" class="th">行号</uni-th>
|
<uni-th align="center" class="th">物料编码</uni-th>
|
<uni-th align="center" class="th">物料名称</uni-th>
|
<uni-th align="center" class="th">规格型号</uni-th>
|
<uni-th align="center" class="th">入库数量</uni-th>
|
<uni-th align="center" class="th">单位</uni-th>
|
<uni-th align="center" class="th">供应商编码</uni-th>
|
<uni-th align="center" class="th">已退数</uni-th>
|
<uni-th align="center" class="th">剩余可退数</uni-th>
|
<uni-th align="center" class="th">到货单号</uni-th>
|
<uni-th align="center" class="th">taskNo</uni-th>
|
<uni-th align="center" class="th">入库单号</uni-th>
|
<uni-th align="center" class="th">入库日期</uni-th>
|
</uni-tr>
|
<uni-tr v-for="(item, index) in getMaterials" :key="index">
|
<uni-td align="center">
|
<input class="form-input" disabled="true" type="text" v-model="item.workNo"/>
|
</uni-td>
|
<uni-td align="center">
|
<input class="form-input" disabled="true" type="text" v-model="item.workLine"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemNo"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemName"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemModel"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.sumQuantity"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.unit"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.suppNo"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.quantity"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.refundableQuantity"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.cbillNo"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.taskNo"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.billNo"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.createDate"/>
|
</uni-td>
|
</uni-tr>
|
</uni-table>
|
</view>
|
|
<view class="plus-button">
|
<button type="warn" v-if="isUpdate" @click="save">生成验退单</button>
|
</view>
|
<view class="plus-button">
|
<button type="warn" v-if="!isUpdate && this.formData.status ==0" @click="audit">审核</button>
|
</view>
|
<view class="plus-button">
|
<button type="warn" v-if="!isUpdate && this.formData.status ==1" @click="FToErp">反审核</button>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
formData: {},
|
tableData: [],
|
|
getMaterials: [],
|
|
depotCodeList: [],
|
depotNameList: [],
|
reasonCandidates: ['来料不良', '其他退料'],
|
fmrmodeCandidates: ['退料补料', '退料并扣款'],
|
supplierList: [],
|
supplierNameList: [],
|
isUpdate: true,
|
|
Message: '',
|
messageId: 0,
|
messageCenter: {},
|
};
|
},
|
onLoad(options) {
|
//options中包含了url附带的参数
|
|
let params = options;
|
|
if (params["id"]) {
|
this.isUpdate = false;
|
this.formData.id = params["id"];
|
this.formData.itemOutNo = params["itemOutNo"];
|
//getQaItemXj02
|
this.init();
|
} else {
|
//初始化检验单号
|
this.$post({
|
url: "/MesInvItemOuts/GetMaxItemOutNo"
|
}).then(res => {
|
this.formData.itemOutNo = res.data.tbBillList;
|
this.formData.createBy = this.$loginInfo.account;
|
this.formData.createDate = this.$getDate("yyyy-mm-dd hh24:mi:ss");
|
this.formData.fType = 0;
|
});
|
|
//车间下拉框的初始化
|
this.$post({
|
url: "/MesDepots/GetList"
|
}).then(res => {
|
this.depotCodeList = res.data.tbBillList;
|
this.depotNameList = res.data.tbBillList.map(item => item.depotName);
|
});
|
|
this.$post({
|
url: "/MesInvItemArn/GetSuppliers"
|
}).then(res => {
|
this.supplierList = res.data.tbBillList;
|
this.supplierNameList = res.data.tbBillList.map(item => item.suppName);
|
});
|
}
|
},
|
methods: {
|
|
//反审核
|
FToErp() {
|
this.Message = "";
|
|
if (this.tableData.length == 0) {
|
this.Message = "条码为空,无法推送ERP";
|
return;
|
}
|
|
//DeApproveBefore
|
this.$post({
|
url: "/MesInvItemOuts/DeApproveBefore",
|
data: {
|
id: this.formData.id,
|
}
|
}).then(res1 => {
|
if (res1.data.tbBillList) {
|
this.Message = "正在推送采购退料单[" + this.formData.itemOutNo + "]到ERP.... 请稍后";
|
let userName = this.$loginInfo.account;
|
this.$post({
|
url: '/MesInvItemOuts/SaveMessageCenter',
|
data: {
|
id: this.formData.id,
|
billNo: this.formData.itemOutNo,
|
userName: userName,
|
type: "B"
|
}
|
}).then(res => {
|
this.messageCenter = res.data.tbBillList;
|
this.sendErp(this.messageCenter);
|
});
|
} else {
|
this.$showMessage(this.formData.itemOutNo + "已经推送ERP,无法重复推送");
|
}
|
});
|
},
|
sendErp(e) {
|
console.log(e);
|
this.$sendPostRequest(e).then(res => {
|
|
this.saveMessage("B", {
|
url: this.$store.state.serverInfo.serverAPI + '/MesInvItemOuts/DeApprove',
|
data: {id: this.formData.id, billNo: this.formData.itemOutNo}
|
});
|
|
if (res.state == 200) {
|
this.Message += " 正在执行MES回调!请稍后"
|
//执行MES回调
|
this.DeApprove();
|
} else {
|
this.Message += " ERP返回信息:" + res.msg;
|
//更新接口记录表
|
this.messageCenter.result = 0;
|
this.messageCenter.dealWith = 0;
|
this.messageCenter.status = 1;
|
this.messageCenter.resultData = res.msg;
|
this.updateMessage(this.messageCenter);
|
}
|
});
|
},
|
//反审核的MES回调
|
DeApprove() {
|
this.$post({
|
url: '/MesInvItemOuts/DeApprove',
|
data: {
|
id: this.formData.id,
|
billNo: this.formData.itemOutNo
|
}
|
}).then(res => {
|
if (res.data.tbBillList) {
|
this.Message += " 审核成功!";
|
} else {
|
this.Message += " 审核失败!";
|
}
|
|
let entity = {
|
id: this.messageId,
|
resultData: JSON.stringify(res.data),
|
dealWith: res.data.tbBillList ? 1 : 0,
|
result: res.data.tbBillList ? 1 : 0,
|
}
|
this.updateMessage(entity);
|
|
});
|
},
|
|
audit() {
|
this.$post({
|
url: "/MesInvItemOuts/Audit",
|
data: {
|
userName: this.formData.createBy,
|
billNo: this.formData.itemOutNo,
|
id: this.formData.id,
|
}
|
}).then(res => {
|
if (res.data.tbBillList) {
|
this.init();
|
} else {
|
this.$showMessage("审核失败");
|
}
|
});
|
},
|
|
|
save() {
|
if (this.tableData.length == [] || this.tableData.length == 0) {
|
this.$showMessage("请选择需要退货的物料");
|
return;
|
}
|
|
if (this.tableData.filter(s => s.quantity == 0 || s.quantity == null || s.quantity == undefined).length > 0) {
|
this.$showMessage("退货数量不允许为0");
|
return;
|
}
|
|
if (this.tableData.filter(s => s.quantity > s.rkQty).length > 0) {
|
this.$showMessage("申请数量不能超过入库数量");
|
return;
|
}
|
|
this.formData.billTypeId = "200";
|
this.$post({
|
url: "/MesInvItemOuts/SaveCombination",
|
data: {
|
form: this.formData,
|
saveItems: this.tableData
|
}
|
}).then(res => {
|
this.formData = res.data.tbBillList.form;
|
this.tableData = res.data.tbBillList.selectItems;
|
this.getMaterials = [];
|
this.isUpdate = false;
|
})
|
},
|
selectMaterialsChange(e) {
|
this.tableData = [];
|
e.detail.index.forEach(s => {
|
let materials = this.getMaterials[s];
|
let newobject = {
|
pbillNo: materials.workNo,
|
workLine: materials.workLine,
|
itemNo: materials.itemNo,
|
itemName: materials.itemName,
|
itemModel: materials.itemModel,
|
rkQty: materials.sumQuantity,
|
workNo: materials.cbillNo,
|
taskNo: materials.taskNo,
|
fType: this.formData.fType,
|
rkno: materials.billNo
|
};
|
this.tableData.push(newobject);
|
});
|
},
|
selectfType(e) {
|
if (e.detail.value.indexOf("1") >= 0) {
|
this.formData.fType = 1;
|
}
|
},
|
onDepotCodeChange(event) {
|
let depotCodeListElement = this.depotCodeList[this.depotNameList.indexOf(event)];
|
this.formData.depotName = event;
|
this.formData.depotCode = depotCodeListElement.depotCode;
|
},
|
onReasonChange(event) {
|
this.formData.reason = event;
|
},
|
onFmrmodeChange(event) {
|
this.formData.fmrmode = event;
|
},
|
onSuppNameChange(event) {
|
let supplierListElement = this.supplierList[this.supplierNameList.indexOf(event)];
|
this.formData.suppNo = supplierListElement.suppNo;
|
this.SelectMaterials();
|
},
|
init() {
|
this.$post({
|
url: "/MesInvItemOuts/GetPage",
|
data: {
|
id: this.formData.id,
|
pageIndex: 1,
|
limit: 1,
|
}
|
}).then(res => {
|
let data = res.data.tbBillList[0];
|
if (data) {
|
this.formData = data;
|
this.formData.billTypeName = "出库单";
|
this.getItem();
|
}
|
});
|
},
|
getItem() {
|
this.$post({
|
url: "/MesInvItemOuts/GetItems",
|
data: {
|
id: this.formData.id
|
}
|
}).then(res1 => {
|
this.tableData = res1.data.tbBillList;
|
})
|
},
|
SelectMaterials() {
|
this.$post({
|
url: "/MesInvItemOuts/SelectMaterials",
|
data: {
|
suppNo: this.formData.suppNo
|
}
|
}).then(res1 => {
|
this.getMaterials = res1.data.tbBillList;
|
})
|
},
|
saveMessage(s, item) {
|
|
let title = "采购退料单" + this.formData.itemOutNo + "审核";
|
let tableName = "MES_INV_ITEM_OUTS_" + s;
|
|
if (s == "B") {
|
title = "采购退料单" + this.formData.itemOutNo + "反审核";
|
}
|
|
let entity = {
|
data: JSON.stringify(item.data),
|
url: item.url,
|
pid: this.messageCenter.id,
|
dealWith: 0,
|
result: 0,
|
status: 1,
|
seq: this.messageCenter.seq + 1,
|
createBy: this.$loginInfo.account,
|
title: title,
|
route: this.formData.itemOutNo,
|
tableName: tableName,
|
contentType: "application/json",
|
}
|
|
this.$post({
|
url: "/MessageCenter/Insert",
|
data: entity
|
}).then(res => {
|
this.messageId = res.data.tbBillList;
|
});
|
},
|
//更新接口记录表
|
updateMessage(messageCenter) {
|
this.$post({
|
url: "/MessageCenter/ResetUpdate",
|
data: messageCenter
|
}).then(res => {
|
if (res.data.tbBillList > 0) {
|
this.Message += " [问题记录成功!]";
|
} else {
|
this.Message += " [问题记录失败!!!]";
|
}
|
});
|
}
|
},
|
onShow() {
|
//每次进入页面都会执行的方法
|
if (this.formData.id) {
|
this.init();
|
}
|
this.formData.billTypeName = "出库单";
|
},
|
};
|
</script>
|
|
<style>
|
.form-group {
|
display: flex;
|
align-items: center;
|
border-bottom: 1px solid #c9c9c9;
|
}
|
|
.form-label {
|
margin-bottom: 0;
|
padding: 5px;
|
}
|
|
.form-input {
|
flex: 1;
|
margin-bottom: 0;
|
padding: 5px;
|
}
|
|
|
.picker {
|
flex: 1;
|
margin-bottom: 0;
|
padding: 5px;
|
font-size: 12px;
|
}
|
|
.uni-form-item {
|
display: flex;
|
border-bottom: 1px solid #c9c9c9;
|
}
|
|
.edit {
|
background-color: white;
|
}
|
|
/* 默认样式 */
|
.list-container {
|
height: 60vh;
|
/* 设置列表容器的高度为剩余空间,并减去表单容器的高度 */
|
overflow-y: auto;
|
/* 允许列表容器垂直滚动 */
|
padding: 10px;
|
/* 可选:添加一些内边距,使列表内容更美观 */
|
}
|
|
/* 在小屏幕设备上,重置高度为适应屏幕 */
|
@media (max-width: 768px) {
|
.list-container {
|
height: calc(100vh - 500px);
|
/* 适当调整高度 */
|
}
|
}
|
|
|
.form-container {
|
padding: 10px;
|
/* 可选:添加一些内边距,使表单内容更美观 */
|
}
|
|
.th {
|
background-color: lightskyblue;
|
color: #FFFFFF;
|
}
|
|
.text {
|
background-color: #ffee6f;
|
}
|
|
.plus-button {
|
line-height: 59px;
|
font-size: 24px;
|
cursor: pointer;
|
z-index: 1000;
|
margin-bottom: 10px;
|
}
|
|
.overlay {
|
position: fixed;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 100%;
|
background-color: rgba(0, 0, 0, 0.5);
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
}
|
|
.popup {
|
background-color: #fff;
|
padding: 20px;
|
border: 1px solid #ccc;
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
width: 68vw;
|
/* 设置宽度为视口宽度的80% */
|
height: 25vh;
|
/* 设置高度为视口高度的80% */
|
}
|
</style>
|