<template>
  <theme class="pt-1">
    <view class="h-full w-full overflow-y-scroll">
      <view class="bg-white mx-5 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">{{ name }}</view>
          <view>{{ dayjs(+item.submitTime).format('MM-DD HH:mm') }}</view>
        </view>
        <!-- 提交的链接 -->
        <view class="w-64 break-all text-blue-400 py-2">
          {{ item.details[0] }}
        </view>
        <!-- 该插件物的审核人 -->
        <view class="mb-2">审核人</view>
        <view class="flex justify-between my-3" v-for="items in item.checkerList">
          <view>
            <view class="pb-2 text-gray-800">
              {{ items.checkerName }}
            </view>
            <view class="pb-2">
              {{ items.remark }}
            </view>
            <view class="pb-2" v-if="items.checkTime > 0">
              {{ dayjs(+items.checkTime).format('MM-DD HH:mm') }}
            </view>
          </view>
          <view class="text-center">
            <view v-show="items.isMine !== 1">{{ item.status == null ? '待审核' : item.status === 1 ? '已通过' : '已驳回' }}</view>
            <view v-show="items.isMine === 1 && items.status == null" class="text-sm">待审核</view>
            <view v-show="items.isMine === 1 && items.status !== null" class="text-sm">
              <view>
                {{ items.status === 1 ? '已通过' : '已驳回' }}
              </view>
              <view v-if="items.score > 0">
                <u-circle-progress active-color="#FA8C16" :percent="items.score" width="90" border-width="7" class="mt-2">
                  <view class="u-progress-content">
                    <view class="progress-dot text-white text-center">{{ items.score }}</view>
                  </view>
                </u-circle-progress>
              </view>
            </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([
//   {
//     plugname:'入职插件V0.8输出',
//     subtime:'12/25 13:01',
//     link:'https://www.baidu.com/',
//     reviewer:[
//       {
//         name:'冯老师',
//         time: '12/25 14:22',
//         advise:'加油！',
//         state:'已通过',
//         grade:80
//       },
//       {
//         name:'宋老师',
//         time: '12/28 8:22',
//         advise:'不详细！',
//         state:'已驳回',
//         grade:''
//       },
//       {
//         name:'张老师',
//         time: '',
//         advise:'',
//         state:'待审批',
//         grade:''
//       },
//     ]
//   },
// ])

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

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

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