lisenzhou 2 vuotta sitten
vanhempi
commit
e279d2b2ca

+ 6
- 14
src/pages/cms/emergencyPlan/detail/index.jsx Näytä tiedosto

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

+ 10
- 1
src/pages/cms/emergencyPlan/list/index.jsx Näytä tiedosto

33
     {
33
     {
34
       title: "内容名称",
34
       title: "内容名称",
35
       dataIndex: "title",
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
       search: false,
50
       search: false,
42
       ellipsis: true,
51
       ellipsis: true,
43
       width: "50%",
52
       width: "50%",
44
-      renderText: (text) => text.replace(regex, ""),
53
+      renderText: (text) => text?.replace(regex, ""),
45
     },
54
     },
46
     {
55
     {
47
       title: "状态",
56
       title: "状态",

+ 6
- 7
src/pages/purchase/bill/edit/index.jsx Näytä tiedosto

99
             searchConfig: {
99
             searchConfig: {
100
               resetText: "返回",
100
               resetText: "返回",
101
             },
101
             },
102
+            submitButtonProps: {
103
+              disabled: isCompleted,
104
+            },
102
             onReset: () => navigate(-1),
105
             onReset: () => navigate(-1),
103
             render: (props, doms) => {
106
             render: (props, doms) => {
104
               console.log(props, doms, "renderprops");
107
               console.log(props, doms, "renderprops");
106
                 <Row>
109
                 <Row>
107
                   <Col span={8} offset={2}>
110
                   <Col span={8} offset={2}>
108
                     <Space>
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
                         <Button
114
                         <Button
117
                           type="primary"
115
                           type="primary"
116
+                          disabled={isCompleted}
118
                           onClick={() => onBillFinish(props)}
117
                           onClick={() => onBillFinish(props)}
119
                         >
118
                         >
120
                           采购完成
119
                           采购完成

+ 12
- 13
src/pages/purchase/plan/edit/index.jsx Näytä tiedosto

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

+ 44
- 0
src/regulation/detail/index.jsx Näytä tiedosto

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 Näytä tiedosto

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
 export default (props) => {
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
   const navigate = useNavigate();
17
   const navigate = useNavigate();
13
 
18
 
19
+  const formRef = useRef();
20
+
14
   useEffect(() => {
21
   useEffect(() => {
15
     if (id) {
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
   }, [id]);
30
   }, [id]);
21
 
31
 
22
   const onFinish = async (values) => {
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
       navigate(-1);
49
       navigate(-1);
29
     });
50
     });
51
+    // }
52
+
30
     return false;
53
     return false;
31
   };
54
   };
32
 
55
 
35
       <Card>
58
       <Card>
36
         <ProForm
59
         <ProForm
37
           formRef={formRef}
60
           formRef={formRef}
38
-          layout={'horizontal'}
61
+          layout={"horizontal"}
39
           labelCol={{ span: 8 }}
62
           labelCol={{ span: 8 }}
40
-          wrapperCol={{ span: 16 }}
63
+          wrapperCol={{ span: 12 }}
41
           onFinish={onFinish}
64
           onFinish={onFinish}
65
+          initialValues={{ status: 0 }}
42
           submitter={{
66
           submitter={{
43
             searchConfig: {
67
             searchConfig: {
44
-              resetText: '返回',
68
+              resetText: "返回",
45
             },
69
             },
46
             onReset: () => navigate(-1),
70
             onReset: () => navigate(-1),
47
             render: (props, doms) => {
71
             render: (props, doms) => {
56
           }}
80
           }}
57
         >
81
         >
58
           <ProFormText
82
           <ProFormText
83
+            name="title"
84
+            label="内容名称"
85
+            placeholder="请输入内容名称"
86
+            rules={[{ required: true, message: "请输入内容名称" }]}
87
+            width={460}
88
+          />
89
+
90
+          <ProForm.Item
59
             name="detail"
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
             width={460}
107
             width={460}
108
+            options={[
109
+              {
110
+                value: 0,
111
+                label: "未发布",
112
+              },
113
+              {
114
+                value: 1,
115
+                label: "已发布",
116
+              },
117
+            ]}
65
           />
118
           />
66
           <ProFormText
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
             width={460}
123
             width={460}
73
           />
124
           />
74
         </ProForm>
125
         </ProForm>
75
       </Card>
126
       </Card>
76
     </PageContainer>
127
     </PageContainer>
77
   );
128
   );
78
-}
129
+};

