<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="学校名" prop="schoolName">
        <el-input
          v-model="queryParams.schoolName"
          placeholder="请输入学校名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="学校图标" prop="schoolIcon">-->
<!--        <el-input-->
<!--          v-model="queryParams.schoolIcon"-->
<!--          placeholder="请输入学校图标"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="学校编号" prop="schoolNumber">
        <el-input
          v-model="queryParams.schoolNumber"
          placeholder="请输入学校编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="学校类型ID" prop="configTypeId">-->
<!--        <el-input-->
<!--          v-model="queryParams.configTypeId"-->
<!--          placeholder="请输入学校类型ID"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="学校类型名" prop="configTypeName">-->
<!--        <el-input-->
<!--          v-model="queryParams.configTypeName"-->
<!--          placeholder="请输入学校类型名"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="办学机构" prop="schoolInstitution">
        <el-select v-model="queryParams.schoolInstitution" placeholder="请选择办学机构" clearable>
          <el-option
            v-for="dict in dict.type.mall_school_institution"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="办学层次" prop="configLevelId">
        <el-select v-model="queryParams.configLevelId" placeholder="请选择层次">
          <el-option
            v-for="item in levelList"
            :key="item.configLevelId"
            :label="item.configLevelName"
            :value="item.configLevelId">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="主管部门" prop="competentDepartment">
        <el-input
          v-model="queryParams.competentDepartment"
          placeholder="请输入主管部门"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <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-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['mall:mallSchool:add']"
        >新增</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="['mall:mallSchool: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="['mall:mallSchool:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['mall:mallSchool:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="mallSchoolList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="学校主键ID" align="center" prop="schoolId" />-->
      <el-table-column label="学校名" align="center" prop="schoolName" />
<!--      <el-table-column label="学校图标" align="center" prop="schoolIcon"  show-overflow-tooltip/>-->
      <el-table-column label="学校图标" align="center" prop="schoolIcon" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.schoolIcon" :width="50" :height="50"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="学校背景图" align="center" prop="backgroundImage" width="100">-->
<!--        <template slot-scope="scope">-->
<!--          <image-preview :src="scope.row.backgroundImage" :width="50" :height="50"/>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="学校简要介绍" align="center" prop="schoolIntroduceShort" show-overflow-tooltip/>
      <el-table-column label="学校编号" align="center" prop="schoolNumber" />
<!--      <el-table-column label="学校类型ID" align="center" prop="configTypeId" />-->
      <el-table-column label="学校层次" align="center" prop="configLevelName" />
      <el-table-column label="学校类型" align="center" prop="configTypeName" />
      <el-table-column label="办学机构" align="center" prop="schoolInstitution">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.mall_school_institution" :value="scope.row.schoolInstitution"/>
        </template>
      </el-table-column>
      <el-table-column label="主管部门" align="center" prop="competentDepartment" />
<!--      <el-table-column label="省份ID" align="center" prop="provinceId" />-->
      <el-table-column label="省份名" align="center" prop="provinceName" />
<!--      <el-table-column label="城市ID" align="center" prop="cityId" />-->
      <el-table-column label="城市名" align="center" prop="cityName" />
<!--      <el-table-column label="区县ID" align="center" prop="areaId" />-->
<!--      <el-table-column label="区县名" align="center" prop="areaName" />-->
      <el-table-column label="地址" align="center" prop="address" />
<!--      <el-table-column label="二维码" align="center" prop="qrCode" width="100">-->
<!--        <template slot-scope="scope">-->
<!--          <image-preview :src="scope.row.qrCode" :width="50" :height="50"/>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="风景" align="center" prop="address" >
        <template slot-scope="scope">
          <el-link type="primary" @click="getScenery(scope.row)">校园风景</el-link>
        </template>
      </el-table-column>

      <el-table-column label="院校评估" align="center" prop="appraise" >
        <template slot-scope="scope">
          <el-link type="primary" @click="getAppraise(scope.row)">院校评估</el-link>
        </template>
      </el-table-column>


      <el-table-column label="环境介绍" align="center" >
        <template slot-scope="scope">
          <el-link type="primary" @click="getIntroduce(scope.row)">环境介绍</el-link>
        </template>
      </el-table-column>
      <el-table-column label="学院介绍" align="center"  >
        <template slot-scope="scope">
          <el-link type="primary" @click="getFaculty(scope.row)">学院介绍</el-link>
        </template>
      </el-table-column>
      <el-table-column label="学校专业" align="center"  >
        <template slot-scope="scope">
          <el-link type="primary" @click="getMajor(scope.row)">学校专业</el-link>
        </template>
      </el-table-column>
      <el-table-column label="招生简章" align="center" prop="address" >
        <template slot-scope="scope">
          <el-link type="primary" @click="getAcceptRules(scope.row)">招生简章</el-link>
        </template>
      </el-table-column>
      <el-table-column label="招生计划" align="center" prop="address" >
        <template slot-scope="scope">
          <el-link type="primary" @click="getPlan(scope.row)">招生计划</el-link>
        </template>
      </el-table-column>
      <el-table-column label="录取数据" align="center" prop="accept" >
        <template slot-scope="scope">
          <el-link type="primary" @click="getAcceptRecord(scope.row)">录取数据</el-link>
        </template>
      </el-table-column>
      <el-table-column label="专业录取数据" align="center" prop="address" >
        <template slot-scope="scope">
          <el-link type="primary" @click="getAccept(scope.row)">专业录取数据</el-link>
        </template>
      </el-table-column>
<!--      <el-table-column label="备注" align="center" prop="remarks" />-->
<!--      <el-table-column label="标签集合" align="center" prop="tags" />-->
<!--      <el-table-column label="学校官网" align="center" prop="schoolWeb" />-->
<!--      <el-table-column label="招生电话" align="center" prop="acceptPhone" />-->
<!--      <el-table-column label="学校邮箱" align="center" prop="schoolMail" />-->
<!--      <el-table-column label="创办时间" align="center" prop="schoolBirthday" />-->
<!--      <el-table-column label="占地面积" align="center" prop="areaSize" />-->
<!--      <el-table-column label="男比例" align="center" prop="maleRatio" />-->
<!--      <el-table-column label="女比例" align="center" prop="femaleRatio" />-->
<!--      <el-table-column label="保研率" align="center" prop="postgraduateRatio" />-->
<!--      <el-table-column label="转专业率" align="center" prop="changeMajorRatio" />-->
<!--      <el-table-column label="硕士点" align="center" prop="mastersDegree" />-->
<!--      <el-table-column label="博士点" align="center" prop="doctorate" />-->
<!--      <el-table-column label="优势专业" align="center" prop="ace" show-overflow-tooltip />-->
<!--      <el-table-column label="就业率" align="center" prop="offerRatio" />-->
<!--      <el-table-column label="创建时间" align="center" prop="createAt" />-->
<!--      <el-table-column label="修改时间" align="center" prop="updateAt" />-->
<!--      <el-table-column label="删除标记：0-正常，1-删除" align="center" prop="delFlag" />-->

      <!--<el-table-column label="" align="center" width="120">-->
      <!--  <template slot-scope="scope">-->
      <!--    <router-link :to="'/mall/mallSchoolScenery/index/' + scope.row.schoolId" class="link-type">-->
      <!--      <div>学校风景</div>-->
      <!--    </router-link>-->
      <!--    <router-link :to="'/mall/mallSchoolAcceptRules/index/' + scope.row.schoolId" class="link-type">-->
      <!--      <div>招生简章</div>-->
      <!--    </router-link>-->
      <!--    <router-link :to="'/mall/mallSchoolAppraise/index/' + scope.row.schoolId" class="link-type">-->
      <!--      <div>院校评估</div>-->
      <!--    </router-link>-->
      <!--    <router-link :to="'/mall/mallSchoolAcceptRecord/index/' + scope.row.schoolId" class="link-type">-->
      <!--      <div>录取数据</div>-->
      <!--    </router-link>-->
      <!--    <router-link :to="'/mall/mallAcceptPlan/index/' + scope.row.schoolId" class="link-type">-->
      <!--      <div>招生计划</div>-->
      <!--    </router-link>-->
      <!--    <router-link :to="'/mall/mallSchoolIntroduce/index/' + scope.row.schoolId" class="link-type">-->
      <!--      <div>学校介绍</div>-->
      <!--    </router-link>-->
      <!--    <router-link :to="'/mall/mallFacultyInfo/index/' + scope.row.schoolId" class="link-type">-->
      <!--      <div>学院介绍</div>-->
      <!--    </router-link>-->
      <!--    <router-link :to="'/mall/mallSchoolAccept/index/' + scope.row.schoolId" class="link-type">-->
      <!--      <div>专业录取数据</div>-->
      <!--    </router-link>-->
      <!--  </template>-->
      <!--</el-table-column>-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['mall:mallSchool:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['mall:mallSchool:remove']"
          >删除</el-button>
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-edit"-->
<!--            @click="handleAddSchoolUser(scope.row)"-->
<!--            v-hasPermi="['mall:mallSchool:addSchoolUser']"-->
<!--          >{{scope.row.sysUserId === 0 ? '新增登录用户' : '修改登录用户'}}</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="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-form-item label="学校名" prop="schoolName">
          <el-input v-model="form.schoolName" placeholder="请输入学校名" />
        </el-form-item>
        <el-form-item label="学校图标" prop="schoolIcon">
          <image-upload v-model="form.schoolIcon" :limit="1"/>
        </el-form-item>
        <el-form-item label="学校背景图">
          <image-upload v-model="form.backgroundImage" :limit="1"/>
        </el-form-item>
        <el-form-item label="学校介绍简要" prop="schoolIntroduceShort">
          <el-input v-model="form.schoolIntroduceShort" type="textarea" :rows="4" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="学校介绍详情" prop="schoolIntroduce">
          <editor v-model="form.schoolIntroduce"  placeholder="请输入内容" :min-height="350" />
        </el-form-item>
        <el-form-item label="学校编号" prop="schoolNumber">
          <el-input v-model="form.schoolNumber" placeholder="请输入学校编号" />
        </el-form-item>

        <el-form-item label="学校类型" prop="configTypeId">
          <el-select v-model="form.configTypeId" placeholder="请选择学校类型">
            <el-option
              v-for="item in schoolTypeList"
              :key="item.configTypeId"
              :label="item.configTypeName"
              :value="item.configTypeId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="办学机构" prop="schoolInstitution">
          <el-select v-model="form.schoolInstitution" placeholder="请选择办学机构">
            <el-option
              v-for="dict in dict.type.mall_school_institution"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="办学层次" prop="configLevelId">
          <el-select v-model="form.configLevelId" placeholder="请选择层次">
            <el-option
              v-for="item in levelList"
              :key="item.configLevelId"
              :label="item.configLevelName"
              :value="item.configLevelId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="主管部门" prop="competentDepartment">
          <el-input v-model="form.competentDepartment" placeholder="请输入主管部门" />
        </el-form-item>
        <el-form-item label="区域选择:">
          <el-select
            style="width: 190px"
            v-model="form.provinceId"
            placeholder="请选择省"
          >
            <el-option
              v-for="item in getProvinceList"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
          <el-select
            style="width: 190px; margin-left: 12px"
            v-model="form.cityId"
            placeholder="请选择市"
            @focus="getCityOrArea"
          >
            <el-option
              v-for="item in getCityOrAreaList"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入地址" />
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="批次选择" prop="batchId">
          <el-select v-model="form.batchList" placeholder="请选择批次" multiple>
            <el-option v-for="item in batchList"
                       :key="item.batchId"
                       :value="item.batchId"
                       :label="item.batchName"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="标签集合" >
          <el-select v-model="form.tagIdList" placeholder="请输入选择标签" multiple @change="$forceUpdate()">
            <el-option v-for="item in tagList"
                       :key="item.schoolTagId"
                       :value="item.schoolTagId"
                       :label="item.tagName"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="学校定位" >
          <el-select v-model="form.positionId" clearable placeholder="请选择定位" >
            <el-option v-for="item in positionList"
                       :key="item.positionId"
                       :value="item.positionId"
                       :label="item.positionName"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="推荐度" >
          <el-select v-model="form.suggestId" clearable  placeholder="请选择推荐度" >
            <el-option v-for="item in suggestList"
                       :key="item.suggestId"
                       :value="item.suggestId"
                       :label="item.suggestName"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学校官网" prop="schoolWeb">
          <el-input v-model="form.schoolWeb" placeholder="请输入学校官网" />
        </el-form-item>
        <el-form-item label="招生电话" prop="acceptPhone">
          <el-input v-model="form.acceptPhone" placeholder="请输入招生电话" />
        </el-form-item>
        <el-form-item label="学校邮箱" >
          <el-input v-model="form.schoolMail" clearable placeholder="请输入学校邮箱" />
        </el-form-item>
        <el-form-item label="创办时间" prop="schoolBirthday">
          <el-input v-model="form.schoolBirthday" placeholder="请输入创办时间" />
        </el-form-item>
        <el-form-item label="占地面积" prop="areaSize">
          <el-input v-model="form.areaSize" placeholder="请输入占地面积" />
          <span style="font-size: 13px">(注:需输入面积单位)</span>
        </el-form-item>
        <el-form-item label="男比例" prop="maleRatio">
          <el-input v-model="form.maleRatio" placeholder="请输入男比例" />
        </el-form-item>
        <el-form-item label="女比例" prop="femaleRatio">
          <el-input v-model="form.femaleRatio" placeholder="请输入女比例" />
        </el-form-item>
        <el-form-item label="保研率" prop="postgraduateRatio">
          <el-input v-model="form.postgraduateRatio" placeholder="请输入保研率" />
        </el-form-item>
        <el-form-item label="就业率" prop="offerRatio">
          <el-input v-model="form.offerRatio" placeholder="请输入就业率" />
        </el-form-item>
         <el-form-item label="转专业情况" prop="changeMajorRatio">
          <el-input v-model="form.changeMajorRatio" placeholder="请输入转专业情况"  maxlength="100"/>
        </el-form-item>
        <el-form-item label="硕士点" prop="mastersDegree">
          <el-input-number :min="0" :precision="0"  controls-position="right"
              oninput="value = value.replace(/[^\d]/g, '');if(value.length>9); value=value.slice(0,9)"
              v-model="form.mastersDegree" placeholder="请输入硕士点个数" />

        </el-form-item>
        <el-form-item label="博士点" prop="doctorate">
          <el-input-number :min="0" :precision="0"  controls-position="right"
              oninput="value = value.replace(/[^\d]/g, '');if(value.length>9); value=value.slice(0,9)"
              v-model="form.doctorate" placeholder="请输入博士点个数" />
        </el-form-item>
        <el-form-item label="优势专业" prop="ace">
          <el-input v-model="form.ace" maxlength="100" placeholder="请输入优势专业" />
        </el-form-item>
         <el-form-item label="综合实力排名(软科)" prop="ranking" label-width="180px">
          <!-- <el-input-number :min="0" :precision="0" v-model="form.ranking" maxlength="100" placeholder="请输入优势专业" /> -->
                <el-input v-model="form.ranking" maxlength="100" placeholder="请输入优势专业" />
        </el-form-item>
<!--        <el-form-item label="创建时间" prop="createAt">-->
<!--          <el-input v-model="form.createAt" placeholder="请输入创建时间" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="修改时间" prop="updateAt">-->
<!--          <el-input v-model="form.updateAt" placeholder="请输入修改时间" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="删除标记：0-正常，1-删除" prop="delFlag">-->
<!--          <el-input v-model="form.delFlag" placeholder="请输入删除标记：0-正常，1-删除" />-->
<!--        </el-form-item>-->

          <!-- 学校录取前提 -->
          <el-form-item label="录取前提" >
                <el-input v-model="form.acceptPremise" placeholder="请输入录取前提" maxlength="30"/>
        </el-form-item>
      </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="openAddSchoolUser" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-form-item label="账号" prop="sysUserName">
          <el-input v-model="form.sysUserName" placeholder="请输入账号" maxlength="30" />
        </el-form-item>
        <el-form-item label="密码" prop="sysUserPassword">
          <el-input v-model="form.sysUserPassword" placeholder="请输入密码" type="password" maxlength="20" show-password/>
        </el-form-item>
        <el-form-item label="帐号状态" prop="sysUserStatus">
          <el-radio-group v-model.number="form.sysUserStatus">
            <el-radio :label="0">正常</el-radio>
            <el-radio :label="1">停用</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitAddSchoolUser">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

     <!--学校风景-->
    <el-dialog title="风景" :visible.sync="openScenery" width="1000px" append-to-body>
      <mall-school-scenery :school-id="schoolId" :school-name="schoolName" :key="schoolId" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaCancel">确 定</el-button>
      </div>
    </el-dialog>

    <!--招生简章-->
    <el-dialog title="招生简章" :visible.sync="openSchoolRules" width="1000px" append-to-body>
      <mall-school-accept-rules :school-id="schoolId" :school-name="schoolName" :key="schoolId" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaCancel">确 定</el-button>
      </div>
    </el-dialog>

    <!--院校评估-->
    <el-dialog title="院校评估" :visible.sync="openAppraise" width="1000px" append-to-body>
      <mall-school-appraise :school-id="schoolId" :school-name="schoolName" :key="schoolId" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaCancel">确 定</el-button>
      </div>
    </el-dialog>

    <!--环境介绍-->
    <el-dialog title="环境介绍" :visible.sync="openIntroduce" width="1000px" append-to-body>
      <mall-school-introduce :school-id="schoolId" :school-name="schoolName" :key="schoolId" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaCancel">确 定</el-button>
      </div>
    </el-dialog>

    <!--院校介绍-->
    <el-dialog title="院校介绍" :visible.sync="openFaculty" width="1000px" append-to-body>
      <mallFacultyInfo :school-id="schoolId" :school-name="schoolName" :key="schoolId" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaCancel">确 定</el-button>
      </div>
    </el-dialog>

    <!--专业-->
    <el-dialog title="学校专业" :visible.sync="openMajor" width="1000px" append-to-body>
      <mall-link-major-school :school-id="schoolId" :school-name="schoolName" :key="schoolId" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaCancel">确 定</el-button>
      </div>
    </el-dialog>

    <!--招生计划-->
    <el-dialog title="招生计划" :visible.sync="openPlan" width="1000px" append-to-body>
      <mall-accept-plan :school-id="schoolId" :school-name="schoolName" :key="schoolId" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaCancel">确 定</el-button>
      </div>
    </el-dialog>

    <!--学校录取数据-->
    <el-dialog title="学校录取数据" :visible.sync="openAcceptRecord" width="1000px" append-to-body>
      <mall-school-accept-record :school-id="schoolId" :school-name="schoolName" :key="schoolId" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaCancel">确 定</el-button>
      </div>
    </el-dialog>

    <!--专业录取数据-->
    <el-dialog title="专业录取数据" :visible.sync="openAccept" width="1000px" append-to-body>
      <mall-school-accept :school-id="schoolId" :school-name="schoolName" :key="schoolId" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaCancel">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listMallSchool,
  getMallSchool,
  delMallSchool,
  addMallSchool,
  updateMallSchool,
  selectPositionList, selectSuggestList, submitSchoolUser
} from "@/api/mall/mallSchool";
import {listMallBatch, selectAllBatchList} from "@/api/mall/mallBatch";
import {listMallConfigType} from "@/api/mall/mallConfigType";
import {getCityOrArea, getProvince} from "@/api/set/setRegion";
import mallSchoolScenery from "@/views/mall/mallSchoolScenery";
import mallFacultyInfo from "@/views/mall/mallFacultyInfo";
import mallSchoolAcceptRules from "@/views/mall/mallSchoolAcceptRules";
import MallSchoolAppraise from "@/views/mall/mallSchoolAppraise";
import MallSchoolAcceptRecord from "@/views/mall/mallSchoolAcceptRecord";
import MallAcceptPlan from "@/views/mall/mallAcceptPlan";
import MallSchoolIntroduce from "@/views/mall/mallSchoolIntroduce";
import MallSchoolAccept from "@/views/mall/mallSchoolAccept";
import MallLinkMajorSchool from "@/views/mall/mallLinkMajorSchool";
import {selectTagList} from "@/api/mall/mallSchoolTag";
import {selectLevelList} from "@/api/mall/mallConfigLevel";

export default {
  name: "MallSchool",
  dicts: ['mall_school_institution'],
  components: {MallLinkMajorSchool, MallSchoolAccept, MallSchoolIntroduce, MallAcceptPlan, MallSchoolAcceptRecord, MallSchoolAppraise, mallSchoolScenery, mallFacultyInfo, mallSchoolAcceptRules},
  data() {
    return {
      // 推荐度集合
      suggestList: [],
      // 定位集合
      positionList: [],
      // 办学层次
      levelList: [],
      // 学校id
      schoolId : null,
      // 学校名称
      schoolName: null,
      // 风景开关
      openScenery: false,
      // 招生简章开关
      openSchoolRules: false,
      // 院校评估开关
      openAppraise: false,
      // 录取数据开关
      openAcceptRecord: false,
      // 招生计划
      openPlan: false,
      // 学校环境介绍
      openIntroduce: false,
      // 院校介绍
      openFaculty: false,
      // 专业录取开关
      openAccept: false,
      // 专业关联开关
      openMajor: false,
      // 一级专业id
      parentMajorId: null,
      // 一级专业列表
      parentMajorList: [],
      // 二级专业列表
      majorList: [],
      // 批次列表
      batchList: [],
      // 标签列表
      tagList: [],
      //省
      getProvinceList: [],
      //市
      getCityOrAreaList: [],
      //区
      getCityOrAreacityList: [],
      // 学校类型列表
      schoolTypeList: {},
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学校表格数据
      mallSchoolList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      openAddSchoolUser: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        schoolName: null,
        schoolIcon: null,
        backgroundImage: null,
        schoolIntroduce: null,
        schoolNumber: null,
        configTypeId: null,
        configTypeName: null,
        schoolInstitution: null,
        competentDepartment: null,
        provinceId: null,
        provinceName: null,
        cityId: null,
        cityName: null,
        areaId: null,
        areaName: null,
        address: null,
        remarks: null,
        tags: null,
        schoolWeb: null,
        acceptPhone: null,
        schoolMail: null,
        schoolBirthday: null,
        areaSize: null,
        maleRatio: null,
        femaleRatio: null,
        postgraduateRatio: null,
        offerRatio: null,
        createAt: null,
        updateAt: null,
        delFlag: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        sysUserName: [
          { required: true, message: "账号不能为空", trigger: "blur" },
          { min: 5, max: 20, message: '账号长度必须介于 5 和 20 之间', trigger: 'blur' }
        ],
        sysUserPassword: [
          { required: true, message: "密码不能为空", trigger: "blur" },
          { min: 6, max: 20, message: '密码长度必须介于 6 和 20 之间', trigger: 'blur' }
        ],

        schoolName: [
          { required: true, message: "学校名不能为空", trigger: "blur" }
        ],
        schoolIcon: [
          { required: true, message: "学校图标不能为空", trigger: "blur" }
        ],

        schoolIntroduce: [
          { required: true, message: "学校简要介绍不能为空", trigger: "blur" }
        ],
        schoolNumber: [
          { required: true, message: "学校编号不能为空", trigger: "blur" }
        ],
        configTypeId: [
          { required: true, message: "学校类型不能为空", trigger: "blur" }
        ],
        // configTypeName: [
        //   { required: true, message: "学校类型名不能为空", trigger: "blur" }
        // ],
        schoolInstitution: [
          { required: true, message: "办学机构", trigger: "blur" }
        ],
        configLevelId: [
          { required: true, message: "办学层次", trigger: "blur" }
        ],
        competentDepartment: [
          { required: true, message: "主管部门不能为空", trigger: "blur" }
        ],
        provinceId: [
          { required: true, message: "省份ID不能为空", trigger: "blur" }
        ],
        // provinceName: [
        //   { required: true, message: "省份名不能为空", trigger: "blur" }
        // ],
        cityId: [
          { required: true, message: "城市ID不能为空", trigger: "blur" }
        ],
        // cityName: [
        //   { required: true, message: "城市名不能为空", trigger: "blur" }
        // ],
        areaId: [
          { required: true, message: "区县ID不能为空", trigger: "blur" }
        ],
        // areaName: [
        //   { required: true, message: "区县名不能为空", trigger: "blur" }
        // ],
        address: [
          { required: true, message: "地址不能为空", trigger: "blur" }
        ],
        // remarks: [
        //   { required: true, message: "备注不能为空", trigger: "blur" }
        // ],
        tags: [
          { required: true, message: "标签集合不能为空", trigger: "blur" }
        ],
        schoolWeb: [
          { required: true, message: "学校官网不能为空", trigger: "blur" }
        ],
        acceptPhone: [
          { required: true, message: "招生电话不能为空", trigger: "blur" }
        ],
        // schoolMail: [
        //   { required: true, message: "学校邮箱不能为空", trigger: "blur" }
        // ],
        schoolBirthday: [
          { required: true, message: "创办时间不能为空", trigger: "blur" }
        ],
        areaSize: [
          { required: true, message: "占地面积不能为空", trigger: "blur" }
        ],
        maleRatio: [
          { required: true, message: "男比例不能为空", trigger: "blur" }
        ],
        femaleRatio: [
          { required: true, message: "女比例不能为空", trigger: "blur" }
        ],
        postgraduateRatio: [
          { required: true, message: "保研率不能为空", trigger: "blur" }
        ],
        offerRatio: [
          { required: true, message: "就业率不能为空", trigger: "blur" }
        ],
        // createAt: [
        //   { required: true, message: "创建时间不能为空", trigger: "blur" }
        // ],
        // updateAt: [
        //   { required: true, message: "修改时间不能为空", trigger: "blur" }
        // ],
        // delFlag: [
        //   { required: true, message: "删除标记：0-正常，1-删除不能为空", trigger: "blur" }
        // ]
      }
    };
  },
  created() {
    this.getProvince();
    this.getList();
    this.getBatchList();
    this.getTagList();
    this.getLevelList();
    this.getPositionList();
    this.getSuggestList();
  },
  methods: {
    /** 新增登录用户按钮操作 */
    handleAddSchoolUser(row) {
      this.reset();
      const schoolId = row.schoolId
      getMallSchool(schoolId).then(response => {
        this.form = response.data;
        this.openAddSchoolUser = true;
        this.title = "新增登录用户";
      });
    },
    /** 新增登录用户提交按钮 */
    submitAddSchoolUser() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.schoolId != null) {
            submitSchoolUser(this.form).then(response => {
              this.$modal.msgSuccess("成功");
              this.openAddSchoolUser = false;
              this.getList();
            });
          }
        }
      });
    },

    // 获取省
    getProvince() {
      this.loading = true;
      getProvince(this.queryParams).then((response) => {
        this.getProvinceList = response.data.data;
        this.loading = false;
      });
      this.loading = false;
    },
    // 获取市
    getCityOrArea() {
      this.loading = true;
      let ida = this.form.provinceId || this.queryParams.provinceId;
      getCityOrArea(ida).then((response) => {
        this.getCityOrAreaList = response.data.data;
        this.loading = false;
      });
      this.loading = false;
    },
    //区
    // getCityOrAreacity() {
    //   this.loading = true;
    //   let ida = this.form.cityId || this.queryParams.cityId;
    //   getCityOrArea(ida).then((response) => {
    //     this.getCityOrAreacityList = response.data.data;
    //     this.loading = false;
    //   });
    //   this.loading = false;
    // },
    /** 查询学校列表 */
    getList() {
      this.loading = true;
      listMallConfigType().then(response => {
        this.schoolTypeList = response.rows;
      });
      listMallSchool(this.queryParams).then(response => {
        this.mallSchoolList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.openAddSchoolUser = false;
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        sysUserName: null,
        sysUserPassword: null,
        sysUserStatus: 0,
        schoolId: null,
        schoolName: null,
        schoolIcon: null,
        backgroundImage: null,
        schoolIntroduce: null,
        schoolNumber: null,
        configTypeId: null,
        configTypeName: null,
        schoolInstitution: null,
        schoolIntroduceShort: null,
        competentDepartment: null,
        provinceId: null,
        provinceName: null,
        cityId: null,
        cityName: null,
        areaId: null,
        areaName: null,
        address: null,
        remarks: null,
        tags: null,
        schoolWeb: null,
        acceptPhone: null,
        schoolMail: null,
        schoolBirthday: null,
        areaSize: null,
        maleRatio: null,
        femaleRatio: null,
        postgraduateRatio: null,
        offerRatio: null,
        createAt: null,
        updateAt: null,
        delFlag: null,
        batchList: [],
        tagIdList: [],
        configLevelId: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.schoolId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加学校";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const schoolId = row.schoolId || this.ids
      getMallSchool(schoolId).then(response => {
        this.form = response.data;
        if(this.form.tags != null ){
          this.form.tagIdList = this.form.tags.split(",").map(Number);
        }

        this.open = true;
        this.title = "修改学校";
      });

      let ida = row.provinceId;
      getCityOrArea(ida).then((response) => {
        this.getCityOrAreaList = response.data.data;
      });
      let idb = row.cityId;
      getCityOrArea(idb).then((response) => {
        this.getCityOrAreacityList = response.data.data;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          //console.log(this.form.acceptPremise);
          if (this.form.tagIdList && this.form.tagIdList.length > 0){
            this.form.tags = this.form.tagIdList.join(",");
          }
          if (this.form.schoolId != null) {
            updateMallSchool(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addMallSchool(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const schoolIds = row.schoolId || this.ids;
      this.$modal.confirm('是否确认删除学校编号为"' + schoolIds + '"的数据项？').then(function() {
        return delMallSchool(schoolIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('mall/mallSchool/export', {
        ...this.queryParams
      }, `mallSchool_${new Date().getTime()}.xlsx`)
    },
    /** 批次列表 */
    getBatchList(){
      selectAllBatchList().then(response=>{
        this.batchList = response.data;
      })
    },
    /** 标签列表 */
    getTagList(){
      selectTagList().then(response=>{
        this.tagList = response.data;
      })
    },
    /** 一级专业列表 */
    getParentMajorList(){
      const pid = 0;
      selectMajorListByPid(pid).then(response=>{
        this.parentMajorList = response.data;
      })
    },
    /** 二级专业列表 */
    getMajorList(){
      const pid = this.parentMajorId;
      selectMajorListByPid(pid).then(response=>{
        this.majorList = response.data;
      })
    },
    /** 校园风景 */
    getScenery(row){
      this.schoolId = row.schoolId;
      this.schoolName = row.schoolName;
      this.openScenery = true;
    },
    /** 招生简章 */
    getAcceptRules(row){
      this.schoolId = row.schoolId;
      this.schoolName = row.schoolName;
      this.openSchoolRules = true;
    },
    /** 院校评估 */
    getAppraise(row){
      this.schoolId = row.schoolId;
      this.schoolName = row.schoolName;
      this.openAppraise = true;
    },

    /** 录取数据 */
    getAcceptRecord(row){
      this.schoolId = row.schoolId;
      console.log(this.schoolId);
      this.schoolName = row.schoolName;
      this.openAcceptRecord = true;
    },

    /** 招生计划 */
    getPlan(row){
      this.schoolId = row.schoolId;
      this.schoolName = row.schoolName;
      this.openPlan = true;
    },
    /** 学校环境介绍 */
    getIntroduce(row){
      this.schoolId = row.schoolId;
      this.schoolName = row.schoolName;
      this.openIntroduce= true;
    },
    /** 学院介绍 */
    getFaculty(row){
      this.schoolId = row.schoolId;
      this.schoolName = row.schoolName;
      this.openFaculty = true;
    },
    /** 专业录取数据 */
    getAccept(row){
      this.schoolId = row.schoolId;
      this.schoolName = row.schoolName;
      this.openAccept = true;
    },
    /** 专业 */
    getMajor(row){
      this.schoolId = row.schoolId;
      this.schoolName = row.schoolName;
      this.openMajor = true;
    },
    diaCancel(){
        this.openScenery = false;
        this.openSchoolRules =  false;
        this.openAppraise =false;
        this.openAcceptRecord = false;
        this.openPlan = false;
        this.openIntroduce = false;
        this.openFaculty = false;
        this.openAccept =  false;
        this.openMajor = false;
    },
    /** 层次列表 */
    getLevelList(){
      selectLevelList().then(response=>{
        this.levelList = response.data;
      })
    },
    /** 获取定位列表 */
    getPositionList(){
      selectPositionList().then(response=>{
        this.positionList = response.data
      })
    },
    /** 推荐列表 */
    getSuggestList(){
      selectSuggestList().then(response=>{
        this.suggestList = response.data
      })
    }
  }
};
</script>
