Yansen 2 gadus atpakaļ
vecāks
revīzija
731dc292aa

+ 40
- 0
src/pages/message/detail.jsx Parādīt failu

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 Parādīt failu

1
 import React from 'react';
1
 import React from 'react';
2
-import { useNavigate } from 'react-router-dom';
2
+import { useNavigate, Link } from 'react-router-dom';
3
 import { queryTable } from '@/utils/request';
3
 import { queryTable } from '@/utils/request';
4
 import { ProTable } from '@ant-design/pro-components';
4
 import { ProTable } from '@ant-design/pro-components';
5
 import { Button, message, Popconfirm } from 'antd';
5
 import { Button, message, Popconfirm } from 'antd';
9
 
9
 
10
 export default (props) => {
10
 export default (props) => {
11
   const columns = [
11
   const columns = [
12
-    {
13
-      title: 'id',
14
-      dataIndex: 'id',
15
-      search: false,
16
-    },
17
     {
12
     {
18
       title: '时间',
13
       title: '时间',
19
       dataIndex: 'createDate',
14
       dataIndex: 'createDate',
20
       valueType: 'date',
15
       valueType: 'date',
21
       search: false,
16
       search: false,
17
+      width: 160,
22
     },
18
     },
23
     {
19
     {
24
       title: '时间',
20
       title: '时间',
42
       title: '状态',
38
       title: '状态',
43
       dataIndex: 'isReaded',
39
       dataIndex: 'isReaded',
44
       search: false,
40
       search: false,
41
+      width: 120,
45
       valueEnum: {
42
       valueEnum: {
46
-        1: {
43
+        true: {
47
           text: '已读',
44
           text: '已读',
48
           status: 'Processing',
45
           status: 'Processing',
49
         },
46
         },
50
-        0: {
47
+        false: {
51
           text: '未读',
48
           text: '未读',
52
           status: 'Error',
49
           status: 'Error',
53
         },
50
         },
57
       title: '操作',
54
       title: '操作',
58
       valueType: 'option',
55
       valueType: 'option',
59
       width: 200,
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 Parādīt failu

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

+ 4
- 0
src/pages/stock/list/style.less Parādīt failu

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

+ 9
- 0
src/routes/routes.jsx Parādīt failu

43
 import EmergencyPlanDetail from "@/pages/cms/emergencyPlan/detail";
43
 import EmergencyPlanDetail from "@/pages/cms/emergencyPlan/detail";
44
 import FilesList from "@/pages/cms/files/list";
44
 import FilesList from "@/pages/cms/files/list";
45
 import MessageList from '@/pages/message';
45
 import MessageList from '@/pages/message';
46
+import MessageDetail from '@/pages/message/detail';
46
 
47
 
47
 /**
48
 /**
48
  * meta 用来扩展自定义数据数据
49
  * meta 用来扩展自定义数据数据
305
         meta: {
306
         meta: {
306
           title: '消息列表',
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 Parādīt failu

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