<template>
  <div>
    <BaseDialog
      width="990px"
      :isShow.sync="isDialog"
      title="题库记录"
      :isShowFooter="false"
      @close="close"
    >
      <div style="max-height: 600px; overflow-y: auto;padding: 3px;">
        <table-list
          rowKey="id"
          ref="tableList"
          :tableSets="tableSet"
          :tableData="tableData"
          :navText="navText"
          :loading="loading"
        >
          <template slot="customize">
            <el-button type="warning" @click="openAddDialog"> 新增 </el-button>
          </template>
          <template slot="btn" slot-scope="props">
            <el-button type="text" @click="del(props.scope.row)"
              >删除</el-button
            >
          </template>
        </table-list>
      </div>
      <!-- 新增弹窗 -->
      <addQuestionBankDialog ref="addQuestionBankDialog" @refresh="refresh()" />
    </BaseDialog>
  </div>
</template>
  
<script>
import tableList from "@/components/tableList";
import addQuestionBankDialog from "./addQuestionBankDialog.vue";
export default {
  components: { tableList, addQuestionBankDialog },
  data() {
    return {
      isDialog: false,
      loading: false,
      navText: {
        title: "开通记录",
        index: 0,
        ch: "条",
        addHide: true,
        custom: false,
      },
      tableSet: [
        {
          label: "",
          prop: "sign",
          hidden: true,
        },
        {
          label: "姓名",
          prop: "userName",
          hidden: true,
        },
        {
          label: "身份证号",
          prop: "userCard",
          hidden: true,
          width: "180"
        },
        {
          label: "教育类型",
          prop: "eduName",
          hidden: true,
        },
        {
          label: "业务层次",
          prop: "businessName",
          hidden: true,
          width: "300"
        },
        {
          label: "专业",
          prop: "majorName",
          hidden: true,
        },
        {
          label: "开通日期",
          prop: "openDate",
          scope: "aTimeList",
          hidden: true,
          isDiszing: true,
          width: "180"
        },
      ],
      tableData: [],
      total: 0,
    };
  },
  mounted() {},
  methods: {
    openBoxs(row, type) {
      this.isDialog = true;
      this.ruleForm = {
        orderGoodsId: row.orderGoodsId,
        orderSn: row.orderSn,
        userCard: row.userCard,
        userName: row.userName,
      }
      this.search()
    },
    close() {
      this.ruleForm = {};
    },
    openAddDialog() {
      this.$refs.addQuestionBankDialog.openBoxs(this.ruleForm)
    },
    search(v) {
      this.loading = true;
      this.$api
        .orderQuestionBankList(this.ruleForm)
        .then((res) => {
          this.tableData = res.data;
          this.navText.index = res.data?.length;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    refresh() {
      this.$emit("refresh");
      this.search();
    },
    del(v) {
      this.$confirm("确定删除此内容？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$api
            .delOrderQuestionBank(v.id)
            .then((res) => {
              this.$message.success("删除成功");
              this.search();
            });
        })
        .catch(() => {});
    },
  },
};
</script>
  
<style lang="scss" scoped>
.text {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
</style>
  