<template>
  <div id="homeworkAchiece">
    <el-row>
      <el-col :span="24" class="list">
        <van-collapse v-model="openCollapse">
          <van-collapse-item :name="index" v-for="(item, index) in achieveList" :key="index">
            <div slot="title" class="title" @click="clickcds(item.id)">
              <span class="name">{{ item.name }}</span>
            </div>
            <van-row v-for="(tag, index) in lesson" :key="index">
              <el-col :span="18">
                <van-col :span="24" class="score"> 名称：{{ tag.lessonname }} </van-col>
                <van-col :span="24" class="score"> 作业分： {{ tag.score }}分</van-col>
              </el-col>
              <el-col :span="6" class="anniu">
                <van-col :span="3" class="score">
                  <van-button v-if="user.job == '学委'" type="primary" size="mini" @click="clickBtn(tag.id, tag.name, tag.score)">上成绩</van-button>
                </van-col>
              </el-col>
            </van-row>
          </van-collapse-item>
        </van-collapse>
      </el-col>
    </el-row>
    <van-dialog v-model="show" title="学生成绩上传" :showConfirmButton="false">
      <van-form @submit="onSubmit">
        <span class="lesson">课程名称</span><span class="lesson">{{ names }}</span>
        <van-field v-model="form.score" name="作业分数" :value="score" label="作业分数" placeholder="请输入作业分数" />
        <div style="margin: 16px;">
          <van-button round block type="info" native-type="submit">
            提交
          </van-button>
        </div>
      </van-form>
    </van-dialog>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
export default {
  name: 'homeworkAchiece',
  props: {
    achieveList: null,
    show: null,
    form: null,
    lessonList: null,
    deptList: null,
    lesson: null,
    lesslist: null,
    names: null,
    score: null,
  },
  components: {},
  data: () => ({
    ruleForm: {
      region: '',
    },
    value: '',
    columns: ['杭州', '宁波', '温州', '嘉兴', '湖州'],
    showPicker: false,
    openCollapse: [],
  }),
  created() {},
  computed: { ...mapState(['user']) },
  methods: {
    onConfirm(value) {
      this.value = value;
      this.showPicker = false;
    },
    clickcds(id) {
      this.$emit('submitss', { id: id });
    },
    clickBtn(id, name, score) {
      this.$emit('clickDialog', { id: id, name: name, score: score });
    },
    onSubmit() {
      this.$emit('submit', { data: this.form });
    },
  },
};
</script>

<style lang="less" scoped>
p {
  padding: 0;
  margin: 0;
}
.list {
  margin: 5px;
  width: 97%;
  padding: 0 10px;
  border-radius: 15px;
}
.list .title {
  float: left;
  width: 100%;
}
.list .name {
  float: left;
  width: 80%;
  font-size: 20px;
}
/deep/.van-cell {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}
/deep/.van-collapse-item__content {
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  padding: 5px 10px;
}
/deep/.van-collapse-item {
  margin: 0 0 10px 0;
}
/deep/.el-collapse-item__content {
  padding: 10px 0 10px 0;
}
.list .score {
  padding: 5px 0;
  font-size: 18px;
}
.anniu {
  padding: 20px 0 0 0;
}
.lesson {
  font-size: 14px;
  padding: 0 21px 0 16px;
  color: #323233;
}
</style>
