<template>
|
<el-dialog
|
width="70%"
|
top="5vh"
|
title="扫码投料"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
class="scan-feed-dialog"
|
>
|
<div class="app-container">
|
<div class="avue-crud">
|
<div style="display:flex;margin-bottom:10px;">
|
<div style="line-height:32px;">
|
<span style="font-weight:bold;">扫码:</span>
|
</div>
|
<div>
|
<el-input
|
size="small"
|
ref="sn_seach_input"
|
v-model="scanContent"
|
v-focus
|
@keyup.enter.native="queryFeedStock"
|
></el-input>
|
</div>
|
<div
|
v-show="batchNo != null"
|
style="line-height:32px;margin-left:10px;color:#076ecd;"
|
>
|
<span>sn号:{{ batchNo }}</span>
|
</div>
|
<!-- <div
|
v-show="ifsBatchNo != null"
|
style="line-height:32px;margin-left:10px;color:#006eff;"
|
>
|
<span>ifs批次号:{{ ifsBatchNo }}</span>
|
</div> -->
|
</div>
|
<el-table
|
:key="tableKey"
|
:data="scanFeedList"
|
border
|
style="width: 100%;"
|
height="500px"
|
>
|
<el-table-column type="index" width="50" align="center" label="序号">
|
</el-table-column>
|
<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="specs"
|
header-align="center"
|
align="center"
|
label="规格型号"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="availableStockQuantity"
|
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="请输入数量"
|
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-column label="操作" align="center" width="80px">
|
<template slot-scope="scope">
|
<el-button
|
type="text"
|
size="small"
|
style="color:red;"
|
@click="delFeed(scope.$index)"
|
>删除</el-button
|
>
|
</template>
|
</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="`saveFeed`"
|
>投 料</el-button
|
>
|
</div>
|
</el-dialog>
|
</template>
|
<script>
|
import { addFeed, getStock, getTodoStock } from '@/api/product/personboard'
|
export default {
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
isOk: {
|
type: Boolean,
|
default: true
|
},
|
paramObject: {
|
type: Object,
|
default: () => {
|
return {}
|
}
|
},
|
workstationId: {
|
type: Number
|
},
|
operationTaskId: {
|
type: Number
|
},
|
materialList: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
}
|
},
|
data() {
|
return {
|
innerVisible: false,
|
tableKey: 0,
|
isSubmit: false,
|
scanContent: null,
|
batchNo: null,
|
ifsBatchNo: null,
|
scanFeedList: []
|
}
|
},
|
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: {
|
saveFeed() {
|
this.isSubmit = true
|
// 调用投料接口,然后刷新线边仓、投料列表
|
var feeds = []
|
var feed
|
for (var i = 0; i < this.scanFeedList.length; i++) {
|
if (!this.scanFeedList[i].suppliedQuantity) {
|
this.isSubmit = false
|
this.$message.error('第' + (i + 1) + '投入数量不能为空')
|
return
|
}
|
if (!this.checkDecimal(this.scanFeedList[i].suppliedQuantity)) {
|
this.isSubmit = false
|
this.$message.error(
|
'第' + (i + 1) + '数据格式有误,数据大于0且最多保留6位小数'
|
)
|
return
|
}
|
feed = {
|
workstationId: this.workstationId,
|
stockId: this.scanFeedList[i].id,
|
joinStockOrderId: null,
|
suppliedQuantity: this.scanFeedList[i].suppliedQuantity,
|
partId: this.scanFeedList[i].partId,
|
partBatchNo: this.scanFeedList[i].partBatchNo,
|
systemNo: this.scanFeedList[i].systemNo,
|
partName: this.scanFeedList[i].partName,
|
unit: this.scanFeedList[i].unit ? this.scanFeedList[i].unit : ''
|
}
|
feeds.push(feed)
|
}
|
const feedIn = {
|
feeds: feeds,
|
feedingFrom: 'stocker',
|
operationTaskId: this.operationTaskId
|
}
|
if (feeds.length > 0) {
|
addFeed(feedIn)
|
.then((response) => {
|
var 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)
|
},
|
// 查询线边仓物料库存
|
queryFeedStock() {
|
if (this.workstationId && this.workstationId != null) {
|
// 根据扫入的字符串信息,判断扫的是条形码,还是二维码
|
if (this.scanContent != null) {
|
let scanParamObject
|
if (this.scanContent.indexOf('lot_batch_no') != -1) {
|
// 二维码
|
const scanContentJson = JSON.parse(
|
this.scanContent.replace(/\n/g, '').replace(/\s*/g, '')
|
)
|
const partNo = scanContentJson.part_no
|
this.ifsBatchNo = scanContentJson.lot_batch_no
|
scanParamObject = {
|
partNo: partNo,
|
ifsBatchNo: this.ifsBatchNo
|
}
|
} else {
|
// 条形码
|
this.batchNo = this.scanContent
|
scanParamObject = {
|
partBatchNo: this.batchNo
|
}
|
}
|
const query = Object.assign(
|
{ current: 0, size: 50 },
|
{ workstationId: this.workstationId },
|
this.paramObject,
|
scanParamObject
|
)
|
if (!this.isOk) {
|
// 待处理
|
getTodoStock(query)
|
.then((response) => {
|
this.dealStoreResponse(response)
|
})
|
.catch(() => {})
|
} else {
|
// 合格
|
getStock(query)
|
.then((response) => {
|
this.dealStoreResponse(response)
|
})
|
.catch(() => {})
|
}
|
} else {
|
this.$message.error('请扫码')
|
}
|
}
|
},
|
dealStoreResponse(response) {
|
const data = response.data
|
if (data.code === 0) {
|
const newScanFeedList = data.data.records
|
if (newScanFeedList != null && newScanFeedList.length > 0) {
|
const _this = this
|
// 校验newScanFeedList中的批次号是否已经扫入过
|
let flag = true
|
for (let i = 0; i < newScanFeedList.length; i++) {
|
const exist = _this.scanFeedList.find(
|
(el) => el.partBatchNo == newScanFeedList[i].partBatchNo
|
)
|
if (exist) {
|
flag = false
|
}
|
}
|
if (flag) {
|
newScanFeedList.forEach(function(item) {
|
const material = _this.materialList.find((el) => {
|
return el.partNo == item.partNo
|
})
|
/* if (material) {
|
if (material.quantityRequired > item.availableStockQuantity) {
|
_this.$set(
|
item,
|
'suppliedQuantity',
|
item.availableStockQuantity
|
)
|
} else {
|
_this.$set(
|
item,
|
'suppliedQuantity',
|
material.quantityRequired
|
)
|
}
|
} else {
|
_this.$set(
|
item,
|
'suppliedQuantity',
|
item.availableStockQuantity
|
)
|
} */
|
_this.$set(item, 'suppliedQuantity', item.availableStockQuantity)
|
_this.scanFeedList.push(item)
|
})
|
} else {
|
this.$message.error('零件批次已存在')
|
}
|
}
|
this.scanContent = null
|
} else {
|
this.$message.error('获取线边仓物料信息失败')
|
}
|
},
|
delFeed(index) {
|
this.scanFeedList.splice(index, 1)
|
}
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
this.scanFeedList = []
|
this.batchNo = null
|
this.ifsBatchNo = null
|
if (this.currshowlist) {
|
this.$nextTick(() => {
|
this.$refs.sn_seach_input.focus()
|
// 根据工单,查询工单对应的产出批次
|
})
|
}
|
}
|
},
|
mounted() {}
|
}
|
</script>
|
<style scoped>
|
.scan-feed-dialog >>> .el-dialog__body {
|
padding: 0px 20px 30px 20px;
|
}
|
</style>
|