<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.batchCode"
          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="handleUpdate"
          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"
    >
      <el-table-column type="selection" width="50" align="center" />

      <el-table-column label="班级名称" align="center" prop="className" />
      <el-table-column label="学生姓名" align="center" prop="studentName" />
      <el-table-column label="测试项目名称" align="center" prop="itemName" />
      <el-table-column
        width="150"
        label="所属批次编号"
        align="center"
        prop="batchCode"
      />
      <el-table-column label="个人成绩" align="center" prop="itemScore">
        <template slot-scope="scope">
          {{
            scope.row.scoreDictValue == "" || scope.row.scoreDictValue == null
              ? scope.row.itemScore
              : ""
          }}
          {{
            scope.row.itemScore == "" || scope.row.itemScore == null
              ? scope.row.scoreDictValue
              : ""
          }}
        </template>
      </el-table-column>
      <el-table-column
        label="个人成绩得分"
        align="center"
        prop="itemFraction"
      />
      <el-table-column
        label="综合评价"
        align="center"
        prop="syntheticalAssess"
      />
      <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-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="open2"
      width="550px"
      append-to-body
      :before-close="cancel2"
    >
      <el-form ref="form" :model="form" :rules="rules2" label-width="130px">
        <el-form-item label="所属班级" prop="classId">
          <el-input
            disabled
            v-model="form.classId"
            placeholder="请输入所属班级"
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
          />
        </el-form-item>

        <el-form-item label="学生姓名" prop="studentId">
          <el-input
            disabled
            v-model="form.studentName"
            placeholder="请选择学生姓名"
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
          />
        </el-form-item>

        <el-form-item label="测试项目名称" prop="testItemId">
          <el-input
            disabled
            v-model="form.itemName"
            placeholder="请选择测试项目名称"
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
          />
        </el-form-item>

        <el-form-item label="批次编号" prop="batchCode">
          <el-input
            disabled
            v-model="form.batchCode"
            placeholder="请选择批次编号"
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
          />
        </el-form-item>
        <el-form-item
          label="个人成绩"
          prop="itemScore"
          v-if="form.dictvalue == 'number'"
        >
          <el-input
            v-model="form.itemScore"
            placeholder="请输入个人成绩"
            style="width: 360px"
          />
        </el-form-item>
        <el-form-item
          label="个人成绩"
          prop="scoreDictValue"
          v-if="form.dictvalue == 'text'"
        >
          <el-input
            v-model="form.scoreDictValue"
            placeholder="请输入个人成绩"
            style="width: 360px"
          />
        </el-form-item>
        <el-form-item label="个人成绩得分" prop="itemFraction">
          <el-input
            v-model="form.itemFraction"
            placeholder="请输入个人成绩得分"
            style="width: 360px"
          />
        </el-form-item>
        <el-form-item label="综合评价" prop="syntheticalAssess">
          <el-input
            v-model="form.syntheticalAssess"
            placeholder="请输入综合评价"
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel2">取 消</el-button>
      </div>
    </el-dialog>

    <!-- //添加个人成绩录入管理 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="550px"
      append-to-body
      :before-close="cancel"
    >
      <el-form ref="form" :model="form2" :rules="rules" label-width="130px">
        <el-form-item label="所属幼儿园" prop="classId">
          <el-button
            type=""
            @click="yryinnerVisible = true"
            v-if="kindergartenName == '请选择幼儿园'"
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              color: #c0c4cc;
              padding-left: -10px;
            "
            >{{ kindergartenName }}</el-button
          >

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

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

          <el-button
            type=""
            @click="handleQuery2"
            v-else
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
            >{{ xmname }}</el-button
          >
        </el-form-item>

        <el-form-item label="学生姓名" prop="studentId">
          <el-button
            this.stname="row.studentName;"
            type=""
            @click="studentinfoclick"
            v-if="stname == '请选择学生姓名'"
            style="
              width: 360px;
              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: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
            >{{ stname }}</el-button
          >
        </el-form-item>

        <el-form-item label="测试项目名称" prop="testItemId">
          <el-button
            this.testname="row.itemName;"
            type=""
            v-if="testname == '请选择测试项目名称'"
            @click="innerVisible3 = true"
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              color: #c0c4cc;
              padding-left: -10px;
            "
            >{{ testname }}</el-button
          >

          <el-button
            this.testname="row.itemName;"
            type=""
            @click="innerVisible3 = true"
            v-else
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
            >{{ testname }}</el-button
          >
        </el-form-item>

        <el-form-item label="批次编号" prop="batchCode">
          <el-button
            this.itemNumbername="row.batchCode;"
            type=""
            @click="innerVisible4 = true"
            v-if="itemNumbername == '请选择批次编号'"
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              color: #c0c4cc;
              padding-left: -10px;
            "
            >{{ itemNumbername }}</el-button
          >
          <el-button
            type=""
            @click="innerVisible4 = true"
            v-else
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
            >{{ itemNumbername }}</el-button
          >
        </el-form-item>

        <el-form-item
          label="个人成绩"
          prop="scoreDictValue"
          v-if="form2.scoreDictId == '' || form2.scoreDictId == null"
        >
          <el-input
            v-model="value"
            placeholder="请输入个人成绩"
            style="width: 360px"
          />
        </el-form-item>

        <el-form-item
          label="个人成绩"
          prop="scoreDictValue"
          v-else-if="form2.scoreDictId == ResultType2.dictCode"
        >
          <el-input
            v-model="form2.scoreDictValue"
            placeholder="请输入个人成绩"
            style="width: 360px"
          />
        </el-form-item>

        <el-form-item
          label="个人成绩"
          prop="itemScore"
          v-else-if="form2.scoreDictId == ResultType1.dictCode"
        >
          <el-input
            v-model="form2.itemScore"
            placeholder="请输入个人成绩"
            style="width: 360px"
          />
        </el-form-item>
        <el-form-item label="个人成绩得分" prop="itemFraction">
          <el-input
            v-model="form2.itemFraction"
            placeholder="请输入个人成绩得分"
            style="width: 360px"
          />
        </el-form-item>

        <el-form-item label="综合评价" prop="syntheticalAssess">
          <el-input
            v-model="form2.syntheticalAssess"
            placeholder="请输入综合评价"
            style="
              width: 360px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
            "
          />
        </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
      width="850px"
      title="选择所属幼儿园"
      :visible.sync="yryinnerVisible"
      append-to-body
      :before-close="kindergartencancel"
    >
      <el-table :data="kindergartenList">
        <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="getList"
      />
    </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="handleQuery"
          />
        </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="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table :data="classInfos">
        <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="getList"
      />
    </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">
        <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="getList"
      />
    </el-dialog>

    <!-- 测试项目弹窗 -->

    <el-dialog
      width="850px"
      title="选择测试项目名称"
      :visible.sync="innerVisible3"
      append-to-body
    >
      <el-form
        :model="queryParams4"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="90px"
      >
        <el-form-item label="项目名称" prop="itemName">
          <el-input
            v-model="queryParams4.itemName"
            placeholder="请输入项目名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery4"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table :data="testItemss">
        <el-table-column label="请选择" width="70" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              style="width: 15px; height: 15px"
              v-if="itemId4 == scope.row.id"
              circle
              @click="testclick(scope.row)"
            ></el-button>
            <el-button
              v-else
              style="width: 15px; height: 15px"
              circle
              @click="testclick(scope.row)"
            ></el-button>
          </template>
        </el-table-column>

        <el-table-column
          property="itemName"
          label="项目名称"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column label="字典类型" align="center" prop="resultDictType">
          <template slot-scope="scope">
            {{
              scope.row.resultDictType == ResultType1.dictCode
                ? ResultType1.dictLabel
                : ""
            }}{{
              scope.row.resultDictType == ResultType2.dictCode
                ? ResultType2.dictLabel
                : ""
            }}</template
          >
        </el-table-column>
        <el-table-column
          property="itemCode"
          label="测试项目编号"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="itemContent"
          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="measureUnit"
          label="项目度量单位"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="largeStandardScore"
          label="大班标准最高得分"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="middleStandardScore"
          label="中班标准最高得分"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="smallStandardScore"
          label="小班标准最高得分"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="unifiedStandardScore"
          label="统一标准最高得分"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="sorting"
          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="total4 > 0"
        :total="total4"
        :page.sync="queryParams4.pageNum"
        :limit.sync="queryParams4.pageSize"
        @pagination="getList"
      />
    </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>
          <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-table :data="testScoreBatchs">
          <el-table-column label="请选择" width="70" align="center">
            <template slot-scope="scope">
              <el-button
                type="primary"
                style="width: 15px; height: 15px"
                v-if="itemId5 == scope.row.id"
                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-form>
    </el-dialog>
  </div>
