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

添加新增人口Detail界面2

上级 2d5ac12d
......@@ -41,26 +41,40 @@ export default {
}));
},
*getHouseList({ payload }, { take, put, call, select }) {
console.info(1);
const { clear, pFWDiZhi } = payload;
console.info(2);
if (clear === 'clear') {
console.info(3);
yield put({ type: 'clearList', payload: {} });
console.info(4);
}
const { sourceData } = yield select(state => state.ListHouse);
console.info(5);
const size = sourceData.length;
console.info(6);
const coordinate = {
containerType: 'module',
containerName: 'query-DSRFWInfo',
datasourceName: 'QueryfwTable',
};
console.info(7);
const result = yield call(getData, coordinate, { pst: size, psz: 10, params: { pFWDiZhi } });
console.info(78);
const meta = yield call(getMeta, coordinate);
console.info(9);
yield put({ type: 'setMetas', payload: meta });
console.info(10);
for (const row of result) {
console.info(11);
yield put({ type: 'addHouse', payload: row });
console.info(12);
yield take('addHouse/@@end');
console.info(13);
}
},
*addHouse({ payload }, { put }) {
console.info(11111);
yield put({ type: 'setList', payload: { arrayData: [payload] } });
},
},
......
......@@ -2,6 +2,7 @@
* Created by zhouhuan on 2017/10/30.
*/
import { Toast } from 'antd-mobile';
import { unionBy } from 'lodash';
import { NavigationActions } from 'react-navigation';
import { getData, getMeta } from '../../utils/DataTemplate';
import { datasourceApi } from '../../services/datasource';
......@@ -83,10 +84,16 @@ export default {
}));
},
*addPeopleInfo(ignore, { put }) {
yield put({ type: 'getPeopleDetailInfo', payload: {} });
yield put(NavigationActions.navigate({
routeName: 'addPeoppleInfo',
}));
},
*GoToPeopleDetailEditScreen(ignore, { put }) {
yield put(NavigationActions.navigate({
routeName: 'peopleInfoDetailEdit',
}));
},
*updateDSRDetail({ payload }, { call, put }) {
console.log('update');
const coordinate = {
......@@ -126,10 +133,6 @@ export default {
}));
yield put({ type: 'setDisabled', payload: true });
},
*setStatus({ payload }, { put }) {
yield put({ type: 'setDisabled', payload: false });
yield put({ type: 'setEdit', payload });
},
*DuKa(ignored, { call, put }) {
try {
Toast.loading('读卡中...', 0);
......@@ -172,7 +175,8 @@ export default {
return { ...state, detailData };
},
setPeopleList(state, { payload: { arrayData } }) {
return { ...state, sourceData: [...state.sourceData, ...arrayData] };
const newSourceData = unionBy(state.sourceData, arrayData, 'id');
return { ...state, sourceData: newSourceData };
},
setMetas(state, { payload }) {
return { ...state, metas: payload };
......
......@@ -4,7 +4,7 @@
import React from 'react';
import { createForm } from 'rc-form';
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 Icon from 'react-native-vector-icons/FontAwesome';
import { createAction } from '../../../utils';
......@@ -68,7 +68,6 @@ class AddPeopleInfo extends React.Component {
})}
clear
placeholder="请输入"
editable="true"
ref={(el) => {
this.customFocusInst = el;
}}
......@@ -84,7 +83,6 @@ class AddPeopleInfo extends React.Component {
})}
clear
placeholder="请输入"
editable="true"
ref={(el) => {
this.customFocusInst = el;
}}
......
......@@ -5,6 +5,7 @@ import { StackNavigator } from 'react-navigation';
import PeopleInfo from './peopelInfo';
import PeopleDetailInfo from './peopleDetailInfo';
import AddPeopleInfo from './addPeopleInfo';
import peopleDetailEditScreen from "./peopleDetailEditScreen";
const peopleInfoErJiScreen = StackNavigator(
{
......@@ -17,6 +18,9 @@ const peopleInfoErJiScreen = StackNavigator(
addPeoppleInfo: {
screen: AddPeopleInfo,
},
peopleInfoDetailEdit: {
screen: peopleDetailEditScreen,
},
},
{
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 @@
* Created by zhouhuan on 2017/11/2.
*/
import React from 'react';
import { createForm } from 'rc-form';
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 Icon from 'react-native-vector-icons/FontAwesome';
import { createAction } from '../../../utils';
@connect(({ peopleInfo }) => ({ peopleInfo }))
......@@ -15,150 +15,118 @@ class PeopleDetailInfo extends React.Component {
this.props.dispatch(createAction('peopleInfo/getPeopleDetail')(id));
}
onEdit =() => {
this.props.dispatch(createAction('peopleInfo/setStatus')(true));
};
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'));
this.props.dispatch(createAction('peopleInfo/GoToPeopleDetailEditScreen')());
};
render() {
const { detailData, editable, disabled } = this.props.peopleInfo;
console.log(this.props.peopleInfo);
const { getFieldProps } = this.props.form;
return (
<ScrollView>
<List>
<InputItem
{...getFieldProps('xingMing', {
initialValue: detailData.xingMing,
rules: [
{ required: true, message: '不允许为空' },
],
})}
clear
placeholder=""
editable={editable}
ref={(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; }}
>
联系地址
</InputItem>
<InputItem
{...getFieldProps('yuHuZhuGuanXi', {
initialValue: detailData.yuHuZhuGuanXi,
})}
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>
const { detailData, editable, metas } = this.props.peopleInfo;
if (editable === true) {
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>
);
} else {
return (
<ScrollView>
<WhiteSpace />
<WhiteSpace />
<WingBlank>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<Icon.Button
name="edit"
backgroundColor="#08BBF9"
onPress={this.onEdit}
>
编辑
</Icon.Button>
</View>
</List.Item>
</List>
</ScrollView>
);
<WhiteSpace />
<List>
{
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论