| | |
| | | this.$message.error("请选择实验调度"); |
| | | return false; |
| | | } |
| | | |
| | | // 校验实验日期 |
| | | if (!this.form.experimentDate) { |
| | | this.$message.error("请填写实验日期"); |
| | | return false; |
| | | } |
| | | |
| | | // 校验参与人员 |
| | | if ( |
| | | !this.selectedParticipants || |
| | |
| | | this.$message.error("请选择参与人员"); |
| | | return false; |
| | | } |
| | | |
| | | // 校验实验目的 |
| | | const purpose = this.$refs.purposeEditor.getContent(); |
| | | if (!purpose || purpose === "<p></p>" || purpose.trim() === "<p></p>") { |
| | | this.$message.error("请填写实验目的"); |
| | | return false; |
| | | } |
| | | |
| | | // 校验工艺参数及路线 |
| | | const process = this.$refs.processEditor.getContent(); |
| | | if (!process || process === "<p></p>" || process.trim() === "<p></p>") { |
| | | this.$message.error("请填写工艺参数及路线"); |
| | | return false; |
| | | } |
| | | |
| | | // 校验 DynamicComponent 里的表格 |
| | | function checkDynamicComponentTables(list, label) { |
| | | if (!Array.isArray(list)) return true; |
| | | for (const comp of list) { |
| | | if (comp.type === 'customTable') { |
| | | if (!comp.data || !Array.isArray(comp.data.headers) || comp.data.headers.length === 0) { |
| | | this.$message.error(`${label}中有表格未添加表头`); |
| | | return false; |
| | | } |
| | | if (!Array.isArray(comp.data.rows) || comp.data.rows.length === 0) { |
| | | this.$message.error(`${label}中有表格未添加数据`); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | // 校验实验材料 |
| | | if (!this.form.experimentMaterial) { |
| | | this.$message.error("请添加实验材料"); |
| | | return false; |
| | | } |
| | | |
| | | if (!checkDynamicComponentTables.call(this, this.form.experimentMaterial, '实验材料')) { |
| | | return false; |
| | | } |
| | | // 校验实验设备 |
| | | if (!this.form.experimentDevice) { |
| | | this.$message.error("请添加实验设备"); |
| | | return false; |
| | | } |
| | | |
| | | if (!checkDynamicComponentTables.call(this, this.form.experimentDevice, '实验设备')) { |
| | | return false; |
| | | } |
| | | // 校验实验步骤记录 |
| | | if (!this.stepList || this.stepList.length === 0) { |
| | | this.$message.error("请添加实验操作步骤"); |
| | | return false; |
| | | } |
| | | |
| | | // 校验每个步骤是否都有内容 |
| | | const invalidStep = this.stepList.findIndex((step) => !step.content); |
| | | if (invalidStep !== -1) { |
| | | this.$message.error(`请完善第${invalidStep + 1}个步骤的内容`); |
| | | return false; |
| | | // 校验每个步骤是否都有内容及表格 |
| | | for (let i = 0; i < this.stepList.length; i++) { |
| | | const step = this.stepList[i]; |
| | | if (!step.content) { |
| | | this.$message.error(`请完善第${i + 1}个步骤的内容`); |
| | | return false; |
| | | } |
| | | if (!checkDynamicComponentTables.call(this, step.content, `第${i + 1}个步骤`)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | }, |
| | | handleStopExperiment() { |