"use strict";
import { fullMap } from '../../../../fullMap.js';
import { khcAlert } from '../../../alert/khcAlert.js'
import { form } from '../../form/form.js';
import { util } from '../../../../util/util.js'
import { khcModal } from '../../../alert/khcModal.js'
import { config } from "../../../../config.js";
import {pageInfoMap} from "../../../../pageInfoMap.js";
import {httpUtil} from "../../../../util/httpUtil.js";
import {bpm} from "../../../bpm/bpm.js";
import {khcModalSlide} from "../../../alert/khcModalSlide.js";
import {khcToastr} from "../../../alert/khcToastr.js";
import {page} from "../../page.js";
import {khcBootBox} from "../../../alert/khcBootBox.js";
//let jsonConfig={objID:that.data.queryComponentObjID,button_method:button.button_method,pkCode:pkCode}
let functionMap=new Map();// 使用 Map 来存储多个函数。每个函数都通过 set 方法添加到 Map 中，键是函数名，值是对应的函数。
export function main(jsonConfig) {
    try {
        functionMap.get(jsonConfig.button_method).apply(jsonConfig);
    } catch (error) {
        khcAlert.showSystemError(error.message);
        console.log(error);
    }
}
/*function createOne() {
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let pageID = queryViewComponent.pageID;
    //如何获取form的code
    let params = {};
    let componentArray = fullMap.getObj(pageID).componentArray;
    for (let i = 0; i < componentArray.length; i++) {
        if (componentArray[i].type == 'form') {
            params = componentArray[i].code;
        }
    }
    let formPage = fullMap.getObj(pageID);
    formPage.formComponent.initForm();
    formPage.showComponent('form');
    let eleMap = formPage.formComponent.getFormMap();
    if(pageInfoMap.getObj(formPage.formComponent.code.queryCode)==undefined){
    }else{
        eleMap.get('page_parent_uuid').setValue(pageInfoMap.getObj(formPage.formComponent.code.queryCode).page_parent_uuid)
    }
    eleMap.forEach( (obj,key)=>{
        if(obj.type=='childPage'){
            //start 新增时按钮渲染
            let tableView=obj.pageObj.queryComponent.tableView
            let rowButtonArray=tableView.queryInfo.rowButtonArray
            for (let i = 0; i < rowButtonArray.length; i++) {
                rowButtonArray[i].button_show_query_type='1'
            }
            let tableButtonArray=tableView.queryInfo.tableButtonArray
            for (let i = 0; i < tableButtonArray.length; i++) {
                tableButtonArray[i].button_show_query_type='1';
                let buttonEle=document.getElementById(obj.pageObj.queryComponent.parentObjID).querySelector('button[name="'+tableButtonArray[i].button_name+'"]');
                if(buttonEle!=null){
                    buttonEle.style.display='';
                }
            }
            //end 新增时按钮渲染
        }
    })
    formPage.formComponent.setSaveAfter( ()=> {
        let pkId = formPage.formComponent.saveOneData.id;
        let dsCode = formPage.formComponent.code.dsCode;
        let formCode = formPage.formComponent.code.formCode;
        let queryCode = formPage.queryComponent.code.queryCode;
        let pageCode = formPage.pageCode;
        let processInstanceID = formPage.formComponent.saveOneData.process_instance_id;
        let taskId = formPage.formComponent.saveOneData.process_task_id;
        if (!util.isNull(processInstanceID)) {
            let editObj={pageCode:pageCode,dsCode:dsCode,queryCode:queryCode,formCode:formCode,pkId:pkId,taskId:taskId};
            util.toEditPage(editObj);
        } else {
            formPage.formComponent.clearValue();
            formPage.showComponent('query');
            formPage.queryComponent.getTableObj().refresh();
        }

    })
    formPage.formComponent.formCreate();
    formPage.formComponent.setButtonParams(jsonConfig.buttonParams);
}*/

function createOne(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let pageComponent=fullMap.getObj(queryViewComponent.pageID);
    let formComponent=null;
    if(jsonConfig.getFormComponentFunc!=undefined){
        formComponent=jsonConfig.getFormComponentFunc(pageComponent);
    }else{
        formComponent=pageComponent.formComponent;
    }
    if(util.isNull(formComponent)){
        let formData={}
        if(jsonConfig.getFormDataFunc!=undefined){
            formData=jsonConfig.getFormDataFunc(pageComponent);
        }else{
            let componentArray = pageComponent.componentArray;
            for (let i = 0; i < componentArray.length; i++) {
                if (componentArray[i].type == 'form') {
                    let parentObjId=util.getUUID();
                    document.getElementById(pageComponent.objID).insertAdjacentHTML('afterBegin',`<div class="d-none" id="${parentObjId}"></div>`);
                    formData = {
                        parentObjID: parentObjId,
                        code: componentArray[i].code ,
                        pageID:componentArray[i].pageID}
                }
            }
            formData.type='create_form';
            pageComponent.componentArray.push(formData);
        }
        formComponent = new form(formData);
        fullMap.push(formData.parentObjID,formComponent);
        formComponent.setFormShowType('modals')
        if(jsonConfig.setSaveBefore!=undefined){
            formComponent.setSaveBefore(jsonConfig.setSaveBefore);
        }
        formComponent.setSaveAfter( ()=> {
            let pkId = formComponent.saveOneData.id;
            let dsCode = formComponent.code.dsCode;
            let formCode = formComponent.code.formCode;
            let queryCode = pageComponent.queryComponent.code.queryCode;
            let pageCode = pageComponent.pageCode;
            let processInstanceID = formComponent.saveOneData.process_instance_id;
            let taskId = formComponent.saveOneData.process_task_id;
            if (!util.isNull(processInstanceID)) {
                let editObj={pageCode:pageCode,dsCode:dsCode,queryCode:queryCode,formCode:formCode,pkId:pkId,taskId:taskId};
                util.toEditPage(editObj);
            } else {
                formComponent.clearValue();
                pageComponent.showComponent('query');
                pageComponent.queryComponent.getTableObj().refresh();
            }
        })
        formComponent.render().then(() => {
            if(jsonConfig.renderThenFunc!=undefined){
                formComponent.renderThenFunc=jsonConfig.renderThenFunc;
            }else{
                formComponent.renderThenFunc=()=> {
                    let eleMap = formComponent.getFormMap();
                    if(pageInfoMap.getObj(formComponent.code.queryCode)==undefined||
                        pageInfoMap.getObj(formComponent.code.queryCode).page_parent_uuid==undefined){
                    }else{
                        eleMap.get('page_parent_uuid').setValue(pageInfoMap.getObj(formComponent.code.queryCode).page_parent_uuid)
                    }
                    formComponent.formCreate();
                    formComponent.setButtonParams(jsonConfig.buttonParams);
                    if(jsonConfig.setFormComponentFunc!=undefined){
                        jsonConfig.setFormComponentFunc(pageComponent,formComponent);
                    }else{
                        pageComponent.formComponent=formComponent;
                    }
                    if(jsonConfig.showComponentFunc!=undefined){
                        jsonConfig.showComponentFunc(pageComponent);
                    }else{
                        pageComponent.showComponent('create_form');
                    }
                }
            }
            formComponent.renderThenFunc();
        });
    }else{
        formComponent.renderThenFunc();
    }
}
functionMap.set('createOne', createOne);// 将函数添加到 Map 中
/**
 * 右侧模态框
 */
