瀏覽代碼

feat: 报时报修盲接暂存

touchitvoid 2 年之前
父節點
當前提交
a5f8042842
共有 7 個文件被更改,包括 425 次插入35 次删除
  1. 14 14
      src/router/config.tsx
  2. 28 0
      src/services/fix.ts
  3. 18 8
      src/views/Fix/online-form.tsx
  4. 142 7
      src/views/Fix/return-visit.tsx
  5. 209 4
      src/views/Fix/to-do.tsx
  6. 1 2
      src/views/User/account.tsx
  7. 13 0
      src/views/User/hooks.ts

+ 14 - 14
src/router/config.tsx

@@ -88,8 +88,8 @@ const UserList = lazy(() => import('../views/User/account'))
 // 报事报修相关
 const FixType = lazy(() => import('../views/Fix/type'))
 const FixOnlineForm = lazy(() => import('../views/Fix/online-form'))
-// const FixReturnVisit = lazy(() => import('../views/Fix/return-visit'))
-// const FixTodo = lazy(() => import('../views/Fix/to-do'))
+const FixReturnVisit = lazy(() => import('../views/Fix/return-visit'))
+const FixTodo = lazy(() => import('../views/Fix/to-do'))
 const FixOrderDetail = lazy(() => import('../views/Fix/order-detail'))
 
 // 投诉相关
@@ -405,18 +405,18 @@ export const routes: any = [
         component: Wrapper(FixOrderDetail),
         hideInMenu: true
       },
