Commit 943407cf authored by shifangwuji's avatar shifangwuji

9/22(last)

parent 0462a7c3
...@@ -85,22 +85,22 @@ ...@@ -85,22 +85,22 @@
<hr style="margin: 0 0 20px 0; width: 81%" /> <hr style="margin: 0 0 20px 0; width: 81%" />
<!-- jbcod 输入框 --> <!-- wjb 输入框 -->
<el-row :gutter="40"> <el-row :gutter="40">
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
label="jbcode:" label="jbcode:"
style="flex-basis: 50%" style="flex-basis: 50%"
prop="jbcod" prop="wjb"
> >
<el-input <el-input
ref="input5" ref="input5"
v-model="form.jbcod" v-model="form.wjb"
placeholder="请输入jbcode" placeholder="请输入jbcode"
:minlength="3" :minlength="3"
style="width: 868px" style="width: 868px"
:maxlength="100" :maxlength="100"
:disabled="!jbcodEnabled" :disabled="!wjbEnabled"
@keyup.enter.native="handleTab(4, $event)" @keyup.enter.native="handleTab(4, $event)"
/> />
</el-form-item> </el-form-item>
...@@ -387,7 +387,7 @@ export default { ...@@ -387,7 +387,7 @@ export default {
name: 'Role', name: 'Role',
data() { data() {
return { return {
jbcodEnabled: false, wjbEnabled: false,
wbcodeEnabled: false, wbcodeEnabled: false,
wblotEnabled: false, wblotEnabled: false,
jlcodEnabled: false, jlcodEnabled: false,
...@@ -406,7 +406,7 @@ export default { ...@@ -406,7 +406,7 @@ export default {
lot: '', lot: '',
gx: '', gx: '',
machine: '', machine: '',
jbcod: '', wjb: '',
jbcode: '', jbcode: '',
jbrank: '', jbrank: '',
jblot: '', jblot: '',
...@@ -421,10 +421,10 @@ export default { ...@@ -421,10 +421,10 @@ export default {
lot: [{ required: true, message: '请输入lot', trigger: 'blur' }], lot: [{ required: true, message: '请输入lot', trigger: 'blur' }],
gx: [{ required: true, message: '请选择gx', trigger: 'blur' }], gx: [{ required: true, message: '请选择gx', trigger: 'blur' }],
machine: [{ required: true, message: '请输入machine', trigger: 'blur' }], machine: [{ required: true, message: '请输入machine', trigger: 'blur' }],
jbcod: [ wjb: [
{ {
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
this.validateJbcod(value, callback); this.validateWjb(value, callback);
}, },
trigger: 'blur', trigger: 'blur',
}, },
...@@ -469,16 +469,16 @@ export default { ...@@ -469,16 +469,16 @@ export default {
} }
}, },
watch: { watch: {
'form.jbcod': { 'form.wjb': {
handler(newJbcod) { handler(newWjb) {
if (newJbcod) { if (newWjb) {
// 检查是否为空或未定义 // 检查是否为空或未定义
const parts = newJbcod.split(',') const parts = newWjb.split(',')
this.form.jbcode = parts[0] || '' this.form.jbcode = parts[0] || ''
this.form.jbrank = parts[1] || '' this.form.jbrank = parts[1] || ''
this.form.jblot = parts[2] || '' this.form.jblot = parts[2] || ''
} else { } else {
// 如果 newJbcod 为空,可以选择在这里重置相关字段 // 如果 newWjb 为空,可以选择在这里重置相关字段
this.form.jbcode = '' this.form.jbcode = ''
this.form.jbrank = '' this.form.jbrank = ''
this.form.jblot = '' this.form.jblot = ''
...@@ -525,18 +525,24 @@ export default { ...@@ -525,18 +525,24 @@ export default {
this.init() this.init()
}, },
methods: { methods: {
validateJbcod(value, callback) { validateWjb(value, callback) {
if (this.jbcodEnabled) { if (this.wjbEnabled) {
// 检查是否开启验证 // 检查是否开启验证
if (value) { if (value) {
}else { // 检查是否为空或未定义
callback(new Error('jbcode不能为空')); const parts = value.split(',');
} const jbcode = parts[0];
if (!jbcod || !jbcode || !jbrank || !jblot) { const jbrank = parts[1];
const jblot = parts[2];
if (!jbcode || !jbrank || !jblot) {
callback(new Error('jbtype、jbrank、jblot不能为空')); callback(new Error('jbtype、jbrank、jblot不能为空'));
} else { } else {
callback(); callback();
} }
} else {
callback(new Error('jbcode不能为空'));
}
} else { } else {
callback(); // 如果验证未开启,直接通过 callback(); // 如果验证未开启,直接通过
} }
...@@ -546,18 +552,27 @@ export default { ...@@ -546,18 +552,27 @@ export default {
if (this.jlcodEnabled) { if (this.jlcodEnabled) {
// 检查是否开启验证 // 检查是否开启验证
if (value) { if (value) {
// 检查是否为空或未定义
const parts = value.split(',');
const jlname = parts[0];
const jllot = parts[1];
const jlvalidDate = parts[2];
if (!jlname || !jllot || !jlvalidDate) {
callback(new Error('jltype、jllot、jlvalidDate不能为空'));
} else { } else {
callback(new Error('jlcod不能为空')); callback();
} }
if (!jlcod || !jlname || !jllot || !jlvalidDate) {
callback(new Error('jltype、jllot、jlbzq不能为空'));
} else { } else {
callback(); callback(new Error('jlcod不能为空'));
} }
} else { } else {
callback(); // 如果验证未开启,直接通过 callback(); // 如果验证未开启,直接通过
} }
}, },
validateField(value, callback, fieldName) { validateField(value, callback, fieldName) {
if (this[fieldName + 'Enabled']) { if (this[fieldName + 'Enabled']) {
// 检查是否开启验证 // 检查是否开启验证
...@@ -599,9 +614,9 @@ export default { ...@@ -599,9 +614,9 @@ export default {
this.queryInputsEnabled = true this.queryInputsEnabled = true
console.log('data', response.data) console.log('data', response.data)
if (response.data.jbcode !== '') { if (response.data.jbcode !== '') {
this.jbcodEnabled = true this.wjbEnabled = true
}else{ }else{
this.jbcodEnabled = false this.wjbEnabled = false
} }
if (response.data.wb !== '') { if (response.data.wb !== '') {
this.wbcodeEnabled = true this.wbcodeEnabled = true
...@@ -621,14 +636,14 @@ export default { ...@@ -621,14 +636,14 @@ export default {
response.data.jl === '' response.data.jl === ''
) { ) {
// 所有输入框都锁定,报错 // 所有输入框都锁定,报错
this.jbcodEnabled = false this.wjbEnabled = false
this.wbcodeEnabled = false this.wbcodeEnabled = false
this.wblotEnabled = false this.wblotEnabled = false
this.jlcodEnabled = false this.jlcodEnabled = false
this.queryInputsEnabled = true this.queryInputsEnabled = true
this.lockUserEnabled = true this.lockUserEnabled = true
this.unlockButtonVisible = true this.unlockButtonVisible = true
this.form.jbcod = '' this.form.wjb = ''
this.form.wbcode = '' this.form.wbcode = ''
this.form.wblot = '' this.form.wblot = ''
this.form.jlcod = '' this.form.jlcod = ''
...@@ -647,7 +662,7 @@ export default { ...@@ -647,7 +662,7 @@ export default {
.catch(() => { .catch(() => {
console.log('Setting lockUserEnabled to true') console.log('Setting lockUserEnabled to true')
// 查询失败时,将所有输入框锁定并显示错误提示 // 查询失败时,将所有输入框锁定并显示错误提示
this.jbcodEnabled = false this.wjbEnabled = false
this.wbcodeEnabled = false this.wbcodeEnabled = false
this.wblotEnabled = false this.wblotEnabled = false
this.jlcodEnabled = false this.jlcodEnabled = false
...@@ -674,7 +689,7 @@ export default { ...@@ -674,7 +689,7 @@ export default {
lot: this.form.lot, lot: this.form.lot,
gx: this.form.gx, gx: this.form.gx,
machine: this.form.machine, machine: this.form.machine,
jbcod: this.form.jbcod, wjb: this.form.wjb,
jbcode: this.form.jbcode, jbcode: this.form.jbcode,
jbrank: this.form.jbrank, jbrank: this.form.jbrank,
jblot: this.form.jblot, jblot: this.form.jblot,
...@@ -685,10 +700,25 @@ export default { ...@@ -685,10 +700,25 @@ export default {
}).then(response => { }).then(response => {
if (response.code === 200) { if (response.code === 200) {
// 解锁成功,恢复页面状态 // 解锁成功,恢复页面状态
this.jbcodEnabled = false if (!this.form.wjb) {
this.wbcodeEnabled = false this.wjbEnabled = false;
this.wblotEnabled = false } else {
this.jlcodEnabled = false this.wjbEnabled = true;
}
if (!this.form.wbcode && !this.form.wblot) {
this.wbcodeEnabled = false;
this.wblotEnabled = false;
} else {
this.wbcodeEnabled = true;
this.wblotEnabled = true;
}
if (!this.form.jlcod) {
this.jlcodEnabled = false;
} else {
this.jlcodEnabled = true;
}
this.lockUserEnabled = false this.lockUserEnabled = false
this.queryInputsEnabled = false this.queryInputsEnabled = false
this.unlockButtonVisible = false this.unlockButtonVisible = false
...@@ -729,7 +759,7 @@ export default { ...@@ -729,7 +759,7 @@ export default {
lot: '', lot: '',
gx: '', gx: '',
machine: '', machine: '',
jbcod: '', wjb: '',
jbcode: '', jbcode: '',
jbrank: '', jbrank: '',
jblot: '', jblot: '',
...@@ -740,7 +770,7 @@ export default { ...@@ -740,7 +770,7 @@ export default {
unlockUsername: '' unlockUsername: ''
} }
this.queryInputsEnabled = false this.queryInputsEnabled = false
this.jbcodEnabled = false this.wjbEnabled = false
this.wbcodeEnabled = false this.wbcodeEnabled = false
this.wblotEnabled = false this.wblotEnabled = false
this.jlcodEnabled = false this.jlcodEnabled = false
...@@ -798,7 +828,7 @@ export default { ...@@ -798,7 +828,7 @@ export default {
if (res.code === 200) { if (res.code === 200) {
if (res.data !== null) { if (res.data !== null) {
// 保存成功,重置表单和字段状态 // 保存成功,重置表单和字段状态
this.jbcodEnabled = false this.wjbEnabled = false
this.wbcodeEnabled = false this.wbcodeEnabled = false
this.wblotEnabled = false this.wblotEnabled = false
this.jlcodEnabled = false this.jlcodEnabled = false
...@@ -806,7 +836,7 @@ export default { ...@@ -806,7 +836,7 @@ export default {
this.queryInputsEnabled = false this.queryInputsEnabled = false
this.unlockButtonVisible = false this.unlockButtonVisible = false
this.queryButtonVisible = true this.queryButtonVisible = true
this.form.jbcod = '' this.form.wjb = ''
this.form.wbcode = '' this.form.wbcode = ''
this.form.wblot = '' this.form.wblot = ''
this.form.jlcod = '' this.form.jlcod = ''
...@@ -828,7 +858,7 @@ export default { ...@@ -828,7 +858,7 @@ export default {
.catch(() => { .catch(() => {
// 请求失败,设置字段状态 // 请求失败,设置字段状态
this.setFieldEnabledStatus(false) this.setFieldEnabledStatus(false)
this.jbcodEnabled = false this.wjbEnabled = false
this.wbcodeEnabled = false this.wbcodeEnabled = false
this.wblotEnabled = false this.wblotEnabled = false
this.jlcodEnabled = false this.jlcodEnabled = false
...@@ -849,7 +879,7 @@ export default { ...@@ -849,7 +879,7 @@ export default {
}, },
// 设置字段状态 // 设置字段状态
setFieldEnabledStatus(enabled) { setFieldEnabledStatus(enabled) {
this.jbcodEnabled = enabled this.wjbEnabled = enabled
this.wbcodeEnabled = enabled this.wbcodeEnabled = enabled
this.wblotEnabled = enabled this.wblotEnabled = enabled
this.jlcodEnabled = enabled this.jlcodEnabled = enabled
......
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