<template>
    <div class="app-container">
        <el-dialog title="查询" :visible.sync="query" width="50%" append-to-body>
            <el-form ref="queryParams" :model="queryParams" label-width="96px" class="search">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="学科" prop="sub">
                            <el-select v-model="queryParams.sub" clearable placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.teaching_subjects" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="获奖类别" prop="awardtype">
                            <el-select v-model="queryParams.awardtype" clearable placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.award_type_fdxs" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="获奖级别" prop="awardrank">
                            <el-select v-model="queryParams.awardrank" clearable placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.awards_level" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="获奖等级" prop="awardlevel">
                            <el-select v-model="queryParams.awardlevel" clearable placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.award_rank" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="获奖人" prop="username">
                            <el-input v-model="queryParams.username" placeholder="请输入获奖人" clearable
                                @keyup.enter.native="handleQuery" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="指导教师" prop="guidanceteacher">
                            <el-input v-model="queryParams.guidanceteacher" clearable placeholder="请输入内容" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="获奖开始时间" prop="startTime">
                            <el-date-picker clearable v-model="queryParams.startTime" type="date" value-format="yyyy-MM-dd"
                                placeholder="请选择" style="width: 100%;">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="获奖结束时间" prop="endTime">
                            <el-date-picker clearable v-model="queryParams.endTime" type="date" value-format="yyyy-MM-dd"
                                placeholder="请选择" style="width: 100%;">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item>
                    <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-dialog>
        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-search" size="mini" @click="handleQuerycx">查询</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                    v-hasPermi="['school:fudaos:addgl']">新增</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
                    v-hasPermi="['school:fudaos:edit']">修改</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
                    v-hasPermi="['school:fudaos:delete']">删除</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                    v-hasPermi="['school:fudaos:export']">导出</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table :row-style="{ height: '1px' }" :cell-style="{ padding: '0px' }"
            :header-cell-style="{ height: '50px', fontSize: '12px', padding: '0 0' }" :data="awardsList"
            @selection-change="handleSelectionChange" :default-sort="{ prop: 'awardtime', order: 'descending' }">
            <el-table-column type="selection" width="30" align="center" />
            <el-table-column type="index" label="序号" width="30" align="center" sortable fixed="left" />
            <el-table-column label="成长类型" align="center" fixed="left" width="90px" show-overflow-tooltip>
                <template>
                    <span>辅导学生获奖</span>
                </template>
            </el-table-column>
            <el-table-column label="学科" align="center" prop="sub" sortable fixed="left" width="60px" show-overflow-tooltip>
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.teaching_subjects" :value="scope.row.sub" />
                </template>
            </el-table-column>
            <el-table-column label="获奖类别" align="center" prop="awardtype" sortable width="80px" show-overflow-tooltip>
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.award_type_fdxs" :value="scope.row.awardtype" />
                </template>
            </el-table-column>
            <el-table-column label="获奖等级" align="center" prop="awardlevel" sortable width="80px" show-overflow-tooltip>
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.award_rank" :value="scope.row.awardlevel" />
                </template>
            </el-table-column>
            <el-table-column label="获奖级别" align="center" prop="awardrank" sortable width="100px" show-overflow-tooltip>
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.awards_level" :value="scope.row.awardrank" />
                </template>
            </el-table-column>
            <el-table-column label="比赛名称" align="center" prop="resultname" sortable width="120px" show-overflow-tooltip />
            <el-table-column label="获奖人" align="center" prop="username" sortable width="80px" show-overflow-tooltip />
            <el-table-column label="指导教师" align="center" prop="guidanceteacher" sortable width="80px"
                show-overflow-tooltip />
            <el-table-column label="主办单位" align="center" prop="org" sortable width="100px" show-overflow-tooltip />
            <el-table-column label="获奖时间" align="center" prop="awardtime"  sortable show-overflow-tooltip>
                <!-- <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.awardTime, '{y}-{m}-{d}') }}</span>
                </template> -->
            </el-table-column>
            <el-table-column label="审核状态" align="center" prop="auditstate" sortable width="80" fixed="right">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.audit_states" :value="scope.row.auditstate" />
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160" fixed="right">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                        v-hasPermi="['school:fudaos:edit']"
                        v-if="scope.row.auditstate === '1' || scope.row.auditstate === '2' || scope.row.auditstate === '3'">修改</el-button>
                    <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                        v-hasPermi="['school:fudaos:delete ']"
                        v-if="scope.row.auditstate === '1' || scope.row.auditstate === '2' || scope.row.auditstate === '3'">删除</el-button>
                    <el-button size="mini" type="text" icon="el-icon-s-check" @click="handleExamine(scope.row)"
                        v-hasPermi="['school:fudaos:submit']" v-if="scope.row.auditstate === '1'">审核</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" />

        <!-- 添加或修改教师获奖对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
            <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="学科" prop="sub">
                            <el-select v-model="form.sub" clearable placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.teaching_subjects" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="获奖类别" prop="awardtype">
                            <el-select v-model="form.awardtype" clearable placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.award_type_fdxs" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="获奖级别" prop="awardrank">
                            <el-select v-model="form.awardrank" clearable placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.awards_level" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="获奖等级" prop="awardlevel">
                            <el-select v-model="form.awardlevel" clearable placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.award_rank" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="成果名称" prop="resultname">
                            <el-input v-model="form.resultname" placeholder="请输入成果名称" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="指导教师" prop="guidanceteacher">
                            <el-input v-model="form.guidanceteacher" placeholder="请输入内容" clearable />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>

                    <el-col :span="12">
                        <el-form-item label="获奖人" prop="username">
                            <el-input v-model="form.username" placeholder="请选择分管领导" clearable
                                @input="openSelect('选择分管领导', 'leaderList', 2)"
                                @focus="openSelect('选择分管领导', 'leaderList', 2)"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="主办单位" prop="org">
                            <el-input v-model="form.org" placeholder="请输入主办单位" clearable />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="获奖时间" prop="awardtime">
                            <el-date-picker clearable v-model="form.awardtime" type="date" value-format="yyyy-MM-dd"
                                placeholder="请选择获奖时间" style="width: 100%;">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="备注" prop="remark">
                            <el-input v-model="form.remark" placeholder="请输入备注" clearable />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12" class="custom-margin">
                        <el-form-item label="证书图片" prop="pictureurl">
                            <el-upload v-loading="uploadLoading" class="avatar-uploader" action="#" accept="image/*"
                                :show-file-list="false" :on-success="handleAvatarSuccess"
                                :before-upload="beforeAvatarUpload" :http-request="uploadImage">
                                <img v-if="form.pictureurl" :src="baseUrl + form.pictureurl"
                                    style="max-width: 100%; max-height: 100%" class="avatar" alt="" />
                                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                            </el-upload>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>

        <!-- 审核 -->
        <el-dialog :title="title" :visible.sync="look" width="1000px" append-to-body>
            <el-form ref="form" :model="form" :rules="rules" label-width="80px" :disabled="isEdit">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="学科" prop="sub">
                            <el-select v-model="form.sub" placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.teaching_subjects" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="获奖类别" prop="awardtype">
                            <el-select v-model="form.awardtype" placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.award_type_fdxs" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="获奖级别" prop="awardrank">
                            <el-select v-model="form.awardrank" placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.awards_level" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="获奖等级" prop="awardlevel">
                            <el-select v-model="form.awardlevel" placeholder="请选择" style="width: 100%;">
                                <el-option v-for="dict in dict.type.award_rank" :key="dict.value" :label="dict.label"
                                    :value="dict.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="成果名称" prop="resultname">
                            <el-input v-model="form.resultname" placeholder="请输入成果名称" />
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="指导教师" prop="guidanceteacher">
                            <el-input v-model="form.guidanceteacher" placeholder="请输入内容" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="获奖人" prop="username">
                            <el-input v-model="form.username" placeholder="请选择分管领导"
                                @input="openSelect('选择分管领导', 'leaderList', 2)"
                                @focus="openSelect('选择分管领导', 'leaderList', 2)"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="主办单位" prop="org">
                            <el-input v-model="form.org" placeholder="请输入主办单位" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="获奖时间" prop="awardtime">
                            <el-date-picker clearable v-model="form.awardtime" type="date" value-format="yyyy-MM-dd"
                                placeholder="请选择获奖时间" style="width: 100%;">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="备注" prop="remark">
                            <el-input v-model="form.remark" placeholder="请输入备注" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12" class="custom-margin">
                        <el-form-item label="证书图片" prop="pictureurl">
                            <el-upload v-loading="uploadLoading" class="avatar-uploader" action="#" accept="image/*"
                                :show-file-list="false" :on-success="handleAvatarSuccess"
                                :before-upload="beforeAvatarUpload" :http-request="uploadImage">
                                <img v-if="form.pictureurl" :src="baseUrl + form.pictureurl"
                                    style="max-width: 100%; max-height: 100%" class="avatar" alt="" />
                                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                            </el-upload>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer" style="display: flex;justify-content: center;">
                <el-button @click="handleAgree" type="primary" size="small">同意</el-button>
                <el-button @click="handleDisagree" type="danger" size="small">不同意</el-button>
            </div>
        </el-dialog>
        <!-- 选择对应处理人 -->
        <SelectUser :id="selectHandles.id" :open.sync="selectHandles.open" :title="selectHandles.title"
            :width="selectHandles.width" :execute="selectHandles.method" @select="selectUser"></SelectUser>

    </div>
