
import http from "@/utils/request"
import { ElMessage } from 'element-plus'

export default {
    post: async function (method, params, success, baseUrl, errMethod) {
        var res = await http.post(method, (params || {}), (baseUrl || "/IManagementService/"), "/api");
        if (res.code != null) {
            if(res.code >5 || res.code==-1)
            {
                errMethod && errMethod()
                ElMessage.error(res.message);
            }
        }
        else {
            success && success(res);
        }
        return res;
    },
    list: async function (method, params) {
        if (params.page) {
             params.PageIndex = params.page;
        }
        var res = await this.post(method, params);
        var formatterData = {
            total: res.TotalCount,
            rows: res.PageData,
            page: res.PageIndex,
            pageSize: res.PageSize
        };
        return formatterData;
    }

  
}
 
