  
	var utils = {
		//时间格式化
		formatDate: (value) => {
			let date = null;
			if (!value) {
			    return date;
			}
			if (value.constructor == Date && !isNaN(value.getTime())) {
			    date = value;
			}
			else if (value.constructor == String || value.constructor == Number) {
			    date = new Date(value);
			}
			else {
			    throw "格式化日期时，传入的数据格式不正确。";
			}
			let y = date.getFullYear();
			let MM = date.getMonth() + 1;
			MM = MM < 10 ? ('0' + MM) : MM;
			let d = date.getDate();
			d = d < 10 ? ('0' + d) : d;
			let h = date.getHours();
			h = h < 10 ? ('0' + h) : h;
			let m = date.getMinutes();
			m = m < 10 ? ('0' + m) : m;
			let s = date.getSeconds();
			s = s < 10 ? ('0' + s) : s;
			return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
		},
		format: (value) => {
			let date = null;
			if (!value) {
			    return date;
			}
			if (value.constructor == Date && !isNaN(value.getTime())) {
			    date = value;
			}
			else if (value.constructor == String || value.constructor == Number) {
			    date = new Date(value);
			}
			else {
			    throw "格式化日期时，传入的数据格式不正确。";
			}
			let y = date.getFullYear();
			let MM = date.getMonth() + 1;
			MM = MM < 10 ? ('0' + MM) : MM;
			let d = date.getDate();
			d = d < 10 ? ('0' + d) : d;
			
			return y + '/' + MM + '/' + d;
		},
		
		//字典数据根据key显示文字
		dataFilter:(arr, val='')=> {
			let name = "";
			arr.forEach((item) => {
			  if (item.key == val) {
				name = item.name;
			  }else{
				  name='--'
			  }
			});
			return name;
		},
		
		//列表转换为树格式
		listtoTree:(data)=>{
			let result = [];
			if (!Array.isArray(data)) {
			  return result;
			}
			data.forEach((item) => {
			  delete item.children;
			});
			let map = {};
			data.forEach((item) => {
			  map[item.id] = item;
			});
			data.forEach((item) => {
			  let parent = map[item.parentId];
			  if (parent) {
				(parent.children || (parent.children = [])).push(item);
			  } else {
				result.push(item);
			  }
			});
			return result;
		},
		getRemoteFile: (path) => {
			return `http://218.24.131.92:18080/images/${path}`;
			//return `https://xzapp.runpengsoft.com/images/${path}`;
		}
	}
	// 格式化日期
  export default utils;