11 changed files with 469 additions and 423 deletions
@ -1,403 +1,411 @@ |
|||||
<template> |
<template> |
||||
<el-dialog title="提示" :visible.sync="dialogVisible" width="1370px" :before-close="handleCancle"> |
<el-dialog title="提示" :visible.sync="dialogVisible" width="1370px" :before-close="handleCancle"> |
||||
<div> |
<span slot="title"> |
||||
<div class="dialog-h-content scroll-h"> |
<span v-if="pageType == 'add'">新增</span> |
||||
<el-form :inline="true" :model="formData" ref="form" :rules="dataRule" :label-width="'90px'" v-if="pageType != 'view'"> |
<span v-if="pageType == 'edit'">修改</span> |
||||
<el-row> |
<span v-if="pageType == 'view'">查看</span> |
||||
<el-col :span="6"> |
</span> |
||||
<el-form-item label="设备名称" prop="equipmentName"> |
<div> |
||||
<el-input v-model="formData.equipmentName" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
<div class="dialog-h-content scroll-h"> |
||||
</el-form-item> |
<el-form :inline="true" :model="formData" ref="form" :rules="dataRule" :label-width="'90px'" v-if="pageType != 'view'"> |
||||
</el-col> |
<el-row> |
||||
<el-col :span="6"> |
<el-col :span="6"> |
||||
<el-form-item label="设备类型" prop="equipmentCategoryCode"> |
<el-form-item label="设备名称" prop="equipmentName"> |
||||
<el-select v-model="formData.equipmentCategoryCode" :disabled="disabled" placeholder="请选择" size="small" clearable class="u-item-width-normal"> |
<el-input v-model="formData.equipmentName" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
||||
<el-option v-for="item in equipmentCategoryCodeArray" :key="item.value" :label="item.label" :value="item.value"></el-option> |
</el-form-item> |
||||
</el-select> |
</el-col> |
||||
</el-form-item> |
<el-col :span="6"> |
||||
</el-col> |
<el-form-item label="设备类型" prop="equipmentCategoryCode"> |
||||
<el-col :span="6"> |
<el-select v-model="formData.equipmentCategoryCode" :disabled="disabled" placeholder="请选择" size="small" clearable class="u-item-width-normal"> |
||||
<el-form-item label="负责人" prop="principalName"> |
<el-option v-for="item in equipmentCategoryCodeArray" :key="item.value" :label="item.label" :value="item.value"></el-option> |
||||
<el-input v-model="formData.principalName" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
</el-select> |
||||
</el-form-item> |
</el-form-item> |
||||
</el-col> |
</el-col> |
||||
<el-col :span="6"> |
<el-col :span="6"> |
||||
<el-form-item label="联系电话" prop="contactNum"> |
<el-form-item label="负责人" prop="principalName"> |
||||
<el-input v-model="formData.contactNum" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
<el-input v-model="formData.principalName" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
||||
</el-form-item> |
</el-form-item> |
||||
</el-col> |
</el-col> |
||||
<el-col :span="6"> |
<el-col :span="6"> |
||||
<el-form-item label="所处位置" prop="location" style="display: block"> |
<el-form-item label="联系电话" prop="contactNum"> |
||||
<el-select |
<el-input v-model="formData.contactNum" :disabled="disabled" class="u-item-width-normal" size="small" clearable placeholder="请输入"></el-input> |
||||
v-model="formData.location" |
</el-form-item> |
||||
:disabled="disabled" |
</el-col> |
||||
filterable |
<el-col :span="6"> |
||||
remote |
<el-form-item label="所处位置" prop="location" style="display: block"> |
||||
:reserve-keyword="true" |
<el-select |
||||
placeholder="请输入关键词" |
v-model="formData.location" |
||||
:remote-method="remoteMethod" |
:disabled="disabled" |
||||
:loading="loading" |
filterable |
||||
> |
remote |
||||
<el-option |
:reserve-keyword="true" |
||||
v-for="(item, index) in searchOptions" |
placeholder="请输入关键词" |
||||
@click.native="handleClickKey(index)" |
:remote-method="remoteMethod" |
||||
:key="item.value" |
:loading="loading" |
||||
:label="item.label" |
> |
||||
:value="item.value" |
<el-option |
||||
></el-option> |
v-for="(item, index) in searchOptions" |
||||
</el-select> |
@click.native="handleClickKey(index)" |
||||
</el-form-item> |
:key="item.value" |
||||
</el-col> |
:label="item.label" |
||||
</el-row> |
:value="item.value" |
||||
<div id="app_event" class="div_map"></div> |
></el-option> |
||||
</el-form> |
</el-select> |
||||
<el-form :inline="false" :model="formData" ref="form" :label-width="'90px'" v-if="pageType == 'view'"> |
</el-form-item> |
||||
<el-row> |
</el-col> |
||||
<el-col :span="6"> |
</el-row> |
||||
<el-form-item label="设备名称" prop="equipmentName">{{ formData.equipmentName }}</el-form-item></el-col>
<el-col :span="6"> |
<div id="app_event" class="div_map"></div> |
||||
<el-form-item label="设备类型" prop="equipmentCategoryCode">{{ formData.equipmentCategoryName }}</el-form-item></el-col>
<el-col :span="6"> |
</el-form> |
||||
<el-form-item label="负责人" prop="principalName">{{ formData.principalName }}</el-form-item></el-col>
<el-col :span="6"> |
<el-form :inline="false" :model="formData" ref="form" :label-width="'90px'" v-if="pageType == 'view'"> |
||||
<el-form-item label="联系电话" prop="contactNum">{{ formData.contactNum }}</el-form-item> |
<el-row> |
||||
</el-col> |
<el-col :span="6"> |
||||
<el-col :span="6"> |
<el-form-item label="设备名称" prop="equipmentName">{{ formData.equipmentName }}</el-form-item> |
||||
<el-form-item label="场所地址" prop="location" style="display: block"> |
</el-col> |
||||
{{ formData.location }} |
<el-col :span="6"> |
||||
|
<el-form-item label="设备类型" prop="equipmentCategoryCode">{{ formData.equipmentCategoryName }}</el-form-item> |
||||
</el-form-item> |
</el-col> |
||||
</el-col> |
<el-col :span="6"> |
||||
</el-row><div id="app_event" class="div_map"></div> |
<el-form-item label="负责人" prop="principalName">{{ formData.principalName }}</el-form-item> |
||||
</el-form> |
</el-col> |
||||
</div> |
<el-col :span="6"> |
||||
<div class="div_btn" v-if="pageType != 'view'"> |
<el-form-item label="联系电话" prop="contactNum">{{ formData.contactNum }}</el-form-item> |
||||
<el-button size="small" @click="handleCancle">取 消</el-button> |
</el-col> |
||||
<!-- <el-button size="small" @click="resetData" v-if="pageType != 'view'">重置</el-button> --> |
<el-col :span="6"> |
||||
<el-button size="small" type="primary" :disabled="btnDisable" @click="handleComfirm" >确 定</el-button> |
<el-form-item label="场所地址" prop="location" style="display: block">{{ formData.location }}</el-form-item> |
||||
</div> |
</el-col> |
||||
<div style="margin-top: 30px;"><record v-if="pageType != 'add' && detailId" :formType="pageType" :id="detailId" :info="{ agencyId: agencyId }"></record></div> |
</el-row> |
||||
</div> |
<div id="app_event" class="div_map"></div> |
||||
<span slot="footer" class="dialog-footer"> |
</el-form> |
||||
<el-button @click="handleCancle">关 闭</el-button> |
</div> |
||||
<!-- <el-button type="primary" @click="handleComfirm">确 定</el-button> --> |
<div class="div_btn" v-if="pageType != 'view'"> |
||||
</span> |
<el-button size="small" @click="handleCancle">取 消</el-button> |
||||
</el-dialog> |
<!-- <el-button size="small" @click="resetData" v-if="pageType != 'view'">重置</el-button> --> |
||||
</template> |
<el-button size="small" type="primary" :disabled="btnDisable" @click="handleComfirm">确 定</el-button> |
||||
|
</div> |
||||
<script> |
<div style="margin-top: 30px;"><record v-if="pageType != 'add' && detailId" :formType="pageType" :id="detailId" :info="{ agencyId: agencyId }"></record></div> |
||||
import { isMobile } from '@/utils/validate'; |
</div> |
||||
import { mapGetters } from 'vuex'; |
<span slot="footer" class="dialog-footer"> |
||||
import { Loading } from 'element-ui'; // 引入Loading服务 |
<el-button @click="handleCancle">关 闭</el-button> |
||||
import { requestPost, requestGet } from '@/js/dai/request'; |
<!-- <el-button type="primary" @click="handleComfirm">确 定</el-button> --> |
||||
import daiMap from '@/utils/dai-map'; |
</span> |
||||
import nextTick from 'dai-js/tools/nextTick'; |
</el-dialog> |
||||
import record from './record'; |
</template> |
||||
let loading; // 加载动画 |
|
||||
let map; |
<script> |
||||
var search; |
import { isMobile } from '@/utils/validate'; |
||||
var markers; |
import { mapGetters } from 'vuex'; |
||||
var infoWindowList; |
import { Loading } from 'element-ui'; // 引入Loading服务 |
||||
var geocoder; // 新建一个正逆地址解析类 |
import { requestPost, requestGet } from '@/js/dai/request'; |
||||
|
import daiMap from '@/utils/dai-map'; |
||||
export default { |
import nextTick from 'dai-js/tools/nextTick'; |
||||
props: { |
import record from './record'; |
||||
dialogVisible: { |
let loading; // 加载动画 |
||||
type: Boolean, |
let map; |
||||
default: '' |
var search; |
||||
}, |
var markers; |
||||
defaultData: { |
var infoWindowList; |
||||
type: Object, |
var geocoder; // 新建一个正逆地址解析类 |
||||
default: null |
|
||||
}, |
export default { |
||||
pageType: { |
props: { |
||||
type: String, |
dialogVisible: { |
||||
default: '' |
type: Boolean, |
||||
}, |
default: '' |
||||
detailId: { |
}, |
||||
type: String, |
defaultData: { |
||||
default: '' |
type: Object, |
||||
}, |
default: null |
||||
detailData: { |
}, |
||||
type: Object, |
pageType: { |
||||
default: null |
type: String, |
||||
}, |
default: '' |
||||
disabled: { |
}, |
||||
type: Boolean, |
detailId: { |
||||
default: false |
type: String, |
||||
} |
default: '' |
||||
}, |
}, |
||||
|
detailData: { |
||||
data() { |
type: Object, |
||||
let checkMObile = (rule, value, callback) => { |
default: null |
||||
if (value === '') { |
}, |
||||
callback(new Error('请输入手机号')); |
disabled: { |
||||
} else { |
type: Boolean, |
||||
if (!isMobile(value)) { |
default: false |
||||
callback(new Error('手机号格式不正确')); |
} |
||||
} |
}, |
||||
callback(); |
|
||||
} |
data() { |
||||
}; |
let checkMObile = (rule, value, callback) => { |
||||
return { |
if (value === '') { |
||||
btnDisable: false, |
callback(new Error('请输入手机号')); |
||||
user: '', |
} else { |
||||
agencyId: '', |
if (!isMobile(value)) { |
||||
gridList: [], //所属网格list--场所区域 |
callback(new Error('手机号格式不正确')); |
||||
placeTypeList: [], //场所类型 |
} |
||||
resultArray: [{ value: '0', label: '合格' }, { value: '1', label: '不合格' }], |
callback(); |
||||
equipmentCategoryCodeArray: [], |
} |
||||
list: {}, |
}; |
||||
formData: { |
return { |
||||
equipmentName: '', |
btnDisable: false, |
||||
equipmentCategoryCode: '', |
user: '', |
||||
principalName: '', |
agencyId: '', |
||||
location: '', |
gridList: [], //所属网格list--场所区域 |
||||
contactNum: '' |
placeTypeList: [], //场所类型 |
||||
}, |
resultArray: [{ value: '0', label: '合格' }, { value: '1', label: '不合格' }], |
||||
dataRule: { |
equipmentCategoryCodeArray: [], |
||||
equipmentName: [{ required: true, message: '设备名称不能为空', trigger: 'bulr' }], |
list: {}, |
||||
equipmentCategoryCode: [{ required: true, message: '设备类型不能为空', trigger: 'bulr' }], |
formData: { |
||||
principalName: [{ required: true, message: '负责人不能为空', trigger: 'bulr' }], |
equipmentName: '', |
||||
contactNum: [{ required: true, validator: checkMObile, trigger: 'blur' }], |
equipmentCategoryCode: '', |
||||
location: [{ required: true, message: '所处位置不能为空', trigger: 'blur' }] |
principalName: '', |
||||
}, |
location: '', |
||||
//地图 |
contactNum: '' |
||||
loading: false, |
}, |
||||
searchValue: '', |
dataRule: { |
||||
searchOptions: [] |
equipmentName: [{ required: true, message: '设备名称不能为空', trigger: 'bulr' }], |
||||
}; |
equipmentCategoryCode: [{ required: true, message: '设备类型不能为空', trigger: 'bulr' }], |
||||
}, |
principalName: [{ required: true, message: '负责人不能为空', trigger: 'bulr' }], |
||||
watch: {}, |
contactNum: [{ required: true, validator: checkMObile, trigger: 'blur' }], |
||||
components: { record }, |
location: [{ required: true, message: '所处位置不能为空', trigger: 'blur' }] |
||||
created() {}, |
}, |
||||
async mounted() { |
//地图 |
||||
console.log('detailId', this.detailId); |
loading: false, |
||||
this.user = this.$store.state.user; |
searchValue: '', |
||||
this.agencyId = this.user.agencyId; |
searchOptions: [] |
||||
this.startLoading(); |
}; |
||||
this.loadCategory(); |
}, |
||||
// this.loadGrid(); |
watch: {}, |
||||
// this.loadplaceType(); |
components: { record }, |
||||
if (this.pageType != 'add') { |
created() {}, |
||||
this.getDetail(); |
async mounted() { |
||||
} else { |
console.log('detailId', this.detailId); |
||||
this.initMap(); |
this.user = this.$store.state.user; |
||||
} |
this.agencyId = this.user.agencyId; |
||||
await this.endLoading(); |
this.startLoading(); |
||||
this.endLoading(); |
this.loadCategory(); |
||||
}, |
// this.loadGrid(); |
||||
|
// this.loadplaceType(); |
||||
methods: { |
if (this.pageType != 'add') { |
||||
async loadCategory() { |
this.getDetail(); |
||||
const url = '/sys/dict/data/dictlist'; |
} else { |
||||
|
this.initMap(); |
||||
let params = { |
} |
||||
dictType: 'safety_equipment_category' |
await this.endLoading(); |
||||
}; |
this.endLoading(); |
||||
|
}, |
||||
const { data, code, msg } = await requestPost(url, params); |
|
||||
if (code === 0) { |
methods: { |
||||
this.equipmentCategoryCodeArray = data; |
async loadCategory() { |
||||
} else { |
const url = '/sys/dict/data/dictlist'; |
||||
this.$message.error(msg); |
|
||||
} |
let params = { |
||||
}, |
dictType: 'safety_equipment_category' |
||||
async loadGrid() { |
}; |
||||
const url = '/gov/org/customergrid/gridoption'; |
|
||||
let params = { |
const { data, code, msg } = await requestPost(url, params); |
||||
agencyId: this.agencyId, |
if (code === 0) { |
||||
purpose: 'query' |
this.equipmentCategoryCodeArray = data; |
||||
}; |
} else { |
||||
const { data, code, msg } = await requestPost(url, params); |
this.$message.error(msg); |
||||
if (code === 0) { |
} |
||||
this.gridList = data; |
}, |
||||
} else { |
async loadGrid() { |
||||
this.$message.error(msg); |
const url = '/gov/org/customergrid/gridoption'; |
||||
} |
let params = { |
||||
}, |
agencyId: this.agencyId, |
||||
//场所类型 |
purpose: 'query' |
||||
async loadplaceType() { |
}; |
||||
const url = '/gov/org/coverage/dict-select-list/enterprise_patrol'; |
const { data, code, msg } = await requestPost(url, params); |
||||
let params = { |
if (code === 0) { |
||||
// agencyId: this.agencyId, |
this.gridList = data; |
||||
// purpose: 'query' |
} else { |
||||
}; |
this.$message.error(msg); |
||||
const { data, code, msg } = await requestPost(url, params); |
} |
||||
if (code === 0) { |
}, |
||||
this.placeTypeList = data; |
//场所类型 |
||||
} else { |
async loadplaceType() { |
||||
this.$message.error(msg); |
const url = '/gov/org/coverage/dict-select-list/enterprise_patrol'; |
||||
} |
let params = { |
||||
}, |
// agencyId: this.agencyId, |
||||
async getDetail() { |
// purpose: 'query' |
||||
const url = `/actual/base/safetyEquipment/detail/${this.detailId}`; |
}; |
||||
const { data, code, msg } = await requestPost(url); |
const { data, code, msg } = await requestPost(url, params); |
||||
if (code === 0) { |
if (code === 0) { |
||||
console.log('详情数据', data); |
this.placeTypeList = data; |
||||
this.formData = { ...data }; |
} else { |
||||
this.initMap(); |
this.$message.error(msg); |
||||
} else { |
} |
||||
this.$message.error(msg); |
}, |
||||
} |
async getDetail() { |
||||
}, |
const url = `/actual/base/safetyEquipment/detail/${this.detailId}`; |
||||
|
const { data, code, msg } = await requestPost(url); |
||||
handleComfirm() { |
if (code === 0) { |
||||
this.save(); |
console.log('详情数据', data); |
||||
}, |
this.formData = { ...data }; |
||||
async handleAdd() { |
this.initMap(); |
||||
// this.btnDisable = true; |
} else { |
||||
// setTimeout(() => { |
this.$message.error(msg); |
||||
// this.btnDisable = false; |
} |
||||
// }, 10000); |
}, |
||||
// nextTick(1000); |
|
||||
// const form = new Promise((resolve, reject) => { |
handleComfirm() { |
||||
// this.$refs['form'].validate(valid => { |
this.save(); |
||||
// if (valid) resolve(); |
}, |
||||
// }); |
async handleAdd() { |
||||
// }); |
// this.btnDisable = true; |
||||
// const form1 = new Promise((resolve, reject) => { |
// setTimeout(() => { |
||||
// this.$refs['form1'].validate(valid => { |
// this.btnDisable = false; |
||||
// if (valid) resolve(); |
// }, 10000); |
||||
// }); |
// nextTick(1000); |
||||
// }); |
// const form = new Promise((resolve, reject) => { |
||||
// Promise.all([form1, form]) |
// this.$refs['form'].validate(valid => { |
||||
// .then(() => { |
// if (valid) resolve(); |
||||
// this.addFuwu(); |
// }); |
||||
// }) |
// }); |
||||
// .catch(() => { |
// const form1 = new Promise((resolve, reject) => { |
||||
// app.util.validateRule(messageObj); |
// this.$refs['form1'].validate(valid => { |
||||
// this.btnDisable = false; |
// if (valid) resolve(); |
||||
// }); |
// }); |
||||
}, |
// }); |
||||
|
// Promise.all([form1, form]) |
||||
async save() { |
// .then(() => { |
||||
console.log('this.formData', this.formData); |
// this.addFuwu(); |
||||
var url = ''; |
// }) |
||||
var params = {}; |
// .catch(() => { |
||||
if (this.pageType == 'add') { |
// app.util.validateRule(messageObj); |
||||
url = '/actual/base/safetyEquipment/save'; |
// this.btnDisable = false; |
||||
} else { |
// }); |
||||
url = '/actual/base/safetyEquipment/update'; |
}, |
||||
} |
|
||||
params = { ...this.formData }; |
async save() { |
||||
const { data, code, msg } = await requestPost(url, params); |
console.log('this.formData', this.formData); |
||||
if (code === 0) { |
var url = ''; |
||||
this.$message.success('操作成功'); |
var params = {}; |
||||
|
if (this.pageType == 'add') { |
||||
this.handleCancle(); |
url = '/actual/base/safetyEquipment/save'; |
||||
} else if (code >= 8000) { |
} else { |
||||
this.$message.error(msg); |
url = '/actual/base/safetyEquipment/update'; |
||||
} |
} |
||||
}, |
params = { ...this.formData }; |
||||
handleCancle() { |
const { data, code, msg } = await requestPost(url, params); |
||||
this.resetData(); |
if (code === 0) { |
||||
this.$emit('handleClose'); |
this.$message.success('操作成功'); |
||||
}, |
|
||||
resetData() { |
this.handleCancle(); |
||||
this.$refs.form.resetFields(); |
} else if (code >= 8000) { |
||||
}, |
this.$message.error(msg); |
||||
// 开启加载动画 |
} |
||||
startLoading() { |
}, |
||||
loading = Loading.service({ |
handleCancle() { |
||||
lock: true, // 是否锁定 |
this.resetData(); |
||||
text: '正在加载……', // 加载中需要显示的文字 |
this.$emit('handleClose'); |
||||
background: 'rgba(0,0,0,.7)' // 背景颜色 |
}, |
||||
}); |
resetData() { |
||||
}, |
this.$refs.form.resetFields(); |
||||
// 结束加载动画 |
}, |
||||
endLoading() { |
// 开启加载动画 |
||||
// clearTimeout(timer); |
startLoading() { |
||||
if (loading) { |
loading = Loading.service({ |
||||
loading.close(); |
lock: true, // 是否锁定 |
||||
} |
text: '正在加载……', // 加载中需要显示的文字 |
||||
}, // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 |
background: 'rgba(0,0,0,.7)' // 背景颜色 |
||||
initMap() { |
}); |
||||
let { latitude, longitude } = this.$store.state.user; |
}, |
||||
|
// 结束加载动画 |
||||
if (this.formData.latitude && this.formData.longitude) { |
endLoading() { |
||||
latitude = this.formData.latitude; |
// clearTimeout(timer); |
||||
longitude = this.formData.longitude; |
if (loading) { |
||||
} |
loading.close(); |
||||
if (!latitude || latitude == '' || latitude == '0') { |
} |
||||
latitude = 39.9088810666821; |
}, // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 |
||||
longitude = 116.39743841556731; |
initMap() { |
||||
} |
let { latitude, longitude } = this.$store.state.user; |
||||
|
|
||||
this.$nextTick(() => { |
if (this.formData.latitude && this.formData.longitude) { |
||||
map = new daiMap( |
latitude = this.formData.latitude; |
||||
document.getElementById('app_event'), |
longitude = this.formData.longitude; |
||||
{ latitude, longitude }, |
} |
||||
{ |
if (!latitude || latitude == '' || latitude == '0') { |
||||
zoom: 16.2, // 设置地图缩放级别 |
latitude = 39.9088810666821; |
||||
pitch: 43.5, // 设置俯仰角 |
longitude = 116.39743841556731; |
||||
rotation: 45 // 设置地图旋转角度 |
} |
||||
} |
|
||||
); |
this.$nextTick(() => { |
||||
// 监听地图平移结束 |
map = new daiMap( |
||||
map.on('dragend', e => { |
document.getElementById('app_event'), |
||||
this.handleMoveCenter(e); |
{ latitude, longitude }, |
||||
}); |
{ |
||||
|
zoom: 16.2, // 设置地图缩放级别 |
||||
map.setCenter(latitude, longitude); |
pitch: 43.5, // 设置俯仰角 |
||||
if (this.formData.latitude) { |
rotation: 45 // 设置地图旋转角度 |
||||
map.setMarker(latitude, longitude); |
} |
||||
} |
); |
||||
}); |
// 监听地图平移结束 |
||||
}, |
map.on('dragend', e => { |
||||
async handleMoveCenter() { |
this.handleMoveCenter(e); |
||||
//修改地图中心点 |
}); |
||||
const { lat, lng } = map.getCenter(); |
|
||||
this.formData.latitude = lat; |
map.setCenter(latitude, longitude); |
||||
this.formData.longitude = lng; |
if (this.formData.latitude) { |
||||
map.setMarker(lat, lng); |
map.setMarker(latitude, longitude); |
||||
|
} |
||||
let { msg, data } = await map.getAddress(lat, lng); |
}); |
||||
if (msg == 'success') { |
}, |
||||
this.formData.location = data.address; |
async handleMoveCenter() { |
||||
this.searchValue = data.address; |
//修改地图中心点 |
||||
this.searchOptions = []; |
const { lat, lng } = map.getCenter(); |
||||
} |
this.formData.latitude = lat; |
||||
}, |
this.formData.longitude = lng; |
||||
async remoteMethod(query) { |
map.setMarker(lat, lng); |
||||
if (query !== '') { |
|
||||
this.loading = true; |
let { msg, data } = await map.getAddress(lat, lng); |
||||
const { msg, data } = await map.searchNearby(query); |
if (msg == 'success') { |
||||
this.loading = false; |
this.formData.location = data.address; |
||||
this.resultList = []; |
this.searchValue = data.address; |
||||
|
this.searchOptions = []; |
||||
if (msg == 'success' && data.resultList && data.resultList.length > 0) { |
} |
||||
if (data.resultList && data.resultList.length > 0) { |
}, |
||||
this.resultList = data.resultList; |
async remoteMethod(query) { |
||||
this.searchOptions = this.resultList.map(item => { |
if (query !== '') { |
||||
return { value: `${item.id}`, label: `${item.address + item.name}` }; |
this.loading = true; |
||||
}); |
const { msg, data } = await map.searchNearby(query); |
||||
} |
this.loading = false; |
||||
} else { |
this.resultList = []; |
||||
this.searchOptions = [ |
|
||||
{ |
if (msg == 'success' && data.resultList && data.resultList.length > 0) { |
||||
value: '0', |
if (data.resultList && data.resultList.length > 0) { |
||||
label: '未检索到结果' |
this.resultList = data.resultList; |
||||
} |
this.searchOptions = this.resultList.map(item => { |
||||
]; |
return { value: `${item.id}`, label: `${item.address + item.name}` }; |
||||
} |
}); |
||||
} else { |
} |
||||
this.searchOptions = []; |
} else { |
||||
} |
this.searchOptions = [ |
||||
}, |
{ |
||||
handleClickKey(index) { |
value: '0', |
||||
let selPosition = this.resultList[index]; |
label: '未检索到结果' |
||||
let lonlat = selPosition.lonlat.split(' '); |
} |
||||
map.setCenter(lonlat[1], lonlat[0]); |
]; |
||||
map.setMarker(lonlat[1], lonlat[0]); |
} |
||||
this.formData.latitude = lonlat[1]; |
} else { |
||||
this.formData.longitude = lonlat[0]; |
this.searchOptions = []; |
||||
this.formData.location = selPosition.address + selPosition.name; |
} |
||||
} |
}, |
||||
} |
handleClickKey(index) { |
||||
}; |
let selPosition = this.resultList[index]; |
||||
</script> |
let lonlat = selPosition.lonlat.split(' '); |
||||
|
map.setCenter(lonlat[1], lonlat[0]); |
||||
<style lang="scss" scoped> |
map.setMarker(lonlat[1], lonlat[0]); |
||||
@import '@/assets/scss/modules/management/form-main.scss'; |
this.formData.latitude = lonlat[1]; |
||||
@import '@/assets/scss/modules/management/form.scss'; |
this.formData.longitude = lonlat[0]; |
||||
@import '@/assets/scss/modules/visual/a_customize.scss'; |
this.formData.location = selPosition.address + selPosition.name; |
||||
|
} |
||||
</style> |
} |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
@import '@/assets/scss/modules/management/form-main.scss'; |
||||
|
@import '@/assets/scss/modules/management/form.scss'; |
||||
|
@import '@/assets/scss/modules/visual/a_customize.scss'; |
||||
|
</style> |
||||
|
Loading…
Reference in new issue