Yansen 2 years ago
parent
commit
731dc292aa

+ 40
- 0
src/pages/message/detail.jsx View File

@@ -0,0 +1,40 @@
1
+import React from 'react';
2
+import { Button, Card, Typography } from 'antd';
3
+import { useSearchParams, Link } from 'react-router-dom';
4
+import { getMessage } from '@/services/message';
5
+import useBool from '@/utils/hooks/useBool';
6
+
7
+export default (props) => {
8
+  const [searchParams] = useSearchParams();
9
+  const [loading, startLoading, cancelLoading] = useBool(false);
10
+
11
+  const [detail, setDetail] = React.useState({});
12
+  const id = searchParams.get('id');
13
+
14
+  React.useEffect(() => {
15
+    if (id) {
16
+      startLoading()
17
+      getMessage(id).then((res) => {
18
+        setDetail(res);
19
+        cancelLoading();
20
+      }).catch(() => {
21
+        cancelLoading();
22
+      });
23
+    }
24
+  }, [id]);
25
+
26
+  return (
27
+    <Card
28
+      loading={loading}
29
+      title={detail.createDate}
30
+      actions={[
31
+        <Button key={1} type="link" disabled={detail.isReaded}>设为已读</Button>,
32
+        <Link>去处理</Link>
33
+      ]}
34
+    >
35
+      <Typography.Paragraph>
36
+        {detail.message}
37
+      </Typography.Paragraph>
38
+    </Card>
39
+  )
40
+}

+ 25
- 20
src/pages/message/index.jsx View File

@@ -1,5 +1,5 @@
1 1
 import React from 'react';
2
-import { useNavigate } from 'react-router-dom';
2
+import { useNavigate, Link } from 'react-router-dom';
3 3
 import { queryTable } from '@/utils/request';
4 4
 import { ProTable } from '@ant-design/pro-components';
5 5
 import { Button, message, Popconfirm } from 'antd';
@@ -9,16 +9,12 @@ const queryMessage = queryTable(getMessageList);
9 9
 
