index.js 9.8 KB

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