diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseQuery/HouseQueryService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseQuery/HouseQueryService.cs index 1c30dce..453fd84 100644 --- a/Api/Ewide.Application/Service/HouseSafety/HouseQuery/HouseQueryService.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseQuery/HouseQueryService.cs @@ -34,7 +34,28 @@ namespace Ewide.Application.Service.HouseSafety.HouseQuery [HttpPost("/houseQuery/page")] public async Task QueryPage([FromBody] HouseQueryInput input) { - var sql = @"SELECT HC.ID,HC.HouseCode,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,CA.AdCode AreaCode,Proj.AreaCode,Proj.Note,Proj.Name,CONCAT(Proj.Name,'(',Proj.Note,')') FullProjName,HC.Address,IFNULL(HI.BuildingName,'') BuildingName,IFNULL(HI.TotalFloor,0) TotalFloor,IFNULL(HI.TotalArea,0) TotalArea,HI.LandAttribute,IFNULL(HI.HouseGrade,0) HouseGrade,HC.Type,HC.No,HI.State FROM bs_house_code HC + var sql = @"SELECT + HC.ID, + HC.HouseCode, + AA.Name AreaName, + RA.Name RoadName, + CA.Name CommName, + Proj.AreaCode, + Proj.Note, + Proj.Name, + CONCAT(Proj.Name,'(',Proj.Note,')') FullProjName, + HC.Address, + IFNULL(HI.BuildingName,'') BuildingName, + IFNULL(HI.TotalFloor,0) TotalFloor, + IFNULL(HI.TotalArea,0) TotalArea, + HI.LandAttribute, + IFNULL(HI.HouseGrade,0) HouseGrade, + HC.Type, + HC.No, + HI.State, + HI.CompletedDate, + HI.CreatedTime +FROM bs_house_code HC LEFT JOIN bs_house_info HI ON HI.HouseCodeId = HC.Id LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode @@ -42,7 +63,19 @@ LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9) LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6) WHERE 1=1"; - return await _dapperRepository.QueryPageDataDynamic(sql, input, filterFields: new string[] { "HouseCode", "Address", "BuildingName", "State", "AreaCode", "LandAttribute", "HouseGrade" }); + return await _dapperRepository.QueryPageDataDynamic(sql, input, filterFields: new string[] { + "HouseCode", + "Address", + "BuildingName", + "State", + "AreaCode", + "LandAttribute", + "HouseGrade", + "CompletedDate", + "CreatedTime", + "TotalArea", + "TotalFloor" + }); } } } diff --git a/web-react/src/assets/style/lib/form.less b/web-react/src/assets/style/lib/form.less index 771d844..c587a27 100644 --- a/web-react/src/assets/style/lib/form.less +++ b/web-react/src/assets/style/lib/form.less @@ -315,6 +315,13 @@ white-space: normal; } } +.ant-form-vertical { + .ant-form-item-label { + >label { + font-weight: bold; + } + } +} .ant-form-item-required { &::before { content: '' !important; diff --git a/web-react/src/common/api/requests/business/houseSafety/houseQuery.js b/web-react/src/common/api/requests/business/houseSafety/houseQuery.js new file mode 100644 index 0000000..6357a36 --- /dev/null +++ b/web-react/src/common/api/requests/business/houseSafety/houseQuery.js @@ -0,0 +1,5 @@ +const urls = { + houseQueryPage: ['/houseQuery/page', 'post'], +} + +export default urls \ No newline at end of file diff --git a/web-react/src/common/api/requests/business/houseSafety/index.js b/web-react/src/common/api/requests/business/houseSafety/index.js index d8e22cb..6732039 100644 --- a/web-react/src/common/api/requests/business/houseSafety/index.js +++ b/web-react/src/common/api/requests/business/houseSafety/index.js @@ -5,6 +5,7 @@ import houseMember from './houseMember' import houseSelector from './houseSelector' import houseTask from './houseTask' import houseInfo from './houseInfo' +import houseQuery from './houseQuery' const urls = { ...houseProjectInfo, @@ -13,7 +14,8 @@ const urls = { ...houseMember, ...houseSelector, ...houseTask, - ...houseInfo + ...houseInfo, + ...houseQuery } export default urls \ No newline at end of file diff --git a/web-react/src/components/color-selector/index.jsx b/web-react/src/components/form/color-selector/index.jsx similarity index 100% rename from web-react/src/components/color-selector/index.jsx rename to web-react/src/components/form/color-selector/index.jsx diff --git a/web-react/src/components/form/input-number-range/index.jsx b/web-react/src/components/form/input-number-range/index.jsx new file mode 100644 index 0000000..ac5c7d8 --- /dev/null +++ b/web-react/src/components/form/input-number-range/index.jsx @@ -0,0 +1,46 @@ +import React, { Component } from 'react' +import { Col, Input, InputNumber, Row } from 'antd' +import { AntIcon } from 'components' + +export default class index extends Component { + render() { + const { unit, placeholder, value, onChange } = this.props + + console.log(value) + + return ( + + + + { + const result = [e, value && value[1]] + onChange && onChange(result) + }} + /> + + + + + + { + const result = [value && value[0], e] + onChange && onChange(result) + }} + /> + + {unit && {unit}} + + + ) + } +} diff --git a/web-react/src/components/index.js b/web-react/src/components/index.js index 1da9bcd..b66489e 100644 --- a/web-react/src/components/index.js +++ b/web-react/src/components/index.js @@ -1,12 +1,13 @@ export { default as AntIcon } from 'components/ant-icon' export { default as AuthorityView } from './authority-view' export { default as Auth } from './authorized' -export { default as ColorSelector } from './color-selector' +export { default as ColorSelector } from './form/color-selector' export { default as ComponentDynamic } from './component-dynamic' export { default as Container } from './container' export { default as IconSelector } from './icon-selector' export { default as Image } from './image' export { default as ModalForm } from './modal-form' +export { default as InputNumberRange } from './form/input-number-range' export { default as PhotoPreview } from './photo-preview' export { default as QueryList } from './query-list' export { default as QueryTable } from './query-table' diff --git a/web-react/src/components/query-list/index.jsx b/web-react/src/components/query-list/index.jsx index c052306..54464f5 100644 --- a/web-react/src/components/query-list/index.jsx +++ b/web-react/src/components/query-list/index.jsx @@ -1,6 +1,7 @@ import React, { Component } from 'react' import { Button, Form, List, Pagination, Spin, Tooltip } from 'antd' import { AntIcon } from 'components' +import { cloneDeep } from 'lodash' const propsMap = ['autoLoad', 'loadData', 'pageIndex', 'pageSize'] @@ -113,7 +114,7 @@ export default class QueryList extends Component { pageIndex: this.pagination.current, pageSize: this.pagination.pageSize, }, - this.query + cloneDeep(this.query) ) this.setState( diff --git a/web-react/src/components/query-table/index.jsx b/web-react/src/components/query-table/index.jsx index db24757..f1c3049 100644 --- a/web-react/src/components/query-table/index.jsx +++ b/web-react/src/components/query-table/index.jsx @@ -1,7 +1,7 @@ import React, { Component } from 'react' import { Form, Button, Table, Tooltip, Drawer } from 'antd' import { AntIcon } from 'components' -import { isEqual } from 'lodash' +import { cloneDeep, isEqual } from 'lodash' const propsMap = ['columns', 'autoLoad', 'loadData', 'pageIndex', 'pageSize'] @@ -44,7 +44,8 @@ function renderQueryBar() { onFinish={value => this.onQuery(value)} initialValues={queryInitialValues} onValuesChange={(changedValues, allValues) => - onQueryChange && onQueryChange(changedValues, allValues) + onQueryChange && + this.queryForm.current.setFieldsValue(onQueryChange(changedValues, allValues)) } > {query} @@ -74,17 +75,28 @@ function renderQueryBar() { function renderMoreQueryBody() { const { moreQueryVisible } = this.state - const { moreQuery } = this.props + const { moreQuery, onQueryChange, queryInitialValues } = this.props return ( this.setState({ moreQueryVisible: false })} > -
+ + onQueryChange && + this.moreQueryForm.current.setFieldsValue( + onQueryChange(changedValues, allValues) + ) + } + >
{moreQuery}
@@ -216,7 +228,7 @@ export default class QueryTable extends Component { pageSize: this.pagination.pageSize, ...this.sorter, }, - this.query + cloneDeep(this.query) ) if (res.rows || res.data || res.items) { this.setState({ @@ -291,7 +303,9 @@ export default class QueryTable extends Component { ...queryInitialValues, ...queryValues, } - onQueryChange && onQueryChange(this.query) + + const changedValues = cloneDeep(this.query) + onQueryChange && onQueryChange(changedValues, changedValues) this.onReloadData(true) } diff --git a/web-react/src/pages/business/house/query/index.jsx b/web-react/src/pages/business/house/query/index.jsx index 95653c2..0c03ce9 100644 --- a/web-react/src/pages/business/house/query/index.jsx +++ b/web-react/src/pages/business/house/query/index.jsx @@ -1,11 +1,24 @@ import React, { Component } from 'react' -import { Button, Card, Form, Input, message as Message, Popconfirm, Radio, Select, Tag } from 'antd' -import { AntIcon, Auth, Container, QueryTable } from 'components' +import { + Button, + Card, + Checkbox, + Col, + DatePicker, + Form, + Input, + InputNumber, + message as Message, + Row, + Tag, +} from 'antd' +import { AntIcon, Auth, Container, InputNumberRange, QueryTable } from 'components' import { api } from 'common/api' import auth from 'components/authorized/handler' -import { isEqual } from 'lodash' +import { first, isEqual, last } from 'lodash' import getDictData from 'util/dic' import { toCamelCase } from 'util/format' +import { getSearchDateRange, getSearchInfo, QueryType } from 'util/query' /** * 注释段[\/**\/]为必须要改 @@ -15,7 +28,7 @@ import { toCamelCase } from 'util/format' * 配置页面所需接口函数 */ const apiAction = { - page: api.houseTaskPage, + page: api.houseQueryPage, } /** @@ -28,16 +41,21 @@ const name = '/**/' * 统一配置权限标识 * [必要] */ -const authName = 'houseTask' +const authName = 'houseQuery' export default class index extends Component { state = { codes: { - houseType: [], - houseIndustry: [], + houseUsedStatus: [], + housePropertyRights: [], + landAttribute: [], + houseBaseInfo: [], + houseStructureType: [], + houseStorageOfDrawings: [], + houseGrade: [], }, - type: '', + showDrawingMaterialText: false, } // 表格实例 @@ -113,7 +131,15 @@ export default class index extends Component { componentDidMount() { const { onLoading, onLoadData } = this.table.current onLoading() - getDictData('house_type', 'house_industry').then(codes => { + getDictData( + 'house_used_status', + 'house_property_rights', + 'land_attribute', + 'house_base_info', + 'house_structure_type', + 'house_storage_of_drawings', + 'house_grade' + ).then(codes => { this.setState({ codes }, () => { onLoadData() }) @@ -128,9 +154,23 @@ export default class index extends Component { * @returns */ loadData = async (params, query) => { + query.completedDate = getSearchDateRange(query.completedDate) + query.createdTime = getSearchDateRange(query.createdTime) + + const searchInfo = getSearchInfo({ + query, + queryType: { + areaCode: QueryType.Like, + completedDate: [QueryType.GreaterThanOrEqual, QueryType.LessThan], + createdTime: [QueryType.GreaterThanOrEqual, QueryType.LessThan], + totalArea: [QueryType.GreaterThanOrEqual, QueryType.LessThanOrEqual], + totalFloor: [QueryType.GreaterThanOrEqual, QueryType.LessThanOrEqual], + }, + }) + const { data } = await apiAction.page({ ...params, - ...query, + searchInfo, }) return data } @@ -193,6 +233,251 @@ export default class index extends Component { } //#region 自定义方法 + rednerMoreQuery() { + const { codes, showDrawingMaterialText } = this.state + + return ( + + + + + {codes.houseUsedStatus.map(item => ( + + {item.value} + + ))} + + + + + + + 全部 + + + + + + + + + 全部 + + + + + + + + + 全部 + + + + + + + + + 全部 + + + + + + + + + + + + + + + + + + + 全部 + {codes.housePropertyRights.map(item => ( + + {item.value} + + ))} + + + + + + + 全部 + {codes.landAttribute.map(item => ( + + {item.value} + + ))} + + + + + + + 全部 + {codes.houseBaseInfo.map(item => ( + + {item.value} + + ))} + + + + + + + 全部 + {codes.houseStructureType.map(item => ( + + {item.value} + + ))} + + + + + + + + {codes.houseStorageOfDrawings.map(item => ( + + {item.value} + + ))} + + + {showDrawingMaterialText && ( + + + + )} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 全部 + {codes.houseGrade.map(item => ( + + {item.value} + + ))} + + + + + ) + } + + onQueryChange(changedValues, allValues) { + console.log(changedValues) + if (changedValues.hasOwnProperty('drawingMaterial') && changedValues.drawingMaterial) { + this.setState({ + showDrawingMaterialText: changedValues.drawingMaterial.includes('100'), + }) + return + } + + // 全部 + const { codes } = this.state + const key = first(Object.keys(changedValues)) + const mapCount = { + curtainWall: 2, + faceBrick: 2, + coating: 2, + painting: 2, + propertyRights: codes.housePropertyRights.length, + landAttribute: codes.landAttribute.length, + baseInfo: codes.houseBaseInfo.length, + structureType: codes.houseStructureType.length, + houseGrade: codes.houseGrade.length, + } + if (Object.keys(mapCount).includes(key)) { + return { + [key]: this.checkedNone(changedValues[key], mapCount[key]), + } + } + } + + checkedNone(value, count) { + if (first(value) == '' && value.length > 1) { + // 在'无'之后选中其他值 + value.shift() + } else if ((last(value) == '' && value.length > 1) || value.length === count) { + // 在其他值之后选中'无' + value = [''] + } + return value + } //#endregion render() { @@ -207,33 +492,20 @@ export default class index extends Component { autoLoad={false} loadData={this.loadData} columns={this.columns} + queryInitialValues={{ + houseUsedStatus: [1, 2], + curtainWall: [''], + faceBrick: [''], + coating: [''], + painting: [''], + propertyRights: [''], + landAttribute: [''], + baseInfo: [''], + structureType: [''], + houseGrade: [''], + }} query={ - - - 全部 - {codes.houseType.map(item => ( - - {item.value} - - ))} - - - {type == 2 && ( - - - - )} @@ -243,11 +515,10 @@ export default class index extends Component { } moreQuery={ - - - - - + {this.rednerMoreQuery()} + } + onQueryChange={(changedValues, allValues) => + this.onQueryChange(changedValues, allValues) } operator={ diff --git a/web-react/src/util/global/index.js b/web-react/src/util/global/index.js index 918cb47..374ca42 100644 --- a/web-react/src/util/global/index.js +++ b/web-react/src/util/global/index.js @@ -38,4 +38,7 @@ export const RSA_PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQU */ export const CITY = '黄石市' +/** + * 响应式响应宽度 + */ export const SIDER_BREAK_POINT = 1366 \ No newline at end of file diff --git a/web-react/src/util/query/index.js b/web-react/src/util/query/index.js index 51d312f..2aa58ae 100644 --- a/web-react/src/util/query/index.js +++ b/web-react/src/util/query/index.js @@ -1,3 +1,41 @@ +import moment from 'moment' + +/** + * 从键值对的query类型转换成数组类型 + * 键:自动作为field值 + * 值:得到一个数组作为value的值 + * queryType:一个json类型,已query的键为键,QueryType为值. 如果是一个QueryType的数组,则自动对应到value中的各个值 + * 示例: + * + getSearchInfo({ + query: { + value: '123', + text: '123', + code: 'abc', + check: ['1', '2', '3'], + range: [1, 10] + }, + queryType: { + text: QueryType.Equal, + code: QueryType.Like, + check: QueryType.Equal, + range: [QueryType.GreaterThanOrEqual, QueryType.LessThan] + } + }) + + => + + [ + { field: 'value', value: ['123'] }, + { field: 'text', value: ['123'], type: '=' }, + { field: 'code', value: ['abc'], type: 'like' }, + { field: 'check', value: ['1', '2', '3'], type: '=' }, + { field: 'range', value: [1], type: '>=' }, + { field: 'range', value: [10], type: '<' } + ] + * @param {*} param0 + * @returns [{ field: '', value: [], type: '' } ...] + */ export const getSearchInfo = ({ query, queryType }) => { const searchInfo = [] Object.keys(query).forEach((p) => { @@ -38,4 +76,32 @@ export const getSearchInfo = ({ query, queryType }) => { }) return searchInfo +} + +/** + * 获取查询用时间范围数组 + * 在这里会自动将第二个时间增加1天 + * 如果选择的日期范围为2021-01-01~2021-01-10,最终需要取得 >=2021-01-01 and <2021-01-11 的结果 + * @param {*} range 时间范围数组 + * @param {*} format 格式化 + * @returns + */ +export const getSearchDateRange = (range, format = 'YYYY-MM-DD', unit = 'days') => { + if (Array.isArray(range) && range.length === 2) { + range[1] = moment(range[1]).add(1, unit) + range = range.map(p => moment(p).format(format)) + } + return range +} + +/** + * 查询条件类型 + */ +export const QueryType = { + GreaterThan: '>', + GreaterThanOrEqual: '>=', + LessThan: '<', + LessThanOrEqual: '<=', + Like: 'LIKE', + Equal: '=' } \ No newline at end of file