Browse Source

工时、工分

ouyj 4 months ago
parent
commit
07cd5a17cc
3 changed files with 196 additions and 157 deletions
  1. 50 56
      pages/score/detail/index.uvue
  2. 16 0
      pages/score/index.uvue
  3. 130 101
      pages/worktime/detail/index.uvue

+ 50 - 56
pages/score/detail/index.uvue

@@ -43,11 +43,15 @@
 					    <text class="info-label">维保类型</text>
 					    <text class="info-value">{{ getInspectionTypeText(detailData.inspectionType) }}</text>
 					</view>
+					<!-- <view class="info-item" v-if="detailData.workSummary != null && detailData.workSummary != ''">
+					    <text class="info-label">{{ detailData.orderType == 1 ? '维修总结' : '维保总结' }}</text>
+					    <text class="info-value">{{ detailData.workSummary ?? '' }}</text>
+					</view> -->
                 </view>
             </view>
 
             <!-- 工作总结 -->
-            <view class="info-section" v-if="detailData.workSummary != null && detailData.workSummary != ''">
+           <view class="info-section" v-if="detailData.workSummary != null && detailData.workSummary != ''">
                 <view class="section-title">
                     <text class="section-title-text">{{ detailData.orderType == 1 ? '维修总结' : '维保总结' }}</text>
                 </view>
@@ -64,28 +68,25 @@
                     <text class="section-title-text">得分明细</text>
                 </view>
                 <view class="info-card">
-                    <view class="score-item" v-for="(person, index) in detailData.scorePersonList" :key="index">
-                        <view class="person-info">
-                            <text class="person-name">{{ person.nickName }}<text v-if="person.isLeader == 1"> (工作负责人)</text></text>
-                        </view>
-						<view class="score-details">
-							<view class="score-row" v-if="person.selfScore != null">
-								<text class="score-label">自评得分:</text>
-								<text class="score-value">{{ formatNumber(person.selfScore) }}</text>
-							</view>
-							<view class="score-row" v-if="person.reviewScore != null">
-								<text class="score-label">复评得分:</text>
-								<text class="score-value">{{ formatNumber(person.reviewScore) }}</text>
-							</view>
-							<view class="score-row" v-if="person.finalScore != null">
-								<text class="score-label">终评得分:</text>
-								<text class="score-value">{{ formatNumber(person.finalScore) }}</text>
-							</view>
-							<view class="score-row" v-if="person.confirmStatus != null">
-								<text class="score-label">确认状态:</text>
-								<text class="score-value">{{ getConfirmStatusText(person.confirmStatus) }}</text>
-							</view>
-						</view>
+                    <!-- 表格头部 -->
+                    <view class="table-header">
+                        <text class="table-cell score-col">检修员</text>
+                        <text class="table-cell score-col">自评得分</text>
+                        <text class="table-cell score-col">复评得分</text>
+                        <text class="table-cell score-col">终评得分</text>
+                        <text class="table-cell score-col">确认状态</text>
+                    </view>
+                    
+                    <!-- 表格行数据 -->
+                    <view class="table-row" v-for="(person, index) in detailData.scorePersonList" :key="index">
+                        <text class="table-cell score-col">
+                            {{ person.nickName }}
+                            <text class="table-cell score-col" v-if="person.isLeader == 1">(负责人)</text>
+                        </text>
+                        <text class="table-cell score-col">{{ person.selfScore !== null ? formatNumber(person.selfScore) : '-' }}</text>
+                        <text class="table-cell score-col">{{ person.reviewScore !== null ? formatNumber(person.reviewScore) : '-' }}</text>
+                        <text class="table-cell score-col">{{ person.finalScore !== null ? formatNumber(person.finalScore) : '-' }}</text>
+                        <text class="table-cell score-col">{{ person.confirmStatus !== null ? getConfirmStatusText(person.confirmStatus) : '-' }}</text>
                     </view>
                 </view>
             </view>
@@ -484,45 +485,38 @@
                 }
             }
 