</template>

<script>
import {
  listTestItemScore,
  getTestItemScore,
  delTestItemScore,
  addTestItemScore,
  updateTestItemScore,
  classInfo,
  studentInfo,
  testItems,
  testScoreBatch,
} from "@/api/system/testItemScore";
import {
  tKindergartenInfo,
  listKindergartenInfo,
} from "@/api/system/kindergartenInfo";
import Treeselect from "@riophae/vue-treeselect";
export default {
  name: "TestItemScore",
  components: { Treeselect },
  data() {
    var roleMoeny = (rule, value, callback) => {
      var str = value;
      var str_ = "";
      var str2 = "";
      str_ = str.substr(str.indexOf(".")).length;
      if (value.includes(".")) {
        str2 = str.substr(0, str.indexOf(".")).length;
        console.log(str2);
        if (Number.isNaN(Number.parseFloat(value))) {
          callback(new Error("请输入数字"));
        } else if (!this.form2.itemScore) {
          callback(new Error("不能为空"));
        } else if (this.form2.itemScore * 1 > 99999999) {
          callback(new Error("最大99999999")); // 限制最大额度
        } else if (this.form2.itemScore == "0") {
          callback(new Error("请输入成绩")); // 限制最大额度
        } else if (str_ > 3) {
          callback(new Error("小数点后两位")); // 限制最大额度
        } else if (str2 > 3) {
          callback(new Error("整数为三位")); // 限制最大额度
        } else {
          callback();
        }
      } else {
        str2 = str.length;
        console.log(str2);
        if (Number.isNaN(Number.parseFloat(value))) {
          callback(new Error("请输入数字"));
        } else if (!this.form2.itemScore) {
          callback(new Error("不能为空"));
        } else if (this.form2.itemScore * 1 > 99999999) {
          callback(new Error("最大99999999")); // 限制最大额度
        } else if (this.form2.itemScore == "0") {
          callback(new Error("请输入成绩")); // 限制最大额度
        } else if (str2 > 3) {
          callback(new Error("整数为三位")); // 限制最大额度
        } else {
          callback();
        }
      }
    };
    var roleMoeny2 = (rule, value, callback) => {
      var str = value;
      console.log(str);
      var str_ = "";
      var str2 = "";
      str_ = str.substr(str.indexOf(".")).length;
      if (value.includes(".")) {
        str2 = str.substr(0, str.indexOf(".")).length;
        console.log(str2);
        if (Number.isNaN(Number.parseFloat(value))) {
          callback(new Error("请输入数字"));
        } else if (!this.form2.itemFraction) {
          callback(new Error("不能为空"));
        } else if (this.form2.itemFraction * 1 > 99999999) {
          callback(new Error("最大99999999")); // 限制最大额度
        } else if (this.form2.itemFraction == "0") {
          callback(new Error("请输入成绩")); // 限制最大额度
        } else if (str_ > 3) {
          callback(new Error("小数点后两位")); // 限制最大额度
        } else if (str2 > 3) {
          callback(new Error("整数为三位")); // 限制最大额度
        } else {
          callback();
        }
      } else {
        str2 = str.length;
        console.log(str2);
        if (Number.isNaN(Number.parseFloat(value))) {
          callback(new Error("请输入数字"));
        } else if (!this.form2.itemFraction) {
          callback(new Error("不能为空"));
        } else if (this.form2.itemFraction * 1 > 99999999) {
          callback(new Error("最大99999999")); // 限制最大额度
        } else if (this.form2.itemFraction == "0") {
          callback(new Error("请输入成绩")); // 限制最大额度
        } else if (str2 > 3) {
          callback(new Error("整数为三位")); // 限制最大额度
        } else {
          callback();
        }
      }
    };

    var roleMoeny3 = (rule, value, callback) => {
      var str = this.form.itemScore;
      console.log(str);
      var str_ = "";
      var str2 = "";
      str_ = str.substr(str.indexOf(".")).length;
      if (value.includes(".")) {
        str2 = str.substr(0, str.indexOf(".")).length;
        console.log(str2);
        if (Number.isNaN(Number.parseFloat(value))) {
          callback(new Error("请输入数字"));
        } else if (!this.form.itemScore) {
          callback(new Error("不能为空"));
        } else if (this.form.itemScore * 1 > 99999999) {
          callback(new Error("最大99999999")); // 限制最大额度
        } else if (this.form.itemScore == "0") {
          callback(new Error("请输入成绩")); // 限制最大额度
        } else if (str_ > 3) {
          callback(new Error("小数点后两位")); // 限制最大额度
        } else if (str2 > 3) {
          callback(new Error("整数为三位")); // 限制最大额度
        } else {
          callback();
        }
      } else {
        str2 = str.length;
        console.log(str2);
        if (Number.isNaN(Number.parseFloat(value))) {
          callback(new Error("请输入数字"));
        } else if (!this.form.itemScore) {
          callback(new Error("不能为空"));
        } else if (this.form.itemScore * 1 > 99999999) {
          callback(new Error("最大99999999")); // 限制最大额度
        } else if (this.form.itemScore == "0") {
          callback(new Error("请输入成绩")); // 限制最大额度
        } else if (str2 > 3) {
          callback(new Error("整数为三位")); // 限制最大额度
        } else {
          callback();
        }
      }
    };
    var roleMoeny4 = (rule, value, callback) => {
      var str = this.form.itemFraction;
      console.log(str);
      var str_ = "";
      var str2 = "";
      str_ = str.substr(str.indexOf(".")).length;
      if (value.includes(".")) {
        str2 = str.substr(0, str.indexOf(".")).length;
        console.log(str2);
        if (Number.isNaN(Number.parseFloat(value))) {
          callback(new Error("请输入数字"));
        } else if (!this.form.itemFraction) {
          callback(new Error("不能为空"));
        } else if (this.form.itemFraction * 1 > 99999999) {
          callback(new Error("最大99999999")); // 限制最大额度
        } else if (this.form.itemFraction == "0") {
          callback(new Error("请输入成绩")); // 限制最大额度
        } else if (str_ > 3) {
          callback(new Error("小数点后两位")); // 限制最大额度
        } else if (str2 > 3) {
          callback(new Error("整数为三位")); // 限制最大额度
        } else {
          callback();
        }
      } else {
        str2 = str.length;
        console.log(str2);
        if (Number.isNaN(Number.parseFloat(value))) {
          callback(new Error("请输入数字"));
        } else if (!this.form.itemFraction) {
          callback(new Error("不能为空"));
        } else if (this.form.itemFraction * 1 > 99999999) {
          callback(new Error("最大99999999")); // 限制最大额度
        } else if (this.form.itemFraction == "0") {
          callback(new Error("请输入成绩")); // 限制最大额度
        } else if (str2 > 3) {
          callback(new Error("整数为三位")); // 限制最大额度
        } else {
          callback();
        }
      }
    };

    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: [],
      innerVisible3: false,
      testname: "请选择测试项目名称",
      testScoreBatchs: [],
      innerVisible4: 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: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open2: false,
      itemId2: "",
      itemId3: "",
      itemId4: "",
      itemId5: "",
      // 查询参数
      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: "",
      },
      // 测试项目
      queryParams4: {
        pageNum: 1,
        pageSize: 10,
        itemName: null,
      },
      // 批次编号
      queryParams5: {
        pageNum: 1,
        pageSize: 10,
        batchCode: null,
      },

      // 表单参数
      form: {},
      form2: {},
      // 表单校验
      rules2: {
        itemScore: [
          {
            required: true,
            validator: roleMoeny3,
            message: "",
            trigger: "blur",
          },
        ],
        classId: [
          { required: true, message: "所属班级不能为空", trigger: "blur" },
        ],
        studentId: [
          { required: true, message: "学生姓名不能为空", trigger: "blur" },
        ],
        testItemId: [
          { required: true, message: "测试项目名称不能为空", trigger: "blur" },
        ],
        batchCode: [
          {
            required: true,
            message: "批次编号不能为空",
            trigger: "blur",
          },
        ],

        scoreDictValue: [
          { required: true, message: "请输入个人成绩", trigger: "blur" },
        ],
        itemFraction: [
          {
            required: true,
            validator: roleMoeny4,
            message: "",
            trigger: "blur",
          },
        ],

        syntheticalAssess: [
          { required: true, message: "综合评价不能为空", trigger: "blur" },
        ],
      },
      rules: {
        itemScore: [
          {
            required: true,
            validator: roleMoeny,
            message: "",
            trigger: "blur",
          },
        ],
        classId: [
          { required: true, message: "所属班级不能为空", trigger: "blur" },
        ],
        studentId: [
          { required: true, message: "学生姓名不能为空", trigger: "blur" },
        ],
        testItemId: [
          { required: true, message: "测试项目名称不能为空", trigger: "blur" },
        ],
        batchCode: [
          {
            required: true,
            message: "批次编号不能为空",
            trigger: "blur",
          },
        ],

        scoreDictValue: [
          { required: true, message: "请输入个人成绩", trigger: "blur" },
        ],
        itemFraction: [
          {
            required: true,
            validator: roleMoeny2,
            message: "",
            trigger: "blur",
          },
        ],
        syntheticalAssess: [
          { required: true, message: "综合评价不能为空", trigger: "blur" },
        ],
      },
      realVal: "",
      realVal2: "",
    };
  },
  created() {
    this.getList();
  },

  methods: {
    //幼儿园左侧点击
    kindergartenNameclick(row) {
      this.form2.kindergartenId = row.id;
      this.queryParams2.kindergartenId = row.id;
      this.kindergartenName = row.kindergartenName;
      this.kindergartenId = row.id;
      this.yryinnerVisible = false;
    },
    //幼儿园关闭
    kindergartencancel() {
      this.yryinnerVisible = false;
    },
    // 班级信息
    xmclick(row) {
      console.log(row);
      this.xmname = row.className;
      this.itemId2 = row.id;
      this.form.classId = row.id;
      this.form2.classId = row.id;

      console.log(this.form);
      this.innerVisible = false;
      this.form.className = row.className;

      this.queryParams3.classId = row.id;
    },
    //打开选择学生页面
    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.form2.studentId = row.id;

      this.innerVisible2 = false;
      this.form.studentName = row.studentName;
      // console.log(row);
    },

    //测试项目
    testclick(row) {
      if (row.resultDictType == this.ResultType2.dictCode) {
        this.form2.scoreDictId = this.ResultType2.dictCode; //wenben
      } else if (row.resultDictType == this.ResultType1.dictCode) {
        this.form2.scoreDictId = this.ResultType1.dictCode; //number
      }
      console.log(this.form);
      console.log(this.form2);
      console.log(row);
      this.testname = row.itemName;
      this.itemId4 = row.id;
      this.form.testItemId = row.id;
      this.form2.testItemId = row.id;
      this.innerVisible3 = false;
      this.form.itemName = row.itemName;
      // if (row.resultDictType == this.ResultType1.dictCode) {
      //   this.form2.resultDictType = this.ResultType1.dictValue;
      //   this.form.dictValue = this.ResultType1.dictValue;
      //   this.form2.scoreDictValue = "";
      // }

      // if (row.resultDictType == this.ResultType2.dictCode) {
      //   this.form2.resultDictType = this.ResultType2.dictValue;
      //   this.form.dictValue = this.ResultType2.dictValue;
      //   this.form.itemScore = "";
      //   this.form2.itemScore = "";
      // }
    },

    //批次编号
    batchCodeclick(row) {
      // console.log(row);
      // ResultType1
      this.itemNumbername = row.batchCode;
      this.itemId5 = row.id;
      // this.form.itemScore = row.id;
      // this.form2.itemScore = row.id;

      this.innerVisible4 = false;
      this.form.batchCode = row.batchCode;
      this.form2.batchCode = row.batchCode;
    },
    /** 查询个人成绩录入管理列表 */

    getList() {
      //查询班级信息
      this.loading = true;

      // 查询测试项目
      testItems(this.queryParams4).then((res) => {
        this.testItemss = res.rows;
        this.total4 = res.total;
        this.loading = false;
      });
      //获取幼儿园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];
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
      this.kindergartenName = "请选择幼儿园";
      this.kindergartenId = "";
      this.xmname = "请选择所属班级";
      this.stname = "请选择学生姓名";
      this.testname = "请选择测试项目名称";
      this.itemNumbername = "请选择批次编号";
      this.itemId2 = "";
      this.itemId3 = "";
      this.itemId4 = "";
      this.itemId5 = "";
      this.queryParams2.kindergartenId = "";
      this.queryParams3.classId = "";
    },
    cancel2() {
      this.open2 = false;
      // this.xmname = "请选择所属项目";
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        classId: null,
        studentId: null,
        testItemId: null,
        scoreDictId: null,
        scoreDictValue: null,
        batchCode: null,
        itemScore: null,
        syntheticalAssess: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        scoreDictValue: "",
        itemScore: "",
        resultDictType: "",
      };
      this.form2 = {
        classId: null,
        studentId: null,
        testItemId: null,
        scoreDictId: null,
        scoreDictValue: null,
        batchCode: null,
        itemScore: null,
        syntheticalAssess: null,
        scoreDictValue: "",
        itemScore: "",
      };
      //  this.form2 = {
      //   itemId: null,
      //   scoreDictValue: "",
      //   item: "",
      //   resultDictType: "", //number text
      // };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    // 所属班级
    handleQuery2() {
      this.queryParams2.pageNum = 1;
      if (this.queryParams2.kindergartenId == "") {
        this.$message.error("请先选择幼儿园");
      } else {
        classInfo(this.queryParams2).then((response) => {
          this.classInfos = response.rows;
          this.total = response.total;
          this.loading = false;
          this.innerVisible = true;
        });
      }
    },
    // 学生姓名
    handleQuery3() {
      this.queryParams3.pageNum = 1;
      studentInfo(this.queryParams).then((response) => {
        this.studentInfo = response.rows;
        this.total = response.total;
        this.loading = false;
        this.getList();
      });
    },
    // 测试项目
    handleQuery4() {
      this.queryParams4.pageNum = 1;
      testItems(this.queryParams).then((response) => {
        this.testItems = response.rows;
        this.total = response.total;
        this.loading = false;
        this.getList();
      });
    },
    // 批次编号
    handleQuery5() {
      this.queryParams5.pageNum = 1;
      testScoreBatch(this.queryParams).then((response) => {
        this.testScoreBatch = response.rows;
        this.total = response.total;
        this.loading = false;
        this.getList();
      });
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
      this.queryParams.className = "";
    },
    // 多选框选中数据
    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.itemId2 = "";
      this.itemId3 = "";
      this.itemId4 = "";
      this.itemId5 = "";
      this.title = "添加个人成绩录入管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getTestItemScore(id).then((response) => {
        // this.xmname = row.className;
        // this.stname = row.studentName;
        // this.testname=row.itemName;
        // this.itemNumbername = row.batchCode;
        if (response.data.itemScore == "" || response.data.itemScore == null) {
          response.data.dictvalue = "text";
        } else if (
          response.data.scoreDictValue == "" ||
          response.data.scoreDictValue == null
        ) {
          response.data.dictvalue = "number";
        }
        this.form = response.data;
        //  this.form = response.className;
        // this.queryParams.xmname = this.className;
        this.open2 = true;
        this.title = "修改个人成绩录入管理";
        console.log(this.form);
      });
    },
    /** 提交按钮 */
    submitForm() {
      console.log(this.form2);
      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();
            });
          } else {
            addTestItemScore(this.form2).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
              this.xmname = "请选择所属班级";
              this.stname = "请选择学生姓名";
              this.testname = "请选择测试项目名称";
              this.itemNumbername = "请选择批次编号";
              this.itemId2 = "";
              this.itemId3 = "";
              this.itemId4 = "";
              this.itemId5 = "";
              this.kindergartenName = "请选择幼儿园";
              this.kindergartenId = "";
              this.queryParams2.kindergartenId = "";
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm("是否确认删除个人成绩的数据项？")
        .then(function () {
          return delTestItemScore(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/testItemScore/export",
        {
          ...this.queryParams,
        },
        `testItemScore_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
