李志伟 3 years ago
parent
commit
e402bba65c

+ 51
- 26
src/pages/JobStatistics/Order/index.jsx View File

1
-import React from 'react';
2
-import { history } from 'umi';
3
-import { Button } from 'antd';
4
-import { getOrderList } from '@/services/order';
1
+import React, { useState } from 'react';
2
+import { Button, Modal, Form } from 'antd';
5
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
3
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
 import moment from 'moment';
4
 import moment from 'moment';
7
 import PageTable from '@/components/PageTable';
5
 import PageTable from '@/components/PageTable';
6
+import { getOrderList } from '@/services/order';
7
+import { getevaluation } from '@/services/eval'
8
 
8
 
9
 const formatterTime = (val) => {
9
 const formatterTime = (val) => {
10
   return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '';
10
   return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '';
11
 };
11
 };
12
-const getDispatch = (val) => {
13
-  history.push(`./dispatch.jsx?id=${val}`);
14
-}
12
+const FormItem = Form.Item;
13
+const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
14
+
15
 export default (props) => {
15
 export default (props) => {
16
+  const [show, setShow] = useState(false)
17
+  const [evaluation, setEval] = useState()
18
+  const getEvaluated = (val) => {
19
+    getevaluation(val).then(res => {
20
+      setEval(res)
21
+      setShow(true)
22
+    })
23
+  }
16
   const columns = [
24
   const columns = [
17
     {
25
     {
18
       title: '机构名',
26
       title: '机构名',
56
       width: 200,
64
       width: 200,
57
     },
65
     },
58
     {
66
     {
59
-      title: '调度状态',
60
-      dataIndex: 'dispatchStatus',
61
-      key: 'dispatchStatus',
67
+      title: '评价状态',
68
+      dataIndex: 'isEvaluated',
69
+      key: 'isEvaluated',
62
       valueType: 'select',
70
       valueType: 'select',
63
       valueEnum: {
71
       valueEnum: {
64
         '': { text: '不限', status: 'Default' },
72
         '': { text: '不限', status: 'Default' },
65
-        0: { text: '待调度' },
66
-        1: { text: '已调度' }
73
+        0: { text: '待评价' },
74
+        1: { text: '已评价' }
67
       },
75
       },
68
     },
76
     },
69
-    // {
70
-    //   title: '操作',
71
-    //   valueType: 'option',
72
-    //   render: (_, record) => [
73
-    //     <Button
74
-    //       style={{ padding: 0 }}
75
-    //       type="link"
76
-    //       key={2}
77
-    //       onClick={() => getDispatch(record.orderId)}
78
-    //     >
79
-    //       调度
80
-    //     </Button>
81
-    //   ],
82
-    // },
77
+    {
78
+      title: '操作',
79
+      valueType: 'option',
80
+      render: (_, record) => record.isEvaluated ? [
81
+        <Button
82
+          style={{ padding: 0 }}
83
+          type="link"
84
+          key={1}
85
+          onClick={() => getEvaluated(record.orderId)}
86
+        >
87
+          查看评价
88
+        </Button>
89
+      ] : '',
90
+    },
83
     //操作如果是需求多台机器则需调度 状态为待确认时 状态栏显示调度按钮跳到调度页面
91
     //操作如果是需求多台机器则需调度 状态为待确认时 状态栏显示调度按钮跳到调度页面
84
     // 如果是申请退款 则出现处理按钮 显示需求时间 如果未到则退款并且改变已分配农机手状态和农机状态
92
     // 如果是申请退款 则出现处理按钮 显示需求时间 如果未到则退款并且改变已分配农机手状态和农机状态
85
     // 如果已经服务过了 则可以打电话给农户咨询具体情况看是否退部分款项
93
     // 如果已经服务过了 则可以打电话给农户咨询具体情况看是否退部分款项
95
         options={false}
103
         options={false}
96
         scroll={{ x: 1000 }}
104
         scroll={{ x: 1000 }}
97
       />
105
       />
106
+      <Modal
107
+        forceRender
108
+        title='评价'
109
+        visible={show}
110
+        onCancel={() => setShow(false)}
111
+        keyboard={false}
112
+        maskClosable={false}
113
+        destroyOnClose={true}
114
+        footer={null}
115
+      >
116
+        <Form {...formItemLayout}>
117
+          <FormItem label="下单人" >{evaluation?.personName}</FormItem>
118
+          <FormItem label="评分" >{evaluation?.score}</FormItem>
119
+          <FormItem label="评价内容" >{evaluation?.content}</FormItem>
120
+        </Form>
121
+      </Modal>
122
+
98
     </PageHeaderWrapper>
123
     </PageHeaderWrapper>
99
   );
124
   );
100
 };
125
 };

