Browse Source

需求2

master
jiangyy 3 years ago
parent
commit
b23c3e92df
  1. 66
      src/views/modules/shequzhili/csgltc/csgl.vue
  2. 19
      src/views/modules/shequzhili/csgltc/csglDetail.vue
  3. 53
      src/views/modules/shequzhili/csgltc/csglForm.vue
  4. 70
      src/views/modules/shequzhili/ggfwtc/ggfw.vue
  5. 339
      src/views/modules/shequzhili/ggfwtc/ggfwDetail.vue
  6. 648
      src/views/modules/shequzhili/ggfwtc/ggfwForm.vue

66
src/views/modules/shequzhili/csgltc/csgl.vue

@ -118,10 +118,24 @@
label="地址"
mix-width="230">
</el-table-column>
<el-table-column prop="principal"
header-align="center"
align="center"
show-overflow-tooltip
label="负责人"
width="100">
</el-table-column>
<el-table-column prop="mobile"
header-align="center"
align="center"
show-overflow-tooltip
label="联系电话"
width="130">
</el-table-column>
<el-table-column label="操作"
fixed="right"
width="250"
width="200"
header-align="center"
align="center"
class="operate">
@ -270,31 +284,31 @@ export default {
responseType: "blob",
data: params,
})
.then((res) => {
// this.download(res.data, title + '.xls')
if (res.headers["content-disposition"]) {
let fileName = window.decodeURI(
res.headers["content-disposition"].split(";")[1].split("=")[1]
);
console.log("filename", fileName);
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel",
});
var url = window.URL.createObjectURL(blob);
var aLink = document.createElement("a");
aLink.style.display = "none";
aLink.href = url;
aLink.setAttribute("download", fileName);
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink); //
window.URL.revokeObjectURL(url); //blob
} else this.$message.error("下载失败");
})
.catch((err) => {
console.log("err", err);
return this.$message.error("网络错误");
});
.then((res) => {
// this.download(res.data, title + '.xls')
if (res.headers["content-disposition"]) {
let fileName = window.decodeURI(
res.headers["content-disposition"].split(";")[1].split("=")[1]
);
console.log("filename", fileName);
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel",
});
var url = window.URL.createObjectURL(blob);
var aLink = document.createElement("a");
aLink.style.display = "none";
aLink.href = url;
aLink.setAttribute("download", fileName);
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink); //
window.URL.revokeObjectURL(url); //blob
} else this.$message.error("下载失败");
})
.catch((err) => {
console.log("err", err);
return this.$message.error("网络错误");
});
},
//

19
src/views/modules/shequzhili/csgltc/csglDetail.vue

