zlisen 4 years ago
parent
commit
e87e727091

+ 1
- 1
src/components/UploadImage/index.jsx View File

@@ -26,7 +26,7 @@ export default (props) => {
26 26
 
27 27
   return (
28 28
     <Upload
29
-      accept=".png, .jpg, .jpeg, .gif"
29
+      accept=".png, .jpg, .jpeg, .gif, .pdf"
30 30
       listType="picture-card"
31 31
       className="avatar-uploader"
32 32
       showUploadList={false}

+ 327
- 9
src/pages/Medical/Test/Edit/index.js View File

@@ -1,19 +1,337 @@
1
-import React from 'react';
2
-import { connect } from 'umi';
1
+import React, { useEffect, useState } from 'react';
2
+import { connect, history } from 'umi';
3
+
3 4
 import { PageContainer } from '@ant-design/pro-layout';
5
+import Container from '@/components/Container';
6
+import { Input, Form, Button, notification, Upload, message } from 'antd';
7
+import ProForm, {
8
+  ProFormText,
9
+  ProFormTextArea,
10
+  ProFormSelect,
11
+  ProFormDependency,
12
+} from '@ant-design/pro-form';
13
+import request from '@/utils/request';
14
+import School from '@/components/School';
15
+import UploadImage from '@/components/UploadImage';
16
+import { UploadOutlined } from '@ant-design/icons';
17
+import uploadFile from '@/utils/uploadFile';
18
+
19
+const { Search } = Input;
20
+const TestEdit = (props) => {
21
+  const { id, schoolId } = props.location.query;
22
+
23
+  const [searchLoading, setSearchLoading] = useState(false);
24
+  const [school, setSchool] = useState();
25
+  const [fileList, setFileList] = useState([]);
26
+
27
+  const [searchValue, setSearchValue] = useState();
28
+
29
+  const [form] = Form.useForm();
4 30
 
5
-const VisitList = () => {
31
+  // eslint-disable-next-line no-shadow
32
+  const getData = (id) => {
33
+    if (id) {
34
+      request(`/student-no/${id}`, { params: { schoolId: school } })
35
+        .then((res) => {
36
+          form.setFieldsValue(res);
37
+          setSearchLoading(false);
38
+        })
39
+        .catch((e) => {
40
+          setSearchLoading(false);
41
+          notification.error({ message: '未找到该学生' });
42
+          form.resetFields();
43
+        });
44
+    } else {
45
+      // this.setState({ data: [] });
46
+    }
47
+  };
6 48
 
49
+  useEffect(() => {
50
+    if (id) {
51
+      if (id) {
52
+        request(`/medical-log/${id}`)
53
+          .then((res) => {
54
+            form.setFieldsValue({ ...res });
55
+            setSearchLoading(false);
56
+          })
57
+          .catch((e) => {
58
+            setSearchLoading(false);
59
+          });
60
+      } else {
61
+        // this.setState({ data: [] });
62
+      }
63
+    }
64
+  }, [id]);
7 65
 
8
- 
66
+  const onSearch = (value) => {
67
+    if (value) {
68
+      getData(value);
69
+      setSearchLoading(true);
70
+    } else {
71
+      // this.setState({ data: [] });
72
+    }
73
+  };
74
+
75
+  const addTestLog = async (value) => {
76
+    await request('/taTestLog', { method: 'post', data: value })
77
+      .then(() => {
78
+        // notification.success({ message: '新建成功' });
79
+        // history.go('-1');
80
+      })
81
+      .catch((e) => {
82
+        notification.error({ message: e.message });
83
+      });
84
+  };
85
+
86
+  const handleSubmit = async (value) => {
87
+    console.log(value);
88
+    const { studentId, attchment } = value;
89
+    if (!studentId) {
90
+      message.error(`请选择学生`);
91
+    }
92
+    try {
93
+      if (attchment && attchment.fileList.length > 0) {
94
+        attchment.fileList.map((x) => {
95
+          addTestLog({ studentId, name: x.name, attchment: x.response });
96
+          return null;
97
+        });
98
+        notification.success({ message: '新建成功' });
99
+        history.go('-1');
100
+      }
101
+    } catch (error) {
102
+      notification.error({ message: '创建失败' });
103
+    }
104
+  };
105
+
106
+  const handleSchoolChange = (value) => {
107
+    setSchool(value);
108
+    setSearchValue('');
109
+    form.resetFields();
110
+  };
9 111
 
10 112
   return (
11
-    <PageContainer>
12
-      234
113
+    <PageContainer
114
+      header={{
115
+        extra: [
116
+          <Button key="1" onClick={() => history.go('-1')}>
117
+            返回
118
+          </Button>,
119
+        ],
120
+      }}
121
+    >
122
+      <Container>
123
+        <ProForm form={form} submitter={!id} onFinish={handleSubmit}>
124
+          {!id && (
125
+            <ProForm.Group layout="inline">
126
+              <School
127
+                value={school}
128
+                onChange={handleSchoolChange}
129
+                style={{ width: 200, marginBottom: '20px' }}
130
+                allowClear
131
+              />
132
+              <Search
133
+                placeholder="请输入学号"
134
+                value={searchValue}
135
+                onChange={(e) => setSearchValue(e.value)}
136
+                loading={searchLoading}
137
+                style={{ width: 200, marginBottom: '20px' }}
138
+                onSearch={onSearch}
139
+              />
140
+            </ProForm.Group>
141
+          )}
142
+          <Form.Item name="studentId" noStyle />
143
+
144
+          <ProForm.Group layout="inline" title="就诊信息">
145
+            <ProFormText
146
+              label="姓名"
147
+              placeholder="输入名称"
148
+              name="name"
149
+              fieldProps={{ bordered: false, readOnly: true }}
150
+              // rules={[{ required: true, message: '请填写名称' }]}
151
+            />
152
+            <ProFormSelect
153
+              options={[
154
+                {
155
+                  value: 1,
156
+                  label: '男',
157
+                },
158
+                {
159
+                  value: 2,
160
+                  label: '女',
161
+                },
162
+              ]}
163
+              name="sex"
164
+              label="性别"
165
+              fieldProps={{ bordered: false, open: false, allowClear: false }}
166
+              // rules={[{ required: true, message: '请选择性别' }]}
167
+            />
168
+            <ProFormText
169
+              label="学号"
170
+              placeholder="输入学号"
171
+              name="studentNo"
172
+              fieldProps={{ bordered: false, readOnly: true }}
173
+              // rules={[{ required: true, message: '请填写学号' }]}
174
+            />
175
+            <ProFormText
176
+              label="联系方式"
177
+              placeholder="输入联系方式"
178
+              name="phone"
179
+              fieldProps={{ bordered: false, readOnly: true }}
180
+              // rules={[{ required: true, message: '请填写联系方式' }]}
181
+            />
182
+          </ProForm.Group>
183
+
184
+          <Form.Item
185
+            name="attchment"
186
+            label="体检报告"
187
+            placeholder="请选择体检报告"
188
+            extra="支持pdf文件"
189
+            // valuePropName="fileList"
190
+            rules={[{ required: true, message: '请上传体检报告' }]}
191
+          >
192
+            <Upload
193
+              accept=".pdf"
194
+              // listType="picture-card"
195
+              // className="avatar-uploader"
196
+              // showUploadList={false}
197
+              // fileList={fileList}
198
+              customRequest={uploadFile}
199
+              onChange={(info) => {
200
+                if (info.file.status !== 'uploading') {
201
+                  console.log(info.file, info.fileList);
202
+                }
203
+                if (info.file.status === 'done') {
204
+                  message.success(`${info.file.name} 上传成功`);
205
+                  // setFileList([info.file])
206
+                } else if (info.file.status === 'error') {
207
+                  message.error(`${info.file.name} 上传失败`);
208
+                }
209
+              }}
210
+            >
211
+              <Button icon={<UploadOutlined />}>点击上传</Button>
212
+            </Upload>
213
+            {/* <UploadImage /> */}
214
+          </Form.Item>
215
+
216
+          {/* <ProFormTextArea
217
+            label="诊断报告"
218
+            placeholder="输入诊断报告"
219
+            name="attchment"
220
+            fieldProps={{ readOnly: !!id, rows: 10 }}
221
+            rules={[{ required: true, message: '请填写诊断报告' }]}
222
+            style={{ width: '100%' }}
223
+          /> */}
224
+        </ProForm>
225
+      </Container>
226
+      {/* <Container>
227
+        <ProForm form={form} onFinish={handleSubmit}>
228
+          <ProFormText
229
+            label="姓名"
230
+            placeholder="输入姓名"
231
+            name="title"
232
+            rules={[{ required: true, message: '请填写姓名' }]}
233
+          />
234
+
235
+          <ProFormSelect
236
+            options={[
237
+              {
238
+                value: 1,
239
+                label: '男',
240
+              },
241
+              {
242
+                value: 2,
243
+                label: '女',
244
+              },
245
+            ]}
246
+            name="sex"
247
+            label="性别"
248
+            fieldProps={{ bordered: !id, open: id ? false : undefined }}
249
+            rules={[{ required: true, message: '请选择性别' }]}
250
+          />
251
+
252
+          <ProFormSelect
253
+            label="学校"
254
+            placeholder="请选择学校"
255
+            name="schoolId"
256
+            showSearch
257
+            request={async ({ keyWords }) => {
258
+              // if (keyWords) {
259
+              return request('/school', {
260
+                method: 'get',
261
+                params: { name: keyWords, pageNum: 1, pageSize: 1000 },
262
+              })
263
+                .then((res) => {
264
+                  return res?.records?.map((x) => {
265
+                    return { label: x.name, value: x.schoolId };
266
+                  });
267
+                })
268
+                .catch((e) => {
269
+                  notification.error({ message: e.message });
270
+                  return Promise.reject(e.message);
271
+                });
272
+              // }
273
+            }}
274
+          />
275
+
276
+
277
+          <ProFormDependency name={['schoolId']}>
278
+            {({ schoolId }) => {
279
+              return (
280
+                <ProFormSelect
281
+                  label="专业"
282
+                  placeholder="请选择专业"
283
+                  name="specialtyId"
284
+                  dependencies={['schoolId']}
285
+                  showSearch
286
+                  params={{ schoolId }}
287
+                  disabled={!schoolId}
288
+                  options={specialtyOptions}
289
+                  request={async ({ keyWords, ...params }) => {
290
+                    console.log({ params });
291
+                    if (schoolId) {
292
+                      return request('/specialty', {
293
+                        method: 'get',
294
+                        params: { name: keyWords, ...params, pageNum: 1, pageSize: 1000 },
295
+                      })
296
+                        .then((res) => {
297
+                          return res?.records?.map((x) => {
298
+                            return { label: x.name, value: x.specialtyId };
299
+                          });
300
+                        })
301
+                        .catch((e) => {
302
+                          notification.error({ message: e.message });
303
+                          return Promise.reject(e.message);
304
+                        });
305
+                    }
306
+                  }}
307
+                />
308
+              );
309
+            }}
310
+          </ProFormDependency>
311
+
312
+          
313
+          <ProFormText
314
+            label="学号"
315
+            placeholder="输入学号"
316
+            name="studentNo"
317
+            fieldProps={{ bordered: !id, readOnly: !!id }}
318
+            rules={[{ required: true, message: '请填写学号' }]}
319
+          />
320
+
321
+          <Form.Item
322
+            name="image"
323
+            label="体检报告"
324
+            placeholder="请选择体检报告"
325
+            extra="支持pdf文件"
326
+            rules={[{ required: true, message: '请上传体检报告' }]}
327
+          >
328
+            <UploadImage />
329
+          </Form.Item>
330
+        </ProForm>
331
+      
332
+      </Container> */}
13 333
     </PageContainer>
14 334
   );
15 335
 };
16 336
 
17
-export default connect((s) => ({
18
-  typeList: s.post.typeList,
19
-}))(VisitList);
337
+export default TestEdit;

+ 43
- 31
src/pages/Medical/Test/List/index.jsx View File

@@ -1,36 +1,55 @@
1
-import React, { useRef, useCallback } from 'react';
1
+import React, { useState, useRef, useCallback } from 'react';
2 2
 import { connect, history } from 'umi';
3 3
 import { PageContainer } from '@ant-design/pro-layout';
4 4
 import ProTable from '@ant-design/pro-table';
5 5
 import { PlusOutlined } from '@ant-design/icons';
6
-import { Button,  Space } from 'antd';
6
+import { Button,  Space,Image } from 'antd';
7 7
 import  { queryTable } from '@/utils/request';
8
+import School from '@/components/School';
9
+import Specialty from '@/components/Specialty';
8 10
 
9 11
 const VisitList = () => {
10 12
 
11
-
13
+  const [school, setSchool] = useState({});
14
+  const [abc, setA] = useState();
15
+  
12 16
   const ref = useRef();
13 17
   const handleMedicalClick = useCallback((id) => {
14
-    history.push(id ? `/medical/Test/edit?id=${id}` : '/medical/Test/edit');
18
+    history.push(id ? `/medical/Test/edit?id=${id}&schoolId=${school?.schoolId}` : `/medical/Test/edit?schoolId=${school?.schoolId}`);
15 19
   }, []);
16 20
 
17
-  // const actions = [   
18
-  //   <Button key="button" icon={<PlusOutlined />} type="primary" onClick={() => handleMedicalClick()}>
19
-  //     新建
20
-  //   </Button>,
21
-  // ];
21
+  const actions = [   
22
+    <Button key="button" icon={<PlusOutlined />} type="primary" onClick={() => handleMedicalClick()}>
23
+      新建
24
+    </Button>,
25
+  ];
26
+
27
+  
28
+  const renderFormItem = (item, config, form) => {
29
+    const handleSchoolChange = (schoolId, schoolInfo) => {
30
+      form.setFieldsValue({ schoolId });
31
+      form.submit();
32
+      console.log(schoolInfo, 'schoolInfo');
33
+      setSchool({ ...schoolInfo });
34
+    };
35
+
36
+    return <School onChange={handleSchoolChange} allowClear />;
37
+  };
38
+
22 39
   const columns = [
23 40
     {
24
-      title: '就诊编号',
41
+      title: '编号',
25 42
       dataIndex: 'serialNo',
26 43
       hideInSearch: true,
27 44
 
28 45
       align: 'center',
29 46
     },
30 47
     {
31
-      title: '学校名称',
32
-      dataIndex: 'schoolName',
48
+      title: '学校',
49
+      dataIndex: 'schoolId',
33 50
       align: 'center',
51
+      render: (_, row) => row.schoolName,
52
+      renderFormItem,
34 53
     },
35 54
 
36 55
     {
@@ -54,24 +73,14 @@ const VisitList = () => {
54 73
     },
55 74
     {
56 75
       title: '专业',
57
-      dataIndex: 'specialtyName',
76
+      dataIndex: 'specialtyId',
58 77
       align: 'center',
59
-      // hideInTable: true,
78
+      render: (_, row) => row.specialtyName||'-',
79
+      renderFormItem: (item, config, form) => {
80
+        const schoolId = form.getFieldValue('schoolId');
81
+        return <Specialty schoolid={schoolId} disabled={!schoolId}></Specialty>;
82
+      },
60 83
     },
61
-    {
62
-      title: '医生',
63
-      dataIndex: 'doctorName',
64
-      align: 'center',
65
-      hideInSearch: true,
66
-      valueType: 'date',
67
-    },
68
-    // {
69
-    //   title: '就诊科室',
70
-    //   dataIndex: 'createDate',
71
-    //   align: 'center',
72
-    //   hideInSearch: true,
73
-
74
-    // },
75 84
     {
76 85
       title: '创建时间',
77 86
       dataIndex: 'createDate',
@@ -87,8 +96,8 @@ const VisitList = () => {
87 96
       hideInSearch: true,
88 97
       render: (text, record) => (
89 98
         <Space size="middle">
90
-          <a onClick={() => handleMedicalClick(record.serialNo)}>查看报告</a>
91
-         
99
+          <a href={record.attchment} target="_blank" rel="noreferrer">查看报告</a>
100
+          {/* <a onClick={()=>setA(record.attchment)}>查看报告</a> */}
92 101
         </Space>
93 102
       ),
94 103
     },
@@ -98,6 +107,7 @@ const VisitList = () => {
98 107
     <PageContainer>
99 108
       <ProTable
100 109
         columns={columns}
110
+        
101 111
         request={queryTable('/testLog')}
102 112
         formRef={ref}
103 113
         rowKey="serialNo"
@@ -105,8 +115,10 @@ const VisitList = () => {
105 115
         search={{
106 116
           labelWidth: '4em',
107 117
         }}
108
-        // toolBarRender={() => actions}
118
+        toolBarRender={() => actions}
109 119
       />
120
+     
121
+   
110 122
     </PageContainer>
111 123
   );
112 124
 };

+ 7
- 9
src/pages/Medical/Visit/Edit/index.jsx View File

@@ -14,6 +14,8 @@ const VisitEdit = (props) => {
14 14
 
15 15
   const [searchLoading, setSearchLoading] = useState(false);
16 16
   const [school, setSchool] = useState();
17
+  const [searchValue, setSearchValue] = useState();
18
+  
17 19
   const [form] = Form.useForm();
18 20
 
19 21
   // eslint-disable-next-line no-shadow
@@ -73,15 +75,9 @@ const VisitEdit = (props) => {
73 75
 
74 76
   const handleSchoolChange = (value) => {
75 77
     setSchool(value)
76
-    console.log(value)
77
-    // request('/medicalLog', { method: 'post', data: { schoolId, ...value } })
78
-    //   .then(() => {
79
-    //     notification.success({ message: '新建成功' });
80
-    //     history.go('-1');
81
-    //   })
82
-    //   .catch((e) => {
83
-    //     notification.error({ message: e.message });
84
-    //   });
78
+    setSearchValue('')
79
+    form.resetFields()
80
+
85 81
   };
86 82
 
87 83
   return (
@@ -101,6 +97,8 @@ const VisitEdit = (props) => {
101 97
               <School value={school} onChange={handleSchoolChange} style={{ width: 200, marginBottom: '20px' }} allowClear />
102 98
               <Search
103 99
                 placeholder="请输入学号"
100
+                value={searchValue}
101
+                onChange={(e)=>setSearchValue(e.value)}
104 102
                 loading={searchLoading}
105 103
                 style={{ width: 200, marginBottom: '20px' }}
106 104
                 onSearch={onSearch}

+ 1
- 1
src/pages/Medical/Visit/List/index.jsx View File

@@ -102,7 +102,7 @@ const VisitList = () => {
102 102
       title: '专业',
103 103
       dataIndex: 'specialtyId',
104 104
       align: 'center',
105
-      render: (_, row) => row.specialtyName,
105
+      render: (_, row) => row.specialtyName||'-',
106 106
       renderFormItem: (item, config, form) => {
107 107
         const schoolId = form.getFieldValue('schoolId');
108 108
         return <Specialty schoolid={schoolId} disabled={!schoolId}></Specialty>;