Bläddra i källkod

fix:根据状态展示任务计划的合格数\不合格数

sunqijun 2 veckor sedan
förälder
incheckning
40e0c124f7

+ 29 - 3
src/views/production-safety/hiddenTroubleInvestigationAndGovernance/areaCheckPlanManagement/components/areaCheckPlanManagementDetail.vue

@@ -181,15 +181,20 @@
         <template #status="scope">
           <span>{{ STATUS_LABEL[scope.row.status] || '-' }}</span>
         </template>
+        <template #qualifiedItemNum="scope">
+          <span>{{ formatRecordItemNumDisplay(scope.row.qualifiedItemNum, scope.row.status) }}</span>
+        </template>
         <template #unqualifiedItemNum="scope">
           <el-button
+            v-if="isNonZeroUnqualifiedCount(scope.row.unqualifiedItemNum, scope.row.status)"
             type="primary"
             link
             size="small"
-            @click="openUnqualifiedDialog(scope.row)"
+            @click.stop="openUnqualifiedDialog(scope.row)"
           >
-            {{ scope.row.unqualifiedItemNum ?? 0 }}
+            {{ Number(scope.row.unqualifiedItemNum) }}
           </el-button>
+          <span v-else>{{ formatRecordItemNumDisplay(scope.row.unqualifiedItemNum, scope.row.status) }}</span>
         </template>
         <template #sign="scope">
           <template v-if="scope.row.checkedPersonSign.length">
@@ -679,6 +684,27 @@
   const router = useRouter();
   const route = useRoute();
 
+  /**
+   * 合格/不合格项数展示:status=1(待检查)时空或 0 显示「-」;其余状态显示数字(含 0)
+   */
+  function formatRecordItemNumDisplay(v: unknown, status: unknown) {
+    const isPending = Number(status) === 1;
+    const n = v === null || v === undefined || v === '' ? NaN : Number(v);
+    if (isPending) {
+      if (v === null || v === undefined || v === '' || Number.isNaN(n) || n === 0) return '-';
+      return String(n);
+    }
+    if (v === null || v === undefined || v === '') return '0';
+    if (Number.isNaN(n)) return '0';
+    return String(n);
+  }
+
+  /** 不合格项数为-不展示弹框 */
+  function isNonZeroUnqualifiedCount(v: unknown, status: unknown) {
+    if (Number(status) === 1 && !v) return false;
+    return true
+  }
+
   const operate = computed(() => (route.query.operate as string) || 'area-check-plan-create');
   const currentId = computed(() => Number(route.query.id));
   const isCreateMode = computed(() => operate.value === 'area-check-plan-create');
@@ -1056,7 +1082,7 @@
     { label: '检查场所类别', prop: 'checkPlaceCategory', minWidth: '160px' },
     { label: '检查场所', prop: 'checkPlace', minWidth: '160px' },
     { label: '检查项总数', prop: 'checkItemTotal', align: 'center', width: '160px' },
-    { label: '合格项数', prop: 'qualifiedItemNum', align: 'center', width: '120px' },
+    { label: '合格项数', prop: 'qualifiedItemNum', slot: 'qualifiedItemNum', align: 'center', width: '120px' },
     { label: '不合格项数', prop: 'unqualifiedItemNum', slot: 'unqualifiedItemNum', align: 'center', width: '180px' },
     { label: '整体检查情况描述', prop: 'overallCheckDesc', minWidth: '180px', showOverflowTooltip: true },
     { label: '被检查人签字', slot: 'sign', align: 'center', width: '200px' },

+ 29 - 3
src/views/production-safety/hiddenTroubleInvestigationAndGovernance/areaCheckPlanManagementDept/components/areaCheckPlanManagementDeptDetail.vue

@@ -183,15 +183,20 @@
         <template #status="scope">
           <span>{{ STATUS_LABEL[scope.row.status] || '-' }}</span>
         </template>
+        <template #qualifiedItemNum="scope">
+          <span>{{ formatRecordItemNumDisplay(scope.row.qualifiedItemNum, scope.row.status) }}</span>
+        </template>
         <template #unqualifiedItemNum="scope">
           <el-button
