index.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. import React, { useState, useEffect } from 'react';
  2. import { Spin,Form, Input, Button, Table, Select, Space, Modal, message, Row, Col } from 'antd';
  3. import { PlusOutlined } from '@ant-design/icons';
  4. import AddTerm from '../DiagManager/addDiag'
  5. import { getCookie } from '@utils/index'
  6. import '@common/common.less';
  7. import apiObj from '@api/index';
  8. const { post, api } = apiObj;
  9. const { Option } = Select;
  10. //获取列表
  11. function SurgManager() {
  12. useEffect(() => {
  13. getSurgeryPage();
  14. }, []);
  15. const [SurgList, setSurgList] = useState([]);//当前页列表数据
  16. const [Surgid, setSurgid] = useState([]);//当前操作行id
  17. const [title, setTitle] = useState("");//新增/修改的弹窗标题
  18. const [visible, setVisible] = useState(false);//新增修改 弹窗
  19. const [loading, setloading] = useState(true);//是否显示加载中
  20. const [flag, setFlag] = useState(false);//新增1或修改3
  21. const [delvisible, setDelvisible] = useState(false);//删除 弹窗
  22. const [formData, setFormData] = useState({});//当前行数据
  23. const [size, setSize] = useState(15);//每页显示条数
  24. const [total, setTotal] = useState(0);
  25. const [current, setCurrent] = useState(1);//当前页
  26. const [params, setParams] = useState({
  27. pages: 1,
  28. current: 1,
  29. size: 15
  30. });
  31. const [form] = Form.useForm();
  32. let data = {
  33. pages: 1,
  34. current: 1,
  35. size: size
  36. }
  37. //新增/修改 弹窗flag=1新增,3修改
  38. const showModal = (name, flag1, Surgrow) => {
  39. setVisible(true);
  40. setFlag(flag1)
  41. setTitle(name);console.log(flag)
  42. if (flag1 === 1) {
  43. setFormData({
  44. status: 1
  45. })
  46. }else if (flag1 === 3) {
  47. console.log(33,Surgrow)
  48. setFormData(Surgrow)
  49. }
  50. }
  51. //表格数据
  52. function getSurgeryPage(param) { //type(必填): 类型:1-化验、3-辅检、4-诊断、5-药品、6-手术和操作
  53. const hospitalId = getCookie('hospitalId')
  54. setloading(true)
  55. post(api.getTermPage, {...(param || params),type:6,hospitalId:hospitalId}).then((res) => {
  56. if (res.data.code === 200) {
  57. const data = res.data.data;
  58. setSurgList(data.records);
  59. setTotal(data.total)
  60. setloading(false)
  61. }
  62. })
  63. }
  64. function showDelModal(id){
  65. setDelvisible(true);
  66. setSurgid(id);
  67. }
  68. //删除
  69. function delSurgeryById() {
  70. post(api.deleteRecord, { id: Surgid }).then((res) => {
  71. setDelvisible(false);
  72. if (res.data.code === 200) {
  73. getSurgeryPage();
  74. setSurgid("");
  75. message.success("删除成功");
  76. } else {
  77. message.warning(res.data.msg || '操作失败');
  78. }
  79. }).catch(() => {
  80. setDelvisible(false);
  81. message.error("接口出错");
  82. });
  83. }
  84. //每页显示条数切换
  85. function onSizeChange(current, pageSize) {
  86. params.current = current
  87. params.size = pageSize
  88. setSize(pageSize)
  89. setCurrent(current)
  90. setParams(params)
  91. getSurgeryPage()
  92. }
  93. //翻页
  94. function changePage(page, pageSize) {
  95. params.current = page
  96. params.size = pageSize
  97. setCurrent(page)
  98. setParams(params)
  99. getSurgeryPage()
  100. }
  101. //筛选查询
  102. const onFinish = (value) => {
  103. const param = {
  104. ...data,
  105. ...value
  106. }
  107. setCurrent(1)
  108. setParams(param)
  109. getSurgeryPage(param);
  110. };
  111. //重置
  112. const onReset = () => {
  113. setCurrent(1)
  114. setParams(data)
  115. form.resetFields();
  116. getSurgeryPage(data);
  117. };
  118. //删除 提示框取消或关闭
  119. function handleCancel() {
  120. setDelvisible(false);
  121. }
  122. //新增修改 取消或关闭
  123. function cancel() {
  124. setVisible(false)
  125. setFormData([])
  126. }
  127. function saveMatching(saveParams) {
  128. post(api.saveOrUpdateRecord, saveParams).then((res) => {
  129. if (res.data.code === 200) {
  130. message.success("匹配成功");
  131. setVisible(false);
  132. setFormData([])
  133. getSurgeryPage();
  134. } else {
  135. message.warning(res.data.message || "匹配失败,请重试");
  136. }
  137. }).catch((error) => {
  138. message.warning(error.message || "接口出错,请重试",);
  139. })
  140. }
  141. const columns = [
  142. { title: '序号', dataIndex: 'index', render: (text, record, index) => (current - 1) * params.size + index + 1 },
  143. { title: '操作时间', dataIndex: 'gmtModified', },
  144. { title: '医院手术/操作名称', dataIndex: 'hisName', },
  145. { title: 'ICD-10编码', dataIndex: 'code', },
  146. { title: '标准手术/操作名称', dataIndex: 'uniqueName', },
  147. { title: '标准术语状态', dataIndex: 'status',render: (text, record) => {
  148. return record.status===1?'启用':record.status?'禁用':'';
  149. }},
  150. { title: '是否匹配', dataIndex: 'isMatch',render: (text, record) => {
  151. return record.isMatch===1?'已匹配':'未匹配';
  152. }},
  153. {
  154. title: '操作', dataIndex: 'key', render: (text, record) => (
  155. <Space size="middle">
  156. <a onClick={e => showModal('修改手术/操作信息',3, record)}>修改</a>
  157. <a onClick={() => showDelModal(record.id)}>删除</a>
  158. </Space>
  159. )
  160. }
  161. ]
  162. return (
  163. <div className="wrapper">
  164. <div className="filter-box">
  165. <Form
  166. form={form}
  167. name="normal_login"
  168. onFinish={onFinish}
  169. >
  170. <Row gutter={24}>
  171. <Col span={5} key={0}>
  172. <Form.Item label="医院手术/操作名称" name="hisName">
  173. <Input placeholder="请输入" autoComplete='off' allowClear/>
  174. </Form.Item>
  175. </Col>
  176. <Col span={5} key={1}>
  177. <Form.Item label="ICD-10编码" name="hisCode">
  178. <Input placeholder="请输入" autoComplete='off' allowClear/>
  179. </Form.Item>
  180. </Col>
  181. <Col span={5} key={2}>
  182. <Form.Item label="标准手术/操作名称" name="uniqueName">
  183. <Input placeholder="请输入" autoComplete='off' allowClear/>
  184. </Form.Item>
  185. </Col>
  186. <Col span={5} key={3}>
  187. <Form.Item id="groupTypeval" label="是否匹配" name="isMatch">
  188. <Select
  189. showSearch
  190. optionFilterProp="children"
  191. // onSearch={onSearch}
  192. // onFocus={onFocus}
  193. placeholder="全部"
  194. >
  195. <Option value={''} key={-1}>全部</Option>
  196. <Option value={0} key={0}>未匹配</Option>
  197. <Option value={1} key={1}>已匹配</Option>
  198. </Select>
  199. </Form.Item>
  200. </Col>
  201. <Col span={5} key={4}>
  202. <Form.Item label="标准术语状态" name="status">
  203. <Select
  204. showSearch
  205. optionFilterProp="children"
  206. placeholder="全部"
  207. >
  208. <Option value={''} key={-1}>全部</Option>
  209. <Option value={0} key={0}>禁用</Option>
  210. <Option value={1} key={1}>启用</Option>
  211. </Select>
  212. </Form.Item>
  213. </Col>
  214. <Col span={5} key={5}>
  215. <Form.Item>
  216. <Button type="primary" htmlType="submit">
  217. 查询
  218. </Button>
  219. <Button onClick={onReset}>
  220. 重置
  221. </Button>
  222. </Form.Item>
  223. </Col>
  224. </Row>
  225. </Form>
  226. </div>
  227. <div className="table">
  228. <div className="table-header">
  229. <h2 className="table-title">手术/操作信息维护</h2>
  230. <Row gutter={12}>
  231. <Col key={0}>
  232. <Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增手术/操作信息',1)}>新增</Button>
  233. </Col>
  234. </Row>
  235. </div>
  236. <Spin tip="加载中..." spinning={loading}>
  237. <Table
  238. /*rowSelection={{ type: 'checkbox', ...rowSelection, }}*/
  239. columns={columns}
  240. scroll={{ y: 'calc(100vh - 400px)' }}
  241. dataSource={SurgList}
  242. rowKey={record => record.id}
  243. pagination={{
  244. current: current,
  245. pageSize: size,
  246. size: 'small',
  247. showSizeChanger: true,
  248. pageSizeOptions: ['15', '30', '60', '120'],
  249. showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
  250. onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
  251. onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
  252. total: total
  253. }} />
  254. </Spin>
  255. </div>
  256. <AddTerm formData={formData} termSType={106} termType={6} onOk={saveMatching} title={title} visible={visible} cancel={cancel} flag={flag}/>
  257. <Modal
  258. maskClosable={false}
  259. title="删除手术/操作信息"
  260. okText='确定'
  261. cancelText='关闭'
  262. width={400}
  263. visible={delvisible}
  264. onOk={delSurgeryById}
  265. onCancel={handleCancel}
  266. >
  267. <p>手术信息删除后将无法恢复,确认删除这条手术信息。</p>
  268. </Modal>
  269. </div>
  270. )
  271. }
  272. export default SurgManager;