index.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. import React, { useState, useEffect } from 'react';
  2. import { useSelector } from 'react-redux';
  3. import { Empty, ConfigProvider, Form, Input, Button, Table, Select, Space, Modal, message, Row, Col } from 'antd';
  4. import { PlusOutlined } from '@ant-design/icons';
  5. import AddTerm from '../DiagManager/addDiag'
  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. const { surgeryNum } = useSelector((state) => {
  13. return state.userInfo;
  14. });
  15. useEffect(() => {
  16. setSize(15)
  17. setCurrent(1)
  18. form.resetFields();
  19. getSurgeryPage();
  20. }, [surgeryNum]);
  21. const [SurgList, setSurgList] = useState([]);//当前页列表数据
  22. const [Surgid, setSurgid] = useState([]);//当前操作行id
  23. const [title, setTitle] = useState("");//新增/修改的弹窗标题
  24. const [visible, setVisible] = useState(false);//新增修改 弹窗
  25. const [loading, setloading] = useState(true);//是否显示加载中
  26. const [flag, setFlag] = useState(false);//新增1或修改3
  27. const [delvisible, setDelvisible] = useState(false);//删除 弹窗
  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, Surgrow) => {
  45. setVisible(true);
  46. setFlag(flag1)
  47. setTitle(name); console.log(flag)
  48. if (flag1 === 1) {
  49. setFormData({
  50. status: 1,
  51. uniqueName: '',
  52. hisName: ''
  53. })
  54. } else if (flag1 === 3) {
  55. console.log(33, Surgrow)
  56. setFormData(Surgrow)
  57. }
  58. }
  59. //表格数据
  60. function getSurgeryPage(param) { //type(必填): 类型:1-化验、3-辅检、4-诊断、5-药品、6-手术和操作
  61. const hospitalId = localStorage.getItem('hospitalId')
  62. setloading(true)
  63. const hide = message.loading('加载中...', 0);
  64. post(api.getTermPage, { ...(param || params), type: 6, hospitalId: hospitalId }).then((res) => {
  65. hide()
  66. if (res.data.code === 200) {
  67. const data = res.data.data;
  68. setSurgList(data.records);
  69. setTotal(data.total)
  70. setloading(false)
  71. }
  72. })
  73. }
  74. function showDelModal(id) {
  75. setDelvisible(true);
  76. setSurgid(id);
  77. }
  78. //删除
  79. function delSurgeryById() {
  80. post(api.deleteRecord, { id: Surgid }).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. getSurgeryPage();
  92. setSurgid("");
  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. getSurgeryPage()
  117. }
  118. //筛选查询
  119. const onFinish = (value) => {
  120. params.current = 1
  121. const param = {
  122. ...params,
  123. ...value
  124. }
  125. setCurrent(1)
  126. setParams(param)
  127. getSurgeryPage(param);
  128. };
  129. //重置
  130. const onReset = () => {
  131. setSize(15)
  132. setCurrent(1)
  133. setParams(data)
  134. form.resetFields();
  135. getSurgeryPage(data);
  136. };
  137. //删除 提示框取消或关闭
  138. function handleCancel() {
  139. setDelvisible(false);
  140. }
  141. //新增修改 取消或关闭
  142. function cancel() {
  143. setVisible(false)
  144. setFormData([])
  145. }
  146. function saveMatching(saveParams) {
  147. post(api.saveOrUpdateRecord, saveParams).then((res) => {
  148. if (res.data.code === 200) {
  149. message.success("匹配成功");
  150. setVisible(false);
  151. setFormData([])
  152. getSurgeryPage();
  153. } else {
  154. message.warning(res.data.message || "匹配失败,请重试");
  155. }
  156. }).catch((error) => {
  157. message.warning(error.message || "接口出错,请重试",);
  158. })
  159. }
  160. const renderEmpty = () => (
  161. <Empty
  162. imageStyle={{
  163. height: 0,
  164. }}
  165. description={<span></span>}
  166. >
  167. </Empty>
  168. )
  169. const columns = [
  170. { title: '序号', dataIndex: 'index', render: (text, record, index) => (current - 1) * params.size + index + 1 },
  171. { title: '操作时间', dataIndex: 'gmtModified', },
  172. { title: '医院手术/操作名称', dataIndex: 'hisName', },
  173. { title: '手术/操作代码', dataIndex: 'code', },
  174. { title: '标准手术/操作名称', dataIndex: 'uniqueName', },
  175. {
  176. title: '标准术语状态', dataIndex: 'status', render: (text, record) => {
  177. return record.status === 1 ? '启用' : record.status === 0 ? '禁用' : '';
  178. }
  179. },
  180. {
  181. title: '是否匹配', dataIndex: 'isMatch', render: (text, record) => {
  182. return record.isMatch === 1 ? '已匹配' : '未匹配';
  183. }
  184. },
  185. {
  186. title: '操作', dataIndex: 'key', render: (text, record) => (
  187. <Space size="middle">
  188. <a onClick={e => showModal('修改手术/操作信息', 3, record)}>修改</a>
  189. <a style={{ color: "#FF4D4D" }} onClick={() => showDelModal(record.id)}>删除</a>
  190. </Space>
  191. )
  192. }
  193. ]
  194. return (
  195. <div className="wrapper">
  196. <div className="filter-box">
  197. <Form
  198. form={form}
  199. name="normal_login"
  200. onFinish={onFinish}
  201. >
  202. <Row gutter={24}>
  203. <Col span={5} key={0}>
  204. <Form.Item label="医院手术/操作名称" name="hisName">
  205. <Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
  206. </Form.Item>
  207. </Col>
  208. <Col span={5} key={1}>
  209. <Form.Item label="标准手术/操作名称" name="uniqueName">
  210. <Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
  211. </Form.Item>
  212. </Col>
  213. <Col span={5} key={2}>
  214. <Form.Item id="groupTypeval" label="是否匹配" name="isMatch">
  215. <Select
  216. showSearch
  217. optionFilterProp="children"
  218. // onSearch={onSearch}
  219. // onFocus={onFocus}
  220. placeholder="全部"
  221. >
  222. <Option value={''} key={-1}>全部</Option>
  223. <Option value={0} key={0}>未匹配</Option>
  224. <Option value={1} key={1}>已匹配</Option>
  225. </Select>
  226. </Form.Item>
  227. </Col>
  228. <Col span={5} key={3}>
  229. <Form.Item label="标准术语状态" name="status">
  230. <Select
  231. showSearch
  232. optionFilterProp="children"
  233. placeholder="全部"
  234. >
  235. <Option value={''} key={-1}>全部</Option>
  236. <Option value={0} key={0}>禁用</Option>
  237. <Option value={1} key={1}>启用</Option>
  238. </Select>
  239. </Form.Item>
  240. </Col>
  241. <Col span={4} key={4}>
  242. <Form.Item>
  243. <Button type="primary" htmlType="submit">
  244. 查询
  245. </Button>
  246. <Button onClick={onReset}>
  247. 重置
  248. </Button>
  249. </Form.Item>
  250. </Col>
  251. </Row>
  252. </Form>
  253. </div>
  254. <Table
  255. rowSelection={{ type: 'checkbox', ...rowSelection, }}
  256. columns={columns}
  257. dataSource={SurgList}
  258. rowKey={record => record.id}
  259. pagination={{
  260. current: current,
  261. pageSize: size,
  262. size: 'small',
  263. showSizeChanger: true,
  264. pageSizeOptions: ['15', '30', '60', '120'],
  265. showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
  266. onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
  267. onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
  268. total: total,
  269. showQuickJumper: true,
  270. }} />
  271. {visible && formData ?
  272. <Modal maskClosable={false}
  273. title={title}
  274. okText='确定'
  275. cancelText='关闭'
  276. width={'45%'}
  277. visible={visible}
  278. onCancel={cancel}
  279. footer={null}
  280. forceRender={true}
  281. >
  282. <SurgContext.Provider value={{ type, formData }}>
  283. <AddSurg SurgChange={SurgChange} cancel={cancel} isChange={isChange} />
  284. </SurgContext.Provider>
  285. <Modal
  286. title="提示"
  287. okText='确定'
  288. cancelText='关闭'
  289. width={400}
  290. visible={unsaved}
  291. onOk={addCancel}
  292. onCancel={unsavedCancel}
  293. maskClosable={false}
  294. >
  295. <p>当前数据未保存 是否确认关闭?</p>
  296. </Modal>
  297. </Modal>
  298. : ''}
  299. <Modal
  300. maskClosable={false}
  301. title="提示"
  302. okText='确定'
  303. cancelText='关闭'
  304. width={400}
  305. visible={msvisible}
  306. onOk={delOperationById}
  307. onCancel={handleCancel}
  308. >
  309. <p>诊断信息删除后将无法恢复,确认删除这{Surgid.length}条信息。</p>
  310. </Modal>
  311. <Modal
  312. maskClosable={false}
  313. destroyOnClose={true}
  314. title="提示"
  315. width={400}
  316. visible={visible1}
  317. onCancel={handleCancel1}
  318. footer={<Button key="back" onClick={handleCancel1}>关闭</Button>}
  319. >
  320. <div style={{ marginBottom: 10 + 'px' }}>
  321. <span>手术信息导入:</span>
  322. <Upload {...props}><Button type="primary" >导入目录</Button></Upload>
  323. </div>
  324. {uploadStatus === 1 ? (<span style={{ color: '#00AF71' }}>{uploadTip}</span>) : (<span style={{ color: '#E3505B' }}>{tipMap[uploadStatus]}</span>)}
  325. </Modal>
  326. <Modal
  327. maskClosable={false}
  328. destroyOnClose={true}
  329. title="提示"
  330. okText='保存'
  331. cancelText='关闭'
  332. width={800}
  333. visible={visible2}
  334. onCancel={handleCancel2}
  335. onOk={saveMatching}
  336. >
  337. <MatchSurg row={formData} onChange={matchChange}></MatchSurg>
  338. </Modal>
  339. </div>
  340. )
  341. }
  342. export default SurgManager;