275 lines
9.5 KiB
Vue
275 lines
9.5 KiB
Vue
<template>
|
||
<view>
|
||
<view class="form-area">
|
||
<view class="view-item">
|
||
<h4>类型名称</h4>
|
||
<span>{{ upperInfo.typeName }}</span>
|
||
</view>
|
||
<view class="view-item">
|
||
<h4>规格型号</h4>
|
||
<span>{{ upperInfo.typeCode }}</span>
|
||
</view>
|
||
<view class="view-item">
|
||
<h4>待入库数量</h4>
|
||
<span>{{ upperInfo.num }}</span>
|
||
</view>
|
||
<view class="view-item">
|
||
<h4>合格数量</h4>
|
||
<uni-easyinput
|
||
type="number"
|
||
v-model="lowerIpt.passedNum"
|
||
placeholder="请输入数量"></uni-easyinput>
|
||
</view>
|
||
<view class="view-item">
|
||
<h4>待修数量</h4>
|
||
<uni-easyinput
|
||
type="number"
|
||
v-model="lowerIpt.waitRepairNum"
|
||
placeholder="请输入数量"></uni-easyinput>
|
||
</view>
|
||
<view class="view-item">
|
||
<h4>待修备注</h4>
|
||
<uni-easyinput
|
||
v-model="lowerIpt.repairRemark"
|
||
placeholder="请输入待修备注"></uni-easyinput>
|
||
</view>
|
||
<view class="view-item">
|
||
<h4>待报废数量</h4>
|
||
<uni-easyinput
|
||
type="number"
|
||
v-model="lowerIpt.waitCrashNum"
|
||
placeholder="请输入数量"></uni-easyinput>
|
||
</view>
|
||
<view class="view-item">
|
||
<h4>报废原因</h4>
|
||
<uni-data-select
|
||
v-model="lowerIpt.scrapReason"
|
||
:localdata="range"
|
||
></uni-data-select>
|
||
</view>
|
||
<view class="view-item">
|
||
<h4>待报废备注</h4>
|
||
<uni-easyinput
|
||
v-model="lowerIpt.scrapRemark"
|
||
placeholder="请输入待报废备注"></uni-easyinput>
|
||
</view>
|
||
<div class="view-item">
|
||
<h4>附件</h4>
|
||
<uni-file-picker
|
||
v-model="lowerIpt.fileList"
|
||
@select="uploadPhoto"
|
||
@delete="deletePhoto"
|
||
limit="9"
|
||
:del-icon="false"
|
||
></uni-file-picker>
|
||
</div>
|
||
</view>
|
||
<view class="sub-btn" @click="subForm"> 确认 </view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
upperInfo: {
|
||
parentId: "",
|
||
typeName: "",
|
||
typeCode: "",
|
||
num: "",
|
||
},
|
||
lowerIpt: {
|
||
passedNum: "",
|
||
waitRepairNum: "",
|
||
waitCrashNum: "",
|
||
repairRemark: '', // 待修备注
|
||
scrapReason: '', // 报废原因
|
||
scrapRemark: '', // 报废备注
|
||
fileList: [], // 附件
|
||
},
|
||
totalNum: 0,
|
||
range: [
|
||
{value: 1, text: '人为'},
|
||
{value: 2, text: '自然损坏'},
|
||
]
|
||
};
|
||
},
|
||
methods: {
|
||
subForm() {
|
||
//三个数量之和小于等于10 才可提交
|
||
// "taskId": "294",
|
||
// {
|
||
// "parentId": 34,
|
||
// "typeId": "5",
|
||
// "backNum": "1",
|
||
// "backStatus":: "3",//合格为 1 待修2 待报废2
|
||
// "manageType": "1",
|
||
// "createBy": "1"
|
||
// }
|
||
let that = this;
|
||
if (
|
||
!this.lowerIpt.passedNum &&
|
||
!this.lowerIpt.waitRepairNum &&
|
||
!this.lowerIpt.waitCrashNum
|
||
) {
|
||
uni.showToast({
|
||
icon: "none",
|
||
title: "退料数量不能为空!",
|
||
});
|
||
return;
|
||
}
|
||
that.totalNum =
|
||
Number(that.lowerIpt.passedNum) +
|
||
Number(that.lowerIpt.waitRepairNum) +
|
||
Number(that.lowerIpt.waitCrashNum);
|
||
console.log('that.totalNum',that.totalNum);
|
||
if (that.totalNum > that.upperInfo.num) {
|
||
uni.showToast({
|
||
icon: "none",
|
||
title: "接收总量不能大于退库数量!",
|
||
});
|
||
} else if (that.totalNum == 0) {
|
||
uni.showToast({
|
||
icon: "none",
|
||
title: "请确保退料总量不为0!",
|
||
});
|
||
} else {
|
||
console.log(this.handleSubmitData());
|
||
that.$api.backMaterialReceive
|
||
.backMaterialSetNumBack({
|
||
taskId: this.upperInfo.taskId,
|
||
arr: this.handleSubmitData(),
|
||
fileList: this.lowerIpt.fileList,
|
||
})
|
||
.then((res) => {
|
||
console.log("res===", res);
|
||
uni.showToast({
|
||
icon: "none",
|
||
title: "接收成功",
|
||
});
|
||
setTimeout(() => {
|
||
uni.navigateBack();
|
||
}, 300);
|
||
});
|
||
}
|
||
},
|
||
handleSubmitData() {
|
||
let list = [];
|
||
const baseInfo = {
|
||
parentId: this.upperInfo.id,
|
||
typeId: this.upperInfo.modelId,
|
||
manageType: this.upperInfo.manageType,
|
||
createBy: this.upperInfo.userId,
|
||
};
|
||
let passInfo = {
|
||
backStatus: 1,
|
||
backNum: this.lowerIpt.passedNum,
|
||
};
|
||
let repairInfo = {
|
||
backStatus: 2,
|
||
backNum: this.lowerIpt.waitRepairNum,
|
||
repairRemark: this.lowerIpt.repairRemark, // 待维修备注
|
||
};
|
||
let crashInfo = {
|
||
backStatus: 3,
|
||
backNum: this.lowerIpt.waitCrashNum,
|
||
scrapReason: this.lowerIpt.scrapReason, // 报废原因
|
||
scrapRemark: this.lowerIpt.scrapRemark, // 待报废备注
|
||
};
|
||
|
||
if (this.lowerIpt.passedNum) {
|
||
let info = {
|
||
...baseInfo,
|
||
...passInfo,
|
||
};
|
||
list.push(info);
|
||
}
|
||
if (this.lowerIpt.waitRepairNum) {
|
||
let info = {
|
||
...baseInfo,
|
||
...repairInfo,
|
||
};
|
||
list.push(info);
|
||
}
|
||
if (this.lowerIpt.waitCrashNum) {
|
||
let info = {
|
||
...baseInfo,
|
||
...crashInfo,
|
||
};
|
||
list.push(info);
|
||
}
|
||
return list;
|
||
},
|
||
uploadPhoto (e) {
|
||
this.lowerIpt.fileList = []
|
||
console.log('🚀 ~ uploadPhoto ~ e:', e)
|
||
let that = this
|
||
// 上传图片
|
||
for (let i = 0; i < e.tempFilePaths.length; i++) {
|
||
that.$api.fix.uploadPic(e.tempFilePaths[i]).then(res => {
|
||
let dealedData = JSON.parse(res.data)
|
||
if (dealedData.code == 200) {
|
||
this.lowerIpt.fileList.push({
|
||
fileName: dealedData.data.fileName,
|
||
fileUrl: dealedData.data.fileUrl,
|
||
typeId: this.upperInfo.modelId,
|
||
})
|
||
}
|
||
console.log('🚀 ~ this.lowerIpt.fileList ~ e:', this.lowerIpt.fileList)
|
||
}).catch(err => {
|
||
console.log(err);
|
||
})
|
||
}
|
||
},
|
||
},
|
||
onLoad(params) {
|
||
console.log("ev", params);
|
||
this.upperInfo = params;
|
||
},
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.form-area {
|
||
width: 90%;
|
||
margin: 40rpx auto;
|
||
display: flex;
|
||
flex-direction: column;
|
||
|
||
.view-item {
|
||
width: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
margin-bottom: 25rpx;
|
||
|
||
h4 {
|
||
width: 35%;
|
||
font-weight: normal;
|
||
font-size: 28rpx;
|
||
}
|
||
|
||
span {
|
||
font-size: 28rpx;
|
||
}
|
||
}
|
||
|
||
.view-item:last-child {
|
||
margin-bottom: 0;
|
||
}
|
||
}
|
||
|
||
.sub-btn {
|
||
width: 80%;
|
||
margin: 20vh auto;
|
||
box-sizing: border-box;
|
||
padding: 15rpx 0;
|
||
background-color: #3788ff;
|
||
color: #fff;
|
||
border-radius: 40rpx;
|
||
font-size: 28rpx;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
}
|
||
</style>
|