index.js 9.2 KB

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