import { FormSingleSave } from "./pages/FormSingleSave.js";
import { FormSingleDetail } from "./pages/FormSingleDetail.js";
import { TabTableDetail } from "./pages/TabTableDetail.js";
import { TabTableSave } from "./pages/TabTableSave.js";
import { FormMainSubSave } from "./pages/FormMainSubSave.js";
import { TablePaggingSave } from "./pages/TablePaggingSave.js";
import { FormMainSubDetail } from "./pages/FormMainSubDetail.js";
import { GridSingleSelect } from "./lookup/GridSingleSelect.js";
import { GridMultiSelect } from "./lookup/GridMultiSelect.js";
import { TreeNodeSelect } from "./lookup/TreeNodeSelect.js";
import { TreeSingleSelect } from "./lookup/TreeSingleSelect.js";
import { TreeTableQuery } from "./pages/TreeTableQuery.js";
import { FormTableDetail } from "./pages/FormTableDetail.js";
import { TreeTabTableQuery } from "./pages/TreeTabTableQuery";
import { FormTabTableDetail } from "./pages/FormTabTableDetail";
/**
 * 报表模型构建类
 */
export const BirtModelFactory = {
    buildModel(reponsePage) {
        debugger
        let birtModel = reponsePage.birtModel || reponsePage;
        let tpl = reponsePage.template || birtModel.template;
        if (tpl) {
            return this._buildModelByTpl(tpl, birtModel);
        } else {
            // console.error("reponsePage返回页面模型模板template属性未定义.")
            return birtModel
        }
    },
    _buildModelByTpl(tpl, birtModel) {
        if (tpl.endsWith("form-single-save")) {
            return FormSingleSave(birtModel);
        } if (tpl.endsWith("form-single-detail")) {
            return FormSingleDetail(birtModel);
        } else if (tpl.endsWith("tab-table-detail")) {
            if (birtModel.hcDetailForm) {
                birtModel.hcDetailForm = this.buildModel(birtModel.hcDetailForm);
            }
            return TabTableDetail(birtModel);
        } else if (tpl.endsWith("tab-table-save")) {
            if (birtModel.hcDetailForm) {
                birtModel.hcDetailForm = this.buildModel(birtModel.hcDetailForm);
            }
            return TabTableSave(birtModel);
        } else if (tpl.endsWith("form-main-sub-detail")) {
            return FormMainSubDetail(birtModel);
        } else if (tpl.endsWith("form-main-sub-save")) {
            return FormMainSubSave(birtModel);
        } else if (tpl.endsWith("tree-table-query")) {
            return TreeTableQuery(birtModel);
        } else if (tpl.endsWith("tree-tab-table-query")) {
            if (birtModel.hcDetailForm) {
                birtModel.hcDetailForm = this.buildModel(birtModel.hcDetailForm);
            }
            return TreeTabTableQuery(birtModel);
        } else if (tpl.endsWith("table-pagging-save")) {
            return TablePaggingSave(birtModel);
        } else if (tpl.endsWith("form-tab-table")) {
            if (birtModel.hcDetailForm) {
                birtModel.hcDetailForm = this.buildModel(birtModel.hcDetailForm);
            }
            return FormTabTableDetail(birtModel);
        } else if (tpl.endsWith("lookup/grid-single-select")) {
            return GridSingleSelect(birtModel);
        } else if (tpl.endsWith("form-table-detail")) {
            return FormTableDetail(birtModel);
        } else if (tpl.endsWith("lookup/grid-multi-select")) {
            return GridMultiSelect(birtModel);
        } else if (tpl.endsWith("lookup/tree-node-select")) {
            return TreeNodeSelect(birtModel);
        } else if (tpl.endsWith("lookup/tree-single-select")) {
            return TreeSingleSelect(birtModel);
        } else if (tpl == "print") {
            return birtModel;
        } else {
            console.error(`template[${tpl}]报表模型模板未定义.`)
        }
    }

}