<!--
|
* @Descripttion: 新报工查看投入
|
* @version:
|
* @Author: zt_lc
|
* @Date: 2022-06-10 09:24:05
|
* @LastEditors: zt_lc
|
* @LastEditTime: 2022-06-10 10:30:42
|
-->
|
|
<template>
|
<el-dialog
|
title="投料查看"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<div class="work-report-product-in-header">
|
<div></div>
|
<div>
|
<el-button
|
class="in-btn"
|
type="primary"
|
@click="openProductInDialog()"
|
v-if="canEdit"
|
>投入</el-button
|
>
|
</div>
|
</div>
|
<el-table
|
ref="productInTable"
|
:data="productInputList"
|
height="320px"
|
:header-cell-style="productInTableHeaderCellStyle"
|
:row-class-name="productInTableRowClassName"
|
class="tracking-table"
|
>
|
<el-table-column label="报工单号" prop="productNo" align="center">
|
</el-table-column>
|
<el-table-column
|
label="SN号"
|
prop="partBatchNo"
|
align="center"
|
:show-overflow-tooltip="true"
|
>
|
</el-table-column>
|
<el-table-column
|
label="零件编号"
|
prop="partNo"
|
align="center"
|
:show-overflow-tooltip="true"
|
>
|
</el-table-column>
|
<el-table-column
|
label="零件名称"
|
prop="partName"
|
align="center"
|
:show-overflow-tooltip="true"
|
>
|
</el-table-column>
|
<el-table-column
|
label="IFS批次号"
|
prop="ifsBatchNo"
|
align="center"
|
:show-overflow-tooltip="true"
|
>
|
</el-table-column>
|
<el-table-column
|
label="投入数量"
|
prop="inputQuantity"
|
align="center"
|
width="100"
|
>
|
<template scope="scope">
|
<el-input
|
size="small"
|
v-model="scope.row.inputQuantity"
|
placeholder="投入数量"
|
:disabled="!canEdit"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="可用数量"
|
prop="availableStockQuantity"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column label="单位" prop="unit" align="center">
|
</el-table-column>
|
<el-table-column align="center" width="120px" fixed="right">
|
<template slot-scope="scope">
|
<el-tooltip
|
effect="dark"
|
content="全投"
|
placement="top-start"
|
v-if="canEdit"
|
>
|
<el-button
|
type="text"
|
size="small"
|
@click="allIn(scope.$index, scope.row)"
|
>全投</el-button
|
>
|
</el-tooltip>
|
<el-tooltip
|
effect="dark"
|
content="保存"
|
placement="top-start"
|
v-if="canEdit"
|
>
|
<el-button
|
type="text"
|
size="small"
|
@click="addOrUpdateProductIn(scope.row)"
|
>保存</el-button
|
>
|
</el-tooltip>
|
<el-tooltip
|
effect="dark"
|
content="删除"
|
placement="top-start"
|
v-if="canEdit"
|
>
|
<el-button
|
type="text"
|
size="small"
|
class="red-but"
|
@click="delProductIn(scope.$index, scope.row)"
|
>删除</el-button
|
>
|
</el-tooltip>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
</span>
|
<productInDialog
|
:currshowlist.sync="showProductInDialog"
|
:workstationId="workstationId"
|
@handleSelectionChange="selectWorkstationFeed"
|
/>
|
</el-dialog>
|
</template>
|
|
<script>
|
import {
|
queryProductMainDetail,
|
deleteProductInputById,
|
updateProductInput,
|
saveProductInput
|
} from '@/api/product/personboard'
|
import productInDialog from './productInDialog.vue'
|
export default {
|
components: {
|
productInDialog
|
},
|
data() {
|
return {
|
queryId: '',
|
visible: false,
|
productInputList: [],
|
showProductInDialog: false,
|
workstationId: null,
|
productMainId: null,
|
productNo: null,
|
canEdit: true
|
}
|
},
|
methods: {
|
init(id, workstationId, productMainId, productNo, state, shiftState) {
|
this.queryId = id
|
this.queryProductMainDetail(id)
|
this.visible = true
|
this.workstationId = workstationId
|
this.productMainId = productMainId
|
this.productNo = productNo
|
if (
|
state != null &&
|
state != '' &&
|
state == '01draft' &&
|
!(
|
shiftState != null &&
|
shiftState != '' &&
|
shiftState == '03changeshift'
|
)
|
) {
|
this.canEdit = true
|
} else {
|
this.canEdit = false
|
}
|
},
|
productInTableHeaderCellStyle({ row, column, rowIndex, columnIndex }) {
|
let headerStyle = 'background:#599ef4;color:#fff;'
|
if (columnIndex === 0) {
|
headerStyle += 'border-radius: 6px 0px 0px 0px;'
|
} else if (columnIndex === 9) {
|
headerStyle += 'border-radius: 0px 6px 0px 0px;'
|
}
|
return headerStyle
|
},
|
productInTableRowClassName({ row, rowIndex }) {
|
if (rowIndex % 2 === 1) {
|
return 'stripe-row'
|
} else {
|
return ''
|
}
|
},
|
// 根据报工主表id获取投入、产出明细
|
queryProductMainDetail(id) {
|
return new Promise((resolve, reject) => {
|
this.productInputList = []
|
queryProductMainDetail(id)
|
.then((response) => {
|
var code = response.data.code
|
if (code == 0) {
|
var productMainInfo = response.data.data
|
const productInputs = productMainInfo.productInputList
|
if (productInputs != null && productInputs.length > 0) {
|
productInputs.forEach((item) => {
|
if (item.availableStockQuantity == null) {
|
item.availableStockQuantity = 0
|
}
|
})
|
}
|
this.productInputList = productInputs
|
resolve()
|
} else {
|
this.$message.error('获取投入产出明细失败')
|
reject()
|
}
|
})
|
.catch((error) => {
|
reject()
|
})
|
})
|
},
|
// 弹出投料列表,供报工投入使用
|
openProductInDialog() {
|
if (this.productMainId != null && this.productMainId != '') {
|
this.showProductInDialog = true
|
} else {
|
this.$message.warning('请先选择报告或者先填写产出!')
|
}
|
},
|
// 选中需要的投料
|
selectWorkstationFeed(val) {
|
if (val != null && val.length > 0) {
|
for (var i = 0; i < val.length; i++) {
|
this.addProductIn(val[i])
|
}
|
}
|
this.showProductInDialog = false
|
},
|
// 页面新增投入
|
addProductIn(inPartInfo) {
|
var productInput = {}
|
productInput.id = null
|
productInput.stockId = inPartInfo.id
|
productInput.inputQuantity = null
|
productInput.productMainId = this.productMainId
|
productInput.productNo = this.productNo
|
productInput.partNo = inPartInfo.partNo
|
productInput.partName = inPartInfo.partName
|
productInput.partDescription = null
|
productInput.unit = inPartInfo.unit
|
productInput.partBatchNo = inPartInfo.partBatchNo
|
productInput.ifsBatchNo = inPartInfo.ifsBatchNo
|
productInput.availableStockQuantity = inPartInfo.availableStockQuantity
|
this.productInputList.push(productInput)
|
},
|
// 新增或更新投入信息,若存在id则更新、不存在则新增
|
addOrUpdateProductIn(currRow) {
|
if (currRow.inputQuantity != null && currRow.inputQuantity.trim != '') {
|
if (currRow.id != null) {
|
// 修改
|
const productIn = {}
|
productIn.id = currRow.id
|
productIn.inputQuantity = currRow.inputQuantity
|
updateProductInput(productIn)
|
.then((response) => {
|
var data = response.data
|
if (data.code == 0) {
|
this.$message.success('更新投入成功')
|
// 刷新投料信息
|
this.$emit('refreshFeedsForDel')
|
} else {
|
this.$message.error('更新投入失败')
|
}
|
})
|
.catch((error) => {})
|
} else {
|
// 新增
|
const productIn = {}
|
productIn.stockId = currRow.stockId
|
productIn.productMainId = currRow.productMainId
|
productIn.inputQuantity = currRow.inputQuantity
|
saveProductInput(productIn)
|
.then((response) => {
|
var data = response.data
|
if (data.code == 0) {
|
this.$message.success('添加投入成功')
|
this.queryProductMainDetail(this.queryId)
|
// currRow.id = data.data
|
// 刷新投料信息
|
this.$emit('refreshFeedsForDel')
|
} else {
|
this.$message.error('添加投入失败')
|
}
|
})
|
.catch((error) => {})
|
}
|
} else {
|
this.$message.error('投入不能为空')
|
}
|
},
|
// 删除投入信息,若存在投入id,则需调用后台删除并删除前端投入,若不存在,则只需删除前端投入
|
delProductIn(index, currRow) {
|
if (currRow.id != null) {
|
// 则需调用后台删除并删除前端投入
|
deleteProductInputById(currRow.id)
|
.then((response) => {
|
var data = response.data
|
if (data.code == 0) {
|
this.productInputList.splice(index, 1)
|
this.$message.success('删除投入成功')
|
// 刷新投料信息
|
this.$emit('refreshFeedsForDel')
|
} else {
|
this.$message.error('删除投入失败')
|
}
|
})
|
.catch((error) => {})
|
} else {
|
// 删除前端投入
|
this.productInputList.splice(index, 1)
|
this.$message.success('删除投入成功')
|
}
|
},
|
// 全投
|
allIn(index, currRow) {
|
if (currRow.inputQuantity != null && currRow.inputQuantity != '') {
|
currRow.inputQuantity =
|
currRow.inputQuantity + currRow.availableStockQuantity
|
currRow.inputQuantity = Number(currRow.inputQuantity.toFixed(6))
|
currRow.availableStockQuantity = 0
|
} else {
|
currRow.inputQuantity = currRow.availableStockQuantity
|
currRow.availableStockQuantity = 0
|
}
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.work-report-product-in-header {
|
margin-top: 10px;
|
margin-bottom: 14px;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
.red-but.is-disabled {
|
color: #fab6b6;
|
}
|
|
.red-but {
|
color: red;
|
}
|
</style>
|