function createOneByModalSlide(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let params = {};
    let pageComponent=fullMap.getObj(queryViewComponent.pageID);
    let componentArray = pageComponent.componentArray;
    for (let i = 0; i < componentArray.length; i++) {
        if (componentArray[i].type == 'form') {
            params = componentArray[i].code;
        }
    }
    params=util.clone(params);//如果参数有调整请先克隆后再修改。
    if(jsonConfig.paramsAfterFunc!=undefined){
        params=jsonConfig.paramsAfterFunc(params);
    }
    let khcModalForForm=pageComponent.createOneByModalSlideForm;
    if(jsonConfig.getKhcModalForFormAfterFunc!=undefined){
        khcModalForForm=jsonConfig.getKhcModalForFormAfterFunc(pageComponent);
    }
    if(khcModalForForm==null){
        khcModalForForm = new khcModalSlide({ modalAreaID: config.getConfigJson().modalAreaID });
        let parentFormObj=fullMap.getObj(pageComponent.parentFormObjID);
        if(parentFormObj!=undefined){
            khcModalForForm.parentModal=parentFormObj.khcModalForForm
        }
        if(jsonConfig.getKhcModalForFormAfterFunc!=undefined){
            if(jsonConfig.setKhcModalForFormAfterFunc!=undefined){
                jsonConfig.setKhcModalForFormAfterFunc(pageComponent,khcModalForForm);
            }else{
                khcToastr.showErrorMessage('渲染异常,原因是重写了：getKhcModalForFormAfterFunc ，则：setKhcModalForFormAfterFunc也必须重写')
                return ;
            }
        }else{
            pageComponent.createOneByModalSlideForm=khcModalForForm;
        }
        khcModalForForm.render().then(() => {
            let formComponent = new form({ parentObjID: khcModalForForm.getEleID(), code: params ,pageID:queryViewComponent.pageID});
            formComponent.khcModalForForm=khcModalForForm;
            khcModalForForm.formComponent=formComponent;
            khcModalForForm.formObjID=formComponent.getObjID()
            let khcModalForFormKey='khcModalForForm#'+formComponent.getObjID();
            pageInfoMap.push(khcModalForFormKey,khcModalForForm);
            formComponent.setFormShowType('modals')
            if(jsonConfig.setSaveBefore!=undefined){
                formComponent.setSaveBefore(jsonConfig.setSaveBefore);
            }
            formComponent.setSaveAfter( ()=> {
                if(util.isNull(formComponent.saveOneData)){//如果没有返回保存后的数据可能是重写的保存操作，但响应状态是成功的则直接刷新即可
                    formComponent.clearValue();
                    khcModalForForm.hide();
                    pageComponent.queryComponent.getTableObj().refresh();
                    return ;
                }
                let pkId = formComponent.saveOneData.id;
                let dsCode = formComponent.code.dsCode;
                let formCode = formComponent.code.formCode;
                let queryCode = pageComponent.queryComponent.code.queryCode;
                let pageCode = pageComponent.pageCode;
                let processInstanceID = formComponent.saveOneData.process_instance_id;
                let taskId = formComponent.saveOneData.process_task_id;
                if (!util.isNull(processInstanceID)) {
                    let editObj={pageCode:pageCode,dsCode:dsCode,queryCode:queryCode,formCode:formCode,pkId:pkId,taskId:taskId};
                    util.toEditPage(editObj);
                } else {
                    formComponent.clearValue();
                    khcModalForForm.hide();
                    pageComponent.queryComponent.getTableObj().refresh();
                }
            })
            formComponent.render().then(() => {
                if(jsonConfig.renderThenFunc!=undefined){
                    formComponent.renderThenFunc=jsonConfig.renderThenFunc;
                }else{
                    formComponent.renderThenFunc=()=> {
                        let eleMap = formComponent.getFormMap();
                        if(pageInfoMap.getObj(formComponent.code.queryCode)==undefined||
                            pageInfoMap.getObj(formComponent.code.queryCode).page_parent_uuid==undefined){
                        }else{
                            eleMap.get('page_parent_uuid').setValue(pageInfoMap.getObj(formComponent.code.queryCode).page_parent_uuid)
                        }
                        formComponent.formCreate();
                        formComponent.setButtonParams(jsonConfig.buttonParams);
                        khcModalForForm.show();
                    }
                }
                formComponent.renderThenFunc();
            });
        })
    }else{
        let formComponent=khcModalForForm.formComponent
        formComponent.renderThenFunc();
        formComponent.initForm();
    }

}
functionMap.set('createOneByModalSlide', createOneByModalSlide);// 将函数添加到 Map 中
/**
 * 居中模态框
 * @param objID
 */
function createOneByModal(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let params = {};
    let pageComponent=fullMap.getObj(queryViewComponent.pageID);
    let componentArray = pageComponent.componentArray;
    for (let i = 0; i < componentArray.length; i++) {
        if (componentArray[i].type == 'form') {
            params = componentArray[i].code;
        }
    }
    params=util.clone(params);//如果参数有调整请先克隆后再修改。
    if(jsonConfig.paramsAfterFunc!=undefined){
        params=jsonConfig.paramsAfterFunc(params);
    }
    let khcModalForForm=pageComponent.createOneByModalForm;
    if(jsonConfig.getKhcModalForFormAfterFunc!=undefined){
        khcModalForForm=jsonConfig.getKhcModalForFormAfterFunc(pageComponent);
    }
    if(khcModalForForm==null){
        khcModalForForm = new khcModal({ modalAreaID: config.getConfigJson().modalAreaID });
        if(jsonConfig.getKhcModalForFormAfterFunc!=undefined){
            if(jsonConfig.setKhcModalForFormAfterFunc!=undefined){
                jsonConfig.setKhcModalForFormAfterFunc(pageComponent,khcModalForForm);
            }else{
                khcToastr.showErrorMessage('渲染异常,原因是重写了：getKhcModalForFormAfterFunc ，则：setKhcModalForFormAfterFunc也必须重写')
                return ;
            }
        }else{
            pageComponent.createOneByModalForm=khcModalForForm;
        }
        khcModalForForm.render().then(() => {
            let formComponent = new form({ parentObjID: khcModalForForm.getEleID(), code: params ,pageID:queryViewComponent.pageID});
            formComponent.khcModalForForm=khcModalForForm;
            khcModalForForm.formComponent=formComponent;
            khcModalForForm.formObjID=formComponent.getObjID()
            let khcModalForFormKey='khcModalForForm#'+formComponent.getObjID();
            pageInfoMap.push(khcModalForFormKey,khcModalForForm);
            formComponent.setFormShowType('modals')
            if(jsonConfig.setSaveBefore!=undefined){
                formComponent.setSaveBefore(jsonConfig.setSaveBefore);
            }
            formComponent.setSaveAfter( ()=> {
                let pkId = formComponent.saveOneData.id;
                let dsCode = formComponent.code.dsCode;
                let formCode = formComponent.code.formCode;
                let queryCode = pageComponent.queryComponent.code.queryCode;
                let pageCode = pageComponent.pageCode;
                let processInstanceID = formComponent.saveOneData.process_instance_id;
                let taskId = formComponent.saveOneData.process_task_id;
                if (!util.isNull(processInstanceID)) {
                    let editObj={pageCode:pageCode,dsCode:dsCode,queryCode:queryCode,formCode:formCode,pkId:pkId,taskId:taskId};
                    util.toEditPage(editObj);
                } else {
                    formComponent.clearValue();
                    khcModalForForm.hide();
                    pageComponent.queryComponent.getTableObj().refresh();
                }
            })
            formComponent.render().then(() => {
                if(jsonConfig.renderThenFunc!=undefined){
                    formComponent.renderThenFunc=jsonConfig.renderThenFunc;
                }else{
                    formComponent.renderThenFunc=()=> {
                        let eleMap = formComponent.getFormMap();
                        if(pageInfoMap.getObj(formComponent.code.queryCode)==undefined||
                            pageInfoMap.getObj(formComponent.code.queryCode).page_parent_uuid==undefined){
                        }else{
                            eleMap.get('page_parent_uuid').setValue(pageInfoMap.getObj(formComponent.code.queryCode).page_parent_uuid)
                        }
                        formComponent.formCreate();
                        formComponent.setButtonParams(jsonConfig.buttonParams);
                        khcModalForForm.show();
                    }
                }
                formComponent.renderThenFunc();
            });
        })
    }else{
        let formComponent=khcModalForForm.formComponent
        formComponent.renderThenFunc();
        formComponent.initForm();
    }
}
functionMap.set('createOneByModal', createOneByModal);// 将函数添加到 Map 中
/*function editOne() {
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let content = tableViewComponent.getContentMap().get(jsonConfig.pkCode.toString());
    let pageID = queryViewComponent.pageID;
    let params = {};
    let componentArray = fullMap.getObj(pageID).componentArray;
    for (let i = 0; i < componentArray.length; i++) {
        if (componentArray[i].type == 'form') {
            params = componentArray[i].code;
        }
    }
    let formPage = fullMap.getObj(pageID);
    let formVersion=formPage.formComponent.formStructureData.formInfo.form_version
    if(!util.isNull(formVersion)){
        let nowVersion=content.form_version;
        if(nowVersion!=formVersion){
            let pkFieldName=formPage.formComponent.pkFieldName
            let pkId=content[pkFieldName];
            let dsCode=formPage.formComponent.code.dsCode;
            let formCode=formPage.formComponent.code.formCode;
            let queryCode=formPage.queryComponent.code.queryCode;
            let pageCode=formPage.pageCode;
            let taskId = formPage.formComponent.saveOneData.process_task_id;
            let url='./index.html#'+pageCode+'?pageCode='+pageCode+'&dsCode='+dsCode+'&queryCode='+queryCode+'&formCode='+formCode+'&pkId='+pkId+'&formVersion='+nowVersion+'&taskId='+taskId+'&formShowType=page'
            window.location.href=url
            return ;
        }
    }
    formPage.showComponent('form');
    formPage.formComponent.renderValue(content).then(()=>{
        formPage.formComponent.oldEditData=JSON.parse(JSON.stringify(formPage.formComponent.getFormValue()));
        formPage.renderOpinion();
        let showButtonNameArray=[];
        let formView = formPage.formComponent;
        let formButtons=formView.formMap.get('buttons');
        //todo 是否启用工作流，现在的逻辑就是这两个字段有值就是启用工作流，
        // 这个不严谨，如果后续需要新加一个表单给权限大的用户来直接修改数据，就做不了，只能由开发人员来数据库操作修改，应根据form组件配置的变量来校验是否启用工作流
        if (content['process_instance_id'] != null && content['process_instance_id'].length > 0) {
            let formView = formPage.formComponent;
            let thisBpm=new bpm({formView:formView});
            thisBpm.process_definition_id=content.process_definition_id;
            thisBpm.process_instance_id=content.process_instance_id;
            thisBpm.render();
        }
        // start 屏幕看不到按钮后添加固定按钮样式
        let buttons=formButtons;
        if(formPage.formComponent.formStructureData.formInfo.is_bpm_model=='Y'){
            window.onscroll= ()=>{
                let buttonsHtmlObj=document.getElementById(buttons.objID);
                if(buttonsHtmlObj!=null){
                    //滚动条高度+视窗高度 = 可见区域底部高度
                    let visibleBottom = window.scrollY + document.documentElement.clientHeight;
                    //可见区域顶部高度
                    let visibleTop = window.scrollY;
                    let buttonEle=document.getElementById(buttons.objID).querySelector('button[name="' + buttons.data.buttons[0].button_name + '"]');
                    let centerY = buttonEle.offsetTop+(buttonEle.offsetHeight/2)+120;//加120高度
                    if(centerY>visibleTop&&centerY<visibleBottom){
                        for (let i = 0; i < showButtonNameArray.length; i++) {
                            let buttonEle=document.getElementById(buttons.objID).querySelector('button[name="' + showButtonNameArray[i] + '"]');
                            if(buttonEle.style.display==''){
                                buttonEle.style.position='';
                                buttonEle.style.top='';
                                buttonEle.style.zIndex='';
                            }
                        }
                    }else{
                        let auto=1;
                        for (let i = 0; i < showButtonNameArray.length; i++) {
                            let buttonEle=document.getElementById(buttons.objID).querySelector('button[name="' + showButtonNameArray[i] + '"]');
                            if(buttonEle.style.display==''){
                                let buttonTop=10+auto*45;
                                auto++;
                                buttonEle.style.position='fixed';
                                buttonEle.style.top=buttonTop+'px';
                                buttonEle.style.left='88%';
                                buttonEle.style.zIndex=99;
                            }
                        }
                    }
                }
            }
        }
        // end 屏幕看不到按钮后添加固定按钮样式
        formPage.formComponent.setSaveAfter( ()=> {
            if (content['process_instance_id'] == null || content['process_instance_id'].length == 0) {//非工作流表单编辑完成后返回列表
                formPage.formComponent.clearValue();
                formPage.showComponent('query');
            }
            formPage.queryComponent.getTableObj().refresh();

        });
        formPage.formComponent.formEdit();
        formPage.formComponent.setButtonParams(jsonConfig.buttonParams);
    });
}*/
function editOne(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let content = tableViewComponent.getContentMap().get(jsonConfig.pkCode.toString());
    let params = {};
    let pageComponent=fullMap.getObj(queryViewComponent.pageID);
    let formComponent=null;
    if(jsonConfig.getFormComponentFunc!=undefined){
        formComponent=jsonConfig.getFormComponentFunc(pageComponent);
    }else{
        formComponent=pageComponent.editFormComponent;
    }
    if(util.isNull(formComponent)) {
        let formData = {}
        if (jsonConfig.getFormDataFunc != undefined) {
            formData = jsonConfig.getFormDataFunc(pageComponent);
        } else {
            let componentArray = pageComponent.componentArray;
            for (let i = 0; i < componentArray.length; i++) {
                if (componentArray[i].type == 'edit_form') {
                    formData = {
                        parentObjID: componentArray[i].parentObjID,
                        code: componentArray[i].code,
                        pageID: componentArray[i].pageID
                    }
                }
            }
            for (let i = 0; i < componentArray.length; i++) {
                if (componentArray[i].type == 'form') {
                    let parentObjId=util.getUUID();
                    document.getElementById(pageComponent.objID).insertAdjacentHTML('afterBegin',`<div class="d-none" id="${parentObjId}"></div>`);
                    formData = {
                        parentObjID: parentObjId,
                        code: componentArray[i].code ,
                        pageID:componentArray[i].pageID}
                }
            }
            formData.type='edit_form';
            pageComponent.componentArray.push(formData);
        }
        formComponent = new form(formData);
        fullMap.push(formData.parentObjID, formComponent);
        formComponent.setFormShowType('modals')
        formComponent.render().then(() => {
            if(jsonConfig.renderThenFunc!=undefined){
                formComponent.renderThenFunc=jsonConfig.renderThenFunc;
            }else{
                formComponent.renderThenFunc=(content)=>{
                    formComponent.renderValue(content).then(()=>{
                        let eleMap = formComponent.getFormMap();
                        let read=pageInfoMap.getObj('readOnly#'+params.formCode)
                        if(read!=undefined){
                            for (let i = 0; i < read.length; i++) {
                                eleMap.get(read[i]).setDisabled();
                            }
                        }
                        let canNull=pageInfoMap.getObj('canNull#'+params.formCode)
                        if(jsonConfig.setSaveBefore!=undefined){
                            formComponent.setSaveBefore(jsonConfig.setSaveBefore);
                        }
                        formComponent.setSaveAfter( ()=> {
                            pageComponent.showComponent('query');
                            queryViewComponent.getTableObj().refresh();
                        })
                        if(canNull!=undefined){
                            for (let i = 0; i < canNull.length; i++) {
                                eleMap.get(canNull[i]).data.can_null='Y';
                                eleMap.get(canNull[i]).refreshCanNull();
                            }
                        }
                        formComponent.oldEditData=JSON.parse(JSON.stringify(formComponent.getFormValue()));
                        if(!util.isNull(content['process_definition_id'])){
                            let thisBpm=new bpm({formView:formComponent});
                            thisBpm.render();
                        }
                        formComponent.formEdit();//一些高级属性在新增时大部分是不需要设置所以隐藏，在编辑时再展示
                        formComponent.setButtonParams(jsonConfig.buttonParams);
                        if(jsonConfig.showComponentFunc!=undefined){
                            jsonConfig.showComponentFunc(pageComponent);
                        }else{
                            pageComponent.showComponent('edit_form');
                        }
                    })
                }
                if(jsonConfig.setFormComponentFunc!=undefined){
                    jsonConfig.setFormComponentFunc(pageComponent,formComponent);
                }else{
                    pageComponent.editFormComponent=formComponent;
                }
            }
            formComponent.renderThenFunc(content);
        });
    }else{
        formComponent.renderThenFunc(content);
    }
}
functionMap.set('editOne', editOne);// 将函数添加到 Map 中
/**
 * 右侧模态框
 * @param objID
 */
