// 方法名不能大写
export const stringSplit = (string: any, rex: any) => {

  var index=string.lastIndexOf(rex);
  string=string.substring(index+1,string.length);
  return string;

}

// 构建对象
export const objectColumns=(key:any) => {
  const name = ["title", "dataIndex", "render"]
  var temp = new Array()
  key.map((items:any) => {
    var values: any = {}; items.map((thing:any, i:any) => { values[name[i]] = thing }); temp.push(values)
  })
  return temp
}

//取url中图片名字
export const  getUrlPicName=(str:string)=>{
  var tmp=str.split("?") 
  var tmp2=tmp[0].split("/") 
  return(tmp2[tmp2.length-1])
}

//取url中取url最后的参数路径
export const getUrlLast = (str: string) => {
  var index = str.lastIndexOf("/") 
  var tmp =str.substring(0,index)
  return tmp
}
//取url中取url最后的参数
export const getUrlLastParams = (str: string) => {
  var index = str.lastIndexOf("?") 
  var tmp =str.substring(0,index)
  return tmp
}

//保留小数点后面的两位数
export const getNumber = (str: string) => {
  var index = str.lastIndexOf(".") 
  var tmp =str
  if (index > -1) {
    tmp = str.substring(0, index + 3)
    // console.log(tmp) 
    var k = 0;
    for (var i = 0; i < tmp.length; i++) {
      if (tmp[i] == '.') { k++ };
    }
    if (k > 1) {
      tmp = tmp.substring(0, tmp.length-1)
    }    
  }
  return tmp
}

//小数转字符串保留两位小数
export const numberToString = (values: any)=>{
  var a=""+values
  var b=""
  if(a.indexOf('.')>-1){
      b=a
  }else{
      b=a+(".00")
  }
  return b
}
//内容缩进
export const stringTab = (string:any) => {
  if (string.length > 20) {
    return string.slice(0, 20) + "..."
  }
  return string
}

      //   if (/[\u4E00-\u9FA5]/g.test(value)||/^[0-9]+.?[0-9]*$/g.test(value)) {
      //     callback(new Error('只可输入字母、不能输入汉字!'));
      //   } else {
      //     callback();
      //   }
      // const checkInput = (e: any) => {
      //   console.log(e)
      //   if (e.target.value.length == 1) {
      //     message.error("Ower Name Should be limit 2~30!",3)
      //   }
      // }