<template>
|
<el-dialog
|
width="80%"
|
title="车间订单发料"
|
top="5vh"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
class="part-dialog"
|
:close-on-click-modal="false"
|
>
|
<el-tabs v-model="activeName" type="border-card">
|
<el-tab-pane label="MES库存" name="MES">
|
<div style="display:flex;justify-content:flex-start;margin-bottom:5px;">
|
<div style="display:flex;">
|
<div style="width:60px;line-height:32px;">wdr:</div>
|
<el-input
|
v-model="wdrNo"
|
placeholder="wdr"
|
clearable
|
@keyup.enter.native="queryMesStock"
|
></el-input>
|
</div>
|
<div style="display:flex;margin-left:10px;">
|
<div style="width:80px;line-height:32px;">批次号:</div>
|
<el-input
|
v-model="lotBatchNo"
|
placeholder="批次号"
|
clearable
|
></el-input>
|
</div>
|
<div style="margin-left:10px;">
|
<el-button type="primary" @click="queryMesStock">查询</el-button>
|
</div>
|
<div style="margin-left:10px;line-height:32px;">
|
<span style="color:red;">合计数量:</span
|
><span style="color:green;">{{ selectTotalNumber }}</span>
|
</div>
|
</div>
|
<el-table
|
class="mes-stock-table"
|
:data="mesStockData"
|
style="width: 100%;"
|
height="450px"
|
border
|
stripe
|
ref="mesStockTable"
|
@selection-change="mesStockSelectionChange"
|
@row-click="clickMesStock"
|
>
|
<el-table-column type="selection" width="55"> </el-table-column>
|
<el-table-column type="index" width="50" label="序号" align="center">
|
</el-table-column>
|
<el-table-column
|
prop="partNo"
|
label="零件号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partName"
|
label="零件描述"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="batchNo"
|
label="批次号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="warehouseName"
|
label="仓库"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="locNo"
|
label="库位号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="wdr"
|
label="WDR"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="availableQuantity"
|
label="可用库存数量"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="issuedQuantity"
|
label="下发数量"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.issuedQuantity"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="unit"
|
label="单位"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
</el-table>
|
</el-tab-pane>
|
<el-tab-pane label="IFS库存" name="IFS">
|
<el-table
|
class="ifs-stock-table"
|
:data="ifsStockData"
|
style="width: 100%;"
|
height="450px"
|
border
|
stripe
|
ref="ifsStockTable"
|
@selection-change="ifsStockSelectionChange"
|
@row-click="clickIfsStock"
|
>
|
<el-table-column type="selection" width="55"> </el-table-column>
|
<el-table-column type="index" width="50" label="序号" align="center">
|
</el-table-column>
|
<el-table-column
|
prop="partNo"
|
label="零件号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partName"
|
label="零件描述"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="batchNo"
|
label="批次号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="warehouseName"
|
label="仓库"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="locNo"
|
label="库位号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="wdr"
|
label="WDR"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="availableQuantity"
|
label="可用库存数量"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="issuedQuantity"
|
label="下发数量"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.issuedQuantity"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="unit"
|
label="单位"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
</el-table>
|
</el-tab-pane>
|
</el-tabs>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="innerVisible = false">取 消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`saveSelectRow`"
|
>确 定</el-button
|
>
|
</div>
|
</el-dialog>
|
</template>
|
<script>
|
import {
|
getMatIssueFromStock,
|
getMatIssueFromIfs,
|
addMatIssue
|
} from '@/api/plan/issuematerial'
|
import { KeyCode } from 'monaco-editor'
|
export default {
|
components: {},
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
issueOrder: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
}
|
},
|
data() {
|
return {
|
innerVisible: false,
|
isSubmit: false,
|
activeName: 'MES',
|
mesStockData: [],
|
ifsStockData: [],
|
mesSelection: [],
|
ifsSelection: [],
|
wdrNo: null,
|
lotBatchNo: null,
|
selectTotalNumber: 0
|
}
|
},
|
methods: {
|
queryMesStock() {
|
const mesQueryParam = {
|
wdrNo: this.wdrNo,
|
lotBatchNo: this.lotBatchNo
|
}
|
this.mesStockData = []
|
getMatIssueFromStock(this.issueOrder.id, mesQueryParam).then(
|
(response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
const mesStocks = resData.data
|
mesStocks.forEach((item) => {
|
this.mesStockData.push({
|
wdr: item.wdrNo,
|
locNo: item.locationNo,
|
warehouseName: item.warehouse,
|
batchNo: item.lotBatchNo,
|
partNo: item.partNo,
|
partName: item.partName,
|
availableQuantity: item.qtyRequired,
|
issuedQuantity: item.qtyRequired,
|
unit: item.unit,
|
stockId: item.stockId,
|
matFrom: item.matFrom,
|
ifsLineItemNo: item.ifsLineItemNo,
|
serialNo: item.serialNo,
|
engChgLevel: item.engChgLevel
|
})
|
})
|
}
|
}
|
)
|
},
|
mesStockSelectionChange(val) {
|
this.mesSelection = val
|
this.selectTotalNumber = 0
|
this.mesSelection.forEach((item) => {
|
if (item.issuedQuantity != null && item.issuedQuantity != '') {
|
this.selectTotalNumber = Number(
|
(this.selectTotalNumber + Number(item.issuedQuantity)).toFixed(6)
|
)
|
}
|
})
|
},
|
clickMesStock(row) {
|
this.$refs.mesStockTable.toggleRowSelection(row)
|
},
|
ifsStockSelectionChange(val) {
|
this.ifsSelection = val
|
},
|
clickIfsStock(row) {
|
this.$refs.ifsStockTable.toggleRowSelection(row)
|
},
|
blurChangeCallback(row, tabName) {
|
if (tabName === 'MES') {
|
this.checkMesQuality()
|
} else {
|
this.checkIfsQuality()
|
}
|
},
|
checkMesQuality() {
|
let flag = true
|
let flagMsg = '【MES库存】 -- '
|
for (let i = 0; i < this.mesSelection.length; i++) {
|
const k = this.mesStockData.findIndex(
|
(item) => item === this.mesSelection[i]
|
)
|
if (
|
this.mesSelection[i].issuedQuantity == null ||
|
this.mesSelection[i].issuedQuantity == ''
|
) {
|
flag = false
|
flagMsg = flagMsg + '第' + (k + 1) + '行,下发数量不能为空;'
|
} else {
|
if (!this.checkZero(this.mesSelection[i].issuedQuantity)) {
|
flag = false
|
flagMsg = flagMsg + '第' + (k + 1) + '行,下发数量不能为0;'
|
} else {
|
if (!this.checkPositive(this.mesSelection[i].issuedQuantity)) {
|
flag = false
|
flagMsg = flagMsg + '第' + (k + 1) + '行,下发数量需为正数;'
|
} else {
|
if (!this.checkDecimal(this.mesSelection[i].issuedQuantity)) {
|
flag = false
|
flagMsg =
|
flagMsg + '第' + (k + 1) + '行,下发数量最多六位小数;'
|
}
|
}
|
}
|
}
|
}
|
if (!flag) {
|
this.$message.error(flagMsg)
|
}
|
return flag
|
},
|
checkIfsQuality() {
|
let flag = true
|
let flagMsg = '【IFS库存】 -- '
|
for (let i = 0; i < this.ifsSelection.length; i++) {
|
const k = this.ifsStockData.findIndex(
|
(item) => item === this.ifsSelection[i]
|
)
|
if (
|
this.ifsSelection[i].issuedQuantity == null ||
|
this.ifsSelection[i].issuedQuantity == ''
|
) {
|
flag = false
|
flagMsg = flagMsg + '第' + (k + 1) + '行,下发数量不能为空;'
|
} else {
|
if (!this.checkZero(this.ifsSelection[i].issuedQuantity)) {
|
flag = false
|
flagMsg = flagMsg + '第' + (KeyCode + 1) + '行,下发数量不能为0;'
|
} else {
|
if (!this.checkPositive(this.ifsSelection[i].issuedQuantity)) {
|
flag = false
|
flagMsg = flagMsg + '第' + (k + 1) + '行,下发数量需为正数;'
|
} else {
|
if (!this.checkDecimal(this.ifsSelection[i].issuedQuantity)) {
|
flag = false
|
flagMsg =
|
flagMsg + '第' + (k + 1) + '行,下发数量最多六位小数;'
|
}
|
}
|
}
|
}
|
}
|
if (!flag) {
|
this.$message.error(flagMsg)
|
}
|
return flag
|
},
|
checkZero(value) {
|
if (value == 0) {
|
return false
|
} else {
|
return true
|
}
|
},
|
checkPositive(value) {
|
if (!/^[0-9]+.?[0-9]*$/.test(value)) {
|
return false
|
} else {
|
return true
|
}
|
},
|
checkDecimal(value) {
|
if (
|
!/(^[1-9]([0-9]+)?(\.[0-9]{1,6})?$)|(^(0){1}$)|(^[0-9]\.[0-9]{1,6}$)/.test(
|
value
|
)
|
) {
|
return false
|
} else {
|
return true
|
}
|
},
|
saveSelectRow() {
|
this.isSubmit = true
|
let flag
|
if (this.activeName === 'MES') {
|
flag = this.checkMesQuality()
|
} else {
|
flag = this.checkIfsQuality()
|
}
|
if (flag) {
|
// TODO
|
const matIssueList = []
|
if (this.activeName === 'MES') {
|
this.mesSelection.forEach((item) => {
|
matIssueList.push({
|
moId: this.issueOrder.id,
|
partNo: item.partNo,
|
partName: item.partName,
|
unit: item.unit,
|
warehouse: item.warehouseName,
|
lotBatchNo: item.batchNo,
|
locationNo: item.locNo,
|
wdrNo: item.wdr,
|
qtyIssue: item.issuedQuantity,
|
stockId: item.stockId,
|
matFrom: 'MES',
|
ifsLineItemNo: item.ifsLineItemNo,
|
serialNo: item.serialNo,
|
engChgLevel: item.engChgLevel
|
})
|
})
|
} else {
|
this.ifsSelection.forEach((item) => {
|
matIssueList.push({
|
moId: this.issueOrder.id,
|
partNo: item.partNo,
|
partName: item.partName,
|
unit: item.unit,
|
warehouse: item.warehouseName,
|
lotBatchNo: item.batchNo,
|
locationNo: item.locNo,
|
wdrNo: item.wdr,
|
qtyIssue: item.issuedQuantity,
|
stockId: item.stockId,
|
matFrom: 'IFS',
|
ifsLineItemNo: item.ifsLineItemNo,
|
serialNo: item.serialNo,
|
engChgLevel: item.engChgLevel
|
})
|
})
|
}
|
// addMatIssue
|
if (matIssueList.length > 0) {
|
addMatIssue(matIssueList, this.issueOrder.id)
|
.then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
this.innerVisible = false
|
this.$message.success('发料成功!')
|
} else {
|
this.$message.error('发料失败!')
|
}
|
this.isSubmit = false
|
})
|
.catch(() => {
|
this.isSubmit = false
|
})
|
} else {
|
this.$message.error('请选择需发料的库存!')
|
this.isSubmit = false
|
}
|
} else {
|
this.isSubmit = false
|
}
|
},
|
initData() {
|
this.wdrNo = null
|
this.lotBatchNo = null
|
}
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
if (this.currshowlist) {
|
this.initData()
|
this.mesStockData = []
|
this.ifsStockData = []
|
this.$nextTick(() => {
|
const mesQueryParam = {
|
wdrNo: null,
|
lotBatchNo: null
|
}
|
getMatIssueFromStock(this.issueOrder.id, mesQueryParam).then(
|
(response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
const mesStocks = resData.data
|
mesStocks.forEach((item) => {
|
this.mesStockData.push({
|
wdr: item.wdrNo,
|
locNo: item.locationNo,
|
warehouseName: item.warehouse,
|
batchNo: item.lotBatchNo,
|
partNo: item.partNo,
|
partName: item.partName,
|
availableQuantity: item.qtyRequired,
|
issuedQuantity: item.qtyRequired,
|
unit: item.unit,
|
stockId: item.stockId,
|
matFrom: item.matFrom,
|
ifsLineItemNo: item.ifsLineItemNo,
|
serialNo: item.serialNo,
|
engChgLevel: item.engChgLevel
|
})
|
})
|
}
|
}
|
)
|
getMatIssueFromIfs(this.issueOrder.id).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
const ifsStocks = resData.data
|
ifsStocks.forEach((item) => {
|
this.ifsStockData.push({
|
wdr: item.wdrNo,
|
locNo: item.locationNo,
|
warehouseName: item.warehouse,
|
batchNo: item.lotBatchNo,
|
partNo: item.partNo,
|
partName: item.partName,
|
availableQuantity: item.qtyRequired,
|
issuedQuantity: item.qtyRequired,
|
unit: item.unit,
|
matFrom: item.matFrom,
|
ifsLineItemNo: item.ifsLineItemNo,
|
serialNo: item.serialNo,
|
engChgLevel: item.engChgLevel
|
})
|
})
|
}
|
})
|
})
|
}
|
}
|
}
|
}
|
</script>
|
<style>
|
.part-dialog .el-dialog__header {
|
padding: 10px 20px 10px;
|
}
|
.part-dialog .el-dialog__header .el-dialog__headerbtn {
|
top: 10px;
|
}
|
.part-dialog .el-dialog__body {
|
padding: 5px 20px;
|
}
|
|
.part-dialog .el-dialog__footer {
|
padding: 5px 20px 10px;
|
}
|
|
.part-dialog .el-dialog__body .avue-crud__pagination {
|
margin-top: 0px;
|
margin-bottom: 5px;
|
}
|
</style>
|