提交 6b2a7f4c authored 作者: 吴强's avatar 吴强

添加新增人口Detail界面2

上级 2d5ac12d
...@@ -41,26 +41,40 @@ export default { ...@@ -41,26 +41,40 @@ export default {
})); }));
}, },
*getHouseList({ payload }, { take, put, call, select }) { *getHouseList({ payload }, { take, put, call, select }) {
console.info(1);
const { clear, pFWDiZhi } = payload; const { clear, pFWDiZhi } = payload;
console.info(2);
if (clear === 'clear') { if (clear === 'clear') {
console.info(3);
yield put({ type: 'clearList', payload: {} }); yield put({ type: 'clearList', payload: {} });
console.info(4);
} }
const { sourceData } = yield select(state => state.ListHouse); const { sourceData } = yield select(state => state.ListHouse);
console.info(5);
const size = sourceData.length; const size = sourceData.length;
console.info(6);
const coordinate = { const coordinate = {
containerType: 'module', containerType: 'module',
containerName: 'query-DSRFWInfo', containerName: 'query-DSRFWInfo',
datasourceName: 'QueryfwTable', datasourceName: 'QueryfwTable',
}; };
console.info(7);
const result = yield call(getData, coordinate, { pst: size, psz: 10, params: { pFWDiZhi } }); const result = yield call(getData, coordinate, { pst: size, psz: 10, params: { pFWDiZhi } });
console.info(78);
const meta = yield call(getMeta, coordinate); const meta = yield call(getMeta, coordinate);
console.info(9);
yield put({ type: 'setMetas', payload: meta }); yield put({ type: 'setMetas', payload: meta });
console.info(10);
for (const row of result) { for (const row of result) {
console.info(11);
yield put({ type: 'addHouse', payload: row }); yield put({ type: 'addHouse', payload: row });
console.info(12);
yield take('addHouse/@@end'); yield take('addHouse/@@end');
console.info(13);
} }
}, },
*addHouse({ payload }, { put }) { *addHouse({ payload }, { put }) {
console.info(11111);
yield put({ type: 'setList', payload: { arrayData: [payload] } }); yield put({ type: 'setList', payload: { arrayData: [payload] } });
}, },
}, },
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Created by zhouhuan on 2017/10/30. * Created by zhouhuan on 2017/10/30.
*/ */
import { Toast } from 'antd-mobile'; import { Toast } from 'antd-mobile';
import { unionBy } from 'lodash';
import { NavigationActions } from 'react-navigation'; import { NavigationActions } from 'react-navigation';
import { getData, getMeta } from '../../utils/DataTemplate'; import { getData, getMeta } from '../../utils/DataTemplate';
import { datasourceApi } from '../../services/datasource'; import { datasourceApi } from '../../services/datasource';
...@@ -83,10 +84,16 @@ export default { ...@@ -83,10 +84,16 @@ export default {
})); }));
}, },
*addPeopleInfo(ignore, { put }) { *addPeopleInfo(ignore, { put }) {
yield put({ type: 'getPeopleDetailInfo', payload: {} });
yield put(NavigationActions.navigate({ yield put(NavigationActions.navigate({
routeName: 'addPeoppleInfo', routeName: 'addPeoppleInfo',
})); }));
}, },
*GoToPeopleDetailEditScreen(ignore, { put }) {
yield put(NavigationActions.navigate({
routeName: 'peopleInfoDetailEdit',
}));
},
*updateDSRDetail({ payload }, { call, put }) { *updateDSRDetail({ payload }, { call, put }) {
console.log('update'); console.log('update');
const coordinate = { const coordinate = {
...@@ -126,10 +133,6 @@ export default { ...@@ -126,10 +133,6 @@ export default {
})); }));
yield put({ type: 'setDisabled', payload: true }); yield put({ type: 'setDisabled', payload: true });
}, },
*setStatus({ payload }, { put }) {
yield put({ type: 'setDisabled', payload: false });
yield put({ type: 'setEdit', payload });
},
*DuKa(ignored, { call, put }) { *DuKa(ignored, { call, put }) {
try { try {
Toast.loading('读卡中...', 0); Toast.loading('读卡中...', 0);
...@@ -172,7 +175,8 @@ export default { ...@@ -172,7 +175,8 @@ export default {
return { ...state, detailData }; return { ...state, detailData };
}, },
setPeopleList(state, { payload: { arrayData } }) { setPeopleList(state, { payload: { arrayData } }) {
return { ...state, sourceData: [...state.sourceData, ...arrayData] }; const newSourceData = unionBy(state.sourceData, arrayData, 'id');
return { ...state, sourceData: newSourceData };
}, },
setMetas(state, { payload }) { setMetas(state, { payload }) {
return { ...state, metas: payload }; return { ...state, metas: payload };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import React from 'react'; import React from 'react';
import { createForm } from 'rc-form'; import { createForm } from 'rc-form';
import { View, ScrollView } from 'react-native'; import { View, ScrollView } from 'react-native';
import { Button, List, InputItem, WhiteSpace } from 'antd-mobile'; import { List, InputItem, WhiteSpace } from 'antd-mobile';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Icon from 'react-native-vector-icons/FontAwesome'; import Icon from 'react-native-vector-icons/FontAwesome';
import { createAction } from '../../../utils'; import { createAction } from '../../../utils';
...@@ -68,7 +68,6 @@ class AddPeopleInfo extends React.Component { ...@@ -68,7 +68,6 @@ class AddPeopleInfo extends React.Component {
})} })}
clear clear
placeholder="请输入" placeholder="请输入"
editable="true"
ref={(el) => { ref={(el) => {
this.customFocusInst = el; this.customFocusInst = el;
}} }}
...@@ -84,7 +83,6 @@ class AddPeopleInfo extends React.Component { ...@@ -84,7 +83,6 @@ class AddPeopleInfo extends React.Component {
})} })}
clear clear
placeholder="请输入" placeholder="请输入"
editable="true"
ref={(el) => { ref={(el) => {
this.customFocusInst = el; this.customFocusInst = el;
}} }}
......
...@@ -5,6 +5,7 @@ import { StackNavigator } from 'react-navigation'; ...@@ -5,6 +5,7 @@ import { StackNavigator } from 'react-navigation';
import PeopleInfo from './peopelInfo'; import PeopleInfo from './peopelInfo';
import PeopleDetailInfo from './peopleDetailInfo'; import PeopleDetailInfo from './peopleDetailInfo';
import AddPeopleInfo from './addPeopleInfo'; import AddPeopleInfo from './addPeopleInfo';
import peopleDetailEditScreen from "./peopleDetailEditScreen";
const peopleInfoErJiScreen = StackNavigator( const peopleInfoErJiScreen = StackNavigator(
{ {
...@@ -17,6 +18,9 @@ const peopleInfoErJiScreen = StackNavigator( ...@@ -17,6 +18,9 @@ const peopleInfoErJiScreen = StackNavigator(
addPeoppleInfo: { addPeoppleInfo: {
screen: AddPeopleInfo, screen: AddPeopleInfo,
}, },
peopleInfoDetailEdit: {
screen: peopleDetailEditScreen,
},
}, },
{ {
headerMode: 'none', headerMode: 'none',
......
/**
* Created by zhouhuan on 2017/11/2.
*/
import React from 'react';
import { createForm } from 'rc-form';
import { View, ScrollView } from 'react-native';
import { List, InputItem, WhiteSpace } from 'antd-mobile';
import { connect } from 'react-redux';
import Icon from 'react-native-vector-icons/FontAwesome';
import { createAction } from '../../../utils';
@connect(({ peopleInfo }) => ({ peopleInfo }))
class PeopleDetailEditScreen extends React.Component {
componentDidMount() {
const { id } = this.props.navigation.state.params;
this.props.dispatch(createAction('peopleInfo/getPeopleDetail')(id));
}
onSubmit = () => {
this.props.form.validateFields({ force: true }, (error, value) => {
if (!error) {
this.props.dispatch(createAction('peopleInfo/updateDSRDetail')({ id: this.props.peopleInfo.peopleID, singularData: value }));
} else {
console.log('Validation failed');
}
});
};
render() {
const { detailData, metas } = this.props.peopleInfo;
console.log(this.props.peopleInfo);
const { getFieldProps } = this.props.form;
return (
<ScrollView>
<WhiteSpace />
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<Icon.Button
name="id-card"
backgroundColor="#08BBF9"
onPress={() => {
this.props.dispatch({ type: 'peopleInfo/DuKa' });
}}
>
读卡
</Icon.Button>
</View>
<WhiteSpace />
<List>
{
metas.map((m) => {
if (m.required === true) {
return (
<InputItem
{...getFieldProps(m.key, {
initialValue: detailData[m.key],
rules: [
{ required: true, message: '不允许为空' },
{ validator: this.validateNoNull },
],
})}
clear
placeholder="请输入"
ref={(el) => {
this.customFocusInst = el;
}}
>
{m.label}
</InputItem>
);
} else {
return (
<InputItem
{...getFieldProps(m.key, {
initialValue: detailData[m.key],
})}
clear
placeholder="请输入"
ref={(el) => {
this.customFocusInst = el;
}}
>
{m.label}
</InputItem>
);
}
})}
{[1].map(() => {
return (
<List.Item>
<View style={{ flexDirection: 'row', justifyContent: 'center' }}>
<Icon.Button
name="save"
backgroundColor="#08BBF9"
onPress={this.onSubmit}
>
保存
</Icon.Button>
</View>
</List.Item>
);
})
}
</List>
</ScrollView>
);
}
}
export default createForm()(PeopleDetailEditScreen);
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
* Created by zhouhuan on 2017/11/2. * Created by zhouhuan on 2017/11/2.
*/ */
import React from 'react'; import React from 'react';
import { createForm } from 'rc-form';
import { View, ScrollView } from 'react-native'; import { View, ScrollView } from 'react-native';
import { Button, List, InputItem } from 'antd-mobile'; import { List, InputItem, WhiteSpace, WingBlank } from 'antd-mobile';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Icon from 'react-native-vector-icons/FontAwesome';
import { createAction } from '../../../utils'; import { createAction } from '../../../utils';
@connect(({ peopleInfo }) => ({ peopleInfo })) @connect(({ peopleInfo }) => ({ peopleInfo }))
...@@ -15,150 +15,118 @@ class PeopleDetailInfo extends React.Component { ...@@ -15,150 +15,118 @@ class PeopleDetailInfo extends React.Component {
this.props.dispatch(createAction('peopleInfo/getPeopleDetail')(id)); this.props.dispatch(createAction('peopleInfo/getPeopleDetail')(id));
} }
onEdit =() => { onEdit =() => {
this.props.dispatch(createAction('peopleInfo/setStatus')(true)); this.props.dispatch(createAction('peopleInfo/GoToPeopleDetailEditScreen')());
};
onSubmit = () => {
this.props.form.validateFields({ force: true }, (error, value) => {
if (!error) {
this.props.dispatch(createAction('peopleInfo/updateDSRDetail')({ id: this.props.peopleInfo.peopleID, singularData: value }));
} else {
console.log('Validation failed');
}
});
};
onEditBack = () => {
this.props.dispatch(createAction('peopleInfo/onEBack')('clear'));
}; };
render() { render() {
const { detailData, editable, disabled } = this.props.peopleInfo; const { detailData, editable, metas } = this.props.peopleInfo;
console.log(this.props.peopleInfo); if (editable === true) {
const { getFieldProps } = this.props.form; return (
return ( <ScrollView>
<ScrollView> <WhiteSpace/>
<List> <View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<InputItem <Icon.Button
{...getFieldProps('xingMing', { name="id-card"
initialValue: detailData.xingMing, backgroundColor="#08BBF9"
rules: [ onPress={() => {
{ required: true, message: '不允许为空' }, this.props.dispatch({type: 'peopleInfo/DuKa'});
], }}
})} >
clear 读卡
placeholder="" </Icon.Button>
editable={editable} </View>
ref={(el) => { this.customFocusInst = el; }} <WhiteSpace/>
> <List>
姓名 {
</InputItem> metas.map((m) => {
<InputItem if (m.required === true) {
{...getFieldProps('identityCard', { return (
initialValue: detailData.identityCard, <InputItem
})} {...getFieldProps(m.key, {
clear initialValue: detailData[m.key],
placeholder="" rules: [
editable={editable} {required: true, message: '不允许为空'},
ref={(el) => { this.customFocusInst = el; }} {validator: this.validateNoNull},
> ],
证件号码 })}
</InputItem> clear
<InputItem placeholder="请输入"
{...getFieldProps('birthday', { ref={(el) => {
initialValue: detailData.birthday, this.customFocusInst = el;
})} }}
clear >
placeholder="" {m.label}
editable={editable} </InputItem>
ref={(el) => { this.customFocusInst = el; }} );
> } else {
出生日期 return (
</InputItem> <InputItem
<InputItem {...getFieldProps(m.key, {
{...getFieldProps('guoJi', { initialValue: detailData[m.key],
initialValue: detailData.guoJi, })}
})} clear
clear placeholder="请输入"
placeholder="" ref={(el) => {
editable={editable} this.customFocusInst = el;
ref={(el) => { this.customFocusInst = el; }} }}
> >
国籍 {m.label}
</InputItem> </InputItem>
<InputItem );
{...getFieldProps('minZu', { }
initialValue: detailData.minZu, })}
})} {[1].map(() => {
clear return (
placeholder="" <List.Item>
editable={editable} <View style={{flexDirection: 'row', justifyContent: 'center'}}>
ref={(el) => { this.customFocusInst = el; }} <Icon.Button
> name="save"
民族 backgroundColor="#08BBF9"
</InputItem> onPress={this.onSubmit}
<InputItem >
{...getFieldProps('lianXiDianHua', { 保存
initialValue: detailData.lianXiDianHua, </Icon.Button>
})} </View>
clear </List.Item>
placeholder="" );
editable={editable} })
ref={(el) => { this.customFocusInst = el; }} }
> </List>
联系电话 </ScrollView>
</InputItem> );
<InputItem } else {
{...getFieldProps('lianXiDiZhi', { return (
initialValue: detailData.lianXiDiZhi, <ScrollView>
})} <WhiteSpace />
clear <WhiteSpace />
placeholder="" <WingBlank>
editable={editable} <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
ref={(el) => { this.customFocusInst = el; }} <Icon.Button
> name="edit"
联系地址 backgroundColor="#08BBF9"
</InputItem> onPress={this.onEdit}
<InputItem >
{...getFieldProps('yuHuZhuGuanXi', { 编辑
initialValue: detailData.yuHuZhuGuanXi, </Icon.Button>
})}
clear
placeholder=""
editable={editable}
ref={(el) => { this.customFocusInst = el; }}
>
与户主关系
</InputItem>
<InputItem
{...getFieldProps('zhengZhiMianMao', {
initialValue: detailData.zhengZhiMianMao,
})}
clear
placeholder=""
editable={editable}
ref={(el) => { this.customFocusInst = el; }}
>
政治面貌
</InputItem>
<InputItem
{...getFieldProps('hunYinZhuangKuang', {
initialValue: detailData.hunYinZhuangKuang,
})}
clear
placeholder=""
editable={editable}
ref={(el) => { this.customFocusInst = el; }}
>
婚姻状况
</InputItem>
<List.Item>
<View style={{ flexDirection: 'row' }}>
<Button style={{ marginRight: 8 }} type="primary" onClick={this.onEdit}>编辑</Button>
<Button style={{ marginRight: 8 }} onClick={this.onSubmit} disabled={disabled}>保存</Button>
<Button onClick={this.onEditBack}>返回</Button>
</View> </View>
</List.Item> <WhiteSpace />
</List> <List>
</ScrollView> {
); metas.map((m) => {
return (
<List.Item
key={m.key}
extra={detailData[m.key]}
>
{m.label}
</List.Item>
);
})
}
</List>
</WingBlank>
</ScrollView>
);
}
} }
} }
export default createForm()(PeopleDetailInfo); export default PeopleDetailInfo;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论