+ 51
- 21
src/pages/OrderManage/dispatch.jsx View File

5
 import { getMachineryList } from '@/services/machinery';
5
 import { getMachineryList } from '@/services/machinery';
6
 import { history } from 'umi';
6
 import { history } from 'umi';
7
 import { getUserList } from '@/services/user';
7
 import { getUserList } from '@/services/user';
8
-import { addDispatch } from '@/services/dispatch';
8
+import { addDispatch, getdispatchId, cancelDispatch } from '@/services/dispatch';
9
 
9
 
10
 const FormItem = Form.Item;
10
 const FormItem = Form.Item;
11
 const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
11
 const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
16
 export default (props) => {
16
 export default (props) => {
17
   const { location } = props;
17
   const { location } = props;
18
   const { id } = location.query;
18
   const { id } = location.query;
19
-  const [order, setOrder] = useState();
19
+  const [dispatch, setDispatch] = useState();
20
   const [loading, setLoading] = useState(false);
20
   const [loading, setLoading] = useState(false);
21
+  const [dispatchId, setDispatchId] = useState()
21
   const [machineryList, setMachineryList] = useState([]);
22
   const [machineryList, setMachineryList] = useState([]);
22
   const [userList, setUserList] = useState([])
23
   const [userList, setUserList] = useState([])
24
+
25
+  const [cancelLoading, setCancelLoading] = useState(false);
26
+
23
   const submit = () => {
27
   const submit = () => {
24
-    if (!order.machineryId) {
28
+    if (!dispatch.machineryId) {
25
       message.warning('请选择调度的农机');
29
       message.warning('请选择调度的农机');
26
       return
30
       return
27
     }
31
     }
28
-    if (!order.workerId) {
32
+    if (!dispatch.workerId) {
29
       message.warning('请选择农机手');
33
       message.warning('请选择农机手');
30
       return
34
       return
31
     }
35
     }
32
     setLoading(true)
36
     setLoading(true)
33
-    addDispatch(order).then(res => {
37
+    addDispatch(dispatch).then(res => {
34
       message.success('调度成功');
38
       message.success('调度成功');
35
       setLoading(false);
39
       setLoading(false);
36
       goBack()
40
       goBack()
40
     });
44
     });
41
   };
45
   };
42
   const changeMachinery = (e) => {
46
   const changeMachinery = (e) => {
43
-    setOrder({ ...order, machineryId: e })
47
+    setDispatch({ ...dispatch, machineryId: e })
44
   }
48
   }
45
   const changeUser = (e) => {
49
   const changeUser = (e) => {
46
-    setOrder({ ...order, workerId: e })
50
+    setDispatch({ ...dispatch, workerId: e })
51
+  }
52
+  const onCancel = () => {
53
+    setCancelLoading(true)
54
+    cancelDispatch(dispatchId).then(() => {
55
+      setCancelLoading(false)
56
+      setDispatchId()
57
+      setDispatch({ ...dispatch, machineryId: null, workerId: null })
58
+      message.success('取消成功');
59
+    }).catch((err) => {
60
+      setCancelLoading(false);
61
+      message.error(err.message || err);
62
+    });
47
   }
63
   }
48
   useEffect(() => {
64
   useEffect(() => {
49
     getOrderDetail(id).then((res) => {
65
     getOrderDetail(id).then((res) => {
50
-      setOrder(res)
51
-      getMachineryList({ orgId: res.orgId, pageSize: 999 }).then((res2) => {
66
+      res.machineryId = null
67
+      res.typeId = res.machineryType
68
+      setDispatch(res)
69
+      getMachineryList({ orgId: res.orgId, typeId: res.typeId, pageSize: 999 }).then((res2) => {
52
         setMachineryList(res2.records)
70
         setMachineryList(res2.records)
53
       })
71
       })
54
       getUserList({ org_id: res.orgId, pageSize: 999 }).then(res3 => {
72
       getUserList({ org_id: res.orgId, pageSize: 999 }).then(res3 => {
55
         setUserList(res3.records)
73
         setUserList(res3.records)
56
       })
74
       })
75
+      if (res.dispatchStatus == 1) {
76
+        getdispatchId(id).then(res4 => {
77
+          setDispatchId(res4.dispatchId)
78
+          setDispatch({ ...res, machineryId: res4.machineryId, workerId: res4.workerId })
79
+        })
80
+      }
57
     })
81
     })
58
-  }, [])
82
+  }, [id])
59
   return (
83
   return (
60
     <Card>
84
     <Card>
61
       <ProCard tabs={{ type: 'card' }}>
85
       <ProCard tabs={{ type: 'card' }}>
62
         <ProCard.TabPane key={1} tab="订单调度">
86
         <ProCard.TabPane key={1} tab="订单调度">
63
           <Form {...formItemLayout}>
87
           <Form {...formItemLayout}>
64
             <FormItem label="客户姓名">
88
             <FormItem label="客户姓名">
65
-              {order?.personName}
89
+              {dispatch?.personName}
66
             </FormItem>
90
             </FormItem>
67
             <FormItem label="联系电话">
91
             <FormItem label="联系电话">
68
-              {order?.phone}
92
+              {dispatch?.phone}
69
             </FormItem>
93
             </FormItem>
70
             <FormItem label="预约地址">
94
             <FormItem label="预约地址">
71
-              {order?.address}
95
+              {dispatch?.address}
72
             </FormItem>
96
             </FormItem>
73
             <FormItem label="预约时间">
97
             <FormItem label="预约时间">
74
-              {order?.appointmentDate}
98
+              {dispatch?.appointmentDate}
75
             </FormItem>
99
             </FormItem>
76
             <FormItem label="机构名">
100
             <FormItem label="机构名">
77
-              {order?.orgName}
101
+              {dispatch?.orgName}
78
             </FormItem>
102
             </FormItem>
79
             <FormItem label="农机类型">
103
             <FormItem label="农机类型">
80
-              {order?.typeName}
104
+              {dispatch?.typeName}
81
             </FormItem>
105
             </FormItem>
82
             <FormItem label="农机">
106
             <FormItem label="农机">
83
-              <Select placeholder="请选择" value={order?.machineryId} onChange={changeMachinery} allowClear style={{ width: '350px' }}>
107
+              <Select placeholder="请选择" value={dispatch?.machineryId} onChange={changeMachinery} allowClear style={{ width: '350px' }}>
84
                 {machineryList.map((item) => (
108
                 {machineryList.map((item) => (
85
                   <Option value={item.machineryId} key={item.machineryId}>
109
                   <Option value={item.machineryId} key={item.machineryId}>
86
                     {item.name}
110
                     {item.name}
89
               </Select>
113
               </Select>
90
             </FormItem>
114
             </FormItem>
91
             <FormItem label="农机手">
115
             <FormItem label="农机手">
92
-              <Select placeholder="请选择" value={order?.workerId} onChange={changeUser} allowClear style={{ width: '350px' }}>
116
+              <Select placeholder="请选择" value={dispatch?.workerId} onChange={changeUser} allowClear style={{ width: '350px' }}>
93
                 {userList.map((item) => (
117
                 {userList.map((item) => (
94
                   <Option value={item.userId} key={item.userId}>
118
                   <Option value={item.userId} key={item.userId}>
95
                     {item.userName}
119
                     {item.userName}
101
               <Button type="default" onClick={() => goBack()}>
125
               <Button type="default" onClick={() => goBack()}>
102
                 返回
126
                 返回
103
               </Button>
127
               </Button>
104
-              <Button type="primary" loading={loading} onClick={submit} style={{ marginLeft: '4em' }}>
105
-                保存
106
-              </Button>
128
+              {
129
+                dispatchId ?
130
+                  <Button loading={cancelLoading} onClick={onCancel} style={{ marginLeft: '4em' }}>
131
+                    取消
132
+                  </Button> :
133
+                  <Button type="primary" loading={loading} onClick={submit} style={{ marginLeft: '4em' }}>
134
+                    保存
135
+                  </Button>
136
+              }
107
             </FormItem>
137
             </FormItem>
108
           </Form>
138
           </Form>
109
         </ProCard.TabPane>
139
         </ProCard.TabPane>

+ 14
- 0
src/services/dispatch.js View File

5
  * @returns
5
  * @returns
6
  */
6
  */
7
 export const addDispatch = (data) => request('/dispatch', { method: 'post', data });
7
 export const addDispatch = (data) => request('/dispatch', { method: 'post', data });
8
+
9
+/**
10
+ * 查询调度Id详情
11
+ * @param {*} params
12
+ * @returns
13
+ */
14
+export const getdispatchId = (id) => request(`/order/${id}/dispatch`);
15
+
16
+/**
17
+ * 取消调度
18
+ * @param {*} data
19
+ * @returns
20
+ */
21
+export const cancelDispatch = (id) => request(`/dispatch/${id}`, { method: 'delete' });

+ 7
- 0
src/services/eval.js View File

1
+import request from '@/utils/request';
2
+/**
3
+ * 查询评价详情
4
+ * @param {*} params
5
+ * @returns
6
+ */
7
+export const getevaluation = (id) => request(`/order/${id}/evaluation`);