lisenzhou 2 年之前
父節點
當前提交
b4f1a66291

+ 70
- 104
src/pages/guarantee/edit/index.jsx 查看文件

@@ -3,13 +3,16 @@ import {
3 3
   ProForm,
4 4
   ProFormSelect,
5 5
   ProFormText,
6
-  ProFormFieldSet,
7 6
   ProFormDateRangePicker,
8
-  ProFormUploadButton,
9 7
 } from "@ant-design/pro-components";
10 8
 import { useNavigate, useSearchParams } from "react-router-dom";
11 9
 import { Card, Col, Row, Space } from "antd";
12 10
 import { useEffect, useRef } from "react";
11
+import {
12
+  gettCooperationUnitsDetail,
13
+  savetCooperationUnits,
14
+  updatetCooperationUnits,
15
+} from "@/services/cooperationUnits";
13 16
 
14 17
 export default (props) => {
15 18
   const [searchParams] = useSearchParams();
@@ -17,41 +20,43 @@ export default (props) => {
17 20
   const navigate = useNavigate();
18 21
 
19 22
   const formRef = useRef();
20
-  // useEffect(() => {
21
-  //   if (id) {
22
-  //     getPostsDetail(id).then((res) => {
23
-  //       formRef.current.setFieldsValue({
24
-  //         ...res,
25
-  //         filesList: res.filesList?.map((x) => x.fileAddr)[0] || null,
26
-  //       });
27
-  //     });
28
-  //   }
29
-  // }, [id]);
23
+  useEffect(() => {
24
+    if (id) {
25
+      gettCooperationUnitsDetail(id).then((res) => {
26
+        formRef.current.setFieldsValue({
27
+          ...res,
28
+          timeRange: [res.startDate, res.endDate],
29
+          orgType: res?.orgType?.split(","),
30
+        });
31
+      });
32
+    }
33
+  }, [id]);
34
+
35
+  const onFinish = async (values) => {
36
+    console.log(values);
30 37
 
31
-  // const onFinish = async (values) => {
32
-  //   console.log(values);
38
+    if (id) {
39
+      updatetCooperationUnits(id, {
40
+        ...values,
33 41
 
34
-  //   savePosts({
35
-  //     ...values,
36
-  //     type: 'regulation',
37
-  //     filesList: values.filesList
38
-  //       ? [
39
-  //         {
40
-  //           fileAddr: values.filesList,
41
-  //           fileName: values.filesList?.substring(
42
-  //             values.filesList?.lastIndexOf("/") + 1
43
-  //           ),
44
-  //         },
45
-  //       ]
46
-  //       : null,
47
-  //     status: Number(values.status),
48
-  //     ...(id ? { id } : {}),
49
-  //   }).then((res) => {
50
-  //     navigate(-1);
51
-  //   });
42
+        orgType: values.orgType ? values.orgType?.join(",") : null,
43
+        startDate: values.timeRange ? values.timeRange[0] : null,
44
+        endDate: values.timeRange ? values.timeRange[1] : null,
45
+      }).then((res) => {
46
+        navigate(-1);
47
+      });
48
+    } else {
49
+      savetCooperationUnits({
50
+        ...values,
52 51
 
53
-  //   return false;
54
-  // };
52
+        orgType: values.orgType ? values.orgType?.join(",") : null,
53
+        startDate: values.timeRange ? values.timeRange[0] : null,
54
+        endDate: values.timeRange ? values.timeRange[1] : null,
55
+      }).then((res) => {
56
+        navigate(-1);
57
+      });
58
+    }
59
+  };
55 60
 
56 61
   return (
57 62
     <PageContainer>
@@ -61,7 +66,7 @@ export default (props) => {
61 66
           layout={"horizontal"}
62 67
           labelCol={{ span: 8 }}
63 68
           wrapperCol={{ span: 12 }}
64
-          // onFinish={onFinish}
69
+          onFinish={onFinish}
65 70
           initialValues={{ status: 0 }}
66 71
           submitter={{
67 72
             searchConfig: {
@@ -79,50 +84,17 @@ export default (props) => {
79 84
             },
80 85
           }}
81 86
         >
82
-          <ProFormFieldSet
83
-            name="addr"
84
-            label="登记年份"
85
-          >
86
-            <ProFormSelect
87
-              width={460}
88
-              valueEnum={{
89
-                taiyuan: '2019',
90
-                hangzho: '2020',
91
-                hangzh: '2021',
92
-                hangz: '2022',
93
-              }}
94
-            />
95
-          </ProFormFieldSet>
96
-          <ProFormText
97
-            name="createPerson"
98
-            label="机构名称"
99
-            width={460}
100
-          />
87
+          <ProFormText name="name" label="机构名称" width={460} />
101 88
           <ProFormText
102
-            name="createPerson"
89
+            name="businessLicense"
103 90
             label="工商注册证号"
104 91
             width={460}
105 92
           />
106
-          <ProFormText
107
-            name="createPerson"
108
-            label="卫生许可证号"
109
-            width={460}
110
-          />
111
-          <ProFormText
112
-            name="createPerson"
113
-            label="机构名称"
114
-            width={460}
115
-          />
116
-          <ProFormText
117
-            name="createPerson"
118
-            label="供应商联系人"
119
-            width={460}
120
-          />
121
-          <ProFormText
122
-            name="createPerson"
123
-            label="联系电话"
124
-            width={460}
125
-          />
93
+          <ProFormText name="hygieneLicense" label="卫生许可证号" width={460} />
94
+
95
+          <ProFormText name="contacts" label="联系人" width={460} />
96
+          <ProFormText name="phone" label="联系电话" width={460} />
97
+
126 98
           <ProFormDateRangePicker
127 99
             name="timeRange"
128 100
             label="签约时间"
@@ -130,54 +102,48 @@ export default (props) => {
130 102
           />
131 103
           <ProFormSelect
132 104
             width={460}
133
-            name="select-multiple"
105
+            name="orgType"
134 106
             label="机构类别"
135
-            valueEnum={{
136
-              red: '生鲜蔬菜类',
137
-              green: '米面粮油类',
138
-              blue: '饮食类',
139
-              reds: '饮水类',
140
-              greens: '住宿类',
141
-              blues: '物资代储类',
142
-              redss: '医疗救助类',
143
-              greenss: '油料类',
144
-              bluess: '道路施救类',
145
-              bluesss: '其他',
146
-            }}
147 107
             fieldProps={{
148
-              mode: 'multiple',
108
+              mode: "tags",
109
+              options: [
110
+                "生鲜蔬菜类",
111
+                "米面粮油类",
112
+                "饮食类",
113
+                "饮水类",
114
+                "住宿类",
115
+                "物资代储类",
116
+                "医疗救助类",
117
+                "油料类",
118
+                "道路施救类",
119
+              ],
149 120
             }}
150
-            rules={[
151
-              { type: 'array' },
152
-            ]}
153 121
           />
154
-
155 122
           <ProFormText
156
-            name="createPerson"
157
-            label="单日机构内膳食供应能力(人次):"
123
+            name="dietDaily"
124
+            label="单日机构内膳食供应能力(人次)"
158 125
             width={460}
159 126
           />
160 127
           <ProFormText
161
-            name="createPerson"
162
-            label="单次机构内膳食供应能力(人)"
128
+            name="dietSingle"
129
+            label="单次机构内膳食供应能力(人)"
163 130
             width={460}
164 131
           />
165 132
           <ProFormText
166
-            name="createPerson"
167
-            label="单日远程膳食供应能力(人次)"
133
+            name="dietRemoteDaily"
134
+            label="单日远程膳食供应能力(人次)"
168 135
             width={460}
169 136
           />
170 137
           <ProFormText
171
-            name="createPerson"
172
-            label="单次远程膳食供应能力(人)"
138
+            name="dietRemoteSingle"
139
+            label="单次远程膳食供应能力(人)"
173 140
             width={460}
174 141
           />
175 142
           <ProFormText
176
-            name="timeRange"
177
-            label="机构内住宿供应能力(人)"
143
+            name="stayCapability"
144
+            label="机构内住宿供应能力(人)"
178 145
             width={460}
179 146
           />
180
-          <ProFormUploadButton label="机构图片" name="upload" action="upload.do" />
181 147
         </ProForm>
182 148
       </Card>
183 149
     </PageContainer>

+ 31
- 30
src/pages/guarantee/list/index.jsx 查看文件

@@ -1,59 +1,55 @@
1 1
 import { queryTable } from "@/utils/request";
2 2
 import { PageContainer, ProTable } from "@ant-design/pro-components";
3 3
 import { Link, useNavigate } from "react-router-dom";
4
-
4
+import {
5
+  getCooperationUnitsList,
6
+  deletetCooperationUnits,
7
+} from "@/services/cooperationUnits";
5 8
 import { Button, message, Popconfirm } from "antd";
6 9
 import { useRef, useState } from "react";
7 10
 
8 11
 const GuaranteeTaskGuarantee = (props) => {
9 12
   const navigate = useNavigate();
10
-  const [isOpen, setIsOpen] = useState(false);
11
-  const [modalData, setModalData] = useState({});
12 13
   const actionRef = useRef();
13 14
   const formRef = useRef();
14 15
 
15
-  // const handleDelete = (id) => {
16
-  //   if (id) {
17
-  //     deleteGuaranteeTask(id).then((res) => {
18
-  //       actionRef.current.reload();
19
-  //     });
20
-  //   }
21
-  // };
22
-
23
-  const onCancel = () => {
24
-    setIsOpen(false);
25
-    setModalData({});
16
+  const handleDelete = (id) => {
17
+    if (id) {
18
+      deletetCooperationUnits(id).then((res) => {
19
+        actionRef.current.reload();
20
+      });
21
+    }
26 22
   };
27 23
 
28 24
   const columns = [
29 25
     {
30 26
       title: "机构名称",
31
-      dataIndex: "guaranteeNo",
27
+      dataIndex: "name",
32 28
       search: true,
33 29
     },
34 30
     {
35 31
       title: "机构类别",
36
-      dataIndex: "receiver",
32
+      dataIndex: "orgType",
37 33
       search: true,
38 34
     },
39 35
     {
40 36
       title: "工商注册证号",
41
-      dataIndex: "dateRange",
37
+      dataIndex: "businessLicense",
42 38
       search: false,
43 39
     },
44 40
     {
45 41
       title: "卫生许可证号",
46
-      dataIndex: "address",
42
+      dataIndex: "hygieneLicense",
47 43
       search: false,
48 44
     },
49 45
     {
50 46
       title: "联系人",
51
-      dataIndex: "totalPersonNum",
47
+      dataIndex: "contacts",
52 48
       search: false,
53 49
     },
54 50
     {
55 51
       title: "联系电话",
56
-      dataIndex: "standard",
52
+      dataIndex: "phone",
57 53
       search: false,
58 54
     },
59 55
     {
@@ -66,11 +62,22 @@ const GuaranteeTaskGuarantee = (props) => {
66 62
           style={{ padding: 0 }}
67 63
           type="link"
68 64
           onClick={() => {
69
-            // navigate(`/task/evaluate/list?id=${record.id}`);
65
+            navigate(`/task/guarantee/edit?id=${record.id}`);
70 66
           }}
71 67
         >
72
-          评价
68
+          修改
73 69
         </Button>,
70
+        <Popconfirm
71
+          key={3}
72
+          title="您是否确认删除 ?"
73
+          onConfirm={() => handleDelete(record.id)}
74
+          okText="确定"
75
+          cancelText="取消"
76
+        >
77
+          <Button style={{ padding: 0 }} type="link">
78
+            删除
79
+          </Button>
80
+        </Popconfirm>,
74 81
       ],
75 82
     },
76 83
   ];
@@ -80,25 +87,19 @@ const GuaranteeTaskGuarantee = (props) => {
80 87
       <ProTable
81 88
         actionRef={actionRef}
82 89
         formRef={formRef}
83
-        postData={(data) => {
84
-          return data.map((x) => ({
85
-            dateRange: [x.startDate, x.endDate],
86
-            ...x,
87
-          }));
88
-        }}
89 90
         rowKey="id"
90 91
         toolBarRender={() => [
91 92
           <Button
92 93
             key="2"
93 94
             type="primary"
94 95
             onClick={() => {
95
-              navigate('/task/guarantee/edit');
96
+              navigate("/task/guarantee/edit");
96 97
             }}
97 98
           >
98 99
             新增
99 100
           </Button>,
100 101
         ]}
101
-        // request={queryTable(getGuaranteeTaskList)}
102
+        request={queryTable(getCooperationUnitsList)}
102 103
         columns={columns}
103 104
       />
104 105
     </PageContainer>

+ 1
- 1
src/pages/guaranteeTask/Edit/BasicForm.jsx 查看文件

@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
2 2
 import { Link, useNavigate } from 'react-router-dom';
3 3
 import { Button, Row, Col, Form, Input, InputNumber, DatePicker, notification } from 'antd';
4 4
 import { addGuaranteeTask, updateGuaranteeTask } from '@/services/guaranteeTask';
5
-
5
+import moment from 'moment';
6 6
 const { TextArea } = Input;
7 7
 const { RangePicker } = DatePicker;
8 8
 

+ 1
- 1
src/routes/routes.jsx 查看文件

@@ -137,7 +137,7 @@ export const authRoutes = [
137 137
         path: "guarantee/list",
138 138
         element: <GuaranteeList />,
139 139
         meta: {
140
-          title: "社会保障机构",
140
+          title: "保障机构",
141 141
           // permission: 'guaranteeTask.guarantee',
142 142
         },
143 143
       },

+ 21
- 0
src/services/cooperationUnits.js 查看文件

@@ -0,0 +1,21 @@
1
+import { restful } from "@/utils/request";
2
+
3
+/**
4
+ * 构造 Service
5
+ * @returns
6
+ */
7
+const [
8
+  getCooperationUnitsList,
9
+  gettCooperationUnitsDetail,
10
+  savetCooperationUnits,
11
+  updatetCooperationUnits,
12
+  deletetCooperationUnits,
13
+] = restful("/cooperationUnits");
14
+
15
+export {
16
+  getCooperationUnitsList,
17
+  gettCooperationUnitsDetail,
18
+  savetCooperationUnits,
19
+  updatetCooperationUnits,
20
+  deletetCooperationUnits,
21
+};