import { http } from '@/common/utils/request'
export const get_options_sys = async (data:any ,sys:string) => 
    http.get(`/${sys}/storeds`, data)
// 获取弹出窗数据通用接口 
export const get_dialogName = ({ type, key, value, label, system='sec',  code_type, field_id, udf_param_json }:any) => {
    let sys = system;
    if(type.indexOf('.')>0){
        sys = type.split('.')[0]
        type = type.split('.')[1]
    }
    let params = {
        "[ProcedureName]": `pw_${sys}_dialog_name_query`,
        dialog_field: key,
        field_value: value,
        field_label: label,
        code_type: code_type,
        field_id,
        udf_param_json,
    };
    return get_options_sys(params, sys)
}
export const setMappings_dialog = (data:any, control:any) => {
    let Mappings = control.dialog.mappings
    if(!Mappings) return 
    let options = control.dialog.activeOption 
    if(!options) return  // 行数据在
    if(options instanceof Array) return  // 如果多选 return
    for(let item of Mappings){
        let target = item['param'] || item['control']
        if(options[target] != null && options[target] != undefined){
            data[item['control']] = options[target]
        }
    }
}

export const dialogData = {
    
}
