update 完善编码信息读取

This commit is contained in:
2021-06-21 17:19:20 +08:00
parent 727e52c0aa
commit f31f79d59d
9 changed files with 459 additions and 246 deletions

View File

@@ -56,4 +56,10 @@ namespace Ewide.Application
public string ZoonId { get; set; }
public int Type { get; set; }
}
public class GetHouseCodeInput
{
[Required(ErrorMessage = "房屋编码ID不可为空")]
public string Id { get; set; }
}
}

View File

@@ -25,4 +25,18 @@ namespace Ewide.Application
public string Lng { get; set; }
public string Lat { get; set; }
}
public class GetHouseCodeOutput
{
public string Id { get; set; }
public int Type { get; set; }
public int Industry { get; set; }
public string AreaCode { get; set; }
public string ProjectId { get; set; }
public int No { get; set; }
public string ZoneId { get; set; }
public string Address { get; set; }
public string Lng { get; set; }
public string Lat { get; set; }
}
}

View File

@@ -73,6 +73,16 @@ LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6) ";
return await _dapperRepository.QueryPageDataDynamic(sql, input, filterFields: new string[] {"Type", "Address", "HouseCode" });
}
[HttpGet("/houseCode/detail")]
public async Task<dynamic> GetHouserCode([FromQuery] GetHouseCodeInput input)
{
var houseCode = await _houseCodeRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.Id);
var areaCode = (await Db.GetRepository<BsHouseProjectInfo>().DetachedEntities.FirstOrDefaultAsync(p => p.Id == houseCode.ProjectId)).AreaCode;
var result = houseCode.Adapt<GetHouseCodeOutput>();
result.AreaCode = areaCode;
return result;
}
/// <summary>
/// 获取同一区域下的下一个编号
/// </summary>

View File

@@ -3,6 +3,7 @@ const urls = {
houseCodeEdit: ['/houseCode/edit', 'post'],
houseCodePage: ['/houseCode/page', 'post'],
houseCodeNo: '/houseCode/getNextNoByCode',
houseCodeDetail: '/houseCode/detail'
}
export default urls

View File

