|
@@ -1,51 +1,59 @@
|
1
|
|
-import React, { useState } from 'react';
|
|
1
|
+import React, { useEffect, useState } from 'react';
|
2
|
2
|
import { connect, history } from 'umi';
|
3
|
3
|
import ProCard from '@ant-design/pro-card';
|
4
|
4
|
import { PageContainer } from '@ant-design/pro-layout';
|
5
|
5
|
import Container from '@/components/Container';
|
6
|
|
-import { Input, Select, Form, Button } from 'antd';
|
|
6
|
+import { Input, Select, Form, Button, notification } from 'antd';
|
7
|
7
|
import ProForm, { ProFormText, ProFormTextArea, ProFormSelect } from '@ant-design/pro-form';
|
8
|
8
|
import request from '@/utils/request';
|
9
|
9
|
|
10
|
10
|
const { Option } = Select;
|
11
|
11
|
const { Search } = Input;
|
12
|
|
-const VisitEdit = () => {
|
|
12
|
+const VisitEdit = (props) => {
|
|
13
|
+ const { id, schoolId } = props.location.query;
|
13
|
14
|
const [list, setList] = useState([]);
|
14
|
15
|
const [searchLoading, setSearchLoading] = useState(false);
|
15
|
16
|
|
16
|
17
|
const [form] = Form.useForm();
|
17
|
|
- // state = {
|
18
|
|
- // data: [],
|
19
|
|
- // value: undefined,
|
20
|
|
- // };
|
21
|
18
|
|
22
|
|
- // const changeStatus = (hospital) => {
|
23
|
|
- // // 0 变 1, 1 变 0
|
24
|
|
- // // eslint-disable-next-line no-bitwise
|
25
|
|
- // const status = hospital.status ^ 1;
|
26
|
|
- // const data = { ...hospital, status }
|
27
|
|
-
|
28
|
|
- // request(`/hospital/${hospital.hospitalId}`, {
|
29
|
|
- // method: 'put',
|
30
|
|
- // data,
|
31
|
|
- // })
|
32
|
|
- // .then(() => {
|
33
|
|
- // tableRef.current.reload();
|
34
|
|
- // notification.success({ message: '操作成功' });
|
35
|
|
- // })
|
36
|
|
- // .catch((e) => {
|
37
|
|
- // notification.error({ message: e.message });
|
38
|
|
- // });
|
|
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
|
+ };
|
39
|
34
|
|
40
|
|
- // };
|
|
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])
|
41
|
52
|
|
42
|
53
|
const onSearch = (value) => {
|
43
|
54
|
if (value) {
|
44
|
|
- request(`/student/${value}`)
|
45
|
|
- .then((res) => {
|
46
|
|
- form.setFieldsValue(res)
|
47
|
|
- })
|
48
|
|
- .catch((e) => {});
|
|
55
|
+ getData(value);
|
|
56
|
+ setSearchLoading(true);
|
49
|
57
|
} else {
|
50
|
58
|
// this.setState({ data: [] });
|
51
|
59
|
}
|
|
@@ -56,6 +64,16 @@ const VisitEdit = () => {
|
56
|
64
|
};
|
57
|
65
|
const handleSubmit = (value) => {
|
58
|
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
|
+ });
|
59
|
77
|
};
|
60
|
78
|
return (
|
61
|
79
|
<PageContainer
|
|
@@ -68,87 +86,91 @@ const VisitEdit = () => {
|
68
|
86
|
}}
|
69
|
87
|
>
|
70
|
88
|
<Container>
|
71
|
|
- <ProForm form={form} onFinish={handleSubmit}>
|
|
89
|
+ <ProForm form={form} submitter={!id} onFinish={handleSubmit}>
|
72
|
90
|
<ProCard.Group title="就诊信息" bodyStyle={{ padding: 20 }}>
|
73
|
|
- <Search
|
74
|
|
- placeholder="请输入学号"
|
75
|
|
- loading={searchLoading}
|
76
|
|
- style={{ width: 200 }}
|
77
|
|
- onSearch={onSearch}
|
78
|
|
- />
|
|
91
|
+ {!id && (
|
|
92
|
+ <Search
|
|
93
|
+ placeholder="请输入学号"
|
|
94
|
+ loading={searchLoading}
|
|
95
|
+ style={{ width: 200, marginBottom: '20px' }}
|
|
96
|
+ onSearch={onSearch}
|
|
97
|
+ />
|
|
98
|
+ )}
|
79
|
99
|
|
80
|
100
|
<ProFormText
|
81
|
101
|
label="姓名"
|
82
|
102
|
placeholder="输入名称"
|
83
|
103
|
name="name"
|
|
104
|
+ fieldProps={{ bordered: !id, readOnly: !!id }}
|
84
|
105
|
rules={[{ required: true, message: '请填写名称' }]}
|
85
|
106
|
/>
|
86
|
107
|
|
87
|
108
|
<ProFormSelect
|
88
|
109
|
options={[
|
89
|
110
|
{
|
90
|
|
- value: '6',
|
91
|
|
- label: '6%',
|
|
111
|
+ value: 1,
|
|
112
|
+ label: '男',
|
92
|
113
|
},
|
93
|
114
|
{
|
94
|
|
- value: '12',
|
95
|
|
- label: '12%',
|
|
115
|
+ value: 2,
|
|
116
|
+ label: '女',
|
96
|
117
|
},
|
97
|
118
|
]}
|
98
|
|
- initialValue="6"
|
99
|
|
- name="taxRate"
|
|
119
|
+ name="sex"
|
100
|
120
|
label="性别"
|
|
121
|
+ fieldProps={{ bordered: !id, open: id ? false : undefined }}
|
|
122
|
+ rules={[{ required: true, message: '请选择性别' }]}
|
101
|
123
|
/>
|
102
|
124
|
|
103
|
125
|
<ProFormText
|
104
|
126
|
label="学号"
|
105
|
|
- placeholder="输入名称"
|
106
|
|
- name="name"
|
107
|
|
- rules={[{ required: true, message: '请填写名称' }]}
|
|
127
|
+ placeholder="输入学号"
|
|
128
|
+ name="studentId"
|
|
129
|
+ fieldProps={{ bordered: !id, readOnly: !!id }}
|
|
130
|
+ rules={[{ required: true, message: '请填写学号' }]}
|
108
|
131
|
/>
|
109
|
132
|
|
110
|
133
|
<ProFormText
|
111
|
134
|
label="联系方式"
|
112
|
|
- placeholder="输入名称"
|
113
|
|
- name="name"
|
114
|
|
- rules={[{ required: true, message: '请填写名称' }]}
|
|
135
|
+ placeholder="输入联系方式"
|
|
136
|
+ name="phone"
|
|
137
|
+ fieldProps={{ bordered: !id, readOnly: !!id }}
|
|
138
|
+ rules={[{ required: true, message: '请填写联系方式' }]}
|
115
|
139
|
/>
|
116
|
|
-
|
117
|
|
- {/* {list.map((d) => (
|
118
|
|
- <Option key={d.value}>{d.text}</Option>
|
119
|
|
- ))} */}
|
120
|
|
- {/* {options} */}
|
121
|
|
-
|
122
|
|
- {/* <ProFormSelect
|
123
|
|
- options={[
|
124
|
|
- {
|
125
|
|
- value: '6',
|
126
|
|
- label: '6%',
|
127
|
|
- },
|
128
|
|
- {
|
129
|
|
- value: '12',
|
130
|
|
- label: '12%',
|
131
|
|
- },
|
132
|
|
- ]}
|
133
|
|
- initialValue="6"
|
134
|
|
- width="xs"
|
135
|
|
- name="taxRate"
|
136
|
|
- label="税率"
|
137
|
|
- /> */}
|
138
|
140
|
</ProCard.Group>
|
139
|
141
|
<ProCard.Group title="诊断" bodyStyle={{ padding: 20 }}>
|
140
|
|
- <ProFormText
|
|
142
|
+ <ProFormSelect
|
141
|
143
|
label="就诊科室"
|
142
|
|
- placeholder="输入名称"
|
143
|
|
- name="name"
|
144
|
|
- rules={[{ required: true, message: '请填写名称' }]}
|
|
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: '请选择科室' }]}
|
145
|
165
|
/>
|
146
|
166
|
|
147
|
167
|
<ProFormTextArea
|
148
|
168
|
label="诊断报告"
|
149
|
|
- placeholder="输入简介"
|
150
|
|
- name="desc"
|
151
|
|
- rules={[{ required: true, message: '请填写简介' }]}
|
|
169
|
+ placeholder="输入诊断报告"
|
|
170
|
+ name="attchment"
|
|
171
|
+
|
|
172
|
+ fieldProps={{readOnly: !!id }}
|
|
173
|
+ rules={[{ required: true, message: '请填写诊断报告' }]}
|
152
|
174
|
/>
|
153
|
175
|
</ProCard.Group>
|
154
|
176
|
</ProForm>
|