|
|
|
@ -441,7 +441,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { searchExpApplyList, submitExpApply, deleteExpApply, withdrawExpApply, getSubmitApprovers, getFlowStatus } from '@/api/erf/erf' |
|
|
|
import { searchExpApplyList, submitExpApply, deleteExpApply, withdrawExpApply, getSubmitApprovers, getFlowStatus, getTriConfirmList } from '@/api/erf/erf' |
|
|
|
import { getBuList } from '@/api/factory/site' |
|
|
|
import ExpApplyForm from './components/expApplyForm.vue' |
|
|
|
import ExpProjectDetail from './components/expProjectDetail.vue' |
|
|
|
@ -669,30 +669,77 @@ export default { |
|
|
|
submitApply(row) { |
|
|
|
// ✅ 如果是High Risk,先验证工序 |
|
|
|
if (row.experimentType === 'High Risk') { |
|
|
|
// 先选中该行,确保子组件加载 |
|
|
|
this.currentRow = row |
|
|
|
console.log('🔍 检测到High Risk申请单,开始验证工序...') |
|
|
|
|
|
|
|
// 等待DOM更新后再验证 |
|
|
|
this.$nextTick(() => { |
|
|
|
if (this.$refs.triConfirm && this.$refs.triConfirm.validateHighRiskProcess) { |
|
|
|
const isValid = this.$refs.triConfirm.validateHighRiskProcess() |
|
|
|
if (!isValid) { |
|
|
|
console.log('❌ High Risk验证失败,终止下达') |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.warn('⚠️ 未找到triConfirm组件或validateHighRiskProcess方法') |
|
|
|
// 通过API查询工序列表进行验证(不依赖子组件是否已加载) |
|
|
|
this.validateHighRiskProcessByApi(row.applyNo).then(isValid => { |
|
|
|
if (!isValid) { |
|
|
|
console.log('❌ High Risk验证失败,终止下达') |
|
|
|
this.$alert('High Risk申请单必须至少有一条完整的工序(包含车间、质量、技术三个负责人)才能下达', '操作提示', { |
|
|
|
confirmButtonText: '确定', |
|
|
|
type: 'warning' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
console.log('✅ High Risk验证通过,继续下达流程') |
|
|
|
// 验证通过后继续下达流程 |
|
|
|
this.proceedSubmit(row) |
|
|
|
}).catch(error => { |
|
|
|
console.error('❌ 验证工序异常:', error) |
|
|
|
this.$message.error('验证工序失败,请重试') |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 非High Risk直接下达 |
|
|
|
console.log('📝 Low Risk申请单,直接下达') |
|
|
|
this.proceedSubmit(row) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 通过API验证High Risk工序 |
|
|
|
* |
|
|
|
* @param {String} applyNo 申请单号 |
|
|
|
* @return {Promise<Boolean>} 验证结果 |
|
|
|
*/ |
|
|
|
validateHighRiskProcessByApi(applyNo) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
// 调用API查询工序列表 |
|
|
|
getTriConfirmList({ applyNo: applyNo }).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
const processList = data.list || [] |
|
|
|
console.log('📊 查询到工序数量:', processList.length) |
|
|
|
|
|
|
|
// 检查是否至少有一条完整的工序 |
|
|
|
const completeProcesses = processList.filter(process => { |
|
|
|
const isComplete = process.prodApproverName && |
|
|
|
process.qaApproverName && |
|
|
|
process.techApproverName |
|
|
|
|
|
|
|
if (isComplete) { |
|
|
|
console.log('✅ 完整工序:', process.processStep, { |
|
|
|
车间: process.prodApproverName, |
|
|
|
质量: process.qaApproverName, |
|
|
|
技术: process.techApproverName |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
return isComplete |
|
|
|
}) |
|
|
|
|
|
|
|
console.log(`📈 完整工序数量: ${completeProcesses.length}/${processList.length}`) |
|
|
|
|
|
|
|
// 至少需要一条完整的工序 |
|
|
|
resolve(completeProcesses.length > 0) |
|
|
|
} else { |
|
|
|
reject(new Error(data.msg || '查询工序列表失败')) |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
reject(error) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 执行下达流程 |
|
|
|
*/ |
|
|
|
|