+ 72
- 43
src/regulation/index.jsx Näytä tiedosto

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
 const RegulationList = (props) => {
10
 const RegulationList = (props) => {
11
+
9
   const actionRef = useRef();
12
   const actionRef = useRef();
10
   const navigate = useNavigate();
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
   const handleDelete = (id) => {
23
   const handleDelete = (id) => {
17
     if (id) {
24
     if (id) {
18
-      deleteRegulation(id).then((res) => {
19
-        // message.success('删除成功');
25
+      deletePosts(id).then((res) => {
20
         actionRef.current.reload();
26
         actionRef.current.reload();
21
       });
27
       });
22
     }
28
     }
24
 
30
 
25
   const columns = [
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
       search: false,
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
       search: false,
66
       search: false,
57
     },
67
     },
58
     {
68
     {
59
-      title: '操作',
60
-      valueType: 'option',
69
+      title: "操作",
70
+      valueType: "option",
61
       width: 200,
71
       width: 200,
62
       render: (_, record) => [
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
         <Button
93
         <Button
64
           key={2}
94
           key={2}
65
           style={{ padding: 0 }}
95
           style={{ padding: 0 }}
66
           type="link"
96
           type="link"
67
           onClick={() => {
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
         </Button>,
102
         </Button>,
74
-
75
         <Popconfirm
103
         <Popconfirm
76
           key={3}
104
           key={3}
77
           title="您是否确认删除 ?"
105
           title="您是否确认删除 ?"
91
   return (
119
   return (
92
     <PageContainer>
120
     <PageContainer>
93
       <ProTable
121
       <ProTable
94
-        search={true}
95
         actionRef={actionRef}
122
         actionRef={actionRef}
96
         rowKey="id"
123
         rowKey="id"
97
         toolBarRender={() => [
124
         toolBarRender={() => [
99
             key="2"
126
             key="2"
100
             type="primary"
127
             type="primary"
101
             onClick={() => {
128
             onClick={() => {
102
-              navigate('/cms/regulation/add');
129
+              navigate("/cms/regulation/edit");
103
             }}
130
             }}
104
           >
131
           >
105
             新增
132
             新增
106
           </Button>,
133
           </Button>,
107
         ]}
134
         ]}
108
-        request={queryTable(getRegulationList)}
135
+        // search={false}
136
+        params={{ type: 'regulation' }}
137
+        request={queryTable(getPostsList)}
109
         columns={columns}
138
         columns={columns}
110
       />
139
       />
111
     </PageContainer>
140
     </PageContainer>
112
   );
141
   );
113
-}
142
+};
114
 
143
 
115
-export default RegulationList;
144
+export default RegulationList;

+ 11
- 1
src/routes/routes.jsx Näytä tiedosto

35
 import Roles from "@/pages/roles/index";
35
 import Roles from "@/pages/roles/index";
36
 import RegulationList from "@/regulation";
36
 import RegulationList from "@/regulation";
37
 import RegulationEdit from "@/regulation/edit";
37
 import RegulationEdit from "@/regulation/edit";
38
+import RegulationDetail from "@/regulation/detail";
38
 import UserList from "@/pages/user";
39
 import UserList from "@/pages/user";
39
 import UserEdit from "@/pages/user/Edit";
40
 import UserEdit from "@/pages/user/Edit";
40
 import PurchasePlanList from "@/pages/purchase/plan/list";
41
 import PurchasePlanList from "@/pages/purchase/plan/list";
306
         },
307
         },
307
       },
308
       },
308
       {
309
       {
309
-        path: "regulation/add",
310
+        path: "regulation/edit",
310
         element: <RegulationEdit />,
311
         element: <RegulationEdit />,
311
         meta: {
312
         meta: {
312
           hideInMenu: true,
313
           hideInMenu: true,
314
           permission: 'regulation.edit',
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
         path: "emergency-plan",
328
         path: "emergency-plan",
319
         element: <EmergencyPlanList />,
329
         element: <EmergencyPlanList />,

+ 2
- 2
src/services/regulation.js Näytä tiedosto

5
  * @param {*} params
5
  * @param {*} params
6
  * @returns
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
 * @param {*} id
20
 * @param {*} id
21
 * @returns
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
  * 删除