Browse Source

客户报备审核

wushaodong 4 years ago
parent
commit
76e4639413
3 changed files with 96 additions and 6 deletions
  1. 20 0
      jscore/models/customer.js
  2. 63 6
      jscore/pages/Sales/ReportCustomerDetail.js
  3. 13 0
      jscore/services/customer.js

+ 20 - 0
jscore/models/customer.js

@@ -72,6 +72,26 @@ export default {
                 ResponseError(response);
             }
         },
+        * getUser({payload, callback}, {call, put}) {
+            const response = yield call(customer.getUser, payload);
+            if (!response.code) {
+                if (callback) {
+                    callback(response.data);
+                }
+            } else {
+                ResponseError(response);
+            }
+        },
+        * dispatchUser({payload, callback}, {call, put}) {
+            const response = yield call(customer.dispatchUser, payload);
+            if (!response.code) {
+                if (callback) {
+                    callback(response.data);
+                }
+            } else {
+                ResponseError(response);
+            }
+        },
     },
     subscriptions: {
         setup({dispatch}) {

+ 63 - 6
jscore/pages/Sales/ReportCustomerDetail.js

@@ -7,9 +7,10 @@ import {
 } from 'react-native';
 import {
     Provider,
+    Picker,
     Button,
     List,
-    Modal,
+    Modal, Toast,
 } from '@ant-design/react-native';
 import {connect} from 'react-redux';
 import CallPhone from '../../components/CallPhone';
@@ -20,8 +21,31 @@ class ReportCustomerDetail extends Component {
     //  报备客户详情
     constructor(props) {
         super(props);
+        this.state = {
+            dispatchVisible: false,
+            user: '',
+            USERS: [],
+        };
     };
 
+    componentDidMount() {
+        this._fetchData();
+    }
+
+    _fetchData = () => {
+        this.props.dispatch({
+            type: 'customer/getUser',
+            callback: (data) => {
+                let USERS = [];
+                data.map((item, index) => {
+                    USERS.push({
+                        value: item.value, label: item.lable,
+                    });
+                });
+                this.setState({USERS});
+            },
+        });
+    };
     onSignRepeat = (item) => {
         Modal.alert('提醒', '确定要标记为撞单客户吗?', [
             {
@@ -42,8 +66,28 @@ class ReportCustomerDetail extends Component {
         ]);
     };
 
+    dispatch = (item) => {
+        if (!this.state.user) {
+            Toast.info('请选择人员', 1);
+            return;
+        }
+
+        this.props.dispatch({
+            type: 'customer/dispatchUser',
+            payload: {id: item.id, user: this.state.user},
+            callback: () => {
+                DeviceEventEmitter.emit('backRefesh');
+                this.props.navigation.goBack();
+            },
+        });
+    };
+
     render() {
         const item = this.props.navigation.state.params.item;
+        const dispatchButtons = [
+            {text: '取消', onPress: () => this.setState({dispatchVisible: false})},
+            {text: '保存', onPress: () => this.dispatch(item)},
+        ];
         return (
             <View style={{flex: 1, backgroundColor: '#fff'}}>
                 <Provider>
@@ -115,11 +159,7 @@ class ReportCustomerDetail extends Component {
                     <View style={{flexDirection: 'row', justifyContent: 'center', backgroundColor: '#fff'}}>
                         <Button
                             type="primary"
-                            onPress={() => this.props.navigation.navigate('WriteTrackReport',
-                                {
-                                    customer_id: this.state.getParm.touch_id,
-                                    backKey: this.props.navigation.state.key,
-                                })}
+                            onPress={() => this.setState({dispatchVisible: true})}
                             style={{width: '45%', margin: 5}}
                         >
                             <Text
@@ -134,6 +174,23 @@ class ReportCustomerDetail extends Component {
 
                     </View>
                     }
+                    <Modal
+                        transparent
+                        maskClosable
+                        visible={this.state.dispatchVisible}
+                        footer={dispatchButtons}
+                    >
+                        <Picker
+                            data={this.state.USERS}
+                            cols={1}
+                            value={this.state.user}
+                            onChange={(val) => this.setState({user: val})}
+                        >
+                            <List.Item arrow="horizontal">
+                                选择人员
+                            </List.Item>
+                        </Picker>
+                    </Modal>
                 </Provider>
             </View>
         );

+ 13 - 0
jscore/services/customer.js

@@ -11,6 +11,19 @@ export async function queryReportDict() {
     return request(`/customer/dict/`);
 }
 
+export async function getUser() {
+    return request(`/customer/get_user/`);
+}
+
+export async function dispatchUser(params) {
+    let formdata = new FormData();
+    formdata.append('user', params.user[0]);
+    return request('/customer/report_customer/' + params.id + '/dispatch_customer/', {
+        method: 'POST',
+        body: formdata,
+    });
+}
+
 export async function signRepeat(params) {
     return request('/customer/report_customer/' + params.id + '/sign_hit/', {
         method: 'POST',