<template>
|
<view>
|
<cu-custom bgColor="bg-white" :isBack="true">
|
<block slot="backText">
|
</block>
|
<block slot="content">问题件标记</block>
|
</cu-custom>
|
<view class="flex justify-end align-center padding_right30rpx padding_top12rpx">
|
<text class="fontSize12rpx"> 操作人:{{operator}} </text>
|
</view>
|
<u-form labelPosition="top" :model="warehouse" ref="warehouseRef">
|
<u-row class="border_bottom padding10" style="background-color: #fff;">
|
<u-col span="12">
|
<u-form-item label="容器编号:" prop="containerCode" required style="font-size: 16px;font-weight: bold;padding: 0;">
|
<u-input v-model.trim="warehouse.containerCode" @blur="containerBlur" :focus="true" placeholder="请扫码录入" style="font-weight: bolder;margin-left: 15rpx;" class="width padding_left25rpx">
|
</u-input>
|
</u-form-item>
|
</u-col>
|
</u-row>
|
|
<u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
|
<u-col span="12">
|
<u-form-item label="物料编号:" style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
|
<u-input v-model="warehouse.materialCode" ref="materialRef" placeholder="请扫码录入" @focus="warehouse.materialCode = ''" @blur="getMaterialDetails" style="font-weight: bolder;margin-left: 15rpx;"
|
class="width padding_left25rpx">
|
</u-input>
|
</u-form-item>
|
</u-col>
|
</u-row>
|
</u-form>
|
<modal-code :rescode='rescode' :resmessage='resmessage' ref="resmodal" />
|
<view style="margin-bottom: 200rpx;">
|
<view v-for="(item, eindex) in singlist" :key="item.code" style="width: 100vw;display: flex;">
|
<u-swipe-action :show="item.show" :index="eindex" @click="longpress"
|
@open="open" @close='close' :options="options" style="margin-bottom: 10rpx;width: 100vw;">
|
<view class="title-wrap fontSize32rpx background_fff" :class="Number(item.quantity) > 0 ? 'bg_item' : '' " style="width: 100vw;">
|
<u-row>
|
<u-col span="1">
|
<text class="flex justify-center align-center" style="background-color: #f18202;color: #fff;border-radius: 50vh;width: 40rpx;height: 40rpx;">
|
{{eindex+1}}
|
</text>
|
</u-col>
|
<u-col span="10">
|
<text class="color_f18202">
|
物料编号:{{item.wareMaterialCode}}
|
</text>
|
</u-col>
|
</u-row>
|
<u-row>
|
<u-col span="4">
|
<text>
|
SAP:{{item.sap_Location}}
|
</text>
|
</u-col>
|
<u-col span="8">
|
<text class="el_batchNo">
|
批次:{{item.barNo}}
|
</text>
|
</u-col>
|
</u-row>
|
<u-row style="margin-top: 20rpx;">
|
<u-col span="8">
|
<input class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx" v-model="item.markQuantity"
|
type="number" @blur="changeNum(item)" :min="1" placeholder="请输入标记数量" />
|
</u-col>
|
</u-row>
|
|
<u-row style="margin-top: 20rpx;padding-bottom: 10px;">
|
<u-col span="10">
|
<input class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx" v-model="item.remark"
|
placeholder="请输入备注" />
|
</u-col>
|
<br>
|
</u-row>
|
|
<!-- <u-row style="margin-top: 20rpx;padding-bottom: 10rpx">
|
<u-col span="12">
|
<u-upload :action="action" :header="header" :ref="'upload' + eindex" @on-success="handlerSuccess" @on-error="handlerErr" :auto-upload="false"></u-upload>
|
<u-button @click="submitUpload(eindex)">提交</u-button>
|
</u-col>
|
|
</u-row> -->
|
</view>
|
</u-swipe-action>
|
</view>
|
</view>
|
<button-modal :cleaningShow='true' allTitle='全部取消' cleaningTitle='确认标记' @allsubmit="rest" @submit='submit'/>
|
</view>
|
</template>
|
<script>
|
import ButtonModal from '../../components/buttonModal.vue'
|
import ModalCode from '../../components/ModalCode.vue'
|
import {getContainerMateral,scrapMaterial} from '../../api/mark/index.js'
|
import {getAttrValue} from '../../utils/tool.js'
|
export default {
|
data() {
|
return {
|
rescode: 0,
|
resmessage: "",
|
operator: '',
|
materialList: [], //当前容器里的材料列表
|
singlist: [], //预报废列表
|
options: [
|
{
|
text: '删除',
|
style: {
|
backgroundColor: '#fc4b4b'
|
}
|
}
|
],
|
warehouse: {
|
containerCode: '',
|
materialCode: '',
|
},
|
batchNo: '', //扫码到的当前物料的批次
|
warehouseRules: {
|
containerCode: [{required: true,message: '容器编号不能为空',trigger: 'blur'}],
|
materialCode: [{required: true,message: '物料编号不能为空',trigger: 'blur'}]
|
},
|
action: 'http://172.27.105.59:5566/ScrapMaterial/imageUpload',//上传接口
|
header: {Authorization: 'Bearer ' + uni.getStorageSync('token')},
|
activeIndex: 100, //当前上传的接口
|
|
};
|
},
|
components: {
|
ButtonModal,
|
ModalCode
|
},
|
onReady() {
|
this.$refs.warehouseRef.setRules(this.warehouseRules)
|
},
|
mounted() {
|
this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
|
},
|
|
methods: {
|
//容器失焦事件
|
containerBlur(){
|
if(this.warehouse.containerCode == '') {
|
return
|
}
|
getContainerMateral(this.warehouse.containerCode).then(res => {
|
res.data.map(item => {
|
item.markQuantity = '';
|
item.imageUrl = '';
|
item.remark = '';
|
return item;
|
})
|
this.materialList = res.data;
|
})
|
},
|
|
//物料查询
|
getMaterialDetails() {
|
if(!this.warehouse.materialCode) {
|
return
|
}
|
if(this.warehouse.materialCode.length > 50) {
|
this.batchNo = getAttrValue(this.warehouse.materialCode,'LOTNO')
|
//扫描的物料是否有批次
|
if(!this.batchNo) {
|
this.rescode = 400
|
this.resmessage = '无批次'
|
this.$refs.resmodal.show = true
|
return
|
}
|
this.warehouse.materialCode = getAttrValue(this.warehouse.materialCode,'PARTSNUMBER')
|
// SAP --- && item.sap_Location == SAP
|
let SAP = getAttrValue(this.warehouse.materialCode,'SAP')
|
//判断当前的物料是否在此容器中
|
const count = this.materialList.findIndex(item => item.wareMaterialCode == this.warehouse.materialCode && item.barNo == this.batchNo);
|
if(count < 0) {
|
this.rescode = 400
|
this.resmessage = '容器中不存在批次的物料'
|
this.$refs.resmodal.show = true
|
return
|
}
|
//判断当前的物料是否已经扫描过
|
if(this.singlist.length > 0) {
|
//判断当次扫描的物料是否已存在同批次
|
let index = this.singlist.findIndex(item => item.wareContainerCode == this.warehouse.materialCode && item.barNo == this.batchNo)
|
//置顶
|
if(index > -1) {
|
this.singlist.unshift(...this.singlist.splice(index,1))
|
return
|
}
|
}
|
|
this.singlist.unshift(this.materialList[count])
|
}
|
},
|
//删除详情
|
longpress(index, eindex) {
|
this.singlist.splice(index, 1)
|
|
},
|
// 如果打开一个的时候,不需要关闭其他,则无需实现本方法
|
open(index) {
|
// 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
|
// 原本为'false',再次设置为'false'会无效
|
this.singlist[index].cardNum = true;
|
this.singlist[index].show = true;
|
this.singlist.map((val, idx) => {
|
if (index != idx) this.singlist[idx].show = false;
|
})
|
},
|
close(index) {
|
this.singlist[index].show = false;
|
this.singlist[index].cardNum = false;
|
},
|
//改变标记数量
|
changeNum(option) {
|
if(!option.markQuantity) {
|
uni.showModal({
|
title: '提示',
|
content: '标记不能为空',
|
showCancel: false
|
})
|
}
|
// option.markQuantity = Number(option.markQuantity.toString().match(/^\d+(?:\.\d{0,2})?/)) // 保留两位小数
|
if(option.markQuantity < 0) {
|
uni.showModal({
|
title: '提示',
|
content: '标记数量必须大于0',
|
showCancel: false
|
})
|
}
|
|
},
|
//提交
|
submitUpload(index) {
|
this.activeIndex = index;
|
const uploadRef = 'upload' + index;
|
this.$refs[uploadRef][0].upload();
|
},
|
//上传成功的回调
|
handlerSuccess(res) {
|
if(res.code == 200) {
|
uni.showModal({
|
title: '提示',
|
content: '上传成功',
|
showCancel: false
|
})
|
console.log(this.activeIndex,'activeIndex')
|
this.singlist[this.activeIndex].imageUrl += `|${res.data}`;
|
}else {
|
uni.showModal({
|
title: '提示',
|
content: '上传失败',
|
showCancel: false
|
})
|
}
|
|
},
|
handlerErr(res) {
|
uni.showModal({
|
title: '提示',
|
content: '上传失败',
|
showCancel: false
|
})
|
},
|
//重置页面信息
|
rest() {
|
this.warehouse.containerCode = ''
|
this.warehouse.materialCode = ''
|
this.singlist = []
|
},
|
//确认
|
submit() {
|
//查找是否存在没有填写标记数量的
|
const index = this.singlist.findIndex(item => item.markQuantity == '' || Number(item.markQuantity) <= 0);
|
if(index >= 0) {
|
this.rescode = 400
|
this.resmessage = '标记列表中存在数量为空或者为0'
|
this.$refs.resmodal.show = true
|
return;
|
}
|
// 0712
|
console.log(this.singlist)
|
const params = this.singlist.reduce((curr,item) => {
|
curr.push({
|
wareContainerCode: this.warehouse.containerCode,
|
wareMaterialCode: item.wareMaterialCode,
|
barNo: item.barNo,
|
quantity: Number(item.markQuantity),
|
imageUrl: item.imageUrl,
|
remark: item.remark,
|
sap_Location:item.sap_Location || '',
|
id:item.id
|
})
|
return curr;
|
},[])
|
scrapMaterial(params).then(res => {
|
this.rescode = 400
|
this.resmessage = '标记成功'
|
this.$refs.resmodal.show = true
|
this.rest();
|
})
|
|
|
}
|
|
}
|
}
|
</script>
|
<style lang="scss" scoped>
|
.el_batchNo {
|
padding: 10rpx 0 10rpx 45rpx;
|
color: #808080;
|
}
|
.bg_item {
|
background: #FFEBCD !important;
|
}
|
</style>
|