소스 검색

fix: 加班功能

chenzhen2 2 년 전
부모
커밋
f4dd86d0c9
2개의 변경된 파일22개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 0
      src/main.ts
  2. 20 5
      src/views/envmonitor/components/workOvertime/index.vue

+ 2 - 0
src/main.ts

@@ -10,6 +10,8 @@ import { Toast, Icon, Tab, Tabs, Loading, Popup } from 'vant'
 import '@/permission'
 
 const app = createApp(App)
+
+// Toast.setDefaultOptions()
 const loadingStart = (duration: any = 0) => {
   Toast.loading({
     duration: duration, // 持续展示 toast

+ 20 - 5
src/views/envmonitor/components/workOvertime/index.vue

@@ -67,6 +67,7 @@ import {
   onUpdated,
   nextTick,
   watch,
+  getCurrentInstance,
 } from "vue";
 import { swiper } from "@/utils/swiper";
 import {
@@ -100,6 +101,7 @@ export default defineComponent({
     },
   },
   setup(props, context) {
+    const proxyGlobal: any = getCurrentInstance();
     const screenInfo: any = {
       screenWidth: 0,
       screenHeight: 0,
@@ -982,11 +984,24 @@ export default defineComponent({
       },
       // 提交加班记录
       saveBatchCustomScene(formTimerArr: any, type: any = 1) {
-        saveBatchCustomScene(formTimerArr).then((res) => {
-          if (type === 1) {
-            context.emit("closeWork");
-          }
-        });
+        proxyGlobal.proxy.$loadingStart(0);
+        proxyData.formBtn = true;
+        saveBatchCustomScene(formTimerArr)
+          .then((res) => {
+            let timer: any = setTimeout(() => {
+              proxyGlobal.proxy.$loadinngEnd();
+              if (type === 1) {
+                context.emit("closeWork");
+              }
+              timer = null;
+              clearTimeout(timer);
+              proxyData.formBtn = false;
+            }, 1000);
+          })
+          .catch(() => {
+            proxyGlobal.proxy.$loadinngEnd();
+            proxyData.formBtn = false;
+          });
       },
       // 删除
       triggerDelTime() {