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/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/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 { 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 = { 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={ + + + 全部 + + 住宅 + + + 非住宅 + + +