|
|
@@ -135,7 +135,7 @@
|
|
|
'.fillContent'
|
|
|
"
|
|
|
label-position="top"
|
|
|
- :rules="getAttrRules(attrItem)">
|
|
|
+ :rules="rules[attrItem.description]">
|
|
|
<div v-if="fillStatus === '1'">
|
|
|
<el-select
|
|
|
disabled
|
|
|
@@ -691,25 +691,6 @@ const validateOtherReason = (_rule: any, value: any, callback: any) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const validateFaultSituation = (_rule: any, value: any, callback: any) => {
|
|
|
- if (!['ry', 'rh'].includes(companyName.value)) {
|
|
|
- callback()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- const engineeringQuality = Number(
|
|
|
- attrList.value.find((item) => item.name === '工程质量H')?.fillContent || 0
|
|
|
- )
|
|
|
- const hasFaultSituation = value !== undefined && value !== null && String(value).trim() !== ''
|
|
|
-
|
|
|
- if (engineeringQuality > 0 && !hasFaultSituation) {
|
|
|
- callback(new Error('工程质量H大于0时,故障情况必填'))
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- callback()
|
|
|
-}
|
|
|
-
|
|
|
const rules = reactive<FormRules>({
|
|
|
dailyInjectGasTime: [
|
|
|
{ required: true, message: '请输入当日运转时间' },
|
|
|
@@ -757,20 +738,24 @@ const rules = reactive<FormRules>({
|
|
|
otherNptReason: [{ validator: validateOtherReason }]
|
|
|
})
|
|
|
|
|
|
-const getAttrRules = (attrItem: any) => {
|
|
|
- const baseRules = rules[attrItem.description]
|
|
|
-
|
|
|
- if (attrItem.name !== '故障情况') {
|
|
|
- return baseRules
|
|
|
+const checkFaultSituationBeforeSubmit = async () => {
|
|
|
+ if (!['ry', 'rh'].includes(companyName.value)) {
|
|
|
+ return true
|
|
|
}
|
|
|
|
|
|
- const normalizedRules = Array.isArray(baseRules) ? [...baseRules] : baseRules ? [baseRules] : []
|
|
|
- normalizedRules.push({
|
|
|
- validator: validateFaultSituation,
|
|
|
- trigger: ['blur', 'change']
|
|
|
- })
|
|
|
+ const engineeringQuality = Number(
|
|
|
+ attrList.value.find((item) => item.name === '工程质量H')?.fillContent || 0
|
|
|
+ )
|
|
|
+ const faultSituation = attrList.value.find((item) => item.name === '故障情况')?.fillContent
|
|
|
+ const hasFaultSituation =
|
|
|
+ faultSituation !== undefined && faultSituation !== null && String(faultSituation).trim() !== ''
|
|
|
+
|
|
|
+ if (engineeringQuality > 0 && !hasFaultSituation) {
|
|
|
+ await message.alert('非生产时间中工程质量H大于0时,请填写故障情况')
|
|
|
+ return false
|
|
|
+ }
|
|
|
|
|
|
- return normalizedRules
|
|
|
+ return true
|
|
|
}
|
|
|
|
|
|
const totalValidatorComputed = computed(() => {
|
|
|
@@ -1070,6 +1055,11 @@ const getFillInfo = async () => {
|
|
|
const validations = formRef.value.map((form) => form.validate())
|
|
|
await Promise.all(validations)
|
|
|
|
|
|
+ const canSubmit = await checkFaultSituationBeforeSubmit()
|
|
|
+ if (!canSubmit) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
const company = await IotOpeationFillApi.getOrgName(route.params.id.toString().split(',')[0])
|
|
|
|
|
|
if (devName != '生产日报') {
|