import { Message } from 'element-ui';

export const METHOD = {
  ADD_URL: '/mapResourcesInfo/addOrEditMapResourcesInfoById',
  DELETE_URL: '/mapResourcesInfo/deleteMapResourcesInfoById/',//resourcesId
  LIST_URL: '/mapResourcesInfo/findMapResourcesInfoList/',//pLegendId
  GlobalUrl: '47.104.61.232:8902',
  sysTITLE:'',
  titleArray: [],
  componentUrl:{
      EventsMg: "Duty",
      EventsInfo: "Duty",
      MembersMg: "Duty",
      BookPlan: "Duty",
      BookPlanDown: "Duty",
      PlansMg: "Duty",
      ProcessEvents: "Duty",
      DrillMg: "Duty",
      DealwithNecessary:"Duty",
      RoleMg: "User",
      UserMg: "User",
      BranchMg: "User",
      MenuMg: "User",
      APIMg: "User",
      KnowledgeInfo: "User",
      SocilDeivcMg: "Ioc",
      SignsMg: "Ioc",
      PublicDivceMg: "Ioc",
      CamerasMg: "Ioc",
      CompanyMg: "Ioc",
      GasMg: "Ioc",
      FireMg: "Ioc",
      NaturalMg: "Ioc",
      DeviceMg: "Ioc",
      EmergencySpecialistMg:"Ioc",
      ShelterMg:"Ioc",
      EmergencyTeamMg:"Ioc",
      EmergencyMaterialsMg:"Ioc",
      HealthCareMg:"Ioc",
      CommunicationMg:"Ioc",
      TransportationResourcesMg:"Ioc"
  },
  deleteFun(that: any, url: any, callback: any) {
    (that as any)
      .$confirm("确定删除此条记录吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
      .then(() => {
        (that as any).$axios
          .get(url)
          .then((res: any) => {
            console.log( res )
            if( res ){
              (that as any).$message({
                type: "success",
                message: "删除成功!"
              });
              callback()
            }
          });
      });
  },
  getListData(_this: any, pLegendId: any, param: any, callback: any) {//Object.assign({}, that.PAGE, that.searchData)
    (_this as any).$axios
      .post(`${this.LIST_URL + pLegendId}`, param)
      .then((res: any) => {
        if( res ){
          callback(res)
        }
      });
  },
  delteListData(_this: any, id: any, callback: any) {
    this.deleteFun(
      _this,
      `${this.DELETE_URL + id}`,
      callback
    );
  },
  addListData(_this: any, params: any, callback: any) {
    (_this as any).$axios
      .post(`${this.ADD_URL}`, params)
      .then((res: any) => {
        if( res ){
          callback(res)
        }
      });
  },
  deptList(_this: any, callback: any) {
    (_this as any).$axios
      .get(`/mapResourcesInfo/getUnitList`)
      .then((res: any) => {
        if( res ){
          callback(res)
        }
      });
  },
  axiosPost(that: any, url: any,param:any, callback: any) {//post请求
    (that as any).$axios.post(url, param).then((res:any) => {
      callback(res)
    })
  },
  axiosGet(that: any, url: any, callback: any) {//get请求
    (that as any).$axios.get(url).then((res:any) => {
      callback(res)
    })
  }
}
export default METHOD;