+            v-if="isNonZeroUnqualifiedCount(scope.row.unqualifiedItemNum, scope.row.status)"
             type="primary"
             link
             size="small"
-            @click="openUnqualifiedDialog(scope.row)"
+            @click.stop="openUnqualifiedDialog(scope.row)"
           >
-            {{ scope.row.unqualifiedItemNum ?? 0 }}
+            {{ Number(scope.row.unqualifiedItemNum) }}
           </el-button>
+          <span v-else>{{ formatRecordItemNumDisplay(scope.row.unqualifiedItemNum, scope.row.status) }}</span>
         </template>
         <template #sign="scope">
           <template v-if="scope.row.checkedPersonSign.length">
@@ -505,6 +510,27 @@
   const router = useRouter();
   const route = useRoute();
 
+  /**
+   * 合格/不合格项数展示:status=1(待检查)时空或 0 显示「-」;其余状态显示数字(含 0)
+   */
+  function formatRecordItemNumDisplay(v: unknown, status: unknown) {
+    const isPending = Number(status) === 1;
+    const n = v === null || v === undefined || v === '' ? NaN : Number(v);
+    if (isPending) {
+      if (v === null || v === undefined || v === '' || Number.isNaN(n) || n === 0) return '-';
+      return String(n);
+    }
+    if (v === null || v === undefined || v === '') return '0';
+    if (Number.isNaN(n)) return '0';
+    return String(n);
+  }
+
+  /** 不合格项数为-不展示弹框 */
+  function isNonZeroUnqualifiedCount(v: unknown, status: unknown) {
+    if (Number(status) === 1 && !v) return false;
+    return true
+  }
+
   const currentId = computed(() => Number(route.query.id));
 
   const viewDetailData = ref<Record<string, unknown>>({});
@@ -588,7 +614,7 @@
     { label: '检查场所类别', prop: 'checkPlaceCategory', minWidth: '160px' },
     { label: '检查场所', prop: 'checkPlace', minWidth: '180px' },
     { label: '检查项总数', prop: 'checkItemTotal', align: 'center', width: '160px' },
-    { label: '合格项数', prop: 'qualifiedItemNum', align: 'center', width: '140px' },
+    { label: '合格项数', prop: 'qualifiedItemNum', slot: 'qualifiedItemNum', align: 'center', width: '140px' },
     { label: '不合格项数', prop: 'unqualifiedItemNum', slot: 'unqualifiedItemNum', align: 'center', width: '160px' },
     { label: '整体检查情况描述', prop: 'overallCheckDesc', minWidth: '190px', showOverflowTooltip: true },
     { label: '被检查人签字', slot: 'sign', align: 'center', width: '180px' },

+ 29 - 2
src/views/production-safety/hiddenTroubleInvestigationAndGovernance/areaCheckPlanTask/areaCheckPlanTask.vue

@@ -85,10 +85,15 @@
               }}</span>
             </template>
             <template #qualifiedItemNum="scope">
-              <span>{{ scope.row.qualifiedItemNum ?? 0 }}</span>
+              <span>{{ formatRecordItemNumDisplay(scope.row.qualifiedItemNum, scope.row.status) }}</span>
             </template>
             <template #unqualifiedItemNum="scope">
-              <span style="color:#1777ff;cursor: pointer;"  @click="openUnqualifiedDialog(scope.row)">{{ scope.row.unqualifiedItemNum ?? 0}}</span>
+              <span
+                v-if="isNonZeroUnqualifiedCount(scope.row.unqualifiedItemNum, scope.row.status)"
+                style="color: #1777ff; cursor: pointer"
+                @click.stop="openUnqualifiedDialog(scope.row)"
+              >{{ Number(scope.row.unqualifiedItemNum) }}</span>
+              <span v-else>{{ formatRecordItemNumDisplay(scope.row.unqualifiedItemNum, scope.row.status) }}</span>
             </template>
             <template #action="scope">
               <div class="action-container--div" style="justify-content: flex-start">
