<template>
	<view class="ncc-wrap ncc-wrap-workflow">
		<u-form :model="dataForm" :rules="rules" ref="dataForm" :errorType="['toast']" label-position="left"
			label-width="150" label-align="left">
			<u-form-item label="流程标题" prop="flowTitle" v-if="judgeShow('flowTitle')" required>
				<u-input v-model="dataForm.flowTitle" placeholder="流程标题" :disabled="judgeWrite('flowTitle')"></u-input>
			</u-form-item>
			<u-form-item label="流程编码" prop="billNo" v-if="judgeShow('billNo')" required>
				<u-input v-model="dataForm.billNo" placeholder="流程编码" disabled></u-input>
			</u-form-item>
			<u-form-item label="紧急程度" prop="flowUrgent" v-if="judgeShow('flowUrgent')" required>
				<ncc-select v-model="dataForm.flowUrgent" placeholder="请选择紧急程度" :options="flowUrgentOptions"
					:disabled="judgeWrite('flowUrgent')">
				</ncc-select>
			</u-form-item>

			<view class="ncc-card">
				<u-form-item label="申请人员" prop="applyUser" v-if="judgeShow('applyUser')">
					<u-input v-model="dataForm.applyUser" placeholder="请输入申请人员" :disabled="judgeWrite('applyUser')">
					</u-input>
				</u-form-item>
				<u-form-item label="申请部门" prop="applyDept" v-if="judgeShow('applyDept')">
					<u-input v-model="dataForm.applyDept" placeholder="请输入申请部门" :disabled="judgeWrite('applyDept')">
					</u-input>
				</u-form-item>
				<u-form-item label="申请职位" prop="applyPost" v-if="judgeShow('applyPost')">
					<u-input v-model="dataForm.applyPost" placeholder="请输入申请职位" :disabled="judgeWrite('applyPost')">
					</u-input>
				</u-form-item>
				<u-form-item label="申请日期" prop="applyDate" v-if="judgeShow('applyDate')">
					<ncc-date-time type="date" v-model="dataForm.applyDate" placeholder="请输入申请日期"
						:disabled="judgeWrite('applyDate')"></ncc-date-time>
				</u-form-item>
				<u-form-item label="请假类别" prop="leaveType" v-if="judgeShow('leaveType')" required>
					<ncc-select v-model="dataForm.leaveType" placeholder="请选择下拉框组" :options="leaveTypeList"
						:disabled="judgeWrite('leaveType')"></ncc-select>
				</u-form-item>
				<u-form-item label="请假原因" prop="leaveReason" v-if="judgeShow('leaveReason')" required>
					<u-input v-model="dataForm.leaveReason" placeholder="请输入请假原因" type="textarea"
						:disabled="judgeWrite('leaveReason')"></u-input>
				</u-form-item>
				<u-form-item label="起始时间" prop="leaveStartTime" v-if="judgeShow('leaveStartTime')" required>
					<ncc-date-time type="datetime" v-model="dataForm.leaveStartTime" placeholder="请输入起始时间"
						:disabled="judgeWrite('leaveStartTime')"></ncc-date-time>
				</u-form-item>
				<u-form-item label="结束时间" prop="leaveEndTime" v-if="judgeShow('leaveEndTime')" required>
					<ncc-date-time type="datetime" v-model="dataForm.leaveEndTime" placeholder="请输入结束时间"
						:disabled="judgeWrite('leaveEndTime')"></ncc-date-time>
				</u-form-item>

				<u-form-item label="请假天数" prop="leaveDayCount" v-if="judgeShow('leaveDayCount')" required>
					<u-input v-model="dataForm.leaveDayCount" placeholder="请输入请假天数"
						:disabled="judgeWrite('leaveDayCount')"></u-input>
				</u-form-item>
				<u-form-item label="请假小时" prop="leaveHour" v-if="judgeShow('leaveHour')" required>
					<u-input v-model="dataForm.leaveHour" placeholder="请输入请假小时" type="number"
						:disabled="judgeWrite('leaveHour')"></u-input>
				</u-form-item>
				<u-form-item label="相关附件" prop="fileJson" v-if="judgeShow('fileJson')">
					<ncc-file :list="fileList" :disabled="judgeWrite('fileJson')" />
				</u-form-item>

			</view>
		</u-form>
	</view>
</template>

<script>
	import comMixin from '../mixin'
	export default {
		name: 'LeaveApply',
		mixins: [comMixin],
		data() {
			return {
				billEnCode: 'WF_LeaveApplyNo',
				dataForm: {
					flowTitle: '',
					billNo: '',
					flowUrgent: 1,
					applyUser: '',
					leaveHour: '',
					applyDept: '',
					leaveStartTime: '',
					leaveEndTime: '',
					leaveDayCount: '',
					leaveReason: '',
					applyDate: '',
					leaveType: '',
					fileJson: '',
					applyPost: ''
				},
				rules: {
					flowTitle: [{
						required: true,
						message: '流程标题不能为空',
						trigger: 'blur'
					}],
					flowUrgent: [{
						required: true,
						message: '紧急程度不能为空',
						trigger: 'change',
						type: 'number'
					}],
					billNo: [{
						required: true,
						message: '流程编码不能为空',
						trigger: 'blur',
					}],
					leaveHour: [{
						required: true,
						message: '请假小时不能为空',
						trigger: 'blur',
					}],
					leaveStartTime: [{
						required: true,
						message: '起始时间不能为空',
						trigger: 'blur',
						type: 'number'
					}],
					leaveDayCount: [{
						required: true,
						message: '请假天数不能为空',
						trigger: 'blur',
					}],
					leaveEndTime: [{
						required: true,
						message: '结束时间不能为空',
						trigger: 'blur',
						type: 'number'
					}],
					leaveType: [{
						required: true,
						message: '请假原因不能为空',
						trigger: 'blur',

					}],
				},
				leaveTypeList: [{
						fullName: '事假',
						id: '事假',
						checked: false
					},
					{
						fullName: '病假',
						id: '病假',
						checked: false
					},
					{
						fullName: '婚假',
						id: '婚假',
						checked: false
					},
					{
						fullName: '产假',
						id: '产假',
						checked: false
					},
					{
						fullName: '丧假',
						id: '丧假',
						checked: false
					},
					{
						fullName: '年假',
						id: '年假',
						checked: false
					},
					{
						fullName: '调休',
						id: '调休',
						checked: false
					},
					{
						fullName: '其他',
						id: '其他',
						checked: false
					},

				],
			}
		},
		methods: {
			selfInit(data) {
				this.dataForm.applyDate = new Date().getTime()
				this.dataForm.flowTitle = this.userInfo.userName + "的请假申请表"
				this.dataForm.applyUser = this.userInfo.userName + '/' + this.userInfo.userAccount
				this.dataForm.applyDept = this.userInfo.departmentName
				if (this.userInfo.positionIds && this.userInfo.positionIds.length) {
					let list = this.userInfo.positionIds.map(o => o.name)
					this.dataForm.applyPost = list.join(',')
				}
			},

		}
	}
</script>

<style>

</style>
