490 lines
18 KiB
Vue
490 lines
18 KiB
Vue
<template>
|
||
<el-config-provider :locale="zhCn">
|
||
<el-container class="content">
|
||
<div class="work-area">
|
||
<fieldset class="title-area">
|
||
<legend>
|
||
工作台
|
||
</legend>
|
||
<div class="title-div">
|
||
<span class="title-text">物料入库</span>
|
||
</div>
|
||
<div class="station-div">
|
||
<span class="station-text">工作站:</span>
|
||
</div>
|
||
<div class="station-no-div">
|
||
<span class="station-no-text">{{ standId }}</span>
|
||
</div>
|
||
</fieldset>
|
||
<fieldset class="main-area">
|
||
<legend>
|
||
物料入库
|
||
</legend>
|
||
<el-form ref="workFormRef" :model="workFormEntity" :label-position="labelPosition"
|
||
label-width="150px" style="max-width: 100%" :rules="rules" status-icon>
|
||
<div style="display: flex;">
|
||
<div style="display: block; margin: 5px;">
|
||
<div style="display: flex;">
|
||
<div style="display: flex; flex-direction: column;">
|
||
<div class="display-title-div">
|
||
<span class="display-title-text">箱号</span>
|
||
</div>
|
||
<div class="display-form-div">
|
||
<el-input v-model="workFormEntity.vehicleId" size="default" ref="vehicleId"
|
||
v-on:keyup.enter="addTempTask()" clearable></el-input>
|
||
</div>
|
||
</div>
|
||
<div style="display: flex; flex-direction: column;">
|
||
<div class="display-title-div">
|
||
<span class="display-title-text">料号</span>
|
||
</div>
|
||
<div class="display-form-div">
|
||
<el-input v-model="workFormEntity.goodsId" size="default" clearable
|
||
ref="goodsId" v-on:keyup.enter="addTempTask()"></el-input>
|
||
</div>
|
||
</div>
|
||
<div style="display: flex; flex-direction: column;">
|
||
<div class="display-title-div">
|
||
<span class="display-title-text">数量</span>
|
||
</div>
|
||
<div style="display: flex; margin-top: 20px;">
|
||
<div class="display-form-div-left">
|
||
<el-input v-model="workFormEntity.goodsNum" controls-position="right"
|
||
ref="goodsNum" clearable v-on:keyup.enter="addTempTask()" />
|
||
</div>
|
||
<div class="display-form-div-right">
|
||
<span class="display-form-text-right">PC</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- <div style="margin: 10px;">
|
||
<div class="arrow" @click="addTempTask()">
|
||
<span
|
||
style="margin-left: 25px; align-self: center; font-weight: bold;font-size: 45px; writing-mode: vertical-lr;">继续绑定</span>
|
||
</div>
|
||
</div> -->
|
||
<div style="margin: 10px;">
|
||
<div class="arrow" @click="confirmTask()">
|
||
<span
|
||
style="margin-left: 25px; align-self: center; font-weight: bold;font-size: 45px; writing-mode: vertical-lr;">绑定完成</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</el-form>
|
||
</fieldset>
|
||
<fieldset class="task-list-area" v-if="tempTasks.length > 0">
|
||
<legend>
|
||
已绑定物料
|
||
</legend>
|
||
<el-table :data="tempTasks" stripe border max-height="200px"
|
||
:header-cell-style="{ 'text-align': 'center' }" :cell-style="{ 'text-align': 'center' }">
|
||
<el-table-column prop="vehicleId" label="箱号" min-width="120px" />
|
||
<el-table-column prop="goodsId" label="料号" min-width="120px" />
|
||
<el-table-column prop="goodsNum" label="数量" min-width="120px" />
|
||
<el-table-column fixed="right" label="操作" min-width="120px">
|
||
<template v-slot="scope"><el-button style="width: 120px;" plain type="primary"
|
||
@click="deleteRowTask(scope.row)">取消绑定</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</fieldset>
|
||
</div>
|
||
</el-container>
|
||
</el-config-provider>
|
||
</template>
|
||
|
||
<script setup>
|
||
import store from '@/store'
|
||
import { sendGoodsInTask } from '@/api/task'
|
||
import { replaceEnglishAndNumberIGAI } from '@/utils/formatter'
|
||
import { reactive, ref } from 'vue'
|
||
import { errorBox } from '@/utils/myMessageBox.js'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import loading from '@/utils/loading.js'
|
||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
||
</script>
|
||
|
||
<script>
|
||
export default {
|
||
name: 'goodsIn',
|
||
data() {
|
||
return {
|
||
standId: store.getters.getStandId,
|
||
// timer: '',
|
||
labelPosition: 'top',
|
||
tempTasks: [],
|
||
currentRowTask: reactive({}),
|
||
currentVehicleId: '',
|
||
workFormRef: ref(),
|
||
workFormEntity: reactive({
|
||
vehicleId: '',
|
||
goodsId: '',
|
||
goodsNum: ''
|
||
}),
|
||
rules: reactive({
|
||
vehicleId: [
|
||
{ required: true, message: '请输入箱号' }
|
||
]
|
||
}),
|
||
}
|
||
},
|
||
mounted() {
|
||
this.$refs.vehicleId.focus()
|
||
// this.timer = setInterval(() => {
|
||
// // this.getAllTasks()
|
||
// }, 2000)
|
||
},
|
||
beforeUnmount() {
|
||
// clearInterval(this.timer)
|
||
},
|
||
methods: {
|
||
resetForms() {
|
||
this.workFormEntity = reactive({
|
||
vehicleId: '',
|
||
goodsId: '',
|
||
goodsNum: ''
|
||
})
|
||
},
|
||
addTempTask() {
|
||
if (this.workFormEntity.vehicleId != '') {
|
||
const vehicleIdString = replaceEnglishAndNumberIGAI(this.workFormEntity.vehicleId)
|
||
if (!vehicleIdString.startsWith('ASRS') || vehicleIdString.length != 9) {
|
||
errorBox('料箱格式不正确')
|
||
return
|
||
} else {
|
||
this.workFormEntity.vehicleId = vehicleIdString
|
||
}
|
||
}
|
||
if (this.workFormEntity.goodsNum != '') {
|
||
if (isNaN(Number.parseInt(this.workFormEntity.goodsNum))) {
|
||
errorBox('数量格式不正确')
|
||
return
|
||
} else {
|
||
this.workFormEntity.goodsNum = Number.parseInt(this.workFormEntity.goodsNum)
|
||
}
|
||
}
|
||
if (this.workFormEntity.vehicleId != '' && this.workFormEntity.goodsId != '' && this.workFormEntity.goodsNum != '' && this.workFormEntity.goodsNum > 0) {
|
||
if (this.workFormEntity.vehicleId == this.workFormEntity.goodsId) {
|
||
errorBox('料箱号与料号不能相同')
|
||
return
|
||
}
|
||
if (this.workFormEntity.goodsId == this.workFormEntity.goodsNum) {
|
||
errorBox('料号与数量不能相同')
|
||
return
|
||
}
|
||
if (this.workFormEntity.vehicleId == this.workFormEntity.goodsNum) {
|
||
errorBox('料箱号与数量不能相同')
|
||
return
|
||
}
|
||
if (this.currentVehicleId != '' && this.currentVehicleId != this.workFormEntity.vehicleId) {
|
||
errorBox('请下发之前料箱的任务后再继续绑定新的料箱')
|
||
return
|
||
}
|
||
if (this.workFormEntity.goodsNum == 9999) {
|
||
ElMessageBox.confirm(
|
||
'当前数量达最大值9999。\n是否继续',
|
||
'警告',
|
||
{
|
||
confirmButtonText: '确认',
|
||
cancelButtonText: '取消',
|
||
type: 'warning',
|
||
}
|
||
).then(() => {
|
||
// const sameIndex = this.tempTasks.findIndex(task => task.goodsId == this.workFormEntity.goodsId)
|
||
// if (sameIndex != -1) {// 绑定过相同物料
|
||
// var sameGoods = this.tempTasks[sameIndex]
|
||
// sameGoods.goodsNum = sameGoods.goodsNum + this.workFormEntity.goodsNum
|
||
// } else {
|
||
// this.tempTasks.push({
|
||
// vehicleId: this.workFormEntity.vehicleId,
|
||
// goodsId: this.workFormEntity.goodsId,
|
||
// goodsNum: this.workFormEntity.goodsNum
|
||
// })
|
||
// }
|
||
this.tempTasks.push({
|
||
vehicleId: this.workFormEntity.vehicleId,
|
||
goodsId: this.workFormEntity.goodsId,
|
||
goodsNum: this.workFormEntity.goodsNum
|
||
})
|
||
this.currentVehicleId = this.workFormEntity.vehicleId
|
||
this.workFormEntity.goodsId = ''
|
||
this.workFormEntity.goodsNum = ''
|
||
this.$refs.goodsId.focus()
|
||
return
|
||
}).catch(() => {
|
||
ElMessage.info('操作取消')
|
||
this.workFormEntity.goodsNum = ''
|
||
this.$refs.goodsNum.focus()
|
||
return
|
||
})
|
||
} else {
|
||
// const sameIndex = this.tempTasks.findIndex(task => task.goodsId == this.workFormEntity.goodsId)
|
||
// if (sameIndex != -1) {// 绑定过相同物料
|
||
// var sameGoods = this.tempTasks[sameIndex]
|
||
// sameGoods.goodsNum = sameGoods.goodsNum + this.workFormEntity.goodsNum
|
||
// } else {
|
||
// this.tempTasks.push({
|
||
// vehicleId: this.workFormEntity.vehicleId,
|
||
// goodsId: this.workFormEntity.goodsId,
|
||
// goodsNum: this.workFormEntity.goodsNum
|
||
// })
|
||
// }
|
||
this.tempTasks.push({
|
||
vehicleId: this.workFormEntity.vehicleId,
|
||
goodsId: this.workFormEntity.goodsId,
|
||
goodsNum: this.workFormEntity.goodsNum
|
||
})
|
||
this.currentVehicleId = this.workFormEntity.vehicleId
|
||
this.workFormEntity.goodsId = ''
|
||
this.workFormEntity.goodsNum = ''
|
||
this.$refs.goodsId.focus()
|
||
return
|
||
}
|
||
} else {
|
||
if (this.workFormEntity.vehicleId == '') {
|
||
this.$refs.vehicleId.focus()
|
||
return
|
||
}
|
||
if (this.workFormEntity.goodsId == '') {
|
||
this.$refs.goodsId.focus()
|
||
return
|
||
}
|
||
if (this.workFormEntity.goodsNum == '') {
|
||
this.$refs.goodsNum.focus()
|
||
return
|
||
}
|
||
}
|
||
},
|
||
deleteRowTask(row) {// 删除当前行的入库任务
|
||
this.tempTasks.splice(this.tempTasks.indexOf(row), 1)
|
||
if (this.tempTasks.length == 0) {
|
||
this.currentVehicleId = ''
|
||
}
|
||
},
|
||
confirmTask() {
|
||
loading.open('处理中,请稍等...')
|
||
if (this.currentVehicleId == '') {
|
||
loading.close()
|
||
errorBox('必须输入料箱号')
|
||
return
|
||
}
|
||
// 处理相同料号合并
|
||
var taskList = []
|
||
for (var i = 0; i < this.tempTasks.length; i++) {
|
||
var sameIndex = taskList.findIndex(task => task.goodsId == this.tempTasks[i].goodsId)
|
||
if (sameIndex != -1) {// 绑定过相同物料
|
||
var sameGoods = taskList[sameIndex]
|
||
sameGoods.goodsNum = sameGoods.goodsNum + this.tempTasks[i].goodsNum
|
||
} else {
|
||
taskList.push({
|
||
vehicleId: this.tempTasks[i].vehicleId,
|
||
goodsId: this.tempTasks[i].goodsId,
|
||
goodsNum: this.tempTasks[i].goodsNum
|
||
})
|
||
}
|
||
}
|
||
const request = {
|
||
vehicleId: this.currentVehicleId,
|
||
userName: store.getters.getUserName,
|
||
goodsList: taskList.length > 0 ? taskList : [],
|
||
}
|
||
sendGoodsInTask(request).then(res => {
|
||
loading.close()
|
||
const response = res.data
|
||
if (response.code == 0) {
|
||
ElMessage.success('入库确认成功。')
|
||
this.resetForms()
|
||
this.currentVehicleId = ''
|
||
this.tempTasks = []
|
||
this.$refs.vehicleId.focus()
|
||
} else {
|
||
errorBox(response.message)
|
||
}
|
||
}).catch(err => {
|
||
loading.close()
|
||
console.log(err)
|
||
errorBox('入库处理异常')
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.content {
|
||
display: flex;
|
||
width: 100%;
|
||
}
|
||
|
||
.work-area {
|
||
width: 100%;
|
||
/* padding: 5px; */
|
||
}
|
||
|
||
.main-area {
|
||
margin: auto;
|
||
min-height: fit-content;
|
||
max-height: 90%;
|
||
margin-bottom: 10px;
|
||
min-width: inherit;
|
||
border: solid 1px;
|
||
border-radius: 10px;
|
||
box-shadow: 0px 15px 10px -15px #000;
|
||
overflow: auto;
|
||
}
|
||
|
||
.task-list-area {
|
||
margin: auto;
|
||
min-height: fit-content;
|
||
max-height: 90%;
|
||
margin-bottom: 10px;
|
||
min-width: inherit;
|
||
border: solid 1px;
|
||
border-radius: 10px;
|
||
box-shadow: 0px 15px 10px -15px #000;
|
||
overflow: auto;
|
||
}
|
||
|
||
.title-area {
|
||
display: flex;
|
||
/* min-height: 10%; */
|
||
max-height: max-content;
|
||
margin-bottom: 10px;
|
||
min-width: inherit;
|
||
border: solid 1px;
|
||
border-radius: 10px;
|
||
box-shadow: 0px 15px 10px -15px #000;
|
||
overflow: auto;
|
||
}
|
||
|
||
.arrow {
|
||
background: linear-gradient(-105deg,
|
||
transparent 50%,
|
||
#309330 50%,
|
||
#309330 100%) top right,
|
||
linear-gradient(-75deg,
|
||
transparent 50%,
|
||
#309330 50%,
|
||
#309330 100%) bottom right;
|
||
background-size: 100% 50%;
|
||
height: 270px;
|
||
width: 250px;
|
||
background-repeat: no-repeat;
|
||
display: inline-flex;
|
||
cursor: pointer;
|
||
}
|
||
|
||
:deep(.el-input) {
|
||
width: 230px;
|
||
height: 130px;
|
||
font-size: 25px;
|
||
}
|
||
|
||
:deep(.el-input-number) {
|
||
width: 150px;
|
||
height: 130px;
|
||
font-size: 25px;
|
||
}
|
||
|
||
:deep(.el-select-v2__wrapper) {
|
||
width: 230px;
|
||
height: 130px;
|
||
font-size: 25px;
|
||
}
|
||
|
||
.title-div {
|
||
display: inline-flex;
|
||
width: -webkit-fill-available;
|
||
margin-right: 5px;
|
||
padding: 5px;
|
||
background-color: #CCCCCC;
|
||
}
|
||
|
||
.title-text {
|
||
align-self: center;
|
||
font-weight: bold;
|
||
font-size: 25px;
|
||
}
|
||
|
||
.station-div {
|
||
display: inline-flex;
|
||
justify-content: center;
|
||
width: 150px;
|
||
margin-left: 5px;
|
||
margin-right: 5px;
|
||
padding: 5px;
|
||
background-color: #FFFAAA;
|
||
}
|
||
|
||
.station-text {
|
||
align-self: center;
|
||
font-weight: bold;
|
||
font-size: 25px;
|
||
}
|
||
|
||
.station-no-div {
|
||
display: inline-flex;
|
||
justify-content: center;
|
||
width: 200px;
|
||
padding: 5px;
|
||
border: 5px double #000000;
|
||
}
|
||
|
||
.station-no-text {
|
||
align-self: center;
|
||
font-weight: bold;
|
||
font-size: 25px;
|
||
}
|
||
|
||
.display-title-div {
|
||
display: inline-flex;
|
||
justify-content: center;
|
||
width: 240px;
|
||
height: 80px;
|
||
margin: 5px;
|
||
padding: 5px;
|
||
background-color: #FFFAAA;
|
||
}
|
||
|
||
.display-title-text {
|
||
align-self: center;
|
||
font-weight: bold;
|
||
font-size: 25px;
|
||
}
|
||
|
||
.display-form-div {
|
||
display: inline-flex;
|
||
justify-content: center;
|
||
width: 230px;
|
||
margin: 5px;
|
||
padding: 5px;
|
||
border: 5px double #000000;
|
||
margin-top: 25px;
|
||
}
|
||
|
||
.display-form-div-left {
|
||
display: inline-flex;
|
||
justify-content: center;
|
||
width: 150px;
|
||
margin: 5px;
|
||
padding: 5px;
|
||
border: 5px double #000000;
|
||
}
|
||
|
||
.display-form-div-right {
|
||
display: inline-flex;
|
||
justify-content: center;
|
||
width: 60px;
|
||
margin: 5px;
|
||
padding: 5px;
|
||
background-color: #CCCCCC;
|
||
}
|
||
|
||
.display-form-text-right {
|
||
align-self: center;
|
||
font-weight: bold;
|
||
font-size: 25px;
|
||
}
|
||
</style> |