/**
 * 表单，网格明细，页面模板
 * @param {*} detailDataset 详情数据集，命名规范 ds_[数组下标]_[对话框id]
 * @param {*} conf 组件定义配置项
 * @returns 
 */
 import { StringUtil } from "@birt/funclib/StringUtil.js";
 import { FormStyleFactory } from "../compose/FormStyleFactory";
 import { TableStyleFactory } from "../compose/TableStyleFactory";

 export function FormTableDetail(conf) {
     debugger
     const dlgId = StringUtil.randomString(6);
     // 设置数据集id
     var detailDataset = conf.mainDataset;
     detailDataset.controlId += "_" + dlgId;
 
     // 详情表单
     var hcForm = false;
     if (conf.hcForm) {
         hcForm = {
             controlName: "HcForm",
             controlId: "HcForm_" + dlgId,
             dataset: detailDataset.controlId,
             children: []
         }
         // 应用表单个性化配置
         Object.assign(hcForm, FormStyleFactory.buildForm(conf.hcForm) || {});
     }
     // 网格明细
     var hcTable = {
         controlName: "HcTable",
         dataset: detailDataset.controlId,
         height: function (parentHeight) {
             return parentHeight - 100;
         },
         children: [],
     };
     // 应用网格个性化配置
     Object.assign(hcTable, TableStyleFactory.buildTable(dlgId, detailDataset.controlId, conf) || {});
 
     // 应用报表模型
     var birtWorkBook = Object.assign({
         controlName: "BirtWorkBook",
         controlId: "BirtWorkBook_" + dlgId,
         showToolBar: false,
         totalPage: 1,
         renderType: "detail",
         height: function (parentHeight) {
             return parentHeight;
         },
     }, conf.birtWorkBook || {})
     // 添加布局结构
     birtWorkBook.children = [
         {
             controlName: "BirtSheet",
             controlId: "BirtSheet_" + dlgId,
             name: "sheet_" + dlgId,
             pageIndex: 0,
             dataSets: [detailDataset],
             children: [
                 {
                     controlName: "BirtFormSheet",
                     controlId: "BirtFormSheet_" + dlgId,
                     children: [].concat(hcForm ? hcForm : []).concat(hcTable)
                 }
             ]
         }
     ]
     return birtWorkBook
 }