<template>
    <!-- 基础管理-设备管理-领用或归还 -->
    <div>
        <el-form :model="useOrReturnForm" :rules="useOrReturnFormRules" ref="useOrReturnFormRef" label-width="100px">
            <el-form-item label="领用人" prop="user">
                <el-input v-model="useOrReturnForm.user" placeholder="请输入领用人" />
            </el-form-item>
            <el-form-item label="领用时间" prop="useTime">
                <el-date-picker
                    type="date"
                    style="width: 100%"
                    placeholder="选择领用时间"
                    value-format="yyyy-MM-dd"
                    v-model="useOrReturnForm.useTime"
                />
            </el-form-item>
            <el-form-item label="退还人" prop="returnUser">
                <el-input v-model="useOrReturnForm.returnUser" placeholder="请输入退还人" />
            </el-form-item>

            <el-form-item>
                <el-button @click="cancel">取消</el-button>
                <el-button type="primary" @click="submitForm">确定</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
export default {
    name: 'useOrReturnForm',

    data() {
        return {
            useOrReturnForm: {
                user: '',
                useTime: '',
                returnUser: '',
            },
            useOrReturnFormRules: {
                user: [{ required: true, message: '请输入领用人', trigger: 'blur' }],
                useTime: [{ required: true, message: '请选择领用时间', trigger: 'change' }],
                returnUser: [{ required: true, message: '请输入退还人', trigger: 'blur' }],
            },
        }
    },
    methods: {
        cancel() {
            this.$emit('closeUseOrReturnFormDialog')
        },
        submitForm() {
            // this.$emit('submitForm')

            this.$refs.useOrReturnFormRef.validate((valid) => {
                if (valid) {
                    this.$emit('closeUseOrReturnFormDialog')
                } else {
                    return false
                }
            })
        },
        resetForm() {
            this.$refs.useOrReturnFormRef.resetFields()
        },

        setFormData(data) {},
    },
}
</script>
