From 64bb1c3352f7c824200e408356397620eb790084 Mon Sep 17 00:00:00 2001 From: ky_yusj <2655568377@qq.com> Date: Thu, 24 Jun 2021 16:22:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=20=E5=8C=BA=E5=9F=9F=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HouseProjectInfoService.cs | 1 + .../Service/Area/AreaCodeService.cs | 10 +++++++-- .../src/components/query-table/index.jsx | 5 +++++ .../src/pages/business/house/project/form.jsx | 4 +++- .../pages/business/house/project/index.jsx | 22 ++++++++++++++++++- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/HouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/HouseProjectInfoService.cs index 3efac64..60048d3 100644 --- a/Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/HouseProjectInfoService.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseProjectInfo/HouseProjectInfoService.cs @@ -88,6 +88,7 @@ namespace Ewide.Application.Service.HouseProjectInfo var areaCodeRep = Db.GetRepository(); var projects = await _houseProjectInfoRep.DetachedEntities .Join(areaCodeRep.DetachedEntities, p => p.AreaCode, a => a.Code, (p, a) => new { p, AreaName = a.Name }) + .Where(input.Type>0, x => x.p.Type == input.Type) .Where(!string.IsNullOrEmpty(input.Name), x => x.p.Name.Contains(input.Name)) .Where(!string.IsNullOrEmpty(input.Note), x => x.p.Note.Contains(input.Note)) .Where(!string.IsNullOrEmpty(input.AreaCode), x => x.p.AreaCode == input.AreaCode) diff --git a/Api/Ewide.Core/Service/Area/AreaCodeService.cs b/Api/Ewide.Core/Service/Area/AreaCodeService.cs index 66bf906..337431e 100644 --- a/Api/Ewide.Core/Service/Area/AreaCodeService.cs +++ b/Api/Ewide.Core/Service/Area/AreaCodeService.cs @@ -93,11 +93,17 @@ namespace Ewide.Core.Service.Area #endif } var query = cachedAreaCodes.Where(p => p.LevelType <= level); + var resAreaCode = new List(); if (areaCodeList != null) { - query = query.Where(p => areaCodeList.Contains(p.Code)); + foreach (var code in areaCodeList) + { + var queryRes = query.Where(p => p.Code.StartsWith(code)); + resAreaCode.AddRange(queryRes); + } + cachedAreaCodes = resAreaCode.Distinct().ToList(); } - cachedAreaCodes = query.ToList(); + return new TreeBuildUtil().DoTreeBuild(cachedAreaCodes.Select(u => new AreaTreeNode { Code = u.Code, diff --git a/web-react/src/components/query-table/index.jsx b/web-react/src/components/query-table/index.jsx index 62dc0bd..01a3b19 100644 --- a/web-react/src/components/query-table/index.jsx +++ b/web-react/src/components/query-table/index.jsx @@ -1,6 +1,7 @@ import React, { Component } from 'react' import { Form, Button, Table, Tooltip } from 'antd' import { AntIcon } from 'components' +import { isEqual } from 'lodash' const propsMap = ['columns', 'autoLoad', 'loadData', 'pageIndex', 'pageSize'] @@ -157,6 +158,10 @@ export default class QueryTable extends Component { onLoadData = async () => { this.onLoading() + if (isEqual(this.query, {})) { + this.query = this.props.queryInitialValues + } + const res = await this.loadData( { pageIndex: this.pagination.current, diff --git a/web-react/src/pages/business/house/project/form.jsx b/web-react/src/pages/business/house/project/form.jsx index 750743b..31a7ea1 100644 --- a/web-react/src/pages/business/house/project/form.jsx +++ b/web-react/src/pages/business/house/project/form.jsx @@ -87,7 +87,8 @@ export default class form extends Component { this.record = { pid: params.pid, ...this.record, - areaCode: areaCode.length == 4 ? areaCode : [], + areaCode: + areaCode.length > 0 && areaCode[areaCode.length - 1].length == 12 ? areaCode : [], } //#endregion @@ -213,6 +214,7 @@ export default class form extends Component { rules={[{ required: true, message: '请选择所属区域' }]} > { + if (values.hasOwnProperty('type')) { + this.setState({ type: values.type }) + } + }} query={ + + + 全部 + + 住宅 + + + 非住宅 + + + From 5bf0cb5a126f515e30d86f9980a411f250d11836 Mon Sep 17 00:00:00 2001 From: ky_yusj <2655568377@qq.com> Date: Thu, 24 Jun 2021 18:15:58 +0800 Subject: [PATCH 2/3] update housecode --- .../HouseCode/Dto/HouseCodeOutput.cs | 1 + .../pages/business/house/code/form/index.jsx | 2 + .../pages/business/house/code/form/part.jsx | 66 +++++++++++++------ .../src/pages/business/house/code/index.jsx | 2 +- 4 files changed, 50 insertions(+), 21 deletions(-) diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs index 0316d8b..de2cda4 100644 --- a/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs @@ -29,6 +29,7 @@ namespace Ewide.Application public class GetHouseCodeOutput { public string Id { get; set; } + public string HouseCode { get; set; } public int Type { get; set; } public int Industry { get; set; } public string AreaCode { get; set; } diff --git a/web-react/src/pages/business/house/code/form/index.jsx b/web-react/src/pages/business/house/code/form/index.jsx index ddd7aa4..1583fb5 100644 --- a/web-react/src/pages/business/house/code/form/index.jsx +++ b/web-react/src/pages/business/house/code/form/index.jsx @@ -36,6 +36,8 @@ export default class index extends Component { loading: false, }) }) + } else { + this.setState({ loading: false }) } } diff --git a/web-react/src/pages/business/house/code/form/part.jsx b/web-react/src/pages/business/house/code/form/part.jsx index 2494ff3..e7ddb17 100644 --- a/web-react/src/pages/business/house/code/form/part.jsx +++ b/web-react/src/pages/business/house/code/form/part.jsx @@ -19,6 +19,7 @@ import { cloneDeep, isEqual } from 'lodash' import getDictData from 'util/dic' import { api } from 'common/api' import { CITY } from 'util/global' +import auth from 'components/authorized/handler' const initialValues = { type: 1, @@ -85,6 +86,8 @@ export default class form extends Component { //#region 从后端转换成前段所需格式 await this.initMap() const options = { ...this.state.options } + const { data: areaTree } = await api.getAreaTree() + options.areaTree = areaTree // 有数据 if (this.record) { const { type, areaCode } = this.record @@ -95,6 +98,16 @@ export default class form extends Component { areaCode.substr(0, 9), areaCode, ] + switch (areaTree[0].adCode.length) { + case 6: + this.record.areaCode = this.record.areaCode.slice(1) + break + case 9: + this.record.areaCode = this.record.areaCode.slice(2) + break + default: + break + } // 获取项目和片区列表 const data = await this.getProjectsAndZones({ areaCode: this.record.areaCode, @@ -107,12 +120,12 @@ export default class form extends Component { this.map.setCenter(position) } const codes = await getDictData('house_type', 'house_industry') - const { data: areaTree } = await api.getAreaTree() - options.areaTree = areaTree + this.setState({ codes, options, }) + this.showHouseCode() //#endregion this.form.current.setFieldsValue(this.record) @@ -136,7 +149,7 @@ export default class form extends Component { const postData = form.getFieldsValue() //#region 从前段转换后端所需格式 if (postData.areaCode) { - postData.areaCode = postData.areaCode[3] + postData.areaCode = postData.areaCode[postData.areaCode.length - 1] } //#endregion return postData @@ -282,21 +295,22 @@ export default class form extends Component { type = value.type } - if (!(areaCode && areaCode.length === 4)) return null + if (!(areaCode && areaCode.length > 0 && areaCode[areaCode.length - 1].length === 12)) + return null try { const result = {} if (mode.includes('projects')) { const { data: projects } = await api.houseProjectList({ - areaCode: areaCode[3], + areaCode: areaCode[areaCode.length - 1], type, }) result.projects = projects } if (mode.includes('zones')) { const { data: zones } = await api.houseZoneList({ - areaCode: areaCode[3], + areaCode: areaCode[areaCode.length - 1], }) result.zones = zones } @@ -323,8 +337,14 @@ export default class form extends Component { }) } else if (values) { const { type, industry, areaCode, projectId, no } = values - if (areaCode && areaCode.length === 4 && projectId && no) { - let houseCode = areaCode[3] + if ( + areaCode && + areaCode.length > 0 && + areaCode[areaCode.length - 1].length === 12 && + projectId && + no + ) { + let houseCode = areaCode[areaCode.length - 1] const projectSort = this.state.options.projects.find(p => p.id === projectId).sort houseCode += projectSort.toString().padStart(3, '0') houseCode += no.toString().padStart(3, '0') @@ -368,17 +388,20 @@ export default class form extends Component { // 所属区域 else if (changedValues.hasOwnProperty('areaCode')) { - this.setState({ loading: true }) - const data = await this.getProjectsAndZones() - form.setFieldsValue({ projectId: undefined, zoneId: undefined }) - this.setState({ - options: { - ...this.state.options, - ...data, - }, - loading: false, - }) - this.showHouseCode(form.getFieldsValue()) + const flag = auth({ houseCode: 'getNextNoByCode' }) + if (flag) { + this.setState({ loading: true }) + const data = await this.getProjectsAndZones() + form.setFieldsValue({ projectId: undefined, zoneId: undefined }) + this.setState({ + options: { + ...this.state.options, + ...data, + }, + loading: false, + }) + this.showHouseCode(form.getFieldsValue()) + } } // 所属项目 @@ -474,7 +497,10 @@ export default class form extends Component { Date: Fri, 25 Jun 2021 11:37:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?update=20=E9=80=89=E6=88=BF=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/business/house/member/form.jsx | 252 +++++++++++++++++- .../src/pages/business/house/member/index.jsx | 2 +- 2 files changed, 250 insertions(+), 4 deletions(-) diff --git a/web-react/src/pages/business/house/member/form.jsx b/web-react/src/pages/business/house/member/form.jsx index 70ee907..1857200 100644 --- a/web-react/src/pages/business/house/member/form.jsx +++ b/web-react/src/pages/business/house/member/form.jsx @@ -1,11 +1,257 @@ import React, { Component } from 'react' +import { Form, Input, DatePicker, Select, Radio, Spin, TreeSelect } from 'antd' +import { AntIcon } from 'components' +import { cloneDeep } from 'lodash' +import { api } from 'common/api' +import moment from 'moment' + +const initialValues = { + sex: 0, + sysEmpParam: {}, +} export default class form extends Component { + state = { + // 加载状态 + loading: true, + lockRole: false, + options: { + orgData: [], + roleData: [], + }, + } + + // 表单实例 + form = React.createRef() + + // 初始化数据 + record = {} + + /** + * mount后回调 + */ + componentDidMount() { + this.props.created && this.props.created(this) + } + + /** + * 填充数据 + * 可以在设置this.record之后对其作出数据结构调整 + * [异步,必要] + * @param {*} params + */ + async fillData(params) { + this.record = cloneDeep(params.record || {}) + //#region 从后端转换成前段所需格式 + const orgData = await this.loadOrgData() + const roleData = await this.LoadRoleData() + + // 日期特殊处理 + if (this.record.birthday) { + this.record.birthday = moment(this.record.birthday) + } + + // 提交的时候是"param",而获取下来却是"info",在这里转换一下 + if (this.record.sysEmpInfo) { + this.record.sysEmpParam = this.record.sysEmpInfo + delete this.record.sysEmpInfo + } else if (!this.record.sysEmpParam) { + this.record.sysEmpParam = { + extIds: [], + } + } + + if (params.orgId) { + this.record.sysEmpParam.orgId = params.orgId + } + const defaultRole = params.record + ? await this.loadOwnRole(params.record.id) + : params.orgId + ? await this.loadDefaultRole(params.orgId) + : [] + + if (defaultRole.constructor === Array) { + this.record.roleId = defaultRole.length > 0 ? defaultRole[0] : '' + this.setState({ + lockRole: true, + }) + } else { + this.record.roleId = defaultRole.id + this.setState({ + lockRole: defaultRole.code === 'zone_manager', + }) + } + + this.setState({ + options: { + ...this.state.options, + orgData, + roleData, + }, + }) + + this.record = { + ...this.record, + } + //#endregion + this.form.current.setFieldsValue(this.record) + + this.setState({ + loading: false, + }) + } + + /** + * 获取数据 + * 可以对postData进行数据结构调整 + * [异步,必要] + * @returns + */ + async getData() { + const form = this.form.current + + const valid = await form.validateFields() + if (valid) { + const postData = form.getFieldsValue() + if (this.record) { + postData.id = this.record.id + } + //#region 从前段转换后端所需格式 + //console.log(postData) + //#endregion + return postData + } + } + + //#region 自定义方法 + async loadOrgData() { + const { data } = await api.getOrgTree() + return data + } + + async LoadRoleData() { + const { data } = await api.houseMemberDefaultRoleList() + return data + } + async loadOwnRole(id) { + const { data } = await api.houseMemberOwnRole({ id }) + return data + } + async loadDefaultRole(orgId) { + const { data } = await api.houseMemberDefaultRole({ orgId }) + return data + } render() { return ( -
- 1 -
+
+ }> +
+ + + + + + + + + + + + + {this.props.mode == 'add' && ( + <> + + + + + + + + )} + + + + + + + + + + + 保密 + + + + + + + + + + + + + + + + + + + + +
+
+
) } } diff --git a/web-react/src/pages/business/house/member/index.jsx b/web-react/src/pages/business/house/member/index.jsx index 1b67dae..3780bdc 100644 --- a/web-react/src/pages/business/house/member/index.jsx +++ b/web-react/src/pages/business/house/member/index.jsx @@ -34,7 +34,7 @@ const apiAction = { } // 用于弹窗标题 -const name = '用户' +const name = '人员' export default class index extends Component { state = {