function editOneByModalSlide(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let content = tableViewComponent.getContentMap().get(jsonConfig.pkCode.toString());
    let params = {};
    let pageComponent=fullMap.getObj(queryViewComponent.pageID);
    let componentArray = pageComponent.componentArray;
    for (let i = 0; i < componentArray.length; i++) {
        if (componentArray[i].type == 'form') {
            params = componentArray[i].code;
        }
    }
    params=util.clone(params);//如果参数有调整请先克隆后再修改。
    if(jsonConfig.paramsAfterFunc!=undefined){
        params=jsonConfig.paramsAfterFunc(params);
    }
    let khcModalForForm=pageComponent.editOneByModalSlideForm;
    if(jsonConfig.getKhcModalForFormAfterFunc!=undefined){
        khcModalForForm=jsonConfig.getKhcModalForFormAfterFunc(pageComponent);
    }
    if(khcModalForForm==null){
        khcModalForForm = new khcModalSlide({ modalAreaID: config.getConfigJson().modalAreaID });
        let parentFormObj=fullMap.getObj(pageComponent.parentFormObjID);
        if(parentFormObj!=undefined){
            khcModalForForm.parentModal=parentFormObj.khcModalForForm
        }
        if(jsonConfig.getKhcModalForFormAfterFunc!=undefined){
            if(jsonConfig.setKhcModalForFormAfterFunc!=undefined){
                jsonConfig.setKhcModalForFormAfterFunc(pageComponent,khcModalForForm);
            }else{
                khcToastr.showErrorMessage('渲染异常,原因是重写了：getKhcModalForFormAfterFunc ，则：setKhcModalForFormAfterFunc也必须重写')
                return ;
            }
        }else{
            pageComponent.editOneByModalSlideForm=khcModalForForm;
        }
        khcModalForForm.render().then(() => {
            let formComponent = new form({ parentObjID: khcModalForForm.getEleID(), code: params ,pageID:queryViewComponent.pageID});
            formComponent.khcModalForForm=khcModalForForm;
            khcModalForForm.formComponent=formComponent;
            khcModalForForm.formObjID=formComponent.getObjID()
            let khcModalForFormKey='khcModalForForm#'+formComponent.getObjID();
            pageInfoMap.push(khcModalForFormKey,khcModalForForm);//将khcModal存到pageMap里,拿到此对象可控制隐藏和展示
            formComponent.setFormShowType('modals')
            formComponent.render().then(() => {
                if(jsonConfig.renderThenFunc!=undefined){
                    formComponent.renderThenFunc=jsonConfig.renderThenFunc;
                }else{
                    formComponent.renderThenFunc=(content)=>{
                        //formComponent.code.queryParam=tableViewComponent.getQueryParam(formComponent.code.queryCode);
                        formComponent.code.queryParam=tableViewComponent.code['queryParam'];
                        formComponent.renderValue(content).then(()=>{
                            let eleMap = formComponent.getFormMap();
                            let read=pageInfoMap.getObj('readOnly#'+params.formCode)
                            if(read!=undefined){
                                for (let i = 0; i < read.length; i++) {
                                    eleMap.get(read[i]).setDisabled();
                                }
                            }
                            let canNull=pageInfoMap.getObj('canNull#'+params.formCode)
                            if(jsonConfig.setSaveBefore!=undefined){
                                formComponent.setSaveBefore(jsonConfig.setSaveBefore);
                            }
                            formComponent.setSaveAfter( ()=> {
                                queryViewComponent.getTableObj().refresh();
                                khcModalForForm.hide();
                            })
                            if(canNull!=undefined){
                                for (let i = 0; i < canNull.length; i++) {
                                    eleMap.get(canNull[i]).data.can_null='Y';
                                    eleMap.get(canNull[i]).refreshCanNull();
                                }
                            }
                            formComponent.formEdit();//一些高级属性在新增时大部分是不需要设置所以隐藏，在编辑时再展示
                            formComponent.setButtonParams(jsonConfig.buttonParams);
                            khcModalForForm.show();
                        })
                    }
                }
                formComponent.renderThenFunc(content);
            });
        })
    }else{
        let formComponent=khcModalForForm.formComponent
        formComponent.renderThenFunc(content);
    }
}
functionMap.set('editOneByModalSlide', editOneByModalSlide);// 将函数添加到 Map 中
/**
 * 居中模态框
 * @param objID
 */
