diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeInput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeInput.cs index 8017786..d105eda 100644 --- a/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeInput.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeInput.cs @@ -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; } + } } diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs b/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs index 08bb370..0316d8b 100644 --- a/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseCode/Dto/HouseCodeOutput.cs @@ -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; } + } } diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseCode/HouseCodeService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseCode/HouseCodeService.cs index fb526c0..e57b2b2 100644 --- a/Api/Ewide.Application/Service/HouseSafety/HouseCode/HouseCodeService.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseCode/HouseCodeService.cs @@ -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 GetHouserCode([FromQuery] GetHouseCodeInput input) + { + var houseCode = await _houseCodeRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.Id); + var areaCode = (await Db.GetRepository().DetachedEntities.FirstOrDefaultAsync(p => p.Id == houseCode.ProjectId)).AreaCode; + var result = houseCode.Adapt(); + result.AreaCode = areaCode; + return result; + } + /// /// 获取同一区域下的下一个编号 /// diff --git a/web-react/src/common/api/requests/business/houseSafety/houseCode.js b/web-react/src/common/api/requests/business/houseSafety/houseCode.js index 8aa62a1..67c442a 100644 --- a/web-react/src/common/api/requests/business/houseSafety/houseCode.js +++ b/web-react/src/common/api/requests/business/houseSafety/houseCode.js @@ -3,6 +3,7 @@ const urls = { houseCodeEdit: ['/houseCode/edit', 'post'], houseCodePage: ['/houseCode/page', 'post'], houseCodeNo: '/houseCode/getNextNoByCode', + houseCodeDetail: '/houseCode/detail' } export default urls \ No newline at end of file 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 c6028dc..e8f16be 100644 --- a/web-react/src/pages/business/house/code/form/index.jsx +++ b/web-react/src/pages/business/house/code/form/index.jsx @@ -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 (
- -
-
- - {parts.map((item, i) => ( -
- {item.title &&
{parts.title}
} - this.children.push(r)} - /> -
- ))} -
+ + + +
+
+ + {parts.map((item, i) => ( +
+ {item.title &&
{item.title}
} + } + wrapperClassName="h-400-min" + > + {!loading && ( + this.children.push(r)} + /> + )} + +
+ ))} +
+ +
- + 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 ed86511..071ef89 100644 --- a/web-react/src/pages/business/house/code/form/part.jsx +++ b/web-react/src/pages/business/house/code/form/part.jsx @@ -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() { @@ -59,10 +78,9 @@ export default class form extends Component { * 填充数据 * 可以在设置this.record之后对其作出数据结构调整 * [异步,必要] - * @param {*} params + * @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, }) } @@ -108,7 +126,7 @@ export default class form extends Component { * 获取数据 * 可以对postData进行数据结构调整 * [异步,必要] - * @returns + * @returns */ async getData() { const form = this.form.current @@ -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" - > }>
- +
- - + + {codes.dicHouseType.map(item => ( - {item.value} + + {item.value} + ))} - { - showIndustry && - - + {showIndustry && ( + + {codes.dicHouseIndustry.map(item => ( - {item.value} + + {item.value} + ))} - } + )} - + 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 { - + @@ -488,8 +515,18 @@ export default class form extends Component { - - + + @@ -497,9 +534,12 @@ export default class form extends Component { - + 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 { /> - { - showIndustry && - - - } + {showIndustry && -} - { - houseCode && + {houseCode && ( {houseCode} + > + {houseCode} + - } + )} 房屋编码说明} - description={<> - 房屋所在市—县(市、区)—街道(乡、镇)—社区、居(村)委会)—项目—实物幢序号。 根据省厅既有建筑物编号规则,房屋所在区域编号按照市、县(市、区)、街道(乡、镇)、社区、居(村)委会)、项目分类,其中市、县(市)区部分按照《中华人民共和国行政区划代码》(GB2260)标准编码,街道(乡、镇)按《县以下行政区划代码编码规则》(GB10114-88)标准编码,社区、居(村)委会部分按照统计局提供编码设定。各地上报各街道社区名称后,上述编号由系统自动生成。
各社区下辖项目由各地负责统一编码,住宅项目序号一般一个小区一号,采用3位数,001号起编,范围为001~999。实物幢序号由各地负责统一编码,以幢为单位,采用3位数,001号起编,范围为001~999。 - } /> + description={ + <> + 房屋所在市 + + + + + —县(市、区) + + + —街道(乡、镇) + + + + —社区、居(村)委会) + + + + —项目 + + + + —实物幢序号 + + + 。 + 根据省厅既有建筑物编号规则,房屋所在区域编号按照市、县(市、区)、街道(乡、镇)、社区、居(村)委会)、项目分类,其中市、县(市)区部分按照《中华人民共和国行政区划代码》(GB2260)标准编码,街道(乡、镇)按《县以下行政区划代码编码规则》(GB10114-88)标准编码,社区、居(村)委会部分按照统计局提供编码设定。各地上报各街道社区名称后,上述编号由系统自动生成。 +
+ 各社区下辖项目由各地负责统一编码,住宅项目序号一般一个小区一号,采用3位数,001号起编,范围为001~999。实物幢序号由各地负责统一编码,以幢为单位,采用3位数,001号起编,范围为001~999。 + + } + />
- - {options.zones.map(item => ( - {item.name} + + {item.name} + ))} @@ -554,26 +627,58 @@ export default class form extends Component { - + - - + + - - + + - - + + diff --git a/web-react/src/pages/business/house/code/index.jsx b/web-react/src/pages/business/house/code/index.jsx index 9582ffa..489a27d 100644 --- a/web-react/src/pages/business/house/code/index.jsx +++ b/web-react/src/pages/business/house/code/index.jsx @@ -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: '地址', @@ -65,7 +82,7 @@ export default class index extends Component { /** * 构造函数,在渲染前动态添加操作字段等 - * @param {*} props + * @param {*} props */ constructor(props) { super(props) @@ -77,20 +94,22 @@ export default class index extends Component { title: '操作', width: 150, dataIndex: 'actions', - render: (text, record) => ( - - this.onOpen(record)}>编辑 - - - this.onDelete(record)} - > - 删除 - - - ) + render: (text, record) => ( + + + this.onOpen(record)}>编辑 + + + this.onDelete(record)} + > + 删除 + + + + ), }) } } @@ -99,9 +118,9 @@ export default class index extends Component { * 阻止外部组件引发的渲染,提升性能 * 可自行添加渲染条件 * [必要] - * @param {*} props - * @param {*} state - * @returns + * @param {*} props + * @param {*} state + * @returns */ shouldComponentUpdate(props, state) { return !isEqual(this.state, state) @@ -114,28 +133,30 @@ 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({ - codes: res, - options: { - areaTree: data + this.setState( + { + codes: res, + options: { + areaTree: data, + }, + }, + () => { + onLoadData() } - }, () => { - onLoadData() - }) + ) }) } /** * 调用加载数据接口,可在调用前对query进行处理 * [异步,必要] - * @param {*} params - * @param {*} query - * @returns + * @param {*} params + * @param {*} query + * @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({ @@ -159,15 +180,15 @@ export default class index extends Component { /** * 绑定字典数据 - * @param {*} code - * @param {*} name - * @returns + * @param {*} code + * @param {*} name + * @returns */ bindCodeValue(code, name) { 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 } @@ -177,8 +198,8 @@ export default class index extends Component { /** * 打开新增/编辑弹窗 - * @param {*} modal - * @param {*} record + * @param {*} modal + * @param {*} record */ onOpen(record) { const path = 'business/house/code/form' @@ -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 @@ -201,8 +224,8 @@ export default class index extends Component { /** * 对表格上的操作进行统一处理 * [异步] - * @param {*} action - * @param {*} successMessage + * @param {*} action + * @param {*} successMessage */ async onAction(action, successMessage) { const { onLoading, onLoaded, onReloadData } = this.table.current @@ -222,20 +245,16 @@ export default class index extends Component { /** * 删除 - * @param {*} record + * @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 { 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 { 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 { 全部 - { - codes.dicHouseType.map(item => ( - {item.value} - )) - } + {codes.dicHouseType.map(item => ( + + {item.value} + + ))} - { - type == 2 && + {type == 2 && ( - + {codes.dicHouseIndustry.map(item => ( + + {item.value} + + ))} - } + )} @@ -322,7 +338,9 @@ export default class index extends Component { + > + 新增{name} + } /> diff --git a/web-react/src/pages/business/house/info/form/index.jsx b/web-react/src/pages/business/house/info/form/index.jsx index 3641db9..f3c5602 100644 --- a/web-react/src/pages/business/house/info/form/index.jsx +++ b/web-react/src/pages/business/house/info/form/index.jsx @@ -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 }) - Message.success('提交成功') + setTimeout(() => { + Message.success('提交成功') + this.setState({ saving: false }) + }, 3000) + //#endregion } render() { - const { loading, record } = this.state + const { loading, record, saving } = this.state return (
@@ -105,12 +112,16 @@ export default class index extends Component {
- {/* 可以在工具栏中增加其他控件(只能在一行内) */} + - @@ -175,16 +186,15 @@ export default class index extends Component { return (
this.children.push(c)} diff --git a/web-react/src/views/login/index.jsx b/web-react/src/views/login/index.jsx index 031b9c3..e04b7ea 100644 --- a/web-react/src/views/login/index.jsx +++ b/web-react/src/views/login/index.jsx @@ -8,47 +8,46 @@ 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 }) => { - if (success) { - token.value = data - Message.success('登录成功') - this.props.history.replace('/') - } else { - Message.error(message) - } - }).catch(({ message }) => { - if (typeof message === 'object' && message[0]) { - Message.error(message[0].messages[0]) - } - }) + api.login({ account, password }) + .then(({ success, data, message }) => { + if (success) { + token.value = data + Message.success('登录成功') + this.props.history.replace('/') + } else { + Message.error(message) + } + }) + .catch(({ message }) => { + if (typeof message === 'object' && message[0]) { + Message.error(message[0].messages[0]) + } + this.setState({ loading: false }) + }) } render() { - return (
@@ -62,8 +61,14 @@ export default class index extends Component { label="用户名" > { 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="密码" > { 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" - >登录 + > + 登录 +