From e4696f678e1462e8761a1d45fd5260a53890a41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=AA=E5=B8=A6=E5=A4=A7=E4=BD=AC=E6=B0=94=E5=9C=BA?= <188633308@qq.com> Date: Fri, 21 May 2021 14:51:44 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=85=81=E8=AE=B8=E6=89=93=E5=BC=80?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=89=AF=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web/src/assets/style/main.less | 14 ++ .../common/api/requests/business/houseCode.js | 1 + .../business/house/houseCode/form/index.vue | 60 +++++-- .../business/house/houseCode/form/part.vue | 165 ++++++++++-------- .../pages/business/house/houseCode/index.vue | 8 +- Web/src/views/main/_layout/content.vue | 3 + Web/src/views/main/index.vue | 1 + 7 files changed, 154 insertions(+), 98 deletions(-) diff --git a/Web/src/assets/style/main.less b/Web/src/assets/style/main.less index 8d37c66..ca5c019 100644 --- a/Web/src/assets/style/main.less +++ b/Web/src/assets/style/main.less @@ -194,6 +194,20 @@ } } } + .yo-layout-tab-subtitle { + line-height: 1; + + display: inline-block; + overflow: hidden; + + max-width: 150px; + + transform: translateY(1px); + white-space: nowrap; + text-overflow: ellipsis; + + opacity: .75; + } +.ant-tabs-tab { margin-left: 0; } diff --git a/Web/src/common/api/requests/business/houseCode.js b/Web/src/common/api/requests/business/houseCode.js index cc586a6..4322594 100644 --- a/Web/src/common/api/requests/business/houseCode.js +++ b/Web/src/common/api/requests/business/houseCode.js @@ -1,5 +1,6 @@ export default { houseCodeAdd: ['/houseCode/add', 'post'], + houseCodeEdit: ['/houseCode/edit', 'post'], houseCodePage: ['/houseCode/page', 'post'], houseCodeNo: '/houseCode/getNextNoByCode', } \ No newline at end of file diff --git a/Web/src/pages/business/house/houseCode/form/index.vue b/Web/src/pages/business/house/houseCode/form/index.vue index 797531e..9f23fa5 100644 --- a/Web/src/pages/business/house/houseCode/form/index.vue +++ b/Web/src/pages/business/house/houseCode/form/index.vue @@ -96,25 +96,47 @@ export default { * 对表单提交进行处理 */ this.saving = true; - this.$api - .houseCodeAdd(formData) - .then(({ success }) => { - if (success) { - this.$message.success('保存成功'); - this.$confirm({ - content: '已添加成功,是否继续添加?', - onOk: () => { - this.$refs.forms[0].onProjectChange(); - }, - onCancel: () => { - this.closeContentWindow(); - }, - }); - } - }) - .finally(() => { - this.saving = false; - }); + if (!this.param.record) { + this.$api + .houseCodeAdd(formData) + .then(({ success }) => { + if (success) { + this.$message.success('保存成功'); + this.$confirm({ + content: '已添加成功,是否继续添加?', + onOk: () => { + this.$refs.forms[0].onProjectChange(); + }, + onCancel: () => { + this.closeContentWindow(); + }, + }); + } + }) + .finally(() => { + this.saving = false; + }); + } else { + this.$api + .houseCodeEdit(formData) + .then(({ success }) => { + if (success) { + this.$message.success('保存成功'); + this.$confirm({ + content: '编辑成功,是否继续保留当前页?', + onOk: () => { + this.$refs.forms[0].onProjectChange(); + }, + onCancel: () => { + this.closeContentWindow(); + }, + }); + } + }) + .finally(() => { + this.saving = false; + }); + } }, }, }; diff --git a/Web/src/pages/business/house/houseCode/form/part.vue b/Web/src/pages/business/house/houseCode/form/part.vue index 665ae22..7d2da8b 100644 --- a/Web/src/pages/business/house/houseCode/form/part.vue +++ b/Web/src/pages/business/house/houseCode/form/part.vue @@ -251,10 +251,6 @@ export default { this.onFillData(); }, - mounted() { - this.onMapInit(); - }, - beforeDestroy() { if (this.map) this.map.destroy(); }, @@ -289,6 +285,14 @@ export default { if (this.form.id) { this.onAreaCodeChange(true); } + + this.$nextTick(async () => { + await this.onMapInit(); + if (this.form.lng && this.form.lat) { + this.setMarker([this.form.lng, this.form.lat]); + this.map.setCenter([this.form.lng, this.form.lat]); + } + }); }, /** @@ -362,95 +366,102 @@ export default { }, onMapInit() { - const city = '宁波市'; + return new Promise((resolve) => { + const city = '宁波市'; - const district = new AMap.DistrictSearch({ - subdistrict: 0, - extensions: 'all', - level: 'city', - }); - - district.search(city, (status, result) => { - const bounds = result.districtList[0].boundaries; - const mask = []; - for (let i = 0; i < bounds.length; i += 1) { - mask.push([bounds[i]]); - } - - // 挂载map到this,但不监听 - this.map = new AMap.Map(this.$refs.map, { - city, - viewMode: '3D', - mask, - zoom: 12, + const district = new AMap.DistrictSearch({ + subdistrict: 0, + extensions: 'all', + level: 'city', }); - const geocoder = new AMap.Geocoder({ city }); - - let marker; - const setMarker = (position) => { - if (marker) { - marker.setPosition(position); - } else { - marker = new AMap.Marker({ - map: this.map, - icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png', - position, - offset: new AMap.Pixel(-13, -30), - }); + district.search(city, (status, result) => { + const bounds = result.districtList[0].boundaries; + const mask = []; + for (let i = 0; i < bounds.length; i += 1) { + mask.push([bounds[i]]); } - geocoder.getAddress(position, (status, result) => { - if (status === 'complete' && result.regeocode) { - this.onSetPosition(result.regeocode.formattedAddress, position); - } else { - console.error('根据经纬度查询地址失败'); - } + // 挂载map到this,但不监听 + this.map = new AMap.Map(this.$refs.map, { + city, + viewMode: '3D', + mask, + zoom: 12, }); - }; - this.map.on('click', (e) => { - setMarker(e.lnglat); - }); + const geocoder = new AMap.Geocoder({ city }); - const auto = new AMap.AutoComplete({ - input: this.$refs['map-search'].$el.querySelector('input'), - city, - citylimit: true, - }); + this.map.on('click', (e) => { + this.setMarker(e.lnglat, geocoder); + }); - const placeSearch = new AMap.PlaceSearch({ - city, - citylimit: true, - pageSize: 1, - }); + this.map.on('complete', () => { + resolve(); + }); - auto.on('select', ({ poi: { name: keywords, adcode } }) => { - this.map.clearMap(); - marker = null; - placeSearch.search(keywords, (status, result) => { - const { - poiList: { pois }, - } = result; - pois.forEach((p) => { - setMarker(p.location); + const auto = new AMap.AutoComplete({ + input: this.$refs['map-search'].$el.querySelector('input'), + city, + citylimit: true, + }); + + const placeSearch = new AMap.PlaceSearch({ + city, + citylimit: true, + pageSize: 1, + }); + + auto.on('select', ({ poi: { name: keywords, adcode } }) => { + this.map.clearMap(); + marker = null; + placeSearch.search(keywords, (status, result) => { + const { + poiList: { pois }, + } = result; + pois.forEach((p) => { + this.setMarker(p.location, geocoder); + }); + + this.map.setFitView(); }); - - this.map.setFitView(); }); + + for (let i = 0; i < bounds.length; i += 1) { + new AMap.Polyline({ + path: bounds[i], + strokeColor: '#ccc', + strokeWeight: 4, + map: this.map, + }); + } }); - - for (let i = 0; i < bounds.length; i += 1) { - new AMap.Polyline({ - path: bounds[i], - strokeColor: '#ccc', - strokeWeight: 4, - map: this.map, - }); - } }); }, + setMarker(position, geocoder) { + if (this.marker) { + this.marker.setPosition(position); + } else { + this.marker = new AMap.Marker({ + map: this.map, + icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png', + position, + offset: new AMap.Pixel(-13, -30), + }); + } + + if (geocoder) { + geocoder.getAddress(position, (status, result) => { + if (status === 'complete' && result.regeocode) { + this.onSetPosition(result.regeocode.formattedAddress, position); + } else { + console.error('根据经纬度查询地址失败'); + } + }); + } + }, + onSetPosition(address, { lng, lat }) { this.$set(this.form, 'address', address); this.$set(this.form, 'lng', lng); diff --git a/Web/src/pages/business/house/houseCode/index.vue b/Web/src/pages/business/house/houseCode/index.vue index 122ca14..1e884ea 100644 --- a/Web/src/pages/business/house/houseCode/index.vue +++ b/Web/src/pages/business/house/houseCode/index.vue @@ -64,7 +64,7 @@ - 新增编码 + 新增房屋编码 @@ -254,7 +254,11 @@ export default { */ onOpen(record) { this.openContentWindow({ - title: '房屋编码', + key: record ? record.id : 'business/house/houseCode/form', + title: record ? '修改房屋编码' : '新增房屋编码', + subTitle: + record && + `${record.areaName}-${record.roadName}-${record.commName}-${record.note}-${`000${record.no}`.slice(-3)}`, path: 'business/house/houseCode/form', param: { record, diff --git a/Web/src/views/main/_layout/content.vue b/Web/src/views/main/_layout/content.vue index 295783b..f049914 100644 --- a/Web/src/views/main/_layout/content.vue +++ b/Web/src/views/main/_layout/content.vue @@ -12,6 +12,9 @@
{{ pane.title }} + + {{`- ${pane.subTitle}`}} +