const URL = "/one-api/v1/report-v9/main/";
const dUrl = "/one-api/v1/report-v9/lookup/dropdown/";
const aUrl = "/one-api/v1/report-v9/lookup/ac/";

export async function list(search) {
   try {
      var resp = await axios.post(URL + 'list',{token: window.one_token(), search});
      if (resp.status != 200) {
         return {
            status: "ERR",
            message: resp.statusText
         };
      }
      let data = resp;
      return data;
   } catch(e) {
      return {
         status: "ERR",
         message: e.message
      };
   }
}
export async function lookupparam(prm) {
    try {
       var resp = await axios.post(URL + 'lookupparam',prm);
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
 }
export async function detail(id) {
   try {
      var resp = await axios.post(URL + 'detail',{id:id,token: window.one_token()});
      if (resp.status != 200) {
         return {
            status: "ERR",
            message: resp.statusText
         };
      }
      let data = resp;
      return data;
   } catch(e) {
      return {
         status: "ERR",
         message: e.message
      };
   }
}
 export async function listdropdown(sp) {
    try {
       var resp = await axios.post(dUrl + sp);
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp.data;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
 }
 export async function listautocomplete(prm) {
    try {
        var sp = prm.sp
        var search = prm.search
       var resp = await axios.post(aUrl + sp ,
                  {search: prm.search, dep: prm.dep , value: prm.value} );
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
 }
