Commit fe05d6c5 authored by Hagsn3's avatar Hagsn3

提交代码

parent e27df32c
import request from '@/utils/request'
export function queryByPnAndType(data) {
return request({
url: '/incomematbaseinfo/queryByPnAndType',
method: 'post',
data,
headers: {
'Content-Type': 'application/json;charset=UTF-8' // 接口修改传参类型
}
})
}
......@@ -2,15 +2,15 @@
<div class="enterboundTwo">
<div class="enterForm">
<div class="search">
<el-form :model="form" ref="from" :rules="rules" label-width="80px" class="formClass" label-position="right">
<el-form ref="from" :model="form" :rules="rules" label-width="80px" class="formClass" label-position="right">
<el-form-item label="仓库:" prop="whId">
<el-select v-model="form.whId" filterable class="normalSelect" placeholder="请选择">
<el-option
v-for="(item,index) in warehouseList"
:key="index"
:label="item.dictLabel"
:value="item.dictValue">
</el-option>
:value="item.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item label="类型:" prop="ptype">
......@@ -19,12 +19,12 @@
v-for="(item,index) in typeList"
:key="index"
:label="item.label"
:value="item.value">
</el-option>
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="XX:" prop="value1">
<el-input ref="input1" v-model="form.value1" clearable @keyup.enter.native="handelTab(1,$event)"/>
<el-input ref="input1" v-model="form.value1" clearable @keyup.enter.native="handelTab(1,$event)" />
</el-form-item>
<el-form-item v-if="responsePn">
<div>
......@@ -32,10 +32,10 @@
</div>
</el-form-item>
<el-form-item label="pn:" prop="pn">
<el-input ref="input2" v-model="form.pn" clearable @keyup.enter.native="handelTab(2,$event)"/>
<el-input ref="input2" v-model="form.pn" clearable @keyup.enter.native="handelTab(2,$event)" />
</el-form-item>
<el-form-item label="数量:" prop="qty">
<el-input ref="input3" v-model="form.qty" :maxlength="4" clearable @keyup.enter.native="handelTab(3,$event)"/>
<el-input ref="input3" v-model="form.qty" :maxlength="4" clearable @keyup.enter.native="handelTab(3,$event)" />
</el-form-item>
</el-form>
</div>
......@@ -52,12 +52,13 @@
</template>
<script>
import {getDict} from "@/api/system/dict/data";
import {addIncomeWmsBox, getJcCode} from "@/api/incomeWmsBox";
import {findByLocation} from "@/api/incomeWmsLabel";
import { getDict } from '@/api/system/dict/data'
import { addIncomeWmsBox, getJcCode } from '@/api/incomeWmsBox'
import { findByLocation } from '@/api/incomeWmsLabel'
import { queryByPnAndType } from '@/api/income_mat_baseinfo'
export default {
name: "enterboundTwo",
name: 'EnterboundTwo',
data() {
return {
responsePn: '',
......@@ -69,7 +70,7 @@ export default {
value: '2'
},
{
label: 'wb',
label: 'wd',
value: '3'
},
{
......@@ -94,8 +95,9 @@ export default {
rules: {
value1: [
{ required: true, message: '请输入XX的值', trigger: 'blur' },
{ pattern: /^.*,.*/ | /^.*$/, message: '输入值不符合格式要求,请重新输入', trigger: 'blur' }
],
qty: [{validator: this.validatorQty,trigger: 'blur'}]
qty: [{ validator: this.validatorQty, trigger: 'blur' }]
}
}
},
......@@ -116,7 +118,7 @@ export default {
getDict('WAREHOUSE').then(res => {
console.log('仓库数据字典', res)
this.warehouseList = res.data
let whId = res.data[0].dictValue
const whId = res.data[0].dictValue
this.form.whId = whId
})
},
......@@ -138,14 +140,11 @@ export default {
* **/
switch (i) {
case 1:
this.validXX()
this.validXX(i, e)
break
case 2:
that.validPn()
}
e.target.blur()
const index = i + 1
that.$refs['input' + index].focus()
},
/**
* @description: 如果是1进入校验XX的校验
......@@ -153,18 +152,33 @@ export default {
* @param:
* @return:
**/
validXX() {
validXX(i, e) {
const that = this
if (!that.$refs['input' + i]) {
return
}
console.log('校验xx')
/**
* 1.判断xx是否包含,
* 2.如果包含的话判断是否根据,转成数组 取数组中的第一的数据
* **/
// var location = ''
// if (this.form.value1.includes(',')) {
// var list = this.form.value1.split(',')
// console.log(list)
// location = list[0]
// } else {
// location = this.form.value1
// console.log('location',location);
// }
var location = ''
if (this.form.value1.includes(',')) {
var list = this.form.value1.split(',')
if (this.form.value1.includes(',') || this.form.value1.includes(',')) {
var list = this.form.value1.split(/,|,/)
console.log(list)
location = list[0]
} else {
location = this.form.value1
console.log('location', location)
}
if (location && location !== '') {
findByLocation(location).then(res => {
......@@ -177,6 +191,13 @@ export default {
if (res.data.location) {
this.form.location = res.data.location
}
that.$nextTick(() => {
e.target.blur()
const index = i + 1
that.$refs['input' + index].focus()
})
} else {
this.$message.error('数据库中无对应值,请重新输入')
}
}
})
......@@ -191,13 +212,51 @@ export default {
* @return:
**/
validPn() {
/**
* responsePn:数据库pn
* form.pn:表格pn
*/
if (this.responsePn && this.responsePn !== '' && this.responsePn !== undefined) {
console.log('formPn', this.form.pn)
console.log('responsePn', this.responsePn)
if (this.form.pn !== this.responsePn) {
this.$message.error('您输入的pn与返回pn的不一样')
return false
} else {
const obj = {
pn: this.form.pn,
ptype: this.form.ptype
}
queryByPnAndType(obj).then(response => {
if (response.code === 200 && response.data !== null) {
console.log(response)
this.form.qty = response.data.qty
}
this.$nextTick().then(() => {
this.$refs.input3.focus()
})
})
return true
}
} else {
const obj = {
pn: this.form.pn,
ptype: this.form.ptype
}
queryByPnAndType(obj).then(response => {
if (response.code === 200 && response.data) {
console.log(response)
this.form.qty = response.data.qty
this.$nextTick().then(() => {
this.$refs.input3.focus()
})
} else {
this.$nextTick().then(() => {
this.$refs.input3.focus()
})
}
})
return true
}
return true
},
/**
* @description: 保存
......@@ -206,13 +265,16 @@ export default {
* @return:
**/
SubmitForm() {
console.log(11111111111)
this.$refs.from.validate(valid => {
if(valid && this.validPn()) {
console.log(2222222222222222222222)
if (valid && this.validPn()) {
this.form.qty = Number(this.form.qty)
addIncomeWmsBox(this.form).then(res => {
if (res.code === 200) {
this.resetForm()
this.$message.success('保存成功')
this.resetForm()
this.getOrderCode()
}
})
}
......@@ -270,9 +332,9 @@ export default {
this.getWarehouseList()
},
validatorQty(rule, value, callback) {
const reg = /^[1-9]\d*$/; // 正整数的正则表达式
const reg = /^[1-9]\d*$/ // 正整数的正则表达式
if (value && value !== '' && value !== undefined && !reg.test(value)) {
callback(new Error('请输入正整数'));
callback(new Error('请输入正整数'))
} else {
callback()
}
......
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