DESKTOP-70VPDLK\Administrator 1 жил өмнө
parent
commit
e6e1544c8c

+ 2 - 2
common/chart/circle_chart.vue

@@ -23,7 +23,7 @@
 			},
 			bgColor: {
 				type: String,
-				default: ''
+				default: '#0FB160'
 			},
 		},
 		data() {
@@ -121,4 +121,4 @@
 </script>
 
 <style scoped>
-</style>
+</style>

+ 16 - 2
common/chart/pie_chart.vue

@@ -93,7 +93,7 @@ export default {
     };
   },
   onReady() {
-    this.getServerData();
+    // this.getServerData();
   },
   methods: {
     getServerData() {
@@ -110,6 +110,20 @@ export default {
         this.chartData = JSON.parse(JSON.stringify(res));
       }, 500);
     },
+    setData(data){
+      console.log(data)
+      setTimeout(() => {
+        //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
+        let res = {
+          series: [
+            {
+              data: data
+            }
+          ]
+        };
+        this.chartData = JSON.parse(JSON.stringify(res));
+      }, 50);
+    }
   }
 };
 </script>
@@ -120,4 +134,4 @@ export default {
     width: 135px;
     height: 135px;
   }
-</style>
+</style>

+ 37 - 7
pages/index/index.vue

@@ -24,7 +24,7 @@
 			<view class="">
 				<view class="row-c">
 					<view class="pie_chart column-c">
-						<PieChart></PieChart>
+						<PieChart ref="pieChart"></PieChart>
 						<text class="size-24 text-color-12">任务完成情况</text>
 					</view>
 					<view class="m-b30">
@@ -35,13 +35,13 @@
 									<text class="m-l16 text-color-787">{{item.name}}</text>
 								</view>
 							</view>
-							<text class="text-color-12 sys-weight-600 m-l40">{{item.value}}</text>
+							<text class="text-color-12 sys-weight-600 m-l40">{{item.value}}%</text>
 						</view>
 					</view>
 				</view>
 			</view>
 			<view class="circle_chart column-sb-c m-t10">
-				<CircleChart :width="'180rpx'" :height="'180rpx'" :bgColor="'#0FB160'"></CircleChart>
+				<CircleChart ref="circleObj" :width="'180rpx'" :height="'180rpx'" bgColor="#0FB160" ></CircleChart>
 				<text class="size-24 text-color-12">任务进度</text>
 			</view>
 		</view>
@@ -58,7 +58,8 @@
 	import IndexColumn from "./module/index_column.vue"
 	// 顶部栏目
 	import IndexPersonal from "./module/index_personal.vue"
-  import {getDayBacklogList} from "@/api/task";
+  import {getDateBacklogStatistics, getDayBacklogList} from "@/api/task";
+  import {date} from "@/uni_modules/uv-ui-tools/libs/function/test";
 
 	export default {
 		components: {
@@ -89,6 +90,12 @@
 					value: "100%"
 				}, ],
         memberData:{},
+        statisticsData:{
+          endNum: 0,
+          exceedDate: 0,
+          lagDate: 0,
+          totalNum: 0,
+        },
         backlogList: [],
         weekData: [],
         weekNum: 1,
@@ -106,26 +113,49 @@
 
       })
       this.startList()
+
 		},
 		onPageScroll(res) {
 			this.scrollTop = res.scrollTop / 120
 		},
 		onReachBottom() {
-			console.log('到底部了');
       this.getDayBacklogList()
+
 		},
 		methods: {
+      getDateBacklogStatistics(){
+        getDateBacklogStatistics({'dateNum':this.modelTime}).then(res=>{
+          if(res.code===1){
+            if(res.data.totalNum>0){
+              this.chartList[0].value=(res.data.exceedNum/res.data.totalNum*100).toFixed(0)*1;
+              this.chartList[1].value=(res.data.lagNum/res.data.totalNum*100).toFixed(0)*1;
+              this.chartList[2].value=(res.data.normalNum/res.data.totalNum*100).toFixed(0)*1;
+              this.$refs.circleObj.setServerData( (res.data.endNum/res.data.totalNum).toFixed(2)*1)
+            }else {
+              this.chartList[0].value=0;
+              this.chartList[1].value=0;
+              this.chartList[2].value=0;
+              this.$refs.circleObj.setServerData( 0)
+            }
+            console.log(this.chartList)
+            this.$refs.pieChart.setData( this.chartList)
+
+
+          }
+        })
+      },
       startList(){
         this.backlogList=[];
         this.page=1;
         this.total=null;
         this.getDayBacklogList();
+        this.getDateBacklogStatistics()
       },
       getDayBacklogList() {
         if(this.total!==null && this.total<=this.backlogList.length){
           return
         }
-        getDayBacklogList({'dateNum': this.indexTime,'page':this.page}).then((res) => {
+        getDayBacklogList({'dateNum': this.modelTime,'page':this.page}).then((res) => {
           if (res.code === 1) {
             this.backlogList.push(...res.data.items)
             this.total = res.data.total
@@ -166,4 +196,4 @@
 		height: 16rpx;
 		border-radius: 50%;
 	}
-</style>
+</style>

+ 11 - 5
service/tools.js

@@ -260,16 +260,22 @@ tools.setLoginData = function(data, type) {
 tools.getDate = function(type) {
 	let myDate = new Date();
 	// let myYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
-	// let myMonth = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
-	// let myToday = myDate.getDate(); //获取当前日(1-31)
+	let myMonth = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
+	let myToday = myDate.getDate(); //获取当前日(1-31)
 	// let myDay = myDate.getDay(); //获取当前星期X(0-6,0代表星期天)
 	// let myHour = myDate.getHours(); //获取当前小时数(0-23)
 	// let myMinute = myDate.getMinutes(); //获取当前分钟数(0-59)
 	// let mySecond = myDate.getSeconds(); //获取当前秒数(0-59)
+	if(myMonth<10){
+		myMonth='0'+myMonth
+	}
+	if(myToday<10){
+		myToday='0'+myToday
+	}
 	if (type === '-') {
-		return myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate()
+		return myDate.getFullYear() + '-' + (myMonth) + '-' + myToday
 	} else {
-		return myDate.getFullYear() + '年' + (myDate.getMonth() + 1) + '月' + myDate.getDate() + '日'
+		return myDate.getFullYear() + '年' + (myMonth) + '月' + myToday + '日'
 	}
 }
 
@@ -500,4 +506,4 @@ tools.topHeight = function() {
 	return navTop.height + navTop.top + 10
 }
 
-export default tools
+export default tools