SmartStorage/pages/backMaterialReceiveDetail/backMaterialReceiveDetail.vue

700 lines
15 KiB
Vue
Raw Normal View History

2023-12-23 23:21:42 +08:00
<template>
<view>
<view
class="single-fetch"
v-for="(fetch, index) in fetchList"
:key="index"
>
2023-12-23 23:21:42 +08:00
<view>
<checkbox-group
@change="checkClick(fetch)"
style="margin-right: 15rpx;"
2024-07-18 10:30:47 +08:00
v-show="fetch.backStatus == '0' && Number(fetch.num) == 0"
>
<checkbox :checked="fetch.checked" />
</checkbox-group>
2023-12-23 23:21:42 +08:00
</view>
<view class="info-cont">
<view>
<span>类型名称</span>
<h4>{{ fetch.typeName }}</h4>
</view>
<view>
<span>规格型号</span>
<h4>{{ fetch.typeCode }}</h4>
</view>
<view>
<span>待退料数量</span>
<h4>{{ fetch.num }}</h4>
</view>
<h5
@click="openPopup(fetch)"
>
点击退料
</h5>
2023-12-23 23:21:42 +08:00
</view>
</view>
<view class="btm-sticky">
<view class="checked">
<checkbox-group @tap="checkAll" style="margin-right: 15rpx;">
<checkbox :checked="allChecked" />
</checkbox-group>
<text>全选</text>
2023-12-23 23:21:42 +08:00
</view>
2024-07-18 10:30:47 +08:00
<view
class="exam"
@click="totalBack"
>
完成退料
</view>
2023-12-23 23:21:42 +08:00
</view>
2023-12-24 16:28:36 +08:00
<uni-popup ref="popup1" type="center" :mask-click="false">
2023-12-23 23:21:42 +08:00
<view class="popup1">
<view class="pop-top">
<h4>退料接收</h4>
2024-03-13 17:55:34 +08:00
<uni-icons style="color: #AAAAAA; font-weight: bold;" type="closeempty" size="20"
2023-12-24 16:28:36 +08:00
@click="closePopup1">
2023-12-23 23:21:42 +08:00
</uni-icons>
</view>
<h5 style="width: 85%; margin: 2vh auto; font-weight: normal; text-align: center;">请选择接收方式</h5>
<view class="select-area">
<view @click="scanCode">二维码</view>
<view @click="codeOut">编码接收</view>
2024-03-13 17:55:34 +08:00
<view @click="rfidOut">RFID接收</view>
2023-12-23 23:21:42 +08:00
</view>
<!-- <view class="ipt-area">
<uni-easyinput v-model="codeVal" placeholder="请输入编码"></uni-easyinput>
</view> -->
</view>
</uni-popup>
2023-12-24 16:28:36 +08:00
<uni-popup ref="popup2" type="center" :mask-click="false">
2023-12-23 23:21:42 +08:00
<view class="popup2">
<view class="pop-top">
<h4>退料接收</h4>
2024-03-13 17:55:34 +08:00
<uni-icons style="color: #AAAAAA; font-weight: bold;" type="closeempty" size="20"
2023-12-24 16:28:36 +08:00
@click="closePopup2">
2023-12-23 23:21:42 +08:00
</uni-icons>
</view>
<view class="info-area">
<view>
<h4>类型名称</h4>
<span>{{ infoList.typeName }}</span>
</view>
<view>
<h4>规格型号</h4>
<span>{{ infoList.typeModelName }}</span>
</view>
<view>
<h4>待入库数量</h4>
<span>{{ infoList.preNum }}</span>
</view>
<!-- <view style="flex-direction: column;">
<h4 style="margin-bottom: 30rpx;">待修状态</h4>
<uni-data-checkbox v-model="fixVal" :localdata="fixRange"></uni-data-checkbox>
</view> -->
<view>
<h4>合格数量</h4>
<uni-easyinput type="number" v-model="passedNum" placeholder="请输入"></uni-easyinput>
</view>
<view>
<h4>待修数量</h4>
<uni-easyinput type="number" v-model="waitRepairNum" placeholder="请输入"></uni-easyinput>
</view>
<view>
<h4>待报废数量</h4>
<uni-easyinput type="number" v-model="waitCrashNum" placeholder="请输入"></uni-easyinput>
</view>
</view>
2023-12-24 16:28:36 +08:00
<view class="sub-btn" @click="multiOut">
2023-12-23 23:21:42 +08:00
退料接收
</view>
</view>
</uni-popup>
</view>
</template>
<script>
2023-12-24 14:19:53 +08:00
import QS from "qs"
2023-12-23 23:21:42 +08:00
export default {
data() {
return {
2024-07-18 10:30:47 +08:00
pageNum: 1,
pageSize: 10,
pageTotal: 0,
allChecked: false,
2023-12-23 23:21:42 +08:00
fetchList: [
2023-12-24 16:28:36 +08:00
2023-12-23 23:21:42 +08:00
],
codeVal: '',
manageType: '',
infoList: '',
multiNum: 1,
subList: {},
fixVal: '',
2023-12-24 16:28:36 +08:00
fixRange: [{
text: '合格',
value: '0'
},
{
text: '待修',
value: '1'
},
{
text: '待报废',
value: '2'
}
2023-12-23 23:21:42 +08:00
],
passedNum: '',
waitRepairNum: '',
2023-12-24 16:28:36 +08:00
waitCrashNum: '',
2023-12-24 16:50:36 +08:00
detailsId: '',
2023-12-24 17:28:53 +08:00
taskId: '',
2023-12-24 19:32:32 +08:00
submitFlag:false,
2024-03-13 17:55:34 +08:00
taskStatus:'',
transMaCode: '',
rfidNum: '',
sendTypeId: '',
parentId: ''
2023-12-23 23:21:42 +08:00
}
},
methods: {
2023-12-24 16:28:36 +08:00
openPopup(list) {
2023-12-24 02:19:29 +08:00
console.log(list);
2023-12-23 23:21:42 +08:00
this.infoList = list
2024-03-13 17:55:34 +08:00
this.rfidNum = list.num
this.transMaCode = list.code
this.sendTypeId = list.typeId
this.parentId = list.id
if(Number(list.num)==0){
uni.showToast({
icon: 'none',
title: '待退料数据为0请勿再点击'
})
return
}
2023-12-24 02:19:29 +08:00
if (this.infoList.manageType == '0') {
2023-12-23 23:21:42 +08:00
this.$refs.popup1.open()
2024-04-20 14:35:37 +08:00
} else {
2023-12-24 14:19:53 +08:00
const userInfo = uni.getStorageSync('userInfo');
2023-12-24 16:28:36 +08:00
console.log("userInfo", userInfo)
2023-12-24 14:19:53 +08:00
const userId = userInfo.userid
2023-12-24 16:28:36 +08:00
2023-12-24 14:19:53 +08:00
const {
taskId,
id,
typeId,
2024-04-10 13:52:16 +08:00
modelId,
2023-12-24 14:19:53 +08:00
manageType,
typeName,
typeCode,
num
2023-12-24 16:28:36 +08:00
} = this.infoList
2023-12-24 14:19:53 +08:00
const params = {
2023-12-24 16:28:36 +08:00
taskId,
2023-12-24 14:19:53 +08:00
id,
typeId,
2024-04-10 13:52:16 +08:00
modelId,
2023-12-24 14:19:53 +08:00
manageType,
userId,
typeName,
typeCode,
num
}
const urlStr = QS.stringify(params)
2023-12-24 16:28:36 +08:00
console.log("urlSTR", urlStr)
2023-12-24 02:19:29 +08:00
uni.navigateTo({
2023-12-24 14:19:53 +08:00
url: `/pages/numReceive/numReceive?${urlStr}`
2023-12-24 02:19:29 +08:00
})
2023-12-23 23:21:42 +08:00
}
},
2023-12-24 16:28:36 +08:00
closePopup1() {
2023-12-23 23:21:42 +08:00
this.$refs.popup1.close()
},
2023-12-24 16:28:36 +08:00
closePopup2() {
2023-12-23 23:21:42 +08:00
this.$refs.popup2.close()
},
checkClick(item) {
item.checked = !item.checked
if (!item.checked) {
this.allChecked = false
} else {
const goods = this.fetchList.every(item => {
return item.checked === true
})
if (goods) {
this.allChecked = true
} else {
this.allChecked = false
}
}
},
checkAll() {
this.allChecked = !this.allChecked
if (this.allChecked) {
this.fetchList.map(item => {
if (item.checked == false) {
item.checked = true
}
})
} else {
this.fetchList.map(item => {
if (item.checked == true) {
item.checked = false
}
})
}
},
2023-12-24 16:28:36 +08:00
scanCode() {
const that = this
that.closePopup1()
2024-03-13 17:55:34 +08:00
/* uni.scanCode({
2023-12-23 23:21:42 +08:00
success: (res) => {
2023-12-24 16:28:36 +08:00
console.log("beforeScan", res);
const userInfo = uni.getStorageSync('userInfo');
console.log("beforeScan11111", userInfo,that.taskId)
2023-12-24 16:28:36 +08:00
const userId = userInfo.userid
2023-12-23 23:21:42 +08:00
uni.navigateTo({
url: `/pages/scanReceive/scanReceive?code=${res.result}&typeId=${that.infoList.typeId}&num=${that.infoList.num}&parentId=${that.infoList.id}&manageType=${that.infoList.manageType}&taskId=${that.taskId}&createBy=${userId}&scanType="back"`
2023-12-23 23:21:42 +08:00
})
}
2024-03-13 17:55:34 +08:00
}) */
const userId = uni.getStorageSync('userInfo').userid
uni.navigateTo({
2024-04-08 17:28:48 +08:00
url: `/pages/QRIn/QRIn?typeId=${that.infoList.modelId}&num=${that.infoList.num}&parentId=${that.infoList.id}&manageType=${that.infoList.manageType}&taskId=${that.taskId}&createBy=${userId}&scanType="back"`
2023-12-23 23:21:42 +08:00
})
},
2023-12-24 16:28:36 +08:00
codeOut() {
2023-12-23 23:21:42 +08:00
this.closePopup1()
2023-12-24 16:28:36 +08:00
const userInfo = uni.getStorageSync('userInfo');
console.log("userInfo", userInfo)
const userId = userInfo.userid
2023-12-24 16:50:36 +08:00
2023-12-24 16:28:36 +08:00
const {
taskId,
id,
typeId,
2024-04-08 17:28:48 +08:00
modelId,
2023-12-24 16:28:36 +08:00
manageType,
typeName,
typeCode,
num
} = this.infoList
const params = {
taskId,
id,
typeId,
2024-04-08 17:28:48 +08:00
modelId,
2023-12-24 16:28:36 +08:00
manageType,
userId,
typeName,
typeCode,
num
}
const urlStr = QS.stringify(params)
console.log("urlSTR", urlStr)
2023-12-23 23:21:42 +08:00
uni.navigateTo({
2024-03-13 17:55:34 +08:00
url: `/pages/codeReceive/codeReceive?${urlStr}&maCode=${this.transMaCode}`
})
},
rfidOut () {
this.closePopup1()
uni.navigateTo({
url: `/pages/rfidReceive/rfidReceive?waitOut=${this.rfidNum}&typeId=${this.sendTypeId}&parentId=${this.parentId}&taskId=${this.taskId}`
2023-12-23 23:21:42 +08:00
})
},
2023-12-24 16:28:36 +08:00
multiOut() {
2023-12-23 23:21:42 +08:00
let that = this
this.closePopup2()
that.subList = {
parentId: that.infoList.parenntId,
typeId: that.infoList.typeId,
outNum: that.multiNum,
companyId: uni.getStorageSync('userInfo').sysUser.companyId
}
console.log(that.subList);
that.$api.fetchMaterialOutStore.subOutStore(that.subList, null).then(res => {
console.log(res);
if (res.data.code == 200) {
uni.showToast({
icon: 'none',
title: '退料接收成功!',
success: () => {
uni.navigateBack()
}
})
} else {
uni.showToast({
icon: 'none',
title: '退料接收失败!'
})
}
}).catch(err => {
console.log(err);
})
2023-12-24 16:28:36 +08:00
},
initListData() {
let that = this
2024-03-13 17:55:34 +08:00
console.log(that.detailsId);
2023-12-24 16:28:36 +08:00
that.$api.backMaterialReceive.backMaterialReceiveDetail({
2024-07-18 10:30:47 +08:00
id: that.detailsId,
taskId: that.taskId,
pageNum: that.pageNum,
pageSize: that.pageSize
2023-12-24 16:28:36 +08:00
}).then(res => {
2024-03-13 17:55:34 +08:00
console.log(res);
2023-12-24 16:28:36 +08:00
if (res.data.code == 200) {
2024-07-18 10:30:47 +08:00
that.pageTotal = res.data.data.total
res.data.data.rows.forEach(item => {
if (item.backStatus == '0') item.checked = false
})
2024-07-18 10:30:47 +08:00
/* res.data.data.forEach(item => {
item.checked = false
}) */
that.fetchList = [...that.fetchList, ...res.data.data.rows]
2023-12-24 16:28:36 +08:00
console.log(that.fetchList);
}
}).catch(err => {
console.log(err);
})
2023-12-24 16:50:36 +08:00
},
backReceiveEndBackFn() {
const that = this
2023-12-24 17:28:53 +08:00
let total = that.reduceNumTotal()
console.log("total==",total)
2023-12-24 17:28:53 +08:00
if (total > 0) {
uni.showToast({
icon: 'none',
title: '请完成退料接收后才能结束任务'
})
return
}
// submitFlag false
if(that.submitFlag==true){
return
}
that.submitFlag = true
2024-04-01 09:11:26 +08:00
console.log(that.taskId, that.detailsId);
2023-12-24 16:50:36 +08:00
that.$api.backMaterialReceive.backReceiveEndBack({
2024-03-13 17:55:34 +08:00
createBy: uni.getStorageSync('userInfo').userid,
2023-12-24 16:50:36 +08:00
taskId: that.taskId,
2023-12-24 17:28:53 +08:00
parentId: that.detailsId
}).then(res => {
2024-04-07 09:39:22 +08:00
console.log(res)
2024-03-21 15:42:08 +08:00
if (res.data.code == 200) {
uni.showToast({
icon: 'none',
title: '结束任务成功'
})
console.log("退料结束",res)
that.submitFlag = false
uni.navigateBack()
} else {
uni.showToast({
icon: 'none',
title: res.data.msg
})
}
2023-12-24 17:28:53 +08:00
}).catch(err=>{
that.submitFlag = false
}).finally(result=>{
that.submitFlag = false
})
},
reduceNumTotal() {
const that = this
let sum = that.fetchList.reduce((accumulator, currentValue) => {
return accumulator + Number(currentValue.num);
2023-12-24 17:28:53 +08:00
}, 0);
console.log("numaccumulator", sum)
return sum
2024-07-18 10:30:47 +08:00
},
endBackMaFn (obj) {
let that = this
console.log(obj);
// 完成退料
that.$api.backMaterialReceive.backReceiveEndBack(obj).then(res => {
console.log(res)
if (res.data.code == 200) {
uni.showToast({
icon: 'none',
title: res.data.msg
})
uni.navigateBack()
} else {
uni.showToast({
icon: 'none',
title: res.data.msg
})
}
}).catch(err=>{
console.log(err);
})
},
totalBack () {
let that = this
let submitList = that.fetchList.filter(item => item.checked == true && Number(item.num) == 0)
if (submitList.length != 0) {
console.log(submitList);
let typeIdStr
let typeIdArr = []
submitList.forEach(item => {
typeIdArr.push(item.modelId)
})
typeIdStr = typeIdArr.join(',')
console.log(typeIdStr);
uni.showModal({
title: '完成退料',
content: '确认完成退料吗?',
success: (res) => {
if (res.confirm) {
that.endBackMaFn({
createBy: uni.getStorageSync('userInfo').userid,
parentId: submitList[0].id,
taskId: submitList[0].taskId,
typeId: typeIdStr
})
}
}
})
} else {
uni.showToast({
icon: 'none',
title: '未选中完成退料项!'
})
}
2023-12-23 23:21:42 +08:00
}
},
onLoad(params) {
2024-03-13 17:55:34 +08:00
console.log(params);
2023-12-24 16:50:36 +08:00
this.taskId = params.taskId
2023-12-24 16:28:36 +08:00
this.detailsId = params.id
2023-12-24 19:32:32 +08:00
this.taskStatus = params.taskStatus
2023-12-24 16:28:36 +08:00
},
onShow() {
2024-07-18 10:30:47 +08:00
this.fetchList = []
2023-12-24 16:28:36 +08:00
this.initListData()
},
onNavigationBarButtonTap(ev) {
let that = this
/* if (ev.text == '') {
2023-12-24 19:32:32 +08:00
if(this.taskStatus=="40"){
uni.showToast({
icon: 'none',
title: '请勿再点击'
})
return
}
2023-12-24 16:50:36 +08:00
that.backReceiveEndBackFn()
} */
let submitList = that.fetchList.filter(item => item.checked == true)
if (submitList.length != 0) {
console.log(submitList);
} else {
uni.showToast({
icon: 'none',
title: '未选中完成退料项!'
})
2023-12-24 16:50:36 +08:00
}
2024-07-18 10:30:47 +08:00
},
onReachBottom() {
if (this.fetchList.length >= this.pageTotal) return;
this.pageNum++
this.initListData()
2023-12-23 23:21:42 +08:00
}
}
</script>
<style lang="scss">
body{
background-color: #FAFDFF;
box-sizing: border-box;
padding-bottom: 10vh;
}
2023-12-24 16:28:36 +08:00
.single-fetch {
2023-12-23 23:21:42 +08:00
width: 100%;
box-sizing: border-box;
padding: 30rpx;
2023-12-23 23:21:42 +08:00
border-bottom: 1px solid #DDDDDD;
display: flex;
align-items: center;
.info-cont{
view {
display: flex;
align-items: center;
margin-bottom: 25rpx;
span {
color: #A7A7A7;
padding-right: 20rpx;
}
h4 {
font-size: 14px;
font-weight: normal;
}
2023-12-23 23:21:42 +08:00
}
view:last-child {
margin-bottom: 0;
}
h5{
width: 150rpx;
2023-12-23 23:21:42 +08:00
font-size: 14px;
font-weight: normal;
box-sizing: border-box;
padding: 10rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: #3788FF;
color: #fff;
border-radius: 15rpx;
2023-12-23 23:21:42 +08:00
}
}
2023-12-23 23:21:42 +08:00
}
2023-12-24 16:28:36 +08:00
.btm-exam {
2023-12-23 23:21:42 +08:00
position: fixed;
left: 0;
bottom: 0;
width: 100%;
box-sizing: border-box;
padding: 20rpx 40rpx;
display: flex;
justify-content: flex-end;
border-top: 2px solid #F6F8FF;
2023-12-24 16:28:36 +08:00
.exam {
2023-12-23 23:21:42 +08:00
box-sizing: border-box;
padding: 10rpx 50rpx;
border-radius: 30rpx;
background-color: #3788FF;
font-size: 14px;
color: #fff;
}
}
.btm-sticky{
position: fixed;
bottom: 0;
left: 0;
width: 100%;
box-sizing: border-box;
padding: 15rpx 30rpx;
background-color: #fff;
display: flex;
2024-07-18 10:30:47 +08:00
justify-content: space-between;
align-items: center;
.checked{
display: flex;
align-items: center;
}
2024-07-18 10:30:47 +08:00
.exam{
box-sizing: border-box;
padding: 10rpx 50rpx;
border-radius: 30rpx;
background-color: #3788FF;
font-size: 14px;
color: #fff;
}
}
2023-12-24 16:28:36 +08:00
.popup1 {
2023-12-23 23:21:42 +08:00
width: 80vw;
height: 20vh;
background-color: #fff;
border-radius: 15rpx;
overflow: hidden;
background: linear-gradient(#D9E7FE, #fff, #fff, #fff);
2023-12-24 16:28:36 +08:00
.pop-top {
2023-12-23 23:21:42 +08:00
width: 100%;
height: 5vh;
box-sizing: border-box;
padding: 0 25rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
2023-12-24 16:28:36 +08:00
.select-area {
2023-12-23 23:21:42 +08:00
width: 85%;
margin: 40rpx auto;
display: flex;
justify-content: space-around;
align-items: center;
2023-12-24 16:28:36 +08:00
view {
2023-12-23 23:21:42 +08:00
box-sizing: border-box;
font-size: 14px;
padding: 10rpx 20rpx;
border: 1px solid #D5D5D4;
border-radius: 20rpx;
}
}
2023-12-24 16:28:36 +08:00
.ipt-area {
2023-12-23 23:21:42 +08:00
width: 85%;
margin: 40rpx auto;
}
}
2023-12-24 16:28:36 +08:00
.popup2 {
2023-12-23 23:21:42 +08:00
width: 80vw;
height: 60vh;
background-color: #fff;
border-radius: 15rpx;
overflow: hidden;
background: linear-gradient(#D9E7FE, #fff, #fff, #fff);
2023-12-24 16:28:36 +08:00
.pop-top {
2023-12-23 23:21:42 +08:00
width: 100%;
height: 5vh;
box-sizing: border-box;
padding: 0 25rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
2023-12-24 16:28:36 +08:00
.info-area {
2023-12-23 23:21:42 +08:00
width: 85%;
margin: 30rpx auto;
display: flex;
flex-direction: column;
2023-12-24 16:28:36 +08:00
view {
2023-12-23 23:21:42 +08:00
margin-bottom: 15rpx;
display: flex;
align-items: center;
2023-12-24 16:28:36 +08:00
h4 {
2023-12-23 23:21:42 +08:00
font-weight: normal;
color: #989898;
font-size: 14px;
width: 35%;
}
2023-12-24 16:28:36 +08:00
span {
2023-12-23 23:21:42 +08:00
font-size: 14px;
}
}
}
2023-12-24 16:28:36 +08:00
.sub-btn {
2023-12-23 23:21:42 +08:00
width: 85%;
margin: 30rpx auto;
background-color: #3788FF;
color: #fff;
box-sizing: border-box;
padding: 15rpx 0;
display: flex;
justify-content: center;
align-items: center;
border-radius: 40rpx;
font-size: 14px;
}
}
2023-12-24 16:28:36 +08:00
</style>