|
|
@ -2,15 +2,15 @@ |
|
|
|
<el-card class="form-container" shadow="never"> |
|
|
|
<el-form :model="community" :rules="rules" ref="communityFrom" label-width="130px"> |
|
|
|
|
|
|
|
<el-form-item label="社区名称:" > |
|
|
|
<el-form-item label="社区名称:"> |
|
|
|
|
|
|
|
<span>{{name}}</span> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="取货点名称:" prop="name"> |
|
|
|
<el-input v-model="community.name"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="取货点电话:" prop="counts"> |
|
|
|
<el-input v-model="community.counts"></el-input> |
|
|
|
<el-form-item label="取货点电话:" prop="phone"> |
|
|
|
<el-input v-model="community.phone" maxlength="11"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="取货点地址:" prop="details"> |
|
|
|
<el-input v-model="community.details"></el-input> |
|
|
@ -61,12 +61,12 @@ |
|
|
|
</el-card> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import BaiduMap from 'vue-baidu-map/components/map/Map.vue' |
|
|
|
import BmLocalSearch from 'vue-baidu-map/components/search/LocalSearch'; |
|
|
|
import BmCityList from 'vue-baidu-map/components/controls/CityList'; |
|
|
|
import BmCopyright from 'vue-baidu-map/components/controls/Copyright'; |
|
|
|
import BmView from 'vue-baidu-map/components/map/MapView'; |
|
|
|
import BmMarker from 'vue-baidu-map/components/overlays/Marker' |
|
|
|
// import BaiduMap from 'vue-baidu-map/components/map/Map.vue' |
|
|
|
// import BmLocalSearch from 'vue-baidu-map/components/search/LocalSearch'; |
|
|
|
// import BmCityList from 'vue-baidu-map/components/controls/CityList'; |
|
|
|
// import BmCopyright from 'vue-baidu-map/components/controls/Copyright'; |
|
|
|
// import BmView from 'vue-baidu-map/components/map/MapView'; |
|
|
|
// import BmMarker from 'vue-baidu-map/components/overlays/Marker' |
|
|
|
import { |
|
|
|
createCommunity, |
|
|
|
getCommunity, |
|
|
@ -81,15 +81,15 @@ |
|
|
|
}; |
|
|
|
export default { |
|
|
|
name: 'CommunityDetail', |
|
|
|
components: { |
|
|
|
SingleUpload, |
|
|
|
BaiduMap, |
|
|
|
BmLocalSearch, |
|
|
|
BmCityList, |
|
|
|
BmView, |
|
|
|
BmCopyright, |
|
|
|
BmMarker |
|
|
|
}, |
|
|
|
// components: { |
|
|
|
// SingleUpload, |
|
|
|
// BaiduMap, |
|
|
|
// BmLocalSearch, |
|
|
|
// BmCityList, |
|
|
|
// BmView, |
|
|
|
// BmCopyright, |
|
|
|
// BmMarker |
|
|
|
// }, |
|
|
|
props: { |
|
|
|
isEdit: { |
|
|
|
type: Boolean, |
|
|
@ -97,6 +97,21 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
data() { |
|
|
|
var checkSubmit = (rule, value, callback) => { |
|
|
|
const Submit = |
|
|
|
/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/ |
|
|
|
if (value) { |
|
|
|
if (!Submit.test(value)) { |
|
|
|
callback(new Error('手机号格式不正确')) |
|
|
|
} |
|
|
|
callback() |
|
|
|
} |
|
|
|
callback() |
|
|
|
// if (Submit.test(value)) { |
|
|
|
// return callback() |
|
|
|
// } |
|
|
|
// callback(new Error('请输入手机号')) |
|
|
|
} |
|
|
|
return { |
|
|
|
name: "", |
|
|
|
community: Object.assign({}, defaultCommunity), |
|
|
@ -112,15 +127,20 @@ |
|
|
|
message: '长度在 2 到 140 个字符', |
|
|
|
trigger: 'blur' |
|
|
|
} |
|
|
|
] |
|
|
|
}, |
|
|
|
location: '北京', |
|
|
|
keyword: '百度', |
|
|
|
center: { |
|
|
|
lng: 116.404, |
|
|
|
lat: 39.915 |
|
|
|
], |
|
|
|
phone: [{ |
|
|
|
required: true, |
|
|
|
validator: checkSubmit, |
|
|
|
trigger: 'blur' |
|
|
|
}] |
|
|
|
}, |
|
|
|
zoom: 15 |
|
|
|
// location: '北京', |
|
|
|
// keyword: '百度', |
|
|
|
// center: { |
|
|
|
// lng: 116.404, |
|
|
|
// lat: 39.915 |
|
|
|
// }, |
|
|
|
// zoom: 15 |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
@ -129,21 +149,21 @@ |
|
|
|
// window.addEventListener('mousewheel',this.handleScroll,false) |
|
|
|
}, |
|
|
|
created() { |
|
|
|
console.log("query>>>",this.$route.query) |
|
|
|
console.log("query>>>", this.$route.query) |
|
|
|
this.name = this.$route.query.cname |
|
|
|
|
|
|
|
if (this.isEdit) { |
|
|
|
getCommunity(this.$route.query.id).then(response => { |
|
|
|
this.community = response.data; |
|
|
|
if (this.community.latitude) { |
|
|
|
this.center.lat = this.community.latitude; |
|
|
|
} |
|
|
|
if (this.community.longitude) { |
|
|
|
this.center.lng = this.community.longitude; |
|
|
|
} |
|
|
|
if (this.community.city) { |
|
|
|
this.location = this.community.city; |
|
|
|
} |
|
|
|
// if (this.community.latitude) { |
|
|
|
// this.center.lat = this.community.latitude; |
|
|
|
// } |
|
|
|
// if (this.community.longitude) { |
|
|
|
// this.center.lng = this.community.longitude; |
|
|
|
// } |
|
|
|
// if (this.community.city) { |
|
|
|
// this.location = this.community.city; |
|
|
|
// } |
|
|
|
}); |
|
|
|
} else { |
|
|
|
this.community = Object.assign({}, defaultCommunity); |
|
|
@ -151,24 +171,42 @@ |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
changeAfters(e) { |
|
|
|
console.log('123') |
|
|
|
console.log(e) |
|
|
|
}, |
|
|
|
handleScroll(e) { |
|
|
|
//修复body高度为100%,百度地图鼠标滚轮滚动产生位移问题,以及全景鼠标hover后未显示全景信息问题 |
|
|
|
document.body.scrollTop = 0 |
|
|
|
document.documentElement.scrollTop = 0 |
|
|
|
}, |
|
|
|
syncCenterAndZoom(e) { |
|
|
|
// changeAfters(e) { |
|
|
|
// console.log('123') |
|
|
|
// console.log(e) |
|
|
|
// }, |
|
|
|
// handleScroll(e) { |
|
|
|
// //修复body高度为100%,百度地图鼠标滚轮滚动产生位移问题,以及全景鼠标hover后未显示全景信息问题 |
|
|
|
// document.body.scrollTop = 0 |
|
|
|
// document.documentElement.scrollTop = 0 |
|
|
|
// }, |
|
|
|
// syncCenterAndZoom(e) { |
|
|
|
|
|
|
|
const { |
|
|
|
lng, |
|
|
|
lat |
|
|
|
} = e.target.getCenter() |
|
|
|
this.center.lng = lng |
|
|
|
this.center.lat = lat |
|
|
|
this.zoom = e.target.getZoom() |
|
|
|
// const { |
|
|
|
// lng, |
|
|
|
// lat |
|
|
|
// } = e.target.getCenter() |
|
|
|
// this.center.lng = lng |
|
|
|
// this.center.lat = lat |
|
|
|
// this.zoom = e.target.getZoom() |
|
|
|
// }, |
|
|
|
UpNumber(val, limit = 2) { |
|
|
|
val = val.replace(/[^\d]/g, '') // 保留数字 |
|
|
|
val = val.replace(/^00/, '0.') // 开头不能有两个0 |
|
|
|
val = val.replace(/^\./g, '0.') // 开头为小数点转换为0. |
|
|
|
val = val.replace(/\.{2,}/g, '.') // 两个以上的小数点转换成一个 |
|
|
|
val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); // 只保留一个小数点 |
|
|
|
/^0\d+/.test(val) ? val = val.slice(1) : '' // 两位以上数字开头不能为0 |
|
|
|
const str = '^(\\d+)\\.(\\d{' + limit + '}).*$' |
|
|
|
const reg = new RegExp(str) |
|
|
|
if (limit === 0) { |
|
|
|
// 不需要小数点 |
|
|
|
val = val.replace(reg, '$1') |
|
|
|
} else { |
|
|
|
// 通过正则保留小数点后指定的位数 |
|
|
|
val = val.replace(reg, '$1.$2') |
|
|
|
} |
|
|
|
return val |
|
|
|
}, |
|
|
|
onSubmit(formName) { |
|
|
|
this.$refs[formName].validate((valid) => { |
|
|
@ -179,8 +217,8 @@ |
|
|
|
type: 'warning' |
|
|
|
}).then(() => { |
|
|
|
this.community.companyId = this.$route.query.cid |
|
|
|
this.community.latitude = this.center.lat; |
|
|
|
this.community.longitude = this.center.lng; |
|
|
|
// this.community.latitude = this.center.lat; |
|
|
|
// this.community.longitude = this.center.lng; |
|
|
|
if (this.isEdit) { |
|
|
|
updateCommunity(this.$route.query.id, this.community).then(response => { |
|
|
|
if (response.code == 200) { |
|
|
@ -190,7 +228,7 @@ |
|
|
|
type: 'success', |
|
|
|
duration: 1000 |
|
|
|
}); |
|
|
|
this.$router.back(); |
|
|
|
this.$router.go(-1); |
|
|
|
} else { |
|
|
|
this.$message({ |
|
|
|
message: response.msg, |
|
|
@ -210,7 +248,7 @@ |
|
|
|
type: 'success', |
|
|
|
duration: 1000 |
|
|
|
}); |
|
|
|
this.$router.back(); |
|
|
|
this.$router.go(-1); |
|
|
|
} else { |
|
|
|
this.$message({ |
|
|
|
message: response.msg, |
|
|
|