|
@@ -1,19 +1,184 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import { connect } from 'umi';
|
|
1
|
+import React, { useEffect, useState } from 'react';
|
|
2
|
+import { connect, history } from 'umi';
|
|
3
|
+import ProCard from '@ant-design/pro-card';
|
3
|
4
|
import { PageContainer } from '@ant-design/pro-layout';
|
|
5
|
+import Container from '@/components/Container';
|
|
6
|
+import { Input, Select, Form, Button, notification } from 'antd';
|
|
7
|
+import ProForm, { ProFormText, ProFormTextArea, ProFormSelect } from '@ant-design/pro-form';
|
|
8
|
+import request from '@/utils/request';
|
4
|
9
|
|
5
|
|
-const VisitList = () => {
|
|
10
|
+const { Option } = Select;
|
|
11
|
+const { Search } = Input;
|
|
12
|
+const VisitEdit = (props) => {
|
|
13
|
+ const { id, schoolId } = props.location.query;
|
|
14
|
+ const [list, setList] = useState([]);
|
|
15
|
+ const [searchLoading, setSearchLoading] = useState(false);
|
6
|
16
|
|
|
17
|
+ const [form] = Form.useForm();
|
7
|
18
|
|
8
|
|
-
|
|
19
|
+ const getData = (id) => {
|
|
20
|
+ if (id) {
|
|
21
|
+ request(`/student/${id}`)
|
|
22
|
+ .then((res) => {
|
|
23
|
+ console.log(res, 'res');
|
|
24
|
+ form.setFieldsValue(res);
|
|
25
|
+ setSearchLoading(false);
|
|
26
|
+ })
|
|
27
|
+ .catch((e) => {
|
|
28
|
+ setSearchLoading(false);
|
|
29
|
+ });
|
|
30
|
+ } else {
|
|
31
|
+ // this.setState({ data: [] });
|
|
32
|
+ }
|
|
33
|
+ };
|
9
|
34
|
|
|
35
|
+ useEffect(()=>{
|
|
36
|
+if(id){
|
|
37
|
+ if (id) {
|
|
38
|
+ request(`/medical-log/${id}`)
|
|
39
|
+ .then((res) => {
|
|
40
|
+ console.log(res, 'res');
|
|
41
|
+ form.setFieldsValue(res);
|
|
42
|
+ setSearchLoading(false);
|
|
43
|
+ })
|
|
44
|
+ .catch((e) => {
|
|
45
|
+ setSearchLoading(false);
|
|
46
|
+ });
|
|
47
|
+ } else {
|
|
48
|
+ // this.setState({ data: [] });
|
|
49
|
+ }
|
|
50
|
+}
|
|
51
|
+ },[id])
|
|
52
|
+
|
|
53
|
+ const onSearch = (value) => {
|
|
54
|
+ if (value) {
|
|
55
|
+ getData(value);
|
|
56
|
+ setSearchLoading(true);
|
|
57
|
+ } else {
|
|
58
|
+ // this.setState({ data: [] });
|
|
59
|
+ }
|
|
60
|
+ };
|
|
61
|
+
|
|
62
|
+ const handleChange = (value) => {
|
|
63
|
+ // this.setState({ value });
|
|
64
|
+ };
|
|
65
|
+ const handleSubmit = (value) => {
|
|
66
|
+ // this.setState({ value });
|
|
67
|
+ console.log(value, 'handleSubmit');
|
|
68
|
+ request('/medicalLog', { method: 'post', data: {schoolId, ...value } })
|
|
69
|
+ .then(() => {
|
|
70
|
+
|
|
71
|
+ notification.success({ message: '新建成功' });
|
|
72
|
+ history.go('-1')
|
|
73
|
+ })
|
|
74
|
+ .catch((e) => {
|
|
75
|
+ notification.error({ message: e.message });
|
|
76
|
+ });
|
|
77
|
+ };
|
10
|
78
|
return (
|
11
|
|
- <PageContainer>
|
12
|
|
- 234
|
|
79
|
+ <PageContainer
|
|
80
|
+ header={{
|
|
81
|
+ extra: [
|
|
82
|
+ <Button key="1" onClick={() => history.go('-1')}>
|
|
83
|
+ 返回
|
|
84
|
+ </Button>,
|
|
85
|
+ ],
|
|
86
|
+ }}
|
|
87
|
+ >
|
|
88
|
+ <Container>
|
|
89
|
+ <ProForm form={form} submitter={!id} onFinish={handleSubmit}>
|
|
90
|
+ <ProCard.Group title="就诊信息" bodyStyle={{ padding: 20 }}>
|
|
91
|
+ {!id && (
|
|
92
|
+ <Search
|
|
93
|
+ placeholder="请输入学号"
|
|
94
|
+ loading={searchLoading}
|
|
95
|
+ style={{ width: 200, marginBottom: '20px' }}
|
|
96
|
+ onSearch={onSearch}
|
|
97
|
+ />
|
|
98
|
+ )}
|
|
99
|
+
|
|
100
|
+ <ProFormText
|
|
101
|
+ label="姓名"
|
|
102
|
+ placeholder="输入名称"
|
|
103
|
+ name="name"
|
|
104
|
+ fieldProps={{ bordered: !id, readOnly: !!id }}
|
|
105
|
+ rules={[{ required: true, message: '请填写名称' }]}
|
|
106
|
+ />
|
|
107
|
+
|
|
108
|
+ <ProFormSelect
|
|
109
|
+ options={[
|
|
110
|
+ {
|
|
111
|
+ value: 1,
|
|
112
|
+ label: '男',
|
|
113
|
+ },
|
|
114
|
+ {
|
|
115
|
+ value: 2,
|
|
116
|
+ label: '女',
|
|
117
|
+ },
|
|
118
|
+ ]}
|
|
119
|
+ name="sex"
|
|
120
|
+ label="性别"
|
|
121
|
+ fieldProps={{ bordered: !id, open: id ? false : undefined }}
|
|
122
|
+ rules={[{ required: true, message: '请选择性别' }]}
|
|
123
|
+ />
|
|
124
|
+
|
|
125
|
+ <ProFormText
|
|
126
|
+ label="学号"
|
|
127
|
+ placeholder="输入学号"
|
|
128
|
+ name="studentId"
|
|
129
|
+ fieldProps={{ bordered: !id, readOnly: !!id }}
|
|
130
|
+ rules={[{ required: true, message: '请填写学号' }]}
|
|
131
|
+ />
|
|
132
|
+
|
|
133
|
+ <ProFormText
|
|
134
|
+ label="联系方式"
|
|
135
|
+ placeholder="输入联系方式"
|
|
136
|
+ name="phone"
|
|
137
|
+ fieldProps={{ bordered: !id, readOnly: !!id }}
|
|
138
|
+ rules={[{ required: true, message: '请填写联系方式' }]}
|
|
139
|
+ />
|
|
140
|
+ </ProCard.Group>
|
|
141
|
+ <ProCard.Group title="诊断" bodyStyle={{ padding: 20 }}>
|
|
142
|
+ <ProFormSelect
|
|
143
|
+ label="就诊科室"
|
|
144
|
+ placeholder="输选择"
|
|
145
|
+ name="hospitalId"
|
|
146
|
+ fieldProps={{ bordered: !id, open: id ? false : undefined }}
|
|
147
|
+ request={async ({ keyWords }) => {
|
|
148
|
+ // console.log()
|
|
149
|
+ // if (keyWords) {
|
|
150
|
+ return request('/hospital', {
|
|
151
|
+ method: 'get',
|
|
152
|
+ params: { name: keyWords, schoolId, pageNum: 1, pageSize: 1000 },
|
|
153
|
+ })
|
|
154
|
+ .then((res) => {
|
|
155
|
+ return res?.records?.map((x) => {
|
|
156
|
+ return { label: x.name, value: x.hospitalId };
|
|
157
|
+ });
|
|
158
|
+ })
|
|
159
|
+ .catch((e) => {
|
|
160
|
+ return Promise.reject(e.message);
|
|
161
|
+ });
|
|
162
|
+ // }
|
|
163
|
+ }}
|
|
164
|
+ rules={[{ required: true, message: '请选择科室' }]}
|
|
165
|
+ />
|
|
166
|
+
|
|
167
|
+ <ProFormTextArea
|
|
168
|
+ label="诊断报告"
|
|
169
|
+ placeholder="输入诊断报告"
|
|
170
|
+ name="attchment"
|
|
171
|
+
|
|
172
|
+ fieldProps={{readOnly: !!id }}
|
|
173
|
+ rules={[{ required: true, message: '请填写诊断报告' }]}
|
|
174
|
+ />
|
|
175
|
+ </ProCard.Group>
|
|
176
|
+ </ProForm>
|
|
177
|
+ </Container>
|
13
|
178
|
</PageContainer>
|
14
|
179
|
);
|
15
|
180
|
};
|
16
|
181
|
|
17
|
182
|
export default connect((s) => ({
|
18
|
183
|
typeList: s.post.typeList,
|
19
|
|
-}))(VisitList);
|
|
184
|
+}))(VisitEdit);
|