<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="86px">
            <el-form-item prop="dateRange">
                <el-date-picker v-model="dateRange" value-format="yyyy-MM-dd" type="datetimerange" range-separator="至"
                    start-placeholder="开始日期" end-placeholder="结束日期">
                </el-date-picker>
            </el-form-item>
            <el-form-item prop="appointmentUserName">
                <el-input size="small" v-model="queryParams.appointmentUserName" placeholder="预约人姓名" clearable />
            </el-form-item>
            <el-form-item class="ml20">
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <!-- 表格数据 -->
        <el-table v-loading="loading" :data="studioList" stripe>
            <el-table-column label="序号" type="index" width="55" align="center" />
            <el-table-column label="录播室" align="center" prop="studioName" />
            <el-table-column label="预约日期" align="center" prop="appointmentTime" />
            <el-table-column label="预约节次" align="center" prop="appointmentJc" />
            <el-table-column label="录播内容" align="center" prop="studioContent" />
            <el-table-column label="预约人" align="center" prop="appointmentUserName" />
            <el-table-column label="申请时间" align="center" min-width="200px" prop="applyTime" />
            <el-table-column label="状态" align="center" min-width="200px" prop="statu">
                <template slot-scope="{ row }">
                    {{ row.statu == '1' ? "预约成功" : row.statu == '2' ? "已取消" : "" }}
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">详情
                    </el-button>
                </template>
            </el-table-column>
        </el-table>

        <!--详情对话框 -->
        <el-dialog :title="title" :visible.sync="look" width="1200px" append-to-body @close="cancel">
            <el-form ref="postForm" :model="postForm" :rules="rules" label-width="110px">

                <h2 style="text-align: center;font-size: 24px;font-family: SourceHanSansSC-regular;">录播室预约单</h2>
                <div>
                    <div class="dialog-footer btn">
                        <el-button class="btnup" type="primary" @click="cancel">关 闭</el-button>
                    </div>
                    <table style="width: 100%;" class="tabstyle">
                        <tr>
                            <td>录播室</td>
                            <td class="btntext">{{ studioName }}</td>
                            <td>预约日期</td>
                            <td class="btntext">{{ appointmentTime }}</td>

                        </tr>
                        <tr>
                            <td>节次</td>
                            <td class="btntext">{{ appointmentJc }}</td>
                            <td>预约人</td>
                            <td class="btntext">{{ appointmentUserName }}</td>
                        </tr>
                        <td rowspan="1" class="btntxt">录播内容</td>
                        <td colspan="5">{{ studioContent }}</td>


                        <tr>
                            <td>申请时间</td>
                            <td>{{ applyTime }}</td>
                            <td>状态</td>
                            <td class="btntext" colspan="5">{{ statu === '1' ? '预约成功' : '已取消' }}</td>
                        </tr>
                    </table>
                </div>
                <div class="sm">说明：录播室每天开放 上午四节、下午四节、晚上三节。共计每天11节。
                    请提前一天进行预约。
                </div>
            </el-form>
        </el-dialog>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList"></pagination>



    </div>
</template>

<script>
import {
    listStuditor,// 查看全部录播室预约情况列表
    getStuditor// 查看录播室预约详情
} from "@/api/smartSchool/personWork/venueReservation/appointmentRecordingroom"

export default {
    name: 'appointmentRecordingroom',
    data() {
        return {
            dialogEditNote: false,
            form: {},
            // 日期范围
            dateRange: [],
            // 模糊搜索
            queryParams: {
                dateRange: [],
                appointmentUserName: "",
                pageNum: 1,
                pageSize: 10,
            },
            // 加载遮罩
            loading: true,
            // 记录条数
            total: 0,
            // 弹出层标题
            title: "",
            // 查看列表
            postForm: {

            },
            // 录播室名称
            studioName: "",
            //预约日期
            appointmentTime: "",
            // 节次
            appointmentJc: "",
            // 预约人
            appointmentUserName: "",
            // 录播内容
            studioContent: "",
            // 状态
            statu: "",
            // 申请时间
            applyTime: "",
            // 记录列表
            studioList: [

            ],
            rules: {},
            // 详情
            look: false,
        };
    },
    methods: {
        // 获取列表
        getList() {
            this.loading = true;
            const params = {
                appointmentUserName: this.queryParams.appointmentUserName,
                startTime: this.dateRange[0],
                endTime: this.dateRange[1],
            };
            console.log(123, params);
            listStuditor(params).then(response => {
                this.studioList = response.rows;
                this.total = response.total;
                this.loading = false;
            })
        },
        // 模糊搜索
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },

        // 重置
        resetQuery() {
            this.dateRange = [];
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 详情
        handleEdit(row) {
            const id = row.id || this.ids
            // this.title = "查看";
            this.postForm = row;
            console.log(111, row)
            getStuditor(id).then((response) => {
                console.log(333, this.postForm);
                this.studioName = response.data.studioName;
                this.appointmentTime = response.data.appointmentTime;
                this.appointmentJc = response.data.appointmentJc;
                this.appointmentUserName = response.data.appointmentUserName;
                this.studioContent = response.data.studioContent;
                this.statu = response.data.statu;
                this.applyTime = response.data.applyTime;
                this.look = true;
            });


        },
        // 取消按钮
        cancel() {
            this.look = false;
            this.form = {}
            this.handleQuery();
        },
    },
    created() {
        this.getList()
    },
};
</script>
<style lang="scss">
.tabstyle {
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 16px !important;

}

.tabstyle td,
.tabstyle th {
    border: 1px solid black;
    padding: 8px;
    position: relative;
}

.tabstyle input[type="text"] {
    border: none;
    outline: none;
    font-size: inherit;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    /* opacity: 0; */
}

.btntext {
    width: 300px;
}

.btn {
    display: flex;
    flex-direction: row;
    justify-content: end;

}

.btnup {
    margin-left: 12px;
    margin-bottom: 15px;
    padding: 9px 25px;
    border-radius: 6px;
    background-color: rgba(15, 64, 245, 1);
    color: rgba(255, 255, 255, 1);
    font-size: 13px;
    text-align: center;
    font-family: PingFang SC;

}
</style>
