<template>

  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleCancel"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-table
      ref="table"
      size="middle"
      :pagination="false"
      rowKey="id"
      :columns="columns"
      :dataSource="knows">
    </a-table>
  </j-modal>
</template>

<script>

import {getAction, httpAction} from '@/api/manage'
import pick from 'lodash.pick'
import JTreeSelect from '@/components/jeecg/JTreeSelect'
import {validateDuplicateValue} from '@/utils/util'
import JImageUpload from '@/components/jeecg/JImageUpload'
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
import JDictSelectTag from "@/components/dict/JDictSelectTag"
import JMultiSelectTag from "@/components/dict/JMultiSelectTag"
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
import JEditor from '@/components/jeecg/JEditor'

export default {
  name: "StudentPaperPointsShowModal",
  components: {
    JImageUpload,
    JTreeSelect,
    JSelectDepart,
    JSelectUserByDep,
    JDictSelectTag,
    JMultiSelectTag,
    JSearchSelectTag,
    JEditor,
  },
  data() {
    return {
      form: this.$form.createForm(this),
      title: "操作",
      width: 800,
      visible: false,
      model: {},
      sum: 0.0,
      labelCol: {
        xs: {span: 24},
        sm: {span: 5},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      },
      confirmLoading: false,
      validatorRules: {},
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        }, {
          title: '名称',
          align: "center",
          dataIndex: 'knowname'
        }, {
          title: '得分',
          align: "center",
          dataIndex: 'point'
        },{
          title: '应得分',
          align: "center",
          dataIndex: 'pointshould'
        },
        {
          title: '比例',
          align: "center",
          dataIndex: 'percentage',
          sorter: (a, b) => {
            return a.percentage-b.percentage;
          }
        },
      ],
      url: {
        getpoint: "/course/seCourse/getpoint",
        getStudentExamPoints: "/ex/exHistory/getStudentExamPoints"
      },
      knows: []
    }
  },
  created() {
  },
  methods: {
    add() {
      this.edit({});
    },
    edit(record) {
    },
    showpoint(id) {
      this.visible = true;
      this.knows=[]
      getAction(this.url.getStudentExamPoints, {id: id}).then((res) => {
        if (res.success) {
          console.log(res.success)
          console.log(res.result)
          this.knows = res.result;
        } else {

        }
      });
    },
    accAdd(arg1, arg2) {
      var r1, r2, m;
      try {
        r1 = arg1.toString().split(".")[1].length
      } catch (e) {
        r1 = 0
      }
      try {
        r2 = arg2.toString().split(".")[1].length
      } catch (e) {
        r2 = 0
      }
      m = Math.pow(10, Math.max(r1, r2));
      return (arg1 * m + arg2 * m) / m;
    },
    close() {
      this.$emit('close');
      this.visible = false;
    },
    handleCancel() {
      this.close()
    },
  }
}
</script>