|
@@ -787,6 +787,12 @@ const getMaterialCount = (bomNodeId: number) => {
|
|
|
return materialList.value.filter(item => item.bomNodeId === bomNodeId).length
|
|
|
}
|
|
|
|
|
|
+const hasDelay = (row) => {
|
|
|
+ return row.delayKilometers > 0 ||
|
|
|
+ row.delayNaturalDate > 0 ||
|
|
|
+ row.delayDuration > 0
|
|
|
+}
|
|
|
+
|
|
|
const close = () => {
|
|
|
delView(unref(currentRoute))
|
|
|
push({ name: 'IotMainWorkOrder', params:{}})
|
|
@@ -856,10 +862,8 @@ const configFormRules = reactive({
|
|
|
const validateTableData = (): boolean => {
|
|
|
let isValid = true
|
|
|
const errorMessages: string[] = []
|
|
|
- const noRulesErrorMessages: string[] = [] // 未设置任何保养项规则 的错误提示信息
|
|
|
- const noRules: string[] = [] // 行记录中设置了保养规则的记录数量
|
|
|
- const configErrors: string[] = [] // 保养规则配置弹出框
|
|
|
let shouldBreak = false;
|
|
|
+ const materialRequiredErrors: string[] = [] // 物料必填错误
|
|
|
|
|
|
if (list.value.length === 0) {
|
|
|
errorMessages.push('工单明细不存在')
|
|
@@ -869,6 +873,26 @@ const validateTableData = (): boolean => {
|
|
|
return isValid
|
|
|
}
|
|
|
|
|
|
+ // 新增物料必填校验(仅在非委外模式下检查)
|
|
|
+ if (formData.value.outsourcingFlag !== 1) { // 非委外模式
|
|
|
+ list.value.forEach((row, index) => {
|
|
|
+ const rowNumber = index + 1
|
|
|
+ const deviceIdentifier = `${row.deviceCode}-${row.name}`
|
|
|
+
|
|
|
+ // 检查是否设置了推迟保养
|
|
|
+ const hasDelay =
|
|
|
+ (row.delayKilometers || 0) > 0 ||
|
|
|
+ (row.delayNaturalDate || 0) > 0 ||
|
|
|
+ (row.delayDuration || 0) > 0
|
|
|
+
|
|
|
+ // 未设置推迟保养且未选择物料
|
|
|
+ if (!hasDelay && getMaterialCount(row.bomNodeId) === 0) {
|
|
|
+ materialRequiredErrors.push(`第${rowNumber}行【${deviceIdentifier}】必须选择物料`)
|
|
|
+ isValid = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
list.value.forEach((row, index) => {
|
|
|
if (shouldBreak) return;
|
|
|
const rowNumber = index + 1 // 用户可见的行号从1开始
|
|
@@ -881,9 +905,15 @@ const validateTableData = (): boolean => {
|
|
|
if (errorMessages.length > 0) {
|
|
|
message.error('设备状态错误')
|
|
|
}
|
|
|
+ // 合并错误信息
|
|
|
+ if (materialRequiredErrors.length > 0) {
|
|
|
+ message.error(materialRequiredErrors.join('\n'))
|
|
|
+ }
|
|
|
return isValid
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/** 重置表单 */
|
|
|
const resetForm = () => {
|
|
|
formData.value = {
|