"use strict";
import { base } from './base.js'
import { util } from '../../util/util.js'
import { tree } from '../page/query/tree.js'
import {khcModal} from '../alert/khcModal.js'
import {config} from "../../config.js";
import {page} from "../page/page.js";
import {fullMap} from "../../fullMap.js";
import {pageInfoMap} from "../../pageInfoMap.js";
import {httpUtil} from "../../util/httpUtil.js";
/**
 * 子表
 */
class vChildPage extends base {
    constructor(data) {
        super(data);
        this.type='childPage';
        this.isValue=false;
        this.pageObj=null;
    }
    render(parentObjID) {
        let that=this;
        let data = this.data
        let pageCode=data.dict_code.code;
        let code = { pageCode: pageCode }
        let obj={url:config.getConfigJson().pageInfoUrl,params:code,isClientCache:true}
        httpUtil.post(obj, (response)=>{
            let pageType = response.data.data.page_type;
            if (pageType == 'ordinary') {
                let componentArray = response.data.data.componentData;
                for (let i = 0; i < componentArray.length; i++) {
                    let componentInfo = componentArray[i];
                    let code={ version: '1.0.0', dsCode: componentInfo.ds_code, formCode: componentInfo.form_code,queryCode: componentInfo.query_code };
                    let formCode = { parentObjID: util.getUUID() + 'div', type: 'form', code: code }
                    let queryCode = { parentObjID: util.getUUID() + 'div', type: 'query', code: code };
                    let formPageData = { parentObjID: parentObjID };
                    formPageData['parentFormObjID'] = data.formObjID;
                    formPageData['pageCode'] = pageCode;
                    formPageData['formCode'] = formCode;

                    formPageData['queryCode'] = queryCode;
                    formPageData['pkFieldName'] = 'id';
                    formPageData['isReadOnly'] = data.is_read_only;
                    obj={url:config.getConfigJson().metaUrl,params:code,isClientCache:true}
                    httpUtil.post(obj, (response)=>{
                        let thisFormPage = new page(formPageData);
                        thisFormPage.render();
                        fullMap.push(thisFormPage.objID, thisFormPage);
                        that.pageObj=thisFormPage;
                    });
                }
            }
        });
    }
    setDisabled(){
        let that=this;
        that.data.is_read_only='Y';//未创建对象时只需设置状态即可，是否渲染会根据此状态判断
        if(!util.isNull(that.pageObj)){
            that.pageObj.isReadOnly='Y';
            that.pageObj.queryComponent.tableView.setDisabled();//已创建的对象需调用方法
        }
    }
    removeDisabled(){

    }
    hide(){
        //document.getElementById(this.parentObjID).setAttribute('style', 'display:none');//隐藏
    }
    show(){
        //document.getElementById(this.parentObjID).setAttribute('style', '');//展示
    }
    getValue() {

    }
    setValue(){

    }
    hideDiv(){

    }
    showDiv(){

    }
    refreshCanNull(){

    }

}
export { vChildPage }