<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="80px">
            <el-form-item label="设备名称" prop="equipmentName">
                <el-input v-model="queryParams.equipmentName" placeholder="请输入设备名称" clearable />
            </el-form-item>
            <el-form-item label="借用日期" prop="borrowTime">
                <el-date-picker v-model="queryParams.borrowTime" type="date" placeholder="选择日期" value-format="yyyy-MM-dd "
                    clearable />
            </el-form-item>

            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-table v-loading="loading" border :data="lendingRecords" stripe>
            <el-table-column label="序号" type="index" width="55" align="center" />
            <el-table-column label="自编码" align="center" prop="encode" />
            <el-table-column label="设备名称" align="center" prop="equipmentName" />
            <el-table-column label="型号" align="center" prop="model" />
            <el-table-column label="借用日期" align="center" prop="borrowTime" />
            <el-table-column label="借用人" align="center" prop="borrowBy" />
            <el-table-column label="归还状态" align="center" prop="returnState">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.return_state" :value="scope.row.returnState"></dict-tag>
                </template>
            </el-table-column>
            <el-table-column label="用途" align="center" prop="purpose" />
            <el-table-column label="借用期限" align="center" prop="deadline" />
            <el-table-column label="操作" align="center">
                <template v-slot="scope">
                    <el-button size="mini" type="text" icon="el-icon-view" @click="handleLook(scope.row)">查看
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList"></pagination>
        <!--查看对话框 -->
        <el-dialog title="详细信息" :visible.sync="dialogVisible" width="1200px" append-to-body>
            <el-form ref="postForm" :model="postForm" label-width="110px" :disabled="isEdit">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="自编码" prop="encode">
                            <el-input v-model="postForm.encode"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="设备名称" prop="equipmentName">
                            <el-input v-model="postForm.equipmentName"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="型号" prop="model">
                            <el-input v-model="postForm.model"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="借用日期:" prop="borrowTime">
                            <el-date-picker v-model="postForm.borrowTime" type="datetime" style="width: 100%;"
                                value-format="yyyy-MM-dd HH:mm:ss" clearable></el-date-picker>
                        </el-form-item>

                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="借用人" prop="borrowBy">
                            <el-input v-model="postForm.borrowBy" clearable />
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="用途" prop="purpose">
                            <el-input v-model="postForm.purpose" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="借用期限" prop="deadline">
                            <el-input v-model="postForm.deadline" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="归还状态" prop="returnState">
                            <el-select v-model="postForm.returnState" clearable style="width: 100%;">
                                <el-option v-for="dict in dict.type.return_state" :key="dict.value" :label="dict.label"
                                    :value="dict.value" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
            </span>

        </el-dialog>

    </div>
</template>

<script>


import {
    listTeacherjy,
    listTeacherjyxq
} from "@/api/smartSchool/personWork/propertyManagement";
export default {
    dicts: ['return_state'],
    data() {
        return {
            queryParams: {
                equipmentName: '',
                borrowTime: '',
                pageNum: 1,
                pageSize: 10,
            },

            //借出记录数据
            lendingRecords: [],
            loading: false,
            total: 0,
            dialogVisible: false,
            postForm: {
                borrowBy: "",
                borrowByid: "",
                borrowTime: "",
                deadline: "",
                delFlag: "",
                encode: undefined,
                equipmentId: "",
                equipmentName: "",
                id: "",
                model: "",
                purpose: "",

            },
            isEdit: false,
        }
    },
    created() {
        this.getList();
    },
    methods: {
        //获取数据信息
        getList() {
            listTeacherjy(this.queryParams).then((response) => {
                this.lendingRecords = response.rows;
                this.loading = false;
                console.log(111, response.rows);
                this.total = response.total;
            });
        },
        //重置
        resetQuery() {
            this.queryParams = {
                equipmentName: '',
                borrowTime: '',
                pageNum: 1,
                pageSize: 10,
            },
                this.getList();
        },
        //导出
        exportRecord() { },
        handleLook(row) {
            console.log(row);
            const params = {
                id: row.id,
            }
            listTeacherjyxq(params).then(response => {
                console.log(response);
                this.postForm = response.data;
                console.log(this.postForm);
                this.dialogVisible = true;
                this.isEdit = true;
            });
        },

    }

}
</script>

<style lang="scss" scoped></style>