@ -35,13 +35,26 @@
style="display: block">
<span>{{formData.capacity}}</span>
</el-form-item>
<el-form-item label="负责人:"
prop="principal"
label-width="150px"
style="display: block">
<span>{{formData.principal}}</span>
</el-form-item>
<el-form-item label="联系电话:"
prop="mobile"
label-width="150px"
style="display: block">
<span>{{formData.mobile}}</span>
</el-form-item>
<el-form-item label="地址:"
style="display: block"
prop="address"
label-width="150px">
<div class="item_width_1">
<span>{{formData.address}}</span>
<div id="app" class="div_map"></div>
<div id="app"
class="div_map"></div>
</div>
</el-form-item>
@ -76,7 +89,7 @@ export default {
},
components: {},
async mounted () {
await this.initMap()
await this.initMap()
},
methods: {
@ -100,7 +113,7 @@ export default {
initMap () {
//
let { latitude, longitude } = this.$store.state.user;
console.log('lat'+latitude+',lon'+longitude)
console.log('lat' + latitude + ',lon' + longitude)
if (!latitude || latitude == "" || latitude == "0") {
latitude = 39.9088810666821;
longitude = 116.39743841556731;

53
src/views/modules/shequzhili/csgltc/csglForm.vue

@ -78,22 +78,39 @@
:max="9999"
label="容纳人数"></el-input-number>
</el-form-item>
<el-form-item label="负责人"
style="display: block"
label-width="150px"
prop="principal">
<el-input v-model="formData.principal"
class="item_width_1"
placeholder="请输入负责人姓名"></el-input>
</el-form-item>
<el-form-item label="联系电话"
style="display: block"
label-width="150px"
prop="mobile">
<el-input v-model="formData.mobile"
class="item_width_1"
placeholder="请输入联系电话"></el-input>
</el-form-item>
<el-form-item label="地址"
prop="address"
label-width="150px"
style="display: block">
<div class="item_width_1">
<el-input
style="width:420px"
:placeholder="'请输入所在地址'"
v-model="formData.address">
<el-input style="width:420px"
:placeholder="'请输入所在地址'"
v-model="formData.address">
</el-input>
<el-button
style="margin-left: 10px"
type="default"
size="small"
@click="handleSearchMap">查询</el-button>
<div id="app" class="div_map"></div>
<el-button style="margin-left: 10px"
type="default"
size="small"
@click="handleSearchMap">查询</el-button>
<div id="app"
class="div_map"></div>
</div>
</el-form-item>
</el-form>
@ -141,7 +158,9 @@ export default {
capacity: 0,//
address: '', //
longitude: 36.0722275, //
latitude: 120.38945519 //
latitude: 120.38945519, //
principal: '',
mobile: ''
},
cityManagement: {
@ -205,14 +224,14 @@ export default {
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
if (null != data){
data : this.cityManagement
if (null != data) {
data: this.cityManagement
}
this.formData = { ...data }
// let { latitude, longitude } = this.$store.state.user;
// const lat = this.formData.latitude === null || this.formData.latitude === '' ? latitude : this.formData.latitude;
// const lon = this.formData.longitude === null || this.formData.longitude === '' ? longitude : this.formData.longitude;
if (this.formData.latitude !== null && this.formData.latitude !== '' && this.formData.longitude !== null && this.formData.longitude !== ''){
if (this.formData.latitude !== null && this.formData.latitude !== '' && this.formData.longitude !== null && this.formData.longitude !== '') {
map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude))
this.setMarker(this.formData.latitude, this.formData.longitude)
}
@ -243,9 +262,9 @@ export default {
},
async addUnit () {
let url = ''
if (this.formType === 'add'){
if (this.formType === 'add') {
url = '/gov/org/icCityManagement/add'
}else {
} else {
url = '/gov/org/icCityManagement/edit'
}
const { data, code, msg, internalMsg } = await requestPost(url, this.formData)
@ -273,7 +292,7 @@ export default {
initMap () {
//
let { latitude, longitude } = this.$store.state.user;
console.log('lat'+latitude+',lon'+longitude)
console.log('lat' + latitude + ',lon' + longitude)
if (!latitude || latitude == "" || latitude == "0") {
latitude = 39.9088810666821;
longitude = 116.39743841556731;

70
src/views/modules/shequzhili/ggfwtc/ggfw.vue

@ -116,9 +116,23 @@
label="地址"
mix-width="230">
</el-table-column>
<el-table-column prop="principal"
header-align="center"
align="center"
show-overflow-tooltip
label="负责人"
width="100">
</el-table-column>
<el-table-column prop="mobile"
header-align="center"
align="center"
show-overflow-tooltip
label="联系电话"
width="130">
</el-table-column>
<el-table-column label="操作"
fixed="right"
width="250"
width="200"
header-align="center"
align="center"
class="operate">
@ -276,31 +290,31 @@ export default {
responseType: "blob",
data: params,
})
.then((res) => {
// this.download(res.data, title + '.xls')
if (res.headers["content-disposition"]) {
let fileName = window.decodeURI(
res.headers["content-disposition"].split(";")[1].split("=")[1]
);
console.log("filename", fileName);
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel",
});
var url = window.URL.createObjectURL(blob);
var aLink = document.createElement("a");
aLink.style.display = "none";
aLink.href = url;
aLink.setAttribute("download", fileName);
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink); //
window.URL.revokeObjectURL(url); //blob
} else this.$message.error("下载失败");
})
.catch((err) => {
console.log("err", err);
return this.$message.error("网络错误");
});
.then((res) => {
// this.download(res.data, title + '.xls')
if (res.headers["content-disposition"]) {
let fileName = window.decodeURI(
res.headers["content-disposition"].split(";")[1].split("=")[1]
);
console.log("filename", fileName);
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel",
});
var url = window.URL.createObjectURL(blob);
var aLink = document.createElement("a");
aLink.style.display = "none";
aLink.href = url;
aLink.setAttribute("download", fileName);
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink); //
window.URL.revokeObjectURL(url); //blob
} else this.$message.error("下载失败");
})
.catch((err) => {
console.log("err", err);
return this.$message.error("网络错误");
});
},
//
@ -619,8 +633,8 @@ export default {
}
</script>
<style lang="scss" scoped >
@import "@/assets/scss/buttonstyle.scss";
@import "@/assets/scss/modules/management/list-main.scss";
@import "@/assets/scss/buttonstyle.scss";
@import "@/assets/scss/modules/management/list-main.scss";
.div_main {
width: 100%;
}

339
src/views/modules/shequzhili/ggfwtc/ggfwDetail.vue

@ -35,13 +35,26 @@
style="display: block">
<span>{{formData.capacity}}</span>
</el-form-item>
<el-form-item label="负责人:"
prop="principal"
label-width="150px"
style="display: block">
<span>{{formData.principal}}</span>
</el-form-item>
<el-form-item label="联系电话:"
prop="mobile"
label-width="150px"
style="display: block">
<span>{{formData.mobile}}</span>
</el-form-item>
<el-form-item label="地址:"
style="display: block"
prop="address"
label-width="150px">
<div class="item_width_1">
<span>{{formData.address}}</span>
<div id="app" class="div_map"></div>
<div id="app"
class="div_map"></div>
</div>
</el-form-item>
</el-form>
@ -57,193 +70,193 @@
<script>
import { Loading } from 'element-ui' // Loading
var map
var search
var markers
var infoWindowList
var geocoder //
import { Loading } from 'element-ui' // Loading
let loading //
export default {
data () {
return {
formData: {},
var map
var search
var markers
var infoWindowList
var geocoder //
}
},
components: {},
mounted () {
this.initMap()
},
let loading //
export default {
data () {
return {
formData: {},
methods: {
handleCancle () {
}
},
components: {},
mounted () {
this.initMap()
},
this.$emit('diaClose')
methods: {
handleCancle () {
},
this.$emit('diaClose')
async initForm (row) {
this.startLoading()
this.formData = { ...row }
map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude))
this.setMarker(this.formData.latitude, this.formData.longitude)
},
this.endLoading()
async initForm (row) {
this.startLoading()
this.formData = { ...row }
map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude))
this.setMarker(this.formData.latitude, this.formData.longitude)
},
this.endLoading()
// init
initMap () {
//
var center = new window.TMap.LatLng(36.0722275, 120.38945519)
// map TMap.Map()
map = new window.TMap.Map(document.getElementById('app'), {
center: center, //
zoom: 17.2, //
pitch: 43.5, //
rotation: 45 //
})
},
search = new window.TMap.service.Search({ pageSize: 10 })
//
markers = new TMap.MultiMarker({
map: map,
geometries: []
})
infoWindowList = Array(10)
// init
initMap () {
//
var center = new window.TMap.LatLng(36.0722275, 120.38945519)
// map TMap.Map()
map = new window.TMap.Map(document.getElementById('app'), {
center: center, //
zoom: 17.2, //
pitch: 43.5, //
rotation: 45 //
})
search = new window.TMap.service.Search({ pageSize: 10 })
//
markers = new TMap.MultiMarker({
map: map,
geometries: []
})
infoWindowList = Array(10)
geocoder = new TMap.service.Geocoder(); //
//
map.on('panend', () => {
this.handleMoveCenter()
})
this.handleMoveCenter()
this.convert()
},
geocoder = new TMap.service.Geocoder(); //
setMarker (lat, lng) {
markers.setGeometries([])
markers.add([
{
id: '4',
styleId: 'marker',
position: new TMap.LatLng(lat, lng),
properties: {
title: 'marker4'
}
}
])
},
//
map.on('panend', () => {
this.handleMoveCenter()
handleSearchMap () {
infoWindowList.forEach((infoWindow) => {
infoWindow.close()
})
infoWindowList.length = 0
markers.setGeometries([])
//
search
.searchRectangle({
keyword: this.keyWords,
bounds: map.getBounds()
})
this.handleMoveCenter()
this.convert()
},
setMarker (lat, lng) {
markers.setGeometries([])
markers.add([
{
id: '4',
styleId: 'marker',
position: new TMap.LatLng(lat, lng),
properties: {
title: 'marker4'
}
.then((result) => {
let { data } = result
if (Array.isArray(data) && data.length > 0) {
const {
location: { lat, lng }
} = data[0]
map.setCenter(new TMap.LatLng(lat, lng))
this.setMarker(lat, lng)
this.formData.latitude = lat
this.formData.longitude = lng
this.convert()
} else {
this.$message.error('未检索到相关位置坐标')
}
])
},
handleSearchMap () {
infoWindowList.forEach((infoWindow) => {
infoWindow.close()
})
infoWindowList.length = 0
markers.setGeometries([])
//
search
.searchRectangle({
keyword: this.keyWords,
bounds: map.getBounds()
})
.then((result) => {
let { data } = result
if (Array.isArray(data) && data.length > 0) {
const {
location: { lat, lng }
} = data[0]
map.setCenter(new TMap.LatLng(lat, lng))
this.setMarker(lat, lng)
this.formData.latitude = lat
this.formData.longitude = lng
this.convert()
} else {
this.$message.error('未检索到相关位置坐标')
}
})
},
handleMoveCenter () {
//
const center = map.getCenter()
const lat = center.getLat()
const lng = center.getLng()
this.formData.latitude = lat
this.formData.longitude = lng
this.setMarker(lat, lng)
this.convert(lat, lng)
},
convert (lat, lng) {
markers.setGeometries([]);
// var input = document.getElementById('location').value.split(',');
let location
if (lat && lng) {
location = new TMap.LatLng(lat, lng);
} else {
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude);
}
},
// map.setCenter(location);
markers.updateGeometries([
{
id: 'main', //
position: location,
},
]);
geocoder
.getAddress({ location: location }) //
.then((result) => {
// this.formData.address = result.result.address
//
});
},
//
startLoading () {
loading = Loading.service({
lock: true, //
text: '正在加载……', //
background: 'rgba(0,0,0,.7)' //
})
},
//
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close()
}
}
handleMoveCenter () {
//
const center = map.getCenter()
const lat = center.getLat()
const lng = center.getLng()
this.formData.latitude = lat
this.formData.longitude = lng
this.setMarker(lat, lng)
this.convert(lat, lng)
},
computed: {
convert (lat, lng) {
markers.setGeometries([]);
// var input = document.getElementById('location').value.split(',');
let location
if (lat && lng) {
location = new TMap.LatLng(lat, lng);
} else {
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude);
}
// map.setCenter(location);
markers.updateGeometries([
{
id: 'main', //
position: location,
},
]);
geocoder
.getAddress({ location: location }) //
.then((result) => {
// this.formData.address = result.result.address
//
});
},
props: {
//
startLoading () {
loading = Loading.service({
lock: true, //
text: '正在加载……', //
background: 'rgba(0,0,0,.7)' //
})
},
//
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close()
}
}
},
computed: {
},
props: {
}
}
</script>
<style lang="scss" scoped >
@import "@/assets/scss/modules/visual/communityManageForm.scss";
@import "@/assets/scss/modules/visual/communityManageForm.scss";
</style>
<style scoped>
.detail_span {
width: 500px;
font-weight: bold;
text-align: left;
margin: 0 0;
font-size: 16px;
}
.form {
margin-top: 30px;
}
.detail_span {
width: 500px;
font-weight: bold;
text-align: left;
margin: 0 0;
font-size: 16px;
}
.form {
margin-top: 30px;
}
</style>

648
src/views/modules/shequzhili/ggfwtc/ggfwForm.vue

@ -60,22 +60,38 @@
:max="9999"
label="容纳人数"></el-input-number>
</el-form-item>
<el-form-item label="负责人"
style="display: block"
label-width="150px"
prop="principal">
<el-input v-model="formData.principal"
class="item_width_1"
placeholder="请输入负责人姓名"></el-input>
</el-form-item>
<el-form-item label="联系电话"
style="display: block"
label-width="150px"
prop="mobile">
<el-input v-model="formData.mobile"
class="item_width_1"
placeholder="请输入联系电话"></el-input>
</el-form-item>
<el-form-item label="地址"
prop="address"
label-width="150px"
style="display: block">
<div class="item_width_1">
<el-input
style="width:420px"
:placeholder="'请输入所在地址'"
v-model="formData.address">
<el-input style="width:420px"
:placeholder="'请输入所在地址'"
v-model="formData.address">
</el-input>
<el-button
style="margin-left: 10px"
type="default"
size="small"
@click="handleSearchMap">查询</el-button>
<div id="app" class="div_map"></div>
<el-button style="margin-left: 10px"
type="default"
size="small"
@click="handleSearchMap">查询</el-button>
<div id="app"
class="div_map"></div>
</div>
</el-form-item>
</el-form>
@ -94,357 +110,359 @@
</template>
<script>
import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // Loading
import { requestPost } from '@/js/dai/request'
import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // Loading
import { requestPost } from '@/js/dai/request'
var map
var search
var markers
var infoWindowList
var geocoder //
let loading //
export default {
data () {
return {
formType: 'add', // addeditdetail
btnDisable: false,
icPublicServiceId: '',
keyWords: '',
formData: {
name: '',//
category: '',
areaCovered: '',//
capacity: '',//
address: '', //
longitude: 36.0722275, //
latitude: 120.38945519, //
principal: '',
mobile: ''
},
serviceList: [],//list
publicServiceData: {},
}
},
components: {},
mounted () {
this.initMap()
},
methods: {
async initForm (type, icPublicServiceId) {
this.startLoading()
this.$refs.ref_form.resetFields();
//
await this.loadService()
this.formType = type
if (icPublicServiceId) {
this.icPublicServiceId = icPublicServiceId
this.formData.icPublicServiceId = icPublicServiceId
await this.loadFormData()
} else {
// map.setCenter(new TMap.LatLng(36.0722275, 120.38945519))
// this.setMarker(36.0722275, 120.38945519)
}
var map
var search
var markers
var infoWindowList
var geocoder //
this.endLoading()
let loading //
export default {
data () {
return {
formType: 'add', // addeditdetail
btnDisable: false,
icPublicServiceId: '',
keyWords: '',
formData: {
name: '',//
category: '',
areaCovered: '',//
capacity: '',//
address: '', //
longitude: 36.0722275, //
latitude: 120.38945519 //
},
serviceList: [],//list
publicServiceData: {},
}
},
components: {},
mounted () {
this.initMap()
},
methods: {
async initForm (type, icPublicServiceId) {
this.startLoading()
this.$refs.ref_form.resetFields();
//
async loadService () {
const url = "/gov/org/coverage/dict-select-list/public_service"
// const url = "http://yapi.elinkservice.cn/mock/245/gov/org/coverage/dict-select-list/public_service"
let params = {
}
//
await this.loadService()
const { data, code, msg } = await requestPost(url, params)
this.formType = type
if (icPublicServiceId) {
this.icPublicServiceId = icPublicServiceId
this.formData.icPublicServiceId = icPublicServiceId
await this.loadFormData()
} else {
// map.setCenter(new TMap.LatLng(36.0722275, 120.38945519))
// this.setMarker(36.0722275, 120.38945519)
}
if (code === 0) {
this.serviceList = data
this.endLoading()
} else {
this.$message.error(msg)
}
},
},
//
async loadService () {
const url = "/gov/org/coverage/dict-select-list/public_service"
// const url = "http://yapi.elinkservice.cn/mock/245/gov/org/coverage/dict-select-list/public_service"
let params = {
//
async loadFormData () {
const url = '/gov/org/icPublicService/detail'
// const url = 'http://yapi.elinkservice.cn/mock/245/gov/org/icPublicService/detail'
let params = {
icPublicServiceId: this.icPublicServiceId
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
console.log(data)
if (null != data) {
data: this.publicServiceData
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
this.serviceList = data
} else {
this.$message.error(msg)
this.formData = { ...data }
// let { latitude, longitude } = this.$store.state.user;
// const lat = this.formData.latitude === null || this.formData.latitude === '' ? '' : this.formData.latitude;
// const lon = this.formData.longitude === null || this.formData.longitude === '' ? '' : this.formData.longitude;
if (this.formData.latitude !== null && this.formData.latitude !== '' && this.formData.longitude !== null && this.formData.longitude !== '') {
map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude))
this.setMarker(this.formData.latitude, this.formData.longitude)
}
} else {
this.$message.error(msg)
}
},
},
//
async loadFormData () {
const url = '/gov/org/icPublicService/detail'
// const url = 'http://yapi.elinkservice.cn/mock/245/gov/org/icPublicService/detail'
let params = {
icPublicServiceId: this.icPublicServiceId
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
console.log(data)
if (null != data) {
data: this.publicServiceData
}
this.formData = { ...data }
// let { latitude, longitude } = this.$store.state.user;
// const lat = this.formData.latitude === null || this.formData.latitude === '' ? '' : this.formData.latitude;
// const lon = this.formData.longitude === null || this.formData.longitude === '' ? '' : this.formData.longitude;
if (this.formData.latitude !== null && this.formData.latitude !== '' && this.formData.longitude !== null && this.formData.longitude !== ''){
map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude))
this.setMarker(this.formData.latitude, this.formData.longitude)
}
async handleComfirm () {
this.btnDisable = true
setTimeout(() => {
this.btnDisable = false
}, 10000)
this.$refs['ref_form'].validate((valid, messageObj) => {
if (!valid) {
app.util.validateRule(messageObj)
this.btnDisable = false
} else {
this.$message.error(msg)
this.addUnit()
}
},
})
async handleComfirm () {
this.btnDisable = true
setTimeout(() => {
this.btnDisable = false
}, 10000)
this.$refs['ref_form'].validate((valid, messageObj) => {
if (!valid) {
app.util.validateRule(messageObj)
this.btnDisable = false
} else {
this.addUnit()
}
},
async addUnit () {
let url = ''
if (this.formType === 'add') {
url = '/gov/org/icPublicService/add'
} else {
url = '/gov/org/icPublicService/edit'
}
const { data, code, msg, internalMsg } = await requestPost(url, this.formData)
if (code === 0) {
this.$message({
type: 'success',
message: '操作成功'
})
this.resetData()
this.$emit('dialogOk')
this.btnDisable = false
} else {
this.btnDisable = false
this.$message.error(internalMsg)
}
},
},
async addUnit () {
let url = ''
if (this.formType === 'add'){
url = '/gov/org/icPublicService/add'
}else {
url = '/gov/org/icPublicService/edit'
}
const { data, code, msg,internalMsg } = await requestPost(url, this.formData)
if (code === 0) {
this.$message({
type: 'success',
message: '操作成功'
})
this.resetData()
this.$emit('dialogOk')
this.btnDisable = false
} else {
this.btnDisable = false
this.$message.error(internalMsg)
}
},
handleCancle () {
this.resetData()
this.$emit('dialogCancle')
handleCancle () {
this.resetData()
this.$emit('dialogCancle')
},
},
// init
initMap () {
let { latitude, longitude } = this.$store.state.user;
console.log('lat' + latitude + ',lon' + longitude)
if (!latitude || latitude == "" || latitude == "0") {
latitude = 39.9088810666821;
longitude = 116.39743841556731;
}
//
var center = new window.TMap.LatLng(latitude, longitude);
// map TMap.Map()
map = new window.TMap.Map(document.getElementById('app'), {
center: center, //
zoom: 17.2, //
pitch: 43.5, //
rotation: 45 //
})
search = new window.TMap.service.Search({ pageSize: 10 })
//
markers = new TMap.MultiMarker({
map: map,
geometries: []
})
infoWindowList = Array(10)
geocoder = new TMap.service.Geocoder(); //
//
map.on('panend', () => {
this.handleMoveCenter()
})
// this.handleMoveCenter()
this.convert()
},
// init
initMap () {
let { latitude, longitude } = this.$store.state.user;
console.log('lat'+latitude+',lon'+longitude)
if (!latitude || latitude == "" || latitude == "0") {
latitude = 39.9088810666821;
longitude = 116.39743841556731;
setMarker (lat, lng) {
markers.setGeometries([])
markers.add([
{
id: '4',
styleId: 'marker',
position: new TMap.LatLng(lat, lng),
properties: {
title: 'marker4'
}
}
//
var center = new window.TMap.LatLng(latitude, longitude);
// map TMap.Map()
map = new window.TMap.Map(document.getElementById('app'), {
center: center, //
zoom: 17.2, //
pitch: 43.5, //
rotation: 45 //
})
search = new window.TMap.service.Search({ pageSize: 10 })
//
markers = new TMap.MultiMarker({
map: map,
geometries: []
})
infoWindowList = Array(10)
geocoder = new TMap.service.Geocoder(); //
])
},
//
map.on('panend', () => {
this.handleMoveCenter()
handleSearchMap () {
infoWindowList.forEach((infoWindow) => {
infoWindow.close()
})
infoWindowList.length = 0
markers.setGeometries([])
//
search
.searchRectangle({
keyword: this.formData.address,
bounds: map.getBounds()
})
// this.handleMoveCenter()
this.convert()
},
setMarker (lat, lng) {
markers.setGeometries([])
markers.add([
{
id: '4',
styleId: 'marker',
position: new TMap.LatLng(lat, lng),
properties: {
title: 'marker4'
}
.then((result) => {
let { data } = result
if (Array.isArray(data) && data.length > 0) {
const {
location: { lat, lng }
} = data[0]
map.setCenter(new TMap.LatLng(lat, lng))
this.setMarker(lat, lng)
this.formData.latitude = lat
this.formData.longitude = lng
this.convert()
} else {
this.$message.error('未检索到相关位置坐标')
}
])
},
handleSearchMap () {
infoWindowList.forEach((infoWindow) => {
infoWindow.close()
})
infoWindowList.length = 0
markers.setGeometries([])
//
search
.searchRectangle({
keyword: this.formData.address,
bounds: map.getBounds()
})
.then((result) => {
let { data } = result
if (Array.isArray(data) && data.length > 0) {
const {
location: { lat, lng }
} = data[0]
map.setCenter(new TMap.LatLng(lat, lng))
this.setMarker(lat, lng)
this.formData.latitude = lat
this.formData.longitude = lng
this.convert()
} else {
this.$message.error('未检索到相关位置坐标')
}
})
},
},
handleMoveCenter () {
//
const center = map.getCenter()
const lat = center.getLat()
const lng = center.getLng()
this.formData.latitude = lat
this.formData.longitude = lng
this.setMarker(lat, lng)
this.convert(lat, lng)
},
handleMoveCenter () {
//
const center = map.getCenter()
const lat = center.getLat()
const lng = center.getLng()
this.formData.latitude = lat
this.formData.longitude = lng
this.setMarker(lat, lng)
this.convert(lat, lng)
},
convert (lat, lng) {
markers.setGeometries([]);
// var input = document.getElementById('location').value.split(',');
let location
if (lat && lng) {
location = new TMap.LatLng(lat, lng);
} else {
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude);
}
convert (lat, lng) {
markers.setGeometries([]);
// var input = document.getElementById('location').value.split(',');
let location
if (lat && lng) {
location = new TMap.LatLng(lat, lng);
} else {
location = new TMap.LatLng(this.formData.latitude, this.formData.longitude);
}
// map.setCenter(location);
markers.updateGeometries([
{
id: 'main', //
position: location,
},
]);
geocoder
.getAddress({ location: location }) //
.then((result) => {
console.log(this.formData)
// this.formData.address = result.result.address === '' || result.result.address === null ? this.formData.address : result.result.address
this.formData.address = this.formData.address !== '' && this.formData.address !== null && (this.formData.longitude === '' || this.formData.longitude === null) ? this.formData.address : result.result.address
//
});
},
// map.setCenter(location);
markers.updateGeometries([
{
id: 'main', //
position: location,
},
]);
geocoder
.getAddress({ location: location }) //
.then((result) => {
console.log(this.formData)
// this.formData.address = result.result.address === '' || result.result.address === null ? this.formData.address : result.result.address
this.formData.address = this.formData.address !== '' && this.formData.address !== null && (this.formData.longitude === '' || this.formData.longitude === null) ? this.formData.address : result.result.address
//
});
},
resetData () {
this.icPublicServiceId = ''
this.keyWords = ''
this.formData = {
name: '',
category: '',
areaCovered: '',
capacity: '',
address: '', //
longitude: '', //
latitude: '' //
}
},
//
startLoading () {
loading = Loading.service({
lock: true, //
text: '正在加载……', //
background: 'rgba(0,0,0,.7)' //
})
},
//
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close()
}
resetData () {
this.icPublicServiceId = ''
this.keyWords = ''
this.formData = {
name: '',
category: '',
areaCovered: '',
capacity: '',
address: '', //
longitude: '', //
latitude: '' //
}
},
computed: {
dataRule () {
return {
name: [
{ required: true, message: '场所名称不能为空', trigger: 'blur' },
],
category: [
{ required: true, message: '场所类别不能为空', trigger: 'blur' }
],
address: [
{ required: true, message: '地址不能为空', trigger: 'blur' }
],
/*longitude: [
{ required: true, message: '坐标不能为空', trigger: 'blur' }
],
latitude: [
{ required: true, message: '坐标不能为空', trigger: 'blur' }
]*/
}
},
//
startLoading () {
loading = Loading.service({
lock: true, //
text: '正在加载……', //
background: 'rgba(0,0,0,.7)' //
})
},
//
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close()
}
}
},
computed: {
dataRule () {
return {
name: [
{ required: true, message: '场所名称不能为空', trigger: 'blur' },
],
category: [
{ required: true, message: '场所类别不能为空', trigger: 'blur' }
],
address: [
{ required: true, message: '地址不能为空', trigger: 'blur' }
],
/*longitude: [
{ required: true, message: '坐标不能为空', trigger: 'blur' }
],
latitude: [
{ required: true, message: '坐标不能为空', trigger: 'blur' }
]*/
}
},
props: {
typeList: {
type: Array,
default: []
},
},
props: {
typeList: {
type: Array,
default: []
},
}
}
}
</script>
<style scoped>
.div_map {
position: relative;
}
.div_searchmap {
z-index: 5000;
position: absolute;
top: 5px;
left: 5px;
}
.div_map {
position: relative;
}
.div_searchmap {
z-index: 5000;
position: absolute;
top: 5px;
left: 5px;
}
</style>
<style lang="scss" scoped >
@import "@/assets/scss/modules/visual/communityManageForm.scss";
@import "@/assets/scss/modules/visual/communityManageForm.scss";
</style>

Loading…
Cancel
Save