"use strict";
import { khcAlert } from '../../../component/alert/khcAlert.js'
import { fullMap } from '../../../fullMap.js';
import {config} from "../../../config.js";
import { util } from "../../../util/util.js";
import {httpUtil} from "../../../util/httpUtil.js";
import {khcToastr} from "../../../component/alert/khcToastr.js";
import {pageInfoMap} from "../../../pageInfoMap.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 updateNotifyStatus() {
    let jsonConfig=this;
    let formComponent = fullMap.getObj(jsonConfig.objID);
    let content = formComponent.getFormValue();
    let data = {};
    data['title'] = '是否修改状态为已读';
    data['confirmButtonColor'] = '#3085d6';
    data['cancelButtonColor'] = '#181C21E6';
    khcAlert.showConfirm(data, ()=>{
        let code = formComponent.code;
        let formCode = code.formCode;
        let dsCode = code.dsCode;
        let version = code.version;
        let formValueArray=[];
        content.is_read='Y';//将状态N改为Y：未读 改成 已读
        formValueArray.push(content)
        let params = { "version": version, "dsCode": dsCode, "formCode": formCode, "saveData": formValueArray }
        let obj={url:config.getConfigJson().saveUrl,params:params}
        return httpUtil.post(obj, (response)=>{
            Swal.fire(
                '操作成功',
                '',
                'success'
            )
            let khcModalForFormKey='khcModalForForm#'+formComponent.getObjID();
            let khcModalForForm=pageInfoMap.getObj(khcModalForFormKey);
            khcModalForForm.hide();
            util.import2023('../component/header/icon/iconAction.js',formComponent.initSystemNotifyJsonConfig);
        })
    });
}
functionMap.set('updateNotifyStatus', updateNotifyStatus);// 将函数添加到 Map 中