finish-plan-detail.vue 4.32 KB
<template>
  <view class="page-container">
    <!-- 页面级加载组件 -->
    <up-loading-page
        v-if="loading"
        :loading="true"
        title="加载中..."
        color="#3c9cff"
    ></up-loading-page>

    <!-- 内容容器 -->
    <template  v-else>
      <view v-if="orderDetail.length>0">
        <view class="content-wrap" v-for="(i, index) in orderDetail" :key="index">
          <!-- 工单详情内容 -->
          <up-cell-group :border="false" inset >
            <!-- 1. 工单名称 -->
            <up-cell
                align="middle"
            >
              <template #title>
                <view  class="up-line-1">{{i.planName || '--'}}</view>
              </template>
              <!--            <template #value>-->
              <!--              <view  class="up-line-1">{{orderDetail.planName || '&#45;&#45;'}}</view>-->
              <!--            </template>-->
            </up-cell>

            <!-- 2. 工单位置 -->
            <up-cell
                title="计划编码"
                :value="i.planNo || '--'"
                align="middle"
            ></up-cell>

            <!-- 3. 工单名称 -->
            <up-cell
                title="养护周期"
                :value="`${i.rate}${uni.$dict.getDictLabel('cycle_id_type', i.cycleId)}`"
                align="middle"
            ></up-cell>

            <!-- 4. 情况描述 -->
            <up-cell
                title="计划有效期"
                :value="`${timeFormat(i.beginTime,'yyyy-mm-dd')} 至 ${timeFormat(i. endTime,'yyyy-mm-dd')}`"
                align="middle"
            ></up-cell>

            <!-- 5. 问题照片(核心修复:判断条件+空值处理) -->
            <up-cell title="照片">
              <template #value>
                <view class="cell-content-wrap">

                  <!-- 修复1:正确判断problemImgsList,补充空数组默认值 -->
                  <up-album
                      v-if="!!i.imgList?.length"
                      :urls="i.imgList || []"
                      singleSize="70"
                      :preview-full-image="true"

                  ></up-album>
                  <text v-else class="empty-text">暂无问题照片</text>
                </view>
              </template>
            </up-cell>

            <!-- 7. 处理结果 -->
            <up-cell
                align="middle"
            >
              <template #title>
                <view  style="min-width: 200rpx">巡查描述</view>
              </template>
              <template #value>
                <view  class="up-line-1 common-text-color">{{i.remark || '--'}}</view>
              </template>
            </up-cell>

            <up-cell
                title="提交时间"
                :value="timeFormat(i.finishTime,'yyyy-mm-dd hh:MM:ss') || '--'"
                align="middle"

            ></up-cell>

            <up-cell
                title="提交人"
                :value="i.userName || '--'"
                align="middle"
                :border="false"
            ></up-cell>
          </up-cell-group>

        </view>
      </view>
       <view v-else>
         <up-empty
             mode="history">
         </up-empty>
       </view>

    </template>
  </view>
</template>

<script setup lang="ts">
import {ref} from 'vue';
import {inspectioDetailByPlanno} from "@/api/patrol-manage/patrol-plan";
import {onLoad} from '@dcloudio/uni-app';
import {timeFormat} from '@/uni_modules/uview-plus';
// 状态管理
const loading = ref(true);
const orderDetail = ref([]);


/**
 * 获取工单详情
 */
const getOrderDetail = async (plan_no: string) => {
  try {
    loading.value = true;
    const res = await inspectioDetailByPlanno({plan_no});
    console.log('接口返回:', res);

    orderDetail.value = res;
  } catch (error) {
    console.error('获取工单详情失败:', error);
    uni.showToast({title: '加载失败,请重试', icon: 'none'});
  } finally {
    loading.value = false;
  }
};

// 页面加载
onLoad((options) => {
  const {planNo} = options;
  if (planNo) {
    getOrderDetail(planNo);
  } else {
    loading.value = false;
    uni.showToast({title: '缺少工单ID', icon: 'none'});
  }
});
</script>

<style scoped lang="scss">

// 内容容器
.content-wrap {
  background: #fff;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 30rpx;
}


</style>