Ver código fonte

feat: 投诉建议暂存

touchitvoid 2 anos atrás
pai
commit
7acc8c57bd

+ 16 - 0
src/services/complaint.ts

@@ -0,0 +1,16 @@
+import request from './request'
+
+export const ComplaintApi = params => {
+  const config = {
+    url: '/suggestion/order',
+    method: params.method || 'get'
+  }
+  config[!['get', 'delete'].includes(config.method) ? 'data' : 'params'] = params
+  return request(config)
+}
+
+// 获取投诉详情 /api/v1/suggestion/order/info
+export const GetComplaintInfo = () => request({
+  url: '/suggestion/order/info',
+  method: 'get'
+})

+ 15 - 15
src/views/Complaint/index.tsx

@@ -1,13 +1,13 @@
 import React from 'react'
 import type { ActionType } from '@ant-design/pro-table'
 import ProTable from '@ant-design/pro-table'
-import {Button, Modal, Form, Radio, Input, message, Select, DatePicker, Upload} from 'antd'
+import {Button, Modal, Form, Input, message, Select, Upload} from 'antd'
 import { withRouter } from 'react-router-dom'
-import { User } from '../../services/user'
+import { ComplaintApi } from '../../services/complaint'
 import './index.scss'
 import {PlusOutlined} from "@ant-design/icons";
 
-const Complaint: React.FC = (props: any) => {
+const ComplaintPage: React.FC = (props: any) => {
   const columns: any = [
     {
       title: 'ID',
@@ -80,7 +80,7 @@ const Complaint: React.FC = (props: any) => {
               title: '删除记录',
               content: '你确定删除这条记录吗?',
               onOk: async () => {
-                await User({ method: 'delete', id: row.id })
+                await ComplaintApi({ method: 'delete', id: row.id })
                 message.success('操作成功!')
                 actionRef.current.reload()
               }
@@ -111,11 +111,11 @@ const Complaint: React.FC = (props: any) => {
 
   const onSubmit = () => {
     form.validateFields().then(async values => {
-      await User({
+      await ComplaintApi({
         method: 'post',
         ...values,
-        group_id: 11,
-        department_id: 0
+        garden_id: 1,
+        apply_pic: pic.map(({ response }) => response.data),
       })
       message.success('操作成功!')
       form.resetFields()
@@ -130,7 +130,7 @@ const Complaint: React.FC = (props: any) => {
         headerTitle="投诉建议/投诉录入"
         actionRef={actionRef}
         rowKey="key"
-        request={User}
+        request={ComplaintApi}
         toolBarRender={() => [
           <Button
             type="primary"
@@ -143,7 +143,7 @@ const Complaint: React.FC = (props: any) => {
         columns={columns}
       />
       <Modal
-        title='添加投诉建议'
+        title='添加投诉/建议'
         visible={state.visible}
         onOk={onSubmit}
         onCancel={() => setState(pre => ({ ...pre, visible: false }))}
@@ -153,22 +153,22 @@ const Complaint: React.FC = (props: any) => {
           wrapperCol={{ span: 15 }}
           form={form}
         >
-          <Form.Item label='投诉类型' name="group_id" rules={[{ required: true }]}>
+          <Form.Item label='投诉类型' name="suggestion_type" rules={[{ required: true }]}>
             <Select placeholder='请选择' options={[
               { label: '投诉', value: 1 },
               { label: '建议', value: 2 },
             ]} />
           </Form.Item>
-          <Form.Item label='投诉人' name="user_name" rules={[{ required: true }]}>
+          <Form.Item label='投诉人' name="apply_people" rules={[{ required: true }]}>
             <Input placeholder="请输入" />
           </Form.Item>
-          <Form.Item label='联系方式' name="user_name" rules={[{ required: true }]}>
+          <Form.Item label='联系方式' name="apply_people_phone" rules={[{ required: true }]}>
             <Input placeholder="请输入" />
           </Form.Item>
-          <Form.Item label='投诉内容' name="user_name" rules={[{ required: true }]}>
+          <Form.Item label='投诉内容' name="apply_content" rules={[{ required: true }]}>
             <Input.TextArea placeholder="多行输入" rows={4} />
           </Form.Item>
-          <Form.Item label='投诉图片' name="user_name" rules={[{ required: false }]}>
+          <Form.Item label='投诉图片' name="apply_pic" rules={[{ required: false }]}>
             <Upload
               action="http://localhost:3000/api/v1/upload"
               listType="picture-card"
@@ -184,4 +184,4 @@ const Complaint: React.FC = (props: any) => {
   )
 }
 
-export default withRouter(Complaint)
+export default withRouter(ComplaintPage)

+ 5 - 0
src/views/Complaint/order-detail.tsx

@@ -1,6 +1,7 @@
 import React from 'react'
 import { Button, Card, Divider, Form, Table, Col, Row, Image } from "antd"
 import { useHistory } from "react-router"
+import { GetComplaintInfo } from "../../services/complaint"
 
 const columns = [
   {
@@ -39,6 +40,10 @@ const OrderDetail: React.FC = () => {
 
   const history = useHistory()
 
+  React.useEffect(() => {
+    GetComplaintInfo()
+  }, [])
+
   return (
     <React.Fragment>
       <div className="flex justify-between items-center pb-3" style={{ fontSize: '18px' }}>