<template>
	<wd-cell-group>
		<wd-cell  title="申请信息" value="历史查询" size="large" clickable @click="onClick"/>
		<wd-cell title="职工姓名" :value="info.username_dictText" />
		<wd-cell title="所属单位" :value="info.sysOrgCode_dictText" />
		<wd-cell title="联系方式" :value="info.phone" />
		<wd-cell title="请假类型" :value="info.type" />
		<wd-cell title="请假开始时间" :value="info.begintime" />
		<wd-cell title="请假结束时间" :value="info.endtime" />
		<wd-cell title="请假天数" :value="info.days + '天'" />
		<wd-cell title="出发地" :value="info.departure" />
		<wd-cell title="目的地" :value="info.destination" />
		<wd-cell title="请假原因" :value="info.reason" />
		<wd-cell title="附件" v-if="info.path">
			<template v-for="(img, index) in image" :key="index">
				<wd-img :width="100" :height="100" :src="img" :enable-preview="true" />
			</template>
		</wd-cell>
	</wd-cell-group>
</template>

<script setup>
	import {
		queryByIdApi
	} from '@/api/humanResource/absence'
	import {
		imgUrl
	} from '@/utils/index'
	const info = ref({})
	const image = ref([])
	const props = defineProps({
		formData: {
			type: Object,
			default: () => {},
		}
	})

	const onClick = () => {
		uni.navigateTo({
			url: `/pages-humanResource/absence/index?username=${info.value.username}`
		});
	}
	// 申请信息
	const queryById = () => {
		queryByIdApi(props.formData.dataId).then((res) => {
			if (res.success) {
				info.value = res.result.records[0]
				if(info.value.path){
					image.value = info.value.path.split(',').map(path => imgUrl(path))
				}
			}
		})
	}

	onMounted(() => {
		queryById()
	})
</script>