<!-- 查看成绩 -->
<template>
  <div>
    <el-dialog
      :before-close="handleClose"
      :close-on-click-modal="false"
      :visible="visible"
      custom-class="bbsl-location-dialog"
      title="批量设置成绩"
      width="50%"
    >
      <div>
        <el-form
          ref="formInfo"
          :model="form"
          :rules="rules"
          label-position="top"
          label-width="150px"
        >
          <el-row>
            <el-col :span="8">
              <el-form-item label="课目" prop="subjectId">
                <el-select
                  v-model="form.subjectId"
                  clearable
                  placeholder="请选择课目"
                  @change="positionPaper"
                >
                  <el-option
                    v-for="item in subjectList"
                    :key="item.subjectid"
                    :label="item.subjectname"
                    :value="item.subjectid"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="试卷" prop="paperId">
                <el-select
                  v-model="form.paperId"
                  clearable
                  placeholder="请选择试卷"
                >
                  <el-option
                    v-for="item in paperList"
                    :key="item.paperid"
                    :label="item.name"
                    :value="item.paperid"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirm">确 认</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import ndbbMenu from '@/api/examination/ndbbMenu.js'

export default {
  name: 'resultsDialog',
  data() {
    return {
      visible: false,
      form: {
        positionId: '',
        subjectId: '',
        paperId: ''
      },
      subjectList: [],
      subjectId: '',
      paperList: [],
      rules: {
        subjectId: [
          {
            required: true,
            message: '请选择课目',
            trigger: 'blur'
          }
        ],
        paperId: [
          {
            required: true,
            message: '请选择试卷',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  created() {},
  mounted() {},
  methods: {
    open(val) {
      console.log(val)
      this.visible = true
      this.form.positionId = val
      this.subjectInfo()
    },
    //课目
    subjectInfo() {
      ndbbMenu.getSubjectInfo(
        {
          positionId: this.form.positionId
        },
        res => {
          if (res.state) {
            this.subjectList = res.value
          }
        }
      )
    },
    //试卷
    positionPaper(val) {
      ndbbMenu.getPositionPaper(
        {
          subjectId: val
        },
        res => {
          if (res.state) {
            this.paperList = res.value
          }
        }
      )
    },
    confirm() {
      console.log(this.form)
      ndbbMenu.batchSettingYear(this.form, res => {
        if (res.state) {
          this.$message({
            message: '设置成功',
            type: 'success'
          })
          this.handleClose()
        }
      })
    },
    // 关闭新增人员窗口
    handleClose() {
      this.visible = false
      this.form = {
        positionId: '',
        subjectId: '',
        paperId: ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog__body {
  height: 100% !important;
  max-height: 80%;
}

.left-aside {
  border-right: 1px solid #eee;
  padding: 10px;
}

.select-aside {
  border-left: 1px solid #eee;
}

::v-deep .el-table__header-wrapper .el-checkbox {
  //找到表头那一行，然后把里面的复选框隐藏掉
  display: none;
}
</style>
