<template>
	<request-form
		title="出差申请"
		subtitle="填写出差信息，支持手机端快速提交"
		biz-type="travel"
		:request-api="submitTravel"
		:initial-form="initialForm"
		:sections="sections"
		:flow-fields="flowFields"
	/>
</template>

<script>
import RequestForm from '@/components/hrm/RequestForm.vue'
import { addTravelReq } from '@/api/hrm/travel'

export default {
	components: { RequestForm },
	data() {
		return {
			initialForm: { travelType: '', startTime: '', endTime: '', destination: '', reason: '', applyFileIds: '', remark: '' },
			sections: [
				{ key: 'basic', title: '基础信息', fields: [
					{ key: 'travelType', label: '出差类型', type: 'select', required: true, placeholder: '请选择出差类型', options: ['客户拜访', '项目支持', '培训学习', '会议会展', '验收交付', '其他'] },
					{ key: 'startTime', label: '开始时间', type: 'datetime', required: true, placeholder: '请选择开始时间' },
					{ key: 'endTime', label: '结束时间', type: 'datetime', required: true, placeholder: '请选择结束时间' },
					{ key: 'destination', label: '目的地', type: 'city', required: true, placeholder: '请选择全球城市' }
				]},
				{ key: 'desc', title: '说明', fields: [
					{ key: 'reason', label: '事由', type: 'textarea', required: true, placeholder: '请说明出差目的与任务' },
					{ key: 'applyFileIds', label: '附件', type: 'file', required: false, placeholder: '上传附件文件' },
					{ key: 'remark', label: '备注', type: 'textarea', required: false, placeholder: '可选' }
				]}
			],
			flowFields: [
				{ key: 'travelType', label: '出差类型', required: true },
				{ key: 'startTime', label: '开始时间', required: true },
				{ key: 'endTime', label: '结束时间', required: true },
				{ key: 'destination', label: '目的地', required: true },
				{ key: 'reason', label: '事由', required: true }
			]
		}
	},
	methods: { submitTravel(payload) { return addTravelReq(payload) } }
}
</script>

<style scoped></style>