Просмотр исходного кода

运行记录填报优化-保存加载判断

zhouql 2 недель назад
Родитель
Сommit
9e84d3177e
2 измененных файлов с 37 добавлено и 25 удалено
  1. 1 0
      locale/zh-Hans.json
  2. 36 25
      pages/recordFilling/detail.vue

+ 1 - 0
locale/zh-Hans.json

@@ -169,6 +169,7 @@
   "operationRecordFilling.totalDeviceCount": "应填设备数",
   "operationRecordFilling.filledDeviceCount": "已填设备数",
   "operationRecordFilling.unfilledDeviceCount": "未填设备数",
+  "operationRecordFilling.PleaseLoadAllItems": "请加载所有填报项后再提交",
   // --------------------------------------- 状态相关 ----------------------------------------
   "status.enable": "启用",
   "status.disable": "停用",

+ 36 - 25
pages/recordFilling/detail.vue

@@ -166,7 +166,7 @@
         type="primary"
         @click="onSubmit()"
         :disabled="dataList.length < totalNum"
-        v-if="isView && dataList.length === totalNum"
+        v-if="isView"
       >
         {{ $t("operation.save") }}
       </button>
@@ -469,7 +469,9 @@ const queryList = (pageNo, pageSize) => {
           });
           console.log("resAttrs-modelId", resAttrs);
         }
+        return item;
       });
+
       console.log("resList--", resList);
       // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
       paging.value.complete(resList);
@@ -525,6 +527,14 @@ const toFixed = (num) => {
 
 const onSubmit = async () => {
   // console.log("onSubmit", dataList.value);
+  // 校验是否所有待填写项都已加载
+  if (dataList.value.length < totalNum) {
+    uni.showToast({
+      title: t("operationRecordFilling.PleaseLoadAllItems"),
+      icon: "none",
+    });
+    return; // 校验失败直接返回
+  }
   // 1. 校验所有必填项
   // 遍历dataList.value中nonSumList每个item(非生产日报 isReport!=1)的fillContent字段,
   // 如果为null或者为空,则提示用户填写,
@@ -618,37 +628,35 @@ const onSubmit = async () => {
   await recordFillingDetailInsertDataList(submitList)
     .then(async (res) => {
       console.log("🚀 ~ 提交工单填报内容结果 ~ res:", res);
-      setTimeout(async () => {
-        if (res?.code === 0) {
-          // 3. 调用更新工单状态接口
-          const upRes = await recordFillingUpOperationOrder({
-            id: params.value.orderId,
+      if (res?.code === 0) {
+        // 3. 调用更新工单状态接口
+        const upRes = await recordFillingUpOperationOrder({
+          id: params.value.orderId,
+        });
+        console.log("🚀 ~ upRes:", upRes);
+        if (upRes?.code === 0) {
+          console.log("工单状态更新成功");
+          uni.showToast({
+            title: t("operation.success"),
+            duration: 1500,
+            icon: "none",
           });
-          console.log("🚀 ~ upRes:", upRes);
-          if (upRes?.code === 0) {
-            console.log("工单状态更新成功");
-            uni.showToast({
-              title: t("operation.success"),
-              duration: 1500,
-              icon: "none",
-            });
-            setTimeout(() => {
-              uni.navigateBack();
-            }, 1500);
-          } else {
-            console.error("工单状态更新失败", upRes);
-            uni.showToast({
-              title: t("operation.fail"),
-              icon: "none",
-            });
-          }
+          setTimeout(() => {
+            uni.navigateBack();
+          }, 1500);
         } else {
+          console.error("工单状态更新失败", upRes);
           uni.showToast({
             title: t("operation.fail"),
             icon: "none",
           });
         }
-      }, 5000);
+      } else {
+        uni.showToast({
+          title: t("operation.fail"),
+          icon: "none",
+        });
+      }
     })
     .catch((error) => {
       console.error("保存失败", error);
@@ -767,6 +775,9 @@ const onSubmit = async () => {
 }
 :deep(.uni-select__input-text) {
   text-align: right;
+  .align-left {
+    text-align: right;
+  }
 }
 :deep(.uni-select--disabled) {
   color: #d5d5d5 !important;