10 10
 export default (props) => {
11 11
   const columns = [
12
-    {
13
-      title: 'id',
14
-      dataIndex: 'id',
15
-      search: false,
16
-    },
17 12
     {
18 13
       title: '时间',
19 14
       dataIndex: 'createDate',
20 15
       valueType: 'date',
21 16
       search: false,
17
+      width: 160,
22 18
     },
23 19
     {
24 20
       title: '时间',
@@ -42,12 +38,13 @@ export default (props) => {
42 38
       title: '状态',
43 39
       dataIndex: 'isReaded',
44 40
       search: false,
41
+      width: 120,
45 42
       valueEnum: {
46
-        1: {
43
+        true: {
47 44
           text: '已读',
48 45
           status: 'Processing',
49 46
         },
50
-        0: {
47
+        false: {
51 48
           text: '未读',
52 49
           status: 'Error',
53 50
         },
@@ -57,18 +54,26 @@ export default (props) => {
57 54
       title: '操作',
58 55
       valueType: 'option',
59 56
       width: 200,
60
-      render: (_, record) => [
61
-        <Button
62
-          key={2}
63
-          style={{ padding: 0 }}
64
-          type="link"
65
-          onClick={() => {
66
-            navigate(`/system/message/detail?id=${record.id}`);
67
-          }}
68
-        >
69
-          详情
70
-        </Button>,
71
-      ],
57
+      render: (_, record) => {
58
+        const doUrl = record.targetType === 'store' ?
59
+        `/stock/list?id=${record.targetId}` : undefined;
60
+
61
+        return [
62
+          <Button
63
+            key={1}
64
+            type="link"
65
+            disabled={record.isReaded}
66
+          >
67
+            设为已读
68
+          </Button>,
69
+          <Link
70
+            key={2}
71
+            to={doUrl}
72
+          >
73
+            去处理
74
+          </Link>,
75
+        ]
76
+      },
72 77
     },
73 78
   ]
74 79
 

+ 8
- 19
src/pages/stock/list/index.jsx View File

@@ -1,29 +1,21 @@
1 1
 import { deleteStore, getStoreList, getStoreTypeList, storeExport } from '@/services/stock';
2 2
 import { queryDict, queryTable } from '@/utils/request';
3 3
 import { PageContainer, ProTable } from '@ant-design/pro-components';
4
-import { useNavigate } from 'react-router-dom';
4
+import { useNavigate, useSearchParams } from 'react-router-dom';
5 5
 import { Button, message, Modal, Popconfirm } from 'antd';
6 6
 import { useRef, useState } from 'react';
7 7
 import OutAndIn from '../outAndIn';
8
+import './style.less';
8 9
 
9 10
 const StockList = (props) => {
10 11
   const [isOpen, setIsOpen] = useState(false);
11 12
   const [modalData, setModalData] = useState({});
12
-  // const [storeTypeDict, setStoreTypeDict] = useState([]);
13 13
   const actionRef = useRef();
14 14
   const formRef = useRef();
15 15
   const navigate = useNavigate();
16
-  
17
-  // useEffect(() => {
18
-  //   getStoreTypeList({ pageSize: 9999, pageNum: 1 }).then((res) => {
19
-  //     setStoreTypeDict(
20
-  //       res?.records?.map((x) => ({
21
-  //         label: x.name,
22
-  //         value: x.id,
23
-  //       })) || [],
24
-  //     );
25
-  //   });
26
-  // }, []);
16
+  const [searchParams] = useSearchParams();
17
+
18
+  const id = searchParams.get('id');
27 19
 
28 20
   const handleDelete = (id) => {
29 21
     if (id) {
@@ -44,14 +36,10 @@ const StockList = (props) => {
44 36
   };
45 37
 
46 38
   const columns = [
47
-    // {
48
-    //   title: 'id',
49
-    //   dataIndex: 'id',
50
-    //   search: false,
51
-    // },
52 39
     {
53 40
       title: '名称',
54 41
       dataIndex: 'name',
42
+      render: (t, row) => row.warnAmount >= row.amount ? `${t} (库存不足)` : t
55 43
     },
56 44
     {
57 45
       title: '单位',
@@ -70,7 +58,6 @@ const StockList = (props) => {
70 58
       dataIndex: 'amount',
71 59
       search: false,
72 60
     },
73
-
74 61
     {
75 62
       title: '操作',
76 63
       valueType: 'option',
@@ -120,7 +107,9 @@ const StockList = (props) => {
120 107
       <ProTable
121 108
         actionRef={actionRef}
122 109
         formRef={formRef}
110
+        params={{ id }}
123 111
         rowKey="id"
112
+        rowClassName={(row) => row.warnAmount >= row.amount ? 'store-danger' : ''}
124 113
         toolBarRender={() => [
125 114
           <Button
126 115
             key="2"

+ 4
- 0
src/pages/stock/list/style.less View File

@@ -0,0 +1,4 @@
1
+
2
+.store-danger {
3
+  color: #ff4d4f;
4
+}

+ 9
- 0
src/routes/routes.jsx View File

@@ -43,6 +43,7 @@ import EmergencyPlanEdit from "@/pages/cms/emergencyPlan/edit";
43 43
 import EmergencyPlanDetail from "@/pages/cms/emergencyPlan/detail";
44 44
 import FilesList from "@/pages/cms/files/list";
45 45
 import MessageList from '@/pages/message';
46
+import MessageDetail from '@/pages/message/detail';
46 47
 
47 48
 /**
48 49
  * meta 用来扩展自定义数据数据
@@ -305,6 +306,14 @@ export const authRoutes = [
305 306
         meta: {
306 307
           title: '消息列表',
307 308
         },
309
+      },
310
+      {
311
+        path: 'message/detail',
312
+        element: <MessageDetail />,
313
+        meta: {
314
+          title: '消息详情',
315
+          hideInMenu: true,
316
+        },
308 317
       }
309 318
     ],
310 319
   },

+ 2
- 0
src/services/message.js View File

@@ -2,8 +2,10 @@ import { restful } from '@/utils/request';
2 2
 
3 3
 const [
4 4
   getMessageList,
5
+  getMessage,
5 6
 ] = restful("/noticeMessage");
6 7
 
7 8
 export {
8 9
   getMessageList,
10
+  getMessage,
9 11
 }