<template>
|
<view class="wrap">
|
<view>
|
<scroll-view class="scroll-list edit-product-out-scroll" scroll-y="true">
|
<u-cell-group class="list" :border="false">
|
<u-card :title="item.username" :sub-title="item.phone" v-for="(item, index) in editProductOutList"
|
:key="item.id" :index="item.id" :showHead="showEditCardHead">
|
<view slot="body">
|
<view class="row-list">
|
<u-row justify="space-between">
|
<u-col span="4">
|
<span class="span-lable">SN号</span>
|
</u-col>
|
<u-col span="8">
|
<view>
|
<span>{{item.outBatchNo}}</span>
|
</view>
|
</u-col>
|
</u-row>
|
</view>
|
<view class="row-list">
|
<u-row justify="space-between">
|
<u-col span="4">
|
<span class="span-lable">IFS批次号</span>
|
</u-col>
|
<u-col span="8">
|
<view>
|
<u-input class="custom-edit-input" v-model="item.ifsBatchNo" type="text"
|
:clearable=false height="50"></u-input>
|
</view>
|
</u-col>
|
</u-row>
|
</view>
|
<view class="row-list">
|
<u-row justify="space-between">
|
<u-col span="4">
|
<span class="span-lable">起始米标</span>
|
</u-col>
|
<u-col span="8">
|
<view>
|
<u-input class="custom-edit-input" v-model="item.startMeterMark" type="digit"
|
:clearable=false height="50" @blur="startMeterBlur(item)"></u-input>
|
</view>
|
</u-col>
|
</u-row>
|
</view>
|
<view class="row-list">
|
<u-row justify="space-between">
|
<u-col span="4">
|
<span class="span-lable">截止米标</span>
|
</u-col>
|
<u-col span="8">
|
<view>
|
<u-input class="custom-edit-input" v-model="item.endMeterMark"
|
:clearable=false height="50" type="digit" @blur="endMeterBlur(item)"></u-input>
|
</view>
|
</u-col>
|
</u-row>
|
</view>
|
<view class="row-list">
|
<u-row justify="space-between">
|
<u-col span="4">
|
<span class="span-lable">生产数量</span>
|
</u-col>
|
<u-col span="8">
|
<view>
|
<span>{{item.productQty}}</span>
|
</view>
|
</u-col>
|
</u-row>
|
</view>
|
<view class="row-list">
|
<u-row justify="space-between">
|
<u-col span="4">
|
<span class="span-lable">报废数量</span>
|
</u-col>
|
<u-col span="8">
|
<view>
|
<u-input class="custom-edit-input" v-model="item.scrapQty"
|
:clearable=false height="50" type="digit"></u-input>
|
</view>
|
</u-col>
|
</u-row>
|
</view>
|
<view class="row-list">
|
<u-row justify="space-between">
|
<u-col span="4">
|
<span class="span-lable">分段描述</span>
|
</u-col>
|
<u-col span="8">
|
<view>
|
<u-input class="custom-edit-input" v-model="item.segmentDesc" type="text"
|
:clearable=false height="50"></u-input>
|
</view>
|
</u-col>
|
</u-row>
|
</view>
|
</view>
|
</u-card>
|
</u-cell-group>
|
</scroll-view>
|
</view>
|
<view class="edit-product-out-btn-view">
|
<u-button text="确定" type="success" size="medium" :customStyle="{width:'150rpx'}" @click="updateProductOut">
|
确定</u-button>
|
</view>
|
</view>
|
</template>
|
<script>
|
export default {
|
data() {
|
return {
|
editProductOutList:[],
|
showEditCardHead: false
|
};
|
},
|
onLoad(params) {
|
if (params.item) {
|
let list = JSON.parse(decodeURIComponent(params.item));
|
this.editProductOutList =list
|
}
|
},
|
onShow() {
|
|
},
|
methods: {
|
startMeterBlur(item)
|
{
|
if(item.endMeterMark!="")
|
{
|
let qty= parseFloat(item.endMeterMark) - parseFloat(item.startMeterMark)
|
qty = parseFloat(qty.toFixed(4))
|
this.$set(item, 'productQty', qty);
|
}
|
},
|
endMeterBlur(item )
|
{
|
if(item.startMeterMark!="")
|
{
|
let qty= parseFloat(item.endMeterMark) - parseFloat(item.startMeterMark)
|
qty = parseFloat(qty.toFixed(4))
|
this.$set(item, 'productQty', qty);
|
}
|
},
|
async updateProductOut() {
|
|
for (let i = 0; i < this.editProductOutList.length; i++) {
|
|
// 起始米标校验
|
if (!this.isNumber(this.editProductOutList[i].startMeterMark)) {
|
this.$u.toast('第' + (i + 1) + '行,【起始米标】请输入非负数,小数位最多4位!')
|
return
|
}
|
// 截止米标校验
|
if (!this.isNumber(this.editProductOutList[i].endMeterMark)) {
|
this.$u.toast('第' + (i + 1) + '行,【截止米标】请输入非负数,小数位最多4位!')
|
return
|
}
|
// 截止米标需大于开始米标
|
if (
|
Number(this.editProductOutList[i].endMeterMark) <
|
Number(this.editProductOutList[i].startMeterMark)
|
) {
|
this.$u.toast('第' + (i + 1) + '行,【截止米标】需大于【起始米标】')
|
return
|
}
|
}
|
|
let data=[]
|
this.editProductOutList.forEach((el) => {
|
let productVo = {}
|
productVo.id = el.id
|
let productOuts = []
|
let productOut = {}
|
productOut.startMeterMark = parseFloat(el.startMeterMark)
|
productOut.endMeterMark = parseFloat(el.endMeterMark)
|
productOut.productQty = el.productQty
|
productOut.segmentDesc = el.segmentDesc
|
productOut.scrapQty = el.scrapQty
|
productOut.ifsBatchNo = el.ifsBatchNo
|
productOut.reelNumber = el.reelNumber
|
productOut.remark = el.remark
|
productOuts.push(productOut)
|
productVo.productOutputList = productOuts
|
data.push(productVo)
|
})
|
|
let res= await this.$u.api.outputRegister.batchUpdateProductMain(data)
|
let that = this
|
if(res.code==0)
|
{
|
uni.showModal({
|
title: '提示',
|
content: '编辑成功',
|
showCancel: false,
|
success: function() {
|
that.refreshLastPage()
|
// setTimeout(()=> {
|
// that.refreshLastPage()
|
// }, 5500);
|
}
|
})
|
|
}else
|
{
|
uni.showModal({
|
title: '提示',
|
content: '编辑失败',
|
showCancel: false,
|
success: function() {
|
}
|
})
|
}
|
},
|
isNumber(value) {
|
var reg = /^[0-9]+(.[0-9]{1,4})?$/
|
if (
|
value == undefined ||
|
value == null ||
|
value === '' ||
|
value.trim === ''
|
) {
|
return false
|
} else {
|
if (!reg.test(value)) {
|
return false
|
} else {
|
return true
|
}
|
}
|
},
|
//刷新上一个页面
|
refreshLastPage() {
|
// 告知 A.vue 更新数据
|
// 获取页面栈
|
let pages = getCurrentPages()
|
|
// 获取上一页栈
|
let prevPage = pages[pages.length - 2]
|
|
// 触发上一页 upData 函数(并携带参数)
|
prevPage.$vm.refreshTrackingRecord()
|
|
// 返回上一页
|
uni.navigateBack({
|
delta: 1
|
})
|
},
|
}
|
};
|
</script>
|
<style lang="scss">
|
.edit-product-out-scroll{
|
background-color: #f8f8f8;
|
}
|
.edit-product-out-scroll{
|
::v-deep .u-cell-item-box{
|
background-color: #f8f8f8;
|
}
|
}
|
.edit-product-out-btn-view{
|
display: flex;
|
justify-content: space-between;
|
margin-top: 20rpx;
|
}
|
.custom-edit-input{
|
border-bottom: 2rpx solid #F8F8F8;
|
}
|
|
</style>
|