lisenzhou 2 anos atrás
pai
commit
48fdaca909

+ 38
- 0
src/pages/cms/emergencyPlan/detail/index.jsx Ver arquivo

@@ -0,0 +1,38 @@
1
+import { savePosts, getPostsDetail, updatePosts } from "@/services/posts";
2
+import { getStoreList } from "@/services/stock";
3
+import {
4
+  PageContainer,
5
+  ProForm,
6
+  ProFormSelect,
7
+  ProFormText,
8
+} from "@ant-design/pro-components";
9
+import { useNavigate, useSearchParams } from "react-router-dom";
10
+import { Card, Typography, message, Row, Button, Space } from "antd";
11
+import { useEffect, useRef, useState } from "react";
12
+import Wangeditor from "@/components/Wangeditor";
13
+const { Title } = Typography;
14
+export default (props) => {
15
+  const [searchParams] = useSearchParams();
16
+  const id = searchParams.get("id");
17
+  const [data, setData] = useState({});
18
+  const navigate = useNavigate();
19
+
20
+  const formRef = useRef();
21
+
22
+  useEffect(() => {
23
+    if (id) {
24
+      getPostsDetail(id).then((res) => {
25
+        setData(res);
26
+      });
27
+    }
28
+  }, [id]);
29
+
30
+  return (
31
+    <Card extra={<Button onClick={()=>navigate(-1)}> 返回</Button>}>
32
+      <Title level={2} style={{ marginBottom: "2em" }}>
33
+        {data.title}
34
+      </Title>
35
+      <div dangerouslySetInnerHTML={{ __html: data?.detail }}></div>
36
+    </Card>
37
+  );
38
+};

+ 30
- 1
src/pages/cms/emergencyPlan/edit/index.jsx Ver arquivo