function editOneByModal(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let content = tableViewComponent.getContentMap().get(jsonConfig.pkCode.toString());
    let params = {};
    let pageComponent=fullMap.getObj(queryViewComponent.pageID);
    let componentArray = pageComponent.componentArray;
    for (let i = 0; i < componentArray.length; i++) {
        if (componentArray[i].type == 'form') {
            params = componentArray[i].code;
        }
    }
    params=util.clone(params);//如果参数有调整请先克隆后再修改。
    if(jsonConfig.paramsAfterFunc!=undefined){
        params=jsonConfig.paramsAfterFunc(params);
    }
    let khcModalForForm=pageComponent.editOneByModalForm;
    if(jsonConfig.getKhcModalForFormAfterFunc!=undefined){
        khcModalForForm=jsonConfig.getKhcModalForFormAfterFunc(pageComponent);
    }
    if(khcModalForForm==null){
        khcModalForForm = new khcModal({ modalAreaID: config.getConfigJson().modalAreaID });
        if(jsonConfig.getKhcModalForFormAfterFunc!=undefined){
            if(jsonConfig.setKhcModalForFormAfterFunc!=undefined){
                jsonConfig.setKhcModalForFormAfterFunc(pageComponent,khcModalForForm);
            }else{
                khcToastr.showErrorMessage('渲染异常,原因是重写了：getKhcModalForFormAfterFunc ，则：setKhcModalForFormAfterFunc也必须重写')
                return ;
            }
        }else{
            pageComponent.editOneByModalForm=khcModalForForm;
        }
        khcModalForForm.render().then(() => {
            let formComponent = new form({ parentObjID: khcModalForForm.getEleID(), code: params ,pageID:queryViewComponent.pageID});
            formComponent.khcModalForForm=khcModalForForm;
            khcModalForForm.formComponent=formComponent;
            khcModalForForm.formObjID=formComponent.getObjID()
            let khcModalForFormKey='khcModalForForm#'+formComponent.getObjID();
            pageInfoMap.push(khcModalForFormKey,khcModalForForm);//将khcModal存到pageMap里,拿到此对象可控制隐藏和展示
            formComponent.setFormShowType('modals')
            formComponent.render().then(() => {
                if(jsonConfig.renderThenFunc!=undefined){
                    formComponent.renderThenFunc=jsonConfig.renderThenFunc;
                }else {
                    formComponent.renderThenFunc=(content)=>{
                        formComponent.renderValue(content).then(()=>{
                            let eleMap = formComponent.getFormMap();
                            let read=pageInfoMap.getObj('readOnly#'+params.formCode)
                            if(read!=undefined){
                                for (let i = 0; i < read.length; i++) {
                                    eleMap.get(read[i]).setDisabled();
                                }
                            }
                            let canNull=pageInfoMap.getObj('canNull#'+params.formCode)
                            if(jsonConfig.setSaveBefore!=undefined){
                                formComponent.setSaveBefore(jsonConfig.setSaveBefore);
                            }
                            formComponent.setSaveAfter( ()=> {
                                queryViewComponent.getTableObj().refresh();
                                khcModalForForm.hide();
                            })
                            if(canNull!=undefined){
                                for (let i = 0; i < canNull.length; i++) {
                                    eleMap.get(canNull[i]).data.can_null='Y';
                                    eleMap.get(canNull[i]).refreshCanNull();
                                }
                            }
                            formComponent.formEdit();//一些高级属性在新增时大部分是不需要设置所以隐藏，在编辑时再展示
                            formComponent.setButtonParams(jsonConfig.buttonParams);
                            khcModalForForm.show();
                        })
                    }
                }
                formComponent.renderThenFunc(content);
            });
        })
    }else{
        let formComponent=khcModalForForm.formComponent
        formComponent.renderThenFunc(content);
    }
}
functionMap.set('editOneByModal', editOneByModal);// 将函数添加到 Map 中
function addSelectTable(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let content = tableViewComponent.getContentMap().get(jsonConfig.pkCode.toString());
    if(tableViewComponent.selectTableDataArray==undefined){
        tableViewComponent.selectTableDataArray=[]
    }
    if(!tableViewComponent.selectTableDataArray.includes(content.id+'')){
        tableViewComponent.selectTableDataArray.push(content.id+'');
        tableViewComponent.getContentsFromServer().then(()=>{
            tableViewComponent.tUtil.getSelectTableBodyHtml().then((htmlTemplate)=>{
                document.getElementById(tableViewComponent.eleID+'_select').querySelector('tbody').innerHTML = htmlTemplate;
                tableViewComponent.tableButtonsView.renderSelectHtml();
                tableViewComponent.tableButtonsView.addSelectEventListener();
            })
        })

    }else{
        khcToastr.showWarningMessage('该记录已存在')
    }
}
functionMap.set('addSelectTable', addSelectTable);// 将函数添加到 Map 中
function removeSelectTable(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let content = tableViewComponent.getContentMap().get(jsonConfig.pkCode.toString());
    if(tableViewComponent.selectTableDataArray==undefined){
        tableViewComponent.selectTableDataArray=[]
    }
    if(tableViewComponent.selectTableDataArray.includes(content.id+'')){
        let newArray=util.removeArrayValue(tableViewComponent.selectTableDataArray,content.id+'');
        tableViewComponent.selectTableDataArray=newArray;
        tableViewComponent.getContentsFromServer().then(()=>{
            tableViewComponent.tUtil.getSelectTableBodyHtml().then((htmlTemplate)=>{
                document.getElementById(tableViewComponent.eleID+'_select').querySelector('tbody').innerHTML = htmlTemplate;
                tableViewComponent.tableButtonsView.renderSelectHtml();
                tableViewComponent.tableButtonsView.addSelectEventListener();
            })
        })
    }
}
functionMap.set('removeSelectTable', removeSelectTable);// 将函数添加到 Map 中
//详情
function showDetail() {
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    tableViewComponent.showDetail(jsonConfig.pkCode);
}
functionMap.set('showDetail', showDetail);// 将函数添加到 Map 中
function deleteOne() {
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let params = queryViewComponent.getCode();
    params=util.clone(params);
    params=util.mergeObject(jsonConfig.buttonParams,params)
    params.pkIds = [{ pkId: jsonConfig.pkCode }]
    khcAlert.showDelConfirm('', ()=> {
        let obj={url:config.getConfigJson().delUrl,params:params}
        return httpUtil.post(obj, (response)=>{
            Swal.fire(
                '已删除',
                '删除成功',
                'success'
            )
            tableViewComponent.refresh();
        })
    })
}
functionMap.set('deleteOne', deleteOne);// 将函数添加到 Map 中
function columnShowUpdate(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let tableDataMap = tableViewComponent.getContentMap();
    let upLoadParam = {};
    let params = {};
    let componentArray = fullMap.getObj(queryViewComponent.pageID).componentArray;
    for (let i = 0; i < componentArray.length; i++) {
        if (componentArray[i].type == 'form') {
            upLoadParam = componentArray[i].code;
        }
    }
    params.dsCode='ds_template';
    params.formCode='form_template_column_show_update';
    let khcModalForForm = new khcModal({ modalAreaID: config.getConfigJson().modalAreaID });
    khcModalForForm.render().then(() => {
        let formComponent = new form({ parentObjID: khcModalForForm.getEleID(), code: params ,pageID:queryViewComponent.pageID});
        formComponent.khcModalForForm=khcModalForForm;
        khcModalForForm.formObjID=formComponent.getObjID()
        let khcModalForFormKey='khcModalForForm#'+formComponent.getObjID();
        pageInfoMap.push(khcModalForFormKey,khcModalForForm);
        formComponent.setFormShowType('modals')
        //同理可以实现saveBefore
        formComponent.setSaveBefore( ()=> {
            let eleMap=formComponent.getFormMap();
            let columnShow=eleMap.get('column_show').getValue();
            let array = columnShow.split(',')
            let tableData=tableViewComponent.tableStructureData
            tableViewComponent.tableMinWidth=0;
            if (tableViewComponent.queryInfo.is_checkbox == 'Y') {
                tableViewComponent.tableMinWidth += 30+42;
            }
            if (tableViewComponent.queryInfo.is_managing=='Y') {
                tableViewComponent.tableMinWidth += 150+42;
            }
            tableData.forEach((value)=>{
                if(array.includes(value.name)){
                    value.data.list_load_is_render='Y';
                    tableViewComponent.tableMinWidth += value.data.width+42;
                }else if(value.data.is_list=='Y'&&value.data.list_load_is_render=='Y'){
                    value.data.list_load_is_render='N';
                }
            })
            if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
                khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
                return false;//返回false
            }
            tableViewComponent.updateTableMinWidth();
            queryViewComponent.getTableObj().refresh();
            khcModalForForm.hide();
            khcAlert.showSuccessMessage('配置成功（重新加载页面则重置）')
            return false;//返回false，后面保存代码块无需执行
        })
        formComponent.setRenderBefore(function (){
            formComponent=this;
            let formData=formComponent.formStructureData.formData;
            formData.forEach((value)=>{
                if(value.name=='column_show'){
                    value.data.dict_code=tableViewComponent.columnDictCode
                    value.data.default_value=tableViewComponent.listLoadRenderFieldArray.toString()
                }
            })
         })
        formComponent.render().then(() => {
            formComponent.formCreate();
            khcModalForForm.show();
        });
    })
}
functionMap.set('columnShowUpdate', columnShowUpdate);// 将函数添加到 Map 中
function saveAllData() {
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    let updateData = tableViewComponent.getTableEditData();
    if (updateData.length == 0) {
        khcAlert.showSuccessMessage('您没有更改任何数据，不做处理', 1500);
    } else {
        let componentArray = fullMap.getObj(queryViewComponent.pageID).componentArray;
        let params = tableViewComponent.code;
        for (let i = 0; i < componentArray.length; i++) {
            if (componentArray[i].type == 'form') {
                params = componentArray[i].code;
            }
        }
        params=util.clone(params);
        params=util.mergeObject(jsonConfig.buttonParams,params)
        params['saveData'] = updateData
        let obj={url:config.getConfigJson().saveUrl,params:params}
        return httpUtil.post(obj, (response)=>{
            khcAlert.showSuccessMessage('保存成功，共更新' + updateData.length + '条数据', 1200)
            tableViewComponent.refresh(true);//强制刷新
        })
    }


}
functionMap.set('saveAllData', saveAllData);// 将函数添加到 Map 中
//插入行
function insertOne() {
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let params = queryViewComponent.getCode();
    params=util.clone(params);
    params=util.mergeObject(jsonConfig.buttonParams,params)
    let saveDataOne={};
    if(pageInfoMap.getObj(queryViewComponent.code.queryCode)==undefined){
    }else{
        saveDataOne.page_parent_uuid=pageInfoMap.getObj(queryViewComponent.code.queryCode).page_parent_uuid;
    }
    params['saveData'] = [
        saveDataOne
    ]
    let obj={url:config.getConfigJson().insertOneUrl,params:params}
    return httpUtil.post(obj, (response)=>{
        tableViewComponent.refresh();
    })
}
functionMap.set('insertOne', insertOne);// 将函数添加到 Map 中
function deleteChecked() {
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    let ids = tableViewComponent.getCheckedDataPkCode();
    let params = queryViewComponent.getCode();
    params=util.clone(params);
    params=util.mergeObject(jsonConfig.buttonParams,params)
    params.pkIds = ids;
    if (ids.length == 0) {
        khcAlert.showWarningMessage('请勾选您要删除的数据！')
    } else {
        khcAlert.showDelConfirm({title:'是否删除选中的：'+ids.length+'条数据'}, () =>{
            let obj={url:config.getConfigJson().delUrl,params:params}
            return httpUtil.post(obj, (response)=>{
                Swal.fire(
                    '已删除',
                    '删除成功',
                    'success'
                )
                tableViewComponent.refresh();
            })
        })
    }


}
functionMap.set('deleteChecked', deleteChecked);// 将函数添加到 Map 中
function uploadExcelTemplate(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let params = queryViewComponent.code;
    let eleMap = queryViewComponent.getFormMap();
    params.fileArray=eleMap.get('upload_file').getValue()
    let obj={url:config.getConfigJson().importExcelDataNew,params:params}
    return httpUtil.post(obj, (response)=>{
        Swal.fire(
            '导入成功',
            response.data.data.importMessage,
            'success'
        )
    })
}
functionMap.set('uploadExcelTemplate', uploadExcelTemplate);// 将函数添加到 Map 中

