Browse Source

工分、工时

ouyj 5 months ago
parent
commit
6641ad6dfd
2 changed files with 257 additions and 9 deletions
  1. 130 9
      pages/score/index.uvue
  2. 127 0
      pages/worktime/index.uvue

+ 130 - 9
pages/score/index.uvue

@@ -129,10 +129,10 @@
             </view>
             <view class="info-row">
               <view class="info-label">
-                <text class="text-gray"><!-- {{ getWorkOrderTypeText(getPropertyValue(item, 'orderType')) }} --></text>
+                <text class="text-gray">{{ getWorkOrderTypeInfo(item) }}</text>
               </view>
               <view class="info-value-row">
-                <text class="score-text">{{ formatNumber(parseFloat(getPropertyValue(item, 'score'))) }}</text>
+                <text v-if="getPropertyValue(item, 'score') !== ''" class="score-text">{{ formatNumber(parseFloat(getPropertyValue(item, 'score'))) }}</text>
                 <!-- <text class="status-text">{{ getOrderStatusText(getPropertyValue(item, 'scoreStatus')) }}</text> -->
               </view>
             </view>
@@ -208,6 +208,10 @@
     
     // 工单状态字典列表
     const statusDictList = ref<SysDictData[]>([])
+    // 维保类型字典列表
+    const inspectionTypeDictList = ref<SysDictData[]>([])
+    // 检修类型字典列表
+    const maintenanceTypeDictList = ref<SysDictData[]>([])
     const dictLoaded = ref<boolean>(false)
     
     // 计算属性
@@ -273,11 +277,87 @@
                 }
                 
                 statusDictList.value = dictData
-                dictLoaded.value = true
             }
         } catch (e: any) {
             console.error('获取工单评分状态字典失败:', e.message)
-            dictLoaded.value = true
+        }
+    }
+    
+    // 获取维保类型字典列表
+    const loadInspectionTypeDictList = async (): Promise<void> => {
+        try {
+            const result = await getDictDataByType('gxt_inspection_type')
+            const resultObj = result as UTSJSONObject
+            
+            if (resultObj['code'] == 200) {
+                const data = resultObj['data'] as any[]
+                const dictData: SysDictData[] = []
+                
+                if (data != null && data.length > 0) {
+                    for (let i = 0; i < data.length; i++) {
+                        const item = data[i] as UTSJSONObject
+                        // 只提取需要的字段
+                        const dictItem: SysDictData = {
+                            dictValue: item['dictValue'] as string | null,
+                            dictLabel: item['dictLabel'] as string | null,
+                            dictCode: null,
+                            dictSort: null,
+                            dictType: null,
+                            cssClass: null,
+                            listClass: null,
+                            isDefault: null,
+                            status: null,
+                            default: null,
+                            createTime: null,
+                            remark: null
+                        }
+                        dictData.push(dictItem)
+                    }
+                }
+                
+                inspectionTypeDictList.value = dictData
+            }
+        } catch (e: any) {
+            console.error('获取维保类型字典失败:', e.message)
+        }
+    }
+    
+    // 获取检修类型字典列表
+    const loadMaintenanceTypeDictList = async (): Promise<void> => {
+        try {
+            const result = await getDictDataByType('gxt_maintenance_type')
+            const resultObj = result as UTSJSONObject
+            
+            if (resultObj['code'] == 200) {
+                const data = resultObj['data'] as any[]
+                const dictData: SysDictData[] = []
+                
+                if (data != null && data.length > 0) {
+                    for (let i = 0; i < data.length; i++) {
+                        const item = data[i] as UTSJSONObject
+                        // 只提取需要的字段
+                        const dictItem: SysDictData = {
+                            dictValue: item['dictValue'] as string | null,
+                            dictLabel: item['dictLabel'] as string | null,
+                            dictCode: null,
+                            dictSort: null,
+                            dictType: null,
+                            cssClass: null,
+                            listClass: null,
+                            isDefault: null,
+                            status: null,
+                            default: null,
+                            createTime: null,
+                            remark: null
+                        }
+                        dictData.push(dictItem)
+                    }
+                }
+                
+                maintenanceTypeDictList.value = dictData
+            }
+        } catch (e: any) {
+            console.error('获取检修类型字典失败:', e.message)
         }
     }
     
@@ -301,6 +381,44 @@
       return ""
     }
     
