<template>
|
<view class="overflow">
|
<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 margin_top10rpx padding10" style="background-color: #fff;">
|
<u-col span="12">
|
<u-form-item label="容器编号:" prop="containerCode" required
|
style="font-size: 32rpx;font-weight: bold;padding: 0;">
|
<u-input v-model="warehouse.WareContainerCode" placeholder="请录入或扫码" @focus="warehouse.WareContainerCode=''"
|
:focus="true"
|
@blur="checkTask"
|
class="width padding_left25rpx">
|
</u-input>
|
</u-form-item>
|
</u-col>
|
<!-- <u-col span="2">
|
<u-icon class="iconfont icon-saoma fontSize60rpx"></u-icon>
|
</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: 32rpx;font-weight: bold;padding: 0 0 10rpx;">
|
<u-input v-model="warehouse.WareMaterialCode" @focus="warehouse.WareMaterialCode = ''" placeholder="请录入或扫码"
|
@blur="checkTask" class="width padding_left25rpx">
|
</u-input>
|
</u-form-item>
|
</u-col>
|
<!-- <u-col span="2">
|
<u-icon class="iconfont icon-saoma fontSize60rpx"></u-icon>
|
</u-col> -->
|
</u-row>
|
|
</u-form>
|
<modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
|
<view v-if="singlist.length>0" :style="'height:calc(100vh - '+(CustomBar+225)+'px'">
|
<view class="margin_top10rpx overflow_auto" style="height:calc(100% - 30rpx)">
|
<scroll-view scroll-y="true">
|
<u-swipe-action :show="item.show" :index="eindex" v-for="(item, eindex) in singlist" :key="eindex"
|
@click="longpress" @open="open" :options="options">
|
<view class="item u-border-bottom ">
|
<!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
|
<view class="title-wrap itemTap" @tap.stop.prevent="pitch(item)"
|
:class="item.edit?'clickactive':''">
|
<view :key="eindex+'singlist'"
|
class="fontSize32rpx width margin_auto background_fff padding15 border_radius margin_bottom10rpx relative box_sizing transition">
|
<u-row>
|
<u-col span="11" class="flex">
|
<view class="flex justify-center align-center"
|
style="background-color: #f18202;color: #fff;border-radius: 50vh;width: 40rpx;height: 40rpx;">
|
{{eindex+1}}
|
</view>
|
<view class="color_f18202 padding_left10rpx">
|
{{item.wareMaterialCode}} - {{item.batchNo}}
|
</view>
|
</u-col>
|
<u-col span='1' v-if='sign'>
|
<u-icon name='question-circle' color='#f18202'></u-icon>
|
</u-col>
|
</u-row>
|
<u-row style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
|
<u-col span="6">
|
<view class="" >
|
物料名称:{{item.wareMaterialName}}
|
</view>
|
</u-col>
|
<u-col span="6">
|
<view class="">
|
报废数量:{{item.quantity}}
|
</view>
|
</u-col>
|
</u-row>
|
<u-row>
|
<u-col span="6">
|
<view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
|
已报废数量:{{item.completeQuantity}}
|
</view>
|
</u-col>
|
<u-col span="5">
|
<input
|
class="border_bottom_f18202 width text-left fontSize32rpx padding_left10rpx"
|
v-model="item.uncollectedQuantity" type="number"
|
@tap.prevent.stop=""
|
@blur.stop.prevent="changeNum(item,$event)" placeholder="请输入报废数量" />
|
</u-col>
|
</u-row>
|
</view>
|
</view>
|
</view>
|
</u-swipe-action>
|
</scroll-view>
|
</view>
|
<u-popup v-model="detailshow" border-radius="14" @close="detailshow=false" mode="bottom" :closeable='true'>
|
<view class="pop ">
|
<h2 class="text_align_center padding_bottom18 padding15">物料信息</h2>
|
<!-- <scroll-view scroll-y="true" style="height: 50vh;"> -->
|
<view class="line flex justify-between">
|
<text class="text-gray">物料编号</text>
|
<text>{{materlist.wareMaterialCode}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">物料名称</text>
|
<text>{{materlist.wareMaterialName}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">容器编号</text>
|
<text>{{materlist.wareContainerCode}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">库存数量</text>
|
<text>{{materlist.quantity}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">物料大类</text>
|
<text>{{materlist.wareMaterialCategoryName}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">物料小类</text>
|
<text>{{materlist.wareMaterialTypeName}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">单位</text>
|
<text>{{materlist.unit}}</text>
|
</view>
|
<view class="line flex justify-between">
|
<text class="text-gray">报废单号</text>
|
<text>{{materlist.orderNo}}</text>
|
</view>
|
|
</view>
|
</u-popup>
|
</view>
|
<!-- <button-modal :empTytowerShow='true' cleaningTitle='重置' @reset='rest' garmenTitle='确认报废' @submit='submit' /> -->
|
<button-modal :issueShow='true' issueTitle="打印" subTitle='确认' restTiltle='重置' @reset='rest'
|
@submit='submit' @issue="init"/>
|
</view>
|
</template>
|
|
<script>
|
import ButtonModal from '../../components/buttonModal.vue'
|
import ModalCode from '../../components/ModalCode.vue'
|
import BluePrint from '@/pages/print/bluePrint.js'
|
import {getAttrValue} from '@/utils/tool.js'
|
import { addPrintRecord } from '../../api/print.js'
|
|
import {
|
scrapQuery,
|
confirm
|
} from '@/api/scrap.js'
|
export default {
|
data() {
|
return {
|
detailshow: false,
|
renameFocus: false,
|
modalshow: false,
|
issueShow: false,
|
rescode: 0,
|
resmessage: "",
|
focuM: false,
|
focu: true,
|
sign: false, //问题标识
|
operator: '',
|
singlist: [], //物料详情
|
options: [{
|
text: '详情',
|
style: {
|
backgroundColor: '#fc9f35'
|
}
|
}],
|
materlist: {},
|
warehouse: {
|
'WareContainerCode':"",
|
'WareMaterialCode':"",
|
'BatchNo':""
|
},
|
warehouseRules: {
|
// Code: [{
|
// required: true,
|
// message: '二维码不能为空',
|
// trigger: 'blur'
|
// }]
|
},
|
arr: [],
|
addForm:{
|
// 'code':123
|
}
|
};
|
},
|
components: {
|
ButtonModal,
|
ModalCode
|
},
|
onReady() {
|
this.$refs.warehouseRef.setRules(this.warehouseRules)
|
},
|
mounted() {
|
this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
|
},
|
methods: {
|
//验证二维码
|
checkTask() {
|
if(this.warehouse.WareContainerCode=='' || this.warehouse.WareMaterialCode==''){
|
return
|
}
|
if(this.warehouse.WareMaterialCode.length < 50) {
|
return
|
}
|
// 错误码提示
|
let str = this.warehouse.WareMaterialCode.replace(/\s/g,'')
|
if(str.indexOf('LOTNO') == -1 || str.indexOf('PARTSNUMBER') == -1){
|
uni.showToast({
|
title:'二维码格式错误',
|
icon:'none',
|
duration: 2000
|
})
|
return
|
}
|
//获取批次
|
this.warehouse.BatchNo = getAttrValue(this.warehouse.WareMaterialCode,'LOTNO')
|
//物料编号
|
this.warehouse.WareMaterialCode = getAttrValue(this.warehouse.WareMaterialCode,'PARTSNUMBER')
|
// SAP --- && item.sap_Location == SAP
|
let SAP = getAttrValue(this.warehouse.WareMaterialCode,'SAP')
|
|
this.$refs.warehouseRef.validate(valid => {
|
if (valid) {
|
scrapQuery({
|
...this.warehouse,
|
'sap_Location':SAP
|
}).then((res) => {
|
if (res.code == 200) {
|
if (res.data.length <= 0) {
|
this.rescode = 400
|
this.resmessage = '暂无数据'
|
this.$refs.resmodal.show = true
|
return
|
}
|
this.singlist = res.data
|
this.singlist.forEach(item => {
|
item.uncollectedQuantity =(Number(item.quantity) -Number( item.completeQuantity) ).toFixed(3)
|
if (item.quantity) {
|
item.edit = true
|
}
|
})
|
} else {
|
this.$refs.resmodal.show = true
|
this.rescode = res.code
|
this.resmessage = res.message
|
}
|
})
|
}
|
})
|
},
|
//删除详情
|
longpress(index, eindex) {
|
this.singlist.forEach(item => {
|
item.materlist = [{
|
issue: ''
|
}]
|
})
|
this.materlist = this.singlist[index]
|
this.detailshow = true
|
},
|
// 如果打开一个的时候,不需要关闭其他,则无需实现本方法
|
open(index) {
|
// 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
|
// 原本为'false',再次设置为'false'会无效
|
this.singlist[index].show = true;
|
this.singlist.map((val, idx) => {
|
if (index != idx) this.singlist[idx].show = false;
|
})
|
},
|
//改变组盘数量
|
changeNum(val, event) {
|
//防止穿透
|
event.stopPropagation()
|
if(val==''){
|
return
|
}
|
// val.uncollectedQuantity = Number(val.uncollectedQuantity.toString().match(/^\d+(?:\.\d{0,2})?/)) // 保留两位小数
|
if (val.uncollectedQuantity >Number( val.quantity) - Number( val.completeQuantity)){
|
this.$refs.resmodal.show = true
|
this.resmessage = '数量大于总数和已报废数量差'
|
this.rescode = 400
|
}
|
},
|
rest() {
|
this.warehouse.WareContainerCode = ''
|
this.warehouse.WareMaterialCode = ''
|
this.singlist = []
|
},
|
//确认
|
submit() {
|
this.$refs.warehouseRef.validate(valid => {
|
if (valid) {
|
|
this.arr = this.singlist.filter(item => item.edit == 1)
|
if (this.arr == 0) {
|
this.$refs.resmodal.show = true
|
this.resmessage = '请选择报废物料'
|
this.rescode = res.code
|
return
|
}
|
const index = this.arr.findIndex(item => {
|
return item.uncollectedQuantity == '' || item.uncollectedQuantity == undefined || item.uncollectedQuantity == 0
|
})
|
if(index > -1) {
|
this.$refs.resmodal.show = true
|
this.resmessage = '请填写报废数量'
|
this.rescode = res.code
|
return
|
}
|
|
let details = []
|
this.arr.forEach(item => {
|
details.push({
|
createdTime: this.Datetime,
|
updatedTime: this.Datetime,
|
createdUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
|
createdUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
|
updatedUserId: JSON.parse(uni.getStorageSync('userInfo')).id,
|
updatedUserName: JSON.parse(uni.getStorageSync('userInfo')).name,
|
wareContainerCode:item.wareContainerCode,
|
wareMaterialCode: item.wareMaterialCode,
|
wareMaterialName: item.wareMaterialName,
|
price: item.price,
|
batchNo: item.batchNo,
|
id:item.id,
|
completeQuantity:item.completeQuantity,
|
ordersId:item.ordersId,
|
quantity: item.uncollectedQuantity,
|
orderNo: item.orderNo,
|
sap_Location:item.sap_Location,
|
scrapMaterialId:item.scrapMaterialId
|
})
|
})
|
|
uni.showModal({
|
title: '提示',
|
content: '确认报废',
|
showCancel: true,
|
cancelColor: '#333333',
|
success: (res => {
|
if (res.confirm) {
|
confirm(details).then((res) => {
|
this.$refs.resmodal.show = true
|
this.resmessage = res.message
|
this.rescode = res.code
|
if (res.code == 200) {
|
this.rest()
|
}
|
})
|
} else if (res.cancel) {
|
|
}
|
})
|
});
|
|
}
|
})
|
},
|
|
init() {
|
if (this.singlist.length <= 0) {
|
this.detailshow = false
|
this.rescode = 400
|
this.resmessage = "没有需要打印的物料"
|
this.$refs.resmodal.show = true
|
return
|
}
|
this.arrPt = this.singlist.filter((v) => v.edit == true)
|
if (this.arrPt.length <= 0) {
|
uni.showToast({
|
icon: 'none',
|
title: '请选中打印的物料并填写数量',
|
duration: 2000
|
})
|
return
|
}
|
|
let arr3 = this.arrPt.findIndex((v) => v.wareMaterialCode == "" || v.uncollectedQuantity <= 0 || v.uncollectedQuantity == undefined || v.uncollectedQuantity == ''|| v.batchNo == ''|| v.batchNo == null)
|
|
if (arr3 >= 0) {
|
if (this.arrPt[arr3].wareMaterialCode == '') {
|
this.detailshow = false
|
this.rescode = 400
|
this.resmessage = `物料编号为空,不能继续打印`
|
this.$refs.resmodal.show = true
|
}
|
if (this.arrPt[arr3].batchNo == '' || this.arrPt[arr3].batchNo == null) {
|
this.detailshow = false
|
this.rescode = 400
|
this.resmessage = `批次为空,不能继续打印`
|
this.$refs.resmodal.show = true
|
}
|
if (this.arrPt[arr3].uncollectedQuantity <= 0 || this.arrPt[arr3].uncollectedQuantity == undefined || this.arrPt[arr3].uncollectedQuantity == '') {
|
this.detailshow = false
|
this.rescode = 400
|
this.resmessage = `数量大于0`
|
this.$refs.resmodal.show = true
|
}
|
return
|
}
|
let arr4 = this.arrPt.findIndex((v) => v.uncollectedQuantity > v.quantity - v.completeQuantity)
|
if (arr4 >= 0) {
|
this.detailshow = false
|
this.rescode = 400
|
this.resmessage = `大于报废数量与已报废数量之差`
|
this.$refs.resmodal.show = true
|
return
|
}
|
this.print()
|
},
|
|
//打印
|
print() {
|
// 数组只有一个对象
|
this.materlist = this.arrPt[0]
|
uni.showLoading({//防止多次点击
|
mask: true,
|
title: "正在连接..."
|
})
|
let ptintContext = [{
|
type: 'text',
|
x: 0,
|
y: 0,
|
text: '',
|
size: 2,
|
rotate: 0,
|
bold: 0,
|
underline: false,
|
reverse: false
|
},
|
{
|
type: 'text',
|
x: 0,
|
y: 0,
|
text: '',
|
size: 2,
|
rotate: 0,
|
bold: 0,
|
underline: false,
|
reverse: false
|
},
|
{
|
type: 'text',
|
x: 0,
|
y: 0,
|
text: '',
|
size: 2,
|
rotate: 0,
|
bold: 0,
|
underline: false,
|
reverse: false
|
},
|
/* 以上空数据,为防止丢包时打印不正常 */
|
{
|
type: 'line',
|
x1: 3,
|
y1: 3,
|
x2: 565,
|
y2: 3,
|
width: 2
|
},
|
{
|
type: 'line',
|
x1: 3,
|
y1: 3,
|
x2: 3,
|
y2: 345,
|
width: 2
|
},
|
{
|
type: 'line',
|
x1: 3,
|
y1: 345,
|
x2: 565,
|
y2: 345,
|
width: 2
|
},
|
{
|
type: 'line',
|
x1: 565,
|
y1: 345,
|
x2: 565,
|
y2: 3,
|
width: 2
|
},
|
{
|
type: 'text',
|
x: 80,
|
y: 15,
|
text: '牧野汽车装备(武汉)有限公司',
|
size: 3,
|
rotate: 0,
|
bold: 1,
|
underline: false,
|
reverse: false
|
},
|
{
|
type: 'line',
|
x1: 3,
|
y1: 60,
|
x2: 565,
|
y2: 60,
|
width: 2
|
},
|
{
|
type: 'text',
|
x: 10,
|
y: 75,
|
text: `物料编号: ${this.materlist.wareMaterialCode}`,
|
size: 2,
|
rotate: 0,
|
bold: 1,
|
underline: false,
|
reverse: false
|
},
|
{
|
type: 'line',
|
x1: 3,
|
y1: 110,
|
x2: 380,
|
y2: 110,
|
width: 2
|
},
|
{
|
type: 'text',
|
x: 10,
|
y: 125,
|
text: `物料名称: ${this.materlist.materialTypeId || ''}`,
|
size: 2,
|
rotate: 0,
|
bold: 1,
|
underline: false,
|
reverse: false
|
},
|
{
|
type: 'line',
|
x1: 3,
|
y1: 160,
|
x2: 380,
|
y2: 160,
|
width: 2
|
},
|
{
|
type: 'text',
|
x: 10,
|
y: 175,
|
text: `批次: ${this.materlist.batchNo}`,
|
size: 2,
|
rotate: 0,
|
bold: 1,
|
underline: false,
|
reverse: false
|
},
|
{
|
type: 'line',
|
x1: 3,
|
y1: 210,
|
x2: 565,
|
y2: 210,
|
width: 2
|
},
|
{
|
type: 'line',
|
x1: 380,
|
y1: 60,
|
x2: 380,
|
y2: 210,
|
width: 2
|
},
|
{ type: 'qr', x: 410, y: 72, text: `PARTS NUMBER: ${this.materlist.wareMaterialCode},SAP: ${this.materlist.sap_Location || ''},LOT NO: ${this.materlist.batchNo},QUANTITY: ${this.materlist.uncollectedQuantity}`, width: 3, level: 1 },
|
{
|
type: 'text',
|
x: 10,
|
y: 225,
|
text: `数量(QTY): ${this.materlist.uncollectedQuantity}`,
|
size: 2,
|
rotate: 0,
|
bold: 1,
|
underline: false,
|
reverse: false
|
},
|
{
|
type: 'line',
|
x1: 3,
|
y1: 260,
|
x2: 565,
|
y2: 260,
|
width: 2
|
},
|
{
|
type: 'text',
|
x: 160,
|
y: 278,
|
text: `标记问题件`,
|
size: 4,
|
rotate: 0,
|
bold: 1,
|
underline: false,
|
reverse: false
|
},
|
]
|
console.log(ptintContext)
|
// addPrintRecord(this.addForm).then(res => { //测试
|
BluePrint.print(this.$store, ptintContext).then((res) => {
|
this.printHandle()
|
}).catch((err) => {
|
uni.hideLoading();
|
uni.showToast({
|
icon: 'error',
|
title: '打印失败',
|
duration: 2000
|
})
|
})
|
},
|
printHandle(){
|
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
|
let curRoute = routes[routes.length - 1].route //获取当前页面路由
|
if (curRoute == 'pages/scrap/scrap') {
|
this.arrPt.splice(0, 1)
|
if(this.arrPt.length==0){
|
uni.hideLoading();
|
uni.showToast({
|
title: `打印完成`,
|
duration: 2000
|
})
|
return
|
}
|
uni.showLoading({
|
mask: true,
|
title: `打印成功:${this.materlist.wareMaterialCode}`
|
})
|
this.timer = setTimeout(() => {// 设置定时器的作用:连接蓝牙失败跳页面,js运行有时有延迟,造成读取当前页面路由错误
|
clearTimeout(this.timer)
|
this.print()
|
|
// 添加打印记录:和打印分开,互不干扰
|
this.addForm.code = this.materlist.wareMaterialCode;
|
this.addForm.name = this.materlist.wareMaterialName;
|
this.addForm.batchNo = this.materlist.batchNo;
|
console.log(this.addForm)
|
//这里不再记录打印记录,因为有了斑马打印 【Editby shaocx,2023-05-22】
|
/*
|
addPrintRecord(this.addForm).then(res => {
|
if (res.code == 200) {
|
} else {
|
uni.hideLoading();
|
uni.showToast({
|
icon: 'none',
|
title: '打印记录存储失败',
|
duration: 2000
|
})
|
}
|
})
|
//*/
|
}, 5000)
|
}
|
},
|
//选中
|
pitch(e) {
|
e.edit = !e.edit
|
this.arr = this.singlist.filter(item => item.edit)
|
this.$forceUpdate()
|
},
|
},
|
|
}
|
</script>
|
|
<style lang="scss">
|
.clickactive {
|
position: relative;
|
border: 1px solid #f18202;
|
border-radius: 5rpx;
|
background: white !important;
|
|
&::after {
|
content: '';
|
background-image: url("@/static/modal/iconCk.png");
|
background-size: cover;
|
width: 24px;
|
height: 24px;
|
display: block;
|
position: absolute;
|
right: 0;
|
bottom: 0;
|
}
|
}
|
|
.triangle-topright {
|
width: 0;
|
height: 0;
|
border-top: 37px solid #ffff00;
|
border-right: 37px solid transparent;
|
position: absolute;
|
top: 0;
|
left: 0px;
|
}
|
|
.itemTap {
|
margin-bottom: 10rpx;
|
}
|
</style>
|