lisenzhou il y a 2 ans
Parent
révision
e279d2b2ca

+ 6
- 14
src/pages/cms/emergencyPlan/detail/index.jsx Voir le fichier

@@ -1,15 +1,9 @@
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";
1
+import { getPostsDetail } from "@/services/posts";
2
+
9 3
 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";
4
+import { Card, Typography, Button } from "antd";
5
+import { useEffect, useState } from "react";
6
+
13 7
 const { Title } = Typography;
14 8
 export default (props) => {
15 9
   const [searchParams] = useSearchParams();
@@ -18,8 +12,6 @@ export default (props) => {
18 12
   const [url, setUrl] = useState("");
19 13
   const navigate = useNavigate();
20 14
 
21
-  const formRef = useRef();
22
-
23 15
   useEffect(() => {
24 16
     if (id) {
25 17
       getPostsDetail(id).then((res) => {
@@ -36,7 +28,7 @@ export default (props) => {
36 28
       </Title>
37 29
       <div dangerouslySetInnerHTML={{ __html: data?.detail }}></div>
38 30
       {url && (
39
-        <div style={{marginTop:"2em"}}>
31
+        <div style={{ marginTop: "2em" }}>
40 32
           <a
41 33
             href={`${url}`}
42 34
             download

+ 10
- 1
src/pages/cms/emergencyPlan/list/index.jsx Voir le fichier

@@ -33,6 +33,15 @@ const EmergencyPlanList = (props) => {
33 33
     {
34 34
       title: "内容名称",
35 35
       dataIndex: "title",
36
+      render: (text, record) => (
37
+        <a
38
+          onClick={() => {
39
+            navigate(`/cms/emergency-plan/detail?id=${record.id}`);
40
+          }}
41
+        >
42
+          {text}
43
+        </a>
44
+      ),
36 45
     },
37 46
 
38 47
     {
@@ -41,7 +50,7 @@ const EmergencyPlanList = (props) => {
41 50
       search: false,
42 51
       ellipsis: true,
43 52
       width: "50%",
44
-      renderText: (text) => text.replace(regex, ""),
53
+      renderText: (text) => text?.replace(regex, ""),
45 54
     },
46 55
     {
47 56
       title: "状态",

+ 6
- 7
src/pages/purchase/bill/edit/index.jsx Voir le fichier

@@ -99,6 +99,9 @@ export default (props) => {
99 99
             searchConfig: {
100 100
               resetText: "返回",
101 101
             },
102
+            submitButtonProps: {
103
+              disabled: isCompleted,
104
+            },
102 105
             onReset: () => navigate(-1),
103 106
             render: (props, doms) => {
104 107
               console.log(props, doms, "renderprops");
@@ -106,15 +109,11 @@ export default (props) => {
106 109
                 <Row>
107 110
                   <Col span={8} offset={2}>
108 111
                     <Space>
109
-                      {doms?.map((x, index) => {
110
-                        if (index === 1 && isCompleted) {
111
-                          return null;
112
-                        }
113
-                        return x;
114
-                      })}
115
-                      {id&&!isCompleted && (
112
+                      {doms}
113
+                      {id&& (
116 114
                         <Button
117 115
                           type="primary"
116
+                          disabled={isCompleted}
118 117
                           onClick={() => onBillFinish(props)}
119 118
                         >
120 119
                           采购完成

+ 12
- 13
src/pages/purchase/plan/edit/index.jsx Voir le fichier

@@ -85,6 +85,10 @@ export default (props) => {
85 85
           submitter={{
86 86
             searchConfig: {
87 87
               resetText: "返回",
88
+              
89
+            },
90
+            submitButtonProps: {
91
+              disabled: isCompleted,
88 92
             },
89 93
             onReset: () => navigate(-1),
90 94
             render: (props, doms) => {
@@ -93,14 +97,7 @@ export default (props) => {
93 97
               return (
94 98
                 <Row>
95 99
                   <Col span={8} offset={2}>
96
-                    <Space>
97
-                      {doms?.map((x, index) => {
98
-                        if (index === 1 && isCompleted) {
99
-                          return null;
100
-                        }
101
-                        return x;
102
-                      })}
103
-                    </Space>
100
+                    <Space>{doms}</Space>
104 101
                   </Col>
105 102
                 </Row>
106 103
               );
@@ -110,12 +107,14 @@ export default (props) => {
110 107
           <ProFormText
111 108
             name="title"
112 109
             label="采购计划"
110
+            allowClear={false}
113 111
             placeholder="请输入采购计划"
114 112
             rules={[{ required: true, message: "请输入采购计划" }]}
115 113
             width={480}
116 114
           />
117 115
           <ProFormText
118 116
             name="planDate"
117
+            allowClear={false}
119 118
             label="计划时间"
120 119
             placeholder="请输入计划时间"
121 120
             rules={[{ required: true, message: "请输入计划时间" }]}
@@ -138,6 +137,7 @@ export default (props) => {
138 137
                       <ProFormSelect
139 138
                         {...restField}
140 139
                         name={[name, "storeId"]}
140
+                        allowClear={false}
141 141
                         label="库存名称"
142 142
                         placeholder="请选择库存名称"
143 143
                         rules={[{ required: true, message: "请输入选择名称" }]}
@@ -146,6 +146,7 @@ export default (props) => {
146 146
 
147 147
                       <ProFormDigit
148 148
                         {...restField}
149
+                        allowClear={false}
149 150
                         name={[name, "planAmount"]}
150 151
                         label="计划数量"
151 152
                         placeholder="请输入计划数量"
@@ -165,20 +166,18 @@ export default (props) => {
165 166
                         fieldProps={{ precision: 2, prefix: "¥" }}
166 167
                         // width={150}
167 168
                       />
168
-                      <MinusCircleOutlined onClick={() => remove(name)} />
169
+                    {  !isCompleted&&<MinusCircleOutlined onClick={() => remove(name)} />}
169 170
                     </Space>
170 171
                   ))}
171
-                  <Form.Item>
172
+                  {!isCompleted&&<Form.Item>
172 173
                     <Button
173 174
                       type="dashed"
174 175
                       onClick={() => add()}
175
-                      // block
176
-                      // style={{width:100}}
177 176
                       icon={<PlusOutlined />}
178 177
                     >
179 178
                       添加
180 179
                     </Button>
181
-                  </Form.Item>
180
+                  </Form.Item>}
182 181
                 </>
183 182
               )}
184 183
             </Form.List>

+ 44
- 0
src/regulation/detail/index.jsx Voir le fichier

@@ -0,0 +1,44 @@
1
+import { getPostsDetail } from "@/services/posts";
2
+
3
+import { useNavigate, useSearchParams } from "react-router-dom";
4
+import { Card, Typography, Button } from "antd";
5
+import { useEffect, useState } from "react";
6
+
7
+const { Title } = Typography;
8
+export default (props) => {
9
+  const [searchParams] = useSearchParams();
10
+  const id = searchParams.get("id");
11
+  const [data, setData] = useState({});
12
+  const [url, setUrl] = useState("");
13
+  const navigate = useNavigate();
14
+
15
+  useEffect(() => {
16
+    if (id) {
17
+      getPostsDetail(id).then((res) => {
18
+        setData(res);
19
+        setUrl(res.filesList[0]?.fileAddr);
20
+      });
21
+    }
22
+  }, [id]);
23
+
24
+  return (
25
+    <Card title={<Button onClick={() => navigate(-1)}> 返回</Button>}>
26
+      <Title level={2} style={{ marginBottom: "2em" }}>
27
+        {data.title}
28
+      </Title>
29
+      <div dangerouslySetInnerHTML={{ __html: data?.detail }}></div>
30
+      {url && (
31
+        <div style={{ marginTop: "2em" }}>
32
+          <a
33
+            href={`${url}`}
34
+            download
35
+            // rel="noopener noreferrer"
36
+            // key="link"
37
+          >
38
+            {url?.substring(url?.lastIndexOf("/") + 1)}
39
+          </a>
40
+        </div>
41
+      )}
42
+    </Card>
43
+  );
44
+};

+ 80
- 29
src/regulation/edit/index.jsx Voir le fichier

@@ -1,32 +1,55 @@
1
-import { addRegulation, getRegulationById } from '@/services/regulation';
2
-import { queryDict } from '@/utils/request';
3
-import { PageContainer, ProForm, ProFormSelect, ProFormText } from '@ant-design/pro-components';
4
-import { Card, Col, message, Row, Space } from 'antd';
5
-import { useNavigate, useSearchParams } from 'react-router-dom';
6
-import { useEffect, useRef, useState } from 'react';
1
+import { savePosts, getPostsDetail } from "@/services/posts";
2
+import {
3
+  PageContainer,
4
+  ProForm,
5
+  ProFormSelect,
6
+  ProFormText,
7
+} from "@ant-design/pro-components";
8
+import { useNavigate, useSearchParams } from "react-router-dom";
9
+import { Card, Col, Row, Space } from "antd";
10
+import { useEffect, useRef } from "react";
11
+import UploadFile from "@/components/UploadFile";
12
+import Wangeditor from "@/components/Wangeditor";
7 13
 
8 14
 export default (props) => {
9
-  const [searchParams, setSearchParams] = useSearchParams();
10
-  const id = searchParams.get('id');
11
-  const formRef = useRef();
15
+  const [searchParams] = useSearchParams();
16
+  const id = searchParams.get("id");
12 17
   const navigate = useNavigate();
13 18
 
19
+  const formRef = useRef();
20
+
14 21
   useEffect(() => {
15 22
     if (id) {
16
-      getRegulationById(id).then((res) => {
17
-        formRef.current.setFieldsValue(res);
23
+      getPostsDetail(id).then((res) => {
24
+        formRef.current.setFieldsValue({
25
+          ...res,
26
+          filesList: res.filesList?.map((x) => x.fileAddr)[0]||null,
27
+        });
18 28
       });
19 29
     }
20 30
   }, [id]);
21 31
 
22 32
   const onFinish = async (values) => {
23
-    console.log(values);
24
-
25
-    //添加,修改
26
-    addRegulation({ ...values, id }).then((res) => {
27
-      // message.success('成功');
33
+    savePosts({
34
+      ...values,
35
+      type: 'regulation',
36
+      filesList: values.filesList
37
+        ? [
38
+            {
39
+              fileAddr: values.filesList,
40
+              fileName: values.filesList?.substring(
41
+                values.filesList?.lastIndexOf("/") + 1
42
+              ),
43
+            },
44
+          ]
45
+        : null,
46
+      status: Number(values.status),
47
+      ...(id?{id}:{}),
48
+    }).then((res) => {
28 49
       navigate(-1);
29 50
     });
51
+    // }
52
+
30 53
     return false;
31 54
   };
32 55
 
@@ -35,13 +58,14 @@ export default (props) => {
35 58
       <Card>
36 59
         <ProForm
37 60
           formRef={formRef}
38
-          layout={'horizontal'}
61
+          layout={"horizontal"}
39 62
           labelCol={{ span: 8 }}
40
-          wrapperCol={{ span: 16 }}
63
+          wrapperCol={{ span: 12 }}
41 64
           onFinish={onFinish}
65
+          initialValues={{ status: 0 }}
42 66
           submitter={{
43 67
             searchConfig: {
44
-              resetText: '返回',
68
+              resetText: "返回",
45 69
             },
46 70
             onReset: () => navigate(-1),
47 71
             render: (props, doms) => {
@@ -56,23 +80,50 @@ export default (props) => {
56 80
           }}
57 81
         >
58 82
           <ProFormText
83
+            name="title"
84
+            label="内容名称"
85
+            placeholder="请输入内容名称"
86
+            rules={[{ required: true, message: "请输入内容名称" }]}
87
+            width={460}
88
+          />
89
+
90
+          <ProForm.Item
59 91
             name="detail"
60
-            label="发布内容"
61
-            placeholder="请输入发布内容"
62
-            rules={[{ required: true, message: '请输入发布内容' }]}
63
-            allowClear={false}
92
+            label="发布详情"
93
+            placeholder="请输入发布详情"
94
+            rules={[{ required: true, message: "请输入发布详情" }]}
95
+          >
96
+            <Wangeditor></Wangeditor>
97
+          </ProForm.Item>
98
+          <ProForm.Item name="filesList" label="文件">
99
+            <UploadFile preview={true}></UploadFile>
100
+          </ProForm.Item>
101
+
102
+          <ProFormSelect
103
+            name="status"
104
+            label="状态"
105
+            placeholder="请选择"
106
+            rules={[{ required: true, message: "请选择状态" }]}
64 107
             width={460}
108
+            options={[
109
+              {
110
+                value: 0,
111
+                label: "未发布",
112
+              },
113
+              {
114
+                value: 1,
115
+                label: "已发布",
116
+              },
117
+            ]}
65 118
           />
66 119
           <ProFormText
67
-            name="title"
68
-            label="内容名称"
69
-            placeholder="请输入内容名称"
70
-            rules={[{ required: true, message: '请输入内容名称' }]}
71
-            allowClear={false}
120
+            name="createPerson"
121
+            label="发布人"
122
+            placeholder="请输入发布人"
72 123
             width={460}
73 124
           />
74 125
         </ProForm>
75 126
       </Card>
76 127
     </PageContainer>
77 128
   );
78
-}
129
+};

+ 72
- 43
src/regulation/index.jsx Voir le fichier

@@ -1,22 +1,28 @@
1
-import { getRegulationList, deleteRegulation } from '@/services/regulation';
2
-import { PageContainer, ProTable } from '@ant-design/pro-components';
3
-import { useRef, useState, useEffect } from 'react';
4
-import { useNavigate } from 'react-router-dom';
5
-import { queryTable } from '@/utils/request';
6
-import { Button, message, Popconfirm } from 'antd';
1
+import { getPostsList, deletePosts, updatePosts } from "@/services/posts";
2
+import { queryTable } from "@/utils/request";
3
+import { PageContainer, ProTable } from "@ant-design/pro-components";
4
+import { useNavigate } from "react-router-dom";
5
+import { Button, Popconfirm } from "antd";
6
+import { useRef } from "react";
7
+
8
+const regex = /(<([^>]+)>)/gi;
7 9
 
8 10
 const RegulationList = (props) => {
11
+
9 12
   const actionRef = useRef();
10 13
   const navigate = useNavigate();
11 14
 
12
-  useEffect(() => {
13
-    actionRef.current.reload();
14
-  });
15
+  const updata = (row) => {
16
+    if (row.id) {
17
+      updatePosts(row.id, { status: row.status === 1 ? 0 : 1 }).then((res) => {
18
+        actionRef.current.reload();
19
+      });
20
+    }
21
+  };
15 22
 
16 23
   const handleDelete = (id) => {
17 24
     if (id) {
18
-      deleteRegulation(id).then((res) => {
19
-        // message.success('删除成功');
25
+      deletePosts(id).then((res) => {
20 26
         actionRef.current.reload();
21 27
       });
22 28
     }
@@ -24,54 +30,76 @@ const RegulationList = (props) => {
24 30
 
25 31
   const columns = [
26 32
     {
27
-      title: 'id',
28
-      dataIndex: 'id',
29
-      width: 200,
30
-      search: false,
31
-    },
32
-    {
33
-      title: '标题',
34
-      dataIndex: 'title',
35
-      width: 200,
36
-      search: true,
33
+      title: "内容名称",
34
+      dataIndex: "title",
35
+      render: (text, record) => (
36
+        <a
37
+          onClick={() => {
38
+            navigate(`/cms/regulation/detail?id=${record.id}`);
39
+          }}
40
+        >
41
+          {text}
42
+        </a>
43
+      ),
37 44
     },
38 45
 
39 46
     {
40
-      title: '内容',
41
-      dataIndex: 'detail',
42
-      width: 200,
47
+      title: "发布内容",
48
+      dataIndex: "detail",
43 49
       search: false,
50
+      ellipsis: true,
51
+      width: "50%",
52
+      renderText: (text) => text?.replace(regex, ""),
44 53
     },
45
-
46 54
     {
47
-      title: '发布人',
48
-      dataIndex: 'create_person',
49
-      width: 200,
50
-      search: false,
55
+      title: "状态",
56
+      dataIndex: "status",
57
+      valueType: "select",
58
+      valueEnum: {
59
+        0: { text: "未发布", status: "Error" },
60
+        1: { text: "已发布", status: "Processing" },
61
+      },
51 62
     },
52 63
     {
53
-      title: '发布时间',
54
-      dataIndex: 'create_date',
55
-      width: 200,
64
+      title: "发布人",
65
+      dataIndex: "createPerson",
56 66
       search: false,
57 67
     },
58 68
     {
59
-      title: '操作',
60
-      valueType: 'option',
69
+      title: "操作",
70
+      valueType: "option",
61 71
       width: 200,
62 72
       render: (_, record) => [
73
+        <Button
74
+          key={4}
75
+          style={{ padding: 0 }}
76
+          type="link"
77
+          onClick={() => {
78
+            updata(record);
79
+          }}
80
+        >
81
+          {record.status === 1 ? "下架" : "发布"}
82
+        </Button>,
83
+        <Button
84
+          key={1}
85
+          style={{ padding: 0 }}
86
+          type="link"
87
+          onClick={() => {
88
+            navigate(`/cms/regulation/detail?id=${record.id}`);
89
+          }}
90
+        >
91
+          详情
92
+        </Button>,
63 93
         <Button
64 94
           key={2}
65 95
           style={{ padding: 0 }}
66 96
           type="link"
67 97
           onClick={() => {
68
-            console.log(record, ']]');
69
-            navigate(`/cms/regulation/add?id=${record.id}`);
98
+            navigate(`/cms/regulation/edit?id=${record.id}`);
70 99
           }}
71 100
         >
72
-          编辑
101
+          修改
73 102
         </Button>,
74
-
75 103
         <Popconfirm
76 104
           key={3}
77 105
           title="您是否确认删除 ?"
@@ -91,7 +119,6 @@ const RegulationList = (props) => {
91 119
   return (
92 120
     <PageContainer>
93 121
       <ProTable
94
-        search={true}
95 122
         actionRef={actionRef}
96 123
         rowKey="id"
97 124
         toolBarRender={() => [
@@ -99,17 +126,19 @@ const RegulationList = (props) => {
99 126
             key="2"
100 127
             type="primary"
101 128
             onClick={() => {
102
-              navigate('/cms/regulation/add');
129
+              navigate("/cms/regulation/edit");
103 130
             }}
104 131
           >
105 132
             新增
106 133
           </Button>,
107 134
         ]}
108
-        request={queryTable(getRegulationList)}
135
+        // search={false}
136
+        params={{ type: 'regulation' }}
137
+        request={queryTable(getPostsList)}
109 138
         columns={columns}
110 139
       />
111 140
     </PageContainer>
112 141
   );
113
-}
142
+};
114 143
 
115
-export default RegulationList;
144
+export default RegulationList;

+ 11
- 1
src/routes/routes.jsx Voir le fichier

@@ -35,6 +35,7 @@ import RotationChartDetail from "@/pages/rotationChart/detail";
35 35
 import Roles from "@/pages/roles/index";
36 36
 import RegulationList from "@/regulation";
37 37
 import RegulationEdit from "@/regulation/edit";
38
+import RegulationDetail from "@/regulation/detail";
38 39
 import UserList from "@/pages/user";
39 40
 import UserEdit from "@/pages/user/Edit";
40 41
 import PurchasePlanList from "@/pages/purchase/plan/list";
@@ -306,7 +307,7 @@ export const authRoutes = [
306 307
         },
307 308
       },
308 309
       {
309
-        path: "regulation/add",
310
+        path: "regulation/edit",
310 311
         element: <RegulationEdit />,
311 312
         meta: {
312 313
           hideInMenu: true,
@@ -314,6 +315,15 @@ export const authRoutes = [
314 315
           permission: 'regulation.edit',
315 316
         },
316 317
       },
318
+      {
319
+        path: "regulation/detail",
320
+        element: <RegulationDetail />,
321
+        meta: {
322
+          hideInMenu: true,
323
+          title: "规章制度详情",
324
+          permission: 'regulation.detail',
325
+        },
326
+      },
317 327
       {
318 328
         path: "emergency-plan",
319 329
         element: <EmergencyPlanList />,

+ 2
- 2
src/services/regulation.js Voir le fichier

@@ -5,7 +5,7 @@ import request from '@/utils/request';
5 5
  * @param {*} params
6 6
  * @returns
7 7
  */
8
-export const getRegulationList = (params) => request('/posts', { params });
8
+export const getRegulationList = (params) => request('/posts', { params,successTip:false });
9 9
 
10 10
 /**
11 11
 * 新增,更新
@@ -20,7 +20,7 @@ export const addRegulation = (data) => request(`/posts`, { method: 'post', data
20 20
 * @param {*} id
21 21
 * @returns
22 22
 */
23
-export const getRegulationById = (id) => request(`/posts/${id}`);
23
+export const getRegulationById = (id) => request(`/posts/${id}` ,{successTip:false});
24 24
 
25 25
 /**
26 26
  * 删除