<template>
|
<view class="wrap">
|
<view class="row-list" v-if="info.type!='shift'">
|
<u-row justify="space-between" class="shift-product-out-main-row">
|
<u-col span="4">
|
<span class="span-lable">人员</span>
|
</u-col>
|
<u-col span="8">
|
<view class="shift-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="shift-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="起始米标">
|
<u-input v-model="productOutForm.startMeterMark" placeholder="请输入起始米标" type="digit" />
|
</u-form-item>
|
<u-form-item label="截止米标">
|
<u-input v-model="productOutForm.endMeterMark" placeholder="请输入截止米标" type="digit" />
|
</u-form-item>
|
<u-form-item label="每盘产量">
|
<u-input v-model="productOutForm.productQty" placeholder="请输入每盘产量" type="digit" />
|
</u-form-item>
|
<u-form-item label="报废数量">
|
<u-input v-model="productOutForm.scrapQty" placeholder="请输入报废数量" type="digit" />
|
</u-form-item>
|
<u-form-item label="载具编号">
|
<u-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="分段描述">
|
<u-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="shift-product-out-bottom-view">
|
<u-button text="确定" type="success" size="medium" :customStyle="{width:'150rpx'}" @click="addShiftProudctOut">
|
确定</u-button>
|
</view>
|
</view>
|
</template>
|
<script>
|
export default {
|
data() {
|
const currentDateTime = this.getDateTime();
|
return {
|
productOutForm: {
|
workstationId: null,
|
operationTaskId: null,
|
partId: null,
|
partNo: null,
|
partName: null,
|
unit: null,
|
outBatchNo: null,
|
reelNumber: null,
|
ifsBatchNo: null,
|
startMeterMark: null,
|
endMeterMark: null,
|
productQty: null,
|
segmentDesc: null,
|
scrapQty: null,
|
remark: null,
|
staffName: null,
|
date: currentDateTime,
|
status: null,
|
disNumber: null
|
},
|
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.productOutForm.outBatchNo = option.outBatchNo
|
this.productOutForm.startMeterMark = option.endMeterMark
|
this.productOutForm.endMeterMark = option.endMeterMark
|
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 queryUserParam = {
|
id: this.info.dutyId
|
}
|
console.log(queryUserParam)
|
let resUser = await this.$u.api.outputRegister.getPersonByDutyRecordId(queryUserParam)
|
|
let userList = resUser.data
|
if (userList.length > 0) {
|
this.personInitList = []
|
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.productOutForm.staffName = staffName
|
} else {
|
this.personBoardList = []
|
this.productOutForm.staffName = ''
|
}
|
|
}
|
|
},
|
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 = []
|
|
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.productOutForm.staffName = staffName
|
}
|
}
|
},
|
async addShiftProudctOut() {
|
// 起始米标校验
|
if (!this.isNumber(this.productOutForm.startMeterMark)) {
|
this.$u.toast('【起始米标】请输入非负数,小数位最多4位!')
|
return
|
}
|
// 截止米标校验
|
if (!this.isNumber(this.productOutForm.endMeterMark)) {
|
this.$u.toast('【截止米标】请输入非负数,小数位最多4位!')
|
return
|
}
|
// 截止米标需大于开始米标
|
if (
|
Number(this.productOutForm.endMeterMark) <
|
Number(this.productOutForm.startMeterMark)
|
) {
|
this.$u.toast('【截止米标】需大于【起始米标】')
|
return
|
}
|
let productStaffs = []
|
let productStaffIds = []
|
this.personBoardList.forEach((item) => {
|
productStaffs.push(item.staffNo)
|
productStaffIds.push(item.staffId)
|
})
|
let productOuts = []
|
let productVo = {
|
isChangeShift: true,
|
id: null,
|
workstationId: this.productOutForm.workstationId,
|
operationTaskId: this.productOutForm.operationTaskId,
|
productOutputList: productOuts
|
}
|
if (this.info.type == "person") {
|
let productOut = null
|
this.personBoardList.forEach((item) => {
|
productOut = {
|
workstationId: this.productOutForm.workstationId,
|
operationTaskId: this.productOutForm.operationTaskId,
|
partId: this.productOutForm.partId,
|
startMeterMark: this.productOutForm.startMeterMark,
|
endMeterMark: this.productOutForm.endMeterMark,
|
productQty: null,
|
productStaffs: [item.staffNo],
|
productStaffIds: [item.staffId],
|
outBatchNo: this.productOutForm.outBatchNo,
|
reelNumber: this.productOutForm.reelNumber,
|
status: true,
|
dutyRecordId: this.info.dutyId,
|
ifsBatchNo: this.productOutForm.ifsBatchNo,
|
scrapQty: this.productOutForm.scrapQty,
|
segmentDesc: this.productOutForm.segmentDesc,
|
remark: this.productOutForm.remark
|
}
|
productOuts.push(productOut)
|
})
|
} else {
|
let productOut = {
|
workstationId: this.productOutForm.workstationId,
|
operationTaskId: this.productOutForm.operationTaskId,
|
partId: this.productOutForm.partId,
|
startMeterMark: this.productOutForm.startMeterMark,
|
endMeterMark: this.productOutForm.endMeterMark,
|
productQty: null,
|
productStaffs: productStaffs,
|
productStaffIds: productStaffIds,
|
outBatchNo: this.productOutForm.outBatchNo,
|
reelNumber: this.productOutForm.reelNumber,
|
status: false,
|
dutyRecordId: this.info.dutyId,
|
ifsBatchNo: this.productOutForm.ifsBatchNo,
|
scrapQty: this.productOutForm.scrapQty,
|
segmentDesc: this.productOutForm.segmentDesc,
|
remark: this.productOutForm.remark
|
}
|
productOuts.push(productOut)
|
}
|
let res = await this.$u.api.outputRegister.saveProductOutput(productVo)
|
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">
|
.shift-product-out-main-info {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
|
.shift-product-out-main-row {
|
padding-bottom: 2px;
|
padding-top: 2px;
|
}
|
|
.shift-product-out-form {
|
.u-form-item {
|
padding: 7rpx;
|
}
|
}
|
|
.shift-product-out-bottom-view {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
height: calc(100vh - var(--window-top) - var(--window-bottom) - 1062rpx);
|
}
|
</style>
|