"use strict";
import { fullMap } from '../../../fullMap.js';
import { khcAlert } from '../../../component/alert/khcAlert.js'
import { form } from '../../../component/page/form/form.js';
import { util } from '../../../util/util.js'
import { khcModal } from '../../../component/alert/khcModal.js'

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 menuTableRenderAfter(){
    let jsonConfig=this;
    let table=fullMap.getObj(jsonConfig.objID);
    let trObjArray = document.getElementById(table.eleID).querySelector('tbody').querySelectorAll('tr');
    for (let trObj of trObjArray) {
        let tdArray = trObj.querySelectorAll('td');
        for (let tdObj of tdArray) {
            if (tdObj.getAttribute('eleName') == 'menu_icon') {
                let iconHtml='<i class="'+util.toOldChar(tdObj.innerHTML)+'"></i>';
                tdObj.innerHTML=iconHtml;
                tdObj.style.fontSize='18px'
            }else if (tdObj.getAttribute('eleName') == 'menu_page') {
                let page=util.toOldChar(tdObj.innerHTML).split(' ')[0];
                tdObj.onclick= ()=>{
                    window.location.href='#'+page;
                }
                let iconHtml='<span style="cursor:pointer;">'+util.toOldChar(tdObj.innerHTML)+'</span>';
                tdObj.innerHTML=iconHtml;
            }
        }
    }
}
functionMap.set('menuTableRenderAfter', menuTableRenderAfter);// 将函数添加到 Map 中