From 9bd6446a762e39d7e2814842afbe0009018db040 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: Wed, 19 May 2021 23:15:22 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=AE=9E=E7=8E=B0=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=88=BF=E5=B1=8B=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api/Ewide.Application/Entity/BsHouseCode.cs | 52 +++ Api/Ewide.Application/Ewide.Application.xml | 7 + .../Service/HouseCode/Dto/HouseCodeInput.cs | 42 +++ .../Service/HouseCode/HouseCodeService.cs | 35 ++ .../Service/HouseCode/IHouseCodeService.cs | 14 + .../Dto/HouseProjectInfoInput.cs | 8 + .../HouseProjectInfoService.cs | 16 +- .../IHouseProjectInfoService.cs | 3 +- Web/src/assets/style/app.less | 1 + Web/src/assets/style/lib/page.less | 8 + Web/src/common/api/index.js | 2 +- .../common/api/requests/business/houseCode.js | 3 + .../api/requests/business/houseProjectInfo.js | 3 +- Web/src/common/api/requests/business/index.js | 4 +- Web/src/components/yoTable/index.js | 8 +- .../business/house/houseCode/form/index.vue | 31 +- .../business/house/houseCode/form/part.vue | 332 +++++++++++++----- .../house/houseInfo/form/base/building.vue | 1 + .../pages/business/house/houseInfo/index.vue | 235 ++++++++++++- .../pages/business/house/houseInfo/query.vue | 192 ++++++++++ Web/src/views/main/_layout/content.vue | 1 + 21 files changed, 885 insertions(+), 113 deletions(-) create mode 100644 Api/Ewide.Application/Entity/BsHouseCode.cs create mode 100644 Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs create mode 100644 Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs create mode 100644 Api/Ewide.Application/Service/HouseCode/IHouseCodeService.cs create mode 100644 Web/src/assets/style/lib/page.less create mode 100644 Web/src/common/api/requests/business/houseCode.js create mode 100644 Web/src/pages/business/house/houseInfo/query.vue diff --git a/Api/Ewide.Application/Entity/BsHouseCode.cs b/Api/Ewide.Application/Entity/BsHouseCode.cs new file mode 100644 index 0000000..8886a7a --- /dev/null +++ b/Api/Ewide.Application/Entity/BsHouseCode.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Ewide.Application.Entity +{ + [Table("bs_house_code")] + [Comment("房屋编码表")] + public class BsHouseCode : Core.DEntityBase + { + [Comment("系统使用的区域编码")] + [MaxLength(50)] + [Required] + public string AreaCode { get; set; } + + [Comment("项目ID")] + [MaxLength(36)] + [Required] + public string ProjectId { get; set; } + + [Comment("编号")] + [MaxLength(3)] + [Required] + public string No { get; set; } + + [Comment("片区ID")] + [MaxLength(36)] + [Required] + public string ZoneId { get; set; } + + [Comment("详细地址")] + [MaxLength(500)] + [Required] + public string Address { get; set; } + + [Comment("性质")] + [Required] + public int Type { get; set; } + + [Comment("所属行业")] + [Required] + public int Industry { get; set; } + + [Comment("坐标-经度")] + [MaxLength(50)] + public string Lng { get; set; } + + [Comment("坐标-纬度")] + [MaxLength(50)] + public string Lat { get; set; } + } +} diff --git a/Api/Ewide.Application/Ewide.Application.xml b/Api/Ewide.Application/Ewide.Application.xml index 4a7d351..772d2e1 100644 --- a/Api/Ewide.Application/Ewide.Application.xml +++ b/Api/Ewide.Application/Ewide.Application.xml @@ -51,5 +51,12 @@ + + + 获取项目下拉列表 + + + + diff --git a/Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs b/Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs new file mode 100644 index 0000000..c4eca9e --- /dev/null +++ b/Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs @@ -0,0 +1,42 @@ +using Ewide.Core; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ewide.Application.Service.HouseCode.Dto +{ + public class HouseCodeInput + { + } + + public class AddHouseCodeInput : PageInputBase + { + [Required(ErrorMessage = "区域编码不能为空")] + public string AreaCode { get; set; } + [Required(ErrorMessage = "项目Id不能为空")] + public string ProjectId { get; set; } + [Required(ErrorMessage = "房屋编号不能为空")] + public string No { get; set; } + [Required(ErrorMessage = "片区Id不能为空")] + public string ZoneId { get; set; } + [Required(ErrorMessage = "房屋地址不能为空")] + public string Address { get; set; } + [Required(ErrorMessage = "房屋性质不能为空")] + public int Type { get; set; } + [Required(ErrorMessage = "所属行业不能为空")] + public int Industry { get; set; } + [Required(ErrorMessage = "经度不能为空")] + public string Lng { get; set; } + [Required(ErrorMessage = "纬度不能为空")] + public string Lat { get; set; } + } + + public class EditHouseCodeInput : AddHouseCodeInput + { + [Required(ErrorMessage = "房屋编码Id不能为空")] + public string Id { get; set; } + } +} diff --git a/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs b/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs new file mode 100644 index 0000000..f5e98e5 --- /dev/null +++ b/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs @@ -0,0 +1,35 @@ +using Ewide.Application.Entity; +using Ewide.Application.Service.HouseCode.Dto; +using Furion.DatabaseAccessor; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ewide.Application.Service.HouseCode +{ + public class HouseCodeService : IHouseCodeService, IDynamicApiController, ITransient + { + private readonly IRepository _houseCodeRep; + + public HouseCodeService(IRepository HouseCodeRep) + { + _houseCodeRep = HouseCodeRep; + } + + [HttpPost("/houseCode/add")] + public async Task AddHouseCode(AddHouseCodeInput input) + { + var houseCode = input.Adapt(); + var isExist = await _houseCodeRep.AnyAsync(p => p.AreaCode == houseCode.AreaCode && p.ProjectId == houseCode.ProjectId && p.No == houseCode.No); + if (isExist) throw Oops.Oh("房屋编码已存在,不可重复添加"); + await _houseCodeRep.InsertAsync(houseCode); + } + } +} diff --git a/Api/Ewide.Application/Service/HouseCode/IHouseCodeService.cs b/Api/Ewide.Application/Service/HouseCode/IHouseCodeService.cs new file mode 100644 index 0000000..c735523 --- /dev/null +++ b/Api/Ewide.Application/Service/HouseCode/IHouseCodeService.cs @@ -0,0 +1,14 @@ +using Ewide.Application.Service.HouseCode.Dto; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ewide.Application.Service.HouseCode +{ + public interface IHouseCodeService + { + Task AddHouseCode(AddHouseCodeInput input); + } +} diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs b/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs index 7f6a693..6efcdff 100644 --- a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs +++ b/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs @@ -41,4 +41,12 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto { public string pid { get; set; } } + + public class ListHouseProjectInfoInput + { + [Required(ErrorMessage = "区域编码不可为空")] + public string AreaCode { get; set; } + [Required(ErrorMessage = "性质不可为空")] + public int Type { get; set; } + } } diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs index 5b5273d..52e7588 100644 --- a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs +++ b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs @@ -121,7 +121,7 @@ namespace Ewide.Application.Service.HouseProjectInfo } [HttpGet("/houseProjectInfo/nextSort")] - public async Task GetNextProjectSortByAreaCode([FromQuery] HouseProjectInfoInput input) + public async Task GetNextProjectSortByAreaCode([FromQuery] ListHouseProjectInfoInput input) { //var projects = await _houseProjectInfoRep.DetachedEntities // .Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type) @@ -138,5 +138,19 @@ namespace Ewide.Application.Service.HouseProjectInfo return p.GetValueOrDefault(0) + 1; } + + /// + /// 获取项目下拉列表 + /// + /// + /// + [HttpGet("houseProjectInfo/list")] + public async Task GetProjectList([FromQuery] ListHouseProjectInfoInput input) + { + return await _houseProjectInfoRep.DetachedEntities + .Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type) + .OrderBy(p => p.Sort) + .ToListAsync(); + } } } diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs index d4c74c0..2d6824d 100644 --- a/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs +++ b/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs @@ -18,6 +18,7 @@ namespace Ewide.Application.Service.HouseProjectInfo Task GetProject([FromQuery] QueryProjectInput input); Task QueryProjectPageList([FromQuery] PageProjectInput input); - Task GetNextProjectSortByAreaCode([FromQuery] HouseProjectInfoInput input); + Task GetNextProjectSortByAreaCode([FromQuery] ListHouseProjectInfoInput input); + Task GetProjectList([FromQuery] ListHouseProjectInfoInput input); } } diff --git a/Web/src/assets/style/app.less b/Web/src/assets/style/app.less index 9511bbf..219f657 100644 --- a/Web/src/assets/style/app.less +++ b/Web/src/assets/style/app.less @@ -22,6 +22,7 @@ @import './lib/list.less'; @import './lib/form.less'; @import './lib/form-page.less'; +@import './lib/page.less'; @import './lib/description.less'; @import './lib/input.less'; @import './lib/select.less'; diff --git a/Web/src/assets/style/lib/page.less b/Web/src/assets/style/lib/page.less new file mode 100644 index 0000000..5ea7706 --- /dev/null +++ b/Web/src/assets/style/lib/page.less @@ -0,0 +1,8 @@ +@import (reference) '~@/assets/style/extend.less'; +.yo-page { + &--header { + padding: @padding-md 0; + + background-color: @white; + } +} diff --git a/Web/src/common/api/index.js b/Web/src/common/api/index.js index 5260960..fbf090e 100644 --- a/Web/src/common/api/index.js +++ b/Web/src/common/api/index.js @@ -78,7 +78,7 @@ for (let key in urls) { const item = urls[key] let url = '', - method = 'post', + method = 'get', options = {} if (item.constructor === String) { url = item diff --git a/Web/src/common/api/requests/business/houseCode.js b/Web/src/common/api/requests/business/houseCode.js new file mode 100644 index 0000000..87ae030 --- /dev/null +++ b/Web/src/common/api/requests/business/houseCode.js @@ -0,0 +1,3 @@ +export default { + houseCodeAdd: ['/houseCode/add', 'post'] +} \ No newline at end of file diff --git a/Web/src/common/api/requests/business/houseProjectInfo.js b/Web/src/common/api/requests/business/houseProjectInfo.js index cdedfaa..d0e965e 100644 --- a/Web/src/common/api/requests/business/houseProjectInfo.js +++ b/Web/src/common/api/requests/business/houseProjectInfo.js @@ -4,5 +4,6 @@ export default { houseProejctEdit: ['/houseProjectInfo/edit', 'post'], houseProejctDelete: ['/houseProjectInfo/delete', 'post'], houseProejctDetail: ['/houseProjectInfo/detail', 'get'], - houseProjectNextSort:['/houseProjectInfo/nextSort','get'] + houseProjectNextSort: ['/houseProjectInfo/nextSort', 'get'], + houseProjectList: ['houseProjectInfo/list', 'get'] } \ No newline at end of file diff --git a/Web/src/common/api/requests/business/index.js b/Web/src/common/api/requests/business/index.js index 9688ff2..45b68b7 100644 --- a/Web/src/common/api/requests/business/index.js +++ b/Web/src/common/api/requests/business/index.js @@ -1,5 +1,7 @@ import houseProjectInfo from './houseProjectInfo' +import houseCode from './houseCode' export default { - ...houseProjectInfo + ...houseProjectInfo, + ...houseCode } \ No newline at end of file diff --git a/Web/src/components/yoTable/index.js b/Web/src/components/yoTable/index.js index eb89b08..5ee24f3 100644 --- a/Web/src/components/yoTable/index.js +++ b/Web/src/components/yoTable/index.js @@ -19,6 +19,9 @@ export default { type: Array, require: true, }, + moreQuery: { + type: Function + } }, data() { @@ -203,10 +206,13 @@ export default { {this.$scopedSlots.query()} - + 查询 重置 + { + this.moreQuery && 更多查询条件 + } diff --git a/Web/src/pages/business/house/houseCode/form/index.vue b/Web/src/pages/business/house/houseCode/form/index.vue index 2942068..99608b9 100644 --- a/Web/src/pages/business/house/houseCode/form/index.vue +++ b/Web/src/pages/business/house/houseCode/form/index.vue @@ -34,21 +34,6 @@ - - - - - @@ -62,7 +47,7 @@ 取消 - 保存 + 保存 @@ -86,6 +71,8 @@ export default { component: () => import('./part'), }, ], + + saving: false, }; }, @@ -108,6 +95,18 @@ export default { /** * 对表单提交进行处理 */ + this.saving = true; + this.$api + .houseCodeAdd(formData) + .then(({ success }) => { + if (success) { + this.$message.success('保存成功'); + 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 e4a7052..e326c96 100644 --- a/Web/src/pages/business/house/houseCode/form/part.vue +++ b/Web/src/pages/business/house/houseCode/form/part.vue @@ -16,17 +16,37 @@ - + + + {{ item.value }} + + + + + {{ item.value }} + + + 宁波市 - - + @@ -34,8 +54,22 @@ - - - + + + + {{ item.name }} + + + + + - + + + - + + + + - - + + - - + +
- 缺搜索 -
+ +
- - - - - - {{ item.value }} - - - - - {{ item.value }} - - @@ -106,13 +131,23 @@ /* 表单内容默认值 */ const defaultForm = { /* ... */ - nature: '1', + type: '1', + no: '001', + zoneId: 'test', }; export default { props: ['param'], data() { + const validatorIndustry = (rule, value, callback) => { + if (this.form.type == 2 && !value) { + callback(new Error('请选择所属行业、系统')); + } else { + callback(); + } + }; + return { labelCol: { flex: '150px' }, wrapperCol: { flex: '1' }, @@ -122,8 +157,14 @@ export default { /** 验证格式 */ rules: { /* ... */ + type: [{ required: true, message: '请选择房屋性质' }], + industry: [{ validator: validatorIndustry }], areaCode: [{ required: true, message: '请选择房屋所在区域' }], - code: [{ required: true, message: '请输入房屋序号' }], + projectId: [{ required: true, message: '请选择项目', trigger: 'blur' }], + no: [{ required: true, message: '请输入房屋序号', trigger: 'blur' }], + address: [{ required: true, message: '请输入房屋地址', trigger: 'blur' }], + lng: [{ required: true, message: '请在地图中选择坐标' }], + lat: [{ required: true, message: '请在地图中选择坐标' }], }, /** 加载异步数据状态 */ @@ -131,42 +172,15 @@ export default { /** 其他成员属性 */ /* ... */ - houseType: [], - houseIndustry: [], - options: [ - { - value: 'zhejiang', - label: 'Zhejiang', - children: [ - { - value: 'hangzhou', - label: 'Hangzhou', - children: [ - { - value: 'xihu', - label: 'West Lake', - }, - ], - }, - ], - }, - { - value: 'jiangsu', - label: 'Jiangsu', - children: [ - { - value: 'nanjing', - label: 'Nanjing', - children: [ - { - value: 'zhonghuamen', - label: 'Zhong Hua Men', - }, - ], - }, - ], - }, - ], + codes: { + houseType: [], + houseIndustry: [], + }, + + options: { + areaTree: [], + projects: [], + }, }; }, @@ -176,7 +190,11 @@ export default { }, mounted() { - new AMap.Map(this.$refs.map); + this.onMapInit(); + }, + + beforeDestroy() { + if (this.map) this.map.destroy(); }, methods: { @@ -208,6 +226,7 @@ export default { /** 验证通过后可以对数据进行转换得到想要提交的格式 */ /* ... */ + record.areaCode = record.areaCode[3]; reslove(record); } else { @@ -246,7 +265,8 @@ export default { this.loading = true; /** 可以在这里await获取一些异步数据 */ /* ... */ - this.onLoadCodes(); + await this.onLoadCodes(); + await this.onLoadAreaTree(); this.loading = false; }, @@ -259,10 +279,158 @@ export default { this.$api.sysDictTypeDropDownAwait({ code: 'dic_house_industry' }), ]) .then(([dic_house_type, dic_house_industry]) => { - this.houseType = dic_house_type.data; - this.houseIndustry = dic_house_industry.data; + this.codes.houseType = dic_house_type.data; + this.codes.houseIndustry = dic_house_industry.data; }); }, + + onMapInit() { + 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 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), + }); + } + + geocoder.getAddress(position, (status, result) => { + if (status === 'complete' && result.regeocode) { + this.onSetPosition(result.regeocode.formattedAddress, position); + } else { + console.error('根据经纬度查询地址失败'); + } + }); + }; + + this.map.on('click', (e) => { + setMarker(e.lnglat); + }); + + 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) => { + setMarker(p.location); + }); + + 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, + }); + } + }); + }, + + onSetPosition(address, { lng, lat }) { + this.$set(this.form, 'address', address); + this.$set(this.form, 'lng', lng); + this.$set(this.form, 'lat', lat); + }, + + onLoadAreaTree() { + return this.$api.getAreaTree().then(({ data }) => { + this.options.areaTree = data; + }); + }, + + /** + * 切换房屋性质 + */ + onTypeChange() { + if (this.form.industry) { + this.form.industry = undefined; + } + this.getProjects(); + }, + + /** + * 切换区域 + */ + onAreaCodeChange() { + if (this.form.areaCode.length != 4) { + this.form.areaCode = []; + } + + this.getProjects(); + }, + + getProjects() { + if (this.form.projectId) { + this.form.projectId = undefined; + } + if (this.form.areaCode && this.form.areaCode.length === 4) { + this.loading = true; + this.$api + .houseProjectList({ + areaCode: this.form.areaCode[3], + type: this.form.type, + }) + .then(({ data }) => { + this.options.projects = data; + }) + .finally(() => { + this.loading = false; + }); + } + }, + + /** + * 切换项目 + */ + onProjectChange() {}, }, }; \ No newline at end of file diff --git a/Web/src/pages/business/house/houseInfo/form/base/building.vue b/Web/src/pages/business/house/houseInfo/form/base/building.vue index 46bb83e..65c3e82 100644 --- a/Web/src/pages/business/house/houseInfo/form/base/building.vue +++ b/Web/src/pages/business/house/houseInfo/form/base/building.vue @@ -14,6 +14,7 @@ > + diff --git a/Web/src/pages/business/house/houseInfo/index.vue b/Web/src/pages/business/house/houseInfo/index.vue index d7fceb3..ecff33a 100644 --- a/Web/src/pages/business/house/houseInfo/index.vue +++ b/Web/src/pages/business/house/houseInfo/index.vue @@ -1,10 +1,227 @@ \ No newline at end of file + + +
+ + + + + + + + + + + + +
+ (test)打开表单 +
+ + + + + + + 编辑 + + + + 删除 + + + + + + +
+
+ + +
+ + \ No newline at end of file diff --git a/Web/src/pages/business/house/houseInfo/query.vue b/Web/src/pages/business/house/houseInfo/query.vue new file mode 100644 index 0000000..7b5defe --- /dev/null +++ b/Web/src/pages/business/house/houseInfo/query.vue @@ -0,0 +1,192 @@ + + \ No newline at end of file diff --git a/Web/src/views/main/_layout/content.vue b/Web/src/views/main/_layout/content.vue index 2967dee..304648e 100644 --- a/Web/src/views/main/_layout/content.vue +++ b/Web/src/views/main/_layout/content.vue @@ -58,6 +58,7 @@ v-for="pane in panes" >