提交 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/>
<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> <List>
{
metas.map((m) => {
if (m.required === true) {
return (
<InputItem <InputItem
{...getFieldProps('xingMing', { {...getFieldProps(m.key, {
initialValue: detailData.xingMing, initialValue: detailData[m.key],
rules: [ rules: [
{ required: true, message: '不允许为空' }, {required: true, message: '不允许为空'},
{validator: this.validateNoNull},
], ],
})} })}
clear clear
placeholder="" placeholder="请输入"
editable={editable} ref={(el) => {
ref={(el) => { this.customFocusInst = el; }} this.customFocusInst = el;
> }}
姓名
</InputItem>
<InputItem
{...getFieldProps('identityCard', {
initialValue: detailData.identityCard,
})}
clear
placeholder=""
editable={editable}
ref={(el) => { this.customFocusInst = el; }}
>
证件号码
</InputItem>
<InputItem
{...getFieldProps('birthday', {
initialValue: detailData.birthday,
})}
clear
placeholder=""
editable={editable}
ref={(el) => { this.customFocusInst = el; }}
>
出生日期
</InputItem>
<InputItem
{...getFieldProps('guoJi', {
initialValue: detailData.guoJi,
})}
clear
placeholder=""
editable={editable}
ref={(el) => { this.customFocusInst = el; }}
>
国籍
</InputItem>
<InputItem
{...getFieldProps('minZu', {
initialValue: detailData.minZu,
})}
clear
placeholder=""
editable={editable}
ref={(el) => { this.customFocusInst = el; }}
>
民族
</InputItem>
<InputItem
{...getFieldProps('lianXiDianHua', {
initialValue: detailData.lianXiDianHua,
})}
clear
placeholder=""
editable={editable}
ref={(el) => { this.customFocusInst = el; }}
>
联系电话
</InputItem>
<InputItem
{...getFieldProps('lianXiDiZhi', {
initialValue: detailData.lianXiDiZhi,
})}
clear
placeholder=""
editable={editable}
ref={(el) => { this.customFocusInst = el; }}
> >
联系地址 {m.label}
</InputItem> </InputItem>
);
} else {
return (
<InputItem <InputItem
{...getFieldProps('yuHuZhuGuanXi', { {...getFieldProps(m.key, {
initialValue: detailData.yuHuZhuGuanXi, initialValue: detailData[m.key],
})} })}
clear clear
placeholder="" placeholder="请输入"
editable={editable} ref={(el) => {
ref={(el) => { this.customFocusInst = el; }} this.customFocusInst = el;
}}
> >
与户主关系 {m.label}
</InputItem> </InputItem>
<InputItem );
{...getFieldProps('zhengZhiMianMao', { }
initialValue: detailData.zhengZhiMianMao,
})} })}
clear {[1].map(() => {
placeholder="" return (
editable={editable} <List.Item>
ref={(el) => { this.customFocusInst = el; }} <View style={{flexDirection: 'row', justifyContent: 'center'}}>
<Icon.Button
name="save"
backgroundColor="#08BBF9"
onPress={this.onSubmit}
> >
政治面貌 保存
</InputItem> </Icon.Button>
<InputItem </View>
{...getFieldProps('hunYinZhuangKuang', { </List.Item>
initialValue: detailData.hunYinZhuangKuang, );
})} })
clear }
placeholder="" </List>
editable={editable} </ScrollView>
ref={(el) => { this.customFocusInst = el; }} );
} else {
return (
<ScrollView>
<WhiteSpace />
<WhiteSpace />
<WingBlank>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<Icon.Button
name="edit"
backgroundColor="#08BBF9"
onPress={this.onEdit}
> >
婚姻状况 编辑
</InputItem> </Icon.Button>
<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>
<WhiteSpace />
<List>
{
metas.map((m) => {
return (
<List.Item
key={m.key}
extra={detailData[m.key]}
>
{m.label}
</List.Item> </List.Item>
);
})
}
</List> </List>
</WingBlank>
</ScrollView> </ScrollView>
); );
} }
}
} }
export default createForm()(PeopleDetailInfo); export default PeopleDetailInfo;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论