李志伟 3 年前
父节点
当前提交
e402bba65c
共有 4 个文件被更改,包括 123 次插入47 次删除
  1. 51
    26
      src/pages/JobStatistics/Order/index.jsx
  2. 51
    21
      src/pages/OrderManage/dispatch.jsx
  3. 14
    0
      src/services/dispatch.js
  4. 7
    0
      src/services/eval.js

+ 51
- 26
src/pages/JobStatistics/Order/index.jsx 查看文件

@@ -1,18 +1,26 @@
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 3
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
6 4
 import moment from 'moment';
7 5
 import PageTable from '@/components/PageTable';
6
+import { getOrderList } from '@/services/order';
7
+import { getevaluation } from '@/services/eval'
8 8
 
9 9
 const formatterTime = (val) => {
10 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 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 24
   const columns = [
17 25
     {
18 26
       title: '机构名',
@@ -56,30 +64,30 @@ export default (props) => {
56 64
       width: 200,
57 65
     },
58 66
     {
59
-      title: '调度状态',
60
-      dataIndex: 'dispatchStatus',
61
-      key: 'dispatchStatus',
67
+      title: '评价状态',
68
+      dataIndex: 'isEvaluated',
69
+      key: 'isEvaluated',
62 70
       valueType: 'select',
63 71
       valueEnum: {
64 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,6 +103,23 @@ export default (props) => {
95 103
         options={false}
96 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 123
     </PageHeaderWrapper>
99 124
   );
100 125
 };

+ 51
- 21
src/pages/OrderManage/dispatch.jsx 查看文件

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

+ 14
- 0
src/services/dispatch.js 查看文件

@@ -5,3 +5,17 @@ import request from '@/utils/request';
5 5
  * @returns
6 6
  */
7 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 查看文件

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