@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import { Button, Card, message as Message, Modal } from 'antd'
import { ComponentDynamic, Container } from 'components'
import { Button, Card, Col, message as Message, Modal, Row, Spin } from 'antd'
import { AntIcon, ComponentDynamic, Container } from 'components'
import { isEqual } from 'lodash'
import { api } from 'common/api'
@@ -12,6 +12,9 @@ const parts = [
export default class index extends Component {
state = {
loading: true,
record: null,
saving: false,
}
@@ -23,6 +26,19 @@ export default class index extends Component {
return !isEqual(this.state, state)
}
componentDidMount() {
// 获取详细数据
const { id } = this.props.param
if (id) {
api.houseCodeDetail({ id }).then(({ data }) => {
this.setState({
record: data,
loading: false,
})
})
}
}
async onSubmit() {
for (const child of this.children) {
try {
@@ -36,8 +52,9 @@ export default class index extends Component {
}
}
//#region 提交数据
this.setState({ saving: true })
if (!this.props.param.record) {
if (!this.state.record) {
// 新增
try {
const { success } = await api.houseCodeAdd(this.formData)
@@ -57,7 +74,10 @@ export default class index extends Component {
} else {
// 编辑
try {
const { success } = await api.houseCodeEdit(this.formData)
const { success } = await api.houseCodeEdit({
id: this.state.record.id,
...this.formData,
})
if (success) {
Message.success('保存成功')
}
@@ -65,39 +85,54 @@ export default class index extends Component {
this.setState({ saving: false })
}
}
//#endregion
}
render() {
const { id, param } = this.props
const { id } = this.props
const { loading, record, saving } = this.state
return (
<div className="yo-form-page">
<Container mode="fluid">
<Container mode="fluid" ref={this.setContainer}>
<Row gutter={16} type="flex">
<Col flex="1">
<br />
<div className="yo-adorn--house-top" />
<Card className="yo-form-page--body">
{parts.map((item, i) => (
<section key={i} id={`form-${i}-${id}`}>
{item.title && <h5>{parts.title}</h5>}
{item.title && <h5>{item.title}</h5>}
<Spin
spinning={loading}
indicator={<AntIcon type="loading" />}
wrapperClassName="h-400-min"
>
{!loading && (
<ComponentDynamic
is={item.component}
param={param}
record={record}
onRef={r => this.children.push(r)}
/>
)}
</Spin>
</section>
))}
</Card>
</Col>
</Row>
</Container>
<div className="yo-form-page--bar">
<Container mode="fluid">
<div className="yo-form-page--bar-inner">
<span></span>
<span>
<Button>取消</Button>
<Button onClick={() => window.closeContentWindow()}>取消</Button>
<Button
loading={saving}
type="primary"
onClick={() => this.onSubmit()}
loading={this.state.saving}
>
保存
</Button>

View File

@@ -1,36 +1,49 @@
import React, { Component } from 'react'
import { Button, Cascader, Form, Input, InputNumber, Radio, Spin, Select, Row, Col, Tag, Alert, Tooltip } from 'antd'
import {
Button,
Cascader,
Form,
Input,
InputNumber,
Radio,
Spin,
Select,
Row,
Col,
Tag,
Alert,
Tooltip,
} from 'antd'
import { AntIcon, Auth } from 'components'
import { cloneDeep } from 'lodash'
import { cloneDeep, isEqual } from 'lodash'
import getDictData from 'util/dic'
import { api } from 'common/api'
import { CITY } from 'util/global'
const initialValues = {
type: 1,
industry: 1
industry: 1,
}
const labelCol = { flex: '150px' }
const wrapperCol = { flex: '1' }
export default class form extends Component {
state = {
// 加载状态
loading: true,
codes: {
dicHouseType: [],
dicHouseIndustry: []
dicHouseIndustry: [],
},
options: {
areaTree: [],
projects: [],
zones: []
zones: [],
},
houseCode: '',
showIndustry: false
showIndustry: false,
}
// 表单实例
@@ -41,6 +54,10 @@ export default class form extends Component {
// 初始化数据
record = {}
shouldComponentUpdate(props, state) {
return !isEqual(this.state, state)
}
/**
* mount后回调
*/
@@ -48,7 +65,9 @@ export default class form extends Component {
if (this.props.onRef) {
this.props.onRef(this)
}
this.fillData(this.props.param)
this.fillData({
record: this.props.record,
})
}
componentWillUnmount() {
@@ -62,7 +81,6 @@ export default class form extends Component {
* @param {*} params
*/
async fillData(params) {
this.record = cloneDeep(params.record)
//#region 从后端转换成前段所需格式
await this.initMap()
@@ -75,12 +93,12 @@ export default class form extends Component {
areaCode.substr(0, 4),
areaCode.substr(0, 6),
areaCode.substr(0, 9),
areaCode
areaCode,
]
// 获取项目和片区列表
const data = await this.getProjectsAndZones({
areaCode: this.record.areaCode,
type
type,
})
Object.assign(options, data)
// 定位
@@ -93,14 +111,14 @@ export default class form extends Component {
options.areaTree = areaTree
this.setState({
codes,
options
options,
})
this.showHouseCode()
//#endregion
this.form.current.setFieldsValue(this.record)
this.setState({
loading: false
loading: false,
})
}
@@ -116,9 +134,6 @@ export default class form extends Component {
const valid = await form.validateFields()
if (valid) {
const postData = form.getFieldsValue()
if (this.record) {
postData.id = this.record.id
}
//#region 从前段转换后端所需格式
if (postData.areaCode) {
postData.areaCode = postData.areaCode[3]
@@ -130,7 +145,6 @@ export default class form extends Component {
//#region 自定义方法
initMap() {
// eslint-disable-next-line no-undef
const amap = AMap
@@ -140,7 +154,7 @@ export default class form extends Component {
const district = new amap.DistrictSearch({
subdistrict: 0,
extensions: 'all',
level: 'city'
level: 'city',
})
district.search(city, (status, result) => {
@@ -152,15 +166,15 @@ export default class form extends Component {
const geocoder = new amap.Geocoder({ city })
geocoder.getLocation(city, (status, result) => {
if (status !== 'complete' || !(result.geocodes && result.geocodes.length)) return
if (status !== 'complete' || !(result.geocodes && result.geocodes.length))
return
this.citycode = result.geocodes[0].addressComponent.citycode
this.map = new amap.Map(this.refs.map, {
mask,
zoom: 12,
center: result.geocodes[0].location
center: result.geocodes[0].location,
})
this.map.on('click', e => {
@@ -176,7 +190,7 @@ export default class form extends Component {
path,
strokeColor: '#ccc',
strokeWeight: 4,
map: this.map
map: this.map,
})
}
@@ -186,13 +200,13 @@ export default class form extends Component {
const auto = new amap.AutoComplete({
input: this.refs['map-search'].input,
city,
citylimit: true
citylimit: true,
})
const placeSearch = new amap.PlaceSearch({
city,
citylimit: true,
pageSize: 1
pageSize: 1,
})
auto.on('select', ({ poi: { name: keywords, adcode } }) => {
@@ -206,15 +220,13 @@ export default class form extends Component {
}
})
})
})
})
})
}
setMarker(position, geocoder) {
const set = (position) => {
const set = position => {
if (this.marker) {
this.marker.setPosition(position)
} else {
@@ -242,7 +254,6 @@ export default class form extends Component {
set(position)
resolve(position)
} else {
console.error('根据经纬度查询地址失败')
@@ -260,7 +271,7 @@ export default class form extends Component {
this.form.current.setFieldsValue({
address,
lng,
lat
lat,
})
}
@@ -279,13 +290,13 @@ export default class form extends Component {
if (mode.includes('projects')) {
const { data: projects } = await api.houseProjectList({
areaCode: areaCode[3],
type
type,
})
result.projects = projects
}
if (mode.includes('zones')) {
const { data: zones } = await api.houseZoneList({
areaCode: areaCode[3]
areaCode: areaCode[3],
})
result.zones = zones
}
@@ -300,7 +311,7 @@ export default class form extends Component {
this.setState({ loading: true })
const { data: no } = await api.houseCodeNo({ projectId })
this.form.current.setFieldsValue({
no
no,
})
this.setState({ loading: false })
}
@@ -308,7 +319,7 @@ export default class form extends Component {
showHouseCode(values) {
if (this.record) {
this.setState({
houseCode: this.record.houseCode
houseCode: this.record.houseCode,
})
} else if (values) {
const { type, industry, areaCode, projectId, no } = values
@@ -323,7 +334,8 @@ export default class form extends Component {
if (!industry) {
this.setState({ houseCode: '' })
} else {
const tag = this.state.codes.dicHouseIndustry.find(p => p.code == industry).extCode.tag
const tag = this.state.codes.dicHouseIndustry.find(p => p.code == industry)
.extCode.tag
houseCode += `-${tag}`
this.setState({ houseCode })
}
@@ -340,16 +352,16 @@ export default class form extends Component {
if (changedValues.hasOwnProperty('type')) {
this.setState({
showIndustry: changedValues.type == 2,
loading: true
loading: true,
})
const data = await this.getProjectsAndZones()
form.setFieldsValue({ projectId: undefined })
this.setState({
options: {
...this.state.options,
...data
...data,
},
loading: false
loading: false,
})
this.showHouseCode(form.getFieldsValue())
}
@@ -362,9 +374,9 @@ export default class form extends Component {
this.setState({
options: {
...this.state.options,
...data
...data,
},
loading: false
loading: false,
})
this.showHouseCode(form.getFieldsValue())
}
@@ -392,15 +404,14 @@ export default class form extends Component {
this.setState({
options: {
...this.state.options,
...data
...data,
},
loading: false
loading: false,
})
}
//#endregion
render() {
const { loading, codes, options, showIndustry, houseCode } = this.state
return (
@@ -409,61 +420,70 @@ export default class form extends Component {
ref={this.form}
// labelCol={labelCol}
// wrapperCol={wrapperCol}
onValuesChange={(changedValues, allValues) => this.onValuesChange(changedValues, allValues)}
onValuesChange={(changedValues, allValues) =>
this.onValuesChange(changedValues, allValues)
}
layout="vertical"
>
<Spin spinning={loading} indicator={<AntIcon type="loading" />}>
<Row gutter={16}>
<Col span={10}>
<div className="yo-map-container">
<div className="yo-map--search">
<Input.Search allowClear placeholder="请输入关键字" ref="map-search" />
<Input.Search
allowClear
placeholder="请输入关键字"
ref="map-search"
/>
</div>
<div className="h-700" ref="map"></div>
</div>
</Col>
<Col span={14}>
<Form.Item label="房屋性质" name="type" rules={[{ required: true, message: '请选择房屋性质' }]}>
<Radio.Group
disabled={!!this.record}
buttonStyle="solid"
<Form.Item
label="房屋性质"
name="type"
rules={[{ required: true, message: '请选择房屋性质' }]}
>
<Radio.Group disabled={!!this.record} buttonStyle="solid">
{codes.dicHouseType.map(item => (
<Radio.Button
key={item.code}
value={+item.code}
>{item.value}</Radio.Button>
<Radio.Button key={item.code} value={+item.code}>
{item.value}
</Radio.Button>
))}
</Radio.Group>
</Form.Item>
{
showIndustry &&
<Form.Item label="所属行业、系统" name="industry" rules={[{ required: true, message: '请选择所属行业、系统' }]}>
<Radio.Group
disabled={!!this.record}
buttonStyle="solid"
{showIndustry && (
<Form.Item
label="所属行业、系统"
name="industry"
rules={[{ required: true, message: '请选择所属行业、系统' }]}
>
<Radio.Group disabled={!!this.record} buttonStyle="solid">
{codes.dicHouseIndustry.map(item => (
<Radio.Button
key={item.code}
value={+item.code}
>{item.value}</Radio.Button>
<Radio.Button key={item.code} value={+item.code}>
{item.value}
</Radio.Button>
))}
</Radio.Group>
</Form.Item>
}
)}
<Form.Item label="房屋编码" required className="mb-none">
<Row gutter={16}>
<Col flex="100%">
<Form.Item name="areaCode" rules={[{ required: true, message: '请选择房屋所在区域' }]}>
<Form.Item
name="areaCode"
rules={[
{ required: true, message: '请选择房屋所在区域' },
]}
>
<Cascader
allowClear={false}
displayRender={(labels) => labels.join(' - ')}
displayRender={labels => labels.join(' - ')}
fieldNames={{
label: 'name',
value: 'code',
children: 'children'
children: 'children',
}}
options={options.areaTree}
expandTrigger="hover"
@@ -473,13 +493,20 @@ export default class form extends Component {
<Col flex="1">
<Row gutter={8}>
<Col flex="1">
<Form.Item name="projectId" rules={[{ required: true, message: '请选择项目' }]}>
<Form.Item
name="projectId"
rules={[
{ required: true, message: '请选择项目' },
]}
>
<Select placeholder="请选择项目">
{options.projects.map(item => (
<Select.Option
key={item.id}
value={item.id}
>{item.name}({item.note})</Select.Option>
>
{item.name}({item.note})
</Select.Option>
))}
</Select>
</Form.Item>
@@ -488,8 +515,18 @@ export default class form extends Component {
<Col>
<Button.Group>
<Button>项目管理</Button>
<Tooltip placement="top" title="重新加载项目列表">
<Button icon={<AntIcon type="reload" />} onClick={() => this.onReloadProjectsOrZones('projects')}></Button>
<Tooltip
placement="top"
title="重新加载项目列表"
>
<Button
icon={<AntIcon type="reload" />}
onClick={() =>
this.onReloadProjectsOrZones(
'projects'
)
}
></Button>
</Tooltip>
</Button.Group>
</Col>
@@ -497,9 +534,12 @@ export default class form extends Component {
</Row>
</Col>
<Col flex="1">
<Form.Item name="no" rules={[{ required: true, message: '请输入房屋序号' }]}>
<Form.Item
name="no"
rules={[{ required: true, message: '请输入房屋序号' }]}
>
<InputNumber
formatter={(value) => value.padStart(3, '0')}
formatter={value => value.padStart(3, '0')}
max={999}
min={1}
precision={0}
@@ -509,14 +549,10 @@ export default class form extends Component {
/>
</Form.Item>
</Col>
{
showIndustry &&
<Col>-</Col>
}
{showIndustry && <Col>-</Col>}
</Row>
</Form.Item>
{
houseCode &&
{houseCode && (
<Form.Item>
<Tag
color="purple"
@@ -524,27 +560,64 @@ export default class form extends Component {
fontSize: '24px',
fontWeight: 'bold',
letterSpacing: '10px',
padding: '12px'
padding: '12px',
}}
>{houseCode}</Tag>
>
{houseCode}
</Tag>
</Form.Item>
}
)}
<Alert
message={<b>房屋编码说明</b>}
description={<>
房屋所在市<AntIcon type="border" /><AntIcon type="border" /><AntIcon type="border" /><AntIcon type="border" /><AntIcon type="border" /><AntIcon type="border" />街道<AntIcon type="border" /><AntIcon type="border" /><AntIcon type="border" />社区委会<AntIcon type="border" /><AntIcon type="border" /><AntIcon type="border" />项目<AntIcon type="border" /><AntIcon type="border" /><AntIcon type="border" />实物幢序号<AntIcon type="border" /><AntIcon type="border" /><AntIcon type="border" /> 根据省厅既有建筑物编号规则房屋所在区域编号按照市街道社区委会项目分类其中市区部分按照中华人民共和国行政区划代码GB2260标准编码街道县以下行政区划代码编码规则GB10114-88标准编码社区委会部分按照统计局提供编码设定各地上报各街道社区名称后上述编号由系统自动生成<br />各社区下辖项目由各地负责统一编码住宅项目序号一般一个小区一号采用3位数001号起编范围为001~999实物幢序号由各地负责统一编码以幢为单位采用3位数001号起编范围为001~999
</>} />
description={
<>
房屋所在市
<AntIcon type="border" />
<AntIcon type="border" />
<AntIcon type="border" />
<AntIcon type="border" />
<AntIcon type="border" />
<AntIcon type="border" />
街道
<AntIcon type="border" />
<AntIcon type="border" />
<AntIcon type="border" />
社区委会
<AntIcon type="border" />
<AntIcon type="border" />
<AntIcon type="border" />
项目
<AntIcon type="border" />
<AntIcon type="border" />
<AntIcon type="border" />
实物幢序号
<AntIcon type="border" />
<AntIcon type="border" />
<AntIcon type="border" />
根据省厅既有建筑物编号规则房屋所在区域编号按照市街道社区委会项目分类其中市区部分按照中华人民共和国行政区划代码GB2260标准编码街道县以下行政区划代码编码规则GB10114-88标准编码社区委会部分按照统计局提供编码设定各地上报各街道社区名称后上述编号由系统自动生成
<br />
各社区下辖项目由各地负责统一编码住宅项目序号一般一个小区一号采用3位数001号起编范围为001~999实物幢序号由各地负责统一编码以幢为单位采用3位数001号起编范围为001~999
</>
}
/>
<br />
<Form.Item label="所属片区" required>
<Row gutter={8}>
<Col flex="1">
<Form.Item name="zoneId" rules={[{ required: true, message: '请选择所属片区' }]} noStyle>
<Select placeholder="请选择所属片区" className="w-100-p">
<Form.Item
name="zoneId"
rules={[{ required: true, message: '请选择所属片区' }]}
noStyle
>
<Select
placeholder="请选择所属片区"
className="w-100-p"
>
{options.zones.map(item => (
<Select.Option
key={item.id}
value={item.id}
>{item.name}</Select.Option>
<Select.Option key={item.id} value={item.id}>
{item.name}
</Select.Option>
))}
</Select>
</Form.Item>
@@ -554,26 +627,58 @@ export default class form extends Component {
<Button.Group>
<Button>片区管理</Button>
<Tooltip placement="top" title="重新加载片区列表">
<Button icon={<AntIcon type="reload" />} onClick={() => this.onReloadProjectsOrZones('zones')}></Button>
<Button
icon={<AntIcon type="reload" />}
onClick={() =>
this.onReloadProjectsOrZones('zones')
}
></Button>
</Tooltip>
</Button.Group>
</Col>
</Auth>
</Row>
</Form.Item>
<Form.Item label="房屋地址" name="address" rules={[{ required: true, message: '请输入房屋地址' }]}>
<Input autoComplete="off" placeholder="请输入房屋地址或在地图上选择地点" />
<Form.Item
label="房屋地址"
name="address"
rules={[{ required: true, message: '请输入房屋地址' }]}
>
<Input
autoComplete="off"
placeholder="请输入房屋地址或在地图上选择地点"
/>
</Form.Item>
<Form.Item label="地理坐标" required>
<Row gutter={16}>
<Col span={12}>
<Form.Item name="lng" className="mb-none" rules={[{ required: true, message: '请在地图中选择坐标' }]}>
<Input disabled placeholder="请在地图中选择坐标" prefix="经度" />
<Form.Item
name="lng"
className="mb-none"
rules={[
{ required: true, message: '请在地图中选择坐标' },
]}
>
<Input
disabled
placeholder="请在地图中选择坐标"
prefix="经度"
/>
</Form.Item>
</Col>
<Col span={12}>
<Form.Item name="lat" className="mb-none" rules={[{ required: true, message: '请在地图中选择坐标' }]}>
<Input disabled placeholder="请在地图中选择坐标" prefix="纬度" />
<Form.Item
name="lat"
className="mb-none"
rules={[
{ required: true, message: '请在地图中选择坐标' },
]}
>
<Input
disabled
placeholder="请在地图中选择坐标"
prefix="纬度"
/>
</Form.Item>
</Col>
</Row>

View File

@@ -1,5 +1,16 @@
import React, { Component } from 'react'
import { Button, Card, Cascader, Form, Input, InputNumber, Popconfirm, message as Message, Radio, Select } from 'antd'
import {
Button,
Card,
Cascader,
Form,
Input,
InputNumber,
Popconfirm,
message as Message,
Radio,
Select,
} from 'antd'
import { isEqual } from 'lodash'
import { AntIcon, Auth, Container, QueryTable, QueryTableActions } from 'components'
import { api } from 'common/api'
@@ -10,25 +21,24 @@ import { getSearchInfo } from 'util/query'
// 配置页面所需接口函数
const apiAction = {
page: api.houseCodePage
page: api.houseCodePage,
}
// 用于弹窗标题
const name = '房屋编码'
export default class index extends Component {
state = {
codes: {
dicHouseType: [],
dicHouseIndustry: []
dicHouseIndustry: [],
},
options: {
areaTree: []
areaTree: [],
},
type: ''
type: '',
}
// 表格实例
@@ -41,14 +51,21 @@ export default class index extends Component {
dataIndex: 'houseCode',
sorter: true,
width: 300,
render: (text, record) => `${record.areaName}-${record.roadName}-${record.commName}-${record.note}-${record.no.toString().padStart(3, '0')}`
render: (text, record) =>
`${record.areaName}-${record.roadName}-${record.commName}-${record.note}-${record.no
.toString()
.padStart(3, '0')}`,
},
{
title: '房屋性质及行业',
dataIndex: 'type',
sorter: true,
width: 150,
render: (text, record) => this.bindCodeValue(text, 'dic_house_type') + (text === 2 ? `(${this.bindCodeValue(record.industry, 'dic_house_industry')})` : '')
render: (text, record) =>
this.bindCodeValue(text, 'dic_house_type') +
(text === 2
? `(${this.bindCodeValue(record.industry, 'dic_house_industry')})`
: ''),
},
{
title: '地址',
@@ -77,7 +94,8 @@ export default class index extends Component {
title: '操作',
width: 150,
dataIndex: 'actions',
render: (text, record) => (<QueryTableActions>
render: (text, record) => (
<QueryTableActions>
<Auth auth="houseCode:edit">
<a onClick={() => this.onOpen(record)}>编辑</a>
</Auth>
@@ -90,7 +108,8 @@ export default class index extends Component {
<a>删除</a>
</Popconfirm>
</Auth>
</QueryTableActions>)
</QueryTableActions>
),
})
}
}
@@ -114,16 +133,19 @@ export default class index extends Component {
componentDidMount() {
const { onLoading, onLoadData } = this.table.current
onLoading()
getDictData('dic_house_type', 'dic_house_industry').then(async (res) => {
getDictData('dic_house_type', 'dic_house_industry').then(async res => {
const { data } = await api.getAreaTree()
this.setState({
this.setState(
{
codes: res,
options: {
areaTree: data
}
}, () => {
areaTree: data,
},
},
() => {
onLoadData()
})
}
)
})
}
@@ -135,7 +157,6 @@ export default class index extends Component {
* @returns
*/
loadData = async (params, query) => {
if (query.areaCode) {
query.areaCode = query.areaCode.pop()
}
@@ -146,8 +167,8 @@ export default class index extends Component {
no: '=',
type: '=',
address: 'like',
houseCode: 'like'
}
houseCode: 'like',
},
})
const { data } = await apiAction.page({
@@ -167,7 +188,7 @@ export default class index extends Component {
name = toCamelCase(name)
const codes = this.state.codes[name]
if (codes) {
const c = codes.find((p) => p.code == code)
const c = codes.find(p => p.code == code)
if (c) {
return c.value
}
@@ -187,11 +208,13 @@ export default class index extends Component {
title: record ? '修改房屋编码' : '新增房屋编码',
subTitle:
record &&
`${record.areaName}-${record.roadName}-${record.commName}-${record.note}-${record.no.toString().padStart(3, '0')}`,
`${record.areaName}-${record.roadName}-${record.commName}-${record.note}-${record.no
.toString()
.padStart(3, '0')}`,
path,
param: {
record
}
id: record.id,
},
})
// modal.current.open({
// record
@@ -225,17 +248,13 @@ export default class index extends Component {
* @param {*} record
*/
onDelete(record) {
this.onAction(
apiAction.delete(record),
'删除成功'
)
this.onAction(apiAction.delete(record), '删除成功')
}
//#region 自定义方法
//#endregion
render() {
const { options, codes, type } = this.state
return (
@@ -248,9 +267,9 @@ export default class index extends Component {
loadData={this.loadData}
columns={this.columns}
queryInitialValues={{
type: ''
type: '',
}}
onQueryChange={(values) => {
onQueryChange={values => {
if (values.hasOwnProperty('type')) {
this.setState({ type: values.type })
}
@@ -259,11 +278,11 @@ export default class index extends Component {
<Auth auth="houseCode:page">
<Form.Item name="areaCode">
<Cascader
displayRender={(labels) => labels.join(' - ')}
displayRender={labels => labels.join(' - ')}
fieldNames={{
label: 'name',
value: 'code',
children: 'children'
children: 'children',
}}
options={options.areaTree}
className="w-400"
@@ -273,7 +292,7 @@ export default class index extends Component {
</Form.Item>
<Form.Item label="编号" name="no">
<InputNumber
formatter={(value) => value && value.padStart(3, '0')}
formatter={value => value && value.padStart(3, '0')}
max={999}
min={1}
precision={0}
@@ -284,31 +303,28 @@ export default class index extends Component {
<Form.Item label="房屋性质" name="type">
<Radio.Group buttonStyle="solid">
<Radio.Button value="">全部</Radio.Button>
{
codes.dicHouseType.map(item => (
<Radio.Button
key={item.code}
value={item.code}
>{item.value}</Radio.Button>
))
}
{codes.dicHouseType.map(item => (
<Radio.Button key={item.code} value={item.code}>
{item.value}
</Radio.Button>
))}
</Radio.Group>
</Form.Item>
{
type == 2 &&
{type == 2 && (
<Form.Item label="行业" name="industry">
<Select allowClear className="w-150" placeholder="请选择行业">
{
codes.dicHouseIndustry.map(item => (
<Select.Option
key={item.code}
value={item.code}
>{item.value}</Select.Option>
))
}
<Select
allowClear
className="w-150"
placeholder="请选择行业"
>
{codes.dicHouseIndustry.map(item => (
<Select.Option key={item.code} value={item.code}>
{item.value}
</Select.Option>
))}
</Select>
</Form.Item>
}
)}
<Form.Item label="地址" name="address">
<Input autoComplete="off" placeholder="请输入地址" />
</Form.Item>
@@ -322,7 +338,9 @@ export default class index extends Component {
<Button
icon={<AntIcon type="plus" />}
onClick={() => this.onOpen()}
>新增{name}</Button>
>
新增{name}
</Button>
</Auth>
}
/>

View File

@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import { Button, Descriptions, message as Message, Spin, Tabs } from 'antd'
import { defaultsDeep, isEqual } from 'lodash'
import { isEqual, truncate } from 'lodash'
import { AntIcon, ComponentDynamic, Container } from 'components'
import { api } from 'common/api'
@@ -54,6 +54,8 @@ export default class index extends Component {
loading: true,
record: null,
saving: false,
}
children = []
@@ -65,8 +67,8 @@ export default class index extends Component {
}
componentDidMount() {
// 获取详细数据
const { taskId } = this.props.param
if (taskId) {
api.houseInfoGetByTaskId({ taskId }).then(({ data }) => {
this.setState({
@@ -90,13 +92,18 @@ export default class index extends Component {
}
}
console.log(this.formData)
//#region 提交数据
this.setState({ saving: true })
setTimeout(() => {
Message.success('提交成功')
this.setState({ saving: false })
}, 3000)
//#endregion
}
render() {
const { loading, record } = this.state
const { loading, record, saving } = this.state
return (
<div className="yo-form-page">
@@ -105,12 +112,16 @@ export default class index extends Component {
<div className="yo-form-page--bar yo-form-page--bar--with-tab">
<Container mode="fluid">
<div className="yo-form-page--bar-inner">
<span>{/* 可以在工具栏中增加其他控件(只能在一行内) */}</span>
<span></span>
<span>
<Button onClick={() => window.closeContentWindow()}>
取消
</Button>
<Button onClick={() => this.onSubmit()} type="primary">
<Button
loading={saving}
type="primary"
onClick={() => this.onSubmit()}
>
保存
</Button>
</span>
@@ -175,16 +186,15 @@ export default class index extends Component {
return (
<div
key={i}
className={
(this.state.actived === i.toString()
className={[
this.state.actived === i.toString()
? 'yo-tab-external-tabpane-active'
: 'yo-tab-external-tabpane-inactive') +
' yo-tab-external-tabpane'
}
: 'yo-tab-external-tabpane-inactive',
'yo-tab-external-tabpane',
].join(' ')}
>
<ComponentDynamic
is={tab.component}
{...this.props}
record={record}
loading={loading}
onRef={c => this.children.push(c)}

View File

@@ -8,31 +8,29 @@ import { token } from 'common/token'
import './index.less'
export default class index extends Component {
state = {
loading: false,
focusUser: false,
focusPassword: false
focusPassword: false,
}
backgroundImage = require(`assets/image/login-bg-0${Math.floor(Math.random() * 4)}.jpg`)
focus = {
user: false,
password: false
password: false,
}
form = React.createRef()
onLogin = (values) => {
this.setState({
loading: true
})
onLogin = values => {
this.setState({ loading: true })
let { account, password } = values
password = encryptByRSA(password, RSA_PUBLIC_KEY)
api.login({ account, password }).then(({ success, data, message }) => {
api.login({ account, password })
.then(({ success, data, message }) => {
if (success) {
token.value = data
Message.success('登录成功')
@@ -40,15 +38,16 @@ export default class index extends Component {
} else {
Message.error(message)
}
}).catch(({ message }) => {
})
.catch(({ message }) => {
if (typeof message === 'object' && message[0]) {
Message.error(message[0].messages[0])
}
this.setState({ loading: false })
})
}
render() {
return (
<div className="yo-login">
<img src={this.backgroundImage.default} alt="" />
@@ -62,8 +61,14 @@ export default class index extends Component {
label="用户名"
>
<Input
onBlur={() => { this.setState({ focusUser: !!this.form.current.getFieldValue('account') }); }}
onFocus={() => { this.setState({ focusUser: true }) }}
onBlur={() => {
this.setState({
focusUser: !!this.form.current.getFieldValue('account'),
})
}}
onFocus={() => {
this.setState({ focusUser: true })
}}
size="large"
autoComplete="off"
/>
@@ -75,8 +80,15 @@ export default class index extends Component {
label="密码"
>
<Input.Password
onBlur={() => { this.setState({ focusPassword: !!this.form.current.getFieldValue('password') }) }}
onFocus={() => { this.setState({ focusPassword: true }) }}
onBlur={() => {
this.setState({
focusPassword:
!!this.form.current.getFieldValue('password'),
})
}}
onFocus={() => {
this.setState({ focusPassword: true })
}}
size="large"
autoComplete="off"
/>
@@ -89,7 +101,9 @@ export default class index extends Component {
htmlType="submit"
size="large"
type="primary"
>登录</Button>
>
登录
</Button>
</Form.Item>
</Form>
</Container>