<script setup lang="ts" name="LeaveDetailFlow">
/* 出差详情 */
import { ref, reactive, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
// import { showImagePreview } from 'vant'
import { getFlowChart } from '@/api/flowEngine/flowInterface'
import { getBusinessTrip } from '@/api/attendance/trip'
import { useDict } from '@/common/utils/dict'
import FlowTimeline from '@/components/Flow/FlowTimeline.vue'
import TripCloseListItem from './TripCloseListItem.vue'
import { listTAmCarManageAll, getTAmCarApply, addTAmCarApply, updateTAmCarApply } from '@/api/carUse/index'
const router = useRouter()
const props = defineProps<{
  id: string
  instanceId: string
}>()

const { request_leave_type } = useDict('request_leave_type')

const detail = ref<any>({})
const detailClose = ref<any>({})
const nodeData = ref<any>()
const activeTab = ref('')

getTAmCarApply(props.id).then(res => {
  detail.value = res.data
})
getFlowChart({ instanceId: props.instanceId }).then(res => {
  nodeData.value = res.data
})

// 预览
// 预览
function onPreview(index) {
  // showImagePreview({
  //   images: detail.value.fileList.map(item => item.url),
  //   startPosition: index
  // })

  uni.previewImage({
    urls:detail.value.fileList.map(item => item.url),
    current:index
  })
}

// 点击销假列表
function onDetailClose(item) {
  router.push({
    path: '/attendance/trip/close-detail',
    query: {
      id: item.id,
      instanceId: item.instanceId
    }
  })
}
</script>

<template>

  <van-cell-group>
    <van-cell title="车号" :value="detail.carNum" />
    <van-cell title="申请时间" :value="detail.applyDate" />
    <van-cell title="归还时间" :value="detail.applyBacktime" />
    <van-cell title="申请时长(小时)" :value="detail.applyLong" />
    <van-cell title="申请原因" :value="detail.applyReason" />
    <van-cell title="备注" :value="detail.remarks" />
    <van-grid
      v-if="detail.fileList?.length"
      :border="false"
      :column-num="3"
      class="grid">
      <template v-for="(item, index) in detail.fileList" :key="index">
        <van-grid-item>
          <van-image :src="item.url" @click="onPreview(index)" />
        </van-grid-item>
      </template>
    </van-grid>
  </van-cell-group>
  <FlowTimeline :node-data="nodeData" />


</template>

<style lang="less" scoped>
.grid {
  :deep(.van-image) {
    width: 100%;
    height: 0;
    padding-bottom: 100%;
    .van-image__img {
      position: absolute;
      object-fit: cover;
    }
  }
}

:deep(.van-cell) {
  .van-cell__title {
    margin-right: 1rem;
    flex: none;
  }
  .van-cell__value {
    display: flex;
    justify-content: flex-end;
    color: var(--van-cell-text-color);
    overflow: hidden;
    span {
      text-align: justify;
    }
  }
}
</style>
