浏览代码

修改客户信息

wushaodong 4 年之前
父节点
当前提交
9d2062f78f

+ 19 - 0
jscore/models/customer.js

@@ -16,6 +16,7 @@ export default {
         reviewRecordRState: REFRESH_STATE.Ready,
         reviewRecordData: [],
         projectDict: [],
+        customerDetail: {},
     },
     reducers: {
         updateState(state, {payload}) {
@@ -144,6 +145,24 @@ export default {
                 ResponseError(response);
             }
         },
+        * editCustomerInfo({payload, callback}, {call, put}) {
+            const response = yield call(customer.editCustomerInfo, payload);
+            if (!response.code) {
+                if (callback) {
+                    callback();
+                }
+            } else {
+                ResponseError(response);
+            }
+        },
+        * fetchCustomerDetail({payload, callback}, {call, put}) {
+            const response = yield call(customer.queryCustomerDetail, payload);
+            if (response.id) {
+                yield put(createAction('queryList')({customerDetail: response}));
+            } else {
+                ResponseError(response);
+            }
+        },
     },
     subscriptions: {
         setup({dispatch}) {

+ 262 - 0
jscore/pages/Sales/EditCustomer.js

@@ -0,0 +1,262 @@
+import React, {Component} from 'react';
+import {
+    View,
+    Text, StyleSheet, ScrollView, StatusBar, DeviceEventEmitter, KeyboardAvoidingView, Platform,
+} from 'react-native';
+
+import {connect} from 'react-redux';
+import {
+    Provider,
+    Button,
+    Toast,
+    List,
+    Picker,
+    InputItem,
+} from '@ant-design/react-native';
+import RadioModal from '../../components/RadioModal';
+import ComponentsStyles from '../../components/ComponentsStyles';
+import CheckValid from '../../components/CheckValid';
+
+@connect(customer => ({...customer}))
+class EditCustomer extends Component {
+    // 报备客户
+    constructor(props) {
+        super(props);
+        this.state = {
+            id: '',
+            name: '',
+            tel: '',
+            gender: 2,
+            village: '',
+            address: '',
+            source: '',
+            project: [],
+            notes: '',
+
+            project_text: '请选择',
+            CUSTOMER_SOURCE: [],
+        };
+    }
+
+    componentDidMount() {
+        this._fetchData();
+    }
+
+    _fetchData = () => {
+        this.props.dispatch({
+            type: 'customer/fetchReportDict',
+            callback: (data) => {
+                let CUSTOMER_SOURCE = [];
+                data.source.map((item, index) => {
+                    CUSTOMER_SOURCE.push({
+                        value: item.id, label: item.name,
+                    });
+                });
+                const item = this.props.navigation.state.params.item;
+                this.setState({
+                    CUSTOMER_SOURCE,
+                    id: item.id,
+                    name: item.name,
+                    tel: item.tel,
+                    gender: (item.gender).toString(),
+                    village: (item.village).toString(),
+                    address: (item.address).toString(),
+                    source: [item.source],
+                    project: item.project,
+                    notes: item.notes,
+                    project_text: item.project_text,
+                });
+            },
+        });
+    };
+
+    onSave = () => {
+        if (!this.state.name) {
+            Toast.info('请填写姓名', 1);
+            return;
+        }
+        if (!this.state.tel) {
+            Toast.info('请填写手机号', 1);
+            return;
+        }
+        if (!CheckValid(this.state.tel, 'tel')) {
+            Toast.info('请填写正确的手机号', 1);
+            return;
+        }
+        if (!this.state.village) {
+            Toast.info('请填写小区', 1);
+            return;
+        }
+        if (!this.state.address) {
+            Toast.info('请填写地址', 1);
+            return;
+        }
+        if (!this.state.source.length) {
+            Toast.info('请选择来源', 1);
+            return;
+        }
+        if (!this.state.project.length) {
+            Toast.info('请选择项目', 1);
+            return;
+        }
+
+        this.props.dispatch({
+            type: 'customer/editCustomerInfo',
+            payload: this.state,
+            callback: () => {
+                DeviceEventEmitter.emit('backRefesh'); //刷新列表
+                DeviceEventEmitter.emit('refeshCustomerDetail'); // 刷新客户明细
+                this.props.navigation.goBack();
+            },
+        });
+    };
+    onProjectPress = () => {
+        this.props.navigation.navigate('SearchProject', {
+            callback: this.setProject,
+            checked_ids: this.state.project,
+            checked_names: this.state.project_text,
+        });
+    };
+    setProject = (ids, name) => {
+        this.setState({project_text: name, project: ids});
+    };
+
+    render() {
+        const {loading} = this.props.customer;
+        const isIOS = Platform.OS === 'ios' ? true : false;
+        return (
+            <KeyboardAvoidingView behavior={'padding'} enabled={isIOS} style={{backgroundColor: '#fff', flex: 1}}>
+                <StatusBar backgroundColor={'#fff'} barStyle='dark-content'/>
+                <Provider>
+                    <ScrollView keyboardShouldPersistTaps={'handled'}>
+                        <List style={styles.listStyle}>
+                            <InputItem
+                                clear
+                                value={this.state.name}
+                                onChange={value => {
+                                    this.setState({
+                                        name: value,
+                                    });
+                                }}
+                                placeholder="请输入客户姓名"
+                            >
+                                <Text style={ComponentsStyles.requiredText}>姓名</Text>
+                            </InputItem>
+
+                            <View style={ComponentsStyles.genderStyle}>
+                                <Text style={[ComponentsStyles.requiredText, {textAlignVertical: 'center'}]}>性别</Text>
+                                <RadioModal
+                                    selectedValue={this.state.gender.toString()}
+                                    onValueChange={id => this.setState({gender: id})}
+                                    style={ComponentsStyles.radioStyle}
+                                    innerStyle={{
+                                        width: 50,
+                                    }}
+                                >
+                                    <Text value="1">女</Text>
+                                    <Text value="2">男</Text>
+                                </RadioModal>
+                            </View>
+
+                            <InputItem
+                                clear
+                                type={'number'}
+                                value={this.state.tel}
+                                onChange={value => {
+                                    this.setState({
+                                        tel: value,
+                                    });
+                                }}
+                                placeholder="请输入电话"
+                            >
+                                <Text style={ComponentsStyles.requiredText}>电话</Text>
+                            </InputItem>
+
+                            <InputItem
+                                clear
+                                value={this.state.village}
+                                onChange={value => {
+                                    this.setState({
+                                        village: value,
+                                    });
+                                }}
+                                placeholder="请输入小区"
+                            >
+                                <Text style={ComponentsStyles.requiredText}>小区</Text>
+                            </InputItem>
+
+                            <InputItem
+                                clear
+                                value={this.state.address}
+                                onChange={value => {
+                                    this.setState({
+                                        address: value,
+                                    });
+                                }}
+                                placeholder="请输入地址"
+                            >
+                                <Text style={ComponentsStyles.requiredText}>地址</Text>
+                            </InputItem>
+
+                            <Picker
+                                data={this.state.CUSTOMER_SOURCE}
+                                cols={1}
+                                value={this.state.source}
+                                onChange={text => {
+                                    this.setState({
+                                        source: text,
+                                    });
+                                }}
+                            >
+                                <List.Item arrow="horizontal">
+                                    <Text style={ComponentsStyles.requiredText}>来源</Text>
+                                </List.Item>
+                            </Picker>
+                            <List.Item
+                                arrow="horizontal"
+                                extra={
+                                    <Text
+                                        style={{fontSize: 17, width: 200, textAlign: 'right'}}
+                                        onPress={() => this.onProjectPress()}>
+                                        {this.state.project_text}
+                                    </Text>}
+                            >
+                                <Text style={ComponentsStyles.requiredText}>项目</Text>
+                            </List.Item>
+
+                            <InputItem
+                                clear
+                                value={this.state.notes}
+                                onChange={value => {
+                                    this.setState({
+                                        notes: value,
+                                    });
+                                }}
+                                placeholder="请输入备注"
+                            >
+                                <Text style={ComponentsStyles.font15}>备注</Text>
+                            </InputItem>
+                        </List>
+                    </ScrollView>
+                    <Button
+                        onPress={this.onSave}
+                        type="primary"
+                        loading={loading}
+                        disabled={loading}
+                        style={ComponentsStyles.button}>保存</Button>
+                </Provider>
+            </KeyboardAvoidingView>
+        );
+    }
+}
+
+const styles = StyleSheet.create({
+    listStyle: {
+        marginTop: 5,
+    },
+    dateInput: {
+        borderWidth: 0,
+        alignItems: 'flex-end',
+    },
+});
+export default EditCustomer;

+ 7 - 0
jscore/pages/Sales/Index.js

@@ -10,6 +10,7 @@ import SearchProject from './SearchProject';
 import ReviewTodayList from './ReviewTodayList';
 import ReviewDetail from './ReviewDetail';
 import WriteTrackReport from './WriteTrackReport';
+import EditCustomer from './EditCustomer';
 
 const HomeStack = createStackNavigator({
         SalesHome: {
@@ -60,6 +61,12 @@ const HomeStack = createStackNavigator({
                 title: '填写跟踪报告',
             },
         },
+        EditCustomer: {
+            screen: EditCustomer,
+            navigationOptions: {
+                title: '修改客户信息',
+            },
+        },
     },
     {
         initialRouteName: 'SalesHome',

+ 57 - 10
jscore/pages/Sales/ReviewDetail.js

@@ -6,7 +6,7 @@ import {
     ScrollView,
     Dimensions, DeviceEventEmitter,
 } from 'react-native';
-import {Tabs, Provider, Button, List} from '@ant-design/react-native';
+import {Tabs, Provider, Button, Modal, List} from '@ant-design/react-native';
 import {createAction} from '../../utils';
 import {connect} from 'react-redux';
 import CallPhone from '../../components/CallPhone';
@@ -30,7 +30,6 @@ class ReviewDetail extends Component {
                 rows: 10,
                 customer: this.props.navigation.state.params.item.id,
             },
-            item: this.props.navigation.state.params.item,
             moreModelVisible: false,
         };
 
@@ -38,16 +37,26 @@ class ReviewDetail extends Component {
 
     componentDidMount() {
         this._fetchReviewReoprt();
-        this.refesh = DeviceEventEmitter.addListener('backRefesh', (param) => {
-            this.props.dispatch(createAction('auth/fetchTipsCount')());
+        this._fetchData();
+        this.refeshReport = DeviceEventEmitter.addListener('refeshReport', (param) => {
             this._fetchReviewReoprt(1);
         });
+        this.refeshCustomerDetail = DeviceEventEmitter.addListener('refeshCustomerDetail', (param) => {
+            this._fetchData(1);
+        });
     }
 
     componentWillUnmount() {
-        this.refesh.remove();
+        this.refeshReport.remove();
+        this.refeshCustomerDetail.remove();
     }
 
+    _fetchData = () => {
+        this.props.dispatch({
+            type: 'customer/fetchCustomerDetail',
+            payload:{id:this.state.getParm.customer},
+        });
+    };
     _fetchMore = () => {
         const {page, total} = this.props.customer;
         if (page * this.state.getParm.rows >= total) {
@@ -68,8 +77,7 @@ class ReviewDetail extends Component {
         this.props.dispatch(createAction('customer/fetchReviewRecord')(this.state.getParm));
     };
 
-    baseInfo = () => {
-        const reviewDetailData = this.state.item;
+    baseInfo = (reviewDetailData) => {
         return <View style={{marginTop: 5}}>
             <List style={styles.listStyle}>
                 <List.Item extra={<Text style={ComponentsStyles.font15}>{reviewDetailData.name}</Text>} arrow="empty">
@@ -189,7 +197,7 @@ class ReviewDetail extends Component {
     };
 
     render() {
-        const {reviewRecordData, reviewRecordRState} = this.props.customer;
+        const {reviewRecordData, reviewRecordRState, customerDetail} = this.props.customer;
 
         return (
             <Provider>
@@ -213,7 +221,7 @@ class ReviewDetail extends Component {
                 >
                     {/*基本信息*/}
                     <ScrollView>
-                        {this.baseInfo()}
+                        {this.baseInfo(customerDetail)}
                     </ScrollView>
                     {/*    跟踪记录*/}
                     <View>
@@ -237,7 +245,7 @@ class ReviewDetail extends Component {
                         type="primary"
                         onPress={() => this.props.navigation.navigate('WriteTrackReport',
                             {
-                                item: this.state.item,
+                                item: customerDetail,
                             })}
                         style={{width: 200, margin: 5}}
                     >
@@ -251,6 +259,45 @@ class ReviewDetail extends Component {
                         <Text
                             style={{color: '#fff'}}>更多</Text></Button>
                 </View>
+                <Modal
+                    popup
+                    closable
+                    maskClosable
+                    animationType="slide-up"
+                    visible={this.state.moreModelVisible}
+                    onClose={() => this.setState({moreModelVisible: false})}
+                >
+                    <View style={{padding: 10}}>
+                        <List>
+
+                            <List.Item>
+                                <Text style={styles.modalText}
+                                      onPress={() => this.setState({
+                                          dealVisible: true,
+                                          moreModelVisible: false,
+                                      })}>内部跟踪</Text>
+                            </List.Item>
+
+                            <List.Item>
+                                <Text
+                                    style={styles.modalText}
+                                    onPress={() => {
+                                        this.props.navigation.navigate('EditCustomer',
+                                            {
+                                                item: customerDetail,
+                                            });
+                                        this.setState({moreModelVisible: false});
+                                    }
+                                    }
+                                >修改信息</Text>
+                            </List.Item>
+
+                            <List.Item onPress={() => this.setState({moreModelVisible: false})}>
+                                <Text style={styles.modalText}>取消</Text>
+                            </List.Item>
+                        </List>
+                    </View>
+                </Modal>
             </Provider>
         );
     }

+ 9 - 1
jscore/pages/Sales/ReviewTodayList.js

@@ -1,7 +1,7 @@
 import React, {Component} from 'react';
 import {
     View,
-    TouchableOpacity, Text, StyleSheet,
+    TouchableOpacity, Text, StyleSheet, DeviceEventEmitter,
 } from 'react-native';
 
 import {createAction} from '../../utils';
@@ -24,6 +24,14 @@ class ReviewTodayList extends Component {
 
     componentDidMount() {
         this._fetchData();
+        this.refesh = DeviceEventEmitter.addListener('backRefesh', (param) => {
+            this.props.dispatch(createAction('auth/fetchTipsCount')());
+            this._fetchData(1);
+        });
+    }
+
+    componentWillUnmount() {
+        this.refesh.remove();
     }
 
     _fetchData = (page) => {

+ 1 - 1
jscore/pages/Sales/WriteInternalReport.js

@@ -53,7 +53,7 @@ class WriteTrackReport extends Component {
             payload: this.state,
             callback: () => {
                 // 返回,刷新潜客跟踪列表或潜客完善列表
-                DeviceEventEmitter.emit('backRefesh');
+                DeviceEventEmitter.emit('refeshReport');
                 this.props.navigation.goBack();
             },
         });

+ 20 - 0
jscore/services/customer.js

@@ -17,6 +17,10 @@ export async function queryReviewToday(params) {
     return request(`/customer/new_customer/?${stringify(params)}`);
 }
 
+export async function queryCustomerDetail(params) {
+    return request(`/customer/new_customer/` + params.id + `/`);
+}
+
 export async function queryReviewRecord(params) {
     return request(`/customer/get_review/?${stringify(params)}`);
 }
@@ -30,6 +34,22 @@ export async function dispatchUser(params) {
     });
 }
 
+export async function editCustomerInfo(params) {
+    let formdata = new FormData();
+    formdata.append('name', params.name);
+    formdata.append('gender', params.gender);
+    formdata.append('tel', params.tel);
+    formdata.append('village', params.village);
+    formdata.append('address', params.address);
+    formdata.append('source', params.source[0]);
+    formdata.append('project', JSON.stringify(params.project));
+    formdata.append('notes', params.notes);
+    return request('/customer/new_customer/' + params.id + '/', {
+        method: 'PUT',
+        body: formdata,
+    });
+}
+
 export async function addReview(params) {
     let formdata = new FormData();
     formdata.append('instruction', params.instruction);