yanghao před 1 týdnem
rodič
revize
eb22461e2d
2 změnil soubory, kde provedl 52 přidání a 39 odebrání
  1. 1 1
      .env.local
  2. 51 38
      src/views/pms/iotrhdailyreport/rh-form.vue

+ 1 - 1
.env.local

@@ -4,7 +4,7 @@ NODE_ENV=development
 VITE_DEV=true
 
 # 请求路径  http://192.168.188.60:48080  https://iot.deepoil.cc:5443  http://172.26.0.56:48080  http://192.168.188.198:48080
-VITE_BASE_URL='https://iot.deepoil.cc:5443'
+VITE_BASE_URL='http://192.168.188.86:48080'
 
 # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
 VITE_UPLOAD_TYPE=server

+ 51 - 38
src/views/pms/iotrhdailyreport/rh-form.vue

@@ -66,6 +66,7 @@ interface FormOriginal {
   otherNptReason: string
 
   productionStatus: string
+  malfunction: string
   remark: string
   relocationDays: number
   capacity: number
@@ -91,6 +92,7 @@ const FORM_KEYS: (keyof FormOriginal)[] = [
   'dailyInjectWaterTime',
   'constructionStatus',
   'productionStatus',
+  'malfunction',
   'remark',
   'relocationDays',
   'capacity',
@@ -244,6 +246,15 @@ const validateOtherReason = (_rule: any, value: any, callback: any) => {
   }
 }
 
+const validateMalfunction = (_rule: any, value: any, callback: any) => {
+  const accidentTime = Number(form.value.accidentTime || 0)
+  if (accidentTime > 0 && !String(value || '').trim()) {
+    callback(new Error('工程质量大于0时,故障情况必填'))
+  } else {
+    callback()
+  }
+}
+
 // 动态构建校验规则
 const rules = reactive<FormRules>({
   dailyGasInjection: [{ required: true, message: '请输入当日注气量', trigger: ['blur', 'change'] }],
@@ -259,6 +270,7 @@ const rules = reactive<FormRules>({
     { validator: validateTotalTime(), trigger: ['blur', 'change'] }
   ],
   dailyInjectWaterTime: [{ validator: validateTotalTime(), trigger: ['blur', 'change'] }],
+  malfunction: [{ validator: validateMalfunction, trigger: ['blur', 'change'] }],
   otherNptReason: [{ validator: validateOtherReason, trigger: ['blur', 'change'] }]
 })
 
@@ -289,6 +301,17 @@ watch(
   { deep: true }
 )
 
+watch(
+  () => form.value.accidentTime,
+  () => {
+    if (!isMainFieldDisabled.value) {
+      nextTick(() => {
+        formRef.value?.validateField('malfunction')
+      })
+    }
+  }
+)
+
 // --- 提交 ---
 const submitForm = async () => {
   if (!formRef.value) return
@@ -336,8 +359,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
     :model-value="visible"
     @update:model-value="emits('update:visible', $event)"
     header-class="mb-0!"
-    size="50%"
-  >
+    size="50%">
     <template #header>
       <span class="text-xl font-bold text-[var(--el-text-color-primary)]">
         {{ type === 'edit' ? '编辑日报' : '审批日报' }}
@@ -352,13 +374,11 @@ const handleAudit = async (auditStatus: 20 | 30) => {
       :model="form"
       v-loading="loading"
       require-asterisk-position="right"
-      :disabled="formType === 'readonly' && type !== 'approval'"
-    >
+      :disabled="formType === 'readonly' && type !== 'approval'">
       <!-- 顶部提示区 -->
       <div class="flex flex-col gap-3 text-sm mb-4">
         <div
-          class="rounded-md border border-blue-100 bg-blue-50/80 p-3 dark:border-blue-900/30 dark:bg-blue-900/10"
-        >
+          class="rounded-md border border-blue-100 bg-blue-50/80 p-3 dark:border-blue-900/30 dark:bg-blue-900/10">
           <div class="flex flex-col gap-2.5">
             <div class="flex items-center justify-between">
               <div class="text-gray-600 dark:text-gray-400">
@@ -366,8 +386,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
                 当日注气量 / 产能
               </div>
               <span
-                class="inline-flex items-center rounded border border-red-200 bg-red-100 px-2 py-0.5 text-xs font-medium text-red-600 dark:bg-red-900/20 dark:border-red-800 dark:text-red-400"
-              >
+                class="inline-flex items-center rounded border border-red-200 bg-red-100 px-2 py-0.5 text-xs font-medium text-red-600 dark:bg-red-900/20 dark:border-red-800 dark:text-red-400">
                 >120% 红色预警
               </span>
             </div>
@@ -380,12 +399,10 @@ const handleAudit = async (auditStatus: 20 | 30) => {
         </div>
         <div
           v-if="isEdit && form.opinion"
-          class="flex gap-3 rounded-md border border-yellow-200 bg-yellow-50 p-3 dark:border-yellow-800 dark:bg-yellow-900/10"
-        >
+          class="flex gap-3 rounded-md border border-yellow-200 bg-yellow-50 p-3 dark:border-yellow-800 dark:bg-yellow-900/10">
           <Icon
             icon="ep:warning-filled"
-            class="mt-0.5 shrink-0 text-base text-yellow-600 dark:text-yellow-500"
-          />
+            class="mt-0.5 shrink-0 text-base text-yellow-600 dark:text-yellow-500" />
           <div class="flex flex-col">
             <h4 class="mb-1 font-bold text-yellow-800 dark:text-yellow-500">审核意见</h4>
             <p class="leading-relaxed text-gray-600 dark:text-gray-400">{{ form.opinion }}</p>
@@ -415,22 +432,19 @@ const handleAudit = async (auditStatus: 20 | 30) => {
           <el-input
             :model-value="transitTime.value"
             disabled
-            :class="{ 'warning-input': transitTime.original > 1.2 }"
-          />
+            :class="{ 'warning-input': transitTime.original > 1.2 }" />
         </el-form-item>
         <el-form-item label="施工状态" prop="constructionStatus">
           <el-select
             v-model="form.constructionStatus"
             placeholder="请选择施工状态"
             :disabled="isMainFieldDisabled"
-            clearable
-          >
+            clearable>
             <el-option
               v-for="(dict, index) in getStrDictOptions(DICT_TYPE.PMS_PROJECT_TASK_SCHEDULE)"
               :key="index"
               :label="dict.label"
-              :value="dict.value"
-            />
+              :value="dict.value" />
           </el-select>
         </el-form-item>
         <el-form-item label="当日注气量(方)" prop="dailyGasInjection">
@@ -440,8 +454,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
             v-model="form.dailyGasInjection"
             :controls="false"
             align="left"
-            :disabled="isMainFieldDisabled"
-          />
+            :disabled="isMainFieldDisabled" />
         </el-form-item>
         <el-form-item label="当日注水量(方)" prop="dailyWaterInjection">
           <el-input-number
@@ -450,8 +463,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
             v-model="form.dailyWaterInjection"
             :controls="false"
             align="left"
-            :disabled="isMainFieldDisabled"
-          />
+            :disabled="isMainFieldDisabled" />
         </el-form-item>
         <el-form-item class="col-span-2" label="施工区域" prop="location">
           <el-input v-model="form.location" disabled />
@@ -462,8 +474,16 @@ const handleAudit = async (auditStatus: 20 | 30) => {
             type="textarea"
             autosize
             maxlength="1000"
-            :disabled="isMainFieldDisabled"
-          />
+            :disabled="isMainFieldDisabled" />
+        </el-form-item>
+
+        <el-form-item class="col-span-2" label="故障情况" prop="malfunction">
+          <el-input
+            v-model="form.malfunction"
+            type="textarea"
+            autosize
+            maxlength="1000"
+            :disabled="isMainFieldDisabled" />
         </el-form-item>
         <el-form-item class="col-span-2" label="备注" prop="remark">
           <el-input
@@ -471,8 +491,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
             type="textarea"
             autosize
             maxlength="1000"
-            :disabled="isMainFieldDisabled"
-          />
+            :disabled="isMainFieldDisabled" />
         </el-form-item>
 
         <!-- 时间信息 -->
@@ -492,8 +511,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
             :controls="false"
             align="left"
             placeholder="注气+非生产=24H"
-            :disabled="isMainFieldDisabled"
-          />
+            :disabled="isMainFieldDisabled" />
         </el-form-item>
         <el-form-item label="当日注水时间(H)" prop="dailyInjectWaterTime">
           <el-input-number
@@ -504,8 +522,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
             :controls="false"
             align="left"
             placeholder="注气=0时,注水+非生产=24H"
-            :disabled="isMainFieldDisabled"
-          />
+            :disabled="isMainFieldDisabled" />
         </el-form-item>
 
         <!-- 循环渲染11个具体非生产时间 -->
@@ -513,8 +530,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
           v-for="field in NON_PROD_FIELDS"
           :key="field.key"
           :label="field.label + '(H)'"
-          :prop="field.key"
-        >
+          :prop="field.key">
           <el-input-number
             class="!w-full"
             :min="0"
@@ -522,8 +538,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
             v-model="form[field.key as keyof FormOriginal]"
             :controls="false"
             align="left"
-            :disabled="isMainFieldDisabled"
-          />
+            :disabled="isMainFieldDisabled" />
         </el-form-item>
 
         <!-- 其他非生产原因 -->
@@ -531,8 +546,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
           <el-input
             v-model="form.otherNptReason"
             placeholder="请输入其他非生产原因"
-            :disabled="isMainFieldDisabled"
-          />
+            :disabled="isMainFieldDisabled" />
         </el-form-item>
 
         <!-- 审批意见 -->
@@ -544,8 +558,7 @@ const handleAudit = async (auditStatus: 20 | 30) => {
               maxlength="1000"
               type="textarea"
               :autosize="{ minRows: 3 }"
-              :disabled="formType === 'readonly'"
-            />
+              :disabled="formType === 'readonly'" />
           </el-form-item>
         </div>
       </div>