+    // 获取工单类型相关信息(维保类型或检修类型)
+    function getWorkOrderTypeInfo(item: any | null): string {
+      if (item == null) return ''
+      
+      const orderType = getPropertyValue(item, 'orderType')
+      
+      // 维保工单显示维保类型
+      if (orderType == "2") {
+        const inspectionType = getPropertyValue(item, 'inspectionType')
+        if (inspectionType != null && inspectionType != '') {
+          // 如果字典尚未加载,返回原始值
+          if (inspectionTypeDictList.value.length == 0) {
+            return inspectionType
+          }
+          
+            // 查找字典中对应的标签
+            const dictItem = inspectionTypeDictList.value.find(dict => dict.dictValue == inspectionType)
+            return (dictItem != null ? dictItem.dictLabel : inspectionType) as string
+        }
+      } 
+      // 维修工单显示检修类型
+      else if (orderType == "1") {
+        const maintenanceType = getPropertyValue(item, 'maintenanceType')
+        if (maintenanceType != null && maintenanceType != '') {
+          // 如果字典尚未加载,返回原始值
+          if (maintenanceTypeDictList.value.length == 0) {
+            return maintenanceType
+          }
+          
+            // 查找字典中对应的标签
+            const dictItem = maintenanceTypeDictList.value.find(dict => dict.dictValue == maintenanceType)
+            return (dictItem != null ? dictItem.dictLabel : maintenanceType) as string
+        }
+      }
+      
+      return ""
+    }
+    
     // 获取工单状态文本
     function getScoringStatus(item: any | null): string | null {
         if (item == null) return ''
@@ -359,9 +477,9 @@
         const responseData = resultObj['data'] as UTSJSONObject
         
         if (responseData != null) {
-          totalScore.value = (responseData['totalScore'] != null) ? parseFloat((responseData['totalScore'] as number).toFixed(1)) : 0
-          maintenanceScore.value = (responseData['maintenanceScore'] != null) ? parseFloat((responseData['maintenanceScore'] as number).toFixed(1)) : 0
-          repairScore.value = (responseData['repairScore'] != null) ? parseFloat((responseData['repairScore'] as number).toFixed(1)) : 0
+          totalScore.value = (responseData['totalScore'] != null) ? parseFloat((responseData['totalScore'] as number).toFixed(2)) : 0
+          maintenanceScore.value = (responseData['maintenanceScore'] != null) ? parseFloat((responseData['maintenanceScore'] as number).toFixed(2)) : 0
+          repairScore.value = (responseData['repairScore'] != null) ? parseFloat((responseData['repairScore'] as number).toFixed(2)) : 0
           rank.value = (responseData['rank'] != null) ? responseData['rank'] as number : null
           totalRankingUsers.value = (responseData['totalRankingUsers'] != null) ? responseData['totalRankingUsers'] as number : null
         } else {
@@ -414,7 +532,7 @@
         const prevYear = prevMonth === 0 ? now.getFullYear() - 1 : now.getFullYear();
         let monthStr = prevMonth === 0 ? '12' : prevMonth.toString()
         if (prevMonth !== 0 && prevMonth < 10) {
-          monthStr = '0' + monthStr
+          monthStr = '0' + monthStr 
         }
         monthValue = `${prevYear}-${monthStr}`;
       }
@@ -500,14 +618,17 @@
     
     function formatNumber(value: number | null) {
       if (value === null) return '0.0'
-      return value.toFixed(1)
+      return value.toFixed(2)
     }
     
     // 生命周期
     onMounted(() => {
       loadStatusDictList()
+      loadInspectionTypeDictList()
+      loadMaintenanceTypeDictList()
       loadData(false)
       getStatistics()
+      dictLoaded.value = true
     })
 </script>
 

+ 127 - 0
pages/worktime/index.uvue

@@ -113,6 +113,11 @@
               <text class="item-title">{{ getPropertyValue(item, 'workOrderProjectNo') }}-风机编号{{ getPropertyValue(item, 'pcsDeviceName') }}的{{ getWorkOrderTypeText(getPropertyValue(item, 'orderType')) }}</text>
               <text class="info-value">{{ getWorkOrderStatus(item) }}</text>
             </view>
+			<view class="info-row">
+			  <view class="info-label">
+			    <text class="text-gray">{{ getWorkOrderTypeInfo(item) }}</text>
+			  </view>
+			</view>
             <view class="info-row">
               <view class="info-label">
                 <text class="text-gray">下发时间: {{ formatDate(getPropertyValue(item, 'assignTime')) }}</text>
@@ -218,6 +223,10 @@ const endDate = ref<string>('')
 
 // 工单状态字典列表
 const statusDictList = ref<SysDictData[]>([])
+// 维保类型字典列表
+const inspectionTypeDictList = ref<SysDictData[]>([])
+// 检修类型字典列表
+const maintenanceTypeDictList = ref<SysDictData[]>([])
 const dictLoaded = ref<boolean>(false)
 
 // 计算属性
@@ -275,6 +284,84 @@ const loadStatusDictList = async (): Promise<void> => {
     }
 }
 
