<template>
  <div class="page-box" v-loading="Loading.appMainLoading">
    <tablePagination
      v-if="apiColumns_Table"
      :currenButtonData="currenButtonData"
      :tableData="tableData"
      :tableLoading="Loading.tableLoading"
      :tableColumns="apiColumns_Table"
      @rowDrop="rowDrop"
      :totalCount="totalCount"
      :multipleSelection="multipleSelection"
      :MaxResultCount="PageListParams.MaxResultCount"
      @topbutton="topbutton"
      @inlineDialog="inlineDialog"
      @sortChange="sortChange"
      @alertoldSkipCount="alertoldSkipCount"
      @alterResultCount="alterResultCount"
      @handleSelectionChange="handleSelectionChange"
      :currentPageProps="oldSkipCount"
      :quicklySearchOption="quicklySearchOption"
      @quicklySearchClick="quicklySearchClick"
      @quicklySearchClear="quicklySearchClear"
      :primarySearchOption="primarySearchOption"
      @overallSearchFormClick="overallSearchFormClick"
      :httpOverallSearchData="httpOverallSearchData"
    ></tablePagination>
    <curren-Drawer
      :title="apiColumns_DesTions"
      :tableColumns="apiColumns_DetailsTable"
      :tabsDesTions="apiColumns_DesTions"
      :DrawerLoading="Loading.DrawerLoading"
      :drawer="displayDialog.detailsDialog"
      :dropdownData="dropdownData"
      :propsData="propsData"
      @drawerShut="(val) => (displayDialog.detailsDialog = val)"
      @drawerbutton="drawerbutton"
      @handleCommand="drawerHandle"
      @close-value="closeValue"
      :totalCount="totalCountDetails"
      :currentPage="oldSkipCountDetails"
      :MaxResultCount="MaxResultCountDetails"
      @alterResultCountDetails="alterResultCountDetails"
      @alertoldSkipCountDetails="alertoldSkipCountDetails"
    ></curren-Drawer>
    <!-- 新增与编辑 -->
    <newAndEdiDialog
      :loading="Loading.newAndEdiLoading"
      :active="active"
      :pageStatus="pageStatus"
      :formReveal="formReveal"
      :formTitle="formTitle"
      :displayDialog="editDialog"
      :FormData="formReveal ? CreateFormData : editFormData"
      :Form="formReveal ? CreateForm : editForm"
      :Options="editOptions"
      :Handle="editHandle"
      :Rules="formReveal ? editRules.cerateRule : editRules.editRule"
      @FormSubmit="FormSubmit"
      @close="FormClose"
      @goBack="goBack"
    ></newAndEdiDialog>
    <filterForDetailPage
      v-if="filterForDetailShow"
      :listColumns="apiColumns_DetailsTable"
      :parentColumns="apiColumns_Table"
      @closeDialog="changeFilterForDetailShow"
    ></filterForDetailPage>
    <!-- DeleteApi="TestSchoolDetailList_delete" -->
    <!-- todo: 明细查询中的parentColumns 是否需要独立表头，现与列表页面一致-->
  </div>
</template>
<script>
import { tableMixins } from "@/mixins/TableMixins";
import { LoadingMixins } from "@/mixins/LoadingMixins";
import { drawerMixins } from "@/mixins/drawerMixins"
import { TableHeaderMixins } from "@/mixins/TableHeaderMixins";
import { newAndEdiDialogMixins } from "@/mixins/newAndEdiDialogMixins"
import { mixins } from "@/mixins/mixins";
import { filterSelectMixins } from '@/mixins/filter-Select'
import { getToken } from '@/utils/auth'
import  * as tableColumns_api from "@/utils/tableColumns_api/index" //全局从接口缓存的表头
import  * as tabsDesTions_api from "@/utils/tabsDesTions_api/index" //全局从接口缓存的详情
import  * as detailsTableColumns_api from "@/utils/detailsTableColumns_api/index" //全局从接口缓存的详情


export default {
  name: "TestSchool",
  mixins: [
    tableMixins,
    LoadingMixins,
    drawerMixins,
    TableHeaderMixins,
    mixins,
    filterSelectMixins,
    newAndEdiDialogMixins
  ],
  computed: {
    editDialog: {
      get: function () {
        return this.displayDialog.newDialog || this.displayDialog.editDialog;
      },
    },
  },
  data() {
    return {
      //常用按钮数据
      currenButtonData: [
        this.defaultAddBtn(),//新增
        this.defaultExportBtn({
          isRedundance:true,
          isDetailExport:true
        }),//导出
        this.defaultFreshBtn(),//刷新
        this.defaultFilterBtn(),//筛选
        this.defaultFilterForDetailBtn()//明细查询按钮
      ],
      // 明细查询弹窗显示
      filterForDetailShow:false,
      //新增数据
      CreateFormData: {
        schoolName:null,
        orderType:null,
        details:null,
        details: [
          {
              "lastModifierId": "ad731144-d789-f322-fede-327cac55dd36",
              "creationTime": "1978-07-18T22:00:37.5Z",
              "creatorId": "19e78d1b-6203-8d6d-b6e7-ae5b503c0824",
              "id": "5926ec25-2132-ba25-6b93-e453c17f00e2",
              "studentName": "张三0712",
              "orderType": 712,
              "masterId": "a044e2c6-3bc6-7cdd-55a6-f1a2a9682ccb",
              "lastModificationTime": "1946-12-30T14:22:31.982Z"
          },
        ],
      },
      //编辑数据
      editFormData: {
        id:null,
        schoolName:null,
        orderType:null,
        details:null,
      },
      // 新增配置
      CreateForm: [
        { type: "input", label: '名称', prop: 'schoolName', colSpan: 12 },
        { type: "input", label: 'orderType', prop: 'orderType', colSpan: 12 },
      ],
      // 编辑配置
      editForm: [
        { type: "input", label: '名称', prop: 'schoolName', colSpan: 12 },
        { type: "input", label: 'orderType', prop: 'orderType', colSpan: 12 },
      ],
      editOptions: {},
      editRules: {
        cerateRule: {
          schoolName: [{ required: true, trigger: "blur", message: "不可为空" }],
        },
        editRule: {
          schoolName: [{ required: true, trigger: "blur", message: "不可为空" }],
        }
      },
    };
  },
  mounted() {
    this.initApiColumns()
    this.paging();
  },
  methods: {
    // 获取通过api的表头数据，不可以在初始化处理，因为接口返回问题
    initApiColumns(){
      this.apiColumns_Table = tableColumns_api[this.$route.name]
      this.apiColumns_DesTions = tabsDesTions_api[this.$route.name]
      this.apiColumns_DetailsTable = detailsTableColumns_api[this.$route.name]
    },
  }
}
</script>
<style lang="scss" scoped>
@import "@/styles/basicData.scss";
</style>