Bläddra i källkod

同步全局loading

xsh_1997 6 dagar sedan
förälder
incheckning
5de38b4a11

+ 2 - 1
ruoyi-ui/src/lang/bo/dataModel.js

@@ -18,7 +18,8 @@ export default {
18 18
     msgDelOk: "སུབ་ཟིན།",
19 19
     msgModOk: "བཟོ་བཅོས་ཟིན།",
20 20
     msgAddOk: "གསར་སྣོན་ཟིན།",
21
-    ruleLen100: "ཡིག་ཆ་100ལས་མི་ཆོག"
21
+    ruleLen100: "ཡིག་ཆ་100ལས་མི་ཆོག",
22
+    syncLoading: "གཞི་གྲངས་མཉམ་སྒྲིག་བཞིན... སྒུག་རོགས།"
22 23
   },
23 24
   status: {
24 25
     dash: "—"

+ 2 - 1
ruoyi-ui/src/lang/bo/livestockFinance.js

@@ -18,7 +18,8 @@ export default {
18 18
     unitStep: "གོམ།",
19 19
     unitHead: "ཨ།",
20 20
     yes: "ཡིན།",
21
-    no: "མིན།"
21
+    no: "མིན།",
22
+    syncLoading: "གཞི་གྲངས་མཉམ་སྒྲིག་བཞིན... སྒུག་རོགས།"
22 23
   },
23 24
   yakAsset: {
24 25
     queryYakNo: "འབྲོང་ཨང་།",

+ 2 - 1
ruoyi-ui/src/lang/zh/dataModel.js

@@ -18,7 +18,8 @@ export default {
18 18
     msgDelOk: "删除成功",
19 19
     msgModOk: "修改成功",
20 20
     msgAddOk: "新增成功",
21
-    ruleLen100: "长度不能超过 100 个字符"
21
+    ruleLen100: "长度不能超过 100 个字符",
22
+    syncLoading: "正在同步数据,请稍候..."
22 23
   },
23 24
   status: {
24 25
     dash: "—"

+ 2 - 1
ruoyi-ui/src/lang/zh/livestockFinance.js

@@ -18,7 +18,8 @@ export default {
18 18
     unitStep: "步",
19 19
     unitHead: "头",
20 20
     yes: "是",
21
-    no: "否"
21
+    no: "否",
22
+    syncLoading: "正在同步数据,请稍候..."
22 23
   },
23 24
   yakAsset: {
24 25
     queryYakNo: "牦牛编号",

+ 16 - 0
ruoyi-ui/src/mixins/dataModelLocaleMixin.js

@@ -24,6 +24,22 @@ export default {
24 24
         return this.$t("dataModel.yakDiseaseWarning.warningType9")
25 25
       }
26 26
       return this.$t("dataModel.status.dash")
27
+    },
28
+    /** 第三方数据同步,带全局 loading */
29
+    runSyncWithLoading(syncFn) {
30
+      if (this.syncing) {
31
+        return Promise.reject(new Error("syncing"))
32
+      }
33
+      let modalLoading = false
34
+      this.syncing = true
35
+      this.$modal.loading(this.dmCommon("syncLoading"))
36
+      modalLoading = true
37
+      return syncFn().finally(() => {
38
+        this.syncing = false
39
+        if (modalLoading) {
40
+          this.$modal.closeLoading()
41
+        }
42
+      })
27 43
     }
28 44
   }
29 45
 }

+ 16 - 0
ruoyi-ui/src/mixins/livestockFinanceLocaleMixin.js

@@ -12,6 +12,22 @@ export default {
12 12
     },
13 13
     lfCommon(key) {
14 14
       return this.$t(`livestockFinance.common.${key}`)
15
+    },
16
+    /** 第三方数据同步,带全局 loading */
17
+    runSyncWithLoading(syncFn) {
18
+      if (this.syncing) {
19
+        return Promise.reject(new Error("syncing"))
20
+      }
21
+      let modalLoading = false
22
+      this.syncing = true
23
+      this.$modal.loading(this.lfCommon("syncLoading"))
24
+      modalLoading = true
25
+      return syncFn().finally(() => {
26
+        this.syncing = false
27
+        if (modalLoading) {
28
+          this.$modal.closeLoading()
29
+        }
30
+      })
15 31
     }
16 32
   }
17 33
 }

+ 2 - 8
ruoyi-ui/src/views/dataModel/pasture/index.vue

@@ -292,11 +292,7 @@ export default {
292 292
       })
293 293
     },
294 294
     handleSync() {
295
-      if (this.syncing) {
296
-        return
297
-      }
298
-      this.syncing = true
299
-      syncPasture()
295
+      this.runSyncWithLoading(() => syncPasture())
300 296
         .then((res) => {
301 297
           const data = res.data || {}
302 298
           this.$modal.msgSuccess(
@@ -314,9 +310,7 @@ export default {
314 310
           }
315 311
           this.getList()
316 312
         })
317
-        .finally(() => {
318
-          this.syncing = false
319
-        })
313
+        .catch(() => {})
320 314
     }
321 315
   }
322 316
 }

+ 2 - 8
ruoyi-ui/src/views/dataModel/yakDiseaseWarning/index.vue

@@ -239,11 +239,7 @@ export default {
239 239
       this.assetDrawerOpen = true
240 240
     },
241 241
     handleSync() {
242
-      if (this.syncing) {
243
-        return
244
-      }
245
-      this.syncing = true
246
-      syncYakDiseaseWarning()
242
+      this.runSyncWithLoading(() => syncYakDiseaseWarning())
247 243
         .then((res) => {
248 244
           const data = res.data || {}
249 245
           this.$modal.msgSuccess(
@@ -258,9 +254,7 @@ export default {
258 254
           }
259 255
           this.getList()
260 256
         })
261
-        .finally(() => {
262
-          this.syncing = false
263
-        })
257
+        .catch(() => {})
264 258
     }
265 259
   }
266 260
 }

+ 2 - 8
ruoyi-ui/src/views/livestockFinance/yakAsset/index.vue

@@ -171,11 +171,7 @@ export default {
171 171
       this.detailOpen = true
172 172
     },
173 173
     handleSync() {
174
-      if (this.syncing) {
175
-        return
176
-      }
177
-      this.syncing = true
178
-      syncYakAsset()
174
+      this.runSyncWithLoading(() => syncYakAsset())
179 175
         .then((res) => {
180 176
           const data = res.data || {}
181 177
           const msg = this.lfT("syncSummary", {
@@ -189,9 +185,7 @@ export default {
189 185
           }
190 186
           this.getList()
191 187
         })
192
-        .finally(() => {
193
-          this.syncing = false
194
-        })
188
+        .catch(() => {})
195 189
     }
196 190
   }
197 191
 }