ouyj 5 bulan lalu
induk
melakukan
b987919f46
1 mengubah file dengan 55 tambahan dan 53 penghapusan
  1. 55 53
      pages/worktime/index.uvue

+ 55 - 53
pages/worktime/index.uvue

@@ -214,6 +214,37 @@ function getWorkOrderTypeText(orderType: string | null): string {
   return ""
 }
 
+// 获取统计数据
+function getStatistics() {
+  const params: UTSJSONObject = {
+    keyword: searchKeyword.value,
+    orderType: orderTypeFilter.value,
+    timeRange: timeRange.value
+  }
+  
+  if (timeRange.value === 'custom') {
+    params.beginDate = startDate.value
+    params.endDate = endDate.value
+  }
+  
+  getOrderHourStatistics(params).then((response: any) => {
+    const resultObj = response as UTSJSONObject
+    const responseData = resultObj['data'] as UTSJSONObject
+    
+    if (responseData != null) {
+      totalHours.value = (responseData['totalHours'] != null) ? parseFloat((responseData['totalHours'] as number).toFixed(1)) : 0
+      maintenanceHours.value = (responseData['maintenanceHours'] != null) ? parseFloat((responseData['maintenanceHours'] as number).toFixed(1)) : 0
+      repairHours.value = (responseData['repairHours'] != null) ? parseFloat((responseData['repairHours'] as number).toFixed(1)) : 0
+      rank.value = (responseData['rank'] != null) ? responseData['rank'] as number : null
+    } else {
+      totalHours.value = 0
+      maintenanceHours.value = 0
+      repairHours.value = 0
+      rank.value = null
+    }
+  })
+}
+
 // 方法
 function loadData(isRefresh: boolean) {
   const shouldRefresh = isRefresh
@@ -263,41 +294,6 @@ function loadData(isRefresh: boolean) {
   })
 }
 
-// 生命周期
-onMounted(() => {
-  loadData(false)
-})
-
-function getStatistics() {
-  const params: UTSJSONObject = {
-    keyword: searchKeyword.value,
-    orderType: orderTypeFilter.value,
-    timeRange: timeRange.value
-  }
-  
-  if (timeRange.value === 'custom') {
-    params.beginDate = startDate.value
-    params.endDate = endDate.value
-  }
-  
-  getOrderHourStatistics(params).then((response: any) => {
-    const resultObj = response as UTSJSONObject
-    const responseData = resultObj['data'] as UTSJSONObject
-    
-    if (responseData != null) {
-      totalHours.value = (responseData['totalHours'] != null) ? responseData['totalHours'] as number : 0
-      maintenanceHours.value = (responseData['maintenanceHours'] != null) ? responseData['maintenanceHours'] as number : 0
-      repairHours.value = (responseData['repairHours'] != null) ? responseData['repairHours'] as number : 0
-      rank.value = (responseData['rank'] != null) ? responseData['rank'] as number : null
-    } else {
-      totalHours.value = 0
-      maintenanceHours.value = 0
-      repairHours.value = 0
-      rank.value = null
-    }
-  })
-}
-
 function handleSearch() {
   loadData(true)
   getStatistics()
@@ -395,6 +391,12 @@ function formatNumber(value: number | null) {
   if (value === null) return '0.0'
   return value.toFixed(1)
 }
+
+// 生命周期
+onMounted(() => {
+  loadData(false)
+  getStatistics()
+})
 </script>
 
 <style lang="scss">
@@ -466,17 +468,17 @@ function formatNumber(value: number | null) {
 
 /* 工时统计 */
 .stats-section {
-  margin: 24rpx 30rpx;
+  margin: 15rpx 30rpx;
   background-color: #ffffff;
   border-radius: 16rpx;
-  padding: 30rpx;
+  padding: 20rpx;
 }
 
 .stats-header {
   flex-direction: row;
   justify-content: space-between;
   align-items: center;
-  margin-bottom: 30rpx;
+  margin-bottom: 20rpx;
 }
 
 .stats-title {
@@ -491,8 +493,8 @@ function formatNumber(value: number | null) {
 }
 
 .time-filter {
-  padding: 8rpx 20rpx;
-  margin-left: 16rpx;
+  padding: 6rpx 16rpx;
+  margin-left: 12rpx;
   font-size: 24rpx;
   border-radius: 24rpx;
   background-color: #f2f3f5;
@@ -506,12 +508,12 @@ function formatNumber(value: number | null) {
 }
 
 .stats-content {
-  margin-top: 30rpx;
+  margin-top: 20rpx;
   flex-direction: column;
 }
 
 .total-hours {
-  margin-bottom: 40rpx;
+  margin-bottom: 30rpx;
   flex-direction: column;
   align-items: center;
 }
@@ -520,12 +522,12 @@ function formatNumber(value: number | null) {
   font-size: 28rpx;
   color: #666;
   display: block;
-  margin-bottom: 10rpx;
+  margin-bottom: 8rpx;
 }
 
 .hours-value {
   display: block;
-  font-size: 64rpx;
+  font-size: 48rpx;
   font-weight: bold;
   color: #165dff;
   line-height: 1.2;
@@ -544,22 +546,22 @@ function formatNumber(value: number | null) {
 
 .breakdown-label {
   display: block;
-  font-size: 32rpx;
-  font-weight: bold;
-  color: #333;
-  line-height: 1.4;
+    font-size: 32rpx;
+    font-weight: bold;
+    color: #333;
+    line-height: 1.4;
 }
 
-.breakdown-value {
+.breakdown-value { 
   font-size: 28rpx;
-  color: #666;
-  display: block;
-  margin-bottom: 10rpx;
+    color: #666;
+    display: block;
+    margin-bottom: 8rpx;
 }
 
 /* 列表项样式 */
 .list-item {
-  margin: 24rpx 30rpx;
+  margin: 12rpx 30rpx;
   background-color: #ffffff;
   border-radius: 16rpx;
 }