@@ -371,6 +376,28 @@
   import { useFormConfigHook } from '@/hooks/useFormConfigHook';
   import { HIDDEN_DANGER_FORM_CONFIG, HIDDEN_DANGER_FORM_RULES, REASON_OPTIONS, HIDDEN_DANGER_FORM_DATA } from "./configs/form"
   const router = useRouter();
+
+  /**
+   * 合格/不合格项数展示:status=1(待检查)时空或 0 显示「-」;其余状态显示数字(含 0)
+   */
+  function formatRecordItemNumDisplay(v: unknown, status: unknown) {
+    const isPending = Number(status) === 1;
+    const n = v === null || v === undefined || v === '' ? NaN : Number(v);
+    if (isPending) {
+      if (v === null || v === undefined || v === '' || Number.isNaN(n) || n === 0) return '-';
+      return String(n);
+    }
+    if (v === null || v === undefined || v === '') return '0';
+    if (Number.isNaN(n)) return '0';
+    return String(n);
+  }
+
+  /** 不合格项数为-不展示弹框 */
+  function isNonZeroUnqualifiedCount(v: unknown, status: unknown) {
+    if (Number(status) === 1 && !v) return false;
+    return true
+  }
+
   const basicTableRef = ref<InstanceType<typeof BasicTable>>();
   const { tableConfig, pagination } = useTableConfig(AREA_CHECK_PLAN_TABLE_COLUMNS, TABLE_OPTIONS);
   const tableData = ref<AreaCheckPlanRecord[]>([]);

+ 29 - 2
src/views/production-safety/hiddenTroubleInvestigationAndGovernance/areaCheckPlanTaskDept/areaCheckPlanTaskDept.vue

@@ -85,10 +85,15 @@
               }}</span>
             </template>
             <template #qualifiedItemNum="scope">
-              <span>{{ scope.row.qualifiedItemNum ?? 0 }}</span>
+              <span>{{ formatRecordItemNumDisplay(scope.row.qualifiedItemNum, scope.row.status) }}</span>
             </template>
             <template #unqualifiedItemNum="scope">
-              <span style="color:#1777ff;cursor: pointer;"  @click="openUnqualifiedDialog(scope.row)">{{ scope.row.unqualifiedItemNum ?? 0 }}</span>
+              <span
+                v-if="isNonZeroUnqualifiedCount(scope.row.unqualifiedItemNum, scope.row.status)"
+                style="color: #1777ff; cursor: pointer"
+                @click.stop="openUnqualifiedDialog(scope.row)"
+              >{{ Number(scope.row.unqualifiedItemNum) }}</span>
+              <span v-else>{{ formatRecordItemNumDisplay(scope.row.unqualifiedItemNum, scope.row.status) }}</span>
             </template>
             <template #action="scope">
               <div class="action-container--div" style="justify-content: left">
@@ -377,6 +382,28 @@
   import { useFormConfigHook } from '@/hooks/useFormConfigHook';
   import { HIDDEN_DANGER_FORM_CONFIG, HIDDEN_DANGER_FORM_RULES, REASON_OPTIONS, HIDDEN_DANGER_FORM_DATA } from "./configs/form"
   const router = useRouter();
+
+  /**
+   * 合格/不合格项数展示:status=1(待检查)时空或 0 显示「-」;其余状态显示数字(含 0)
+   */
+  function formatRecordItemNumDisplay(v: unknown, status: unknown) {
+    const isPending = Number(status) === 1;
+    const n = v === null || v === undefined || v === '' ? NaN : Number(v);
+    if (isPending) {
+      if (v === null || v === undefined || v === '' || Number.isNaN(n) || n === 0) return '-';
+      return String(n);
+    }
+    if (v === null || v === undefined || v === '') return '0';
+    if (Number.isNaN(n)) return '0';
+    return String(n);
+  }
+
+  /** 不合格项数为-不展示弹框 */
+  function isNonZeroUnqualifiedCount(v: unknown, status: unknown) {
+    if (Number(status) === 1 && !v) return false;
+    return true
+  }
+
   const { id } = useUserInfoHook();
   const basicTableRef = ref<InstanceType<typeof BasicTable>>();
   const { tableConfig, pagination } = useTableConfig(AREA_CHECK_PLAN_TABLE_COLUMNS, TABLE_OPTIONS);