<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="所属班级" prop="className">
        <el-input
          v-model="queryParams.className"
          placeholder="请输入所属班级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学生姓名" prop="studentName">
        <el-input
          v-model="queryParams.studentName"
          placeholder="请输入学生姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="项目名称" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入项目名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="批次名称" prop="batchCode">
        <el-input
          v-model="queryParams.batchName"
          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="['system:testItemScore:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate2"
          v-hasPermi="['system:testItemScore: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="['system:testItemScore: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="['system:testItemScore:export']"
          >导出</el-button
        >
      </el-col> -->
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="testItemScoreList"
      @selection-change="handleSelectionChange"
      ref="table"
    >
      <el-table-column type="selection" width="50" align="center" />
      <el-table-column
        width="150"
        label="所属批次编号"
        align="center"
        prop="batchCode"
      />
      <el-table-column label="批次名称" align="center" prop="batchName" />
      <el-table-column label="班级名称" align="center" prop="className" />
      <el-table-column label="学生姓名" align="center" prop="studentName" />

      <el-table-column label="创建人" align="center" prop="createBy" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <!-- <el-table-column label="修改人" align="center" prop="updateBy" />
      <el-table-column label="修改时间" align="center" prop="updateTime" /> -->
      <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-search"
            @click="seepraent(scope.row)"
            v-hasPermi="['system:testItemScore:edit']"
            >查看</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:testItemScore:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:testItemScore:remove']"
            >删除</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="1300px"
      append-to-body
      :before-close="cancel"
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="105px"
        :inline="true"
      >
        <el-form-item label="所属幼儿园" prop="classId" v-if="form.id == ''">
          <el-button
            type=""
            @click="yryinnerVisible = true"
            v-if="kindergartenName == '请选择幼儿园'"
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              color: #c0c4cc;
              padding-left: -10px;
            "
            >{{ kindergartenName }}</el-button
          >

          <el-button
            type=""
            @click="yryinnerVisible = true"
            v-else
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            "
            >{{ kindergartenName }}</el-button
          >
        </el-form-item>

        <el-form-item
          label="所属班级"
          prop="classId"
          v-if="form.id == ''"
          label-width="90px"
        >
          <el-button
            type=""
            @click="handleQuery2"
            v-if="xmname == '请选择所属班级'"
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              color: #c0c4cc;
              padding-left: -10px;
            "
            >{{ xmname }}</el-button
          >

          <el-button
            type=""
            @click="handleQuery2"
            v-else
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            "
            >{{ xmname }}</el-button
          >
        </el-form-item>
        <el-form-item
          label="学生姓名"
          prop="studentId"
          v-if="form.id == null"
          label-width="90px"
        >
          <el-button
            disabled
            type=""
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
            >{{ stname }}</el-button
          >
        </el-form-item>
        <el-form-item
          label="学生姓名"
          prop="studentId"
          v-else
          label-width="90px"
        >
          <el-button
            this.stname="row.studentName;"
            type=""
            @click="studentinfoclick"
            v-if="stname == '请选择学生姓名'"
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              color: #c0c4cc;
              padding-left: -10px;
            "
            >{{ stname }}</el-button
          >
          <el-button
            this.stname="row.studentName"
            type=""
            @click="studentinfoclick"
            v-else
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
            >{{ stname }}</el-button
          >
        </el-form-item>
        <el-form-item
          label="所属批次"
          prop="batchCode"
          v-if="form.id == null"
          label-width="90px"
        >
          <el-button
            type=""
            disabled
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
            >{{ itemNumbername }}</el-button
          >
        </el-form-item>
        <el-form-item
          label="所属批次"
          prop="batchCode"
          v-else
          label-width="90px"
        >
          <el-button
            this.itemNumbername="row.batchCode;"
            type=""
            @click="testclick"
            v-if="itemNumbername == '请选择批次编号'"
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              color: #c0c4cc;
              padding-left: -10px;
            "
            >{{ itemNumbername }}</el-button
          >
          <el-button
            type=""
            @click="testclick"
            v-else
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            "
            >{{ itemNumbername }}</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        ref="singleTable"
        :data="form.itemScoreList"
        style="width: 93%; margin: 20px auto"
      >
        <el-table-column
          property="itemCode"
          label="项目编号"
          width="230"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="itemName"
          label="项目名称"
          width="230"
          align="center"
        >
        </el-table-column>
        <!-- <el-table-column
          property="scoreDictId"
          label="字典类型"
          align="center"
          width="120"
        >
          <template slot-scope="scope">
            {{
              scope.row.scoreDictId == ResultType1.dictCode
                ? ResultType1.dictLabel
                : ""
            }}{{
              scope.row.scoreDictId == ResultType2.dictCode
                ? ResultType2.dictLabel
                : ""
            }}</template
          >
        </el-table-column> -->
        <el-table-column
          property="itemScore"
          label="个人成绩"
          width="230"
          align="center"
        >
          <template slot-scope="scope">
            <el-input
              type="number"
              v-model="scope.row.itemScore"
              v-if="
                scope.row.itemScore != null ||
                scope.row.scoreDictId == ResultType1.dictCode
              "
            ></el-input>
            <el-input
              v-model="scope.row.scoreDictValue"
              v-if="
                scope.row.scoreDictValue != null ||
                scope.row.scoreDictId == ResultType2.dictCode
              "
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column
          property="itemFraction"
          label="个人成绩得分"
          width="230"
          align="center"
        >
          <template slot-scope="scope">
            <el-input type="number" v-model="scope.row.itemFraction"></el-input>
          </template>
        </el-table-column>

        <el-table-column
          property="syntheticalAssess"
          label="综合评价"
          width="230"
          align="center"
        >
          <template slot-scope="scope">
            <el-input v-model="scope.row.syntheticalAssess"></el-input>
          </template>
        </el-table-column>
      </el-table>

      <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="open2"
      width="1000px"
      append-to-body
      :before-close="cancel"
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="105px"
        :inline="true"
      >
        <el-form-item label="学生姓名" prop="studentId" label-width="90px">
          <el-button
            disabled
            type=""
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
            >{{ stname }}</el-button
          >
        </el-form-item>

        <el-form-item
          label="所属批次"
          prop="batchCode"
          v-if="form.id == null"
          label-width="90px"
        >
          <el-button
            type=""
            disabled
            style="
              width: 200px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
            >{{ itemNumbername }}</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        ref="singleTable"
        :data="form.itemScoreList"
        style="width: 95%; margin: 20px auto"
      >
        <el-table-column
          property="itemCode"
          label="项目编号"
          width="185"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="itemName"
          label="项目名称"
          width="185"
          align="center"
        >
        </el-table-column>
        <!-- <el-table-column
          property="scoreDictId"
          label="字典类型"
          align="center"
          width="120"
        >
          <template slot-scope="scope">
            {{
              scope.row.scoreDictId == ResultType1.dictCode
                ? ResultType1.dictLabel
                : ""
            }}{{
              scope.row.scoreDictId == ResultType2.dictCode
                ? ResultType2.dictLabel
                : ""
            }}</template
          >
        </el-table-column> -->
        <el-table-column
          property="itemScore"
          label="个人成绩"
          width="180"
          align="center"
        >
          <template slot-scope="scope">
            <el-input
              type="number"
              v-model="scope.row.itemScore"
              v-if="
                scope.row.itemScore != null ||
                scope.row.scoreDictId == ResultType1.dictCode
              "
            ></el-input>
            <el-input
              v-model="scope.row.scoreDictValue"
              v-if="
                scope.row.scoreDictValue != null ||
                scope.row.scoreDictId == ResultType2.dictCode
              "
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column
          property="itemFraction"
          label="个人成绩得分"
          width="180"
          align="center"
        >
          <template slot-scope="scope">
            <el-input type="number" v-model="scope.row.itemFraction"></el-input>
          </template>
        </el-table-column>

        <el-table-column
          property="syntheticalAssess"
          label="综合评价"
          width="180"
          align="center"
        >
          <template slot-scope="scope">
            <el-input v-model="scope.row.syntheticalAssess"></el-input>
          </template>
        </el-table-column>
      </el-table>

      <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
      width="850px"
      title="选择所属幼儿园"
      :visible.sync="yryinnerVisible"
      append-to-body
      :before-close="kindergartencancel"
    >
      <el-form
        :model="kqueryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="100px"
      >
        <el-form-item label="幼儿园名称" prop="className">
          <el-input
            v-model="kqueryParams.kindergartenName"
            placeholder="请输入幼儿园名称"
            clearable
            @keyup.enter.native="kinhandleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="kinhandleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="kinresetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>

      <el-table :data="kindergartenList" @cell-dblclick="kindergartenNameclick">
        <el-table-column label="请选择" width="70" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              style="width: 15px; height: 15px"
              circle
              @click="kindergartenNameclick(scope.row)"
              v-if="kindergartenId == scope.row.id"
            ></el-button>

            <el-button
              v-else
              style="width: 15px; height: 15px"
              circle
              @click="kindergartenNameclick(scope.row)"
            ></el-button>
          </template>
        </el-table-column>

        <el-table-column
          property="kindergartenName"
          label="幼儿园名字"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="kindergartenAddress"
          label="幼儿园地址"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="幼儿园所在组织"
          align="center"
          prop="organizeName"
          width="150"
        >
        </el-table-column>
        <el-table-column
          property="contacts"
          label="联系人"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="phone"
          label="联系电话"
          width="150"
          align="center"
        >
        </el-table-column>
      </el-table>
      <pagination
        v-show="total6 > 0"
        :total="total6"
        :page.sync="kqueryParams.pageNum"
        :limit.sync="kqueryParams.pageSize"
        @pagination="kininfo"
      />
    </el-dialog>

    <!--所属班级 弹窗 -->

    <el-dialog
      width="850px"
      title="选择所属班级"
      :visible.sync="innerVisible"
      append-to-body
    >
      <el-form
        :model="queryParams2"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="90px"
      >
        <el-form-item label="班级名称" prop="className">
          <el-input
            v-model="queryParams2.className"
            placeholder="请输入班级名称"
            clearable
            @keyup.enter.native="handleQuery2"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery2"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="classresetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table :data="classInfos" @cell-dblclick="xmclick">
        <el-table-column label="请选择" width="70" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              style="width: 15px; height: 15px"
              v-if="itemId2 == scope.row.id"
              circle
              @click="xmclick(scope.row)"
            ></el-button>
            <el-button
              v-else
              style="width: 15px; height: 15px"
              circle
              @click="xmclick(scope.row)"
            ></el-button>
          </template>
        </el-table-column>

        <el-table-column
          property="className"
          label="班级名称"
          width="150"
          align="center"
        >
        </el-table-column>

        <el-table-column
          property="classType"
          label="班级类型"
          width="150"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.classType == "LARGE_CLASS" ? "大班" : "" }}
            {{ scope.row.classType == "MIDDLE_CLASS" ? "中班" : "" }}
            {{ scope.row.classType == "SMALL_CLASS" ? "小班" : "" }}
            {{ scope.row.classType == "GRADUATE" ? "毕业" : "" }}
          </template>
        </el-table-column>
        <el-table-column
          property="classTeacher"
          label="班主任姓名"
          width="150"
          align="center"
        >
        </el-table-column>
        <!-- <el-table-column
            property="classType"
            label="班级类型"
            width="150"
            align="center"
          >

          </el-table-column> -->
        <el-table-column
          property="phone"
          label="联系电话"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="creatBy"
          label="创建人"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="createTime"
          label="创建时间"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="updateBy"
          label="修改人"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="updateTime"
          label="修改时间"
          width="150"
          align="center"
        >
        </el-table-column>
      </el-table>
      <pagination
        v-show="total2 > 0"
        :total="total2"
        :page.sync="queryParams2.pageNum"
        :limit.sync="queryParams2.pageSize"
        @pagination="classinfo"
      />
    </el-dialog>

    <!-- 学生姓名弹窗 -->
    <el-dialog
      width="850px"
      title="选择学生姓名"
      :visible.sync="innerVisible2"
      append-to-body
    >
      <el-form
        :model="queryParams3"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="90px"
      >
        <el-form-item label="学生姓名" prop="studentName">
          <el-input
            v-model="queryParams3.studentName"
            placeholder="请输入学生姓名"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery3"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table :data="studentInfos" @cell-dblclick="studentclick">
        <el-table-column label="请选择" width="70" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              style="width: 15px; height: 15px"
              v-if="itemId3 == scope.row.id"
              circle
              @click="studentclick(scope.row)"
            ></el-button>
            <el-button
              v-else
              style="width: 15px; height: 15px"
              circle
              @click="studentclick(scope.row)"
            ></el-button>
          </template>
        </el-table-column>

        <el-table-column
          property="studentName"
          label="学生姓名"
          width="150"
          align="center"
        >
        </el-table-column>

        <el-table-column
          property="studentSex"
          label="学生性别"
          width="150"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.studentSex == "MALE" ? "男" : "" }}
            {{ scope.row.studentSex == "FEMALE" ? "女" : "" }}
          </template>
        </el-table-column>
        <el-table-column
          property="studentNumber"
          label="学生编号"
          width="150"
          align="center"
        >
        </el-table-column>
        <!-- <el-table-column
            property="classType"
            label="班级类型"
            width="150"
            align="center"
          >

          </el-table-column> -->
        <el-table-column
          property="birthDate"
          label="出生日期"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="cardNumber"
          label="身份证号"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="onceName"
          label="曾用名"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="homeAddress"
          label="家庭住址"
          width="150"
          align="center"
        >
        </el-table-column>

        <el-table-column
          property="creatBy"
          label="创建人"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="createTime"
          label="创建时间"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="updateBy"
          label="修改人"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="updateTime"
          label="修改时间"
          width="150"
          align="center"
        >
        </el-table-column>
      </el-table>
      <pagination
        v-show="total3 > 0"
        :total="total3"
        :page.sync="queryParams3.pageNum"
        :limit.sync="queryParams3.pageSize"
        @pagination="studentinfo"
      />
    </el-dialog>

    <!-- 批次编号 -->

    <el-dialog
      width="850px"
      title="选择所属批次"
      :visible.sync="innerVisible4"
      append-to-body
    >
      <el-form
        :model="queryParams5"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="90px"
      >
        <el-form-item label="批次编号" prop="batchCode">
          <el-input
            v-model="queryParams5.batchCode"
            placeholder="请输入批次编号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="批次名称" prop="batchCode">
          <el-input
            v-model="queryParams5.batchName"
            placeholder="请输入批次名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery5"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table :data="testScoreBatchs" @cell-dblclick="batchCodeclick">
        <el-table-column label="请选择" width="70" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              style="width: 15px; height: 15px"
              v-if="itemNumbername == scope.row.batchCode"
              circle
              @click="batchCodeclick(scope.row)"
            ></el-button>
            <el-button
              v-else
              style="width: 15px; height: 15px"
              circle
              @click="batchCodeclick(scope.row)"
            ></el-button>
          </template>
        </el-table-column>

        <el-table-column
          property="batchCode"
          label="批次编号"
          width="150"
          align="center"
        >
        </el-table-column>

        <el-table-column
          property="batchName"
          label="批次名称"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="remark"
          label="备注信息"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="creatBy"
          label="创建人"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="createTime"
          label="创建时间"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="updateBy"
          label="修改人"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="updateTime"
          label="修改时间"
          width="150"
          align="center"
        >
        </el-table-column>
      </el-table>

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

    <!-- //查看个人成绩 -->
    <el-dialog
      title="查看个人成绩"
      :visible.sync="innerVisible5"
      append-to-body
      width="1000px"
    >
      <el-table
        ref="singleTable"
        :data="getAllTestItemScore"
        style="width: 95%; "
      >
        <el-table-column
          property="itemCode"
          label="项目编号"
          width="185"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="itemName"
          label="项目名称"
          width="185"
          align="center"
        >
        </el-table-column>
        <!-- <el-table-column
          property="scoreDictId"
          label="字典类型"
          align="center"
          width="120"
        >
          <template slot-scope="scope">
            {{
              scope.row.scoreDictId == ResultType1.dictCode
                ? ResultType1.dictLabel
                : ""
            }}{{
              scope.row.scoreDictId == ResultType2.dictCode
                ? ResultType2.dictLabel
                : ""
            }}</template
          >
        </el-table-column> -->
        <el-table-column
          property="itemScore"
          label="个人成绩"
          width="180"
          align="center"
        >
          <template slot-scope="scope">
            {{
              scope.row.itemScore != null ||
              scope.row.scoreDictId == ResultType1.dictCode
                ? scope.row.itemScore
                : scope.row.scoreDictValue
            }}
          </template>
        </el-table-column>
        <el-table-column
          property="itemFraction"
          label="个人成绩得分"
          width="180"
          align="center"
        >
          <!-- <template slot-scope="scope">
            <el-input type="number" v-model="scope.row.itemFraction" readonly></el-input>
          </template> -->
        </el-table-column>

        <el-table-column
          property="syntheticalAssess"
          label="综合评价"
          width="180"
          align="center"
        >
          <!-- <template slot-scope="scope">
            <el-input v-model="scope.row.syntheticalAssess" readonly></el-input>
          </template> -->
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import {
  listTestItemScore,
  getTestItemScore,
  delTestItemScore,
  addTestItemScore,
  updateTestItemScore,
  classInfo,
  studentInfo,
  testScoreBatch,
  getAllTestItemScoreInfo,
} from "@/api/system/testItemScore";
import {
  tKindergartenInfo,
  listKindergartenInfo,
} from "@/api/system/kindergartenInfo";
import Treeselect from "@riophae/vue-treeselect";
export default {
  name: "TestItemScore",
  components: { Treeselect },
  data() {
    return {
      value: "",
      //项目测试类型
      itemResultType: "item_result_type",
      //字典类型
      itemResultTypelist: [],
      ResultType1: "", //numberLeixing
      ResultType2: "", //textleixing
      // 遮罩层
      // 遮罩层
      loading: true,
      itemScore: "",
      yryinnerVisible: false,
      testItemScoreLists: [],
      xmname: "请选择所属班级",
      studentInfos: [],
      innerVisible: false,
      stname: "请选择学生姓名",
      innerVisible2: false,
      testItemss: [],
      testScoreBatchs: [],
      innerVisible4: false,
      innerVisible5: false,
      itemNumbername: "请选择批次编号",
      //幼儿园查询参数
      kqueryParams: {
        pageNum: 1,
        pageSize: 10,
        organizeId: null,
        kindergartenName: null,
        kindergartenAddress: null,
        kindergartenType: null,
        phone: null,
        contacts: null,
      },
      //幼儿园list
      kindergartenList: [],
      //幼儿园名字
      kindergartenName: "请选择幼儿园",
      //幼儿园ID
      kindergartenId: "",
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      total2: 0,
      total3: 0,
      total4: 0,
      total5: 0,
      total6: 0,
      // 班级信息表格数据
      classInfos: [],
      // 个人成绩录入管理表格数据
      testItemScoreList: [],
      //个人成绩查看
      getAllTestItemScore: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open2: false,
      itemId2: "",
      itemId3: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        className: null,
        studentName: null,
        itemName: null,
        batchCode: null,
      },
      // 班级
      queryParams2: {
        pageNum: 1,
        pageSize: 10,
        kindergartenId: "",
        className: null,
        classType: null,
      },
      // 学生姓名
      queryParams3: {
        pageNum: 1,
        pageSize: 10,
        studentName: null,
        classId: "",
      },
      // 批次编号
      queryParams5: {
        pageNum: 1,
        pageSize: 10,
        batchCode: null,
        batchName: "",
      },
      addqueryParams: {
        studentId: "",
        batchId: "",
        batchCode: "",
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        classId: [
          { required: true, message: "所属班级不能为空", trigger: "blur" },
        ],
        studentId: [
          { required: true, message: "学生姓名不能为空", trigger: "blur" },
        ],
        testItemId: [
          { required: true, message: "测试项目名称不能为空", trigger: "blur" },
        ],
        batchCode: [
          {
            required: true,
            message: "批次编号不能为空",
            trigger: "blur",
          },
        ],
      },
      testitems: [],
      selection2: {},
    };
  },
  created() {
    this.getList();
  },

  methods: {
    handledbClick(row, event, column) {
      this.$refs.table.toggleRowSelection(row);
      console.log(row, event, column);
    },
    // 查看个人信息
    seepraent(row) {
      this.reset();
      getAllTestItemScoreInfo(row).then((res) => {
        console.log(res);
        this.getAllTestItemScore = res.data;
        console.log(this.getAllTestItemScore);
        this.innerVisible5 = true;
      });
    },
    testclick() {
      if (this.addqueryParams.studentId == "") {
        this.$message.error("请先选择学生");
      } else {
        this.innerVisible4 = true;
      }
    },
    delitem(item) {
      console.log(item);
      this.form.itemScoreList = this.form.itemScoreList.filter((e) => {
        return e.id != item.id;
      });
    },
    getAllTest() {
      this.form.itemScoreList = [];
      console.log(this.addqueryParams);
      getAllTestItemScoreInfo(this.addqueryParams).then((res) => {
        console.log(this.form);
        this.form.itemScoreList = res.data;
      });
    },
    //幼儿园左侧点击
    kindergartenNameclick(row) {
      this.queryParams2.kindergartenId = row.id;
      this.kindergartenName = row.kindergartenName;
      this.kindergartenId = row.id;
      this.yryinnerVisible = false;
      this.xmname = "请选择所属班级";
      this.stname = "请选择学生姓名";
      this.itemId2 = "";
      this.itemId3 = "";
      this.form.classId = null;
      this.queryParams3.classId = "";
      this.addqueryParams.studentId = "";
      console.log(this.queryParams3);
      this.form.studentId = null;
    },
    //幼儿园关闭
    kindergartencancel() {
      this.yryinnerVisible = false;
    },
    // 班级信息
    xmclick(row) {
      console.log(row);
      this.xmname = row.className;
      this.itemId2 = row.id;
      this.form.classId = row.id;
      console.log(this.form);
      this.innerVisible = false;
      this.form.className = row.className;
      this.queryParams3.classId = row.id;
      this.stname = "请选择学生姓名";
      this.itemId3 = "";
      this.addqueryParams.studentId = "";
      this.form.studentId = null;
      console.log(this.addqueryParams);
    },
    //打开选择学生页面
    studentinfoclick() {
      if (this.queryParams3.classId == "" || !this.queryParams3.classId) {
        this.$message.error("请先选择班级");
      } else {
        //查询学生信息
        studentInfo(this.queryParams3).then((res) => {
          this.studentInfos = res.rows;
          this.total3 = res.total;
          this.innerVisible2 = true;
          this.itemId2 = this.queryParams3.classId;
        });
      }
    },
    // 学生信息
    studentclick(row) {
      this.stname = row.studentName;
      this.itemId3 = row.id;
      this.form.studentId = row.id;
      this.addqueryParams.studentId = row.id;
      this.innerVisible2 = false;
      this.form.studentName = row.studentName;
      if (this.form.batchCode != null) {
        this.getAllTest();
      }
      // console.log(row);
    },

    //批次编号
    batchCodeclick(row) {
      this.itemNumbername = row.batchCode;
      this.addqueryParams.batchCode = row.batchCode;
      this.addqueryParams.batchId = row.id;
      console.log(this.addqueryParams);
      this.innerVisible4 = false;
      this.form.batchCode = row.batchCode;
      this.getAllTest();
    },
    /** 查询个人成绩录入管理列表 */

    getList() {
      //查询班级信息
      this.loading = true;
      //获取幼儿园list
      listKindergartenInfo(this.kqueryParams).then((response) => {
        this.kindergartenList = response.rows;
        this.total6 = response.total;
      });
      // 查询测试成绩批次编号
      testScoreBatch(this.queryParams5).then((res) => {
        this.testScoreBatchs = res.rows;
        this.total5 = res.total;
        this.loading = false;
      });

      listTestItemScore(this.queryParams).then((response) => {
        this.testItemScoreList = response.rows;
        this.total = response.total;
        this.loading = false;
      });

      tKindergartenInfo(this.itemResultType).then((res) => {
        // console.log(res);
        this.itemResultTypelist = res.data;
        this.ResultType1 = this.itemResultTypelist[0];
        this.ResultType2 = this.itemResultTypelist[1];
        console.log(this.ResultType1);
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.open2 = false;
      this.reset();
      this.kindergartenName = "请选择幼儿园";
      this.kindergartenId = "";
      this.xmname = "请选择所属班级";
      this.stname = "请选择学生姓名";
      this.itemNumbername = "请选择批次编号";
      this.itemId2 = "";
      this.itemId3 = "";
      this.queryParams2.kindergartenId = "";
      this.queryParams3.classId = "";
    },
    // 表单重置
    reset() {
      this.form = {
        id: "",
        classId: null,
        studentId: null,
        batchCode: null,
        itemScoreList: [],
        batchId: null,
        batchCode: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    // 所属班级
    handleQuery2() {
      this.queryParams2.pageNum = 1;
      if (this.queryParams2.kindergartenId == "") {
        this.$message.error("请先选择幼儿园");
      } else {
        this.classinfo();
        this.innerVisible = true;
        this.loading = false;
      }
    },
    // 学生姓名
    studentinfo() {
      studentInfo(this.queryParams3).then((response) => {
        this.studentInfos = response.rows;
        this.total3 = response.total;
      });
    },
    handleQuery3() {
      this.queryParams3.pageNum = 1;
      this.studentinfo();
      this.loading = false;
    },
    // 批次编号
    handleQuery5() {
      this.queryParams5.pageNum = 1;
      testScoreBatch(this.queryParams5).then((response) => {
        this.testScoreBatchs = response.rows;
        this.total5 = response.total;
        this.loading = false;
      });
    },
    kinhandleQuery() {
      listKindergartenInfo(this.kqueryParams).then((response) => {
        this.kindergartenList = response.rows;
        this.total6 = response.total;
      });
    },

    handleQuery() {
      this.queryParams.pageNum = 1;
      listTestItemScore(this.queryParams).then((response) => {
        this.testItemScoreList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 重置按钮操作 */
    classinfo() {
      classInfo(this.queryParams2).then((response) => {
        this.classInfos = response.rows;
        this.total2 = response.total;
        this.queryParams3.studentName = null;
      });
    },
    classresetQuery() {
      this.queryParams2.className = null;
      this.queryParams3.classId == "";
      this.classinfo();
    },
    kininfo() {
      listKindergartenInfo(this.kqueryParams).then((response) => {
        this.kindergartenList = response.rows;
        this.total6 = response.total;
      });
    },
    kinresetQuery() {
      this.kqueryParams.kindergartenName = "";
      this.queryParams2.kindergartenId = "";
    },
    resetQuery() {
      this.resetForm("queryForm");
      this.kqueryParams.kindergartenName = "";
      // 班级
      this.queryParams2.className = null;
      // 学生姓名
      this.queryParams5 = {
        pageNum: 1,
        pageSize: 10,
        batchCode: null,
        batchName: "",
      };
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        className: null,
        studentName: null,
        itemName: null,
        batchCode: null,
      };
      this.handleQuery();

      studentInfo(this.queryParams3).then((response) => {
        this.studentInfos = response.rows;
        this.total3 = response.total;
      });
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
      if (selection.length == 1) {
        console.log(selection.studentId);
        selection.forEach((e) => {
          this.selection2.studentId = e.studentId;
          this.selection2.batchCode = e.batchCode;
        });
      }
      console.log(this.selection2);
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.itemId2 = "";
      this.itemId3 = "";
      this.title = "添加个人成绩录入管理";
    },
    /** 修改按钮操作 */
    handleUpdate2() {
      this.reset();
      getTestItemScore(this.selection2).then((response) => {
        console.log();
        this.form = response.data;
        this.open2 = true;
        this.queryParams3.classId = response.data.classId;
        this.stname = response.data.studentName;
        this.itemId3 = response.data.studentId;
        this.addqueryParams.studentId = response.data.studentId;
        this.itemNumbername = response.data.batchCode;
        console.log(this.form);
      });
    },

    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      var list = {
        studentId: row.studentId,
        batchCode: row.batchCode,
      };
      this.form.itemScoreList = [];
      console.log(list);
      getTestItemScore(list).then((response) => {
        console.log();
        this.form = response.data;
        this.open2 = true;
        this.queryParams3.classId = response.data.classId;
        this.stname = response.data.studentName;
        this.itemId3 = response.data.studentId;
        this.addqueryParams.studentId = response.data.studentId;
        this.itemNumbername = response.data.batchCode;
        console.log(this.form);
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id == null) {
            updateTestItemScore(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open2 = false;
              this.getList();
              this.xmname = "请选择所属班级";
              this.stname = "请选择学生姓名";
              this.itemNumbername = "请选择批次编号";
              this.itemId2 = "";
              this.itemId3 = "";
              this.kindergartenName = "请选择幼儿园";
              this.kindergartenId = "";
              this.queryParams2.kindergartenId = "";
            });
          } else {
            this.form.itemScoreList.forEach((e) => {
              e.testItemId = e.itemId;
            });
            addTestItemScore(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
              this.xmname = "请选择所属班级";
              this.stname = "请选择学生姓名";
              this.itemNumbername = "请选择批次编号";
              this.itemId2 = "";
              this.itemId3 = "";
              this.kindergartenName = "请选择幼儿园";
              this.kindergartenId = "";
              this.queryParams2.kindergartenId = "";
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const studentId = row.studentId;
      const batchCode = row.batchCode;

      this.$modal
        .confirm("是否确认删除个人成绩的数据项？")
        .then(function () {
          return delTestItemScore(studentId, batchCode);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/testItemScore/export",
        {
          ...this.queryParams,
        },
        `testItemScore_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
