From fb834eaa11bf5912d59ff38ec1c9568202ba17c0 Mon Sep 17 00:00:00 2001 From: ky_yusj <2655568377@qq.com> Date: Wed, 23 Jun 2021 11:31:57 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HouseSelector/HouseSelectorService.cs | 2 +- .../business/house/info/form/base/aspect.jsx | 2 +- .../house/info/form/base/attachments.jsx | 2 +- .../house/info/form/base/building.jsx | 20 +++++-- .../business/house/info/form/base/drawing.jsx | 7 ++- .../house/info/form/base/identification.jsx | 2 +- .../house/info/form/base/ownership.jsx | 2 +- .../business/house/info/form/base/unit.jsx | 2 +- .../business/house/info/form/patrol/base.jsx | 2 +- .../business/house/info/form/patrol/grade.jsx | 53 +++++++++++-------- .../house/info/form/patrol/handling.jsx | 2 +- .../house/info/form/patrol/inspection.jsx | 8 +-- .../house/info/form/patrol/result.jsx | 2 +- web-react/src/store/reducer/business.js | 26 ++++++++- 14 files changed, 88 insertions(+), 44 deletions(-) diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs index f040d2e..46d1295 100644 --- a/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs +++ b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs @@ -145,7 +145,7 @@ INNER JOIN (SELECT * FROM bs_house_member_relation WHERE SysUserId = @UserId) HM HouseCodeId = p }.Insert(); - var initTask = _bsHouseTaskRep.DetachedEntities.FirstOrDefault(t => t.TaskType == 0); + var initTask = _bsHouseTaskRep.DetachedEntities.FirstOrDefault(t =>t.HouseCodeId == p && t.TaskType == 0); if (initTask == null) { new BsHouseTask diff --git a/web-react/src/pages/business/house/info/form/base/aspect.jsx b/web-react/src/pages/business/house/info/form/base/aspect.jsx index 8dbd577..021ac46 100644 --- a/web-react/src/pages/business/house/info/form/base/aspect.jsx +++ b/web-react/src/pages/business/house/info/form/base/aspect.jsx @@ -98,7 +98,7 @@ export default class aspect extends Component { houseInfo.facadePhoto = fileValue } //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState({ loading: false }) this.call() diff --git a/web-react/src/pages/business/house/info/form/base/attachments.jsx b/web-react/src/pages/business/house/info/form/base/attachments.jsx index 2db909c..b9ac6ce 100644 --- a/web-react/src/pages/business/house/info/form/base/attachments.jsx +++ b/web-react/src/pages/business/house/info/form/base/attachments.jsx @@ -124,7 +124,7 @@ export default class attachments extends Component { } } //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState({ loading: false }) this.call() diff --git a/web-react/src/pages/business/house/info/form/base/building.jsx b/web-react/src/pages/business/house/info/form/base/building.jsx index c3a66f1..a4031a6 100644 --- a/web-react/src/pages/business/house/info/form/base/building.jsx +++ b/web-react/src/pages/business/house/info/form/base/building.jsx @@ -59,6 +59,13 @@ export default class building extends Component { }) } + componentWillUnmount() { + dispatch({ + type: 'PATROL_REMOVE_INIT_GRADE_BY_COMPLETED_DATE', + id: this.props.id, + }) + } + call() { if (this.props.onRef) { this.props.onRef(this) @@ -79,10 +86,12 @@ export default class building extends Component { const { houseInfo } = this.record if (houseInfo.completedDate) { houseInfo.completedDate = moment(houseInfo.completedDate) - debugger dispatch({ type: 'PATROL_INIT_GRADE_BY_COMPLETED_DATE', - value: +houseInfo.completedDate.format('YYYY'), + date: { + id: this.props.id, + value: +houseInfo.completedDate.format('YYYY'), + }, }) } @@ -110,7 +119,7 @@ export default class building extends Component { ) //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState(_state) this.call() @@ -172,7 +181,10 @@ export default class building extends Component { if (houseInfo.hasOwnProperty('completedDate')) { dispatch({ type: 'PATROL_INIT_GRADE_BY_COMPLETED_DATE', - value: +houseInfo.completedDate.format('YYYY'), + date: { + id: this.props.id, + value: +houseInfo.completedDate.format('YYYY'), + }, }) } } diff --git a/web-react/src/pages/business/house/info/form/base/drawing.jsx b/web-react/src/pages/business/house/info/form/base/drawing.jsx index 9d0bbba..022e24c 100644 --- a/web-react/src/pages/business/house/info/form/base/drawing.jsx +++ b/web-react/src/pages/business/house/info/form/base/drawing.jsx @@ -72,13 +72,16 @@ export default class drawing extends Component { if (houseInfo.drawingMaterial) { houseInfo.drawingMaterial = houseInfo.drawingMaterial.split(',') } - this.setState({ showDrawingMaterialText: houseInfo.drawingMaterial.includes('100') }) + this.setState({ + showDrawingMaterialText: + !!houseInfo.drawingMaterial && houseInfo.drawingMaterial.includes('100'), + }) } const codes = await getDictData('dic_house_storage_of_drawings') console.log(codes) this.setState({ codes }) //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState({ loading: false }) this.call() diff --git a/web-react/src/pages/business/house/info/form/base/identification.jsx b/web-react/src/pages/business/house/info/form/base/identification.jsx index 9950546..5b77bcd 100644 --- a/web-react/src/pages/business/house/info/form/base/identification.jsx +++ b/web-react/src/pages/business/house/info/form/base/identification.jsx @@ -75,7 +75,7 @@ export default class identification extends Component { ) this.setState({ codes }) //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState({ loading: false }) this.call() diff --git a/web-react/src/pages/business/house/info/form/base/ownership.jsx b/web-react/src/pages/business/house/info/form/base/ownership.jsx index cbc48c0..f12ad79 100644 --- a/web-react/src/pages/business/house/info/form/base/ownership.jsx +++ b/web-react/src/pages/business/house/info/form/base/ownership.jsx @@ -67,7 +67,7 @@ export default class ownership extends Component { const codes = await getDictData('dic_house_property_rights') this.setState({ codes }) //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState({ loading: false }) this.call() diff --git a/web-react/src/pages/business/house/info/form/base/unit.jsx b/web-react/src/pages/business/house/info/form/base/unit.jsx index b04f5ed..59d5bb3 100644 --- a/web-react/src/pages/business/house/info/form/base/unit.jsx +++ b/web-react/src/pages/business/house/info/form/base/unit.jsx @@ -62,7 +62,7 @@ export default class unit extends Component { this.record = cloneDeep(params.record) //#region 从后端转换成前段所需格式 //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState({ loading: false }) this.call() diff --git a/web-react/src/pages/business/house/info/form/patrol/base.jsx b/web-react/src/pages/business/house/info/form/patrol/base.jsx index 996ca1f..e231a6d 100644 --- a/web-react/src/pages/business/house/info/form/patrol/base.jsx +++ b/web-react/src/pages/business/house/info/form/patrol/base.jsx @@ -47,7 +47,7 @@ export default class base extends Component { this.record.patrolInfo.patrolDate = patrolDate ? moment(patrolDate) : patrolDate } //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState({ loading: false }) this.call() diff --git a/web-react/src/pages/business/house/info/form/patrol/grade.jsx b/web-react/src/pages/business/house/info/form/patrol/grade.jsx index 806ecae..fa45753 100644 --- a/web-react/src/pages/business/house/info/form/patrol/grade.jsx +++ b/web-react/src/pages/business/house/info/form/patrol/grade.jsx @@ -1,5 +1,5 @@ import React, { Component } from 'react' -import { Form, Input, Radio, Spin } from 'antd' +import { Form, Tooltip, Radio, Spin } from 'antd' import { AntIcon } from 'components' import { cloneDeep, first, isEqual, last, sortBy } from 'lodash' import getDictData from 'util/dic' @@ -64,6 +64,7 @@ export default class handling extends Component { */ async fillData(params) { this.record = cloneDeep(params.record) + const _state = { loading: false } //#region 从后端转换成前段所需格式 if (this.record) { @@ -76,7 +77,7 @@ export default class handling extends Component { 'dic_house_grade' ) //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState(_state) this.call() @@ -101,18 +102,22 @@ export default class handling extends Component { } } - getInitGrade(year) { - if (year > 1999) { - return 1 - } - if (year > 1994 && year < 2000) { - return 2 - } - if (year > 1979 && year < 1995) { - return 3 - } - if (year < 1980) { - return 4 + getInitGrade(completedDate) { + const date = completedDate.find(p => p.id === this.props.id) + if (date) { + const { value: year } = date + if (year > 1999) { + return 1 + } + if (year > 1994 && year < 2000) { + return 2 + } + if (year > 1979 && year < 1995) { + return 3 + } + if (year < 1980) { + return 4 + } } } @@ -127,15 +132,17 @@ export default class handling extends Component { name={['patrolInfo', 'initGrade']} rules={[{ required: true, message: '请选择初始等级' }]} > - - {codes.dicHousePatrolInitGrade.map(item => { - return ( - - {item.value} - - ) - })} - + + + {codes.dicHousePatrolInitGrade.map(item => { + return ( + + {item.value} + + ) + })} + + @@ -242,7 +242,7 @@ export default class inspection extends Component { @@ -278,7 +278,7 @@ export default class inspection extends Component { diff --git a/web-react/src/pages/business/house/info/form/patrol/result.jsx b/web-react/src/pages/business/house/info/form/patrol/result.jsx index 7b92e2c..6fbd040 100644 --- a/web-react/src/pages/business/house/info/form/patrol/result.jsx +++ b/web-react/src/pages/business/house/info/form/patrol/result.jsx @@ -47,7 +47,7 @@ export default class result extends Component { //#region 从后端转换成前段所需格式 //#endregion - this.form.current.setFieldsValue(this.record) + this.form.current && this.form.current.setFieldsValue(this.record) this.setState({ loading: false }) this.call() diff --git a/web-react/src/store/reducer/business.js b/web-react/src/store/reducer/business.js index 7d63a84..cad0e2a 100644 --- a/web-react/src/store/reducer/business.js +++ b/web-react/src/store/reducer/business.js @@ -1,8 +1,30 @@ const business = (state = {}, action) => { switch (action.type) { case 'PATROL_INIT_GRADE_BY_COMPLETED_DATE': - const _state = { ...state, completedDate: action.value } - return _state + { + const completedDate = state.completedDate || [] + const { date } = action + const record = completedDate.find(p => p.id === date.id) + if (record) { + record.value = date.value + } else { + completedDate.push(date) + } + const _state = { ...state, completedDate } + return _state + } + case 'PATROL_REMOVE_INIT_GRADE_BY_COMPLETED_DATE': + { + const completedDate = state.completedDate || [] + const record = completedDate.find(p => p.id === action.id) + if (!record) { + return state + } else { + completedDate.splice(completedDate.indexOf(record), 1) + const _state = { ...state, completedDate } + return _state + } + } default: return state }