-      // {
-      //   title: '报修待办',
-      //   path: '/admin/fix/dealt',
-      //   exact: true,
-      //   component: Wrapper(FixTodo)
-      // },
-      // {
-      //   title: '报修回访',
-      //   path: '/admin/fix/return-visit',
-      //   exact: true,
-      //   component: Wrapper(FixReturnVisit)
-      // }
+      {
+        title: '报修待办',
+        path: '/admin/fix/dealt',
+        exact: true,
+        component: Wrapper(FixTodo)
+      },
+      {
+        title: '报修回访',
+        path: '/admin/fix/return-visit',
+        exact: true,
+        component: Wrapper(FixReturnVisit)
+      }
     ]
   },
   {

+ 28 - 0
src/services/fix.ts

@@ -15,6 +15,34 @@ export const GetFixOrderInfo = () => request({
   method: 'get'
 })
 
+// 派单
+export const FixOrderSend = data => request({
+  url: '/repair/order/send',
+  method: 'put',
+  data
+})
+
+// 退单 /api/v1/repair/order/back
+export const FixOrderRefund = data => request({
+  url: '/repair/order/back',
+  method: 'put',
+  data
+})
+
+// 结单 /api/v1/repair/order/finish
+export const FixOrderFinish = data => request({
+  url: '/repair/order/finish',
+  method: 'put',
+  data
+})
+
+// 结单 /api/v1/repair/order/return_visit
+export const FixOrderReturnVisit = data => request({
+  url: '/repair/order/return_visit',
+  method: 'put',
+  data
+})
+
 export const FixClassApi = params => {
   const config = {
     url: '/repair/class',

+ 18 - 8
src/views/Fix/online-form.tsx

@@ -3,11 +3,12 @@ import type { ActionType } from '@ant-design/pro-table'
 import ProTable from '@ant-design/pro-table'
 import { Button, Modal, Form, Input, message, Select, DatePicker, Upload } from 'antd'
 import { withRouter } from 'react-router-dom'
-import { FixApi } from '../../services/fix'
+import { FixApi, FixOrderSend } from '../../services/fix'
 import './index.scss'
 import { PlusOutlined } from "@ant-design/icons"
 import { useFixClass } from "./hooks"
 import { useBuildingHouse } from "../building/hooks"
+import { useUser } from "../User/hooks"
 
 const FixOnlineForm: React.FC = (props: any) => {
   const columns: any = [
@@ -114,10 +115,12 @@ const FixOnlineForm: React.FC = (props: any) => {
   const [pic, setPic]: any = React.useState([])
   const [fixClass, setFixClass] = useFixClass()
   const [buildHouse, setBuildHouse]: any = useBuildingHouse()
+  const [cUsers, setUsers]: any = useUser()
 
   React.useEffect(() => {
     setFixClass()
     setBuildHouse()
+    setUsers()
   }, [])
 
   const uploadButton = (
@@ -153,6 +156,16 @@ const FixOnlineForm: React.FC = (props: any) => {
     })
   }
 
+  const handleSendOrder = () => {
+    orderForm.validateFields().then(async values => {
+      await FixOrderSend({ ...values, id: state.editId })
+      message.success('操作成功!')
+      orderForm.resetFields()
+      actionRef.current?.reloadAndRest()
+      setState(prevState => ({ ...prevState, orderVisible: false, editId: null }))
+    })
+  }
+
   return (
     <React.Fragment>
       <ProTable
@@ -174,7 +187,7 @@ const FixOnlineForm: React.FC = (props: any) => {
       <Modal
         title='派单'
         visible={state.orderVisible}
-        onOk={onSubmit}
+        onOk={handleSendOrder}
         onCancel={() => setState(pre => ({ ...pre, orderVisible: false }))}
       >
         <Form
@@ -182,13 +195,10 @@ const FixOnlineForm: React.FC = (props: any) => {
           wrapperCol={{ span: 15 }}
           form={orderForm}
         >
-          <Form.Item label='部门' name="group_id" rules={[{ required: true }]}>
-            <Select placeholder='请选择' options={[]} />
-          </Form.Item>
-          <Form.Item label='报修师傅' name="group_id" rules={[{ required: true }]}>
-            <Select placeholder='请选择' options={[]} />
+          <Form.Item label='报修师傅' name="current_uid" rules={[{ required: true }]}>
+            <Select placeholder='请选择' options={cUsers} />
           </Form.Item>
-          <Form.Item label='处理意见' name="group_id" rules={[{ required: true }]}>
+          <Form.Item label='处理意见' name="feedback" rules={[{ required: true }]}>
             <Input.TextArea placeholder="多行输入" rows={4} />
           </Form.Item>
         </Form>

+ 142 - 7
src/views/Fix/return-visit.tsx

@@ -1,12 +1,147 @@
-import React from 'react'
-import { Card } from "antd";
+import React, { useRef } from 'react'
+import type { ActionType } from '@ant-design/pro-table'
+import ProTable from '@ant-design/pro-table'
+import { Button, Modal, Form, Input, message, Select } from 'antd'
+import { withRouter } from 'react-router-dom'
+import { FixOrderReturnVisit, FixApi } from '../../services/fix'
+import './index.scss'
+
+const FixReturnVisit: React.FC = (props: any) => {
+  const columns: any = [
+    {
+      title: 'ID',
+      dataIndex: 'id',
+      search: false
+    },
+    {
+      title: '分类名称',
+      dataIndex: 'class_name',
+      search: true,
+    },
+    {
+      title: '联系地址',
+      dataIndex: 'house_name',
+      search: false,
+    },
+    {
+      title: '报修人',
+      dataIndex: 'apply_people',
+      search: true,
+    },
+    {
+      title: '联系电话',
+      dataIndex: 'apply_people_phone',
+      search: true,
+    },
+    {
+      title: '预约时间',
+      dataIndex: 'appointment',
+      search: false,
+      valueType: 'dateTime',
+    },
+    {
+      title: '报修内容',
+      dataIndex: 'apply_content',
+      search: false,
+    },
+    {
+      title: '报修时间',
+      dataIndex: 'created_at',
+      search: false,
+      valueType: 'dateTime',
+    },
+    {
+      title: '状态',
+      dataIndex: 'status',
+      search: false,
+      valueEnum: {
+        1: { text: '未派单' },
+        2: { text: '已派单' },
+        3: { text: '已完结' },
+      }
+    },
+    {
+      title: '操作',
+      dataIndex: 'option',
+      search: false,
+      render: (_, row, index, action) => {
+        return [
+          <Button
+            className="mr-1.5"
+            onClick={() => {
+              orderForm.setFieldsValue(row)
+              setState(prevState => ({
+                ...prevState,
+                formMode: 'send',
+                orderVisible: true,
+                editId: row.id
+              }))
+            }}
+          >回访</Button>,
+          <Button
+            className="mr-1.5"
+            onClick={() => {
+              props.history.push('/admin/fix/order-detail')
+            }}
+          >详情</Button>,
+        ]
+      }
+    }
+  ]
+
+  const [state, setState] = React.useState({
+    orderVisible: false,
+    editId: null,
+    formMode: 'send'
+  })
+
+  const actionRef: any = useRef<ActionType>()
+  const [orderForm] = Form.useForm()
+
+  const onSubmit = () => {
+    orderForm.validateFields().then(async values => {
+      await FixOrderReturnVisit({ ...values, id: state.editId })
+      message.success('操作成功!')
+      orderForm.resetFields()
+      actionRef.current?.reloadAndRest()
+      setState(prevState => ({ ...prevState, orderVisible: false, editId: null }))
+    })
+  }
 
-const CustomerService: React.FC = () => {
   return (
-    <Card>
-      Im客服
-    </Card>
+    <React.Fragment>
+      <ProTable
+        headerTitle="报事报修/在线报修"
+        actionRef={actionRef}
+        rowKey="key"
+        request={FixApi}
+        params={{ status: 3 }}
+        columns={columns}
+      />
+      <Modal
+        title='报修回访'
+        visible={state.orderVisible}
+        onOk={onSubmit}
+        onCancel={() => setState(pre => ({ ...pre, orderVisible: false }))}
+      >
+        <Form
+          labelCol={{ span: 5 }}
+          wrapperCol={{ span: 15 }}
+          form={orderForm}
+        >
+          <Form.Item label='满意度' name="return_visit_level" rules={[{ required: true }]}>
+            <Select placeholder="请选择" options={[
+              { label: '满意', value: 1 },
+              { label: '不满意', value: 2 },
+            ]} />
+          </Form.Item>
+          <Form.Item label='业主评价' name="return_visit_content" rules={[{ required: true }]}>
+            <Input.TextArea placeholder="多行输入" rows={4} />
+          </Form.Item>
+        </Form>
+      </Modal>
+    </React.Fragment>
   )
 }
 
-export default CustomerService
+export default withRouter(FixReturnVisit)

+ 209 - 4
src/views/Fix/to-do.tsx

@@ -1,11 +1,216 @@
 import React from 'react'
+import type { ActionType } from '@ant-design/pro-table'
+import ProTable from '@ant-design/pro-table'
+import { Button, Modal, Form, Input, message, Select, Upload } from 'antd'
+import { withRouter } from 'react-router-dom'
+import { FixApi, FixOrderSend, FixOrderRefund, FixOrderFinish } from '../../services/fix'
+import './index.scss'
+import { PlusOutlined } from "@ant-design/icons"
+import { useUser } from "../User/hooks"
 
-const CustomerService: React.FC = () => {
-  return (
+const FixTodo: React.FC = (props: any) => {
+  const columns: any = [
+    {
+      title: 'ID',
+      dataIndex: 'id',
+      search: false
+    },
+    {
+      title: '分类名称',
+      dataIndex: 'class_name',
+      search: true,
+    },
+    {
+      title: '联系地址',
+      dataIndex: 'house_name',
+      search: false,
+    },
+    {
+      title: '报修人',
+      dataIndex: 'apply_people',
+      search: true,
+    },
+    {
+      title: '联系电话',
+      dataIndex: 'apply_people_phone',
+      search: true,
+    },
+    {
+      title: '预约时间',
+      dataIndex: 'appointment',
+      search: false,
+      valueType: 'dateTime',
+    },
+    {
+      title: '报修内容',
+      dataIndex: 'apply_content',
+      search: false,
+    },
+    {
+      title: '报修时间',
+      dataIndex: 'created_at',
+      search: false,
+      valueType: 'dateTime',
+    },
+    {
+      title: '状态',
+      dataIndex: 'status',
+      search: false,
+      valueEnum: {
+        1: { text: '未派单' },
+        2: { text: '已派单' },
+        3: { text: '已完结' },
+      }
+    },
+    {
+      title: '操作',
+      dataIndex: 'option',
+      search: false,
+      render: (_, row, index, action) => {
+        return [
+          <Button
+            className="mr-1.5"
+            onClick={() => {
+              orderForm.setFieldsValue(row)
+              setState(prevState => ({
+                ...prevState,
+                formMode: 'send',
+                orderVisible: true,
+                editId: row.id
+              }))
+            }}
+          >转单</Button>,
+          <Button
+            className="mr-1.5"
+            onClick={() => {
+              setState(prevState => ({
+                ...prevState,
+                formMode: 'return',
+                orderVisible: true
+              }))
+            }}
+          >退单</Button>,
+          <Button
+            className="mr-1.5"
+            onClick={() => {
+              props.history.push('/admin/fix/order-detail')
+            }}
+          >详情</Button>,
+          <Button onClick={() => {
+            setState(prevState => ({
+              ...prevState,
+              formMode: 'finish',
+              orderVisible: true
+            }))
+          }}>办结</Button>
+        ]
+      }
+    }
+  ]
+
+  const [pic, setPic]: any = React.useState([])
+  const [cUsers, setUsers]: any = useUser()
+
+  React.useEffect(() => {
+    setUsers()
+  }, [])
+
+  const uploadButton = (
     <div>
-      Im客服
+      <PlusOutlined />
+      <div style={{ marginTop: 8 }}>上传图片</div>
     </div>
   )
+  const [state, setState] = React.useState({
+    visible: false,
+    orderVisible: false,
+    editId: null,
+    formMode: 'send'
+  })
+
+  const FinishForm = <React.Fragment>
+    <Form.Item label='处理意见' name="feedback" rules={[{ required: true }]}>
+      <Input.TextArea placeholder="多行输入" rows={4} />
+    </Form.Item>
+    <Form.Item label='维修后照片' name="repair_pic" rules={[{ required: true }]}>
+      <Upload
+        action="http://localhost:3000/api/v1/upload"
+        listType="picture-card"
+        fileList={pic}
+        onChange={(({ fileList }) => setPic(fileList))}
+      >{ uploadButton }</Upload>
+    </Form.Item>
+  </React.Fragment>
+
+  // 报修退单
+  const ChargeBackForm = <React.Fragment>
+    {/*<Form.Item label='上级处理人' name="feedback" rules={[{ required: true }]}>*/}
+    {/*  <Input placeholder="单行输入"/>*/}
+    {/*</Form.Item>*/}
+    <Form.Item label='处理意见' name="feedback" rules={[{ required: true }]}>
+      <Input.TextArea placeholder="多行输入" rows={4} />
+    </Form.Item>
+  </React.Fragment>
+
+  const SendForm = <React.Fragment>
+    <Form.Item label='报修师傅' name="current_uid" rules={[{ required: true }]}>
+      <Select placeholder='请选择' options={cUsers} />
+    </Form.Item>
+    <Form.Item label='处理意见' name="feedback" rules={[{ required: true }]}>
+      <Input.TextArea placeholder="多行输入" rows={4} />
+    </Form.Item>
+  </React.Fragment>
+
+  const Forms = {
+    return: ChargeBackForm,
+    finish: FinishForm,
+    send: SendForm
+  }
+
+  const actionRef: any = React.useRef<ActionType>()
+  const [orderForm] = Form.useForm()
+
+  const onSubmit = () => {
+    const _Api = {
+      send: FixOrderSend,
+      refund: FixOrderRefund,
+      finish: FixOrderFinish
+    }
+    orderForm.validateFields().then(async values => {
+      await _Api[state.formMode]({ ...values, id: state.editId })
+      message.success('操作成功!')
+      orderForm.resetFields()
+      actionRef.current?.reloadAndRest()
+      setState(prevState => ({ ...prevState, orderVisible: false, editId: null }))
+    })
+  }
+
+  return (
+    <React.Fragment>
+      <ProTable
+        headerTitle="报事报修/在线报修"
+        actionRef={actionRef}
+        rowKey="key"
+        request={FixApi}
+        params={{ status: 2 }}
+        columns={columns}
+      />
+      <Modal
+        title='转单'
+        visible={state.orderVisible}
+        onOk={onSubmit}
+        onCancel={() => setState(pre => ({ ...pre, orderVisible: false }))}
+      >
+        <Form
+            labelCol={{ span: 5 }}
+            wrapperCol={{ span: 15 }}
+            form={orderForm}
+          >
+          { Forms[state.formMode] }
+          </Form>
+      </Modal>
+    </React.Fragment>
+  )
 }
 
-export default CustomerService
+export default withRouter(FixTodo)

+ 1 - 2
src/views/User/account.tsx

@@ -1,10 +1,9 @@
 import React from 'react'
 import type { ActionType } from '@ant-design/pro-table'
 import ProTable from '@ant-design/pro-table'
-import {Button, Modal, Form, Select, Input, InputNumber, message} from 'antd'
+import {Button, Modal, Form, Select, Input, message} from 'antd'
 import { withRouter } from 'react-router-dom'
 import { User } from '../../services/user'
-import { SELECTOR_CAR_TYPE, SELECTOR_CAR_BIND_TYPE } from '../../CONSTANT'
 import './index.scss'
 
 const Roles: React.FC = (props: any) => {

+ 13 - 0
src/views/User/hooks.ts

@@ -0,0 +1,13 @@
+import { useState } from "react"
+import { User } from '../../services/user'
+
+export const useUser = () => {
+  const [state, setState] = useState([])
+  const request = (params = { page: 1, pageSize: 9999 }) => {
+    User(params)
+      .then(({ data }) => {
+        setState(data?.map(({ user_name, id }) => ({ value: id, label: user_name })))
+      })
+  }
+  return [state, request] as const
+}