Commit 4aec84a9 authored by hubaoshan's avatar hubaoshan

液体出入库

parent cedeae8a
...@@ -92,6 +92,16 @@ export function batchAddIncomeWmsBox(data) { ...@@ -92,6 +92,16 @@ export function batchAddIncomeWmsBox(data) {
} }
}) })
} }
export function batchAddIncomeWmsBoxNew(data) {
return request({
url: '/incomewmsbox/batchAddNew',
method: 'post',
data: data,
headers: {
'Content-Type': 'application/json;charset=UTF-8' // 接口修改传参类型
}
})
}
export function checkIsZero(data) { export function checkIsZero(data) {
return request({ return request({
url: 'incomewmsbox/checkIsZero', url: 'incomewmsbox/checkIsZero',
......
...@@ -4,7 +4,7 @@ import { getInfo } from '@/api/login' ...@@ -4,7 +4,7 @@ import { getInfo } from '@/api/login'
import Layout from '@/layout/index' import Layout from '@/layout/index'
// pathList: 是要隐藏菜单的集合 system元素:一级菜单的路径(path) // pathList: 是要隐藏菜单的集合 system元素:一级菜单的路径(path)
const pathList = ['system', 'system/log', 'production', 'equipment', 'process', '/none2', 'sample', 'tlias', '/test', '/inspect', '/controlPlatform/control', '/template/planeGraph', '/demoData/demoData1','/setup/test'] const pathList = ['system', 'system/log', 'production', 'equipment', 'process', '/none2', 'sample', 'tlias', '/test', '/inspect', '/controlPlatform/control', '/template/planeGraph', '/demoData/demoData1', '/setup/test']
const permission = { const permission = {
state: { state: {
......
...@@ -211,7 +211,7 @@ export function successAudio(start) { ...@@ -211,7 +211,7 @@ export function successAudio(start) {
// 自定义转换成大写的 // 自定义转换成大写的
export function customUpperCase(sourceStr) { export function customUpperCase(sourceStr) {
return sourceStr && sourceStr !== '' ? sourceStr.toUpperCase() : sourceStr return sourceStr && sourceStr !== '' ? sourceStr.toUpperCase().trim() : sourceStr
} }
export function UpperCaseStr(sourceStr) { export function UpperCaseStr(sourceStr) {
......
<template>
<div class="dispose-module">
<div class="search">
<el-form ref="searchRef" :model="form" :rules="rules" label-width="80px" class="formClass" label-position="right" @submit.native.prevent>
<div class="searchDiv">
<el-form-item label="ptype:">
<!-- <span>{{ form.ptype && getDictLabelByValue(typeList, form.ptype.trim()) || '-' }}</span>-->
<span v-if="form.ptype === '1'">jb</span>
<span v-else-if="form.ptype === '20'">jl</span>
<span v-else>-</span>
</el-form-item>
<el-form-item label="code:">
<span>{{ form.orderCode || '-' }}</span>
</el-form-item>
</div>
<el-form-item label="pn:">
<span>{{ form.pn || '-' }}</span>
</el-form-item>
<div class="searchDiv">
<el-form-item label="lot:">
<span>{{ form.lot || '-' }}</span>
</el-form-item>
<el-form-item v-if="form.cj && form.cj !== null" label="cj:">
<span>{{ getLabelByCj(form.cj) || '-' }}</span>
</el-form-item>
</div>
<div class="searchDiv">
<el-form-item label="qty:">
<span>{{ form.qty || '-' }}</span>
</el-form-item>
<!-- <el-form-item label="rank:">-->
<!-- <span>{{ form.rank || '-' }}</span>-->
<!-- </el-form-item>-->
</div>
</el-form>
</div>
<hr class="disposeHr">
<div class="disposeTable">
<div class="searchInput">
<el-form ref="formRef" :model="searchForm" :rules="rules" label-width="80px" class="formClass" label-position="right" @submit.native.prevent>
<el-form-item label="位置" prop="search">
<el-input ref="input1" v-model="searchForm.search" clearable @keyup.enter.native="handleSearch" />
</el-form-item>
<el-form-item label="YY" prop="value2">
<el-input ref="input2" v-model="searchForm.value2" clearable @keyup.enter.native="handleSearchLot" />
</el-form-item>
</el-form>
</div>
<div class="disposeTableContent">
<el-table :data="tableList" :row-class-name="tableRowClassName" style="width: 100%">
<el-table-column label="location">
<template slot-scope="scope">
<span>{{ scope.row.location || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="LOT">
<template slot-scope="scope">
<span>{{ scope.row.lot || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="数量">
<template slot-scope="scope">
<span v-if="false">{{ scope.row.needNumber || '-' }}</span>
<span>{{ scope.row.needNumber/1000 }}KG</span>
</template>
</el-table-column>
<el-table-column label="cheBzq" min-width="52" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span>{{ scope.row.cheBzq || '-' }}</span>
</template>
</el-table-column>
</el-table>
</div>
</div>
<div class="totalNumber">
<div class="label">总计:</div>
<div v-if="total > 0" class="number">{{ total }}</div>
</div>
<div class="button_row">
<el-button class="button_rowBtn" type="primary" @click="handleSave">出库</el-button>
</div>
</div>
</template>
<script>
import manufacturer from '@/data/jsonData'
import { handleOutWarehouse, persistOut } from '@/api/outcomeWmsJbapplyTemp'
import { customUpperCase } from '@/utils/common'
import { playAudio, successAudio } from '@/utils/common'
export default {
name: 'Dispose',
data() {
return {
manufacturer,
typeList: [],
// 本地储存
/**
* 元素是一个对象 对象中有三个值 location list frequency
* **/
storeList: [],
search: null,
lot: null,
// 总计
total: 0,
rowIndexList: [],
// 当前高亮的索引
currentIndex: -1,
SearchKeyword: '',
businessId: null,
form: {
ptype: null,
orderCode: null,
pn: null,
lot: null,
qty: null,
rank: null,
cj: null
},
rules: {
search: [
{ pattern: /^.*,.*/ | /^.*$/, message: '输入值不符合格式要求,请重新输入', trigger: 'blur' }
]
// value2: [
// { pattern: /^[^:]+:[^:]+:[^:]+:\d+$/, message: '输入值不符合格式要求,请重新输入', trigger: 'blur' }
// ]
},
tableList: [],
searchForm: {
search: '',
lot: '',
value2: ''
}
}
},
created() {
this.focusing()
// this.getAllDict()
// 获取数据字典
this.getDetail()
},
methods: {
getLabelByCj(value) {
const obj = manufacturer.find(item => item.value === value)
return obj ? obj.label : null
},
/**
* @description: 一开始将焦点聚焦到第一个输入框下
* @author: gaoyu
* @param:
* @return:
**/
focusing() {
this.$nextTick().then(() => {
this.$refs.input1.focus()
})
},
tableRowClassName({ row, rowIndex }) {
if (this.rowIndexList.includes(rowIndex)) {
return 'hight_row'
}
},
// 获取详情
getDetail() {
this.businessId = this.$route.query.businessId
const obj = {
businessId: this.businessId
}
handleOutWarehouse(obj).then(res => {
if (res.code === 200) {
this.form = res.data
this.tableList = res.data.boxList
}
})
},
/**
* 获取本次要高亮的行的下坐标和要加的数量
* **/
getIndexAndNeedNumber(location, pn) {
let matchFlag = false
let matchObj = null
let matchIndex = null
/**
* 1.判断储存的list是不是为空
* **/
// this.storeList
// this.tableList
for (let i = 0; i < this.tableList.length; i++) {
const tableObj = this.tableList[i]
// 1. 匹配成功
if (customUpperCase(tableObj.location) === customUpperCase(location) &&
customUpperCase(tableObj.pn) === customUpperCase(pn)) {
matchFlag = true
matchObj = tableObj
matchIndex = i
for (let j = 0; j < this.storeList.length; j++) {
const storeObj = this.storeList[j]
// 2. 重复验证
if (tableObj.businessId === storeObj.businessId) {
matchFlag = false
break
}
}
}
// 3. 确认匹配成功
if (matchFlag) {
this.storeList.push(matchObj)
return {
index: matchIndex,
needNumber: matchObj.needNumber
}
}
}
playAudio(true)
this.searchForm.value2 = ''
this.searchForm.search = ''
this.$message.error({
message: '输入的位置' + this.searchForm.search + '不正确请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.$nextTick().then(() => {
this.$refs.input1.focus()
})
},
// 查询回
handleSearch() {
// 获取位置输入框的数据
this.$refs.formRef.validateField('search', (error) => {
if (error) {
playAudio(true)
this.$message.error({
message: '输入值不符合格式要求,请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
}, () => {})
this.searchForm.search = null
} else {
if (this.searchForm.search.includes(',')) {
this.search = this.searchForm.search.split(',')[0]
this.judgePush(this.search)
} else {
this.search = this.searchForm.search
this.judgePush(this.search)
}
}
})
},
/** 判断是否可以输入*/
judgePush(data) {
let isLegalLocation = false
this.tableList.forEach(item => {
if (customUpperCase(item.location) === customUpperCase(data)) {
isLegalLocation = true
}
})
if (isLegalLocation) {
successAudio(true)
this.$nextTick().then(() => {
this.$refs.input2.focus()
})
} else {
playAudio(true)
this.$message.error({
message: '请输入正确的location值!',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.searchForm.search = null
}
},
handleSearchLot() {
this.$refs.formRef.validateField('value2', (error) => {
if (this.total === this.form.qty) {
this.$message.info({
message: '满了',
duration: 2000
})
this.searchForm.search = ''
this.searchForm.value2 = ''
this.$nextTick().then(() => {
this.$refs.input1.focus()
})
return
}
if (error) {
playAudio(true)
this.$message.error({
message: '输入值不符合格式要求,请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
}, () => {})
// 清空输入框
this.searchForm.value2 = ''
} else {
const values = this.searchForm.value2.split(';')
const obj = {
pn: values[0],
lot: values[1],
qty: this.checkQty(values[2]),
cheBzq: values[4],
cheCjName: values[5]
}
/** ptyp为1的时候*/
if (this.form.ptype === '1') {
if (customUpperCase(obj.pn) !== customUpperCase(this.form.pn)) {
playAudio(true)
this.$message.error({
message: '输入不符合要求请重新输入!',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.searchForm.value2 = null
} else {
var pn = obj.pn
var search = this.search
// 调用方法,并传入位置和pn作为参数
const abj = this.getIndexAndNeedNumber(search, pn)
if (abj) {
const { index, needNumber } = abj
if (!this.rowIndexList.includes(index)) {
successAudio(true)
this.rowIndexList.push(index)
this.search = null
this.pn = null
}
this.$nextTick().then(() => {
this.$refs.input1.focus()
})
this.total = this.total + needNumber
this.searchForm.search = ''
this.searchForm.value2 = '' // 清空LOT输入框数据
}
}
} else if (this.searchForm.value2.split(';') && values.length === 6 && values.every(value => value !== '')) {
// ptype不为1的时候
if (customUpperCase(obj.pn) !== customUpperCase(this.form.pn)) {
playAudio(true)
this.$message.error({
message: '输入不符合要求请重新输入!',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.searchForm.value2 = null
} else {
const pn = obj.pn
const search = this.search
// 调用方法,并传入位置和pn作为参数
const abj = this.getIndexAndNeedNumber(search, pn)
if (abj) {
const { index, needNumber } = abj
if (!this.rowIndexList.includes(index)) {
this.rowIndexList.push(index)
}
successAudio(true)
this.search = null
this.lot = null
this.$nextTick().then(() => {
this.$refs.input1.focus()
})
this.total = this.total + needNumber
this.searchForm.search = ''
this.searchForm.value2 = ''
}
}
} else {
const values = this.searchForm.value2.split(',')
const obj = {
pn: values[0],
lot: values[1],
qty: this.checkQtyByUnit(values),
cheBzq: this.formatCheBzq(values[2]),
cheUnit: values[4],
cheCjName: values[5]
}
if (this.searchForm.value2.split(',') && values.length === 6 && values.every(value => value !== '')) {
// ptype不为1的时候
if (customUpperCase(obj.pn) !== customUpperCase(this.form.pn)) {
playAudio(true)
this.$message.error({
message: '输入不符合要求请重新输入!',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.searchForm.value2 = null
} else {
const pn = obj.pn
const search = this.search
// 调用方法,并传入位置和pn作为参数
const abj = this.getIndexAndNeedNumber(search, pn)
if (abj) {
const { index, needNumber } = abj
if (!this.rowIndexList.includes(index)) {
this.rowIndexList.push(index)
}
successAudio(true)
this.search = null
this.pn = null
this.$nextTick().then(() => {
this.$refs.input1.focus()
})
this.total = this.total + needNumber
this.searchForm.search = ''
this.searchForm.value2 = ''
}
}
} else {
this.$message.error({
message: '输入格式不符合要求,请重新输入',
duration: 2000
})
this.searchForm.value2 = ''
}
}
}
})
},
// 出库
handleSave() {
if (this.total === this.form.qty) {
const obj = {
pn: this.form.pn,
ptype: this.form.ptype,
businessId: this.businessId,
boxList: this.tableList
}
persistOut(obj).then(res => {
if (res.code === 200) {
this.$router.push({
path: '/setup/inspectionRequestProcessing'
})
this.$message.success({
message: '出库成功!',
duration: 2500
})
}
})
} else {
this.$message.warning({
message: '您申请的数量' + this.total + '您总的申请数量' + this.form.qty,
duration: 2000
})
}
},
checkQty(str) {
if (typeof str !== 'string') {
return
}
const data = str.match(/^([a-zA-Z]+)(\d+)([a-zA-Z]+)$/)
if (data) {
const num = data[2]
const unit = customUpperCase(data[3])
if (unit === 'KG') {
return num * 1000
} else if (unit === 'G') {
return num
} else {
this.$message.error({
message: '输入数量格式不正确',
duration: 2000
})
}
} else {
this.$message.error({
message: '输入格式不正确',
duration: 2000
})
}
},
checkBzq(dateStr) {
const str = dateStr.substring(1)
const year = str.substring(0, 4)
const month = str.substring(4, 6).padStart(2, '0')
const day = str.substring(6, 8).padStart(2, '0')
return `${year}-${month}-${day}`
},
formatCheBzq(date) {
return date ? date.split(' ')[0].replace(/\//g, '-') : ''
},
checkQtyByUnit(data) {
const unit = customUpperCase(data[4])
if (unit === 'KG') {
return data[3] * 1000
} else if (unit === 'G') {
return data[3]
}
}
}
}
</script>
<style lang="scss">
.dispose-module{
.hight_row {
background: #FFCC66 !important; /* 设置高亮行的背景色 */
}
.search{
width: 96%;
.searchDiv{
display: flex;
justify-content: space-between;
}
}
.disposeHr{
margin-bottom: 20px;
}
.disposeTable{
margin-left: 2%;
width: 96%;
.disposeTableContent{
margin-top: 20px;
}
}
.totalNumber{
display: flex;
.label{
color: red;
margin: 20px;
}
.number{
margin: 20px;
}
}
.button_row{
display: flex;
justify-content: center;
.button_rowBtn{
font-size: 17px;
width: 160px;
}
.button_rowText{
margin-top: 10px;
}
}
}
</style>
...@@ -170,7 +170,6 @@ export default { ...@@ -170,7 +170,6 @@ export default {
this.queryForm.cj = this.manufacturer[0].value this.queryForm.cj = this.manufacturer[0].value
}, },
methods: { methods: {
customUpperCase,
/** /**
* @description: 获取数据字典 * @description: 获取数据字典
* @author: gaoyu * @author: gaoyu
......
...@@ -195,14 +195,22 @@ export default { ...@@ -195,14 +195,22 @@ export default {
businessId: item.businessId businessId: item.businessId
} }
validNumber(obj).then(res => { validNumber(obj).then(res => {
console.log('res', res)
if (res.data) { if (res.data) {
if (item.ptype === '1') {
this.$router.push({ this.$router.push({
path: '/setup/checkTheApplicationForExit', path: '/setup/checkTheApplicationForExit',
query: { query: {
businessId: item.businessId businessId: item.businessId
} }
}) })
} else {
this.$router.push({
path: '/setup/dealWithStorage',
query: {
businessId: item.businessId
}
})
}
} }
}) })
} }
......
<template>
<div class="storage">
<div class="enterForm">
<div class="search">
<el-form
ref="queryForm"
class="formClass"
:model="queryForm"
:rules="rules"
label-width="80px"
@submit.native.prevent
>
<el-form-item label="仓库:" prop="whId">
<el-select v-model="queryForm.whId" filterable class="normalSelect" placeholder="请选择">
<el-option
v-for="(item,index) in warehouseList"
:key="index"
:label="item.dictLabel"
:value="item.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item label="cj:" prop="cheCjName">
<span>{{ cheCj }}</span>
</el-form-item>
<!-- <el-form-item label="cj" prop="cj">-->
<!-- <el-select-->
<!-- v-model="queryForm.cj"-->
<!-- class="normalSelect"-->
<!-- placeholder="请选择厂家"-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="item in manufacturer"-->
<!-- :key="item.value"-->
<!-- :label="item.label"-->
<!-- :value="item.value"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="XX:" prop="value1">
<el-input
ref="input1"
v-model="queryForm.value1"
:disabled="enterTable.length>0"
clearable
@keyup.enter.native="handelTab(1,$event)"
/>
</el-form-item>
<el-form-item>
<div class="location"> location: {{ queryForm.location }}</div>
<div v-show="showPN(queryForm.location,incomeWmsLabelList.pn)">
<!-- 库PN: {{ incomeWmsLabelList.pn }}-->
<span style="color: black;">库PN: </span><span style="color: red;">{{ incomeWmsLabelList.pn }}</span>
</div>
</el-form-item>
<el-form-item label="YY:" prop="value2">
<el-input ref="input2" v-model="queryForm.value2" clearable @keyup.enter.native="addList" />
</el-form-item>
<el-form-item>
<div class="showPn">
<span class="pnFont">YYpn: {{ incomeWmsBoxList.pn }}</span>
</div>
</el-form-item>
</el-form>
</div>
<div class="enterTable">
<el-table :data="enterTable">
<el-table-column label="lot" min-width="52" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span>{{ scope.row.lot }}</span>
</template>
</el-table-column>
<el-table-column label="qty" min-width="52" :show-overflow-tooltip="true">
{{ qtyKg }}
<template slot-scope="scope">
<span v-if="false">{{ scope.row.qty }}</span>
<span>{{ scope.row.qty/1000 }}KG</span>
</template>
</el-table-column>
<el-table-column label="cheBzq" min-width="52" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span>{{ scope.row.cheBzq }}</span>
</template>
</el-table-column>
<el-table-column min-width="20" :show-overflow-tooltip="true">
<template slot-scope="scope">
<i
class="el-icon-delete-solid"
style="font-size: 26px;margin-left: -10px;color: #46BCF3; margin-top: 7px"
@click="handleDelte(scope.$index)"
/>
<!-- <span>{{scope.row.value3}}</span>-->
</template>
</el-table-column>
</el-table>
</div>
<div class="tableTotal">
<span style="color: red">条数:{{ enterTable.length }}</span>
<span style="color: red;float: right;">液体总重:{{ totalCounts }}</span>
</div>
<div class="buttonRegion">
<el-button class="button_rowBtn" type="primary" @click="SubmitForm">保存</el-button>
<el-button class="button_rowBtn" type="primary" @click="clearFormConfirmation($event)">清空</el-button>
</div>
<!-- 中间文本-->
<div class="BottomContent">
<div class="fontSp">单号: {{ incomeWmsBoxList.order_code }}</div>
<div class="loginUser">操作人: {{ userList.nickName }} </div>
</div>
</div>
</div>
</template>
<script>
import manufacturer from '@/data/jsonData'
import {
batchAddIncomeWmsBoxNew, checkIsZero, getJcCode
} from '@/api/incomeWmsBox'
import { findByLocation } from '@/api/incomeWmsLabel'
import { getInfo } from '@/api/login'
import { getDict } from '@/api/system/dict/data'
import { playAudio, successAudio } from '@/utils/common'
import { customUpperCase } from '@/utils/common'
export default {
name: 'Storage',
data() {
return {
queryForm: {
cj: '',
whId: '',
location: '', // 假设 location 的值为 'A1'
pn: '', // 假设 pn 的值为 'ABC'
value1: '',
value2: '',
lot: '',
qty: '',
rank: ''
},
cheCj: '',
// 库存管理表格数据
incomeWmsBoxList: {
order_code: '',
pn: ''
},
// 仓库数据
warehouseList: [],
form: {},
enterTable: [],
incomeWmsLabelList: {},
userList: {
nickName: ''
},
manufacturer: {},
// 表单校验
rules: {
// value1: [
// { required: true, message: '请输入barcode的值', trigger: 'blur' },
// { pattern: /^.*,.*/ | /^.*$/, message: '输入值不符合格式要求,请重新输入', trigger: 'blur' }
// ],
// value2: [
// { pattern: /^[^:]+:[^:]+:[^:]+:\d+$/, message: '输入值不符合格式要求,请重新输入', trigger: 'blur' }
// ]
}
}
},
computed: {
totalCounts() {
return Number(this.enterTable.reduce((acc, current) => acc + (current.qty || 0), 0))
}
},
created() {
console.log('manufacturer', manufacturer)
this.manufacturer = manufacturer
this.getDictData()
this.focusing()
this.getOrderCode()
this.getLoginUser()
// this.queryForm.cj = this.manufacturer[0].value
},
mounted() {
// this.queryForm.cj = this.manufacturer[0].value
},
methods: {
/**
* @description: 获取数据字典
* @author: gaoyu
* @param:
* @return:
**/
getDictData() {
// 获取仓库的数据字段
getDict('WAREHOUSE').then(res => {
console.log('仓库数据字典', res)
this.warehouseList = res.data
const whId = res.data[0].dictValue
this.queryForm.whId = whId
})
},
showPN(location, pn) {
if ((location !== '' && location !== null) && (pn !== '' && pn !== null && pn !== undefined)) {
return true
} else {
return false
}
},
/**
* 清空按钮
* @param e
*/
// 清空按钮的确认逻辑
clearFormConfirmation(e) {
if (e.target.innerText === '清空') {
this.$confirm('确定要清空列表吗?', '清空列表', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.clearForm(e)
this.getDictData()
// this.queryForm.cj = this.manufacturer[0].value
this.queryForm.cj = ''
this.$message({
type: 'success',
message: '清空成功!'
})
}).catch(() => {
})
}
},
clearForm(e) {
this.queryForm = {
queryForm: {
cj: '',
location: '', // 假设 location 的值为 'A1'
pn: '', // 假设 pn 的值为 'ABC'
value1: '',
value2: '',
lot: '',
qty: '',
rank: ''
}
}
this.incomeWmsLabelList = {}
this.incomeWmsBoxList.pn = ''
this.enterTable = []
const that = this
that.$nextTick(() => {
e.target.blur()
that.$refs['input1'].focus()
})
},
/**
* 保存
*/
SubmitForm() {
this.$confirm('确定要执行新增操作吗?', '批量新增', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$refs.queryForm.validate(valid => {
console.log('chebzq;', this.enterTable[0].cheBzq)
if (valid && this.enterTable.length > 0) {
const obj = {
boxList: this.enterTable
}
batchAddIncomeWmsBoxNew(obj).then(res => {
console.log('res', res)
if (res.code === 200) {
this.msgSuccess('新增成功')
this.clearForm()
// this.queryForm.cj = this.manufacturer[0].value
this.getDictData()
this.getOrderCode()
this.$nextTick().then(() => {
this.$refs.input1.focus()
})
}
})
} else {
this.$message.error('列表的数据不能为空')
}
})
}).catch(() => {
})
},
/** 获取当前登录用户**/
getLoginUser() {
getInfo().then(response => {
if (response.code === 200) {
this.userList.nickName = response.data.user.nickName
}
})
},
/**
* 获取单号
*/
// 获取单号
getOrderCode() {
getJcCode().then(response => {
if (response.code === 200) {
this.incomeWmsBoxList.order_code = response.data
}
})
},
/**
* @description: 监听输入框回车事件,如果回车焦点聚集到下一个输入框
* @author: gaoyu
* @param:
* @return:
**/
handelTab(i, e) {
const that = this
if (!that.$refs['input' + i]) {
return
}
this.$refs.queryForm.validateField('value1', (error) => {
if (error) {
playAudio(true)
this.$message.error({
message: '输入值不符合格式要求,请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
}, () => {
})
} else {
const inputValues = this.queryForm.value1.split(',')
if (inputValues.length === 2) {
this.queryForm.location = inputValues[0].trim()
this.queryForm.pn = inputValues[1].trim()
findByLocation(this.queryForm.location).then(res => {
if (res.code === 200) {
if (res.data != null) {
if (res.data.pn !== null && res.data.pn !== '') {
this.incomeWmsLabelList = res.data
// this.getOrderCode()
successAudio(true)
that.$nextTick(() => {
e.target.blur()
const index = i + 1
that.$refs['input' + index].focus()
})
} else {
successAudio(true)
this.incomeWmsLabelList = res.data
that.$nextTick(() => {
e.target.blur()
const index = i + 1
that.$refs['input' + index].focus()
})
}
} else {
playAudio(true)
this.$message.error({
message: '数据库中无对应数据location:' + this.queryForm.location,
duration: 2000,
onClose: () => {
playAudio(false)
}
}, () => {
})
this.queryForm.value1 = ''
this.queryForm.location = ''
this.incomeWmsLabelList.pn = ''
this.queryForm.value2 = ''
}
}
})
} else {
console.log('查询2')
if (inputValues.length === 1) {
this.queryForm.location = inputValues[0].trim()
console.log('location', this.queryForm.location)
findByLocation(this.queryForm.location).then(res => {
if (res.code === 200) {
console.log('resDate', res.data)
if (res.data != null) {
if (res.data.pn !== null && res.data.pn !== '') {
if (res.data.pn !== this.queryForm.pn) {
successAudio(true)
this.incomeWmsLabelList = res.data
that.$nextTick(() => {
e.target.blur()
const index = i + 1
that.$refs['input' + index].focus()
})
} else {
successAudio(true)
this.incomeWmsLabelList = res.data
// this.getOrderCode()
that.$nextTick(() => {
e.target.blur()
const index = i + 1
that.$refs['input' + index].focus()
})
}
} else {
successAudio(true)
this.incomeWmsLabelList = res.data
that.$nextTick(() => {
e.target.blur()
const index = i + 1
that.$refs['input' + index].focus()
})
}
} else {
playAudio(true)
this.$message.error({
message: '数据库中无对应数据location:' + this.queryForm.location,
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value1 = ''
this.queryForm.location = ''
this.incomeWmsLabelList.pn = ''
this.queryForm.value2 = ''
}
}
})
} else {
playAudio(true)
// 输入值不符合格式要求,进行报错处理
this.$message.error({
message: '输入值不符合格式要求,请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value1 = ''
}
}
}
})
},
/**
* @description: 一开始将焦点聚焦到第一个输入框下
* @author: gaoyu
* @param:
* @return:
**/
focusing() {
this.$nextTick().then(() => {
this.$refs.input1.focus()
})
},
/**
* @description: 监听第二个输入框,回车将输入添加到数组中
* @author: gaoyu
* @param:
* @return:
**/
addList() {
const values = this.queryForm.value2.split(',')
// 校验第三个值是否为整数
// if (/^\d+$/.test(values[3])) {
const obj = {
whId: this.queryForm.whId,
location: this.queryForm.location,
pn: values[0],
lot: values[1],
qty: this.checkQtyByUnit(values),
cheBzq: this.formatCheBzq(values[2]),
cheUnit: values[4],
cheCjName: values[5],
labelId: this.incomeWmsLabelList.businessId,
orderCode: this.incomeWmsBoxList.order_code
}
if (this.queryForm.value2.split(',') && values.length === 6 && values.every(value => value !== '')) {
// this.incomeWmsBoxList.pn = values[1]
if (obj.labelId !== null && obj.labelId !== '' && obj.labelId !== undefined) {
if (this.incomeWmsLabelList.pn && this.incomeWmsLabelList.pn !== '' && this.incomeWmsLabelList.pn !== undefined) {
if (customUpperCase(obj.pn) !== customUpperCase(this.incomeWmsLabelList.pn)) {
playAudio(true)
this.$message.error({
message: '输入的pn值:' + obj.pn + '与数据库中pn值:' + this.incomeWmsLabelList.pn + '不匹配,请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
// this.incomeWmsBoxList.pn = obj.pn
} else {
this.cheCj = obj.cheCjName
let isLegalLot = false
this.enterTable.forEach(item => {
if (customUpperCase(item.lot) === customUpperCase(obj.lot)) {
isLegalLot = true
}
})
if (isLegalLot) {
if (customUpperCase(this.enterTable[0].pn) === customUpperCase(obj.pn)) {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
} else {
playAudio(true)
this.$message.error({
message: '与下方列表的pn:' + this.enterTable[0].pn + '不匹配',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
}
} else {
const Zbj = {
lot: obj.lot
}
checkIsZero(Zbj).then(res => {
if (res.code === 200) {
if (res.data) {
if (this.enterTable.length > 0) {
if (customUpperCase(this.enterTable[0].pn) === customUpperCase(obj.pn)) {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
} else {
playAudio(true)
this.$message.error({
message: '与下方列表的pn:' + this.enterTable[0].pn + '不匹配',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
}
} else {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
}
} else {
// 创建一个新的音频元素
playAudio(true)
this.$message.error({
message: '该LOT值' + obj.lot + '未被检查!',
duration: 2000,
onClose: () => {
// 当消息提示框关闭时停止播放声音
playAudio(false)
}
}, () => {
})
this.queryForm.value2 = null
}
}
})
}
}
} else {
const inputValues = this.queryForm.value1.split(',')
this.queryForm.location = inputValues[0].trim()
findByLocation(this.queryForm.location).then(res => {
if (res.code === 200) {
if (res.data != null) {
let isLegalLot = false
this.enterTable.forEach(item => {
if (customUpperCase(item.lot) === customUpperCase(obj.lot)) {
isLegalLot = true
}
})
if (isLegalLot) {
if (customUpperCase(this.enterTable[0].pn) === customUpperCase(obj.pn)) {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
} else {
playAudio(true)
this.$message.error({
message: '与下方列表的pn值' + this.enterTable[0].pn + '不匹配',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
}
} else {
const Zbj = {
lot: obj.lot
}
checkIsZero(Zbj).then(res => {
if (res.code === 200) {
if (res.data) {
if (this.enterTable.length > 0) {
if (customUpperCase(this.enterTable[0].pn) === customUpperCase(obj.pn)) {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
} else {
playAudio(true)
this.$message.error({
message: '与下方列表的pn值' + this.enterTable[0].pn + '不匹配',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
}
} else {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
}
} else {
playAudio(true)
this.$message.error({
message: '该LOT值' + obj.lot + '未被检查!',
duration: 2000,
onClose: () => {
// 当消息提示框关闭时停止播放声音
playAudio(false)
}
}, () => {
})
this.queryForm.value2 = null
}
}
})
}
} else {
playAudio(true)
this.$message.error({
message: '该location的值' + this.queryForm.location + '无效' + '请输入有效的location值',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.location = ''
}
}
})
}
} else {
playAudio(true)
this.$message.error({
message: '输入格式不符合要求,请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
}
// }
// else {
// this.$message.error('qty的值必须为整数!')
// }
} else {
const values = this.queryForm.value2.split(';')
// 校验第三个值是否为整数
// if (/^\d+$/.test(values[3])) {
console.log(1)
const obj = {
whId: this.queryForm.whId,
cj: this.queryForm.cj,
location: this.queryForm.location,
pn: values[0],
lot: values[1],
qty: this.checkQty(values[2]),
cheBzq: this.checkBzq(values[4]),
cheCjName: values[5],
labelId: this.incomeWmsLabelList.businessId,
orderCode: this.incomeWmsBoxList.order_code
}
if (this.queryForm.value2.split(';') && values.length === 6 && values.every(value => value !== '') && obj.qty !== '') {
if (obj.labelId !== null && obj.labelId !== '' && obj.labelId !== undefined) {
if (this.incomeWmsLabelList.pn && this.incomeWmsLabelList.pn !== '' && this.incomeWmsLabelList.pn !== undefined) {
if (customUpperCase(obj.pn) !== customUpperCase(this.incomeWmsLabelList.pn)) {
playAudio(true)
this.$message.error({
message: '输入的pn值:' + obj.pn + '与数据库中pn值:' + this.incomeWmsLabelList.pn + '不匹配,请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
// this.incomeWmsBoxList.pn = obj.pn
} else {
let isLegalLot = false
this.enterTable.forEach(item => {
if (customUpperCase(item.lot) === customUpperCase(obj.lot)) {
isLegalLot = true
}
})
if (isLegalLot) {
if (customUpperCase(this.enterTable[0].pn) === customUpperCase(obj.pn)) {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
} else {
playAudio(true)
this.$message.error({
message: '与下方列表的pn:' + this.enterTable[0].pn + '不匹配',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
}
} else {
const Zbj = {
lot: obj.lot
}
checkIsZero(Zbj).then(res => {
if (res.code === 200) {
if (res.data) {
if (this.enterTable.length > 0) {
if (customUpperCase(this.enterTable[0].pn) === customUpperCase(obj.pn)) {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
} else {
playAudio(true)
this.$message.error({
message: '与下方列表的pn:' + this.enterTable[0].pn + '不匹配',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
}
} else {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
}
} else {
// 创建一个新的音频元素
playAudio(true)
this.$message.error({
message: '该LOT值' + obj.lot + '未被检查!',
duration: 2000,
onClose: () => {
// 当消息提示框关闭时停止播放声音
playAudio(false)
}
}, () => {
})
this.queryForm.value2 = null
}
}
})
}
}
} else {
const inputValues = this.queryForm.value1.split(',')
this.queryForm.location = inputValues[0].trim()
findByLocation(this.queryForm.location).then(res => {
if (res.code === 200) {
if (res.data != null) {
let isLegalLot = false
this.enterTable.forEach(item => {
if (customUpperCase(item.lot) === customUpperCase(obj.lot)) {
isLegalLot = true
}
})
if (isLegalLot) {
if (customUpperCase(this.enterTable[0].pn) === customUpperCase(obj.pn)) {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
} else {
playAudio(true)
this.$message.error({
message: '与下方列表的pn值' + this.enterTable[0].pn + '不匹配',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
}
} else {
const Zbj = {
lot: obj.lot
}
checkIsZero(Zbj).then(res => {
if (res.code === 200) {
if (res.data) {
if (this.enterTable.length > 0) {
if (customUpperCase(this.enterTable[0].pn) === customUpperCase(obj.pn)) {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
} else {
playAudio(true)
this.$message.error({
message: '与下方列表的pn值' + this.enterTable[0].pn + '不匹配',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = null
}
} else {
successAudio(true)
this.enterTable.push(obj)
this.incomeWmsBoxList.pn = obj.pn
this.queryForm.value2 = ''
}
} else {
playAudio(true)
this.$message.error({
message: '该LOT值' + obj.lot + '未被检查!',
duration: 2000,
onClose: () => {
// 当消息提示框关闭时停止播放声音
playAudio(false)
}
}, () => {
})
this.queryForm.value2 = null
}
}
})
}
} else {
playAudio(true)
this.$message.error({
message: '该location的值' + this.queryForm.location + '无效' + '请输入有效的location值',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.location = ''
}
}
})
}
} else {
playAudio(true)
this.$message.error({
message: '输入格式不符合要求,请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = ''
}
} else {
playAudio(true)
this.$message.error({
message: '输入格式不符合要求,请重新输入',
duration: 2000,
onClose: () => {
playAudio(false)
}
})
this.queryForm.value2 = ''
}
}
},
/**
* @description: 删除数据中元素
* @author: gaoyu
* @param:
* @return:
**/
handleDelte(index) {
this.enterTable.splice(index, 1)
},
checkQty(str) {
if (typeof str !== 'string') {
return
}
const data = str.match(/^([a-zA-Z]+)(\d+)([a-zA-Z]+)$/)
if (data) {
const num = data[2]
const unit = customUpperCase(data[3])
if (unit === 'KG') {
return num * 1000
} else if (unit === 'G') {
return num
} else {
this.$message.error({
message: '输入数量格式不正确',
duration: 2000
})
}
} else {
this.$message.error({
message: '输入格式不正确',
duration: 2000
})
}
},
checkBzq(dateStr) {
const str = dateStr.substring(1)
const year = str.substring(0, 4)
const month = str.substring(4, 6).padStart(2, '0')
const day = str.substring(6, 8).padStart(2, '0')
return `${year}-${month}-${day}`
},
formatCheBzq(date) {
return date ? date.split(' ')[0].replace(/\//g, '-') : ''
},
checkQtyByUnit(data) {
const unit = customUpperCase(data[4])
if (unit === 'KG') {
return data[3] * 1000
} else if (unit === 'G') {
return data[3]
}
}
}
}
</script>
<style scoped lang="scss">
.storage{
display: flex;
justify-content: center;
.enterForm{
width: 96%;
.normalSelect{
width: 100%;
}
//.input1Font{
// width: 100%;
// justify-content: space-between;
// display: flex;
//}
.showPn{
width: 100%;
justify-content: space-between;
display: flex;
}
.tableTotal{
margin-top: 2%;
}
}
.buttonRegion{
margin-top: 20px;
display: flex;
justify-content: space-between;
.button_rowBtn{
font-size: 17px;
width: 120px;
}
}
.BottomContent{
margin-top: 5%;
display: flex;
justify-content: space-between;
.loginUser{
text-align: right;
margin-right: 0.7%;
}
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment