张延森 4 年 前
コミット
0a180652cf
共有6 個のファイルを変更した251 個の追加14 個の削除を含む
  1. 6
    7
      config/routes.js
  2. 64
    0
      src/components/School/index.jsx
  3. 173
    0
      src/pages/Medical/Hospital/index.jsx
  4. 6
    6
      src/pages/System/Params/index.jsx
  5. 1
    1
      src/pages/System/Role/Edit.jsx
  6. 1
    0
      src/pages/User/List/index.jsx

+ 6
- 7
config/routes.js ファイルの表示

@@ -181,6 +181,12 @@ export default [
181 181
                     menuCode: 'medical.test',
182 182
                     hideInMenu: true,
183 183
                     component: './Medical/Test/Edit',
184
+                  },              
185
+                  {
186
+                    path: '/medical/hospital',
187
+                    name: '诊室管理',
188
+                    menuCode: 'medical.hospital',
189
+                    component: './Medical/Hospital',
184 190
                   },
185 191
                 ],
186 192
               },
@@ -244,13 +250,6 @@ export default [
244 250
                     menuCode: 'system.params',
245 251
                     component: './System/Params',
246 252
                   },
247
-              
248
-                  {
249
-                    path: '/system/clinic',
250
-                    name: '诊室管理',
251
-                    menuCode: 'system.clinic',
252
-                    component: '../layouts/BlankLayout',
253
-                  },
254 253
                 ],
255 254
               },
