From efa0e60ffa77fd41449d64521c493571fc46d07e Mon Sep 17 00:00:00 2001
From: hdw <496960745@qq.com>
Date: 星期二, 27 十一月 2018 15:11:59 +0800
Subject: [PATCH] 饼状图配置

---
 gx_tieta/WebRoot/pages/js/pages/index-common.js |  111 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 61 insertions(+), 50 deletions(-)

diff --git a/gx_tieta/WebRoot/pages/js/pages/index-common.js b/gx_tieta/WebRoot/pages/js/pages/index-common.js
index 5223704..6a683c0 100644
--- a/gx_tieta/WebRoot/pages/js/pages/index-common.js
+++ b/gx_tieta/WebRoot/pages/js/pages/index-common.js
@@ -3,76 +3,87 @@
 	gl.namespace('Index.Pie');
 	
 	var pieType = [
+		 {
+			name: '鏈烘埧鍋滅數'
+			,cla: 'repair-pie'
+		 },
          {
-        	 name: '鐢垫睜鐘舵��',
-        	 action: 'Batt_rtstateAction!serchBattStateRate',
-        	 formatData: eleStatus
+        	 name: '鐢垫睜鐘舵��'
+        	 ,cla: 'brdn-pie'
          },
          {
-        	 name: '鐢垫睜鍛婅鐜�',
-        	 action: 'Battalarm_dataAction!serchAlm',
-        	 formatData: eleWarn
+        	 name: '鐢垫睜鍛婅鐜�'
+        	 ,cla: 'warn-pie' 
          },
          {
-        	 name: '鏈烘埧鍋滅數',
-        	 action: 'BattPower_offAction!serchPowerOff',
-        	 formatData: homeCut
+        	 name: '鍗曚綋瀹归噺鍋ュ悍鐜�'
+        	 ,cla: 'health-pie'
          },
          {
-        	 name: '鍗曚綋瀹归噺鍋ュ悍鐜�',
-        	 action: 'Battalarm_dataAction!serchGood',
-        	 formatData: monCapGood
+        	 name: '鏈烘埧缁埅鑳藉姏'
+        	 ,cla: 'endur-pie'
          }
 	];
 	
 	// 灏唒ieType缁戝畾鍒癐ndex.Pie鍛藉悕绌洪棿涓�
 	gl.Index.Pie.pieType = pieType;
 	
-	// 鏍规嵁鏁扮粍璋冪敤鏌ヨ鍐呭
-	function search(arr) {
-		for(var i=0; i<arr.length; i++) {
-			if(arr[i]) {
-				ajax(pieType[i]);
-			}
-		}
-	}
-	
-	// 灏唖earch缁戝畾鍒癐ndex.Pie鍛藉悕绌洪棿涓�
-	gl.Index.Pie.search = search;
-	
-	// 璇锋眰鍚庡彴
-	function ajax(obj) {
-		// ajax璇锋眰鍚庡彴
+	// 鏌ヨ楗肩姸鍥剧姸鎬佽繑鍥為渶瑕佹樉绀洪ゼ鐘跺浘
+	function pieStatus() {
+		// 璁剧疆涓�涓悓姝ユ煡璇㈣繑鍥炰竴涓猟iv.pie-item-list
+		var pieItems;
 		$.ajax({
-			type: 'post',
-			url: obj.action,
-			data: null,
-			async: true,
-			dataType: 'json',
-			success:function(result) {
-				var rs = JSON.parse(result.result);
-				var pieData = obj.formatData(rs);
-				
+			type: 'post'
+			,async: false
+			,url: 'Echarts_usrAction!serchByCondition'
+			,data: null
+			,dataType: 'json'
+			,success: function(res) {
+				var rs = JSON.parse(res.result);
+				//console.log(rs);
+				if(rs.code == 1) {
+					var data = rs.data[0];
+					var rsStatus = formaterPieStauts(data);
+					pieItems = getPieList(rsStatus);
+				}
 			}
 		});
+		
+		return pieItems;
 	}
 	
-	// 鐢垫睜鐘舵��
-	function eleStatus(data) {
-		console.log(data);
+	// 灏唒ieStatus缁戝畾鍒癐ndex.Pie鍛藉悕绌洪棿涓�
+	gl.Index.Pie.pieStatus = pieStatus;
+	
+	// 鏍规嵁鏁扮粍杩斿洖
+	function getPieList(arr) {
+		var pieItems = $('<div class="pie-item-list"></div>');
+		for(var i=0; i<arr.length; i++) {
+			if(arr[i] == 1) {
+				var cla = pieType[i].cla;
+				var pieItem = $('<div class="'+cla+' module"></div>');
+				pieItems.append(pieItem);
+			}
+			
+		}
+		return pieItems;
 	}
 	
-	// 鐢垫睜鍛婅
-	function eleWarn(data) {
-		console.log(data);
+	// 灏唃etPieList缁戝畾鍒癐ndex.Pie鍛藉悕绌洪棿涓�
+	gl.Index.Pie.getPieList = getPieList;
+	
+	// 鏋勯�犳洿鏂伴ゼ鐘跺浘鍙傛暟
+	function formaterPieStauts(obj) {
+		var rs = [];
+		// 閬嶅巻pieType鐨勭被鍨�
+		for(var i=0; i<pieType.length; i++) {
+			var num = i+1;
+			var key = 'echarts'+num+'_enable';
+			rs.push(obj[key]);
+		}
+		return rs;
 	}
 	
-	// 鏈烘埧鍋滅數
-	function homeCut(data) {
-		console.log(data);
-	}
-	// 鍗曚綋瀹归噺鍋ュ悍鐜�
-	function monCapGood(data) {
-		console.log(data);
-	}
+	// 灏唃etPieList缁戝畾鍒癐ndex.Pie鍛藉悕绌洪棿涓�
+	gl.Index.Pie.formaterPieStauts = formaterPieStauts;
 })(jQuery, window, document, GLOBAL);
\ No newline at end of file

--
Gitblit v1.9.1