import { ElMessage } from "element-plus";
const setParams = (res, { id, class_id }) => {
    let params = {
        class_id,
        metric_name: res.name,
        expr: res.indicator_expression,
        alert_range: res.warningScopeRows.map((e) => {
            return {
                variable_name: e.key,
                metric_name: e.indicator_scope,
                metric_label: e.indicator_tag,
                chinese_name: e.cname,
                is_required: e.is_required == 1,
                is_linked: e.is_linkage == 1,
            };
        }) || [],
        duration: res.time,
        duration_unit: res.unit,
        check_period: res.inspection_cycle,
        is_enabled: res.state,
        alert_rule_type: res.rule_type,
    }
    if (id) {
        params.id = id
    }
    return params;
}
export const URL = "https://so.wodcloud.co/v1/api/metric_config"
export const Save = (res, p) => {
    let params = setParams(res, p);
    console.log("params: ", params);
    // axios[id ? 'put' : 'post'](URL, params).then(res => {
    //     if(res.data.code == 200){
    //         console.log('success');
    //     }else{
    //         ElMessage.error(res.data.data)
    //     }
    // })
}