record-detail-list.vue 5.27 KB
<template>
  <view class="page-container">
    <!-- 页面级加载组件 -->
    <up-loading-page
        v-if="loading"
        :loading="true"
        title="加载中..."
        color="#2563EB"
    ></up-loading-page>

    <!-- 内容容器 -->
    <view v-else class="content-wrap">


      <!-- 养护记录卡片(统一卡片样式) -->
      <view class="plan-card" v-for="(i, index) in orderDetail" :key="index">
        <view class="plan-card__head">
          <view class="plan-card__title">{{ i.planName || '无计划名称' }}</view>
        </view>

        <view class="u-body-item u-flex">
          <view class="u-body-item-title">计划编码:</view>
          <view class="u-line-1 u-body-value">{{ i.planNo || '--' }}</view>
        </view>

        <view class="u-body-item u-flex">
          <view class="u-body-item-title">养护周期:</view>
          <view class="u-line-1 u-body-value">{{ `${i.rate}${uni.$dict.getDictLabel('cycle_id_type', i.cycleId)}` }}</view>
        </view>

        <view class="u-body-item u-flex">
          <view class="u-body-item-title">计划有效期:</view>
          <view class="u-line-1 u-body-value">{{ `${timeFormat(i.beginTime,'yy-mm-dd hh:MM:ss')} 至 ${timeFormat(i. endTime,'yy-mm-dd hh:MM:ss')}` }}</view>
        </view>

        <view class="u-body-item u-flex">
          <view class="u-body-item-title">养护描述:</view>
          <view class="u-line-1 u-body-value">{{ i.remark || '--' }}</view>
        </view>

        <view class="u-body-item u-flex">
          <view class="u-body-item-title">提交时间:</view>
          <view class="u-line-1 u-body-value">{{ timeFormat(i.finishTime,'yy-mm-dd hh:MM:ss') || '--' }}</view>
        </view>

        <view class="u-body-item u-flex">
          <view class="u-body-item-title">提交人:</view>
          <view class="u-line-1 u-body-value">{{ i.userName || '--' }}</view>
        </view>

        <!-- 照片 -->
        <view class="photo-block">
          <view class="u-body-item-title">照片:</view>
          <view class="cell-content-wrap">
            <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>
        </view>
      </view>


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

<script setup lang="ts">
import { ref, reactive } from 'vue';
import { inspectioDetailByPlanno } from "@/api/patrol-manage/patrol-plan";
import { onLoad, onShow } 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,
      problemImgsList: Array.isArray(res.problemImgsList) ? res.problemImgsList : [],
      completeImgsList: Array.isArray(res.completeImgsList) ? res.completeImgsList : []
    };
  } 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">
// 页面基础样式
.page-container,
.u-page {
  min-height: 100vh;
  padding-bottom: 40rpx;
  background-color: #F4F6FA;
  box-sizing: border-box;
}

// 内容容器
.content-wrap {
  padding: 0 24rpx;
  width: 100%;
  box-sizing: border-box;
  overflow-y: auto;
}

/* 养护记录卡片:白底圆角 + 标题 + 底部操作区 */
.plan-card {
  margin: 24rpx 0 0;
  padding: 28rpx 28rpx 24rpx;
  background-color: #ffffff;
  border-radius: 16rpx;
  box-shadow: 0 4rpx 16rpx rgba(17, 24, 39, 0.06);
}
.plan-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20rpx;
}
.plan-card__title {
  flex: 1;
  min-width: 0;
  font-size: 32rpx;
  font-weight: 500;
  color: #1F2937;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.plan-card .u-body-item {
  margin-bottom: 12rpx;
}

/* 照片区块 */
.photo-block {
  margin-top: 16rpx;
  padding-top: 16rpx;
  border-top: 1rpx solid #E8EBF0;
}

// 空文本样式
.empty-text {
  color: #909399;
  font-size: 28rpx;
  line-height: 80rpx;
  display: block;
  text-align: left;
}

// 相册样式优化(关键:适配图片展示)
:deep(.up-album) {
  width: 100%;
  box-sizing: border-box;
}

:deep(.up-album__list) {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
}

:deep(.up-album__item) {
  width: calc(33.333% - 10rpx);
  height: 200rpx; // 固定图片高度,避免变形
  margin: 5rpx;
  border-radius: 8rpx;
  overflow: hidden;
  background-color: #f8f8f8;
}

:deep(.up-album__image) {
  width: 100%;
  height: 100%;
  object-fit: cover; // 图片裁剪填充,避免拉伸
}


</style>