Bläddra i källkod

导入增加加载效果

shenhao 3 år sedan
förälder
incheckning
392683d8f5
1 ändrade filer med 18 tillägg och 3 borttagningar
  1. 18 3
      src/main/resources/templates/sys/fx/deviceAllList.html

+ 18 - 3
src/main/resources/templates/sys/fx/deviceAllList.html

@@ -765,10 +765,9 @@
 	
 	
     $("#importdevicefile").click(function () {
+		layuiLoading("上传中……");
         var formData = new FormData();
-        formData
-        .append("importdevice", document.getElementById("importdevice").files[0]);  
-        
+        formData.append("importdevice", document.getElementById("importdevice").files[0]);
         $.ajax({
         	url: "[[${sysUrl}]]/sys/fx/importDeviceData",
             type: "POST",
@@ -783,6 +782,7 @@
             */
             processData: false,
             success: function (data) {
+				layuiRemoveLoading();
                 if (data.status == "success") {
                 	parent.layer.msg("上传成功",{icon:1});
 			    	setTimeout(function(){
@@ -793,11 +793,26 @@
                 }
             },
             error: function () {
+				layuiRemoveLoading();
                 alert("上传失败,请刷新后重试。");
             }
         });
     });
 
+
+	function layuiLoading(msg) {
+		layui.use(['layer', 'form'], function () {
+			index = layer.load(0, {shade: false});
+		});
+	}
+
+	function layuiRemoveLoading(){
+		layui.use(['layer', 'form'], function(){
+			var layer = layui.layer
+			layer.close(index);
+			//调用close方法,关闭全局变量index对应的加载效果
+		});
+	}
 </script>
 
 <script type="text/javascript">