/**
 * 行按钮，通过json配置执行简单操作
 * this
 * this['button_click_json_config']
 * this['button_click_json_config']['type'] 必填 （row1：编辑对话框，row2，编辑模态框，row3：对话框调API接口，rowToPage1：跳转页面 ，table1：checkedButton-适用于需要批量操作等场景）
 * this['button_click_json_config']['pageCode'] type==rowToPage1 则必填 （子表编码）
 * this['button_click_json_config']['title'] type==row1 or row3 or table1 则必填 （操作主题）
 * this['button_click_json_config']['alertTitle'] 选填 （自定义弹框内容）
 * this['button_click_json_config']['content'] type==row1 必填 （要更新的数据）
 * this['button_click_json_config']['methodName'] type==row3 必填 （调用接口标识方法）
 * this['button_click_json_config']['verifyArray'] type==table1 必填 （自定义一些校验配置，当符合条件时才允许通过，否则推出）
 */
function rowButtonClickFunc(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let pageComponent=fullMap.getObj(queryViewComponent.pageID);
    let tableViewComponent = queryViewComponent.getTableObj();
    let content = tableViewComponent.getContentMap().get(jsonConfig.pkCode.toString());
    let buttonJsonConfig=jsonConfig['button_click_json_config'];
    //row1，编辑对话框  row2，编辑模态框  row3，对话框调API接口  rowToPage1，跳转子表
    if(buttonJsonConfig['type']=='row1'){
        let alertData = {};
        alertData.title = `${!util.isNull(buttonJsonConfig['alertTitle'])?buttonJsonConfig['alertTitle']: `请确认是否${buttonJsonConfig['title']}`}`;
        alertData.preConfirm= async () => {
            return new Promise((resolve, reject) => {
                let params =queryViewComponent.getCode();
                let updateContent=buttonJsonConfig['content']
                for (let key in updateContent) {
                    content[key]=updateContent[key];
                }
                let formValueArray=[];
                formValueArray.push(content)
                params.saveData = formValueArray;
                let obj={url:config.getConfigJson().saveUrl,params:params}
                obj.errorCallback= (response)=>{
                    setTimeout(function (){
                        khcAlert.showSystemError(`${buttonJsonConfig['title']}失败`);
                        resolve(false);
                    },500)
                }
                httpUtil.post(obj,(response)=>{
                    setTimeout(function (){
                        Swal.fire(`${buttonJsonConfig['title']}成功`,'','success')
                        pageComponent.queryComponent.getTableObj().refresh();
                    },500)
                })
            });
        }
        khcAlert.showConfirm(alertData, ()=>{});
    }
    if(buttonJsonConfig['type']=='row2'){
        jsonConfig.paramsAfterFunc=function (params){
            params.formCode=buttonJsonConfig['formCode'];
            return util.clone(params);
        }
        let modalKey='';
        //jsonConfig['button_method']  是创建按钮命名唯一的（至于命名什么都可以，唯一就行）
        //buttonJsonConfig['button_method']  调用方法（居中模态框：editOneByModal，居右模态框：editOneByModalSlide）
        modalKey=jsonConfig['old_button_method']+buttonJsonConfig['button_method'];
        jsonConfig.getKhcModalForFormAfterFunc=function (pageComponent){
            return pageComponent[modalKey]
        }
        jsonConfig.setKhcModalForFormAfterFunc=function (pageComponent,khcModalForForm){
            pageComponent[modalKey]=khcModalForForm;
        }
        jsonConfig['button_method']=buttonJsonConfig['button_method'];
        util.import2023(config.getConfigJson().tableActionPath,jsonConfig);
    }
    if(buttonJsonConfig['type']=='row3'){
        let alertData = {};
        alertData.title = `${!util.isNull(buttonJsonConfig['alertTitle'])?buttonJsonConfig['alertTitle']: `请确认是否${buttonJsonConfig['title']}`}`;
        alertData.preConfirm= async () => {
            return new Promise((resolve, reject) => {
                let isWS=buttonJsonConfig['isWS']
                if(!util.isNull(isWS)&&isWS=='Y'){
                    fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,function (data){
                        if(data.status=="ok"){
                            if(data.isHideMask=="Y"){
                                Swal.fire(buttonJsonConfig['title']+'成功', data.message,'success' )
                                fullMap.getObj('mask').hide();
                                queryViewComponent.runSaveAfter()//todo 这怎么是query组件的函数，有问题，需要排查是不是写错了~
                                if(!util.isNull(isWS)&&isWS=='Y')fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,null);//重置ws监听
                            }else{
                                fullMap.getObj('mask').showNewText(data.message)
                            }
                        }else{
                            let alertData={title:data.message,text:'标识码：' + data.status}
                            khcAlert.showSystemError(alertData);
                            fullMap.getObj('mask').hide();
                        }
                    })
                }
                let dsCode=buttonJsonConfig['dsCode'];
                let params;
                if(util.isNull(dsCode)){
                    params =util.clone(queryViewComponent.getCode());
                }else{
                    params={'dsCode':dsCode}
                }
                params.uuid = content['uuid'];
                params.uuids = content['uuid'];
                params.methodName=buttonJsonConfig['methodName'];
                let requestFields=buttonJsonConfig['request_fields'];
                if(requestFields!=undefined&&requestFields.length>0){
                    for (let i = 0; i < requestFields.length; i++) {
                        let fieldName=requestFields[i]['field_name'];
                        params[fieldName] = content[fieldName];
                    }
                }
                let obj={url:config.getConfigJson().myActionUrl,params:params}
                obj.errorCallback= (response)=>{
                    setTimeout(function (){
                        khcAlert.showSystemError(`${buttonJsonConfig['title']}失败`);
                        resolve(false);
                    },500)
                }
                fullMap.getObj('mask').show(`${buttonJsonConfig['title']}中...`)
                httpUtil.post(obj,(response)=>{
                    setTimeout(function (){
                        if(util.isNull(isWS)||isWS=='N'){
                            fullMap.getObj('mask').hide();
                            Swal.fire(`${buttonJsonConfig['title']}成功`,'','success')
                            pageComponent.queryComponent.getTableObj().refresh();
                        }
                    },500)
                })
            });
        }
        khcAlert.showConfirm(alertData, ()=>{});
    }
    if(buttonJsonConfig['type']=='row4'){
        let pageKey=`${jsonConfig['old_button_method']}Page`;
        let searchFunc=function (){
            let searchFieldArray=buttonJsonConfig['searchFieldArray']
            for (let i = 0; i < searchFieldArray.length; i++) {
                let searchFieldJson=searchFieldArray[i];
                let childFieldName=searchFieldJson['childFieldName'];
                if(childFieldName=='page_parent_uuid'){
                    let queryCode=tableViewComponent[pageKey].queryComponent.tableView.code.queryCode
                    let mys={'page_parent_uuid':content[searchFieldJson['fieldName']]}
                    pageInfoMap.push(queryCode,mys)
                    continue;
                }
                let childFieldNameObj=tableViewComponent[pageKey].queryComponent.queryMap.get(searchFieldJson['childFieldName']);
                if(childFieldNameObj==undefined){
                    khcToastr.showErrorMessage('请检查子表是否对：'+searchFieldJson['childFieldName']+'  字段设置为查询项')
                    return
                }else{
                    childFieldNameObj.setValue(content[searchFieldJson['fieldName']]);
                }
            }
            tableViewComponent[pageKey]['searchFieldArray']=searchFieldArray;//将使用的关联字段传给子表，子表在新增时需set进表单里
            tableViewComponent[pageKey].queryComponent.tableView.refresh();
            tableViewComponent[pageKey].queryComponent['parentRow4Page']=pageComponent;
            util.toTops({id:tableViewComponent[pageKey].queryComponent.tableView.eleID,isFocus:false})
        }
        if(tableViewComponent[pageKey]==undefined){
            fullMap.getObj('mask').show('渲染中...')
            let parentObjID =pageComponent.parentObjID;
            let pageData = { parentObjID: parentObjID,pageType:'ordinary' };
            let code={ version: '1.0.0', dsCode: buttonJsonConfig['dsCode'],
                formCode: buttonJsonConfig['formCode'],queryCode: buttonJsonConfig['queryCode'],col: 12};
            let formCode = { parentObjID: util.getUUID() + 'div', type: 'form', code: code }
            let queryCode = { parentObjID: util.getUUID() + 'div', type: 'query', code: code };
            pageData['componentName']=''
            pageData['pageCode'] = '';
            pageData['formCode'] = formCode;
            pageData['queryCode'] = queryCode;
            pageData['parentContent'] = content;
            let thisFormPage = new page(pageData);
            thisFormPage.render();
            tableViewComponent[pageKey]=thisFormPage
            fullMap.push(thisFormPage.objID, thisFormPage);
            setTimeout(function (){
                searchFunc()
                fullMap.getObj('mask').hide();
            },1000)//首次渲染需要延迟调用搜索
        }else{
            tableViewComponent[pageKey].setParentContent(content);
            let tableEleID=tableViewComponent[pageKey].queryComponent.tableView.eleID
            fullMap.getObj('mask').showByElement(tableEleID,1000);//添加局部遮罩(table),体现页面数据更新
            searchFunc();
        }
    }
    if(buttonJsonConfig['type']=='row5'){
        let pageKey=`${jsonConfig['old_button_method']}Page`;
        let modalKey=`${jsonConfig['old_button_method']}Modal`;
        let khcModalForForm = tableViewComponent[modalKey]
        if(khcModalForForm==null){
            khcModalForForm = new khcModalSlide({ modalAreaID: config.getConfigJson().modalAreaID });
            tableViewComponent[modalKey]=khcModalForForm;
        }
        if(util.isNull(buttonJsonConfig['modalShowLR'])){
            khcModalForForm.modalShowLR='left'
        }else{
            khcModalForForm.modalShowLR=buttonJsonConfig['modalShowLR']
        }
        khcModalForForm.render().then(() => {
            if(tableViewComponent[pageKey]==undefined){
                fullMap.getObj('mask').show('渲染中...')
                let parentObjID =khcModalForForm.getEleID();
                let pageData = { parentObjID: parentObjID,pageType:'ordinary' };
                let code={ version: '1.0.0', dsCode: buttonJsonConfig['dsCode'],
                    formCode: buttonJsonConfig['formCode'],queryCode: buttonJsonConfig['queryCode'],col: 12};
                let formCode = { parentObjID: util.getUUID() + 'div', type: 'form', code: code }
                let queryCode = { parentObjID: util.getUUID() + 'div', type: 'query', code: code };
                pageData['componentName']=''
                pageData['pageCode'] = '';
                pageData['formCode'] = formCode;
                pageData['queryCode'] = queryCode;
                pageData['parentContent'] = content;
                let thisFormPage = new page(pageData);
                thisFormPage.render();
                tableViewComponent[pageKey]=thisFormPage
                fullMap.push(thisFormPage.objID, thisFormPage);
                setTimeout(function (){
                    searchFunc()
                    fullMap.getObj('mask').hide();
                },1000)//首次渲染需要延迟调用搜索
            }else{
                tableViewComponent[pageKey].setParentContent(content);
                let tableEleID=tableViewComponent[pageKey].queryComponent.tableView.eleID
                fullMap.getObj('mask').showByElement(tableEleID,1000);//添加局部遮罩(table),体现页面数据更新
                searchFunc();
            }
            khcModalForForm.show();
        })
        let searchFunc=function (){
            let searchFieldArray=buttonJsonConfig['searchFieldArray']
            for (let i = 0; i < searchFieldArray.length; i++) {
                let searchFieldJson=searchFieldArray[i];
                let childFieldName=searchFieldJson['childFieldName'];
                if(childFieldName=='page_parent_uuid'){
                    let queryCode=tableViewComponent[pageKey].queryComponent.tableView.code.queryCode
                    let mys={'page_parent_uuid':content[searchFieldJson['fieldName']]}
                    pageInfoMap.push(queryCode,mys)
                    continue;
                }
                let childFieldNameObj=tableViewComponent[pageKey].queryComponent.queryMap.get(searchFieldJson['childFieldName']);
                if(childFieldNameObj==undefined){
                    khcToastr.showErrorMessage('请检查子表是否对：'+searchFieldJson['childFieldName']+'  字段设置为查询项')
                    return
                }else{
                    childFieldNameObj.setValue(content[searchFieldJson['fieldName']]);
                }
            }
            tableViewComponent[pageKey]['searchFieldArray']=searchFieldArray;//将使用的关联字段传给子表，子表在新增时需set进表单里
            tableViewComponent[pageKey].queryComponent.tableView.refresh();
            tableViewComponent[pageKey].queryComponent['parentRow5Page']=pageComponent;
            util.toTops({id:tableViewComponent[pageKey].queryComponent.tableView.eleID,isFocus:false})
        }
    }
    if(buttonJsonConfig['type']=='row6'){
        let data = khcBootBox.getCustomDefaultData()
        data.title = `${!util.isNull(buttonJsonConfig['alertTitle'])?buttonJsonConfig['alertTitle']: `请确认是否${buttonJsonConfig['title']}`}`;
        data.message = `
            <form id="radioForm">
                <input class="bootbox-input bootbox-input-text form-control" id="${jsonConfig.objID}_khc_message" autocomplete="off" type="text" placeholder="请输入${buttonJsonConfig['khc_message_placeholder']}">
            </form>`
        data.buttons.success = {
            label: '确定',
            className: 'btn-primary',
            callback: function () {
                let khcMessage = document.getElementById(`${jsonConfig.objID}_khc_message`).value
                if(util.isNull(khcMessage)){
                    khcToastr.showWarningMessage(`请填写${buttonJsonConfig['khc_message_placeholder']}`)
                    return false;
                }
                let isWS=buttonJsonConfig['isWS']
                if(!util.isNull(isWS)&&isWS=='Y'){
                    fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,function (data){
                        if(data.status=="ok"){
                            if(data.isHideMask=="Y"){
                                Swal.fire(buttonJsonConfig['title']+'成功', data.message,'success' )
                                fullMap.getObj('mask').hide();
                                queryViewComponent.runSaveAfter()//todo 这怎么是query组件的函数，有问题，需要排查是不是写错了~
                                if(!util.isNull(isWS)&&isWS=='Y')fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,null);//重置ws监听
                            }else{
                                fullMap.getObj('mask').showNewText(data.message)
                            }
                        }else{
                            let alertData={title:data.message,text:'标识码：' + data.status}
                            khcAlert.showSystemError(alertData);
                            fullMap.getObj('mask').hide();
                        }
                    })
                }
                let dsCode=buttonJsonConfig['dsCode'];
                let params;
                if(util.isNull(dsCode)){
                    params =util.clone(queryViewComponent.getCode());
                }else{
                    params={'dsCode':dsCode}
                }
                params.uuid = content['uuid'];
                params.uuids = content['uuid'];
                params.khc_message = khcMessage;
                params.methodName=buttonJsonConfig['methodName'];
                let requestFields=buttonJsonConfig['request_fields'];
                if(requestFields!=undefined&&requestFields.length>0){
                    for (let i = 0; i < requestFields.length; i++) {
                        let fieldName=requestFields[i]['field_name'];
                        params[fieldName] = content[fieldName];
                    }
                }
                let obj={url:config.getConfigJson().myActionUrl,params:params}
                obj.errorCallback= (response)=>{
                    setTimeout(function (){
                        khcAlert.showSystemError(`${buttonJsonConfig['title']}失败`);
                        resolve(false);
                    },500)
                }
                fullMap.getObj('mask').show(`${buttonJsonConfig['title']}中...`)
                httpUtil.post(obj,(response)=>{
                    setTimeout(function (){
                        if(util.isNull(isWS)||isWS=='N'){
                            fullMap.getObj('mask').hide();
                            Swal.fire(`${buttonJsonConfig['title']}成功`,'','success')
                            pageComponent.queryComponent.getTableObj().refresh();
                        }
                    },500)
                })
            }
        }
        data.buttons.danger = {
            label: '取消',
            className: 'btn-default',
            callback: function () {
                // alert('great danger')
            }
        }
        khcBootBox.showCustom(data)
    }
    if(buttonJsonConfig['type']=='rowToPage1'){
        let queryInfo={};
        let idFieldName='';
        if(util.isNull(buttonJsonConfig['idFieldName'])){
            idFieldName='uuid';
        }else{
            idFieldName=buttonJsonConfig['idFieldName']
        }
        let pIdFieldName='';
        if(util.isNull(buttonJsonConfig['pIdFieldName'])){
            pIdFieldName='page_parent_uuid';
        }else{
            pIdFieldName=buttonJsonConfig['pIdFieldName']
        }
        queryInfo[pIdFieldName]=content[idFieldName]
        let pageCode=buttonJsonConfig['pageCode'];
        let url=config.getIndexUrl()+'?pageCode='+pageCode+'&queryInfo='+encodeURIComponent(JSON.stringify(queryInfo))
        window.open(url);
    }
}
functionMap.set('rowButtonClickFunc', rowButtonClickFunc);// 将函数添加到 Map 中