256 255
               {

+ 64
- 0
src/components/School/index.jsx ファイルの表示

@@ -0,0 +1,64 @@
1
+import React, { useEffect, useState } from 'react'
2
+import { Select, Spin } from 'antd'
3
+import request from '@/utils/request'
4
+
5
+export default (props) => {
6
+  const [loading, setLoading] = useState(false)
7
+  const [list, setList] = useState([])
8
+  const [value, setValue] = useState()
9
+
10
+  const filterFunc = (input, option) => {
11
+    return option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
12
+  }
13
+
14
+  const handleChange = (val) => {
15
+    setValue(val)
16
+    const school = list.filter((s) => s.schoolId === val)[0]
17
+
18
+    props.onChange(val, school)
19
+  }
20
+
21
+  useEffect(() => {
22
+    if (props.value !== value) {
23
+      setValue(props.value)
24
+    }
25
+  }, [props.value, value])
26
+
27
+  useEffect(() => {
28
+    setLoading(true)
29
+    request('/school', { params: { pageSize: 100 } }).then(res => {
30
+      const records = res.records || []
31
+      setList(records)
32
+      setLoading(false)
33
+
34
+      if (props.autoDefault !== false && records.length > 0) {
35
+        setValue(records[0].schoolId)
36
+        props.onChange(records[0].schoolId, records[0])
37
+      }
38
+
39
+    }).catch((e) => {
40
+      // eslint-disable-next-line
41
+      console.error(e.message)
42
+      setLoading(false)
43
+    })
44
+
45
+  // eslint-disable-next-line
46
+  }, [])
47
+
48
+  return (
49
+    <Spin spinning={loading}>
50
+      <Select
51
+        showSearch
52
+        optionFilterProp="children"
53
+        filterOption={filterFunc}
54
+        {...props}
55
+        value={value}
56
+        onChange={handleChange}
57
+      >
58
+      {
59
+        list.map((s) => (<Select.Option key={s.schoolId} value={s.schoolId}>{s.name}</Select.Option>))
60
+      }
61
+      </Select>
62
+    </Spin>
63
+  )
64
+}

+ 173
- 0
src/pages/Medical/Hospital/index.jsx ファイルの表示

@@ -0,0 +1,173 @@
1
+import React, { useRef, useState } from 'react';
2
+import { PageContainer } from '@ant-design/pro-layout';
3
+import ProTable from '@ant-design/pro-table';
4
+import { Button, Modal, Input, notification } from 'antd';
5
+import { PlusOutlined } from '@ant-design/icons';
6
+import request, { queryTable } from '@/utils/request';
7
+import School from '@/components/School';
8
+
9
+export default () => {
10
+  const tableRef = useRef();
11
+  const [school, setSchool] = useState();
12
+  const [current, setCurrent] = useState();
13
+  const [inputVal, setInputVal] = useState([]);
14
+  const [show, setShow] = useState(false);
15
+
16
+  const queryFunc = (params, page, sort, filter) => {
17
+    if (!school.schoolId) {
18
+      return Promise.resolve({ data: [], success: true, total: 0 });
19
+    }
20
+
21
+    const newParams = { ...params, schoolId: school.schoolId };
22
+    return queryTable('/hospital')(newParams, page, sort, filter);
23
+  };
24
+
25
+  const handleEdit = (hospital) => {
26
+    setCurrent(hospital);
27
+    setInputVal(hospital.name);
28
+    setShow(true);
29
+  };
30
+
31
+  const handleAdd = () => {
32
+    setCurrent();
33
+    setInputVal();
34
+    setShow(true);
35
+  };
36
+
37
+  const changeStatus = (hospital) => {
38
+    // 0 变 1, 1 变 0
39
+    // eslint-disable-next-line no-bitwise
40
+    const status = hospital.status ^ 1;
41
+    const data = { ...hospital, status }
42
+
43
+    request(`/hospital/${hospital.hospitalId}`, {
44
+      method: 'put',
45
+      data,
46
+    })
47
+      .then(() => {
48
+        tableRef.current.reload();
49
+        notification.success({ message: '操作成功' });
50
+      })
51
+      .catch((e) => {
52
+        notification.error({ message: e.message });
53
+      });
54
+
55
+
56
+  };
57
+
58
+  const renderFormItem = (item, config, form) => {
59
+    const handleSchoolChange = (schoolId, schoolInfo) => {
60
+      form.setFieldsValue({ schoolId });
61
+      form.submit();
62
+      setSchool(schoolInfo);
63
+    };
64
+
65
+    return <School onChange={handleSchoolChange} />;
66
+  };
67
+
68
+  const columns = [
69
+    {
70
+      title: '所属学校',
71
+      key: 'schoolId',
72
+      dataIndex: 'schoolId',
73
+      hideInTable: true,
74
+      valueType: 'select',
75
+      renderFormItem,
76
+    },
77
+    {
78
+      title: '诊室名称',
79
+      key: 'name',
80
+      dataIndex: 'name',
81
+    },
82
+    {
83
+      title: '状态',
84
+      key: 'status',
85
+      dataIndex: 'status',
86
+      valueEnum: {
87
+        0: { text: '未启用', status: 'Default' },
88
+        1: { text: '启用', status: 'Success' },
89
+      },
90
+      hideInSearch: true,
91
+    },
92
+    {
93
+      title: '创建日期',
94
+      key: 'createDate',
95
+      dataIndex: 'createDate',
96
+      valueType: 'date',
97
+      hideInSearch: true,
98
+    },
99
+    {
100
+      title: '操作',
101
+      key: 'option',
102
+      valueType: 'option',
103
+      width: 180,
104
+      render: (_, hospital) => [
105
+        <a key="edit" onClick={() => handleEdit(hospital)}>
106
+          修改
107
+        </a>,
108
+        <a key="status" onClick={() => changeStatus(hospital)}>
109
+          {hospital.status === 1 ? '弃用' : '启用'}
110
+        </a>,
111
+      ],
112
+    },
113
+  ];
114
+
115
+  const handleSubmit = () => {
116
+    setShow(false);
117
+
118
+    if (!inputVal) {
119
+      return;
120
+    }
121
+
122
+    if (current && current.hospitalId) {
123
+      request(`/hospital/${current.hospitalId}`, {
124
+        method: 'put',
125
+        data: { ...current, name: inputVal },
126
+      })
127
+        .then(() => {
128
+          tableRef.current.reload();
129
+          notification.success({ message: '修改成功' });
130
+        })
131
+        .catch((e) => {
132
+          notification.error({ message: e.message });
133
+        });
134
+    } else {
135
+      request('/hospital', { method: 'post', data: { schoolId: school.schoolId, name: inputVal } })
136
+        .then(() => {
137
+          tableRef.current.reload();
138
+          notification.success({ message: '修改成功' });
139
+        })
140
+        .catch((e) => {
141
+          notification.error({ message: e.message });
142
+        });
143
+    }
144
+  };
145
+
146
+  const actions = [
147
+    <Button key="button" icon={<PlusOutlined />} type="primary" onClick={handleAdd}>
148
+      新建
149
+    </Button>,
150
+  ];
151
+
152
+  return (
153
+    <PageContainer>
154
+      <ProTable
155
+        manualRequest
156
+        actionRef={tableRef}
157
+        columns={columns}
158
+        request={queryFunc}
159
+        rowKey="schoolId"
160
+        headerTitle="诊室列表"
161
+        toolBarRender={() => actions}
162
+      />
163
+      <Modal
164
+        title={school?.name}
165
+        visible={show}
166
+        onOk={handleSubmit}
167
+        onCancel={() => setShow(false)}
168
+      >
169
+        <Input size="large" value={inputVal} onChange={(e) => setInputVal(e.target.value)} />
170
+      </Modal>
171
+    </PageContainer>
172
+  );
173
+};

+ 6
- 6
src/pages/System/Params/index.jsx ファイルの表示

@@ -10,6 +10,12 @@ export default () => {
10 10
   const [inputVal, setInputVal] = useState([])
11 11
   const [show, setShow] = useState(false)
12 12
 
13
+  const handleEdit = (config) => {
14
+    setCurrent(config)
15
+    setInputVal(config.value)
16
+    setShow(true)
17
+  }
18
+
13 19
   const columns = [
14 20
     {
15 21
       title: '编码',
@@ -37,12 +43,6 @@ export default () => {
37 43
     },
38 44
   ]
39 45
 
40
-  const handleEdit = (config) => {
41
-    setCurrent(config)
42
-    setInputVal(config.value)
43
-    setShow(true)
44
-  }
45
-
46 46
   const handleSubmit = () => {
47 47
     setShow(false)
48 48
     request(`/sys-config/${current.serialNo}`, { method: 'put', data: { ...current, value: inputVal } }).then(() => {

+ 1
- 1
src/pages/System/Role/Edit.jsx ファイルの表示

@@ -1,6 +1,6 @@
1 1
 import React, { useState, useEffect } from 'react'
2 2
 import { PageContainer } from '@ant-design/pro-layout';
3
-import { Button, Card, Divider, notification } from 'antd';
3
+import { Button, Card, notification } from 'antd';
4 4
 import request from '@/utils/request';
5 5
 import RoleForm from './components/Form'
6 6
 import RoleMenu from './components/Menu'

+ 1
- 0
src/pages/User/List/index.jsx ファイルの表示

@@ -25,6 +25,7 @@ export default () => {
25 25
 
26 26
   const changeStatus = (user) => {
27 27
     // 0 变 1, 1 变 0
28
+    // eslint-disable-next-line no-bitwise
28 29
     const status = user.status ^ 1
29 30
     request(`/user/${user.userId}`, { method: 'put', data: { ...user, status } } ).then(() => {
30 31
       notification.success({ message: '操作成功' })