<template>
|
<el-dialog
|
width="95%"
|
:title="parentInfo.productOutId == null ? '交班产出' : '编辑产出'"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
:close-on-click-modal="false"
|
class="product-out-form"
|
>
|
<div
|
style="float: left;width: 15%;box-sizing: border-box;padding-right: 34px;position: relative"
|
>
|
<el-table
|
stripe
|
ref="productOutPersonList"
|
:data="personBoardList"
|
@selection-change="productOutPersonSelectionChange"
|
:row-style="{ height: '26px' }"
|
:cell-style="{ padding: '0' }"
|
>
|
<el-table-column type="selection" />
|
<el-table-column
|
label="人员名称"
|
prop="staffName"
|
align="center"
|
min-width="75px"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="人员编号"
|
prop="staffNo"
|
align="center"
|
min-width="75px"
|
:show-overflow-tooltip="true"
|
/>
|
</el-table>
|
<div
|
style="position: absolute;top:0px;right: 0px;height: 100%;width: 34px;border-left: 1px solid #f4f2ea;border-right: 1px solid #f4f2ea;"
|
></div>
|
</div>
|
<div style="float: left;width: 85%">
|
<el-row style="">
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>序号</span></el-col
|
><el-col :span="2" class="product-out-form-header-col"
|
><span>零件编号</span></el-col
|
><el-col :span="2" class="product-out-form-header-col"
|
><span>零件名称</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>SN号</span></el-col
|
>
|
<el-col :span="2" class="product-out-form-header-col"
|
><span>载具编号</span></el-col
|
>
|
<el-col :span="2" class="product-out-form-header-col"
|
><span>IFS批次号</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>起始米标</span></el-col
|
><el-col :span="2" class="product-out-form-header-col"
|
><span>截止米标</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>生产数量</span></el-col
|
><el-col :span="1" class="product-out-form-header-col"
|
><span>单位</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>分段描述</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>报废数量</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>盘具重量</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>毛重</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>备注</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>生产人员</span></el-col
|
><el-col :span="1" class="product-out-form-header-col"
|
><span>产出日期</span></el-col
|
><el-col :span="1" class="product-out-form-header-col"
|
><span>统计方式</span></el-col
|
>
|
<el-col :span="1" class="product-out-form-header-col"
|
><span>操作</span></el-col
|
>
|
</el-row>
|
<div class="product-out-form-body-div">
|
<el-row v-for="(item, index) in products" :key="item.id">
|
<el-col :span="1" class="product-out-form-body-col">
|
<span>{{ index + 1 }}</span>
|
</el-col>
|
<el-col :span="2" class="product-out-form-body-col">
|
<el-tooltip
|
class="item"
|
effect="dark"
|
:content="item.partNo"
|
placement="top"
|
>
|
<span class="inline-el-hidden">{{ item.partNo }}</span>
|
</el-tooltip>
|
</el-col>
|
<el-col :span="2" class="product-out-form-body-col">
|
<el-tooltip
|
class="item"
|
effect="dark"
|
:content="item.partName"
|
placement="top"
|
>
|
<span class="inline-el-hidden">{{ item.partName }}</span>
|
</el-tooltip>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col l-mes">
|
<el-tooltip
|
class="item"
|
effect="dark"
|
:content="item.outBatchNo"
|
placement="top"
|
>
|
<span class="inline-el-hidden">{{ item.outBatchNo }}</span>
|
</el-tooltip>
|
</el-col>
|
<el-col :span="2" class="product-out-form-body-col l-mes">
|
<el-input v-model="item.reelNumber"></el-input>
|
</el-col>
|
<el-col :span="2" class="product-out-form-body-col l-mes">
|
<el-input v-model="item.ifsBatchNo" disabled></el-input>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col l-mes">
|
<el-input
|
:disabled="isChangeShift"
|
v-model="item.startMeterMark"
|
></el-input>
|
</el-col>
|
<el-col :span="2" class="product-out-form-body-col l-mes">
|
<el-input v-model="item.endMeterMark"></el-input>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col l-mes">
|
<el-input v-model="item.productQty" disabled></el-input>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col">
|
<span>{{ item.unit }}</span>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col l-mes">
|
<el-input v-model="item.segmentDesc"></el-input>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col l-mes">
|
<el-input v-model="item.scrapQty"></el-input>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col l-mes">
|
<el-input v-model="item.reelWeight"></el-input>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col l-mes">
|
<el-input v-model="item.grossWeight"></el-input>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col l-mes">
|
<el-input v-model="item.remark"></el-input>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col">
|
<el-tooltip
|
class="item"
|
effect="dark"
|
:content="item.staffName"
|
placement="top"
|
>
|
<span class="inline-el-hidden">{{ item.staffName }}</span>
|
</el-tooltip>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col">
|
<el-tooltip
|
class="item"
|
effect="dark"
|
:content="item.date"
|
placement="top"
|
>
|
<span class="inline-el-hidden">{{ item.date }}</span>
|
</el-tooltip>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col">
|
<span>{{ item.status ? '按人员' : '按班次' }}</span>
|
</el-col>
|
<el-col :span="1" class="product-out-form-body-col">
|
<span
|
v-if="item.status && item.dutyRecordId == currentDutyRecord.id"
|
style="cursor: pointer;color: red;"
|
@click="delStaff(index)"
|
>删除</span
|
>
|
</el-col>
|
</el-row>
|
</div>
|
</div>
|
<div slot="footer" class="dialog-footer">
|
<div style="display: inline-block;width: 25%;float: left">
|
<el-button
|
style="margin-right: 34px"
|
type="primary"
|
@click="addProductOutForPerson"
|
>添加</el-button
|
>
|
</div>
|
<el-button @click="innerVisible = false">取 消</el-button>
|
<el-button
|
type="primary"
|
:disabled="saveDisabled"
|
@click="saveProductOuts"
|
>确 定</el-button
|
>
|
</div>
|
</el-dialog>
|
</template>
|
<style>
|
.product-out-form .el-dialog__body {
|
padding-bottom: 0px;
|
}
|
|
.product-out-form .el-dialog__body:after {
|
content: '';
|
clear: both;
|
overflow: hidden;
|
display: block;
|
visibility: hidden;
|
}
|
|
.product-out-form .el-dialog__body .el-table__header th {
|
padding-top: 0px;
|
}
|
|
.product-out-form .el-dialog__body .el-table__body-wrapper {
|
height: 260px;
|
overflow-y: auto;
|
}
|
|
.product-out-form .el-dialog__body .el-table::before {
|
height: 0px;
|
}
|
.product-out-form .el-dialog__body .add-button span {
|
}
|
|
.product-out-form-header-col {
|
text-align: center;
|
color: rgb(144, 147, 153);
|
font-weight: 700;
|
line-height: 23px;
|
font-size: 12px;
|
}
|
|
.product-out-form-body-col {
|
text-align: center;
|
color: rgb(96, 98, 102);
|
font-size: 12px;
|
margin-bottom: 1px;
|
}
|
|
.product-out-form-body-col .el-input {
|
width: 80%;
|
}
|
|
.product-out-form-body-col .el-input input {
|
text-align: center;
|
}
|
|
.product-out-form-body-col span {
|
line-height: 32px;
|
}
|
|
.product-out-form-body-div {
|
height: 260px;
|
overflow-y: auto;
|
}
|
|
.item {
|
margin: 4px;
|
}
|
/*
|
字符串过长时,隐藏显示省略号
|
*/
|
.inline-el-hidden {
|
display: block;
|
width: 93%;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
white-space: nowrap;
|
margin: 0 auto;
|
}
|
</style>
|
<script>
|
import {
|
saveProductOutput,
|
updateProductOutput,
|
getShiftProductOutByOpIdAndWsId
|
} from '@/api/product/personboard'
|
import ElButton from '../../../../node_modules/element-ui/packages/button/src/button.vue'
|
export default {
|
components: { ElButton },
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
productList: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
},
|
parentInfo: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
},
|
currentDutyRecord: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
},
|
personBoardList: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
}
|
},
|
data() {
|
return {
|
innerVisible: false,
|
personSelection: [],
|
saveDisabled: false,
|
currDutyInitproducts: [], // 用于缓存页面中原有的staff产出记录,并且是属于当前班次下的,用于勾选人员时作为原数据参照
|
products: [],
|
clickDateArr: [],
|
isChangeShift: false // 是否是交班新增产出
|
}
|
},
|
methods: {
|
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
|
}
|
}
|
},
|
setOutBatchNo(val) {
|
this.products.forEach(function(el) {
|
el.outBatchNo = val
|
})
|
},
|
// 选中人员,人员变动时,去更新products
|
productOutPersonSelectionChange(val) {
|
// 已选中人员集合val为准,去currDutyInitproducts寻找相同人员(且同班次、按人员,已进行过滤)的信息,若currDutyInitproducts中不存在,则自行组装信息。选中人员信息组合完毕后,
|
// 再去与products(此为页面的实时数据,用户有改动即更新)对比,将其中存在的相同人员的生产数量和生产批次同步过来,若products中生产数量或生产批次不存在值,则不进行同步,沿用原来的。
|
// 最后,将组装好的选中人员信息,更新到products(按照班次进行),注意更新之后选中人员信息在products位置顺序
|
this.personSelection = val
|
},
|
// 根据选中的人员,生成人员产出信息,并且放在右边列表的最前面
|
addProductOutForPerson() {
|
if (this.personSelection != null && this.personSelection.length > 0) {
|
// 理论上来说,products的长度肯定大于0
|
var productCopyList = this.products
|
this.products = []
|
// 获取第一条的生产批次,用于继承
|
var oriOutBatchNo = ''
|
if (productCopyList != null && productCopyList.length > 0) {
|
oriOutBatchNo = productCopyList[0].outBatchNo
|
}
|
// 获取第一条的IFS批次,用于继承
|
var oriIfsBatchNo = ''
|
if (productCopyList != null && productCopyList.length > 0) {
|
oriIfsBatchNo = productCopyList[0].ifsBatchNo
|
}
|
var newProduct
|
for (var i = 0; i < this.personSelection.length; i++) {
|
newProduct = {}
|
var productStaffs = []
|
var productStaffIds = []
|
productStaffIds.push(this.personSelection[i].staffId)
|
productStaffs.push(this.personSelection[i].staffNo)
|
newProduct.staffName = this.personSelection[i].staffName
|
newProduct.staffNo = this.personSelection[i].staffNo
|
newProduct.productNo = this.parentInfo.currProductMainNo
|
newProduct.partId = this.parentInfo.partId
|
newProduct.partNo = this.parentInfo.partNo
|
newProduct.partName = this.parentInfo.partName
|
newProduct.outBatchNo = oriOutBatchNo
|
newProduct.reelNumber = null
|
newProduct.productQty = 0
|
newProduct.ifsBatchNo = oriIfsBatchNo
|
newProduct.unit = this.parentInfo.unit
|
newProduct.productStaffs = productStaffs
|
newProduct.productStaffIds = productStaffIds
|
newProduct.status = true
|
newProduct.systemNo = null
|
newProduct.date = null
|
newProduct.dutyRecordId = this.currentDutyRecord.id
|
|
newProduct.scrapQty = null
|
newProduct.segmentDesc = null
|
newProduct.remark = null
|
|
newProduct.sproductQty = 0
|
|
newProduct.reelWeight = null
|
newProduct.grossWeight = null
|
|
this.products.push(newProduct)
|
}
|
if (productCopyList != null && productCopyList.length > 0) {
|
for (var i = 0; i < productCopyList.length; i++) {
|
this.products.push(productCopyList[i])
|
}
|
}
|
} else {
|
this.$message.warning('若想添加产出,请先选中人员!')
|
}
|
},
|
delStaff(index) {
|
this.products.splice(index, 1)
|
this.$message.success('删除成功')
|
},
|
saveProductOuts() {
|
var canClickFlag = true
|
this.clickDateArr.push(new Date().getTime())
|
if (this.clickDateArr.length > 1) {
|
if (
|
this.clickDateArr[this.clickDateArr.length - 1] -
|
this.clickDateArr[this.clickDateArr.length - 2] <
|
2000
|
) {
|
// 小于2秒则认为重复提交
|
canClickFlag = false
|
}
|
}
|
|
if (canClickFlag) {
|
this.saveDisabled = true
|
if (this.products != null && this.products.length > 0) {
|
// 校验生产批次、生产数量
|
var validateMsg = ''
|
var validateFlag = true
|
for (var i = 0; i < this.products.length; i++) {
|
// 批次校验
|
/* if (
|
this.products[i].outBatchNo == null ||
|
this.products[i].outBatchNo == ''
|
) {
|
validateFlag = false
|
validateMsg = '第' + (i + 1) + '行,【生产批次】格式填写有误!'
|
break
|
} */
|
// 生产数量校验
|
/* if (!this.isNumber(this.products[i].productQty)) {
|
validateFlag = false
|
validateMsg =
|
'第' + (i + 1) + '行,【生产数量】请输入非负数,小数位最多4位!'
|
break
|
} */
|
// 起始米标校验
|
if (!this.isNumber(this.products[i].startMeterMark)) {
|
validateFlag = false
|
validateMsg =
|
'第' + (i + 1) + '行,【起始米标】请输入非负数,小数位最多4位!'
|
break
|
}
|
// 截止米标校验
|
if (!this.isNumber(this.products[i].endMeterMark)) {
|
validateFlag = false
|
validateMsg =
|
'第' + (i + 1) + '行,【截止米标】请输入非负数,小数位最多4位!'
|
break
|
}
|
// 截止米标需大于开始米标
|
if (
|
Number(this.products[i].endMeterMark) <
|
Number(this.products[i].startMeterMark)
|
) {
|
validateFlag = false
|
validateMsg =
|
'第' + (i + 1) + '行,【截止米标】需大于【起始米标】'
|
break
|
}
|
}
|
if (validateFlag) {
|
if (this.parentInfo.productOutId == null) {
|
// 当前是产出的新增
|
var productVo = {}
|
productVo.isChangeShift = this.isChangeShift
|
productVo.id = this.parentInfo.currProductMainId
|
productVo.workstationId = this.parentInfo.workstationId
|
productVo.operationTaskId = this.parentInfo.operationTaskId
|
var productOuts = []
|
var productOut
|
for (var i = 0; i < this.products.length; i++) {
|
productOut = {}
|
productOut.workstationId = this.parentInfo.workstationId
|
productOut.operationTaskId = this.parentInfo.operationTaskId
|
productOut.partId = this.products[i].partId
|
productOut.startMeterMark = this.products[i].startMeterMark
|
productOut.endMeterMark = this.products[i].endMeterMark
|
productOut.productQty = (
|
Number(this.products[i].endMeterMark) -
|
Number(this.products[i].startMeterMark)
|
).toFixed(4)
|
productOut.productStaffs = this.products[i].productStaffs
|
productOut.productStaffIds = this.products[i].productStaffIds
|
productOut.outBatchNo = this.products[i].outBatchNo
|
productOut.reelNumber = this.products[i].reelNumber
|
productOut.status = this.products[i].status
|
productOut.dutyRecordId = this.products[i].dutyRecordId
|
productOut.ifsBatchNo = this.products[i].ifsBatchNo
|
|
productOut.scrapQty = this.products[i].scrapQty
|
productOut.segmentDesc = this.products[i].segmentDesc
|
productOut.remark = this.products[i].remark
|
|
productOut.sproductQty = this.products[i].sproductQty
|
|
productOut.reelWeight = this.products[i].reelWeight
|
productOut.grossWeight = this.products[i].grossWeight
|
productOut.unit = this.products[i].unit
|
|
productOuts.push(productOut)
|
}
|
productVo.productOutputList = productOuts
|
console.log('dasdad', productVo)
|
saveProductOutput(productVo)
|
.then((response) => {
|
var data = response.data
|
if (data.code == 0) {
|
// 返回报工主表id,用于刷新页面
|
var productMainId = data.data
|
this.$message.success('新增成功')
|
this.$emit('refreshProductOutputList', productMainId)
|
this.innerVisible = false
|
} else {
|
this.$message.error('新增失败')
|
}
|
this.saveDisabled = false
|
})
|
.catch((error) => {
|
console.log('失败' + new Date().getTime())
|
this.saveDisabled = false
|
})
|
} else {
|
// 当前是产出的修改更新
|
var productVo = {}
|
var productOuts = []
|
var productOut
|
for (var i = 0; i < this.products.length; i++) {
|
productOut = {}
|
productOut.id = this.parentInfo.productOutId
|
productOut.outBatchNo = this.products[i].outBatchNo
|
productOut.reelNumber = this.products[i].reelNumber
|
productOut.systemNo = this.products[i].systemNo
|
productOut.date = this.products[i].date
|
productOut.startMeterMark = this.products[i].startMeterMark
|
productOut.endMeterMark = this.products[i].endMeterMark
|
productOut.productQty = (
|
Number(this.products[i].endMeterMark) -
|
Number(this.products[i].startMeterMark)
|
).toFixed(4)
|
productOut.productStaffs = this.products[i].productStaffs
|
productOut.productStaffIds = this.products[i].productStaffIds
|
productOut.status = this.products[i].status
|
productOut.dutyRecordId = this.products[i].dutyRecordId
|
productOut.ifsBatchNo = this.products[i].ifsBatchNo
|
productOut.scrapQty = this.products[i].scrapQty
|
productOut.segmentDesc = this.products[i].segmentDesc
|
productOut.remark = this.products[i].remark
|
productOut.sproductQty = this.products[i].sproductQty
|
productOut.reelWeight = this.products[i].reelWeight
|
productOut.grossWeight = this.products[i].grossWeight
|
productOut.unit = this.products[i].unit
|
productOuts.push(productOut)
|
}
|
productVo.productOutputList = productOuts
|
|
updateProductOutput(productVo)
|
.then((response) => {
|
var data = response.data
|
if (data.code == 0) {
|
this.$message.success('更新产出成功')
|
this.$emit(
|
'refreshProductOutputList',
|
this.parentInfo.currProductMainId
|
)
|
this.innerVisible = false
|
} else {
|
this.$message.error('更新产出失败')
|
}
|
this.saveDisabled = false
|
})
|
.catch((error) => {
|
this.saveDisabled = false
|
})
|
}
|
} else {
|
this.$message.error(validateMsg)
|
this.saveDisabled = false
|
}
|
} else {
|
this.$message.warning('无产出数据可提交!')
|
this.saveDisabled = false
|
}
|
}
|
}
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
if (this.currshowlist) {
|
this.clickDateArr = []
|
this.products = []
|
this.isChangeShift = false
|
if (this.parentInfo.productOutId == null) {
|
// 若是新增时,根据工单、机台去查询当前工单机台下未完成的产出,即存在交接,并且未做完的盘
|
getShiftProductOutByOpIdAndWsId(
|
this.parentInfo.workstationId,
|
this.parentInfo.operationTaskId
|
).then((response) => {
|
var data = response.data
|
if (data.code === 0) {
|
if (data.data != null) {
|
// 是交班的新增
|
const lastShiftProductOut = data.data
|
for (let i = 0; i < this.productList.length; i++) {
|
if (
|
this.currentDutyRecord.id !==
|
lastShiftProductOut.dutyRecordId
|
) {
|
this.productList[i].outBatchNo =
|
lastShiftProductOut.outBatchNo
|
this.productList[i].startMeterMark =
|
lastShiftProductOut.endMeterMark
|
this.productList[i].endMeterMark =
|
lastShiftProductOut.endMeterMark
|
this.productList[i].ifsBatchNo =
|
lastShiftProductOut.ifsBatchNo
|
this.isChangeShift = true
|
}
|
|
this.products.push(this.productList[i])
|
}
|
this.$nextTick(() => {
|
this.$refs.productOutPersonList.clearSelection()
|
})
|
if (!this.isChangeShift) {
|
this.innerVisible = false
|
this.$message.error('工单下的报告,无需交班')
|
}
|
} else {
|
/* for (let i = 0; i < this.productList.length; i++) {
|
this.products.push(this.productList[i])
|
}
|
this.$nextTick(() => {
|
this.$refs.productOutPersonList.clearSelection()
|
}) */
|
this.innerVisible = false
|
this.$message.error('工单下的报告,无需交班')
|
}
|
}
|
})
|
} else {
|
for (let i = 0; i < this.productList.length; i++) {
|
this.products.push(this.productList[i])
|
}
|
this.$nextTick(() => {
|
this.$refs.productOutPersonList.clearSelection()
|
})
|
}
|
}
|
}
|
}
|
}
|
</script>
|