fix 区域树

This commit is contained in:
2021-06-24 16:22:37 +08:00
parent a828a62d20
commit 64bb1c3352
5 changed files with 38 additions and 4 deletions

View File

@@ -88,6 +88,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
var areaCodeRep = Db.GetRepository<SysAreaCode>(); var areaCodeRep = Db.GetRepository<SysAreaCode>();
var projects = await _houseProjectInfoRep.DetachedEntities var projects = await _houseProjectInfoRep.DetachedEntities
.Join(areaCodeRep.DetachedEntities, p => p.AreaCode, a => a.Code, (p, a) => new { p, AreaName = a.Name }) .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.Name), x => x.p.Name.Contains(input.Name))
.Where(!string.IsNullOrEmpty(input.Note), x => x.p.Note.Contains(input.Note)) .Where(!string.IsNullOrEmpty(input.Note), x => x.p.Note.Contains(input.Note))
.Where(!string.IsNullOrEmpty(input.AreaCode), x => x.p.AreaCode == input.AreaCode) .Where(!string.IsNullOrEmpty(input.AreaCode), x => x.p.AreaCode == input.AreaCode)

View File

@@ -93,11 +93,17 @@ namespace Ewide.Core.Service.Area
#endif #endif
} }
var query = cachedAreaCodes.Where(p => p.LevelType <= level); var query = cachedAreaCodes.Where(p => p.LevelType <= level);
var resAreaCode = new List<SysAreaCode>();
if (areaCodeList != null) 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 = query.ToList(); cachedAreaCodes = resAreaCode.Distinct().ToList();
}
return new TreeBuildUtil<AreaTreeNode>().DoTreeBuild(cachedAreaCodes.Select(u => new AreaTreeNode return new TreeBuildUtil<AreaTreeNode>().DoTreeBuild(cachedAreaCodes.Select(u => new AreaTreeNode
{ {
Code = u.Code, Code = u.Code,

View File

@@ -1,6 +1,7 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Form, Button, Table, Tooltip } from 'antd' import { Form, Button, Table, Tooltip } from 'antd'
import { AntIcon } from 'components' import { AntIcon } from 'components'
import { isEqual } from 'lodash'
const propsMap = ['columns', 'autoLoad', 'loadData', 'pageIndex', 'pageSize'] const propsMap = ['columns', 'autoLoad', 'loadData', 'pageIndex', 'pageSize']
@@ -157,6 +158,10 @@ export default class QueryTable extends Component {
onLoadData = async () => { onLoadData = async () => {
this.onLoading() this.onLoading()
if (isEqual(this.query, {})) {
this.query = this.props.queryInitialValues
}
const res = await this.loadData( const res = await this.loadData(
{ {
pageIndex: this.pagination.current, pageIndex: this.pagination.current,

View File

@@ -87,7 +87,8 @@ export default class form extends Component {
this.record = { this.record = {
pid: params.pid, pid: params.pid,
...this.record, ...this.record,
areaCode: areaCode.length == 4 ? areaCode : [], areaCode:
areaCode.length > 0 && areaCode[areaCode.length - 1].length == 12 ? areaCode : [],
} }
//#endregion //#endregion
@@ -213,6 +214,7 @@ export default class form extends Component {
rules={[{ required: true, message: '请选择所属区域' }]} rules={[{ required: true, message: '请选择所属区域' }]}
> >
<Cascader <Cascader
disabled={this.state.exist}
options={this.state.options.areaData} options={this.state.options.areaData}
fieldNames={{ fieldNames={{
label: 'name', label: 'name',

View File

@@ -1,5 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Button, Card, Form, Input, message as Message, Popconfirm } from 'antd' import { Button, Radio, Card, Form, Input, message as Message, Popconfirm } from 'antd'
import { import {
AntIcon, AntIcon,
Auth, Auth,
@@ -31,6 +31,7 @@ export default class index extends Component {
codes: { codes: {
houseType: [], houseType: [],
}, },
type: 1,
} }
// 表格实例 // 表格实例
@@ -246,8 +247,27 @@ export default class index extends Component {
autoLoad={false} autoLoad={false}
loadData={this.loadData} loadData={this.loadData}
columns={this.columns} columns={this.columns}
queryInitialValues={{
type: 1,
}}
onQueryChange={values => {
if (values.hasOwnProperty('type')) {
this.setState({ type: values.type })
}
}}
query={ query={
<Auth auth="houseProjectInfo:page"> <Auth auth="houseProjectInfo:page">
<Form.Item label="项目类型" name="type">
<Radio.Group buttonStyle="solid">
<Radio.Button value={0}>全部</Radio.Button>
<Radio.Button value={1}>
<span>住宅</span>
</Radio.Button>
<Radio.Button value={2}>
<span>非住宅</span>
</Radio.Button>
</Radio.Group>
</Form.Item>
<Form.Item label="项目名称" name="name"> <Form.Item label="项目名称" name="name">
<Input autoComplete="off" placeholder="请输入项目名称" /> <Input autoComplete="off" placeholder="请输入项目名称" />
</Form.Item> </Form.Item>