<template>
|
<view class="wrap">
|
<view class="production-index-bg" />
|
<u-navbar title="编辑产出" :background="background" :border-bottom="false" :title-bold="true" title-color="#000"
|
back-icon-color="#000" />
|
<view class="content">
|
<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">起始数量:</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="primary" size="medium" :customStyle="{width:'150rpx'}" @click="updateProductOut">
|
确定</u-button>
|
</view>
|
</view>
|
</template>
|
<script>
|
import content_bg from '@/static/custom/product/productBg.png'
|
|
export default {
|
data() {
|
return {
|
background: {
|
backgroundImage: `url(${content_bg})`,
|
backgroundAttachment: 'fixed',
|
backgroundSize: '100% auto',
|
backgroundRepeat: 'no-repeat',
|
},
|
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">
|
.production-index-bg {
|
background-color: #F6F9FF;
|
background-image: url('~@/static/custom/product/productBg.png');
|
// background: linear-gradient(180deg,rgba(206,227,254,1),rgba(206,227,254,1) 20%,rgba(206,227,254,0.5) 40%,rgba(206,227,254,0.25) 60%,rgba(206,227,254,0.08) 80%,rgba(206,227,254,0));
|
padding: 0 20rpx;
|
background-attachment: fixed;
|
background-size: 100% auto;
|
background-repeat: no-repeat;
|
position: fixed;
|
top: 0;
|
bottom: 0;
|
width: 100%;
|
z-index: -1;
|
}
|
|
.content {
|
display: flex;
|
height: calc(100vh - var(--window-top) - var(--window-bottom) - 334rpx);
|
width: 100%;
|
line-height: 80rpx;
|
font-size: 28rpx;
|
}
|
|
.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;
|
}
|
|
.row-list{
|
font-size: 32rpx;
|
}
|
</style>
|