<!--
 * @Author: zhp
 * @Date: 2023-01-11 09:24:58
 * @LastEditTime: 2023-07-17 09:08:38
 * @LastEditors: zwq
 * @Description: 
-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__user">
      <SearchBar :formConfigs="formConfig" ref="ruleForm" @headBtnClick="buttonClick">
      </SearchBar>
      <base-table
        :table-props="tableProps"
        :page="listQuery.page"
        :limit="listQuery.limit"
        :table-data="tableData"
      >
        <method-btn
          v-if="tableBtn.length"
          slot="handleBtn"
          :width="100"
          label="操作"
          :method-list="tableBtn"
          @clickBtn="handleClick"
        />
      </base-table>
      <pagination
        :limit.sync="listQuery.limit"
        :page.sync="listQuery.page"
        :total="listQuery.total"
        @pagination="getDataList"
      />
      <!-- 弹窗, 条件搜索-->
      <!-- <base-dialog
        :dialogTitle="searchsTitle"
        :dialogVisible="searchsVisible"
        @cancel="searchsCancel"
        @confirm="searchsConfirm"
        :before-close="searchsCancel"
      >
        <searchs ref="searchsRef" @refreshDataList="searchsSubmit"></searchs>
      </base-dialog> -->
      <!-- 弹窗, 新增 / 修改 -->
      <base-dialog
        :dialogTitle="addOrEditTitle"
        :dialogVisible="addOrUpdateVisible"
        @cancel="handleCancel"
        @confirm="handleConfirm"
        :before-close="handleCancel"
      >
        <eightDiscipline-add ref="addOrUpdate" @refreshDataList="successSubmit">
        </eightDiscipline-add>
        <!-- <el-row slot="footer" type="flex" justify="end"> </el-row> -->
      </base-dialog>
    </div>
  </el-card>
</template>

<script>
import basicPage from "@/mixins/basic-page";
import eightDisciplineAdd from "./components/eightDiscipline-add";
import available from "./components/available.vue";
// import Searchs from "./components/eightDiscipline-searchs";
import codeFilter from "@/filters/code-filter";
import i18n from "@/i18n";
const tableProps = [
  {
    prop: "name",
    label: i18n.t("code.name"),
    align: "center",
  },
  {
    prop: "code",
    label: i18n.t("code.code"),
    align: "center",
  },
  {
    prop: "eightDisciplineType",
    label: i18n.t("code.eightDisciplineType"),
    align: "center",
    filter: codeFilter("eightDisciplineType"),
  },
  {
    prop: "problemStatus",
    label: i18n.t("code.problemStatus"),
    align: "center",
    subcomponent: available,
  },
];
const tableBtn = [
  {
    type: "edit",
    btnName: "编辑",
  },
  {
    type: "delete",
    btnName: "删除",
  },
];
export default {
  mixins: [basicPage],
  components: {
    eightDisciplineAdd,
    // Searchs,
  },
  data() {
    return {
      urlOptions: {
        getDataListURL: "/code/eightDiscipline/page",
        deleteURL: "/code/eightDiscipline",
      },
      tableProps,
      tableBtn,
      formConfig: [
        {
          type: "input",
          label: i18n.t("code.name"),
          placeholder: i18n.t("code.name"),
          param: "name",
        },
        {
          type: "input",
          label: i18n.t("code.code"),
          placeholder: i18n.t("code.code"),
          param: "code",
        },
        {
          type: "select",
          label: i18n.t('code.eightDisciplineStatus'),
          selectOptions: [
            { id: 1, name: "可用" },
            { id: 0, name: "不可用" },
          ],
          param: "eightDisciplineStatus",
          defaultSelect: "",
        },
        {
          type: "button",
          btnName: "搜索",
          name: "search",
          color: "primary",
        },
        {
          type: "button",
          btnName: "新增",
          name: "add",
          color: "primary",
        },
      ],
    };
  },
  methods: {
    //search-bar点击
    searchsClick() {
      this.searchsTitle = "条件搜索";
      this.searchsHandle();
    },
    buttonClick(val) {
      switch (val.btnName) {
        case "search":
          // this.listQuery.paramCode = val.paramCode;
          this.listQuery.page = 1;
          this.listQuery.code = val.code;
          this.listQuery.name = val.name;
          this.listQuery.eightDisciplineStatus = val.eightDisciplineStatus;
          this.getDataList();
          break;
        case "add":
          this.addOrEditTitle = this.$t("add");
          this.addOrUpdateVisible = true;
          this.addOrUpdateHandle();
          break;
        default:
          console.log(val);
      }
    },
  },
};
</script>
