提交 75e662c6 authored 作者: 吴强's avatar 吴强

我要提交,请批准

上级 d1cece8a
import React from 'react';
import { Platform, Keyboard } from 'react-native';
import { TabBarBottom, TabBarTop } from 'react-navigation';
class TabBarComponent extends React.PureComponent {
constructor(props) {
super(props);
this.keyboardWillShow = this.keyboardWillShow.bind(this);
this.keyboardWillHide = this.keyboardWillHide.bind(this);
this.state = {
isVisible: true,
};
}
componentWillMount() {
this.keyboardWillShowSub = Keyboard.addListener('keyboardDidShow', this.keyboardWillShow);
this.keyboardWillHideSub = Keyboard.addListener('keyboardDidHide', this.keyboardWillHide);
}
componentWillUnmount() {
this.keyboardWillShowSub.remove();
this.keyboardWillHideSub.remove();
}
keyboardWillShow = () => {
this.setState({
isVisible: false,
});
};
keyboardWillHide = () => {
this.setState({
isVisible: true,
});
};
render() {
const TBB = Platform.select({
ios: TabBarBottom,
android: TabBarTop,
});
return this.state.isVisible ?
<TBB {...this.props} />
:
null;
}
}
export default TabBarComponent;
......@@ -11,7 +11,7 @@ import { processError } from './utils/error';
const app = dva({
initialState: {},
models: [...models, routerModel],
extraEnhancers: [autoRehydrate()],
extraEnhancers: [autoRehydrate({ log: true })],
onError: processError,
});
......
import { unionBy } from 'lodash';
import { NavigationActions } from 'react-navigation';
import { getData, getMeta } from '../../utils/DataTemplate';
export default {
namespace: 'DSRInfo',
state: {
sourceData: [],
metas: [],
DSRID: '',
},
reducers: {
setDSRID(state, { payload }) {
return {
...state,
DSRID: payload,
};
},
setList(state, { payload: { arrayData } }) {
const newSourceData = unionBy(state.sourceData, arrayData, 'id');
return { ...state, sourceData: newSourceData };
},
// 下拉刷新用到的,清空列表的数据
clearList(state) {
return { ...state, sourceData: [] };
},
setMetas(state, { payload }) {
return { ...state, metas: payload };
},
},
effects: {
*jumpPage({ payload: id }, { put }) {
yield put({ type: 'setDSRID', payload: id });
yield put(NavigationActions.navigate({
routeName: 'DSRInfoDetail',
params: { id },
}));
},
*getDSRList({ payload }, { take, put, call, select }) {
if (payload === 'clear') {
yield put({ type: 'clearList', payload: {} });
}
const { sourceData } = yield select(state => state.DSRInfo);
const size = sourceData.length;
const coordinate = {
containerType: 'module',
containerName: 'query-DSRInfo',
datasourceName: 'QueryDSRInfoTable',
};
const result = yield call(getData, coordinate, { pst: size, psz: 10 });
const meta = yield call(getMeta, coordinate);
yield put({ type: 'setMetas', payload: meta });
// const result = yield call('', 'query-DSRFWInfo', 'QueryfwTable', { pst: size, psz: 10 });
for (const row of result) {
yield put({ type: 'addDSR', payload: row });
yield take('addDSR/@@end');
}
},
*addDSR({ payload }, { put }) {
yield put({ type: 'setList', payload: { arrayData: [payload] } });
},
},
};
import { Toast } from 'antd-mobile';
import { NavigationActions } from 'react-navigation';
import { getData, getMeta } from '../../utils/DataTemplate';
import { datasourceApi } from '../../services/datasource';
export default {
namespace: 'DSRInfoDetail',
state: {
singularData: {},
metas: [],
enableEdit: false,
DSRID: '',
},
reducers: {
setList(state, { payload }) {
return { ...state, singularData: payload.singularData };
},
setEnable(state, { payload: enableEdit }) {
return { ...state, enableEdit };
},
setMetas(state, { payload }) {
return { ...state, metas: payload };
},
setDSRID(state, { payload }) {
return {
...state,
DSRID: payload,
};
},
},
effects: {
*getDSRInfoDetail({ payload }, { call, put }) {
const coordinate = {
containerType: 'module',
containerName: 'query-DSRInfo',
datasourceName: 'QueryDSRInfoDetails',
};
const result = yield call(getData, coordinate, { pst: 0, psz: 10, params: { pID: payload } });
const singularData = result[0];
yield put({ type: 'setDSRID', payload });
yield put({ type: 'setList', payload: { singularData: { ...singularData } } });
const metas = yield call(getMeta, coordinate);
yield put({ type: 'setMetas', payload: metas });
},
*updateDSRInfoDetail({ payload }, { call, put }) {
const coordinate = {
containerType: 'module',
containerName: 'query-DSRInfo',
datasourceName: 'QueryDSRInfoDetails',
};
const api = datasourceApi(coordinate);
yield call(api.update, payload.id, payload.singularData);
Toast.success('修改成功!', 1);
yield put(NavigationActions.navigate({
routeName: 'DSRInfoList',
}));
yield put({ type: 'setEnable', payload: false });
},
},
};
......@@ -11,6 +11,7 @@ export default {
state: {
sourceData: {},
detailData: {},
metas: [],
isDetail: false,
editable: false,
disabled: true,
......@@ -38,13 +39,11 @@ export default {
datasourceName: 'QueryDSRInfoDetails',
};
const result = yield call(getData, coordinate, { params: { pID: payload } });
console.log(result);
yield put({ type: 'getDSRDetail', payload: { ...result[0] } });
yield put({ type: 'setDetail', payload: true });
yield put({ type: 'setEdit', payload: false });
},
*updateDSRDetail({ payload }, { call, put }) {
console.log('update');
const coordinate = {
containerType: 'module',
containerName: 'query-DSRInfo',
......@@ -92,6 +91,9 @@ export default {
sourceData: payload,
};
},
setMetas(state, { payload }) {
return { ...state, metas: payload };
},
setDetail(state, { payload }) {
return {
...state,
......
import { getData } from '../../utils/DataTemplate';
import { NavigationActions } from 'react-navigation';
import { getData, getMeta } from '../../utils/DataTemplate';
export default {
namespace: 'ListHouse',
......@@ -22,7 +23,6 @@ export default {
return { ...state, sourceData: [] };
},
setMetas(state, { payload }) {
console.info(payload);
return { ...state, metas: payload };
},
},
......@@ -38,7 +38,6 @@ export default {
yield put({ type: 'clearList', payload: {} });
}
const { sourceData } = yield select(state => state.ListHouse);
console.info(sourceData);
const size = sourceData.length;
const coordinate = {
containerType: 'module',
......
......@@ -3,6 +3,8 @@ import login from './login';
import listHouse from './houseinfo/listhouse';
import HouseDetail from './houseinfo/houseDetail';
import obligeeInfo from './houseinfo/ObligeeInfo';
import DSRInfo from './dangshireninfo/dsrinfo';
import DSRInfoDetail from './dangshireninfo/dsrinfodetail';
export default [
welcome,
......@@ -10,4 +12,6 @@ export default [
listHouse,
HouseDetail,
obligeeInfo,
DSRInfo,
DSRInfoDetail,
];
/**
* Created by zhouhuan on 2017/10/30.
*/
import React from 'react';
import { createForm } from 'rc-form';
import { View, ScrollView } from 'react-native';
import { List, InputItem, Button, Toast } from 'antd-mobile';
import { connect } from 'react-redux';
import { createAction } from '../../../utils';
@connect(({ DSRInfoDetail }) => ({ DSRInfoDetail }))
class DSRInfoDetailScreen extends React.Component {
componentDidMount() {
const { id } = this.props.navigation.state.params;
this.props.dispatch(createAction('DSRInfoDetail/getDSRInfoDetail')(id));
}
onEdit =() => {
this.props.dispatch(createAction('DSRInfoDetail/setEnable')(true));
};
onSubmit = () => {
this.props.form.validateFields({ force: true }, (error, value) => {
if (!error) {
this.props.dispatch(createAction('DSRInfoDetail/updateDSRInfoDetail')({ id: this.props.DSRInfoDetail.DSRID, singularData: value }));
} else {
Toast.show('Validation failed');
}
});
};
validateNoNull = (rule, value, callback) => {
if (value) {
callback();
} else {
callback(new Error('At least four charactors for account'));
}
};
render() {
const { singularData, metas, enableEdit } = this.props.DSRInfoDetail;
const { getFieldProps } = this.props.form;
return (
<ScrollView>
<List>
{
metas.map((m) => {
if (m.required === true) {
return (
<InputItem
{...getFieldProps(m.key, {
initialValue: singularData[m.key],
rules: [
{ required: true, message: '不允许为空' },
{ validator: this.validateNoNull },
],
})}
clear
placeholder="请输入"
editable={enableEdit}
ref={(el) => { this.customFocusInst = el; }}
>
姓名
</InputItem>
);
} else {
return (
<InputItem
{...getFieldProps(m.key, {
initialValue: singularData[m.key],
})}
clear
placeholder="请输入"
editable={enableEdit}
ref={(el) => { this.customFocusInst = el; }}
>
{m.label}
</InputItem>
);
}
})}
{[1].map(() => {
return (
<List.Item>
<View style={{ flexDirection: 'row' }}>
<Button style={{ marginRight: 8 }} type="primary" onClick={this.onEdit}>编辑</Button>
<Button style={{ marginRight: 8 }} onClick={this.onSubmit}>保存</Button>
</View>
</List.Item>
);
})
}
</List>
</ScrollView>
);
}
}
export default createForm()(DSRInfoDetailScreen);
import React, { Component } from 'react';
import { Text, FlatList, View } from 'react-native';
import { Text, FlatList } from 'react-native';
import { Card, WingBlank, WhiteSpace } from 'antd-mobile';
import { connect } from 'react-redux';
import { createAction } from '../../utils';
import FlatListItem from './houseinfo/FlatListItem';
import { createAction } from '../../../utils/index';
import FlatListItem from '../houseinfo/FlatListItem';
@connect(({ DSRInfo }) => ({ DSRInfo/* , loading: !!loading.effects['obligeeInfo/getObligeeInfo'] */ }))
class DSRInfoScreeen extends Component {
componentDidMount() {
const { dispatch } = this.props;
console.info('初始加载');
dispatch(createAction('DSRInfo/getDSRList')());
}
// 上拉加载更多
onEndReached = () => {
// 以下是制造新数据
if (!this.props.loading) {
console.log('上啦加载')
this.props.dispatch(createAction('DSRInfo/getDSRList')());
}
};
......@@ -31,7 +33,6 @@ class DSRInfoScreeen extends Component {
* 若item.key也不存在,则使用数组下标
*
* @param item
* @param index
* @private
*/
// 这里指定使用数组下标作为唯一索引
......@@ -63,7 +64,6 @@ class DSRInfoScreeen extends Component {
// 下拉刷新
renderRefresh = () => {
if (!this.props.loading) {
console.info('wodewodewode');
this.props.dispatch(createAction('DSRInfo/getDSRList')('clear'));
}
};
......
import { StackNavigator } from 'react-navigation';
import DSRInfoScreen from './DSRInfoScreeen';
import DSRInfoDetailScreen from './DSRInfoDetailScreen';
const DSRErJiScreen = StackNavigator(
{
DSRInfoList: {
screen: DSRInfoScreen,
},
DSRInfoDetail: {
screen: DSRInfoDetailScreen,
},
},
{
headerMode: 'none',
navigationOptions: {
gesturesEnabled: false,
},
},
);
export default DSRErJiScreen;
import React, { PureComponent } from 'react';
import { TouchableOpacity, Text, View, StyleSheet, Dimensions, Image } from 'react-native';
import { TouchableOpacity, Text, View, StyleSheet, Dimensions } from 'react-native';
import { Card, WingBlank, WhiteSpace } from 'antd-mobile';
const totalWidth = Dimensions.get('window').width;
......
import React, { Component } from 'react';
import { View, ScrollView, Text } from 'react-native';
import { List, InputItem, Button } from 'antd-mobile';
import { View, ScrollView } from 'react-native';
import { List, InputItem, Button, Toast } from 'antd-mobile';
import { createForm } from 'rc-form';
import { connect } from 'react-redux';
import { createAction } from '../../../utils/index';
......@@ -15,28 +15,26 @@ class HouseDetail extends Component {
this.props.form.validateFields({ force: true }, (error, value) => {
if (!error) {
// 校验成功执行这里的代码
console.info({ id: this.props.navigation.state.params.id, singularData: value });
this.props.dispatch(createAction('HouseDetail/updateHouseDetail')({ id: this.props.ListHouse.houseID, singularData: value }));
console.log(this.props.form.getFieldsValue());
} else {
// 执行出现错误,弹出错处理
console.log('Validation failed');
Toast.show('Validation failed');
}
});
}
};
onReset = () => {
this.props.form.resetFields();
}
};
validateFWBianMa = (rule, value, callback) => {
if (value) {
callback();
} else {
callback(new Error('At least four charactors for account'));
}
}
};
modifyInfo = () => {
this.props.dispatch(createAction({ type: 'setEnable', payload: { enableEdit: true } }));
}
};
render() {
const { getFieldProps } = this.props.form;
......
......@@ -3,8 +3,8 @@
*/
import React from 'react';
import { createForm } from 'rc-form';
import { View, StyleSheet, FlatList, Text, ScrollView } from 'react-native';
import { Card, WingBlank, WhiteSpace } from 'antd-mobile';
import { View, StyleSheet, Text, ScrollView } from 'react-native';
import { Card, WingBlank, WhiteSpace, List, InputItem, Button } from 'antd-mobile';
import { connect } from 'react-redux';
import { createAction } from '../../../utils';
......@@ -29,14 +29,13 @@ class ObligeeInfo extends React.Component {
console.log('Validation failed');
}
});
}
};
onEditBack = () => {
const { houseID } = this.props.ListHouse;
this.props.dispatch(createAction('obligeeInfo/onEBack')(houseID));
}
};
render() {
const { sourceData, isDetail, detailData, editable, disabled } = this.props.obligeeInfo;
console.log(this.props.obligeeInfo);
const { getFieldProps } = this.props.form;
if (isDetail === false) {
return (
......
import React, { Component } from 'react';
import { View, FlatList, Text } from 'react-native';
import { FlatList, Text } from 'react-native';
import { Card, WingBlank, WhiteSpace } from 'antd-mobile';
import { connect } from 'react-redux';
import { createAction } from '../../../utils';
......@@ -33,38 +33,28 @@ class ListHouContent extends Component {
* 若item.key也不存在,则使用数组下标
*
* @param item
* @param index
* @private
*/
// 这里指定使用数组下标作为唯一索引
keyExtractor = item => `${item.id}`;
// 自定义分割线
renderItemSeparatorComponent = ({ highlighted }) => (
<View style={{ height: 1, backgroundColor: '#ccc' }}></View>
);
// Footer布局
renderFooter = () => (
<WingBlank size="lg">
<WhiteSpace size="lg" />
<WhiteSpace size="lg">
<Card>
<Card.Body>
<Text>到底了!!!</Text>
</Card.Body>
</Card>
<WhiteSpace size="lg" />
</WingBlank>
</WhiteSpace>
);
// 空布局
renderEmptyView = () => (
<WingBlank size="lg">
<WhiteSpace size="lg" />
<Card>
<Card.Body>
<Text>当前无内容</Text>
</Card.Body>
</Card>
<WhiteSpace size="lg" />
</WingBlank>
);
// 下拉刷新
......
......@@ -5,7 +5,8 @@ import userInfoPageScreen from './userinfopage';
import fwInfo from './fwInfo';
import chatsIcon from '../../../image/chats-icon.png';
import Empty from '../empty';
import DSRInfoScreeen from './DSRInfoScreeen';
import DSRErJiScreen from './dangshireninfo/index';
import TabBarComponent from '../../components/tabBarComponent';
const Content = TabNavigator({
FWInfo: {
......@@ -23,7 +24,7 @@ const Content = TabNavigator({
},
},
DSRInfo: {
screen: DSRInfoScreeen,
screen: DSRErJiScreen,
navigationOptions: {
lazy: true,
tabBarLabel: '权利人信息',
......@@ -65,7 +66,9 @@ const Content = TabNavigator({
},
},
}, {
lazy: true,
tabBarPosition: 'bottom',
tabBarComponent: TabBarComponent,
animationEnabled: true,
tabBarOptions: {
activeTintColor: '#e91e63',
......
......@@ -6,10 +6,6 @@ export const getData = async (coordinate, { pst, psz, params = {}, filters = [],
const options = { pst, psz, params, filters, sortBys, sortTypes };
const api = datasourceApi(coordinate);
const meta = await api.meta();
console.info(meta);
console.info(meta.p)
console.info(3);
console.info(makeColumns(meta));
const dsb = await api.query(options);
return getArrayData(dsb, meta);
};
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论