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,59 +561,89 @@ export default { ...@@ -519,59 +561,89 @@ export default {
this.getDict() this.getDict()
}, },
// 保存时要调的接口 // 保存时要调的接口
// 提交表单
submitForm() { submitForm() {
this.$confirm('是否确认保存?', '提示', { this.$refs.form.validate((valid) => {
confirmButtonText: '确定', if (valid) {
cancelButtonText: '取消', // 验证通过,继续处理 jlvalidDate 字段
type: 'warning' const jlcodParts = this.form.jlcod.split(',');
}).then(() => { const jlvalidDatePart = jlcodParts[2] || '';
this.$refs.form.validate((valid) => {
if (valid) {
//if(){
// 验证通过,继续处理 jlvalidDate 字段
const jlcodParts = this.form.jlcod.split(',')
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) => {
if (res.code === 200) { console.log('res', res);
if (res.data !== null) { if (res.code === 200) {
this.$message({ if (res.data !== null) {
showClose: true, // 保存成功,重置表单和字段状态
message: '保存成功', this.setFieldEnabledStatus(false);
type: 'success', this.form.jbcode = ''
duration: 5000 this.form.wbcode = ''
}) this.form.wblot = ''
} this.form.jlcod = ''
this.resetForm() this.form.unlockUsername = ''
} 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.resetForm();
} }
})
} else { } else {
// jlvalidDate 格式不正确,显示错误提示 // 保存失败,设置字段状态和显示错误消息
this.$message({ this.setFieldEnabledStatus(false);
showClose: true, this.showErrorMessage(res.message);
message: 'jlcod 中的 jlbzq 不符合规范,请输入有效的日期格式(yyyy-mm-dd)',
type: 'error',
duration: 5000
})
} }
} })
//} .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 {
// 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({
showClose: true,
message,
type: 'error',
duration: 5000,
});
},
// 调数据字典查询 // 调数据字典查询
getDict() { getDict() {
......
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