<template>
|
<view class="wrap">
|
<view class="row-list" v-if="info.type!='shift'">
|
<u-row justify="space-between" class="product-out-main-row">
|
<u-col span="4">
|
<span class="span-lable">人员</span>
|
</u-col>
|
<u-col span="8">
|
<view class="product-out-main-info">
|
<view>
|
<u-button size="mini" @click="toDutyPerson">点击选择</u-button>
|
</view>
|
</view>
|
</u-col>
|
</u-row>
|
</view>
|
<view class="row-list">
|
<u-form class="product-out-form" :model="productOutForm" ref="productOutForm" label-width="180"
|
:label-style="{paddingLeft:'10rpx'}">
|
<u-form-item label="零件编号">
|
<u-input v-model="productOutForm.partNo" disabled placeholder="" />
|
</u-form-item>
|
<u-form-item label="零件名称">
|
<u-input v-model="productOutForm.partName" disabled placeholder="" />
|
</u-form-item>
|
<u-form-item label="盘数">
|
<input v-model="productOutForm.disNumber" placeholder="请输入盘数" type="digit" />
|
</u-form-item>
|
<u-form-item label="起始米标">
|
<input v-model="productOutForm.startMeterMark" placeholder="请输入起始米标" @blur="startMeterBlur"
|
type="digit" />
|
</u-form-item>
|
<u-form-item label="截止米标">
|
<input v-model="productOutForm.endMeterMark" placeholder="请输入截止米标" @blur="endMeterBlur"
|
type="digit" />
|
</u-form-item>
|
<u-form-item label="每盘产量">
|
<u-input v-model="productOutForm.productQty" placeholder="请输入每盘产量" disabled type="digit" />
|
</u-form-item>
|
<u-form-item label="报废数量">
|
<input v-model="productOutForm.scrapQty" placeholder="请输入报废数量" type="digit" />
|
</u-form-item>
|
<u-form-item label="载具编号">
|
<input v-model="productOutForm.reelNumber" placeholder="请输入载具编号" />
|
</u-form-item>
|
<u-form-item label="单位">
|
<u-input v-model="productOutForm.unit" disabled placeholder="" />
|
</u-form-item>
|
<u-form-item label="分段描述">
|
<input v-model="productOutForm.segmentDesc" />
|
</u-form-item>
|
<u-form-item label="生产人员">{{productOutForm.staffName}}</u-form-item>
|
<u-form-item label="产出日期">
|
<u-input v-model="productOutForm.date" disabled />
|
</u-form-item>
|
</u-form>
|
</view>
|
<view class="product-out-bottom-view" style="margin-top: 15px;">
|
<u-button text="确定" type="success" size="medium" @click="addProudctOut">
|
确定</u-button>
|
</view>
|
</view>
|
</template>
|
<script>
|
export default {
|
|
data() {
|
|
const currentDateTime = this.getDateTime();
|
return {
|
productOutForm: {
|
partNo: null,
|
partName: null,
|
intro: null,
|
date: currentDateTime,
|
staffName:""
|
},
|
info: {},
|
personInitList: [],
|
personBoardList: [],
|
products: []
|
|
};
|
},
|
onLoad(option) {
|
//type:shift 按班组 person 按人员
|
this.info.type = option.type
|
this.info.dutyId = option.dutyId
|
this.info.workstationId = option.workstationId
|
|
|
this.productOutForm.workstationId = option.workstationId
|
this.productOutForm.operationTaskId = option.operationTaskId
|
this.productOutForm.partId = option.partId
|
this.productOutForm.partName = option.partName == "null" ? "" : option.partName
|
this.productOutForm.partNo = option.partNo == "null" ? "" : option.partNo
|
this.productOutForm.unit = option.unit == "null" ? "" : option.unit
|
//获取当班人员
|
this.getPerson()
|
},
|
onShow() {
|
|
|
},
|
methods: {
|
getDateTime() {
|
let year = new Date().getFullYear(); //年
|
let month = new Date().getMonth() + 1; //注意!月份是从0月开始获取的,所以要+1;
|
let day = new Date().getDate(); //日
|
let hour = new Date().getHours(); //时
|
let minute = new Date().getMinutes(); //分
|
let second = new Date().getSeconds(); //秒
|
//拼接日期 YYYY/MM/DD HH:mm
|
let currentDate =
|
year +
|
'/' +
|
(month >= 10 ? month : '0' + month) +
|
'/' +
|
(day >= 10 ? day : '0' + day);
|
let currentTime =
|
(hour >= 10 ? hour : '0' + hour) +
|
':' +
|
(minute >= 10 ? minute : '0' + minute) +
|
':' +
|
(second >= 10 ? second : '0' + second);
|
|
return currentDate + " " + currentTime
|
},
|
async getPerson() {
|
let queryParam = {
|
id: this.info.workstationId
|
}
|
|
let res = await this.$u.api.outputRegister.getDutyRecordByWorkstationId(queryParam)
|
|
this.dutyForm = res.data
|
if (this.dutyForm && this.dutyForm.id) {
|
|
let queryUserParam = {
|
id: this.dutyForm.id
|
}
|
|
let resUser = await this.$u.api.outputRegister.getPersonByDutyRecordId(queryUserParam)
|
|
let userList = resUser.data
|
if (userList.length > 0) {
|
this.personInitList = []
|
this.$set(this.productOutForm, 'staffName', "");
|
let staffName = ""
|
userList.map((item, index) => {
|
|
if (index == userList.length - 1) {
|
staffName = staffName + item.staffName
|
} else {
|
staffName = staffName + item.staffName + ","
|
}
|
|
let data = {
|
staffId: item.staffId,
|
staffName: item.staffName,
|
staffNo: item.staffNo,
|
checked: false
|
}
|
|
this.personInitList.push(data)
|
});
|
|
//type:shift 按班组 person 按人员
|
if (this.info.type == "shift") {
|
this.personBoardList = this.personInitList
|
this.$set(this.productOutForm, 'staffName', staffName);
|
} else {
|
this.personBoardList = []
|
this.$set(this.productOutForm, 'staffName', "");
|
}
|
|
}
|
}
|
|
},
|
setProducts() {
|
let productStaffs = []
|
let productStaffIds = []
|
let newProduct = {}
|
this.products = []
|
//type:shift 按班组 person 按人员
|
if (this.info.type == "shift") {
|
// 按班组报工,一条记录
|
let staffName = ''
|
let staffNo = ''
|
for (let i = 0; i < this.personBoardList.length; i++) {
|
staffName += this.personBoardList[i].staffName + ','
|
staffNo += this.personBoardList[i].staffNo + ','
|
productStaffs.push(this.personBoardList[i].staffNo)
|
productStaffIds.push(this.personBoardList[i].staffId)
|
}
|
|
staffName = staffName.substring(0, staffName.length - 1)
|
staffNo = staffNo.substring(0, staffNo.length - 1)
|
|
newProduct = {}
|
newProduct.staffName = staffName
|
newProduct.staffNo = staffNo
|
newProduct.productNo = null
|
newProduct.partId = this.productOutForm.partId
|
newProduct.partNo = this.productOutForm.partNo
|
newProduct.partName = this.productOutForm.partName
|
newProduct.outBatchNo = null
|
newProduct.disNumber = this.productOutForm.disNumber
|
newProduct.productQty = 0
|
newProduct.sproductQty = 0
|
newProduct.ifsBatchNo = null
|
newProduct.unit = this.productOutForm.unit
|
newProduct.productStaffs = productStaffs
|
newProduct.productStaffIds = productStaffIds
|
newProduct.status = false
|
newProduct.systemNo = null
|
newProduct.date = this.productOutForm.date
|
newProduct.dutyRecordId = this.info.dutyId
|
newProduct.startMeterMark = this.productOutForm.startMeterMark
|
newProduct.endMeterMark = this.productOutForm.endMeterMark
|
newProduct.scrapQty = this.productOutForm.scrapQty
|
newProduct.segmentDesc = this.productOutForm.segmentDesc
|
newProduct.remark = null
|
newProduct.outBatchNo = null
|
newProduct.reelNumber = this.productOutForm.reelNumber
|
this.products.push(newProduct)
|
|
} else {
|
let newProduct
|
for (let i = 0; i < this.personBoardList.length; i++) {
|
newProduct = {}
|
productStaffs = []
|
productStaffIds = []
|
productStaffIds.push(this.personBoardList[i].staffId)
|
productStaffs.push(this.personBoardList[i].staffNo)
|
newProduct.staffName = this.personBoardList[i].staffName
|
newProduct.staffNo = this.personBoardList[i].staffNo
|
newProduct.productNo = null
|
newProduct.partId = this.productOutForm.partId
|
newProduct.partNo = this.productOutForm.partNo
|
newProduct.partName = this.productOutForm.partName
|
newProduct.outBatchNo = null
|
newProduct.disNumber = this.productOutForm.disNumber
|
newProduct.productQty = 0
|
newProduct.sproductQty = 0
|
newProduct.unit = this.productOutForm.unit
|
newProduct.productStaffs = productStaffs
|
newProduct.productStaffIds = productStaffIds
|
newProduct.status = true
|
newProduct.systemNo = null
|
newProduct.date = this.productOutForm.date
|
newProduct.dutyRecordId = this.info.dutyId
|
newProduct.startMeterMark = this.productOutForm.startMeterMark
|
newProduct.endMeterMark = this.productOutForm.endMeterMark
|
newProduct.reelNumber = this.productOutForm.reelNumber
|
newProduct.ifsBatchNo = null
|
newProduct.scrapQty = this.productOutForm.scrapQty
|
newProduct.segmentDesc = this.productOutForm.segmentDesc
|
newProduct.remark = null
|
this.products.push(newProduct)
|
}
|
}
|
|
},
|
toDutyPerson() {
|
|
if (this.personInitList.length > 0) {
|
uni.navigateTo({
|
url: '/pages/product/outputRegister/dutyPersonList?item=' + encodeURIComponent(JSON
|
.stringify(this.personInitList))
|
})
|
}
|
},
|
setProductPerson(userList) {
|
//type:shift 按班组 person 按人员
|
if (this.info.type == "person") {
|
//过滤掉选中的人员信息
|
userList = userList.filter(item => item.checked == true)
|
this.personBoardList = []
|
this.$set(this.productOutForm, 'staffName', "");
|
// this.personBoardList = userList
|
if (userList.length > 0) {
|
let staffName = ""
|
userList.map((item, index) => {
|
|
if (index == userList.length - 1) {
|
staffName = staffName + item.staffName
|
} else {
|
staffName = staffName + item.staffName + ","
|
}
|
|
let data = {
|
staffId: item.staffId,
|
staffName: item.staffName,
|
staffNo: item.staffNo,
|
checked: item.checked
|
}
|
|
this.personBoardList.push(data)
|
});
|
this.$set(this.productOutForm, 'staffName', staffName);
|
}
|
}
|
},
|
startMeterBlur(obj) {
|
if ((this.productOutForm.startMeterMark != "" ) && (this.productOutForm.endMeterMark!= "")) {
|
let qty = parseFloat(this.productOutForm.endMeterMark) - parseFloat(this.productOutForm.startMeterMark)
|
qty = parseFloat(qty.toFixed(4))
|
this.$set(this.productOutForm, 'productQty', qty);
|
}
|
},
|
endMeterBlur(obj) {
|
|
if ((this.productOutForm.startMeterMark != "" ) && (this.productOutForm.endMeterMark!= "")) {
|
let qty = parseFloat(this.productOutForm.endMeterMark) - parseFloat(this.productOutForm.startMeterMark)
|
qty = parseFloat(qty.toFixed(4))
|
this.$set(this.productOutForm, 'productQty', qty);
|
}
|
},
|
async addProudctOut() {
|
|
// 生产人员
|
if (this.productOutForm.staffName==""||this.productOutForm.staffName==undefined||this.productOutForm.staffName==null) {
|
|
this.$u.toast('生产人员不能为空')
|
return
|
}
|
|
//设置工单信息
|
this.setProducts();
|
|
for (let i = 0; i < this.products.length; i++) {
|
|
// 盘数校验
|
if (!this.isPositiveIntegerNumber(this.products[i].disNumber)) {
|
|
this.$u.toast('第' + (i + 1) + '行,【盘数】请输入正整数!')
|
return
|
}
|
// 起始米标校验
|
if (!this.isNumber(this.products[i].startMeterMark)) {
|
this.$u.toast('第' + (i + 1) + '行,【起始米标】请输入非负数,小数位最多4位!')
|
return
|
}
|
// 截止米标校验
|
if (!this.isNumber(this.products[i].endMeterMark)) {
|
this.$u.toast('第' + (i + 1) + '行,【截止米标】请输入非负数,小数位最多4位!')
|
return
|
}
|
// 截止米标需大于开始米标
|
if (
|
Number(this.products[i].endMeterMark) <
|
Number(this.products[i].startMeterMark)
|
) {
|
this.$u.toast('第' + (i + 1) + '行,【截止米标】需大于【起始米标】')
|
return
|
}
|
}
|
|
// 当前是产出的新增
|
const list = []
|
for (let i = 0; i < this.products.length; i++) {
|
let productVo = {}
|
productVo.isChangeShift = false
|
productVo.id = null
|
productVo.workstationId = this.productOutForm.workstationId
|
productVo.operationTaskId = this.productOutForm.operationTaskId
|
productVo.discsNumber = this.products[i].disNumber
|
let productOuts = []
|
let productOut = {}
|
productOut.workstationId = this.productOutForm.workstationId
|
productOut.operationTaskId = this.productOutForm.operationTaskId
|
productOut.partId = this.products[i].partId
|
productOut.disNumber = this.products[i].disNumber
|
productOut.productQty = this.products[i].productQty
|
productOut.sproductQty = this.products[i].sproductQty
|
productOut.productStaffs = this.products[i].productStaffs
|
productOut.productStaffIds = this.products[i].productStaffIds
|
productOut.outBatchNo = this.products[i].outBatchNo
|
productOut.status = this.products[i].status
|
productOut.dutyRecordId = this.products[i].dutyRecordId
|
productOut.startMeterMark = this.products[i].startMeterMark
|
productOut.endMeterMark = this.products[i].endMeterMark
|
|
productOut.outBatchNo = this.products[i].outBatchNo
|
productOut.reelNumber = this.products[i].reelNumber
|
productOut.ifsBatchNo = this.products[i].ifsBatchNo
|
productOut.scrapQty = this.products[i].scrapQty
|
productOut.segmentDesc = this.products[i].segmentDesc
|
productOut.remark = this.products[i].remark
|
|
productOuts.push(productOut)
|
productVo.productOutputList = productOuts
|
list.push(productVo)
|
}
|
|
let res = await this.$u.api.outputRegister.batchSaveProductMain(list)
|
let that = this
|
|
if (res.code == 0) {
|
uni.showModal({
|
title: '提示',
|
content: '提交成功',
|
showCancel: false,
|
success: function() {
|
that.refreshLastPage()
|
}
|
})
|
|
} 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
|
}
|
}
|
},
|
isPositiveIntegerNumber(value) {
|
var reg = /^[1-9]\d*$/
|
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">
|
.product-out-main-info {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
|
.product-out-main-row {
|
padding-bottom: 2px;
|
padding-top: 2px;
|
}
|
|
.product-out-form {
|
.u-form-item {
|
padding: 7rpx;
|
}
|
}
|
|
.product-out-bottom-view {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
height: calc(100vh - var(--window-top) - var(--window-bottom) - 1062rpx);
|
}
|
</style>
|
|
|
<style scoped>
|
|
.uni-input-placeholder{font-size: 12px;color: rgb(192, 196, 204);}
|
|
>>>.uni-input-input{font-size: 12px;}
|
</style>
|