Commit 75f6adf9 authored by shifangwuji's avatar shifangwuji

9/21测试版

parent 41899b23
...@@ -292,7 +292,42 @@ export default { ...@@ -292,7 +292,42 @@ export default {
pn: [{ required: true, message: '请输入pn', trigger: 'blur' }], pn: [{ required: true, message: '请输入pn', trigger: 'blur' }],
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' }],
jbcode: [
{
validator: (rule, value, callback) => {
this.validateField(value, callback, 'jbcode');
},
trigger: 'blur',
},
],
wbcode: [
{
validator: (rule, value, callback) => {
this.validateField(value, callback, 'wbcode');
},
trigger: 'blur',
},
],
wblot: [
{
validator: (rule, value, callback) => {
this.validateField(value, callback, 'wblot');
},
trigger: 'blur',
},
],
jlcod: [
{
validator: (rule, value, callback) => {
this.validateField(value, callback, 'jlcod');
},
trigger: 'blur',
},
],
}, },
pissbList: [], pissbList: [],
pgxList: [ pgxList: [
...@@ -348,6 +383,13 @@ export default { ...@@ -348,6 +383,13 @@ export default {
this.init() this.init()
}, },
methods: { methods: {
validateField(value, callback, fieldName) {
if (this[fieldName + 'Enabled'] && !value.trim()) {
callback(new Error(fieldName + '不能为空'));
} else {
callback();
}
},
handlePgxChange() { handlePgxChange() {
if (this.phdList.includes(this.form.pgx)) { if (this.phdList.includes(this.form.pgx)) {
this.isRequired = true this.isRequired = true
...@@ -519,60 +561,90 @@ export default { ...@@ -519,60 +561,90 @@ export default {
this.getDict() this.getDict()
}, },
// 保存时要调的接口 // 保存时要调的接口
// 提交表单
submitForm() { submitForm() {
this.$confirm('是否确认保存?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
//if(){
// 验证通过,继续处理 jlvalidDate 字段 // 验证通过,继续处理 jlvalidDate 字段
const jlcodParts = this.form.jlcod.split(',') const jlcodParts = this.form.jlcod.split(',');
const jlvalidDatePart = jlcodParts[2] || '' const jlvalidDatePart = jlcodParts[2] || '';
if (jlvalidDatePart.trim() !== '') { // 校验 jlvalidDate 字段格式
const jlvalidDateRegex = /^\d{4}\/\d{2}\/\d{2}$/ // 正则表达式用于验证 'yyyy/mm/dd' 格式 const jlvalidDateRegex = /^\d{4}\/\d{2}\/\d{2}$/; // yyyy/mm/dd 格式
if (jlvalidDateRegex.test(jlvalidDatePart)) { if (jlvalidDatePart.trim() === '' || jlvalidDateRegex.test(jlvalidDatePart)) {
// jlvalidDate 格式正确,可以继续保存操作 // 如果 jlvalidDate 符合格式或为空,执行保存操作
addApplication(this.form).then(res => { addApplication(this.form)
console.log('res', res) .then((res) => {
console.log('res', res);
if (res.code === 200) { if (res.code === 200) {
if (res.data !== null) { if (res.data !== null) {
// 保存成功,重置表单和字段状态
this.setFieldEnabledStatus(false);
this.form.jbcode = ''
this.form.wbcode = ''
this.form.wblot = ''
this.form.jlcod = ''
this.form.unlockUsername = ''
this.$message({ this.$message({
showClose: true, showClose: true,
message: '保存成功', message: '保存成功',
type: 'success', type: 'success',
duration: 5000 duration: 5000,
}) });
this.resetForm();
} }
this.resetForm() } else {
} else if (res.code === null) { // 保存失败,设置字段状态和显示错误消息
this.$message({ this.setFieldEnabledStatus(false);
showClose: true, this.showErrorMessage(res.message);
message: res.message,
type: 'error',
duration: 10000
})
} }
}) })
.catch(() => {
// 请求失败,设置字段状态
this.setFieldEnabledStatus(false);
this.showErrorMessage('保存失败');
this.jbcodeEnabled = false
this.wbcodeEnabled = false
this.wblotEnabled = false
this.jlcodEnabled = false
this.queryInputsEnabled = true
this.lockUserEnabled = true
this.unlockButtonVisible = true,
this.form.jbcode = ''
this.form.wbcode = ''
this.form.wblot = ''
this.form.jlcod = ''
this.form.lockUser = ''
});
} else { } else {
// jlvalidDate 格式不正确,显示错误提示 // jlvalidDate 不符合格式,显示错误消息
this.showErrorMessage('jlcod 中的 jlbzq 不符合规范,请输入有效的日期格式(yyyy/mm/dd)');
}
}
});
},
// 设置字段状态
setFieldEnabledStatus(enabled) {
this.jbcodeEnabled = enabled;
this.wbcodeEnabled = enabled;
this.wblotEnabled = enabled;
this.jlcodEnabled = enabled;
this.queryInputsEnabled = !enabled;
this.lockUserEnabled = enabled;
this.unlockButtonVisible = enabled;
},
// 显示错误消息
showErrorMessage(message) {
this.$message({ this.$message({
showClose: true, showClose: true,
message: 'jlcod 中的 jlbzq 不符合规范,请输入有效的日期格式(yyyy-mm-dd)', message,
type: 'error', type: 'error',
duration: 5000 duration: 5000,
}) });
}
}
//}
}
})
})
}, },
// 调数据字典查询 // 调数据字典查询
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