/**
 * table按钮，通过json配置执行简单操作
 * this
 * this['button_click_json_config']
 * this['button_click_json_config']['type'] 必填 （table1：checkedButton-适用于需要批量操作等场景）（table2：适用于初始化等场景，不需要选中数据）
 * this['button_click_json_config']['title'] type==table1 OR table2 则必填 （操作主题）
 * this['button_click_json_config']['verifyArray'] type==table1 必填 （自定义一些校验配置，当符合条件时才允许通过，否则推出）
 * this['button_click_json_config']['methodName'] type==table1 OR table2 必填 （调用方法）
 */
function tableButtonClickFunc(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let pageComponent=fullMap.getObj(queryViewComponent.pageID);
    let tableViewComponent = queryViewComponent.getTableObj();
    let buttonJsonConfig=jsonConfig['button_click_json_config'];
    //row1，编辑对话框  row2，编辑模态框  row3，对话框调API接口  rowToPage1，跳转子表
    if(buttonJsonConfig['type']=='table1'){
        let jsonConfig=this;
        let queryViewComponent = fullMap.getObj(jsonConfig.objID);
        let tableViewComponent = queryViewComponent.getTableObj();
        if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
            khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
            return false;//返回false
        }
        let requestFields=buttonJsonConfig['request_fields'];
        if(requestFields!=undefined&&requestFields.length>0){
            for (let i = 0; i < requestFields.length; i++) {
                let fieldName=requestFields[i]['field_name'];
                params[fieldName] = tableViewComponent.getCheckedDataByFieldName(fieldName);
            }
        }
        let ids = tableViewComponent.getCheckedDataPkCode();
        let uuids = tableViewComponent.getCheckedDataUUID();
        let params = queryViewComponent.getCode();
        params=util.clone(params);
        params=util.mergeObject(jsonConfig.buttonParams,params)
        let checkDataAll = tableViewComponent.getCheckedDataAll();
        params.pkIds = ids;
        params.uuids = uuids;
        params.checkDataAll = checkDataAll;
        params.methodName=buttonJsonConfig['methodName'];
        let isWS=buttonJsonConfig['isWS']
        if (ids.length == 0) {
            khcAlert.showWarningMessage(`请勾选您要${buttonJsonConfig['title']}的数据！`)
            if(!util.isNull(isWS)&&isWS=='Y')fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,null);//重置ws监听
        } else {
            let verifyArray=buttonJsonConfig['verifyArray']
            if(!util.isNull(verifyArray)){
                for (let i = 0; i < ids.length; i++) {
                    let content = tableViewComponent.getContentMap().get(ids[i]['pkId'].toString());
                    for (let j = 0; j < verifyArray.length; j++) {
                        if(content[verifyArray[j]['filed_name']]==verifyArray[j]['value']){
                            khcAlert.showWarningMessage(verifyArray[j]['message'])
                            if(!util.isNull(isWS)&&isWS=='Y')fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,null);//重置ws监听
                            return
                        }
                    }
                }
            }
            khcAlert.showConfirm({title:`是否${buttonJsonConfig['title']}选中的：${ids.length}条数据`}, () =>{
                fullMap.getObj('mask').show(`${buttonJsonConfig['title']}中...`)
                if(!util.isNull(isWS)&&isWS=='Y'){
                    fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,function (data){
                        if(data.status=="ok"){
                            if(data.isHideMask=="Y"){
                                Swal.fire(buttonJsonConfig['title']+'成功', data.message,'success' )
                                fullMap.getObj('mask').hide();
                                queryViewComponent.runSaveAfter()
                                if(!util.isNull(isWS)&&isWS=='Y')fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,null);//重置ws监听
                            }else{
                                fullMap.getObj('mask').showNewText(data.message)
                            }
                        }else{
                            let alertData={title:data.message,text:'标识码：' + data.status}
                            khcAlert.showSystemError(alertData);
                            fullMap.getObj('mask').hide();
                        }
                    })
                }
                let obj={url:config.getConfigJson().myActionUrl,params:params}
                return httpUtil.post(obj, (response)=>{
                    fullMap.getObj('mask').hide()
                    if(isWS!='Y'){
                        Swal.fire(`${buttonJsonConfig['title']}`,`${buttonJsonConfig['title']}成功`,'success')
                    }
                    tableViewComponent.refresh();
                })
            })
        }
    }
    if(buttonJsonConfig['type']=='table2'){
        if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
            khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
            return false;//返回false
        }
        let params = queryViewComponent.getCode();
        params=util.clone(params);
        params=util.mergeObject(jsonConfig.buttonParams,params)
        params.methodName=buttonJsonConfig['methodName'];
        let isWS=buttonJsonConfig['isWS']
        khcAlert.showConfirm({title:`请确认是否${buttonJsonConfig['title']}`}, () =>{
            fullMap.getObj('mask').show(`${buttonJsonConfig['title']}中...`)
            if(!util.isNull(isWS)&&isWS=='Y'){
                fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,function (data){
                    if(data.status=="ok"){
                        if(data.isHideMask=="Y"){
                            Swal.fire(buttonJsonConfig['title']+'成功', data.message,'success' )
                            fullMap.getObj('mask').hide();
                            queryViewComponent.runSaveAfter()
                            if(!util.isNull(isWS)&&isWS=='Y')fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,null);//重置ws监听
                        }else{
                            fullMap.getObj('mask').showNewText(data.message)
                        }
                    }else{
                        let alertData={title:data.message,text:'标识码：' + data.status}
                        khcAlert.showSystemError(alertData);
                        fullMap.getObj('mask').hide();
                    }
                })
            }
            let obj={url:config.getConfigJson().myActionUrl,params:params}
            return httpUtil.post(obj, (response)=>{
                fullMap.getObj('mask').hide()
                if(isWS!='Y'){
                    Swal.fire(`${buttonJsonConfig['title']}`,`${buttonJsonConfig['title']}成功`,'success')
                }
                tableViewComponent.refresh();
            })
        })
    }
    if(buttonJsonConfig['type']=='table3'){
        let jsonConfig=this;
        let queryViewComponent = fullMap.getObj(jsonConfig.objID);
        let tableViewComponent = queryViewComponent.getTableObj();
        if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
            khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
            return false;//返回false
        }
        let ids = tableViewComponent.getCheckedDataPkCode();
        let params = queryViewComponent.getCode();
        params=util.clone(params);
        params=util.mergeObject(jsonConfig.buttonParams,params)
        params.pkIds = ids;
        let isWS=buttonJsonConfig['isWS']
        if (ids.length == 0) {
            khcAlert.showWarningMessage(`请勾选您要${buttonJsonConfig['title']}的数据！`)
            if(!util.isNull(isWS)&&isWS=='Y')fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,null);//重置ws监听
        } else {
            let verifyArray=buttonJsonConfig['verifyArray']
            if(!util.isNull(verifyArray)){
                for (let i = 0; i < ids.length; i++) {
                    let content = tableViewComponent.getContentMap().get(ids[i]['pkId'].toString());
                    for (let j = 0; j < verifyArray.length; j++) {
                        if(content[verifyArray[j]['filed_name']]==verifyArray[j]['value']){
                            khcAlert.showWarningMessage(verifyArray[j]['message'])
                            if(!util.isNull(isWS)&&isWS=='Y')fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,null);//重置ws监听
                            return
                        }
                    }
                }
            }
            khcAlert.showConfirm({title:`是否${buttonJsonConfig['title']}选中的：${ids.length}条数据`}, () =>{
                fullMap.getObj('mask').show(`${buttonJsonConfig['title']}中...`)
                if(!util.isNull(isWS)&&isWS=='Y'){
                    fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,function (data){
                        if(data.status=="ok"){
                            if(data.isHideMask=="Y"){
                                Swal.fire(buttonJsonConfig['title']+'成功', data.message,'success' )
                                fullMap.getObj('mask').hide();
                                queryViewComponent.runSaveAfter()
                                if(!util.isNull(isWS)&&isWS=='Y')fullMap.getObj('ws').khcWSFuncMap.set(queryViewComponent.code.queryCode,null);//重置ws监听
                            }else{
                                fullMap.getObj('mask').showNewText(data.message)
                            }
                        }else{
                            let alertData={title:data.message,text:'标识码：' + data.status}
                            khcAlert.showSystemError(alertData);
                            fullMap.getObj('mask').hide();
                        }
                    })
                }
                let updateData =[]
                for (let i = 0; i < ids.length; i++) {
                    let content = tableViewComponent.getContentMap().get(ids[i]['pkId'].toString());
                    console.log(buttonJsonConfig['content'])
                    content=util.mergeObject(content,buttonJsonConfig['content']);
                    console.log(content)
                    updateData.push(content)
                }
                params['saveData'] = updateData
                let obj={url:config.getConfigJson().saveUrl,params:params}
                return httpUtil.post(obj, (response)=>{
                    fullMap.getObj('mask').hide()
                    if(isWS!='Y'){
                        Swal.fire(`${buttonJsonConfig['title']}`,`${buttonJsonConfig['title']}成功`,'success')
                    }
                    tableViewComponent.refresh();
                })
            })
        }
    }
    if(buttonJsonConfig['type']=='table4'){
        jsonConfig.paramsAfterFunc=function (params){
            let dsCode=buttonJsonConfig['dsCode'];
            if(!util.isNull(dsCode)){
                params={dsCode:dsCode,queryCode:buttonJsonConfig['queryCode']}
            }
            params.formCode=buttonJsonConfig['formCode'];
            return util.clone(params);
        }
        let modalKey='';
        //jsonConfig['button_method']  是创建按钮命名唯一的（至于命名什么都可以，唯一就行）
        //buttonJsonConfig['button_method']  调用方法（居中模态框：createOneByModal，居右模态框：createOneByModalSlide）
        modalKey=jsonConfig['old_button_method']+buttonJsonConfig['button_method'];
        jsonConfig.getKhcModalForFormAfterFunc=function (pageComponent){
            return pageComponent[modalKey]
        }
        jsonConfig.setKhcModalForFormAfterFunc=function (pageComponent,khcModalForForm){
            pageComponent[modalKey]=khcModalForForm;
        }
        jsonConfig['button_method']=buttonJsonConfig['button_method'];
        util.import2023(config.getConfigJson().tableActionPath,jsonConfig);
    }
}
functionMap.set('tableButtonClickFunc', tableButtonClickFunc);// 将函数添加到 Map 中
function columnShowUpdateSelect(){
    let jsonConfig=this;
    let queryViewComponent = fullMap.getObj(jsonConfig.objID);
    let tableViewComponent = queryViewComponent.getTableObj();
    if((tableViewComponent.tUtil!=null&&tableViewComponent.isEditTableData())){
        khcAlert.showWarningMessage('检测到当前表格数据有改动，请先保存当前页数据')
        return false;//返回false
    }
    if(!jsonConfig['buttonParams']['renderTrigger']){
        return
    }
    let buttonObjID=`${tableViewComponent.getEleID()+jsonConfig['buttonParams']['buttonUuid']}`;
    let multiSelect=document.getElementById(`${buttonObjID}bs-multiselect`);
    if(multiSelect==undefined){//首次渲染初始化
        let eleButton=document.getElementById(buttonObjID)
        let columnArray=tableViewComponent.columnDictCode.data;
        let tableManagingName=config.getConfigJson().tableManagingName;
        tableManagingName=`${tableViewComponent.queryInfo['table_managing_name']?tableViewComponent.queryInfo['table_managing_name']:tableManagingName}`
        let isManaging=tableViewComponent.queryInfo.is_managing
        let managingShowType=tableViewComponent.queryInfo.managing_show_type;
        let optionHtml=``;
        if(isManaging=='Y'&&(util.isNull(managingShowType)||managingShowType=='first_show')){
            optionHtml+=`<option value="khc_is_managing" selected>${tableManagingName}</option>`
        }
        for (let i = 0; i < columnArray.length; i++) {
            let columnData=columnArray[i]
            optionHtml+=`<option value="${columnData['key']}" ${tableViewComponent.listLoadRenderFieldArray.includes(columnData['key'])?'selected':''}>${columnData['value']}</option>`
        }
        if(isManaging=='Y'&&managingShowType=='last_show'){
            optionHtml+=`<option value="khc_is_managing" selected>${tableManagingName}</option>`
        }
        let selectHtml=`<select id="${buttonObjID}bs-multiselect" multiple="" style="display: none;">${optionHtml}</select>`
        eleButton.insertAdjacentHTML('afterend', selectHtml);
        $(`#${buttonObjID}bs-multiselect`).multiselect({
            includeSelectAllOption: true,//全选
            nonSelectedText: '全部',//没有值的时候button显示值
            nSelectedText: '个被选中',//有n个值的时候显示n个被选中
            allSelectedText: '全选',//所有被选中的时候 全选（n）
            selectAllText: '全选',
            buttonContainer: '<div>',
            onChange: function (option, checked) {//change事件改变
                console.log($(`#${buttonObjID}bs-multiselect`).val())
                let array=$(`#${buttonObjID}bs-multiselect`).val()
                if(isManaging=='Y'){
                    if(array.includes('khc_is_managing')){
                        tableViewComponent.queryInfo.is_managing='Y'
                    }else{
                        tableViewComponent.queryInfo.is_managing='N'
                    }
                }
                let tableData=tableViewComponent.tableStructureData
                tableData.forEach((value)=>{
                    if(array.includes(value.name)){
                        value.data.list_load_is_render='Y';
                        tableViewComponent.tableMinWidth += value.data.width+42;
                    }else if(value.data.is_list=='Y'&&value.data.list_load_is_render=='Y'){
                        value.data.list_load_is_render='N';
                    }
                })
                document.getElementById(tableViewComponent.eleID).querySelector('thead').innerHTML = tableViewComponent.getTableHeaderHtml();
                tableViewComponent.tUtil.getTableBodyHtml().then((htmlTemplate)=>{
                    document.getElementById(tableViewComponent.eleID).querySelector('tbody').innerHTML = htmlTemplate;
                    $('[data-toggle="tooltip"]').tooltip();//tooltip 插件
                    $('[data-toggle="popover"]').popover({html:true});//popover 弹出框组件
                    tableViewComponent.renderRowButton();
                })
            },
            templates: {
                //button: '<span type="button" class="multiselect dropdown-toggle" data-toggle="dropdown" style="text-align:center;background-color: #ffffff;border: 1px solid #e5e5e5;"><span class="multiselect-selected-text" style="display: none"></span><span class="">筛选列</span></span>',
                //button: '<button type="button" class="btn icon-btn btn-sm btn-outline-primary" data-toggle="dropdown"><span class="far fa-paper-plane"></span></button>',
                button: '<button type="button" class="btn btn-outline-primary" data-toggle="dropdown" title="列配置" style="display: none"><span class="fas fa-tasks"></span></button>',
            }
        });
        eleButton.setAttribute('data-toggle','dropdown')
    }
}
functionMap.set('columnShowUpdateSelect', columnShowUpdateSelect);// 将函数添加到 Map 中