<template>
|
<el-dialog
|
width="40%"
|
title="投料"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
>
|
<div class="app-container">
|
<div class="avue-crud">
|
<el-table
|
v-loading="listLoading"
|
:key="tableKey"
|
:data="dataList"
|
border
|
style="width: 100%;"
|
@cell-dblclick="dblhandleCurrentChange"
|
>
|
<el-table-column
|
prop="partNo"
|
header-align="center"
|
align="center"
|
label="零件编号"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partName"
|
header-align="center"
|
align="center"
|
label="零件"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partBatchNo"
|
header-align="center"
|
align="center"
|
label="零件批号"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="suppliedQuantity"
|
header-align="center"
|
align="center"
|
label="投入数量"
|
>
|
<template scope="scope">
|
<el-input
|
size="small"
|
v-model="scope.row.suppliedQuantity"
|
placeholder="请输入数量"
|
@blur="inputblur"
|
v-focus
|
clearable
|
></el-input>
|
<!--<span v-if="!scope.row.suppliedQuantityFlag">{{scope.row.suppliedQuantity}}</span>-->
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="unit"
|
header-align="center"
|
align="center"
|
label="单位"
|
>
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="innerVisible = false">取 消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`saveReserveFeed`"
|
>投 料</el-button
|
>
|
</div>
|
</el-dialog>
|
</template>
|
<script>
|
import { addFeed } from '@/api/product/personboard'
|
import { fetchList } from '@/api/warehouse/joinstockorder'
|
export default {
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
dataList: {
|
type: Array
|
},
|
isErp: {
|
type: Boolean,
|
default: false
|
},
|
workstationId: {
|
type: Number
|
},
|
operationTaskId: {
|
type: Number
|
},
|
partInfo: {}
|
},
|
data() {
|
return {
|
innerVisible: false,
|
listLoading: false,
|
tableKey: 0,
|
isSubmit: false
|
}
|
},
|
directives: {
|
focus: {
|
inserted: function(el, option) {
|
var defClass = 'el-input'
|
var defTag = 'input'
|
var value = option.value || true
|
if (typeof value === 'boolean')
|
value = { cls: defClass, tag: defTag, foc: value }
|
else
|
value = {
|
cls: value.cls || defClass,
|
tag: value.tag || defTag,
|
foc: value.foc || false
|
}
|
// if (el.classList.contains(value.cls) && value.foc)
|
el.getElementsByTagName(value.tag)[0].focus()
|
}
|
}
|
},
|
methods: {
|
dblhandleCurrentChange(row, column, cell, event) {
|
switch (column.label) {
|
case '投入数量':
|
this.$set(row, 'suppliedQuantityFlag', true)
|
break
|
}
|
},
|
inputblur(row, event, column, cell) {
|
const _that = this
|
const tableD = _that.dataList
|
tableD.forEach(function(item) {
|
_that.$set(item, 'suppliedQuantityFlag', false)
|
})
|
},
|
async saveReserveFeed() {
|
this.isSubmit = true
|
// 调用投料接口,然后刷新线边仓、投料列表、预留物料
|
const feeds = []
|
let feed
|
for (let i = 0; i < this.dataList.length; i++) {
|
if (!this.dataList[i].suppliedQuantity) {
|
this.isSubmit = false
|
this.$message.error('第' + (i + 1) + '投入数量不能为空')
|
return
|
}
|
if (!this.checkDecimal(this.dataList[i].suppliedQuantity)) {
|
this.isSubmit = false
|
this.$message.error(
|
'第' + (i + 1) + '数据格式有误,数据大于0且最多保留6位小数'
|
)
|
return
|
}
|
feed = {
|
workstationId: this.workstationId,
|
stockId: this.dataList[i].stockId,
|
joinStockOrderId: this.dataList[i].id,
|
suppliedQuantity: this.dataList[i].suppliedQuantity,
|
partId: this.dataList[i].partId,
|
partBatchNo: this.dataList[i].partBatchNo,
|
systemNo: this.dataList[i].systemNo,
|
partName: this.dataList[i].partName,
|
partNo: this.dataList[i].partNo
|
}
|
feeds.push(feed)
|
}
|
const feedIn = {
|
feeds: feeds,
|
feedingFrom: this.isErp ? 'stocker' : 'joinStocker',
|
operationTaskId: this.operationTaskId,
|
source: this.isErp ? 'erp' : undefined
|
}
|
if (feeds.length > 0) {
|
if (this.isErp) {
|
// ERP 投料校验是否在预留中包含
|
var query = Object.assign(
|
{ current: 1, size: 999, operationTaskId: this.operationTaskId },
|
this.partInfo
|
)
|
const response = await fetchList(query)
|
if (response.data.code === 0) {
|
for (let i = 0; i < feeds.length; i++) {
|
const f = feeds[i]
|
for (let j = 0; j < response.data.data.records.length; j++) {
|
const item = response.data.data.records[j]
|
if (
|
f.partBatchNo === item.partBatchNo &&
|
f.partNo === item.partNo
|
) {
|
this.$message.error('预留配盘中存在数据:' + f.partNo)
|
this.isSubmit = false
|
return
|
}
|
}
|
}
|
} else {
|
this.$message.error('校验零件是否有预留发生异常')
|
this.isSubmit = false
|
return
|
}
|
}
|
addFeed(feedIn)
|
.then((response) => {
|
const data = response.data
|
if (data.code === 0) {
|
this.$message.success('投料成功')
|
} else {
|
this.$message.error('投料失败')
|
}
|
// 刷新线边仓、投料列表、预留物料
|
this.$emit('refreshFeedList')
|
this.isSubmit = false
|
this.innerVisible = false
|
})
|
.catch(() => {
|
this.isSubmit = false
|
})
|
} else {
|
this.isSubmit = false
|
}
|
},
|
// 大于0且最多保留6位小数
|
checkDecimal(value) {
|
const reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,6})?$/
|
return reg.test(value)
|
}
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
}
|
},
|
mounted() {}
|
}
|
</script>
|