</template>

<script>
import { listAward, listAwardgr, getAward, addAward, updateAward, delAward, audit } from "@/api/smartSchool/electronicArchives/professionalDevelopment/awardTutoringstu";
import { uploadImage as commonUpload } from "@/api/common";
import SelectUser from "./components/SelectUser";
export default {
    name: "tutorAward",
    dicts: ["teaching_subjects", 'award_type_fdxs', 'awards_level', 'award_rank', 'coachingr', 'audit_states'],
    components: {
        SelectUser,
    },
    data() {
        return {
            // 选择对应处理人
            selectHandles: {
                id: null,
                open: false,
                title: '',
                width: '50%',
                method: null,
                type: null // 处理类型： 1 级部/处室； 2 分管； 3 主管
            },
            // 图片上传遮罩层
            uploadLoading: false,
            baseUrl: [process.env.VUE_APP_BASE_API],
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 教师获奖表格数据
            awardsList: [{
                id: 1,
                sub: 1,
                awardType: 1,
                awardRank: null,
                awardLevel: null,
                resultName: null,
                userId: null,
                username: null,
                org: null,
                awardTime: null,
                remark: null,
                pictureName: null,
                pictureurl: null,
                createBy: null,
                createTime: null,
                updateBy: null,
                updateTime: null,
                delFlag: null
            }],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            look: false,
            isEdit: false,
            query: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                sub: null,
                awardType: null,
                awardRank: null,
                awardLevel: null,
                resultName: null,
                userId: null,
                username: null,
                org: null,
                awardTime: null,
                pictureName: null,
                pictureurl: null,
            },
            // 表单参数
            form: {},
            // 表单校验
            rules: {
                sub: [
                    { required: true, message: "学科不能为空", trigger: "change" }
                ],
                awardtype: [
                    { required: true, message: "获奖类别不能为空", trigger: "change" }
                ],
                awardrank: [
                    { required: true, message: "获奖级别不能为空", trigger: "change" }
                ],
                awardlevel: [
                    { required: true, message: "获奖等级不能为空", trigger: "change" }
                ],
                resultname: [
                    { required: true, message: "成果名称不能为空", trigger: "blur" }
                ],
                username: [
                    { required: true, message: "获奖人不能为空", trigger: "blur" }
                ],
                coachingr: [
                    { required: true, message: "辅导指责不能为空", trigger: "change" }
                ],
                guidanceteacher: [
                    { required: true, message: "指导老师不能为空", trigger: "blur" }
                ],
                org: [
                    { required: true, message: "主办单位不能为空", trigger: "blur" }
                ],
                awardtime: [
                    { required: true, message: "获奖时间不能为空", trigger: "blur" }
                ],
                pictureurl: [
                    { required: true, message: "证书图片不能为空", trigger: "blur" }
                ],

            }
        };
    },
    created() {
        this.getList();
    },
    methods: {
        /** 查询教师获奖列表 */
        getList() {
            this.loading = true;
            listAward(this.queryParams).then(response => {
                this.awardsList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        //审核
        handleExamine(row) {
            const id = row.id || this.ids;
            getAward(id).then(response => {
                this.look = true;
                this.isEdit = true,
                    this.form = response.data;
                this.pictureurl = this.pev + this.form.pictureurl
                this.title = "修改综合荣誉";
            });
        },
        // 同意
        handleAgree() {
            const params = {
                id: this.form.id,
                auditstate: '2'  // 表示同意
            };
            audit(params).then(({ code }) => {
                console.log(this.form, 'this.form');
                if (code == 200) {
                    this.$modal.msgSuccess('操作成功')
                    this.look = false;
                    this.getList()
                }
            })
        },

        // 不同意
        handleDisagree() {
            const params = {
                id: this.form.id,
                auditstate: '3'  // 表示不同意
            };
            audit(params).then(({ code }) => {
                console.log(this.form, 'this.form');
                if (code == 200) {
                    this.$modal.msgSuccess('操作成功')
                    this.look = false
                    this.getList()
                }
            })
        },
        // 选择处理人:打开对话框
        openSelect(title, method, type) {
            console.log('form.username', this.form.username);

            if (this.form.username) {
                console.log('有值', this.form.username == "");
            } else {
                console.log('没值', this.form.username);
                this.selectHandles.open = true;
                this.selectHandles.title = title;
                this.selectHandles.method = method;
                this.selectHandles.type = type;
            }
        },
        // 选择处理人
        selectUser(select) {
            this.$set(this.form, `username${this.selectHandles.type}`, select.name);
            console.log(select.name);
            this.$set(this.form, `userId${this.selectHandles.type}`, select.id);
            console.log(select.id);
            // 设置顶层的 username 和 userId 字段
            this.form.username = select.name;
            console.log(124, this.form.username);
            console.log(select);
            this.form.userId = select.id;
            console.log(this.form.userId, 'this.form.userId');

            // 重新赋值选中的 id
            this.selectUser.id = select.id;
        },
        // 上传成功回调
        handleAvatarSuccess(res, file) {
            this.pictureurl = res.data.url;
            this.commonUpload(file);
        },

        // 上传前格式和图片大小限制
        beforeAvatarUpload(file) {
            const type =
                file.type === "image/jpeg" ||
                "image/jpg" ||
                "image/webp" ||
                "image/png";
            const isLt2M = file.size / 1024 / 1024 < 2;
            if (!type) {
                this.$message.error("图片格式不正确!(只能包含jpg，png，webp，JPEG)");
            }
            if (!isLt2M) {
                this.$message.error("上传图片大小不能超过 2MB!");
            }
            return type && isLt2M;
        },
        // 上传图片
        uploadImage(file) {
            const fileData = file.file;
            const formData = new FormData();
            formData.append("file", fileData);
            this.uploadLoading = true;
            commonUpload(formData)
                .then((response) => {
                    this.uploadLoading = false;
                    this.$modal.msgSuccess("上传成功");
                    this.pictureurl = this.pev + response.url;
                    this.form.pictureurl = response.url;
                })
                .catch((error) => {
                    this.uploadLoading = false;
                });
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.form = {
                id: null,
                sub: null,
                awardType: null,
                awardRank: null,
                awardLevel: null,
                resultName: null,
                userId: null,
                username: null,
                org: null,
                awardTime: null,
                remark: null,
                pictureName: null,
                pictureurl: null,
                createBy: null,
                createTime: null,
                updateBy: null,
                updateTime: null,
                delFlag: null
            };
            this.resetForm("form");
        },
        /** 搜索按钮操作 */
        handleQuerycx() {
            this.query = true;
            this.resetcx();
        },
        handleQuery() {
            this.query = true;
            this.getList();
            this.query = false;
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryParams");
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.open = true;
            this.title = "添加教师获奖";
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.reset();
            this.open = true;
            const id = row.id || this.ids
            getAward(id).then(response => {
                this.form = response.data;
                this.title = "修改教师获奖";
            });
        },
        /** 提交按钮 */
        submitForm() {
            this.form.auditstate = '2';
            this.$refs["form"].validate(valid => {
                if (valid) {
                    if (this.form.id != null) {
                        updateAward(this.form).then(response => {
                            this.$modal.msgSuccess("修改成功");
                            this.open = false;
                            this.getList();
                        });
                    } else {
                        addAward(this.form).then(response => {
                            this.$modal.msgSuccess("新增成功");
                            this.open = false;
                            this.getList();
                        });
                    }
                }
            });
        },
        /** 删除按钮操作 */
        handleDelete(row) {
            const ids = row.id || this.ids;
            this.$modal.confirm('是否确认删除教师获奖编号为"' + ids + '"的数据项？').then(function () {
                return delAward(ids);
            }).then(() => {
                this.getList();
                this.$modal.msgSuccess("删除成功");
            }).catch(() => { });
        },
        /** 导出按钮操作 */
        handleExport() {
            this.download('/school/fudaos/export', {
                ...this.queryParams
            }, `辅导教师获奖_${new Date().getTime()}.xlsx`)
        }
    }
};
</script>
<style scoped lang="scss" >
.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.avatar-uploader .el-upload:hover {
    border-color: #409eff;
}

.avatar-uploader-icon {
    font-size: 30px;
    color: #8c939d;
    width: 70px;
    height: 70px;
    line-height: 70px;
    text-align: center;
}

.avatar {
    width: 300px;
    height: 220px;
    display: block;
}

::v-deep .el-form-item {
    margin-bottom: 0px;
}

::v-deep .el-input--medium .el-input__inner {
    height: 26px;
    line-height: 26px;
}

::v-deep .el-dialog__body {
    padding: 10px 20px
}

::v-deep .el-dialog:not(.is-fullscreen) {
    margin-top: 4vh !important;
}

.search ::v-deep .el-form-item__content {
    width: 200px
}

::v-deep .el-table .el-table__cell {
    padding: 0;
}

::v-deep .el-table .cell {
    padding: 0;
}

::v-deep .el-table th.el-table__cell>.cell {
    padding: 0;

}
</style>