+// 获取维保类型字典列表
+const loadInspectionTypeDictList = async (): Promise<void> => {
+	try {
+		const result = await getDictDataByType('gxt_inspection_type')
+		const resultObj = result as UTSJSONObject
+		
+		if (resultObj['code'] == 200) {
+			const data = resultObj['data'] as any[]
+			const dictData: SysDictData[] = []
+			
+			if (data != null && data.length > 0) {
+				for (let i = 0; i < data.length; i++) {
+					const item = data[i] as UTSJSONObject
+					// 只提取需要的字段
+					const dictItem: SysDictData = {
+						dictValue: item['dictValue'] as string | null,
+						dictLabel: item['dictLabel'] as string | null,
+						dictCode: null,
+						dictSort: null,
+						dictType: null,
+						cssClass: null,
+						listClass: null,
+						isDefault: null,
+						status: null,
+						default: null,
+						createTime: null,
+						remark: null
+					}
+					dictData.push(dictItem)
+				}
+			}
+			
+			inspectionTypeDictList.value = dictData
+		}
+	} catch (e: any) {
+		console.error('获取维保类型字典失败:', e.message)
+	}
+}
+
+// 获取检修类型字典列表
+const loadMaintenanceTypeDictList = async (): Promise<void> => {
+	try {
+		const result = await getDictDataByType('gxt_maintenance_type')
+		const resultObj = result as UTSJSONObject
+		
+		if (resultObj['code'] == 200) {
+			const data = resultObj['data'] as any[]
+			const dictData: SysDictData[] = []
+			
+			if (data != null && data.length > 0) {
+				for (let i = 0; i < data.length; i++) {
+					const item = data[i] as UTSJSONObject
+					// 只提取需要的字段
+					const dictItem: SysDictData = {
+						dictValue: item['dictValue'] as string | null,
+						dictLabel: item['dictLabel'] as string | null,
+						dictCode: null,
+						dictSort: null,
+						dictType: null,
+						cssClass: null,
+						listClass: null,
+						isDefault: null,
+						status: null,
+						default: null,
+						createTime: null,
+						remark: null
+					}
+					dictData.push(dictItem)
+				}
+			}
+			
+			maintenanceTypeDictList.value = dictData
+		}
+	} catch (e: any) {
+		console.error('获取检修类型字典失败:', e.message)
+	}
+}
+
 // Helper function to safely extract properties from item
 function getPropertyValue(item: any | null, propertyName: string): string {
   if (item == null) return ''
@@ -547,9 +634,49 @@ function formatNumber(value: number | null) {
   return value.toFixed(1)
 }
 
+// 获取工单类型相关信息(维保类型或检修类型)
+function getWorkOrderTypeInfo(item: any | null): string {
+  if (item == null) return ''
+  
+  const orderType = getPropertyValue(item, 'orderType')
+  
+  // 维保工单显示维保类型
+  if (orderType == "2") {
+	const inspectionType = getPropertyValue(item, 'inspectionType')
+	if (inspectionType != null && inspectionType != '') {
+	  // 如果字典尚未加载,返回原始值
+	  if (inspectionTypeDictList.value.length == 0) {
+		return inspectionType
+	  }
+	  
+		// 查找字典中对应的标签
+		const dictItem = inspectionTypeDictList.value.find(dict => dict.dictValue == inspectionType)
+		return (dictItem != null ? dictItem.dictLabel : inspectionType) as string
+	}
+  } 
+  // 维修工单显示检修类型
+  else if (orderType == "1") {
+	const maintenanceType = getPropertyValue(item, 'maintenanceType')
+	if (maintenanceType != null && maintenanceType != '') {
+	  // 如果字典尚未加载,返回原始值
+	  if (maintenanceTypeDictList.value.length == 0) {
+		return maintenanceType
+	  }
+	  
+		// 查找字典中对应的标签
+		const dictItem = maintenanceTypeDictList.value.find(dict => dict.dictValue == maintenanceType)
+		return (dictItem != null ? dictItem.dictLabel : maintenanceType) as string
+	}
+  }
+  
+  return ""
+}
+	
 // 生命周期
 onMounted(() => {
   loadStatusDictList()
+  loadInspectionTypeDictList()
+  loadMaintenanceTypeDictList()
   loadData(false)
   getStatistics()
 })