Commit bad1e7cb authored by shifangwuji's avatar shifangwuji

first

parent a7a34648
...@@ -88,18 +88,18 @@ ...@@ -88,18 +88,18 @@
</el-col> </el-col>
</el-row> </el-row>
<!-- 提取 jbtype、jbrank 和 jbLot --> <!-- 提取 ptype、jbrank 和 jbLot -->
<el-row :gutter="0" style="display: flex; width: 81%;"> <el-row :gutter="0" style="display: flex; width: 81%;">
<el-col :span="8"> <el-col :span="8">
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="jbtype:" prop="jbtype"> <el-form-item label="jbtype:" prop="ptype">
<template v-if="form.jbtype && form.jbtype.length > 21"> <template v-if="form.ptype && form.ptype.length > 21">
<el-tooltip :content="form.jbtype" effect="dark"> <el-tooltip :content="form.ptype" effect="dark">
<el-input v-model="form.jbtype" placeholder="jbtype" :disabled="true" style="width: 100%;" /> <el-input v-model="form.ptype" placeholder="ptype" :disabled="true" style="width: 100%;" />
</el-tooltip> </el-tooltip>
</template> </template>
<template v-else> <template v-else>
<el-input v-model="form.jbtype" placeholder="jbtype" :disabled="true" style="width: 100%;" /> <el-input v-model="form.ptype" placeholder="ptype" :disabled="true" style="width: 100%;" />
</template> </template>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -281,7 +281,7 @@ export default { ...@@ -281,7 +281,7 @@ export default {
gx: '', gx: '',
machine: '', machine: '',
jbcode: '', jbcode: '',
jbtype: '', ptype: '',
jbrank: '', jbrank: '',
jbLot: '', jbLot: '',
jlcod: '', jlcod: '',
...@@ -314,7 +314,7 @@ export default { ...@@ -314,7 +314,7 @@ export default {
handler(newJbcode) { handler(newJbcode) {
// 当 jbcode 字段发生变化时,解析它并更新相关字段的值 // 当 jbcode 字段发生变化时,解析它并更新相关字段的值
const parts = newJbcode.split(',') const parts = newJbcode.split(',')
this.form.jbtype = parts[0] || '' this.form.ptype = parts[0] || ''
this.form.jbrank = parts[1] || '' this.form.jbrank = parts[1] || ''
this.form.jbLot = parts[2] || '' this.form.jbLot = parts[2] || ''
}, },
...@@ -326,31 +326,10 @@ export default { ...@@ -326,31 +326,10 @@ export default {
const parts = newJlcod.split(',') const parts = newJlcod.split(',')
this.form.jltype = parts[0] || '' this.form.jltype = parts[0] || ''
this.form.jllot = parts[1] || '' this.form.jllot = parts[1] || ''
this.form.jlbzq = parts[2] || ''
// 获取 jlbzqPart
const jlbzqPart = parts[2] || ''
// 检查 jlbzqPart 是否有数据
if (jlbzqPart.trim() !== '') {
// 验证并格式化 jlbzq
const jlbzqRegex = /^\d{4}-\d{2}-\d{2}$/ // 正则表达式用于验证 'yyyy-mm-dd' 格式
if (jlbzqRegex.test(jlbzqPart)) {
this.form.jlbzq = jlbzqPart
} else {
// 如果不符合规范,可以设置一个默认值或者给出错误提示
this.form.jlbzq = '' // 或者设置一个默认值
// 或者显示错误提示
MessageBox.alert('jlcod 中的 jlbzq 不符合规范,请输入有效的日期格式(yyyy-mm-dd)', '错误', {
confirmButtonText: '确定',
type: 'error'
})
}
}
}, },
immediate: true // 立即执行一次以处理初始值 immediate: true // 立即执行一次以处理初始值
} }
}, },
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
...@@ -426,7 +405,7 @@ export default { ...@@ -426,7 +405,7 @@ export default {
}) })
} }
} else if (response.code === 400) { } else {
console.log('Setting lockUserEnabled to true'); console.log('Setting lockUserEnabled to true');
// 查询失败时,将所有输入框锁定并显示错误提示 // 查询失败时,将所有输入框锁定并显示错误提示
this.jbcodeEnabled = false; this.jbcodeEnabled = false;
...@@ -544,40 +523,82 @@ export default { ...@@ -544,40 +523,82 @@ export default {
}).then(() => { }).then(() => {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
addApplication(this.form).then(res => { // 验证通过,继续处理 jlbzq 字段
console.log('res', res) const jlcodParts = this.form.jlcod.split(',')
if (res.code === 200) { const jlbzqPart = jlcodParts[2] || ''
if (res.data !== null) {
if (res.data.ptype === '1') { if (jlbzqPart.trim() !== '') {
this.$message({ const jlbzqRegex = /^\d{4}-\d{2}-\d{2}$/ // 正则表达式用于验证 'yyyy-mm-dd' 格式
showClose: true, if (jlbzqRegex.test(jlbzqPart)) {
message: '保存成功', // jlbzq 格式正确,可以继续保存操作
type: 'success', addApplication(this.form).then(res => {
duration: 5000 console.log('res', res)
}) if (res.code === 200) {
} else if (res.data.ptype === '2') { if (res.data !== null) {
this.$message({
showClose: true,
message: '保存成功',
type: 'success',
duration: 5000
})
}
this.resetForm()
} else if (res.code === null) {
this.$message({ this.$message({
showClose: true, showClose: true,
message: '保存成功', message: res.message,
type: 'success', type: 'error',
duration: 5000 duration: 10000
}) })
} }
} })
this.resetFrom() } else {
} else if (res.code === null) { // jlbzq 格式不正确,显示错误提示
this.$message({ this.$message({
showClose: true, showClose: true,
message: res.message, message: 'jlcod 中的 jlbzq 不符合规范,请输入有效的日期格式(yyyy-mm-dd)',
type: 'error', type: 'error',
duration: 10000 duration: 5000
}) })
} }
}) } else {
// jlbzqPart 为空,可以继续保存操作
addApplication(this.form).then(res => {
console.log('res', res)
if (res.code === 200) {
if (res.data !== null) {
if (res.data.ptype === '1') {
this.$message({
showClose: true,
message: '保存成功',
type: 'success',
duration: 5000
})
} else if (res.data.ptype === '2') {
this.$message({
showClose: true,
message: '保存成功',
type: 'success',
duration: 5000
})
}
}
this.resetForm()
} else if (res.code === null) {
this.$message({
showClose: true,
message: res.message,
type: 'error',
duration: 10000
})
}
})
}
} }
}) })
}) })
}, },
// 调数据字典查询 // 调数据字典查询
getDict() { getDict() {
const obj = { const obj = {
......
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