<template>
  <theme>
    <view class="h-full w-full px-3 pt-1 overflow-y-scroll">
      <view class="bg-white my-2 rounded-md p-3 text-gray-400" v-for="item in listRef">
        <!-- 插件名称和提交时间显示 -->
        <view class="flex justify-between mb-2">
          <view class="text-gray-800">{{ deliverName }}</view>
          <view class="text-xs">{{ dayjs(+item.submitTime).format('MM-DD HH:mm') }}</view>
        </view>
        <!-- 提交的链接 -->
        <DeliverLink v-if="item.details[0]" :link="item.details[0]" />
        <!-- 该插件物的审核人 -->
        <view class="mb-1 mt-3">审核人</view>
        <view class="flex justify-between mb-2" v-for="checkItem in item.checkerList">
          <view>
            <view class="mb-1 text-gray-800 font-semibold">
              {{ checkItem.checkerName }}
            </view>
            <view class="mb-1 text-xs">
              {{ checkItem.remark }}
            </view>
            <view class="mb-1 text-xs" v-if="+checkItem.checkTime > 0">
              {{ dayjs(+checkItem.checkTime).format('MM-DD HH:mm') }}
            </view>
          </view>

          <view class="text-center text-xs">
            <view v-if="checkItem.status == null" class="text-gray-400">待审核</view>
            <view v-else-if="checkItem.status === 1">
              <view class="text-green-600 mb-1">已通过</view>

              <zwp-ring-timing mode="chart" :value="checkItem.score" active-color="#F59E0B" :radius="30" bar-width="4">
                <text class="text-yellow-500 font-medium">{{ checkItem.score }}</text>
              </zwp-ring-timing>
            </view>
            <view class="text-red-600" v-else>已驳回</view>
          </view>
        </view>
      </view>
    </view>
  </theme>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import dayjs from 'dayjs';

const listRef = ref([]);
const deliverName = ref('');

onLoad(options => {
  // 根据交付物id获取上传记录
  (async function getHistory() {
    try {
      const param = { deliverId: options.deliverId };
      const data = await uni.$u.api.getDeliverHistory(param);
      deliverName.value = data.deliverName;
      listRef.value = data.deliverRecordList;
    } catch (error) {
      console.log('error: ', error);
      uni.$ui.showToast('获取交付物历史失败');
    }
  })();
});
</script>

<style lang="scss"></style>
