update patrol
This commit is contained in:
@@ -17,6 +17,9 @@ import { AntIcon } from 'components'
|
|||||||
import getDictData from 'util/dic'
|
import getDictData from 'util/dic'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { CITY } from 'util/global'
|
import { CITY } from 'util/global'
|
||||||
|
import store from 'store'
|
||||||
|
|
||||||
|
const { dispatch } = store
|
||||||
|
|
||||||
const layout = {
|
const layout = {
|
||||||
labelCol: { flex: '150px' },
|
labelCol: { flex: '150px' },
|
||||||
@@ -76,6 +79,11 @@ export default class building extends Component {
|
|||||||
const { houseInfo } = this.record
|
const { houseInfo } = this.record
|
||||||
if (houseInfo.completedDate) {
|
if (houseInfo.completedDate) {
|
||||||
houseInfo.completedDate = moment(houseInfo.completedDate)
|
houseInfo.completedDate = moment(houseInfo.completedDate)
|
||||||
|
debugger
|
||||||
|
dispatch({
|
||||||
|
type: 'PATROL_INIT_GRADE_BY_COMPLETED_DATE',
|
||||||
|
value: +houseInfo.completedDate.format('YYYY'),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkbox
|
// checkbox
|
||||||
@@ -160,6 +168,13 @@ export default class building extends Component {
|
|||||||
showKeepWarmMaterialText: value.includes('100'),
|
showKeepWarmMaterialText: value.includes('100'),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (houseInfo.hasOwnProperty('completedDate')) {
|
||||||
|
dispatch({
|
||||||
|
type: 'PATROL_INIT_GRADE_BY_COMPLETED_DATE',
|
||||||
|
value: +houseInfo.completedDate.format('YYYY'),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#region 自定义方法
|
//#region 自定义方法
|
||||||
|
|||||||
@@ -1,7 +1,176 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
|
import { Form, Input, Radio, Spin } from 'antd'
|
||||||
|
import { AntIcon } from 'components'
|
||||||
|
import { cloneDeep, first, isEqual, last, sortBy } from 'lodash'
|
||||||
|
import getDictData from 'util/dic'
|
||||||
|
import store from 'store'
|
||||||
|
|
||||||
|
const { getState, subscribe } = store
|
||||||
|
|
||||||
|
const layout = {
|
||||||
|
labelCol: { flex: '150px' },
|
||||||
|
wrapperCol: { flex: '1' },
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class handling extends Component {
|
||||||
|
state = {
|
||||||
|
loading: true,
|
||||||
|
codes: {
|
||||||
|
dicHousePatrolInitGrade: [],
|
||||||
|
dicHousePatrolDamageGrade: [],
|
||||||
|
dicHouseGrade: [],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
form = React.createRef()
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
|
||||||
|
this.unsubscribe = subscribe('business', business => {
|
||||||
|
const initGrade = this.getInitGrade(business.completedDate)
|
||||||
|
this.form.current.setFieldsValue({
|
||||||
|
patrolInfo: {
|
||||||
|
initGrade,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldComponentUpdate(props, state) {
|
||||||
|
return !isEqual(this.state, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.fillData({
|
||||||
|
record: this.props.record,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.unsubscribe()
|
||||||
|
}
|
||||||
|
|
||||||
|
call() {
|
||||||
|
if (this.props.onRef) {
|
||||||
|
this.props.onRef(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 填充数据
|
||||||
|
* 可以在设置this.record之后对其作出数据结构调整
|
||||||
|
* [异步,必要]
|
||||||
|
* @param {*} params
|
||||||
|
*/
|
||||||
|
async fillData(params) {
|
||||||
|
this.record = cloneDeep(params.record)
|
||||||
|
const _state = { loading: false }
|
||||||
|
//#region 从后端转换成前段所需格式
|
||||||
|
if (this.record) {
|
||||||
|
const { patrolInfo } = this.record
|
||||||
|
patrolInfo.initGrade = this.getInitGrade(getState('business').completedDate)
|
||||||
|
}
|
||||||
|
_state.codes = await getDictData(
|
||||||
|
'dic_house_patrol_init_grade',
|
||||||
|
'dic_house_patrol_damage_grade',
|
||||||
|
'dic_house_grade'
|
||||||
|
)
|
||||||
|
//#endregion
|
||||||
|
this.form.current.setFieldsValue(this.record)
|
||||||
|
|
||||||
|
this.setState(_state)
|
||||||
|
this.call()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据
|
||||||
|
* 可以对postData进行数据结构调整
|
||||||
|
* [异步,必要]
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async getData() {
|
||||||
|
const form = this.form.current
|
||||||
|
|
||||||
|
const valid = await form.validateFields()
|
||||||
|
if (valid) {
|
||||||
|
const postData = form.getFieldsValue()
|
||||||
|
//#region 从前段转换后端所需格式
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
return postData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default class grade extends Component {
|
|
||||||
render() {
|
render() {
|
||||||
return <div>1</div>
|
const { loading, codes, initGradeValue } = this.state
|
||||||
|
console.log(initGradeValue)
|
||||||
|
return (
|
||||||
|
<Spin spinning={loading} indicator={<AntIcon type="loading" />}>
|
||||||
|
<Form {...layout} ref={this.form}>
|
||||||
|
<Form.Item
|
||||||
|
label="初始等级"
|
||||||
|
name={['patrolInfo', 'initGrade']}
|
||||||
|
rules={[{ required: true, message: '请选择初始等级' }]}
|
||||||
|
>
|
||||||
|
<Radio.Group disabled buttonStyle="solid">
|
||||||
|
{codes.dicHousePatrolInitGrade.map(item => {
|
||||||
|
return (
|
||||||
|
<Radio.Button key={item.code} value={+item.code}>
|
||||||
|
{item.value}
|
||||||
|
</Radio.Button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
label="损坏等级"
|
||||||
|
name={['patrolInfo', 'damageGrade']}
|
||||||
|
rules={[{ required: true, message: '请选择损坏等级' }]}
|
||||||
|
>
|
||||||
|
<Radio.Group buttonStyle="solid">
|
||||||
|
{codes.dicHousePatrolDamageGrade.map(item => {
|
||||||
|
return (
|
||||||
|
<Radio.Button key={item.code} value={+item.code}>
|
||||||
|
{item.value}
|
||||||
|
</Radio.Button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
label="综合等级"
|
||||||
|
name={['patrolInfo', 'comprehensiveGrade']}
|
||||||
|
rules={[{ required: true, message: '请选择综合等级' }]}
|
||||||
|
>
|
||||||
|
<Radio.Group buttonStyle="solid">
|
||||||
|
{codes.dicHouseGrade.map(item => {
|
||||||
|
return (
|
||||||
|
<Radio.Button key={item.code} value={+item.code}>
|
||||||
|
{item.value}
|
||||||
|
</Radio.Button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Spin>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,131 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
|
import { Form, Input, Radio, Spin } from 'antd'
|
||||||
|
import { AntIcon } from 'components'
|
||||||
|
import { cloneDeep, first, isEqual, last, sortBy } from 'lodash'
|
||||||
|
import getDictData from 'util/dic'
|
||||||
|
|
||||||
|
const layout = {
|
||||||
|
labelCol: { flex: '150px' },
|
||||||
|
wrapperCol: { flex: '1' },
|
||||||
|
}
|
||||||
|
|
||||||
export default class handling extends Component {
|
export default class handling extends Component {
|
||||||
|
state = {
|
||||||
|
loading: true,
|
||||||
|
codes: {
|
||||||
|
dicHousePatrolHandlingOpinion: [],
|
||||||
|
dicHousePatrolRectifyReform: [],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
form = React.createRef()
|
||||||
|
|
||||||
|
shouldComponentUpdate(props, state) {
|
||||||
|
return !isEqual(this.state, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.fillData({
|
||||||
|
record: this.props.record,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
call() {
|
||||||
|
if (this.props.onRef) {
|
||||||
|
this.props.onRef(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 填充数据
|
||||||
|
* 可以在设置this.record之后对其作出数据结构调整
|
||||||
|
* [异步,必要]
|
||||||
|
* @param {*} params
|
||||||
|
*/
|
||||||
|
async fillData(params) {
|
||||||
|
this.record = cloneDeep(params.record)
|
||||||
|
const _state = { loading: false }
|
||||||
|
//#region 从后端转换成前段所需格式
|
||||||
|
_state.codes = await getDictData(
|
||||||
|
'dic_house_patrol_handling_opinion',
|
||||||
|
'dic_house_patrol_rectify_Reform'
|
||||||
|
)
|
||||||
|
//#endregion
|
||||||
|
this.form.current.setFieldsValue(this.record)
|
||||||
|
|
||||||
|
this.setState(_state)
|
||||||
|
this.call()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据
|
||||||
|
* 可以对postData进行数据结构调整
|
||||||
|
* [异步,必要]
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async getData() {
|
||||||
|
const form = this.form.current
|
||||||
|
|
||||||
|
const valid = await form.validateFields()
|
||||||
|
if (valid) {
|
||||||
|
const postData = form.getFieldsValue()
|
||||||
|
//#region 从前段转换后端所需格式
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
return postData
|
||||||
|
}
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
return <div>1</div>
|
const { loading, codes } = this.state
|
||||||
|
return (
|
||||||
|
<Spin spinning={loading} indicator={<AntIcon type="loading" />}>
|
||||||
|
<Form {...layout} ref={this.form}>
|
||||||
|
<Form.Item
|
||||||
|
label="处理建议"
|
||||||
|
name={['patrolInfo', 'handlingOpinion']}
|
||||||
|
rules={[{ required: true, message: '请选择处理建议' }]}
|
||||||
|
>
|
||||||
|
<Radio.Group buttonStyle="solid">
|
||||||
|
{codes.dicHousePatrolHandlingOpinion.map(item => {
|
||||||
|
return (
|
||||||
|
<Radio.Button key={item.code} value={+item.code}>
|
||||||
|
{item.value}
|
||||||
|
</Radio.Button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="处理建议备注" name={['patrolInfo', 'handlingOpinionRemark']}>
|
||||||
|
<Input.TextArea
|
||||||
|
autoSize={{ minRows: 3 }}
|
||||||
|
placeholder="请输入处理建议备注"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
label="整改情况"
|
||||||
|
name={['patrolInfo', 'rectifyAndReform']}
|
||||||
|
rules={[{ required: true, message: '请选择整改情况' }]}
|
||||||
|
>
|
||||||
|
<Radio.Group buttonStyle="solid">
|
||||||
|
{codes.dicHousePatrolRectifyReform.map(item => {
|
||||||
|
return (
|
||||||
|
<Radio.Button key={item.code} value={+item.code}>
|
||||||
|
{item.value}
|
||||||
|
</Radio.Button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="整改情况备注" name={['patrolInfo', 'rectifyAndReformRemark']}>
|
||||||
|
<Input.TextArea
|
||||||
|
autoSize={{ minRows: 3 }}
|
||||||
|
placeholder="请输入整改情况备注"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Spin>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,102 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
|
import { Form, Input, Radio, Spin } from 'antd'
|
||||||
|
import { AntIcon } from 'components'
|
||||||
|
import { cloneDeep, first, isEqual, last, sortBy } from 'lodash'
|
||||||
|
|
||||||
|
const layout = {
|
||||||
|
labelCol: { flex: '150px' },
|
||||||
|
wrapperCol: { flex: '1' },
|
||||||
|
}
|
||||||
|
|
||||||
export default class result extends Component {
|
export default class result extends Component {
|
||||||
|
state = {
|
||||||
|
loading: true,
|
||||||
|
codes: {
|
||||||
|
patrolResult: [
|
||||||
|
{ code: '0', value: '正常' },
|
||||||
|
{ code: '-1', value: '异常' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
form = React.createRef()
|
||||||
|
|
||||||
|
shouldComponentUpdate(props, state) {
|
||||||
|
return !isEqual(this.state, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.fillData({
|
||||||
|
record: this.props.record,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
call() {
|
||||||
|
if (this.props.onRef) {
|
||||||
|
this.props.onRef(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 填充数据
|
||||||
|
* 可以在设置this.record之后对其作出数据结构调整
|
||||||
|
* [异步,必要]
|
||||||
|
* @param {*} params
|
||||||
|
*/
|
||||||
|
async fillData(params) {
|
||||||
|
this.record = cloneDeep(params.record)
|
||||||
|
//#region 从后端转换成前段所需格式
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
this.form.current.setFieldsValue(this.record)
|
||||||
|
|
||||||
|
this.setState({ loading: false })
|
||||||
|
this.call()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据
|
||||||
|
* 可以对postData进行数据结构调整
|
||||||
|
* [异步,必要]
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async getData() {
|
||||||
|
const form = this.form.current
|
||||||
|
|
||||||
|
const valid = await form.validateFields()
|
||||||
|
if (valid) {
|
||||||
|
const postData = form.getFieldsValue()
|
||||||
|
//#region 从前段转换后端所需格式
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
return postData
|
||||||
|
}
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
return <div></div>
|
const { loading, codes } = this.state
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Spin spinning={loading} indicator={<AntIcon type="loading" />}>
|
||||||
|
<Form {...layout} ref={this.form}>
|
||||||
|
<Form.Item
|
||||||
|
label="正常与否"
|
||||||
|
name={['patrolInfo', 'patrolResult']}
|
||||||
|
rules={[{ required: true, message: '请选择本期巡查结果' }]}
|
||||||
|
>
|
||||||
|
<Radio.Group buttonStyle="solid">
|
||||||
|
{codes.patrolResult.map(item => {
|
||||||
|
return (
|
||||||
|
<Radio.Button key={item.code} value={+item.code}>
|
||||||
|
{item.value}
|
||||||
|
</Radio.Button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="异常情况描述" name={['patrolInfo', 'patrolResultRemark']}>
|
||||||
|
<Input.TextArea autoSize placeholder="请输入异常情况描述" />
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Spin>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
web-react/src/store/reducer/business.js
Normal file
11
web-react/src/store/reducer/business.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
const business = (state = {}, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case 'PATROL_INIT_GRADE_BY_COMPLETED_DATE':
|
||||||
|
const _state = { ...state, completedDate: action.value }
|
||||||
|
return _state
|
||||||
|
default:
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default business
|
||||||
@@ -3,12 +3,14 @@ import user from './user'
|
|||||||
import layout from './layout'
|
import layout from './layout'
|
||||||
import nav from './nav'
|
import nav from './nav'
|
||||||
import dictData from './dict-data'
|
import dictData from './dict-data'
|
||||||
|
import business from './business'
|
||||||
|
|
||||||
const combine = combineReducers({
|
const combine = combineReducers({
|
||||||
user,
|
user,
|
||||||
layout,
|
layout,
|
||||||
nav,
|
nav,
|
||||||
dictData
|
dictData,
|
||||||
|
business
|
||||||
})
|
})
|
||||||
|
|
||||||
export default combine
|
export default combine
|
||||||
Reference in New Issue
Block a user