Selaa lähdekoodia

文件同步按钮加载

duy 1 kuukausi sitten
vanhempi
commit
971da35745
1 muutettua tiedostoa jossa 36 lisäystä ja 8 poistoa
  1. 36 8
      src/components/tree/hc-tree.vue

+ 36 - 8
src/components/tree/hc-tree.vue

@@ -60,7 +60,7 @@ import EditNodeDialog from '~src/components/dialog/EditNodeDialog.vue'
 import SortNodeDialog from '~src/components/dialog/SortNodeDialog.vue'
 import { HcDelMsg } from 'hc-vue3-ui'
 import initialgApi from '~api/initial/initial'
-
+import { ElLoadingService } from 'element-plus'
 //参数
 const props = defineProps({
     ui: {
@@ -504,7 +504,13 @@ const delNodeMoadl = (node) => {
 }
 
 //同步节点
-const syncNodeMoadl = (node)=>{
+
+const syncNodeMoadl = async (node) => {
+    // 显示加载状态
+    const loadingInstance = ElLoadingService({
+        lock: true,
+        text: '加载中...',
+    })
     window?.$messageBox?.alert('是否同步该节点?', '提示', {
         showCancelButton: true,
         confirmButtonText: '确认同步',
@@ -512,18 +518,30 @@ const syncNodeMoadl = (node)=>{
         callback: async (action) => {
             if (action === 'confirm') {
                 const { code } = await syncProjectTree({
-                    id:node.data.id,
+                    id: node.data.id,
                 })
-                if (code == 200) {
+                 // 隐藏加载状态
+                        loadingInstance.close()
+                if (code === 200) {
                     window.$message?.success('同步成功')
-                    window?.location?.reload() //刷新页面
+                    // 引入延迟,确保用户能看到提示信息
+                    setTimeout(() => {
+                        window?.location?.reload() // 刷新页面
+                       
+                    }, 1000) // 延迟2秒
                 }
+            } else {
+                loadingInstance.close()
             }
         },
     })
 }
 //文件同步
 const filesyncNodeMoadl = async (node, data)=>{
+    const loadingInstance = ElLoadingService({
+        lock: true,
+        text: '加载中...',
+    })
     window?.$messageBox?.alert('是否同步该节点?', '提示', {
         showCancelButton: true,
         confirmButtonText: '确认同步',
@@ -535,11 +553,21 @@ const filesyncNodeMoadl = async (node, data)=>{
                     contractId:data.contractId,
                     associationType: data.associationType,
                 })
-                if (code == 200) {
+                 // 隐藏加载状态
+                 loadingInstance.close()
+                if (code === 200) {
                   await window.$message?.success('同步成功')
-                    window?.location?.reload() //刷新页面
+                       setTimeout(() => {
+                        window?.location?.reload() // 刷新页面
+                       
+                    }, 1000) // 延迟2秒
+                } 
+
+                
+
+            } else {
+                     loadingInstance.close()
                 }
-            }
         },
     })
 }