-            .score-item {
+            /* 表格样式 */
+            .table-header, .table-row {
+                flex-direction: row;
                 padding: 20rpx 0;
                 border-bottom: 1rpx solid #f0f0f0;
-
+                
                 &:last-child {
                     border-bottom: none;
                 }
-
-                .person-info {
-                    margin-bottom: 16rpx;
-
-                    .person-name {
-                        font-size: 30rpx;
-                        font-weight: bold;
-                        color: #333333;
-                    }
+            }
+            
+            .table-header {
+                background-color: #f8f8f8;
+                font-weight: bold;
+            }
+            
+            .table-cell {
+                font-size: 26rpx;
+                color: #333;
+                text-align: center;
+                
+                &.name-col {
+                    flex: 2;
+                    text-align: left;
                 }
-
-                .score-details {
-                    .score-row {
-                        flex-direction: row;
-                        justify-content: space-between;
-                        margin-bottom: 10rpx;
-
-                        &:last-child {
-                            margin-bottom: 0;
-                        }
-
-                        .score-label {
-                            font-size: 26rpx;
-                            color: #666666;
-                        }
-
-                        .score-value {
-                            font-size: 26rpx;
-                            color: #333333;
-                            font-weight: bold;
-                        }
-                    }
+                
+                &.score-col {
+                    flex: 1;
+                }
+                
+                &.status-col {
+                    flex: 1;
                 }
             }
         }

+ 16 - 0
pages/score/index.uvue

@@ -137,6 +137,11 @@
                 <!-- <text class="status-text">{{ getOrderStatusText(getPropertyValue(item, 'scoreStatus')) }}</text> -->
               </view>
             </view>
+			<view class="info-row">
+			  <view class="info-label">
+			    <text class="text-gray">工作结束时间: {{ formatDate(getPropertyValue(item, 'assignTime')) }}</text>
+			  </view> 
+			</view>
           </view>
         </view>
       </template>
@@ -630,6 +635,17 @@
 	    return `status-${rawStatus}`
 	}
 	
+	function formatDate(dateString: string) {
+	  if (dateString == '' || dateString == null) return ''
+	  const date = new Date(dateString)
+	  const year = date.getFullYear()
+	  const month = (date.getMonth() + 1).toString().padStart(2, '0')
+	  const day = date.getDate().toString().padStart(2, '0')
+	  const hours = date.getHours().toString().padStart(2, '0')
+	  const minutes = date.getMinutes().toString().padStart(2, '0')
+	  return `${year}-${month}-${day} ${hours}:${minutes}`
+	}
+	
     // 生命周期
     onMounted(() => {
       loadStatusDictList()

+ 130 - 101
pages/worktime/detail/index.uvue

@@ -41,7 +41,18 @@
                 </view>
                 <view class="info-card">
                     <view class="chart-container">
-                        <tui-xechars ref="chartRef" style="width: 100%;" @initFinished="onInitFinished"></tui-xechars>
+                        <tui-xechars ref="chartRef" style="width: 315rpx; height: 300rpx;" @initFinished="onInitFinished"></tui-xechars>
+                        <view class="chart-legend">
+                            <view v-for="(item, index) in chartLegendData" :key="index" class="legend-item">
+                                <view class="legend-left">
+                                    <view class="legend-color" :style="{ backgroundColor: item.color }"></view>
+                                    <text class="legend-name">{{ item.name }}</text>
+                                </view>
+                                <view class="legend-right">
+                                    <text class="legend-value">{{ formatHours(item.value) }}小时</text>
+                                </view>
+                            </view>
+                        </view>
                     </view>
                 </view>
             </view>
@@ -135,45 +146,17 @@
     // 保存图表实例
     const chartInstance = ref<TuiCharts | null>(null)
     
-    // 图表配置
-    const chartOption = ref({
-        tooltip: {
-            trigger: 'item'
-        },
-        legend: {
-            orient: 'horizontal',
-            bottom: 10
-        },
-        series: [
-            {
-                type: 'pie',
-                radius: ['40%', '70%'],
-                avoidLabelOverlap: false,
-                itemStyle: {
-                    borderRadius: 10,
-                    borderColor: '#fff',
-                    borderWidth: 2
-                },
-                label: {
-                    show: true,
-                    position: 'center'
-                },
-                emphasis: {
-                    label: {
-                        show: true,
-                        fontSize: 18,
-                        fontWeight: 'bold'
-                    }
-                },
-                labelLine: {
-                    show: true
-                },
-                data: [] as UTSJSONObject[],
-				textOffset: 150
-            } as UTSJSONObject
-        ] as UTSJSONObject[]
-    } as UTSJSONObject)
-
+    // 图例数据类型
+    type ChartLegendItem = {
+        name: string
+        value: number
+        color: string
+    }
+    const chartLegendData = ref<ChartLegendItem[]>([])
+    
+    // 颜色配置
+    const chartColors = ['#5B9BF3', '#4DD4C0', '#FF9966', '#FF6B96', '#9B7FE8', '#FFD700', '#8A2BE2']
+    
     // 格式化小时数
     const formatHours = (hourValue: number | null): string => {
         if (hourValue == null) return '0.0'
@@ -197,13 +180,12 @@
                 charts.chartsMap.clear()
             }
             
-            // 创建饼图配置
+            // 创建饼图配置 - 使用环形图配置以匹配 flow-chart 组件
             const pieOption = {
-                type: 'pie',
-                dataLabel: true,
+                type: 'ring',
+                dataLabel: false,
                 legend: {
-                    show: true,
-                    position: 'bottom'
+                    show: false
                 },
                 series: chartData.value.map((item: UTSJSONObject, index: number) => {
                     return {
@@ -211,26 +193,28 @@
                         legendText: item.get('name'),  
                         data: [{
                             name: item.get('name'),
-                            labelText: `${formatHours(item.get('value') as number)}小时`,
-                            labelShow: true,
                             value: item.get('value')
-                        }]
+                        }],
+                        color: chartColors[index % chartColors.length]
                     }
                 }),
                 extra: {
-                    pie: {
+                    ring: {
+                        type: 'ring',
+                        width: 8,
                         activeOpacity: 0.5,
                         activeRadius: 0,
                         offsetAngle: 0,
                         labelWidth: 15,
-                        ringWidth: 30,
-                        // 添加 customRadius 来控制饼图大小
-                        customRadius: 80,
+                        ringWidth: 8,
+                        customRadius: 60,
                         border: false,
                         borderWidth: 0,
                         borderColor: '#FFFFFF',
                         centerColor: '#FFFFFF',
-                        linearType: 'custom'
+                        linearType: 'custom',
+                        // 添加背景色以匹配 flow-chart 组件
+                        backgroundColor: '#C4D7E9'
                     }
                 }
             } as UTSJSONObject
@@ -251,89 +235,86 @@
     // 准备图表数据
     const prepareChartData = (data: orderInfo): void => {
         const chartItems = [] as UTSJSONObject[]
+        const legendItems = [] as ChartLegendItem[]
         
         // 添加各项工时数据
-        if (data.issueHour != null && data.issueHour >= 0) {
+        if (data.issueHour != null) {
             const item = {
 				name: '下发时长', 
 				value: data.issueHour
 			} as UTSJSONObject
             chartItems.push(item)
+            legendItems.push({
+                name: '下发时长',
+                value: data.issueHour,
+                color: chartColors[legendItems.length % chartColors.length]
+            } as ChartLegendItem)
         }
         
-        if (data.acceptHour != null && data.acceptHour >= 0) {
+        if (data.acceptHour != null) {
             const item = {name: '接单时长', value: data.acceptHour} as UTSJSONObject
             chartItems.push(item)
+            legendItems.push({
+                name: '接单时长',
+                value: data.acceptHour,
+                color: chartColors[legendItems.length % chartColors.length]
+            } as ChartLegendItem)
         }
         
-        if (data.prepareHour != null && data.prepareHour >= 0) {
+        if (data.prepareHour != null) {
             const item = {name: '准备时长', value: data.prepareHour} as UTSJSONObject
             chartItems.push(item)
+            legendItems.push({
+                name: '准备时长',
+                value: data.prepareHour,
+                color: chartColors[legendItems.length % chartColors.length]
+            } as ChartLegendItem)
         }
         
-        if (data.workHour != null && data.workHour >= 0) {
+        if (data.workHour != null) {
             const item = {name: '作业时长', value: data.workHour} as UTSJSONObject
             chartItems.push(item)
+            legendItems.push({
+                name: '作业时长',
+                value: data.workHour,
+                color: chartColors[legendItems.length % chartColors.length]
+            } as ChartLegendItem)
         }
         
-        if (data.restartHour != null && data.restartHour >= 0) {
+        if (data.restartHour != null) {
             const item = {name: '复运时长', value: data.restartHour} as UTSJSONObject
             chartItems.push(item)
+            legendItems.push({
+                name: '复运时长',
+                value: data.restartHour,
+                color: chartColors[legendItems.length % chartColors.length]
+            } as ChartLegendItem)
         }
         
-        if (data.handleHour != null && data.handleHour >= 0) {
+        if (data.handleHour != null) {
             const item = {name: '处理时长', value: data.handleHour} as UTSJSONObject
             chartItems.push(item)
+            legendItems.push({
+                name: '处理时长',
+                value: data.handleHour,
+                color: chartColors[legendItems.length % chartColors.length]
+            } as ChartLegendItem)
         }
         
-        if (data.suspendHour != null && data.suspendHour >= 0) {
+        if (data.suspendHour != null) {
             const item = {name: '挂起时长', value: data.suspendHour} as UTSJSONObject
             chartItems.push(item)
+            legendItems.push({
+                name: '挂起时长',
+                value: data.suspendHour,
+                color: chartColors[legendItems.length % chartColors.length]
+            } as ChartLegendItem)
         }
         
         chartData.value = chartItems
+        chartLegendData.value = legendItems
         console.log('更新chartData:', chartItems)
-        
-        // 更新图表配置
-        const newOption = {
-            tooltip: {
-                trigger: 'item'
-            },
-            legend: {
-                orient: 'horizontal',
-                bottom: 10
-            },
-            series: [
-                {
-                    type: 'pie',
-                    radius: ['40%', '70%'],
-                    avoidLabelOverlap: false,
-                    itemStyle: {
-                        borderRadius: 10,
-                        borderColor: '#fff',
-                        borderWidth: 2
-                    },
-                    label: {
-                        show: false,
-                        position: 'center'
-                    },
-                    emphasis: {
-                        label: {
-                            show: true,
-                            fontSize: 18,
-                            fontWeight: 'bold'
-                        }
-                    },
-                    labelLine: {
-                        show: false
-                    },
-                    data: chartItems,
-					textOffset: 150
-                }
-            ]
-        }
-        // 使用深拷贝确保响应式更新
-        chartOption.value = JSON.parse(JSON.stringify(newOption)) as UTSJSONObject
+        console.log('更新chartLegendData:', legendItems)
         
         // 如果图表已经初始化,则直接绘制
         if (chartInstance.value != null && chartItems.length > 0) {
@@ -521,8 +502,56 @@
             }
 
             .chart-container {
+                flex-direction: row;
+                align-items: center;
+                justify-content: space-between;
                 margin: 20rpx 0;
             }
+            
+            .chart-legend {
+                flex: 1;
+                padding-left: 20rpx;
+            }
+            
+            .legend-item {
+                flex-direction: row;
+                align-items: center;
+                justify-content: space-between;
+                margin-bottom: 20rpx;
+            
+                &:last-child {
+                    margin-bottom: 0;
+                }
+             
+                .legend-left {
+                    flex-direction: row;
+                    align-items: center;
+                }
+             
+                .legend-right {
+                    flex-direction: row;
+                    align-items: center;
+                }
+            }
+            
+            .legend-color {
+                width: 24rpx;
+                height: 24rpx;
+                border-radius: 4rpx;
+                margin-right: 12rpx;
+            }
+            
+            .legend-name {
+                font-size: 26rpx;
+                color: #333333;
+                margin-right: 8rpx;
+            }
+            
+            .legend-value {
+                font-size: 26rpx;
+                color: #666666;
+                font-weight: bold;
+            }
 
             .no-data {
                 text-align: center;