@@ -9,6 +9,7 @@ import {
9 9
 import { useNavigate, useSearchParams } from "react-router-dom";
10 10
 import { Card, Col, message, Row, Space } from "antd";
11 11
 import { useEffect, useRef, useState } from "react";
12
+import UploadFile from "@/components/UploadFile";
12 13
 import Wangeditor from "@/components/Wangeditor";
13 14
 
14 15
 export default (props) => {
@@ -59,7 +60,6 @@ export default (props) => {
59 60
     <PageContainer>
60 61
       <Card>
61 62
         <ProForm
62
-          //  readonly
63 63
           formRef={formRef}
64 64
           layout={"horizontal"}
65 65
           labelCol={{ span: 8 }}
@@ -98,6 +98,29 @@ export default (props) => {
98 98
           >
99 99
             <Wangeditor></Wangeditor>
100 100
           </ProForm.Item>
101
+          <ProForm.Item
102
+            name="file"
103
+            label="文件"
104
+   
105
+           
106
+          >
107
+            <UploadFile
108
+              preview={(value) => {
109
+                return (
110
+                  <div style={{ marginTop: "2em" }}>
111
+                    <a
112
+                      href={value}
113
+                      target="_blank"
114
+                      rel="noopener noreferrer"
115
+                      key="link"
116
+                    >
117
+                      {value}
118
+                    </a>
119
+                  </div>
120
+                );
121
+              }}
122
+            ></UploadFile>
123
+          </ProForm.Item>
101 124
 
102 125
           <ProFormSelect
103 126
             name="status"
@@ -116,6 +139,12 @@ export default (props) => {
116 139
               },
117 140
             ]}
118 141
           />
142
+          <ProFormText
143
+            name="createPerson"
144
+            label="发布人"
145
+            placeholder="请输入发布人"
146
+            width={460}
147
+          />
119 148
         </ProForm>
120 149
       </Card>
121 150
     </PageContainer>

+ 47
- 24
src/pages/cms/emergencyPlan/list/index.jsx Ver arquivo

@@ -1,4 +1,4 @@
1
-import { getPostsList } from "@/services/posts";
1
+import { getPostsList, deletePosts, updatePosts } from "@/services/posts";
2 2
 import { queryTable } from "@/utils/request";
3 3
 import { PageContainer, ProTable } from "@ant-design/pro-components";
4 4
 import { useNavigate } from "react-router-dom";
@@ -6,21 +6,25 @@ import { Button, message, Popconfirm } from "antd";
6 6
 import { useRef, useState, useEffect } from "react";
7 7
 import { floatMultiply, floatDivide } from "@/utils";
8 8
 
9
-// type plan 采购计划  bill 采购账单  inStore  采购入库
10
-const StockList = (props) => {
9
+const regex = /(<([^>]+)>)/gi;
10
+
11
+const EmergencyPlanList = (props) => {
11 12
   const { type } = props;
12
-  const [showDetail, setShowDetail] = useState(false);
13
-  const [activeKey, setActiveKey] = useState("");
13
+
14 14
   const actionRef = useRef();
15 15
   const navigate = useNavigate();
16
-  // console.log(props, "props");
17 16
 
18
-  useEffect(() => {
19
-    actionRef.current.reload();
20
-  }, [type]);
17
+  const updata = (row) => {
18
+    if (row.id) {
19
+      updatePosts(row.id, { status: row.status === 1 ? 0 : 1 }).then((res) => {
20
+        actionRef.current.reload();
21
+      });
22
+    }
23
+  };
24
+
21 25
   const handleDelete = (id) => {
22 26
     if (id) {
23
-      deletePurchase(id).then((res) => {
27
+      deletePosts(id).then((res) => {
24 28
         actionRef.current.reload();
25 29
       });
26 30
     }
@@ -36,30 +40,49 @@ const StockList = (props) => {
36 40
       title: "发布内容",
37 41
       dataIndex: "detail",
38 42
       search: false,
39
-      width:'50%'
43
+      ellipsis: true,
44
+      width: "50%",
45
+      renderText: (text) => text.replace(regex, ""),
40 46
     },
41 47
     {
42 48
       title: "状态",
43 49
       dataIndex: "status",
44
-      valueType: 'select',
45
-      valueEnum:{
46
-        0: { text: '未发布', status: 'Error' },
47
-        1: { text: '已发布', status: 'Processing' }, 
50
+      valueType: "select",
51
+      valueEnum: {
52
+        0: { text: "未发布", status: "Error" },
53
+        1: { text: "已发布", status: "Processing" },
48 54
       },
49
-    
50
-    //   const valueEnum = {
51
-    //     all: { text: '全部', status: 'Default' },
52
-    //     running: { text: '运行中', status: 'Processing' },
53
-    //     online: { text: '已上线', status: 'Success' },
54
-    //     error: { text: '异常', status: 'Error' },
55
-    //   };
56 55
     },
57
-
56
+    {
57
+      title: "发布人",
58
+      dataIndex: "createPerson",
59
+      search: false,
60
+    },
58 61
     {
59 62
       title: "操作",
60 63
       valueType: "option",
61 64
       width: 200,
62 65
       render: (_, record) => [
66
+        <Button
67
+          key={3}
68
+          style={{ padding: 0 }}
69
+          type="link"
70
+          onClick={() => {
71
+            updata(record);
72
+          }}
73
+        >
74
+          {record.status === 1 ? "下架" : "发布"}
75
+        </Button>,
76
+        <Button
77
+          key={1}
78
+          style={{ padding: 0 }}
79
+          type="link"
80
+          onClick={() => {
81
+            navigate(`/cms/emergency-plan/detail?id=${record.id}`);
82
+          }}
83
+        >
84
+          详情
85
+        </Button>,
63 86
         <Button
64 87
           key={2}
65 88
           style={{ padding: 0 }}
@@ -110,4 +133,4 @@ const StockList = (props) => {
110 133
   );
111 134
 };
112 135
 
113
-export default StockList;
136
+export default EmergencyPlanList;

+ 55
- 0
src/pages/cms/files/list/addFiles.jsx Ver arquivo

@@ -0,0 +1,55 @@
1
+import { PlusOutlined } from '@ant-design/icons';
2
+import {
3
+  ModalForm,
4
+  ProForm,
5
+  ProFormDateRangePicker,
6
+  ProFormSelect,
7
+  ProFormText,
8
+} from '@ant-design/pro-components';
9
+import { Button, Form, message } from 'antd';
10
+
11
+
12
+
13
+export default () => {
14
+  const [form] = Form.useForm();
15
+
16
+
17
+  const onFinish = ()=>{
18
+
19
+  }
20
+
21
+  return (
22
+    <ModalForm
23
+      title="新建表单"
24
+      trigger={
25
+        <Button type="primary">
26
+          <PlusOutlined />
27
+          新建表单
28
+        </Button>
29
+      }
30
+      form={form}
31
+      autoFocusFirstInput
32
+      modalProps={{
33
+        destroyOnClose: true,
34
+        onCancel: () => console.log('run'),
35
+      }}
36
+      submitTimeout={2000}
37
+      onFinish={async (values) => {
38
+        await waitTime(2000);
39
+        console.log(values.name);
40
+        message.success('提交成功');
41
+        return true;
42
+      }}
43
+    >
44
+    
45
+        <ProFormText
46
+          width="md"
47
+          name="name"
48
+          label="文件名称"
49
+
50
+          placeholder="请输入名称"
51
+        />
52
+
53
+    </ModalForm>
54
+  );
55
+};

+ 164
- 0
src/pages/cms/files/list/index.jsx Ver arquivo

@@ -0,0 +1,164 @@
1
+import { getPostsList, deletePosts, updatePosts } from "@/services/posts";
2
+import { queryTable } from "@/utils/request";
3
+import { PageContainer, ProTable, ProList } from "@ant-design/pro-components";
4
+import { useNavigate } from "react-router-dom";
5
+import { Button, message, Popconfirm } from "antd";
6
+import { useRef, useState, useEffect } from "react";
7
+import { floatMultiply, floatDivide } from "@/utils";
8
+import AddFiles from './addFiles'
9
+
10
+const FilesList = (props) => {
11
+
12
+  const [showDetail, setShowDetail] = useState(false);
13
+  const [activeKey, setActiveKey] = useState("");
14
+  const actionRef = useRef();
15
+  const navigate = useNavigate();
16
+
17
+
18
+  const updata = (row) => {
19
+    if (row.id) {
20
+      updatePosts(row.id, { status: row.status === 1 ? 0 : 1 }).then((res) => {
21
+        actionRef.current.reload();
22
+      });
23
+    }
24
+  };
25
+
26
+  const handleDelete = (id) => {
27
+    if (id) {
28
+      deletePosts(id).then((res) => {
29
+        actionRef.current.reload();
30
+      });
31
+    }
32
+  };
33
+
34
+  const columns = [
35
+    {
36
+      title: "内容名称",
37
+      dataIndex: "title",
38
+    },
39
+
40
+    {
41
+      title: "状态",
42
+      dataIndex: "status",
43
+      valueType: "select",
44
+      valueEnum: {
45
+        0: { text: "未发布", status: "Error" },
46
+        1: { text: "已发布", status: "Processing" },
47
+      },
48
+    },
49
+    {
50
+      title: "发布人",
51
+      dataIndex: "createPerson",
52
+      search: false,
53
+    },
54
+    {
55
+      title: "操作",
56
+      valueType: "option",
57
+      width: 200,
58
+      render: (_, record) => [
59
+        <Button
60
+          key={3}
61
+          style={{ padding: 0 }}
62
+          type="link"
63
+          onClick={() => {
64
+            updata(record);
65
+          }}
66
+        >
67
+          {record.status === 1 ? "下架" : "发布"}
68
+        </Button>,
69
+        <Button
70
+          key={1}
71
+          style={{ padding: 0 }}
72
+          type="link"
73
+          onClick={() => {
74
+            navigate(`/cms/emergency-plan/detail?id=${record.id}`);
75
+          }}
76
+        >
77
+          详情
78
+        </Button>,
79
+        <Button
80
+          key={2}
81
+          style={{ padding: 0 }}
82
+          type="link"
83
+          onClick={() => {
84
+            navigate(`/cms/emergency-plan/edit?id=${record.id}`);
85
+          }}
86
+        >
87
+          修改
88
+        </Button>,
89
+        <Popconfirm
90
+          key={3}
91
+          title="您是否确认删除 ?"
92
+          onConfirm={() => handleDelete(record.id)}
93
+          okText="确定"
94
+          cancelText="取消"
95
+        >
96
+          {/* manualPush */}
97
+          <Button style={{ padding: 0 }} type="link">
98
+            删除
99
+          </Button>
100
+        </Popconfirm>,
101
+      ],
102
+    },
103
+  ];
104
+
105
+  return (
106
+    <PageContainer>
107
+      <ProList
108
+        toolBarRender={() => {
109
+          return [
110
+           <AddFiles />,
111
+          ];
112
+        }}
113
+        search={{}}
114
+        rowKey="id"
115
+        // headerTitle="基础列表"
116
+        pagination={{
117
+          pageSize: 5,
118
+        }}
119
+        showActions="hover"
120
+        metas={{
121
+          title: {
122
+            dataIndex: "fileName",
123
+            title: "文件名称",
124
+          },
125
+          description: {
126
+            dataIndex: "title",
127
+            search: false,
128
+          },
129
+          actions: {
130
+            render: (text, row) => [
131
+              <a
132
+                href={row.url}
133
+                target="_blank"
134
+                rel="noopener noreferrer"
135
+                key="link"
136
+              >
137
+                链路
138
+              </a>,
139
+              <a
140
+                href={row.url}
141
+                target="_blank"
142
+                rel="noopener noreferrer"
143
+                key="warning"
144
+              >
145
+                报警
146
+              </a>,
147
+              <a
148
+                href={row.url}
149
+                target="_blank"
150
+                rel="noopener noreferrer"
151
+                key="view"
152
+              >
153
+                查看
154
+              </a>,
155
+            ],
156
+            search: false,
157
+          },
158
+        }}
159
+      />
160
+    </PageContainer>
161
+  );
162
+};
163
+
164
+export default FilesList;

+ 17
- 4
src/routes/routes.jsx Ver arquivo

@@ -39,6 +39,9 @@ import PurchaseBillEdit from "@/pages/purchase/bill/edit";
39 39
 import PurchaseInStoreEdit from "@/pages/purchase/inStore/edit";
40 40
 import EmergencyPlanList from "@/pages/cms/emergencyPlan/list";
41 41
 import EmergencyPlanEdit from "@/pages/cms/emergencyPlan/edit";
42
+import EmergencyPlanDetail from "@/pages/cms/emergencyPlan/detail";
43
+import FilesList from "@/pages/cms/files/list";
44
+
42 45
 /**
43 46
  * meta 用来扩展自定义数据数据
44 47
  * {
@@ -178,7 +181,7 @@ export const authRoutes = [
178 181
         },
179 182
       },
180 183
       {
181
-        path: 'rotationChart/edit',
184
+        path: 'rotationChart/add',
182 185
         element: <RotationChartEdit />,
183 186
         meta: {
184 187
           title: '公告维护',
@@ -214,12 +217,22 @@ export const authRoutes = [
214 217
         },
215 218
       },
216 219
       {
217
-        path: 'files',
218
-        element: null,
220
+        path: "emergency-plan/detail",
221
+        element: <EmergencyPlanDetail />,
222
+        meta: {
223
+          title: "应急预案详情",
224
+          hideInMenu: true,
225
+        },
226
+      },
227
+
228
+      {
229
+        path: "files",
230
+        element: <FilesList />,
219 231
         meta: {
220
-          title: '文件管理',
232
+          title: "文件管理",
221 233
         },
222 234
       },
235
+     
223 236
     ],
224 237
   },
225 238
   {