diff --git a/src/views/modules/partymember/icpartyorg-add-or-update.vue b/src/views/modules/partymember/icpartyorg-add-or-update.vue index be97ec4a..aaa09184 100644 --- a/src/views/modules/partymember/icpartyorg-add-or-update.vue +++ b/src/views/modules/partymember/icpartyorg-add-or-update.vue @@ -7,8 +7,8 @@ ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '100px'"> - - + + - - + + - - + + - + - + @@ -116,11 +117,10 @@ mySelectOrg:'', // 我选中的当前党组织 orgPid: '', // 党组织的上级ID,没有上级时为0 orgPids: '', // 党组织的所有上级ID,没有上级时为0 - maSelectAgency: '', // 我选中的当前行政组织 agencyId: '', // 行政组织id agencyPids:'', // 行政组织父ids(英文逗号隔开) - longitude: 36.0722275, //经度 - latitude: 120.38945519, //纬度 + longitude: '', //经度 + latitude: '', //纬度 address: '', introduction: '', // 党组织介绍 @@ -137,11 +137,12 @@ agencyOrgList:[] } }, - mounted () { - setTimeout(() => { - this.initMap() - }, 800); - }, + // mounted () { + // setTimeout(() => { + // console.log(':::::::::::::::::::::::') + // this.initMap() + // }, 800); + // }, methods: { init() { this.visible = true @@ -150,12 +151,14 @@ this.dataForm.staffId = localStorage.getItem('staffId') this.$nextTick(() => { this.$refs['dataForm'].resetFields() + this.dataForm.latitude = '' //设置党组织类型 this.setPartyOrgType() this.getOrgList().then(() => { if (this.dataForm.id) { this.getInfo() } else { + this.initMap() if(this.dataForm.orgPids) { this.dataForm.mySelectOrg = this.dataForm.orgPids.split(':') } else { @@ -214,13 +217,12 @@ if(value != '5'){ // 支部 this.dataForm.agencyId = '' this.dataForm.agencyPids = '' - this.dataForm.maSelectAgency = '' } this.$http.get('/gov/org/customeragency/getOrgTreeByUserAndType', {params: {agencyId: this.agencyId, orgType:value}}).then(({data: res}) => { if (res.code !== 0) { return this.$message.error(res.msg) } - this.agencyOrgList = res.data + this.agencyOrgList = this.removeEmptyChildren(res.data) }).catch(() => {}) }, // 获取党组织列表 @@ -228,8 +230,8 @@ return this.$http.get('/resi/partymember/icPartyOrg/getTreelist', {params: {agencyId: this.agencyId}}).then(({data: res}) => { if (res.code !== 0) { return this.$message.error(res.msg) - } - this.orgList = res.data + } + this.orgList = this.removeEmptyChildren(res.data) this.orgList.unshift({ partyOrgName: '一级组织', id: '0' @@ -237,6 +239,18 @@ }).catch(() => { }) }, + removeEmptyChildren (orgArray) { + orgArray.forEach((orgInfo) => { + if (orgInfo && orgInfo.children) { + if (orgInfo.children.length === 0) { + orgInfo.children = undefined + } else { + this.removeEmptyChildren(orgInfo.children) + } + } + }) + return orgArray; + }, // 党组织选中事件 handleChangeOrg(e) { if (this.dataForm.mySelectOrg.length > 0 && this.dataForm.mySelectOrg) { @@ -250,20 +264,6 @@ this.dataForm.orgPids = '' } }, - // 行政组织选中事件 - handleChangeAgency(e){ - console.log(this.dataForm.maSelectAgency) - if (this.dataForm.maSelectAgency.length > 0 && this.dataForm.maSelectAgency) { - this.dataForm.agencyId = this.dataForm.maSelectAgency[this.dataForm.maSelectAgency.length - 1] - this.dataForm.agencyPids = '' - this.dataForm.maSelectAgency.forEach(element => { - this.dataForm.agencyPids = this.dataForm.agencyPids ? this.dataForm.agencyPids + ':' + element : element - }); - } else { - this.dataForm.agencyId = '' - this.dataForm.agencyPids = '' - } - }, // 获取信息 getInfo() { this.$http.get(`/resi/partymember/icPartyOrg/${this.dataForm.id}`).then(({data: res}) => { @@ -275,10 +275,10 @@ ...res.data } // 党组织组织 - this.dataForm.mySelectOrg = this.dataForm.orgPids + this.dataForm.mySelectOrg = this.dataForm.orgPids.split(':') // 行政组织 - this.dataForm.maSelectAgency = this.dataForm.agencyId - + this.dataForm.agencyId = this.dataForm.agencyId + this.initMap() }).catch(() => { }) @@ -305,13 +305,14 @@ }, // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 initMap () { + document.getElementById('app').innerHTML = '' if (document.getElementById('app')) { document.getElementById('mapSeach_id').style.display = "block" document.getElementById('lon_lat_id').style.display = "block" } // 定义地图中心点坐标 - var center = new window.TMap.LatLng(36.0722275, 120.38945519) + var center = new window.TMap.LatLng( this.dataForm.latitude ? this.dataForm.latitude : 36.0722275, this.dataForm.longitude ? this.dataForm.longitude : 120.38945519) // 定义map变量,调用 TMap.Map() 构造函数创建地图 map = new window.TMap.Map(document.getElementById('app'), { center: center, // 设置地图中心点坐标 @@ -380,8 +381,13 @@ const center = map.getCenter() const lat = center.getLat() const lng = center.getLng() - this.dataForm.latitude = lat - this.dataForm.longitude = lng + if (lng === 120.38945519) { + this.dataForm.latitude = '' + this.dataForm.longitude = '' + } else { + this.dataForm.latitude = lat + this.dataForm.longitude = lng + } this.setMarker(lat, lng) this.convert(lat, lng) }, @@ -435,6 +441,9 @@ computed: { dataRule() { return { + partyOrgName: [ + {required: true, message: this.$t('validate.required'), trigger: 'blur'} + ], mySelectOrg: [ {required: true, message: this.$t('validate.required'), trigger: 'blur'} ], @@ -448,7 +457,7 @@ latitude: [ {required: true, message: this.$t('validate.required'), trigger: 'blur'} ], - maSelectAgency: [ + agencyId: [ {required: true, message: this.$t('validate.required'), trigger: 'blur'} ] }