Quellcode durchsuchen

运行记录填报修改

yanghao vor 3 Wochen
Ursprung
Commit
3b3afc2189
2 geänderte Dateien mit 41 neuen und 8 gelöschten Zeilen
  1. 1 1
      config/env.dev.js
  2. 40 7
      pages/recordFilling/detail.vue

+ 1 - 1
config/env.dev.js

@@ -1,7 +1,7 @@
 // 开发环境配置
 export default {
   // apiUrl: "https://iot.deepoil.cc:5443",
-  apiUrl: "http://192.168.188.86:48080",
+  apiUrl: "https://iot.deepoil.cc:5443",
   // apiUrl: "https://aims.deepoil.cc", //正式
   apiUrlSuffix: "/admin-api",
   // 其他开发环境配置...

+ 40 - 7
pages/recordFilling/detail.vue

@@ -1413,9 +1413,38 @@ const isSubmitting = ref(false); // 添加提交状态
 //   submitDataWithDisable();
 // };
 
-const formRef = ref(null);
-
-const onSubmit = async () => {
+const formRef = ref(null);
+
+const isBlankValue = (value) =>
+  value === null || value === undefined || value === "";
+
+const validateReportMalfunction = (item) => {
+  if (
+    !["ry", "rh"].includes(deptName.value) ||
+    item.deviceName !== "生产日报"
+  ) {
+    return true;
+  }
+
+  const nonSumList = Array.isArray(item.nonSumList) ? item.nonSumList : [];
+  const accidentTime = nonSumList.find((nosum) => nosum.name === "工程质量H");
+  const malfunction = nonSumList.find((nosum) => nosum.name === "故障情况");
+
+  if (
+    Number(accidentTime?.fillContent || 0) > 0 &&
+    isBlankValue(malfunction?.fillContent)
+  ) {
+    uni.showToast({
+      title: "工程质量H大于0时,故障情况必填",
+      icon: "none",
+    });
+    return false;
+  }
+
+  return true;
+};
+
+const onSubmit = async () => {
   try {
     if (formRef.value) {
       for (const item of formRef.value) {
@@ -1438,10 +1467,14 @@ const onSubmit = async () => {
   }
 
   // 1. 校验所有必填项 - 在这里进行所有基础校验
-  for (const item of dataList.value) {
-    const nonSumList = Array.isArray(item.nonSumList) ? item.nonSumList : [];
-
-    // 查找当日运转时间H项目
+  for (const item of dataList.value) {
+    const nonSumList = Array.isArray(item.nonSumList) ? item.nonSumList : [];
+
+    if (!validateReportMalfunction(item)) {
+      return;
+    }
+
+    // 查找当日运转时间H项目
 
     const otherNptTime = nonSumList.find((i) => i.name === "其他非生产时间H");
     const runtimeItem = nonSumList.find((i) => i.name === "当日运转时间H");