joywok-business-components
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -55,3 +55,3 @@ /* | ||
'label.no.object.selected': '未选择对象', | ||
'label.objselect-unselect-all': '取消全部选择', | ||
'label.objselect-unselect-all': '取消本次选择', | ||
'label.business.shareobj.business.scenario': '业务场景', | ||
@@ -58,0 +58,0 @@ |
@@ -40,38 +40,38 @@ /** | ||
import React,{ Component }from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { createStore } from 'redux' | ||
import { Provider } from 'react-redux' | ||
import { connect } from 'dva'; | ||
import request from './../utils/request'; | ||
import {Input,Modal,Select,Steps, Spin,Checkbox,message, Button} from 'antd'; | ||
import React, { Component } from 'react'; | ||
import { Input, Modal, message, Button } from 'antd'; | ||
// import Button from './../button/index'; | ||
require('./style/Index.css'); | ||
class MapContainer extends Component{ | ||
class MapContainer extends Component { | ||
constructor(props) { | ||
super(props); | ||
// console.log(props,'123123123123'); | ||
this.state = Object.assign({},{ | ||
loading:true, | ||
detail_address:{}, | ||
name:'', | ||
lang:'zh', | ||
},props.data,props) | ||
this.state = Object.assign({}, { | ||
loading: true, | ||
detail_address: {}, | ||
name: '', | ||
lang: 'zh', | ||
key: '544c827260b7a6b6712093039958f873', | ||
}, props.data, props) | ||
this.time = null; | ||
} | ||
fetchAddress(lng,lat){ | ||
fetchAddress(lng, lat) { | ||
let self = this; | ||
let location = lng+','+lat; | ||
let location = lng + ',' + lat; | ||
this.geocoder_zh = new AMap.Geocoder({ | ||
lang:'zh', | ||
extensions:"all" | ||
lang: 'zh', | ||
extensions: "all" | ||
}); | ||
this.geocoder_en = new AMap.Geocoder({ | ||
lang:'en', | ||
extensions:"all" | ||
lang: 'en', | ||
extensions: "all" | ||
}); | ||
message.loading('正在获取相关数据…') | ||
this["geocoder_"+this.state.lang].getAddress([lng,lat], function(status, result) { | ||
message.destroy(); | ||
// message.loading('正在获取相关数据…') | ||
// message.loading('正在获取数据…') | ||
message.loading(i18n('label.portal.event.get.mapdata')) | ||
this["geocoder_" + this.state.lang].getAddress([lng, lat], function (status, result) { | ||
message.destroy(); | ||
if (status === 'complete' && result.info === 'OK') { | ||
// result为对应的地理位置详细信息 | ||
console.log('result---', result) | ||
// result为对应的地理位置详细信息 | ||
let data = Object.assign({}, { | ||
@@ -85,9 +85,10 @@ longitude: lng, | ||
image: '', | ||
location: result.regeocode['aois'].length!=0?result.regeocode['aois'][0].name:"", | ||
location_name: result.regeocode['pois'].length!=0?result.regeocode['pois'][0].address:"" | ||
location: result.regeocode['aois'].length != 0 ? result.regeocode['aois'][0].name : "", | ||
location_name: result.regeocode['pois'].length != 0 ? result.regeocode['pois'][0].address : "" | ||
}) | ||
self.setState({ | ||
detail_address: data, | ||
aois:result.regeocode['aois'], | ||
name:result.regeocode['formattedAddress'] | ||
aois: result.regeocode['aois'], | ||
pois: result.regeocode['pois'], | ||
name: result.regeocode['formattedAddress'] | ||
}) | ||
@@ -97,20 +98,65 @@ } | ||
} | ||
save(){ | ||
save() { | ||
let self = this; | ||
this.props.events.emit('save',{ | ||
name:self.state.name, | ||
aois:self.state.aois, | ||
detail_address:self.state.detail_address | ||
}); | ||
this.props.events.emit('cancel'); | ||
let { lang, aois, pois } = this.state; | ||
if (aois && aois[0] || pois && pois[0]) { | ||
// message.loading('正在获取地址数据…'); | ||
message.loading(i18n('label.portal.event.get.address.data')); | ||
AMap.plugin('AMap.PlaceSearch', function () { | ||
var placeSearch = new AMap.PlaceSearch({ | ||
lang: lang == 'zh' ? "en" : "zh_cn" | ||
}) | ||
// 对应的POI ID | ||
var poiid = aois && aois[0] ? aois[0]['id'] : pois[0]['id'] | ||
placeSearch.getDetails(poiid, function (status, result) { | ||
message.destroy(); | ||
if (status === 'complete' && result.info === 'OK') { | ||
// 查询成功时,result即为对应的POI详情 | ||
let resData = result.poiList && result.poiList.pois[0]; | ||
let detailAddress = self.state.detail_address; | ||
let curLangData = { | ||
name: detailAddress['location'], | ||
address: detailAddress['location_name'], | ||
latitude: detailAddress['latitude'], | ||
longitude: detailAddress['longitude'], | ||
"type": "geo" | ||
} | ||
let curLangD = { | ||
name: resData && resData['name'], | ||
address: resData && resData['address'], | ||
latitude: detailAddress['latitude'], | ||
longitude: detailAddress['longitude'], | ||
"type": "geo" | ||
} | ||
let detailData = {}; | ||
if (lang == "zh") { | ||
detailData['zh'] = curLangData; | ||
detailData['en'] = curLangD; | ||
} else { | ||
detailData['en'] = curLangData; | ||
detailData['zh'] = curLangD; | ||
} | ||
self.props.events.emit('save', { | ||
name: self.state.name, | ||
aois: self.state.aois, | ||
detail_address: self.state.detail_address, | ||
detailData: detailData | ||
}); | ||
self.props.events.emit('cancel'); | ||
} | ||
}) | ||
}) | ||
} else { | ||
self.props.events.emit('cancel'); | ||
} | ||
} | ||
combineMapPlugin(){ | ||
combineMapPlugin() { | ||
let self = this; | ||
self.map.plugin([ 'AMap.ToolBar','AMap.Autocomplete','AMap.PlaceSearch'], function () { | ||
self.map.plugin(['AMap.ToolBar', 'AMap.Autocomplete', 'AMap.PlaceSearch'], function () { | ||
self.map.addControl(new AMap.ToolBar({ | ||
lang:self.state.lang | ||
lang: self.state.lang | ||
})); | ||
self.auto = new AMap.Autocomplete({ | ||
input: "tipinput", | ||
lang:self.state.lang | ||
lang: self.state.lang | ||
}); | ||
@@ -120,33 +166,37 @@ self.map.addControl(self.auto); | ||
map: self.map, | ||
lang:self.state.lang | ||
lang: self.state.lang | ||
}); //构造地点查询类 | ||
self.map.addControl(placeSearch); | ||
function select(e) { | ||
if(e.poi['id'].length==0){ | ||
message.error('没有获取到搜索的位置',2); | ||
if (e.poi['id'].length == 0) { | ||
// message.error('没有获取到搜索的位置',2); | ||
// message.error('未找到您搜索的位置',2); | ||
message.error(i18n('label.event.noposition'), 2); | ||
return | ||
} | ||
self.map.setZoom(15); | ||
self.map.panTo([e.poi['location']['lng'],e.poi['location']['lat']]); | ||
self.time = setTimeout(function(){ | ||
self.combineMapLocation(e.poi['location']['lng'],e.poi['location']['lat']) | ||
self.fetchAddress(e.poi['location']['lng'],e.poi['location']['lat']); | ||
},200) | ||
self.map.panTo([e.poi['location']['lng'], e.poi['location']['lat']]); | ||
clearTimeout(self.time); | ||
self.time = setTimeout(function () { | ||
self.combineMapLocation(e.poi['location']['lng'], e.poi['location']['lat']) | ||
self.fetchAddress(e.poi['location']['lng'], e.poi['location']['lat']); | ||
}, 200) | ||
} | ||
AMap.event.addListener(self.auto, "select", select); | ||
self.map.on('click', function(e){ | ||
self.time = setTimeout(function(){ | ||
self.combineMapLocation(e['lnglat']['lng'],e['lnglat']['lat']) | ||
self.fetchAddress(e['lnglat']['lng'],e['lnglat']['lat']); | ||
},200) | ||
self.map.on('click', function (e) { | ||
clearTimeout(self.time); | ||
self.time = setTimeout(function () { | ||
self.combineMapLocation(e['lnglat']['lng'], e['lnglat']['lat']) | ||
self.fetchAddress(e['lnglat']['lng'], e['lnglat']['lat']); | ||
}, 200) | ||
}); | ||
self.map.on('dblclick',function(){ | ||
self.map.on('dblclick', function () { | ||
clearTimeout(self.time); | ||
}) | ||
if(typeof(self.marker)!='undefined'){ | ||
if (typeof (self.marker) != 'undefined') { | ||
self.map.remove(self.marker); | ||
} | ||
if(self.state.name && self.state.name.length!=0){ | ||
if (self.state.name && self.state.name.length != 0) { | ||
self.marker = new AMap.Marker({ | ||
lang:self.state.lang, | ||
lang: self.state.lang, | ||
// position: self.state.address.streetNumber.location && self.state.address.streetNumber.location.length!=0?self.state.address.streetNumber.location.split(','):self.state.aois[0].location.split(','), | ||
@@ -159,5 +209,5 @@ offset: new AMap.Pixel(-12, -33) | ||
} | ||
combineMapLocation(lng,lat){ | ||
combineMapLocation(lng, lat) { | ||
let self = this; | ||
if(typeof(self.marker)!='undefined'){ | ||
if (typeof (self.marker) != 'undefined') { | ||
self.map.remove(self.marker); | ||
@@ -167,4 +217,4 @@ } | ||
self.marker = new AMap.Marker({ | ||
lang:self.state.lang, | ||
position: [lng,lat], | ||
lang: self.state.lang, | ||
position: [lng, lat], | ||
offset: new AMap.Pixel(-12, -33), | ||
@@ -174,15 +224,16 @@ }); | ||
} | ||
componentDidMount(){ | ||
componentDidMount() { | ||
let self = this; | ||
var script=document.createElement('script'); | ||
script.type="text/javascript"; | ||
script.src='https://webapi.amap.com/maps?v=1.4.15&key=0dfc4d46208fc4478eadb34410fba73b&plugin=AMap.Geocoder,AMap.ToolBar,AMap.Autocomplete,AMap.PlaceSearch'; | ||
script.class='hahaha' | ||
var script = document.createElement('script'); | ||
script.type = "text/javascript"; | ||
// script.src='https://webapi.amap.com/maps?v=1.4.15&key=0dfc4d46208fc4478eadb34410fba73b&plugin=AMap.Geocoder,AMap.ToolBar,AMap.Autocomplete,AMap.PlaceSearch'; | ||
script.src = 'https://webapi.amap.com/maps?v=1.4.15&key=' + this.state.key + '&plugin=AMap.Geocoder,AMap.ToolBar,AMap.Autocomplete,AMap.PlaceSearch,AMap.CitySearch'; | ||
script.class = 'hahaha' | ||
document.body.appendChild(script); | ||
script.onload = function(){ | ||
self.setState({loading:false}); | ||
script.onload = function () { | ||
self.setState({ loading: false }); | ||
self.init_map(); | ||
} | ||
} | ||
init_map(){ | ||
init_map() { | ||
let self = this; | ||
@@ -193,97 +244,123 @@ let longitude = self.state.detail_address.longitude; | ||
// 有经纬度,就用经纬度渲染。没有经纬度,就通过详细地址获取经纬度后再做渲染 | ||
if(longitude&&latitude&&longitude!=""&&latitude!=""){ | ||
let errormsg = '' | ||
if (longitude && latitude && longitude != "" && latitude != "") { | ||
self.map = new AMap.Map('map-container', { | ||
animateEnable:true, | ||
animateEnable: true, | ||
resizeEnable: true, //是否监控地图容器尺寸变化 | ||
zoom:15, //初始化地图层级 | ||
center: [longitude,latitude], //初始化地图中心点 | ||
lang:self.state.lang | ||
zoom: 15, //初始化地图层级 | ||
center: [longitude, latitude], //初始化地图中心点 | ||
lang: self.state.lang | ||
}); | ||
self.combineMapPlugin(); | ||
self.combineMapLocation(longitude,latitude); | ||
self.fetchAddress(longitude,latitude); | ||
}else if(self.props.data.name=="" && (data.province=='' && data.city=="" && data.district=='') || (JSON.stringify(data.province)=="{}"&&JSON.stringify(data.city)=="{}"&&JSON.stringify(data.district)=="{}")){ | ||
self.combineMapLocation(longitude, latitude); | ||
self.fetchAddress(longitude, latitude); | ||
} else if (self.props.data.name == "" && (data.province == '' && data.city == "" && data.district == '') || (JSON.stringify(data.province) == "{}" && JSON.stringify(data.city) == "{}" && JSON.stringify(data.district) == "{}")) { | ||
self.map = new AMap.Map('map-container', { | ||
animateEnable:true, | ||
animateEnable: true, | ||
resizeEnable: true, //是否监控地图容器尺寸变化 | ||
zoom:15, //初始化地图层级 | ||
lang:self.state.lang | ||
zoom: 15, //初始化地图层级 | ||
lang: self.state.lang | ||
}); | ||
AMap.plugin('AMap.CitySearch', function () { | ||
var citySearch = new AMap.CitySearch({lang:self.state.lang}) | ||
var citySearch = new AMap.CitySearch({ lang: self.state.lang }) | ||
citySearch.getLocalCity(function (status, result) { | ||
if (status === 'complete' && result.info === 'OK') { | ||
// 查询成功,result即为当前所在城市信息 | ||
console.log(result, '这个位置是什么啊'); | ||
self.combineMapPlugin(); | ||
// self.combineMapLocation(data.position.lng,data.position.lat); | ||
// self.fetchAddress(data.position.lng,data.position.lat); | ||
}else{ | ||
message.error('没有获取到当前城市',2); | ||
} else { | ||
message.destory(); | ||
// errormsg = '没有获取到当前城市'; | ||
// message.error('没有获取到当前城市',2); | ||
// message.error('未获取到当前城市信息',2); | ||
message.error(i18n('label.portal.event.nocity'), 2); | ||
return | ||
} | ||
}) | ||
}) | ||
if(longitude.length==0 && latitude.length==0){ | ||
AMap.plugin('AMap.Geolocation', function() { | ||
if (longitude.length == 0 && latitude.length == 0) { | ||
AMap.plugin('AMap.Geolocation', function () { | ||
var geolocation = new AMap.Geolocation({ | ||
enableHighAccuracy: true,//是否使用高精度定位,默认:true | ||
timeout: 10000, //超过10秒后停止定位,默认:5s | ||
buttonPosition:'RB', //定位按钮的停靠位置 | ||
// timeout: 10000, //超过10秒后停止定位,默认:5s | ||
// buttonPosition:'RB', //定位按钮的停靠位置 | ||
buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20) | ||
zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点 | ||
GeoLocationFirst: true | ||
}); | ||
console.log("geolocation::::",geolocation.getCurrentPosition()) | ||
console.log("geolocation::::", geolocation.getCurrentPosition()) | ||
self.map.addControl(geolocation); | ||
geolocation.getCurrentPosition(); | ||
// geolocation.getCurrentPosition(); | ||
geolocation.getCityInfo(); | ||
AMap.event.addListener(geolocation, 'complete', onComplete) | ||
AMap.event.addListener(geolocation, 'error', onError); | ||
function onComplete(data){ | ||
function onComplete(data) { | ||
self.combineMapPlugin(); | ||
self.combineMapLocation(data.position.lng,data.position.lat); | ||
self.fetchAddress(data.position.lng,data.position.lat); | ||
self.combineMapLocation(data.position.lng, data.position.lat); | ||
self.fetchAddress(data.position.lng, data.position.lat); | ||
} | ||
function onError(){ | ||
message.error('没有获取到当前位置',2); | ||
function onError(error) { | ||
message.destroy(); | ||
var citySearch = new AMap.CitySearch({ lang: self.state.lang }); | ||
citySearch.getLocalCity(function (status, result) { | ||
if (status === 'complete' && result.info === 'OK') { | ||
console.log(result, '这个位置是什么啊'); | ||
self.map.setBounds(result.bounds); | ||
} else { | ||
message.error(i18n('label.portal.event.nocity'), 2); | ||
return; | ||
} | ||
}); | ||
message.error(error && error.message, 2); | ||
return | ||
} | ||
}) | ||
} | ||
}else{ | ||
} else { | ||
let keywords; | ||
if((data.province.name&&data.province.name!="") || (data.province&&data.province!="")){ | ||
if ((data.province.name && data.province.name != "") || (data.province && data.province != "")) { | ||
// keywords = (data.province.name ? data.province.name : data.province) + (data.city.name=="市辖区" || data.city.length==0 ? "" : (data.city.name ? data.city.name : data.city)) + (data.district.name ? data.district.name : data.district) + (data.street ? data.street : data.township); | ||
keywords = self.props.data.name!='' ? self.props.data.name : data.province.name + (data.city.name=="市辖区" ? "" : data.city.name) + data.district.name + data.street | ||
}else{ | ||
keywords = self.props.data.name != '' ? self.props.data.name : data.province.name + (data.city.name == "市辖区" ? "" : data.city.name) + data.district.name + data.street | ||
} else { | ||
keywords = self.props.data.name | ||
} | ||
// console.log("keywords::::",keywords) | ||
AMap.plugin('AMap.Geocoder', function() { | ||
AMap.plugin('AMap.Geocoder', function () { | ||
var geocoder = new AMap.Geocoder({ | ||
city: self.props.data.name.split('市')[0] || self.props.data.name.split('省')[0] || self.props.data.name.split('自治区')[0], | ||
lang:self.state.lang | ||
lang: self.state.lang | ||
}) | ||
// 使用geocoder做地理/逆地理编码 根据详细地址查询经纬度,根据经纬度渲染点标记 | ||
geocoder.getLocation(keywords, function(status, result) { | ||
geocoder.getLocation(keywords, function (status, result) { | ||
if (status === 'complete' && result.info === 'OK') { | ||
// result中对应详细地理坐标信息 | ||
console.log(result,'asdasdasdasda'); | ||
if(result.geocodes&&result.geocodes.length>0){ | ||
console.log(result, 'asdasdasdasda'); | ||
if (result.geocodes && result.geocodes.length > 0) { | ||
let geocode = result.geocodes[0]; | ||
// console.log("geocode::::",geocode) | ||
if(geocode.location){ | ||
if (geocode.location) { | ||
self.map = new AMap.Map('map-container', { | ||
animateEnable:true, | ||
animateEnable: true, | ||
resizeEnable: true, //是否监控地图容器尺寸变化 | ||
zoom:15, //初始化地图层级 | ||
center: [geocode.location.lng,geocode.location.lat],//初始化地图中心点, | ||
lang:self.state.lang | ||
zoom: 15, //初始化地图层级 | ||
center: [geocode.location.lng, geocode.location.lat],//初始化地图中心点, | ||
lang: self.state.lang | ||
}); | ||
// console.log('result:',geocode.location.lng,geocode.location.lat); | ||
self.combineMapPlugin(); | ||
self.combineMapLocation(geocode.location.lng,geocode.location.lat); | ||
self.fetchAddress(geocode.location.lng,geocode.location.lat); | ||
}else{ | ||
message.error('没有找到相应的经纬度',2); | ||
self.combineMapLocation(geocode.location.lng, geocode.location.lat); | ||
self.fetchAddress(geocode.location.lng, geocode.location.lat); | ||
} else { | ||
// message.error('没有找到相应的经纬度',2); | ||
// message.error('未找到相应的经纬度',2); | ||
message.error(i18n('label.portal.event.nolanglan'), 2); | ||
return | ||
} | ||
} | ||
} | ||
console.log(status,'asdasdas'); | ||
console.log(status, 'asdasdas'); | ||
}) | ||
@@ -293,35 +370,37 @@ }) | ||
} | ||
cancel(){ | ||
cancel() { | ||
this.props.events.emit('cancel'); | ||
$(".amap-sug-result").addClass('hide'); | ||
} | ||
render(){ | ||
let self = this; | ||
let newName = self.props.data.detail_address.province.name + (self.props.data.detail_address.city.name=="市辖区" ? "" : self.props.data.detail_address.city.name) + self.props.data.detail_address.district.name + self.props.data.detail_address.street; | ||
render() { | ||
let self = this; | ||
let newName = self.props.data.detail_address.province.name + (self.props.data.detail_address.city.name == "市辖区" ? "" : self.props.data.detail_address.city.name) + self.props.data.detail_address.district.name + self.props.data.detail_address.street; | ||
return (<div className="jw-map"> | ||
<div className="jw-map-w"> | ||
{ | ||
this.state.loading?"":<div className="jw-map-search"> | ||
<Input placeholder="搜索" id="tipinput"/> | ||
</div> | ||
} | ||
{ | ||
this.state.loading?<div className="jw-map-loading-c"><div className="jw-map-loading"></div></div>:<div className="jw-map-c" id="map-container"></div> | ||
} | ||
</div> | ||
<div className="jw-map-footer"> | ||
<div className="jw-map-btns"> | ||
<Button className="jw-map-btn-cancel" onClick={(e)=>this.cancel(e)}>取消</Button> | ||
<Button className="jw-map-btn-save" onClick={(e)=>this.save(e)}>确定</Button> | ||
<div className="jw-map-w"> | ||
{ | ||
this.state.loading ? "" : <div className="jw-map-search"> | ||
<Input placeholder={i18n('label.biportal-placeholder')} id="tipinput" /> | ||
</div> | ||
<div className="jw-map-address"> | ||
详细地址:<span>{ | ||
this.state.name && this.state.name.length!=0 ? this.state.name: (newName=='NaN' ? '' : newName) | ||
}</span> | ||
</div> | ||
} | ||
{ | ||
this.state.loading ? <div className="jw-map-loading-c"><div className="jw-map-loading"></div></div> : <div className="jw-map-c" id="map-container"></div> | ||
} | ||
</div> | ||
<div className="jw-map-footer"> | ||
<div className="jw-map-btns"> | ||
<Button className="jw-map-btn-cancel" onClick={(e) => this.cancel(e)}>{i18n('btn.cancel')}</Button> | ||
<Button className="jw-map-btn-save" onClick={(e) => this.save(e)}>{i18n('btn.ok')}</Button> | ||
</div> | ||
</div>) | ||
<div className="jw-map-address"> | ||
{/* <div className="jw-map-address-tip">详细地址:</div> */} | ||
<div className="jw-map-address-tip">{i18n('label.console.iam.dAddress')}:</div> | ||
<div className="jw-map-address-value ellipsis" title={this.state.name && this.state.name.length != 0 ? this.state.name : (newName == 'NaN' ? '' : newName)}>{ | ||
this.state.name && this.state.name.length != 0 ? this.state.name : (newName == 'NaN' ? '' : newName) | ||
}</div> | ||
</div> | ||
</div> | ||
</div>) | ||
} | ||
} | ||
class Map extends Component{ | ||
class Map extends Component { | ||
constructor(props) { | ||
@@ -339,21 +418,21 @@ super(props); | ||
} | ||
render(){ | ||
render() { | ||
let modalData = this.props.modal || {}; | ||
let modal = _.extend({},{ | ||
width:modalData&&modalData.width?modalData.width:'700px', | ||
destroyOnClose:true, | ||
getContainer:()=>document.getElementById(this.props.containerId), | ||
title:null, | ||
visible:true, | ||
footer:null, | ||
onCancel:(e)=>this.props.close(e), | ||
ref:"modal", | ||
let modal = _.extend({}, { | ||
width: modalData && modalData.width ? modalData.width : '700px', | ||
destroyOnClose: true, | ||
getContainer: () => document.getElementById(this.props.containerId), | ||
title: null, | ||
visible: true, | ||
footer: null, | ||
onCancel: (e) => this.props.close(e), | ||
ref: "modal", | ||
maskClosable: false | ||
},modalData); | ||
}, modalData); | ||
let customClass = modal.customClass || ''; | ||
return (<div className={"dialog-c "+customClass} id={this.props.containerId}> | ||
<Modal {...modal}> | ||
<MapContainer {...this.props.data} events={this.props.events}></MapContainer> | ||
</Modal> | ||
</div>) | ||
return (<div className={"dialog-c " + customClass} id={this.props.containerId}> | ||
<Modal {...modal}> | ||
<MapContainer {...this.props.data} events={this.props.events}></MapContainer> | ||
</Modal> | ||
</div>) | ||
} | ||
@@ -360,0 +439,0 @@ componentDidMount() { |
@@ -29,3 +29,3 @@ import React, { Component } from 'react'; | ||
this.lastFetchId = 0; | ||
let newData = this.turnData(props.shareobj||[]); | ||
let newData = this.turnData(props.shareobj || []); | ||
this.state = { | ||
@@ -49,6 +49,6 @@ containerId: 'base-share-container-' + generateMixed(16), | ||
let url = self.state.url ? (self.state.url) : (self.props.url); | ||
if(url){ | ||
if (url) { | ||
request(url + encodeURIComponent(value), { | ||
method: 'GET', | ||
headers: self.props.urlHeaders && {appid: self.props.urlHeaders} | ||
headers: self.props.urlHeaders && { appid: self.props.urlHeaders } | ||
}) | ||
@@ -58,3 +58,3 @@ .then((body) => { | ||
let nowData = []; | ||
_.each( (body.data.JMObjs&&body.data.JMObjs.list) || body.data.JMObjs || body.data.JMUsergroups || body.data.JMBusinessList, function (i) { | ||
_.each((body.data.JMObjs && body.data.JMObjs.list) || body.data.JMObjs || body.data.JMUsergroups || body.data.JMBusinessList, function (i) { | ||
if (Underscore.findWhere(self.props.shareobj, { id: i['id'] })) { | ||
@@ -79,5 +79,5 @@ } else { | ||
allData = self.turnData(allData); | ||
self.setState({ data: allData ,fetching: false }); | ||
self.setState({ data: allData, fetching: false }); | ||
}); | ||
}else { | ||
} else { | ||
self.setState({ data: [], fetching: false }); | ||
@@ -91,4 +91,4 @@ } | ||
let object = Underscore.findWhere(this.state.data, { key: data['key'] }) | ||
if(typeof(object)=='undefined') return; | ||
object['label'] = object['name']||''; | ||
if (typeof (object) == 'undefined') return; | ||
object['label'] = object['name'] || ''; | ||
datas.push(object) | ||
@@ -102,5 +102,5 @@ this.setState({ | ||
$(".jw-shareobj .ant-select-search__field").addClass('hide') | ||
setTimeout(function(){ | ||
setTimeout(function () { | ||
$(".jw-shareobj .ant-select-search__field").removeClass('hide') | ||
},200) | ||
}, 200) | ||
if (typeof (this.props.onChange) == 'function') { | ||
@@ -128,7 +128,7 @@ this.props.onChange(datas) | ||
let curItemName = socialobj.show_name || socialobj.name; | ||
if(socialobj.parent_path&&socialobj.parent_path!='') curItemName = socialobj.parent_path+'-'+curItemName; | ||
if (socialobj.parent_path && socialobj.parent_path != '') curItemName = socialobj.parent_path + '-' + curItemName; | ||
if (socialobj.type == 'jw_n_user') { | ||
return (<div className={"jw-shareobj-item-w " + socialobj.type} data-action-val={socialobj["name"]} data-action-id={socialobj["id"]}> | ||
<div className="jw-shareobj-item-pic"> | ||
<img src={socialobj.dtype&&socialobj.dtype==1 ? jwimgsrc + '/images/jw-img/share/group.png' : (socialobj['avatar'] ? socialobj['avatar']['avatar_l'] : jwimgsrc + '/images/jw-img/share/user.jpg')} /> | ||
<img src={socialobj.dtype && socialobj.dtype == 1 ? jwimgsrc + '/images/jw-img/share/group.png' : (socialobj['avatar'] ? socialobj['avatar']['avatar_l'] : jwimgsrc + '/images/jw-img/share/user.jpg')} /> | ||
</div> | ||
@@ -138,14 +138,14 @@ <div className={"jw-shareobj-item-c " + (socialobj['depts'] && socialobj['depts'].length != 0 ? 'jw-shareobj-item-c-other' : '')}> | ||
{ | ||
socialobj['depts'] && socialobj['depts'].length != 0 ? <div className="jw-shareobj-item-c-tip">{(socialobj['depts'][0]['title'])+(socialobj['depts'][0]['title']!='' ? ',' : '')+(socialobj['depts'][0]['name'])}</div> : '' | ||
socialobj['depts'] && socialobj['depts'].length != 0 ? <div className="jw-shareobj-item-c-tip">{(socialobj['depts'][0]['title']) + (socialobj['depts'][0]['title'] != '' ? ',' : '') + (socialobj['depts'][0]['name'])}</div> : '' | ||
} | ||
</div> | ||
</div>) | ||
} else if (socialobj.type == 'jw_n_group' || socialobj.type == 'jw_n_dept' || socialobj.type == '1'||socialobj.type=='app') { | ||
} else if (socialobj.type == 'jw_n_group' || socialobj.type == 'jw_n_dept' || socialobj.type == '1' || socialobj.type == 'app') { | ||
return (<div className={"jw-shareobj-item-w " + socialobj.type} data-action-val={socialobj["name"]} data-action-id={socialobj["id"]}> | ||
<div className={"jw-shareobj-item-pic " + (socialobj.type=='app' ? 'jw-shareobj-item-pic-app' : '')}> | ||
<img src={socialobj.dtype&&socialobj.dtype==1 ? jwimgsrc + '/images/jw-img/share/group.png' : socialobj['logo']} /> | ||
<div className={"jw-shareobj-item-pic " + (socialobj.type == 'app' ? 'jw-shareobj-item-pic-app' : '')}> | ||
<img src={socialobj.dtype && socialobj.dtype == 1 ? jwimgsrc + '/images/jw-img/share/group.png' : socialobj['logo']} /> | ||
</div> | ||
<div className="jw-shareobj-item-c"> | ||
<div className="jw-shareobj-item-c-name ellipsis">{curItemName}</div> | ||
<div className="jw-shareobj-item-c-tip">{COMPONENT_DICT('label.business.shareobj.dept.member').replace('{num}',socialobj.members_num)}</div> | ||
<div className="jw-shareobj-item-c-tip">{COMPONENT_DICT('label.business.shareobj.dept.member').replace('{num}', socialobj.members_num)}</div> | ||
</div> | ||
@@ -156,5 +156,5 @@ </div>) | ||
<div className="jw-shareobj-item-pic"> | ||
<img src={socialobj.dtype&&socialobj.dtype==1 ? jwimgsrc + '/images/jw-img/share/group.png' : jwimgsrc + '/images/jw-img/share/roles.png'} /> | ||
<img src={socialobj.dtype && socialobj.dtype == 1 ? jwimgsrc + '/images/jw-img/share/group.png' : jwimgsrc + '/images/jw-img/share/roles.png'} /> | ||
</div> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" :"jw-shareobj-item-c"}> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" : "jw-shareobj-item-c"}> | ||
<div className="jw-shareobj-item-c-name ellipsis">{curItemName}</div> | ||
@@ -173,6 +173,6 @@ <div className="jw-shareobj-item-c-tip"></div> | ||
return (<div className={"jw-shareobj-item-w " + socialobj.type} data-action-val={socialobj["name"]} data-action-id={socialobj["id"]}> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype&&socialobj.dtype==1 ? jwimgsrc + '/images/jw-img/share/group.png' : jwimgsrc + '/images/jw-img/share/position.png'} /> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype && socialobj.dtype == 1 ? jwimgsrc + '/images/jw-img/share/group.png' : jwimgsrc + '/images/jw-img/share/position.png'} /> | ||
</div> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" : "jw-shareobj-item-c"}> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" : "jw-shareobj-item-c"}> | ||
<div className="jw-shareobj-item-c-name ellipsis">{curItemName}</div> | ||
@@ -185,6 +185,6 @@ <div className="jw-shareobj-item-c-tip"></div> | ||
return (<div className={"jw-shareobj-item-w " + socialobj.type} data-action-val={socialobj["name"]} data-action-id={socialobj["id"]}> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype&&socialobj.dtype==1 ? jwimgsrc + '/images/jw-img/share/group.png' : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAABSpJREFUaAXtW2tsFFUU/mahy6stiG2xJA3avxUJirWBCk2qaDCCJCZAogmJ4osEoyb6Q43GV6IxGiWgVYk/NNGUUNRoFCmGNIWAaLBI9Yc0KhCssBDtFkq70PU7e3eyszu7szNz12z3cZLdmXvuOffeb777OPfujoG4RKMwsBX3I4r7qGritdLMK8irgWG2u5+otuERfGAYREQx5CvagXpE8BFV7ZIuOjGwh0jvMTZiMBBjtpjBCntCZBQfC1YjugUbMI73io7VdIACeCBA5DJmS0OINUCkTaWBNoaySRgu7NnYC1vEKgyXlJQBFzvdZYbLDBfZEyh36SIj1Aan5BiebHsEOoppc4ApM+0ljA0BFwbtepuGz3/BJga7G4DKBiD0E3DgGeBUj83Sr8KIbmZwqSuNq4HWN4HqeZlLCp8A9j0BHNue3iZQAdzeCTTelZzPPR32PsytfEey3mdKv0s3LAdWdDmDlcZVkTEBNO8Oe1OtYC+eAz6/DeioJrvP8oiCZxRt75D1B+1+PjT6gJuf81Zt8/PJ9qlgP7sFOPEtEAkDP7wE9DyaAH3tQ8m+PlL6Y7h2obdqa66jvTzncV6kG7OLN64ChFkBGzqcXN6Rt1V66VvAsq3q/ui7yTYeUvoMT57moTqaTgoS6CTl0/KKM1izZAHds0kxLaDnLjVzPF/1AXuuMu4wtQZY+DhweYxjlvNAKrOp5R7ZrGZsGdMtL6fmuk7nD/CV88kYq/9rH3DmR3cN7ot375oF7uzTWOUPcPi4as5snjAFZ6ZpWhpV/WKlNH3TmGRT5Q/w0ABw8jtgeh1w51dARZVzW2uvB5Z/omx+ed/Z1iFXH/BIyKH4NFmj/3KCjqiM7vWAsFW/BFj5dWbQAnZVNzD1CmCgC+jjePYp+oC9hn1W+2FGX11twNCfcdDf2EEngd0J7FpLqFzSfIo+4F6Gi7KGupHRf4BezsxWCf8O7GyLg+YYXUnQwVnKou5GC7MCdk2id1jL8HCfm1h6xlxgEcPAq25KPwHJ5uHv74FDLwLnT6ZvXtXVwOq9KkQdOQOc+5Xltah1eyA3YKXi3ACWknIhskNq/xBoaFeljV8GDr8OHOTDNMe9Zj0TC7AJpuoatdk4exQYdTlcTN8sV/1YOrUCIx42WvVRmWSiVk3me/Ef5swtHxFJe/FXXhm/cwO49gZgyWtAXTPHcKW9ssh5juFDwP6ngNMcy6kijN78BmPkZWrpSc2X8DPUxzngBeCPL1NzPaX1u7QsG3cf4OTCnU82Gb8E7Ggl+IMJS5nw1v1MoLMTOqe7XeuA3z51snDM01+WFr/qDqw0I8AOJfZWWfS0e7Di18qeoCH6gOdwKfIisraqf1ooL6/+M+rVeZeXOi22+oCDWWJgS2Wx24rpimlTH6w279xf/fjES9cH7L6ZE8KyDHhC0PA/NqLMsOeHKxsDLxK5wLiY67EpXv3FT/bUPkWf4UFLEOGmEbJrsoaZgwxavMjwqcw7Lhfl6AOWcFFCPzcizO5/MtlSDttHzibrnFK9jznlZs3TByzHq9u5bz2+G8jUPcfC/DWhW9mdZkxtFfmRrZOx+LEdBB6y5iTuL10EpCd8sYJ2nQm9jzv9WNpHpfl00Wc4n633UXcZsI+HVlAuZYYLii4fjS0z7OOhFZRLgIcP8vZHaQixSpfuLw20MZT9wvC2kgFMrEbsNZ4t2M0NTPz3jSKFL+8ubcStgdgbWxW4l0zvKVKockiqXtTi22n8h4iSGNMl8Cref+zuVmHr6M+NAAAAAElFTkSuQmCC"} /> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype && socialobj.dtype == 1 ? jwimgsrc + '/images/jw-img/share/group.png' : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAABSpJREFUaAXtW2tsFFUU/mahy6stiG2xJA3avxUJirWBCk2qaDCCJCZAogmJ4osEoyb6Q43GV6IxGiWgVYk/NNGUUNRoFCmGNIWAaLBI9Yc0KhCssBDtFkq70PU7e3eyszu7szNz12z3cZLdmXvuOffeb777OPfujoG4RKMwsBX3I4r7qGritdLMK8irgWG2u5+otuERfGAYREQx5CvagXpE8BFV7ZIuOjGwh0jvMTZiMBBjtpjBCntCZBQfC1YjugUbMI73io7VdIACeCBA5DJmS0OINUCkTaWBNoaySRgu7NnYC1vEKgyXlJQBFzvdZYbLDBfZEyh36SIj1Aan5BiebHsEOoppc4ApM+0ljA0BFwbtepuGz3/BJga7G4DKBiD0E3DgGeBUj83Sr8KIbmZwqSuNq4HWN4HqeZlLCp8A9j0BHNue3iZQAdzeCTTelZzPPR32PsytfEey3mdKv0s3LAdWdDmDlcZVkTEBNO8Oe1OtYC+eAz6/DeioJrvP8oiCZxRt75D1B+1+PjT6gJuf81Zt8/PJ9qlgP7sFOPEtEAkDP7wE9DyaAH3tQ8m+PlL6Y7h2obdqa66jvTzncV6kG7OLN64ChFkBGzqcXN6Rt1V66VvAsq3q/ui7yTYeUvoMT57moTqaTgoS6CTl0/KKM1izZAHds0kxLaDnLjVzPF/1AXuuMu4wtQZY+DhweYxjlvNAKrOp5R7ZrGZsGdMtL6fmuk7nD/CV88kYq/9rH3DmR3cN7ot375oF7uzTWOUPcPi4as5snjAFZ6ZpWhpV/WKlNH3TmGRT5Q/w0ABw8jtgeh1w51dARZVzW2uvB5Z/omx+ed/Z1iFXH/BIyKH4NFmj/3KCjqiM7vWAsFW/BFj5dWbQAnZVNzD1CmCgC+jjePYp+oC9hn1W+2FGX11twNCfcdDf2EEngd0J7FpLqFzSfIo+4F6Gi7KGupHRf4BezsxWCf8O7GyLg+YYXUnQwVnKou5GC7MCdk2id1jL8HCfm1h6xlxgEcPAq25KPwHJ5uHv74FDLwLnT6ZvXtXVwOq9KkQdOQOc+5Xltah1eyA3YKXi3ACWknIhskNq/xBoaFeljV8GDr8OHOTDNMe9Zj0TC7AJpuoatdk4exQYdTlcTN8sV/1YOrUCIx42WvVRmWSiVk3me/Ef5swtHxFJe/FXXhm/cwO49gZgyWtAXTPHcKW9ssh5juFDwP6ngNMcy6kijN78BmPkZWrpSc2X8DPUxzngBeCPL1NzPaX1u7QsG3cf4OTCnU82Gb8E7Ggl+IMJS5nw1v1MoLMTOqe7XeuA3z51snDM01+WFr/qDqw0I8AOJfZWWfS0e7Di18qeoCH6gOdwKfIisraqf1ooL6/+M+rVeZeXOi22+oCDWWJgS2Wx24rpimlTH6w279xf/fjES9cH7L6ZE8KyDHhC0PA/NqLMsOeHKxsDLxK5wLiY67EpXv3FT/bUPkWf4UFLEOGmEbJrsoaZgwxavMjwqcw7Lhfl6AOWcFFCPzcizO5/MtlSDttHzibrnFK9jznlZs3TByzHq9u5bz2+G8jUPcfC/DWhW9mdZkxtFfmRrZOx+LEdBB6y5iTuL10EpCd8sYJ2nQm9jzv9WNpHpfl00Wc4n633UXcZsI+HVlAuZYYLii4fjS0z7OOhFZRLgIcP8vZHaQixSpfuLw20MZT9wvC2kgFMrEbsNZ4t2M0NTPz3jSKFL+8ubcStgdgbWxW4l0zvKVKockiqXtTi22n8h4iSGNMl8Cref+zuVmHr6M+NAAAAAElFTkSuQmCC"} /> | ||
</div> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" : "jw-shareobj-item-c"}> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" : "jw-shareobj-item-c"}> | ||
<div className="jw-shareobj-item-c-name ellipsis">{curItemName}</div> | ||
@@ -196,6 +196,6 @@ <div className="jw-shareobj-item-c-tip"></div> | ||
return (<div className={"jw-shareobj-item-w " + socialobj.type} data-action-val={socialobj["name"]} data-action-id={socialobj["id"]}> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype&&socialobj.dtype==1 ? jwimgsrc + '/images/jw-img/share/group.png' : jwimgsrc + '/images/jw-img/share/region.png'} /> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype && socialobj.dtype == 1 ? jwimgsrc + '/images/jw-img/share/group.png' : jwimgsrc + '/images/jw-img/share/region.png'} /> | ||
</div> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" :"jw-shareobj-item-c"}> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" : "jw-shareobj-item-c"}> | ||
<div className="jw-shareobj-item-c-name ellipsis">{curItemName}</div> | ||
@@ -205,8 +205,8 @@ <div className="jw-shareobj-item-c-tip"></div> | ||
</div>) | ||
} else if(socialobj.type == 'jw_n_brand'||socialobj.type == 'jw_n_office'||socialobj.type == 'jw_n_personnel_category'||socialobj.type == 'jw_n_function_level'||socialobj.type == 'jw_n_personnel_group'||socialobj.type == 'jw_n_assign_category'||socialobj.type == 'jw_n_store_category'||socialobj.type == 'jw_n_teamtype'||socialobj.type == 'jw_n_region_category'){ | ||
} else if (socialobj.type == 'jw_n_brand' || socialobj.type == 'jw_n_office' || socialobj.type == 'jw_n_personnel_category' || socialobj.type == 'jw_n_function_level' || socialobj.type == 'jw_n_personnel_group' || socialobj.type == 'jw_n_assign_category' || socialobj.type == 'jw_n_store_category' || socialobj.type == 'jw_n_teamtype' || socialobj.type == 'jw_n_region_category') { | ||
return (<div className={"jw-shareobj-item-w " + socialobj.type} data-action-val={socialobj["name"]} data-action-id={socialobj["id"]}> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype&&socialobj.dtype==1 ? jwimgsrc + '/images/jw-img/share/group.png' : jwimgsrc + '/images/jw-img/share/position.png'} /> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype && socialobj.dtype == 1 ? jwimgsrc + '/images/jw-img/share/group.png' : jwimgsrc + '/images/jw-img/share/position.png'} /> | ||
</div> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" : "jw-shareobj-item-c"}> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" : "jw-shareobj-item-c"}> | ||
<div className="jw-shareobj-item-c-name ellipsis">{curItemName}</div> | ||
@@ -216,8 +216,8 @@ <div className="jw-shareobj-item-c-tip"></div> | ||
</div>) | ||
}else if (socialobj.type == 'jw_n_area') { | ||
} else if (socialobj.type == 'jw_n_area') { | ||
return (<div className={"jw-shareobj-item-w " + socialobj.type} data-action-val={socialobj["name"]} data-action-id={socialobj["id"]}> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype&&socialobj.dtype==1 ? jwimgsrc + '/images/jw-img/share/group.png' :jwimgsrc + '/images/jw-img/share/area.png'} /> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? 'hide' : "jw-shareobj-item-pic"}> | ||
<img src={socialobj.dtype && socialobj.dtype == 1 ? jwimgsrc + '/images/jw-img/share/group.png' : jwimgsrc + '/images/jw-img/share/area.png'} /> | ||
</div> | ||
<div className={socialobj.dtype&&socialobj.dtype==2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" :"jw-shareobj-item-c "}> | ||
<div className={socialobj.dtype && socialobj.dtype == 2 ? "jw-shareobj-item-c jw-shareobj-item-c-margin" : "jw-shareobj-item-c "}> | ||
<div className="jw-shareobj-item-c-name ellipsis">{curItemName}</div> | ||
@@ -241,11 +241,15 @@ <div className="jw-shareobj-item-c-tip"></div> | ||
turnData(data) { | ||
// console.log("turnData:::",data) | ||
console.log("turnData:::", data); | ||
console.log("12312312"); | ||
return data.map(function (i) { | ||
return _.extend(i,{ | ||
return _.extend(i, { | ||
id: i.id, | ||
key: i.id+(i.show_name || i.name ||''), | ||
key: i.id + (i.show_name || i.name || ''), | ||
// key: generateMixed(16), | ||
label: i.show_name || i.name ||' ', //禁止删除后面空格 当传来数据错误时进行容错处理 | ||
label: i.show_name || i.name || ' ', //禁止删除后面空格 当传来数据错误时进行容错处理 | ||
type: i.type, | ||
name: i.name||'', | ||
name: i.name || '', | ||
show_name: i.show_name || i.name || '' | ||
@@ -264,3 +268,3 @@ }) | ||
onSearch: this.fetchData, | ||
notFoundContent: (this.props.removeInput==true ? '' :(fetching ? <Spin size="small" /> : <div className="base-share-empty">{COMPONENT_DICT('label.business.shareobj.nodata')}</div>)), | ||
notFoundContent: (this.props.removeInput == true ? '' : (fetching ? <Spin size="small" /> : <div className="base-share-empty">{COMPONENT_DICT('label.business.shareobj.nodata')}</div>)), | ||
filterOption: false, | ||
@@ -271,14 +275,14 @@ getPopupContainer: () => { | ||
}, this.props, { | ||
labelInValue:true, | ||
value: value, | ||
onChange: (e) => { }, | ||
onDeselect: (e) => this.removeChange(e), | ||
onSelect: (e) => this.selectChange(e), | ||
}) | ||
labelInValue: true, | ||
value: value, | ||
onChange: (e) => { }, | ||
onDeselect: (e) => this.removeChange(e), | ||
onSelect: (e) => this.selectChange(e), | ||
}) | ||
this.originShareobj = $.extend(true,[],this.props.shareobj||[]); | ||
this.originShareobj = $.extend(true, [], this.props.shareobj || []); | ||
return (<div className="jw-shareobj" id={this.shareobjId}> | ||
<div className={this.props.container || this.state.containerId}></div> | ||
<Select dropdownClassName={"jw-shareobj-select " + (this.props.removeInput!=undefined&&this.props.removeInput ? 'jw-shareobj-select-romove' : '')} {...datas}> | ||
{data.map(function (d,index) { | ||
<Select dropdownClassName={"jw-shareobj-select " + (this.props.removeInput != undefined && this.props.removeInput ? 'jw-shareobj-select-romove' : '')} {...datas}> | ||
{data.map(function (d, index) { | ||
return <Option key={d.key} className={"jw-shareobj-item " + (d['type'] == 'sep' ? 'jw-shareobj-item-sep ' : '')} disabled={d['type'] == 'sep' ? true : false} value={d.key} title={d.name}>{self._combineOne(d)}</Option> | ||
@@ -290,12 +294,12 @@ // return <Option key={d.key} className={"jw-shareobj-item " + (d['type'] == 'sep' ? 'jw-shareobj-item-sep ' : '')+(d['name'] == ''|| d['name'] == undefined ? 'hide' : '')} disabled={d['type'] == 'sep' ? true : false} value={d.key} title={d.name}>{self._combineOne(d)}</Option> | ||
} | ||
removInput(){ | ||
removInput() { | ||
let self = this; | ||
setTimeout(function(){ | ||
$("#"+self.shareobjId+" .ant-select-search .ant-select-search__field").attr('disabled',true) | ||
setTimeout(function () { | ||
$("#" + self.shareobjId + " .ant-select-search .ant-select-search__field").attr('disabled', true) | ||
}) | ||
} | ||
componentWillReceiveProps(nextProps){ | ||
componentWillReceiveProps(nextProps) { | ||
let self = this; | ||
let newData = this.turnData(nextProps['shareobj']); | ||
if(nextProps.placeholder !== this.state.placeholder || JSON.stringify(newData) !== JSON.stringify(this.state.shareobj)){ | ||
if (nextProps.placeholder !== this.state.placeholder || JSON.stringify(newData) !== JSON.stringify(this.state.shareobj)) { | ||
this.setState({ | ||
@@ -307,6 +311,6 @@ data: newData, | ||
shareobj: newData, | ||
removeInput: nextProps.removeInput!=undefined ? nextProps.removeInput : false | ||
removeInput: nextProps.removeInput != undefined ? nextProps.removeInput : false | ||
}); | ||
this.originShareobj = $.extend(true,[],nextProps.shareobj||[]); | ||
if(nextProps.removeInput!=undefined&&nextProps.removeInput==true){ | ||
this.originShareobj = $.extend(true, [], nextProps.shareobj || []); | ||
if (nextProps.removeInput != undefined && nextProps.removeInput == true) { | ||
self.removInput(); | ||
@@ -346,5 +350,5 @@ } | ||
componentDidMount() { | ||
this.originShareobj = $.extend(true,[],this.props.shareobj||[]); | ||
this.originShareobj = $.extend(true, [], this.props.shareobj || []); | ||
this.originPlaceholder = this.props.placeholder; | ||
if(this.props.removeInput!=undefined&&this.props.removeInput==true){ | ||
if (this.props.removeInput != undefined && this.props.removeInput == true) { | ||
this.removInput(); | ||
@@ -351,0 +355,0 @@ } |
120
gulpfile.js
@@ -9,7 +9,7 @@ 'use strict'; | ||
let less = require('gulp-less'); | ||
let babel=require('gulp-babel'); | ||
let babel = require('gulp-babel'); | ||
let concat = require('gulp-concat'); // 合并文件 | ||
let rename = require('gulp-rename'); // 重命名 | ||
let autoprefixer = require('gulp-autoprefixer'); | ||
const fs = require('fs'); | ||
const fs = require('fs'); | ||
const iconfont = require('gulp-iconfont'); | ||
@@ -21,76 +21,76 @@ const consolidate = require('gulp-consolidate') | ||
function mapGlyphs (glyph) { | ||
console.log(glyph,'asdasdasd'); | ||
return { fileName: glyph.name, codePoint: glyph.unicode[0].charCodeAt(0).toString(16).toUpperCase(),color:glyph['color']} | ||
function mapGlyphs(glyph) { | ||
console.log(glyph, 'asdasdasd'); | ||
return { fileName: glyph.name, codePoint: glyph.unicode[0].charCodeAt(0).toString(16).toUpperCase(), color: glyph['color'] } | ||
} | ||
gulp.task('svg',function(done){ | ||
gulp.task('svg', function (done) { | ||
return gulp.src('components/**/icons/**') | ||
.pipe(through.obj(function(file,enc,cb){ | ||
.pipe(through.obj(function (file, enc, cb) { | ||
let name = file.relative.split('/')[0]; | ||
let fontName = name | ||
gulp.src(`components/${name}/icons/*.svg`) | ||
.pipe(iconfont({ | ||
fontName: fontName, | ||
prependUnicode:false, | ||
formats:['svg', 'ttf', 'eot', 'woff', 'woff2'], | ||
normalize:true, | ||
fontHeight:1000, | ||
timestamp | ||
})) | ||
.on('glyphs', function(glyphs) { | ||
const options = { | ||
fontName:fontName, | ||
cssClass:fontName+'-icon', | ||
fontPath:'http://10.211.55.15/test/fontsize/'+fontName+'/', | ||
glyphs: glyphs.map(mapGlyphs) | ||
} | ||
gulp.src('template/_icons.css') | ||
.pipe(consolidate('lodash', options)) | ||
.pipe(rename({ basename: 'icons' })) | ||
.pipe(gulp.dest(`components/${name}/style/`)) | ||
.pipe(gulp.dest(`lib/${name}/style/`)) | ||
}) | ||
.pipe(gulp.dest(`components/${name}/font`)) | ||
.pipe(gulp.dest(`lib/${name}/font`)) | ||
.pipe(gulp.dest(`allfont/${name}/`)); | ||
.pipe(iconfont({ | ||
fontName: fontName, | ||
prependUnicode: false, | ||
formats: ['svg', 'ttf', 'eot', 'woff', 'woff2'], | ||
normalize: true, | ||
fontHeight: 1000, | ||
timestamp | ||
})) | ||
.on('glyphs', function (glyphs) { | ||
const options = { | ||
fontName: fontName, | ||
cssClass: fontName + '-icon', | ||
fontPath: 'http://10.211.55.15/test/fontsize/' + fontName + '/', | ||
glyphs: glyphs.map(mapGlyphs) | ||
} | ||
gulp.src('template/_icons.css') | ||
.pipe(consolidate('lodash', options)) | ||
.pipe(rename({ basename: 'icons' })) | ||
.pipe(gulp.dest(`components/${name}/style/`)) | ||
.pipe(gulp.dest(`lib/${name}/style/`)) | ||
}) | ||
.pipe(gulp.dest(`components/${name}/font`)) | ||
.pipe(gulp.dest(`lib/${name}/font`)) | ||
.pipe(gulp.dest(`allfont/${name}/`)); | ||
})) | ||
}) | ||
gulp.task('copy',function(){ | ||
gulp.task('copy', function () { | ||
return gulp.src('lib/**') | ||
.pipe(gulp.dest('../jw-appmaker/node_modules/joywok-business-components/lib/')); | ||
.pipe(gulp.dest('../joywok-web/node_modules/joywok-business-components/lib/')); | ||
}) | ||
gulp.task('publicLess', function () { | ||
gulp.src(['../../node_modules/antd/dist/antd.css','components/style/jw-components.css']) | ||
.pipe(concat('jw-components.css')) | ||
.pipe(gulp.dest('dist')); | ||
gulp.src(['../../node_modules/antd/dist/antd.css', 'components/style/jw-components.css']) | ||
.pipe(concat('jw-components.css')) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
gulp.task('js',()=>{ | ||
gulp.task('js', () => { | ||
return gulp.src('components/**/*.js') | ||
.pipe(babel()) | ||
.pipe(gulp.dest("lib")) | ||
.pipe(gulp.dest('../jw-appmaker/node_modules/joywok-business-components/lib/')); | ||
.pipe(babel()) | ||
.pipe(gulp.dest("lib")) | ||
.pipe(gulp.dest('../joywok-web/node_modules/joywok-business-components/lib/')); | ||
}) | ||
gulp.task('css', ()=>{ | ||
gulp.task('css', () => { | ||
// 编译css | ||
var sass = require('gulp-ruby-sass'); | ||
return sass(['components/**/*.scss'],{ | ||
style: 'expanded', | ||
precision: 10 | ||
}) | ||
.pipe(autoprefixer({ | ||
browsers: ['last 2 versions','Android >= 4.0'], | ||
cascade: true, | ||
remove: true | ||
})) | ||
.on('error', console.error.bind(console)) | ||
.pipe(gulp.dest('components/')) | ||
.pipe(gulp.dest('lib/')) | ||
.pipe(gulp.dest('../jw-appmaker/node_modules/joywok-business-components/lib/')); | ||
return sass(['components/**/*.scss'], { | ||
style: 'expanded', | ||
precision: 10 | ||
}) | ||
.pipe(autoprefixer({ | ||
browsers: ['last 2 versions', 'Android >= 4.0'], | ||
cascade: true, | ||
remove: true | ||
})) | ||
.on('error', console.error.bind(console)) | ||
.pipe(gulp.dest('components/')) | ||
.pipe(gulp.dest('lib/')) | ||
.pipe(gulp.dest('../joywok-web/node_modules/joywok-business-components/lib/')); | ||
}); | ||
// 压缩图片 | ||
gulp.task('img',()=>{ | ||
gulp.task('img', () => { | ||
return gulp.src('components/**/images/*') | ||
.pipe(imagemin({ | ||
progressive: true, | ||
svgoPlugins: [{removeViewBox: false}], | ||
svgoPlugins: [{ removeViewBox: false }], | ||
use: [pngquant()] | ||
@@ -100,6 +100,6 @@ })) | ||
}) | ||
gulp.task('default',["publicLess","css","js",'img','copy'],function(){ | ||
gulp.watch(['components/**/*.scss'],["css"]); | ||
gulp.watch(['components/**/*.js'],["js"]); | ||
gulp.watch(['components/**/icons/*.svg'],["svg",'copy']); | ||
gulp.task('default', ["publicLess", "css", "js", 'img', 'copy'], function () { | ||
gulp.watch(['components/**/*.scss'], ["css"]); | ||
gulp.watch(['components/**/*.js'], ["js"]); | ||
gulp.watch(['components/**/icons/*.svg'], ["svg", 'copy']); | ||
}); | ||
@@ -106,0 +106,0 @@ |
@@ -59,3 +59,3 @@ 'use strict'; | ||
'label.no.object.selected': '未选择对象', | ||
'label.objselect-unselect-all': '取消全部选择', | ||
'label.objselect-unselect-all': '取消本次选择', | ||
'label.business.shareobj.business.scenario': '业务场景' | ||
@@ -62,0 +62,0 @@ |
@@ -39,16 +39,2 @@ 'use strict'; | ||
var _reactDom = require('react-dom'); | ||
var _reactDom2 = _interopRequireDefault(_reactDom); | ||
var _redux = require('redux'); | ||
var _reactRedux = require('react-redux'); | ||
var _dva = require('dva'); | ||
var _request = require('./../utils/request'); | ||
var _request2 = _interopRequireDefault(_request); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -99,2 +85,3 @@ | ||
// import Button from './../button/index'; | ||
require('./style/Index.css'); | ||
@@ -108,3 +95,2 @@ | ||
// console.log(props,'123123123123'); | ||
var _this = _possibleConstructorReturn(this, (MapContainer.__proto__ || Object.getPrototypeOf(MapContainer)).call(this, props)); | ||
@@ -116,3 +102,4 @@ | ||
name: '', | ||
lang: 'zh' | ||
lang: 'zh', | ||
key: '544c827260b7a6b6712093039958f873' | ||
}, props.data, props); | ||
@@ -136,6 +123,10 @@ _this.time = null; | ||
}); | ||
_message3.default.loading('正在获取相关数据…'); | ||
_message3.default.destroy(); | ||
// message.loading('正在获取相关数据…') | ||
// message.loading('正在获取数据…') | ||
_message3.default.loading(i18n('label.portal.event.get.mapdata')); | ||
this["geocoder_" + this.state.lang].getAddress([lng, lat], function (status, result) { | ||
_message3.default.destroy(); | ||
if (status === 'complete' && result.info === 'OK') { | ||
console.log('result---', result); | ||
// result为对应的地理位置详细信息 | ||
@@ -156,2 +147,3 @@ var data = Object.assign({}, { | ||
aois: result.regeocode['aois'], | ||
pois: result.regeocode['pois'], | ||
name: result.regeocode['formattedAddress'] | ||
@@ -166,8 +158,57 @@ }); | ||
var self = this; | ||
this.props.events.emit('save', { | ||
name: self.state.name, | ||
aois: self.state.aois, | ||
detail_address: self.state.detail_address | ||
}); | ||
this.props.events.emit('cancel'); | ||
var _state = this.state, | ||
lang = _state.lang, | ||
aois = _state.aois, | ||
pois = _state.pois; | ||
if (aois && aois[0] || pois && pois[0]) { | ||
// message.loading('正在获取地址数据…'); | ||
_message3.default.loading(i18n('label.portal.event.get.address.data')); | ||
AMap.plugin('AMap.PlaceSearch', function () { | ||
var placeSearch = new AMap.PlaceSearch({ | ||
lang: lang == 'zh' ? "en" : "zh_cn" | ||
}); | ||
// 对应的POI ID | ||
var poiid = aois && aois[0] ? aois[0]['id'] : pois[0]['id']; | ||
placeSearch.getDetails(poiid, function (status, result) { | ||
_message3.default.destroy(); | ||
if (status === 'complete' && result.info === 'OK') { | ||
// 查询成功时,result即为对应的POI详情 | ||
var resData = result.poiList && result.poiList.pois[0]; | ||
var detailAddress = self.state.detail_address; | ||
var curLangData = { | ||
name: detailAddress['location'], | ||
address: detailAddress['location_name'], | ||
latitude: detailAddress['latitude'], | ||
longitude: detailAddress['longitude'], | ||
"type": "geo" | ||
}; | ||
var curLangD = { | ||
name: resData && resData['name'], | ||
address: resData && resData['address'], | ||
latitude: detailAddress['latitude'], | ||
longitude: detailAddress['longitude'], | ||
"type": "geo" | ||
}; | ||
var detailData = {}; | ||
if (lang == "zh") { | ||
detailData['zh'] = curLangData; | ||
detailData['en'] = curLangD; | ||
} else { | ||
detailData['en'] = curLangData; | ||
detailData['zh'] = curLangD; | ||
} | ||
self.props.events.emit('save', { | ||
name: self.state.name, | ||
aois: self.state.aois, | ||
detail_address: self.state.detail_address, | ||
detailData: detailData | ||
}); | ||
self.props.events.emit('cancel'); | ||
} | ||
}); | ||
}); | ||
} else { | ||
self.props.events.emit('cancel'); | ||
} | ||
} | ||
@@ -194,3 +235,5 @@ }, { | ||
if (e.poi['id'].length == 0) { | ||
_message3.default.error('没有获取到搜索的位置', 2); | ||
// message.error('没有获取到搜索的位置',2); | ||
// message.error('未找到您搜索的位置',2); | ||
_message3.default.error(i18n('label.event.noposition'), 2); | ||
return; | ||
@@ -200,2 +243,3 @@ } | ||
self.map.panTo([e.poi['location']['lng'], e.poi['location']['lat']]); | ||
clearTimeout(self.time); | ||
self.time = setTimeout(function () { | ||
@@ -208,2 +252,3 @@ self.combineMapLocation(e.poi['location']['lng'], e.poi['location']['lat']); | ||
self.map.on('click', function (e) { | ||
clearTimeout(self.time); | ||
self.time = setTimeout(function () { | ||
@@ -251,3 +296,4 @@ self.combineMapLocation(e['lnglat']['lng'], e['lnglat']['lat']); | ||
script.type = "text/javascript"; | ||
script.src = 'https://webapi.amap.com/maps?v=1.4.15&key=0dfc4d46208fc4478eadb34410fba73b&plugin=AMap.Geocoder,AMap.ToolBar,AMap.Autocomplete,AMap.PlaceSearch'; | ||
// script.src='https://webapi.amap.com/maps?v=1.4.15&key=0dfc4d46208fc4478eadb34410fba73b&plugin=AMap.Geocoder,AMap.ToolBar,AMap.Autocomplete,AMap.PlaceSearch'; | ||
script.src = 'https://webapi.amap.com/maps?v=1.4.15&key=' + this.state.key + '&plugin=AMap.Geocoder,AMap.ToolBar,AMap.Autocomplete,AMap.PlaceSearch,AMap.CitySearch'; | ||
script.class = 'hahaha'; | ||
@@ -268,2 +314,3 @@ document.body.appendChild(script); | ||
// 有经纬度,就用经纬度渲染。没有经纬度,就通过详细地址获取经纬度后再做渲染 | ||
var errormsg = ''; | ||
if (longitude && latitude && longitude != "" && latitude != "") { | ||
@@ -292,2 +339,3 @@ self.map = new AMap.Map('map-container', { | ||
// 查询成功,result即为当前所在城市信息 | ||
console.log(result, '这个位置是什么啊'); | ||
self.combineMapPlugin(); | ||
@@ -297,3 +345,8 @@ // self.combineMapLocation(data.position.lng,data.position.lat); | ||
} else { | ||
_message3.default.error('没有获取到当前城市', 2); | ||
_message3.default.destory(); | ||
// errormsg = '没有获取到当前城市'; | ||
// message.error('没有获取到当前城市',2); | ||
// message.error('未获取到当前城市信息',2); | ||
_message3.default.error(i18n('label.portal.event.nocity'), 2); | ||
return; | ||
} | ||
@@ -306,10 +359,12 @@ }); | ||
enableHighAccuracy: true, //是否使用高精度定位,默认:true | ||
timeout: 10000, //超过10秒后停止定位,默认:5s | ||
buttonPosition: 'RB', //定位按钮的停靠位置 | ||
// timeout: 10000, //超过10秒后停止定位,默认:5s | ||
// buttonPosition:'RB', //定位按钮的停靠位置 | ||
buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20) | ||
zoomToAccuracy: true //定位成功后是否自动调整地图视野到定位点 | ||
zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点 | ||
GeoLocationFirst: true | ||
}); | ||
console.log("geolocation::::", geolocation.getCurrentPosition()); | ||
self.map.addControl(geolocation); | ||
geolocation.getCurrentPosition(); | ||
// geolocation.getCurrentPosition(); | ||
geolocation.getCityInfo(); | ||
AMap.event.addListener(geolocation, 'complete', onComplete); | ||
@@ -322,4 +377,17 @@ AMap.event.addListener(geolocation, 'error', onError); | ||
} | ||
function onError() { | ||
_message3.default.error('没有获取到当前位置', 2); | ||
function onError(error) { | ||
_message3.default.destroy(); | ||
var citySearch = new AMap.CitySearch({ lang: self.state.lang }); | ||
citySearch.getLocalCity(function (status, result) { | ||
if (status === 'complete' && result.info === 'OK') { | ||
console.log(result, '这个位置是什么啊'); | ||
self.map.setBounds(result.bounds); | ||
} else { | ||
_message3.default.error(i18n('label.portal.event.nocity'), 2); | ||
return; | ||
} | ||
}); | ||
_message3.default.error(error && error.message, 2); | ||
return; | ||
} | ||
@@ -363,3 +431,6 @@ }); | ||
} else { | ||
_message3.default.error('没有找到相应的经纬度', 2); | ||
// message.error('没有找到相应的经纬度',2); | ||
// message.error('未找到相应的经纬度',2); | ||
_message3.default.error(i18n('label.portal.event.nolanglan'), 2); | ||
return; | ||
} | ||
@@ -395,3 +466,3 @@ } | ||
{ className: 'jw-map-search' }, | ||
_react2.default.createElement(_input2.default, { placeholder: '\u641C\u7D22', id: 'tipinput' }) | ||
_react2.default.createElement(_input2.default, { placeholder: i18n('label.biportal-placeholder'), id: 'tipinput' }) | ||
), | ||
@@ -415,3 +486,3 @@ this.state.loading ? _react2.default.createElement( | ||
} }, | ||
'\u53D6\u6D88' | ||
i18n('btn.cancel') | ||
), | ||
@@ -423,3 +494,3 @@ _react2.default.createElement( | ||
} }, | ||
'\u786E\u5B9A' | ||
i18n('btn.ok') | ||
) | ||
@@ -430,6 +501,11 @@ ), | ||
{ className: 'jw-map-address' }, | ||
'\u8BE6\u7EC6\u5730\u5740\uFF1A', | ||
_react2.default.createElement( | ||
'span', | ||
null, | ||
'div', | ||
{ className: 'jw-map-address-tip' }, | ||
i18n('label.console.iam.dAddress'), | ||
'\uFF1A' | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'jw-map-address-value ellipsis', title: this.state.name && this.state.name.length != 0 ? this.state.name : newName == 'NaN' ? '' : newName }, | ||
this.state.name && this.state.name.length != 0 ? this.state.name : newName == 'NaN' ? '' : newName | ||
@@ -436,0 +512,0 @@ ) |
@@ -377,3 +377,5 @@ 'use strict'; | ||
value: function turnData(data) { | ||
// console.log("turnData:::",data) | ||
console.log("turnData:::", data); | ||
console.log("12312312"); | ||
return data.map(function (i) { | ||
@@ -380,0 +382,0 @@ return _.extend(i, { |
{ | ||
"name": "joywok-business-components", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1091925
21461