import request from '@/utils/request';


/**
 * 获取指标列表
 */
export async function targetDefinitionPage(data) {
    const res = await request.post(`/eom/target_definition/page `, data);
    if (res.data.code == 0) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
}

/**
 * 保存修改指标
 */
export async function targetDefinitionSave(data) {
    const res = await request.post(`/eom/target_definition/` +( data.id ? 'update' : 'save'), data);
    if (res.data.code == 0) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
}

// 删除指标
export async function targetDefinitionDel(data) {
    const res = await request.delete(`/eom/target_definition/delete`, {data});
    if (res.data.code == 0) {
        return res.data;
    }
    return Promise.reject(new Error(res.data.message));
}

/**
 * 获取目标列表
 */
 export async function salesTargetPage(data) {
    const res = await request.post(`/eom/sales_target/page`, data);
    if (res.data.code == 0) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
}

/**
 * 保存修改目标
 */
 export async function salesTargetSave(data) {
    const res = await request.post(`/eom/sales_target/` +( data.id ? 'update' : 'save'), data);
    if (res.data.code == 0) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
}
// 删除指标
export async function settlementAccountRemoveAPI(data) {
    const res = await request.delete(`/eom/sales_target/delete`, {data});
    if (res.data.code == 0) {
        return res.data;
    }
    return Promise.reject(new Error(res.data.message));
}

// 获取详情
export async function getById(id) {
    const res = await request.get(`/eom/sales_target/getById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  }