order-detail.vue 5.43 KB
<template>
  <view class="u-page">


    <!-- 页面级加载组件(up-loading-page,uview-plus标准组件) -->
    <up-loading-page
        v-if="loading"
        :loading="true"
        title="加载中..."
        color="#3c9cff"
    ></up-loading-page>

    <!-- 内容容器(仅在非加载状态显示) -->
    <view v-else class="content-wrap">
      <!-- 单元格分组(核心uview组件) -->
      <up-cell-group :border="false" inset style="margin: 20rpx;" >
        <!-- 1. 工单编号 -->
        <up-cell
            title="工单编号"
            :value="orderDetail.orderNo || '--'"
            class="up-line-1"
            align="middle"
        ></up-cell>

        <!-- 2. 工单位置 -->
        <up-cell
            title="工单位置"
            :value="orderDetail.roadName || '--'"
            class="up-line-1"
            align="middle"
        ></up-cell>

        <!-- 3. 工单名称 -->
        <up-cell
            title="工单名称"
            :value="orderDetail.orderName || '--'"
            class="up-line-1"
            align="middle"
        ></up-cell>

        <!-- 4. 情况描述 -->
        <up-cell
            title="情况描述"
            :value="orderDetail.remark || '--'"
            class="up-line-1"
            align="middle"
        ></up-cell>

        <!-- 5. 问题照片 -->
        <up-cell title="问题照片" align="top">
          <view class="cell-content-wrap">
            <up-album
                v-if="orderDetail.imgs && orderDetail.imgs.length"
                :list="formatAlbumList(orderDetail.imgs)"
                :column="3"
                :max-count="9"
                :preview-full-image="true"
                disabled
                style="width: 100%;"
            ></up-album>
            <text v-else class="empty-text">暂无问题照片</text>
          </view>
        </up-cell>

        <!-- 6. 完成照片 -->
        <up-cell title="完成照片" align="top">
          <view class="cell-content-wrap">
            <up-album
                v-if="orderDetail.longRangeImgList && orderDetail.longRangeImgList.length"
                :list="formatAlbumList(orderDetail.longRangeImgList)"
                :column="3"
                :max-count="9"
                :preview-full-image="true"
                disabled
                style="width: 100%;"
            ></up-album>
            <text v-else class="empty-text">暂无完成照片</text>
          </view>
        </up-cell>

        <!-- 7. 处理结果 -->
        <up-cell
            title="处理结果"
            :value="orderDetail.handleResultDesc || '--'"
            class="up-line-1"
            align="middle"
            :border="false"
        ></up-cell>
      </up-cell-group>

      <!-- 空状态(原生样式,替代up-empty) -->
      <view v-if="!Object.keys(orderDetail).length" class="empty-wrap">
        <text class="empty-icon">📄</text>
        <text class="empty-text">暂无工单详情</text>
        <text class="empty-subtext">请检查工单ID是否正确</text>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue';
import { inspectionPlanDetail } from "@/api/quick-order/quick-order";

import { onLoad, onShow } from '@dcloudio/uni-app';
// 状态管理
const loading = ref(true);
const orderDetail = ref({});

/**
 * 格式化相册列表(适配up-album)
 */
const formatAlbumList = (imgUrls: string[]) => {
  return imgUrls.map(url => ({
    url,
    thumb: url,
    name: `图片-${Date.now()}`
  }));
};

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

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

// 页面加载
onLoad((options) => {
  const { id } = options;
  if (id) {
    getOrderDetail(id);
  } 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;
  overflow-y: auto;
}

// 单元格内容包裹层
.cell-content-wrap {
  width: 100%;
  padding: 10rpx 0;
  box-sizing: border-box;
}

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

// 优化uview组件样式
:deep(.up-cell-group) {
  --u-cell-group-background-color: #fff;
  --u-cell-group-border-radius: 12rpx;
  --u-cell-group-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
:deep(.up-cell) {
  --u-cell-title-font-size: 28rpx;
  --u-cell-value-font-size: 28rpx;
  --u-cell-title-color: #666;
  --u-cell-value-color: #333;
  --u-cell-padding: 20rpx 15rpx;
  --u-cell-border-color: #f5f5f5;
}
:deep(.up-album__item) {
  margin: 10rpx 5rpx;
  border-radius: 8rpx;
}

// 原生空状态样式
.empty-wrap {
  margin-top: 200rpx;
  text-align: center;
}
.empty-icon {
  font-size: 80rpx;
  display: block;
  margin-bottom: 20rpx;
  color: #ddd;
}
.empty-text {
  font-size: 28rpx;
  color: #999;
  display: block;
}
.empty-subtext {
  font-size: 24rpx;
  color: #ccc;
  margin-top: 10rpx;
  display: block;
}

// 适配up-loading-page样式
:deep(.up-loading-page) {
  margin-top: 100rpx;
}
</style>