<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__user">
      <!-- <search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" /> -->
      <base-table
        :table-props="tableProps"
        :page="listQuery.page"
        :limit="listQuery.limit"
        :table-data="tableData"
      >
        <method-btn
          v-if="tableBtn.length"
          slot="handleBtn"
          :width="60"
          :label="$t('handle')"
          :method-list="tableBtn"
          @clickBtn="handleClick"
        />
      </base-table>
      <pagination
        :limit.sync="listQuery.limit"
        :page.sync="listQuery.page"
        :total="listQuery.total"
        @pagination="getDataList"
      />
      <!-- 弹窗, 新增 / 修改 -->
      <base-dialog
        :dialogTitle="addOrEditTitle"
        :dialogVisible="addOrUpdateVisible"
        @cancel="handleCancel"
        @confirm="handleConfirm"
        :before-close="handleCancel"
        :destroy-on-close="true"
      >
        <add-or-update ref="addOrUpdate" @refreshDataList="successSubmit"></add-or-update>
      </base-dialog>
    </div>
  </el-card>
</template>

<script>
import AddOrUpdate from "./components/startEightGrade-add";
import basicPage from "@/mixins/basic-page";
import codeFilter from "@/filters/code-filter";
import { timeFormatter } from "@/filters/code-filter";
import i18n from "@/i18n";

const tableProps = [
  {
    prop: "title",
    label: i18n.t("code.title"),
    align: "center",
  },
  {
    prop: "code",
    label: i18n.t("code.code"),
    align: "center",
  },
  {
    prop: "eightDisciplineType",
    label: i18n.t("code.eightDisciplineType"),
    align: "center",
    filter: codeFilter("eightDisciplineType"),
  },
  {
    prop: "occurrenceDate",
    label: i18n.t("code.occurrenceDate"),
    align: "center",
    filter: timeFormatter,
  },
  {
    prop: "description",
    label: i18n.t("code.description"),
    align: "center",
  },
  {
    prop: "gradeFinish",
    label: "打分状态",
    align: "center",
    filter: codeFilter("gradeFinish"),
  },
];
const tableBtn = [
  {
    type: "grade",
    btnName: "打分",
  },
];

export default {
  mixins: [basicPage],
  data() {
    return {
      urlOptions: {
        getDataListURL: "/code/startEightDiscipline/page",
        deleteURL: "/code/startEightDiscipline",
      },
      tableProps,
      tableBtn,
      listQuery: {
        limit: 10,
        page: 1,
        total: 1,
        eightDisciplineStatus: 9,
        examineStatus: 0,
      },
      tableData: [],
      formConfig: [
        {
          type: "button",
          btnName: "搜索",
          name: "search",
          color: "primary",
        },
      ],
    };
  },
  components: {
    AddOrUpdate,
  },
  methods: {
    //search-bar点击
    buttonClick(val) {
      switch (val.btnName) {
        case "search":
          this.listQuery.page = 1;
          this.getDataList();
          break;
        default:
          console.log(val);
      }
    },
    otherMethods(val) {
      if(val.data.gradeFinish){
        this.$message({
          message: '该数据已完成打分操作，请勿重复打分！',
          type: 'warning'
        });
      }else{
      this.addOrEditTitle = "打分";
      this.addOrUpdateVisible = true;
      this.addOrUpdateHandle(val.data.id);
      }
    },
  },
};
</script>
