index.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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: size
  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. getSurgeryPage()
  110. }
  111. //翻页
  112. function changePage(page, pageSize) {
  113. params.current = page
  114. params.size = pageSize
  115. setCurrent(page)
  116. setParams(params)
  117. getSurgeryPage()
  118. }
  119. //筛选查询
  120. const onFinish = (value) => {
  121. const param = {
  122. ...data,
  123. ...value
  124. }
  125. setCurrent(1)
  126. setParams(param)
  127. getSurgeryPage(param);
  128. };
  129. //重置
  130. const onReset = () => {
  131. setCurrent(1)
  132. setParams(data)
  133. form.resetFields();
  134. getSurgeryPage(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. getSurgeryPage();
  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: '手术/操作代码', dataIndex: 'code', },
  173. { title: '标准手术/操作名称', dataIndex: 'uniqueName', },
  174. { title: '标准术语状态', dataIndex: 'status',render: (text, record) => {
  175. return record.status===1?'启用':record.status===0?'禁用':'';
  176. }},
  177. { title: '是否匹配', dataIndex: 'isMatch',render: (text, record) => {
  178. return record.isMatch===1?'已匹配':'未匹配';
  179. }},
  180. {
  181. title: '操作', dataIndex: 'key', render: (text, record) => (
  182. <Space size="middle">
  183. <a onClick={e => showModal('修改手术/操作信息',3, record)}>修改</a>
  184. <a style={{color:"#FF4D4D"}} onClick={() => showDelModal(record.id)}>删除</a>
  185. </Space>
  186. )
  187. }
  188. ]
  189. return (
  190. <div className="wrapper">
  191. <div className="filter-box">
  192. <Form
  193. form={form}
  194. name="normal_login"
  195. onFinish={onFinish}
  196. >
  197. <Row gutter={24}>
  198. <Col span={5} key={0}>
  199. <Form.Item label="医院手术/操作名称" name="hisName">
  200. <Input placeholder="请输入" autoComplete='off' allowClear maxLength='30'/>
  201. </Form.Item>
  202. </Col>
  203. <Col span={5} key={1}>
  204. <Form.Item label="标准手术/操作名称" name="uniqueName">
  205. <Input placeholder="请输入" autoComplete='off' allowClear maxLength='30'/>
  206. </Form.Item>
  207. </Col>
  208. <Col span={5} key={2}>
  209. <Form.Item id="groupTypeval" label="是否匹配" name="isMatch">
  210. <Select
  211. showSearch
  212. optionFilterProp="children"
  213. // onSearch={onSearch}
  214. // onFocus={onFocus}
  215. placeholder="全部"
  216. >
  217. <Option value={''} key={-1}>全部</Option>
  218. <Option value={0} key={0}>未匹配</Option>
  219. <Option value={1} key={1}>已匹配</Option>
  220. </Select>
  221. </Form.Item>
  222. </Col>
  223. <Col span={5} key={3}>
  224. <Form.Item label="标准术语状态" name="status">
  225. <Select
  226. showSearch
  227. optionFilterProp="children"
  228. placeholder="全部"
  229. >
  230. <Option value={''} key={-1}>全部</Option>
  231. <Option value={0} key={0}>禁用</Option>
  232. <Option value={1} key={1}>启用</Option>
  233. </Select>
  234. </Form.Item>
  235. </Col>
  236. <Col span={4} key={4}>
  237. <Form.Item>
  238. <Button type="primary" htmlType="submit">
  239. 查询
  240. </Button>
  241. <Button onClick={onReset}>
  242. 重置
  243. </Button>
  244. </Form.Item>
  245. </Col>
  246. </Row>
  247. </Form>
  248. </div>
  249. <div className="table">
  250. <div className="table-header">
  251. <h2 className="table-title">手术/操作信息维护</h2>
  252. <Row gutter={12}>
  253. <Col key={0}>
  254. <Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增手术/操作信息',1)}>新增</Button>
  255. </Col>
  256. </Row>
  257. </div>
  258. <ConfigProvider renderEmpty={loading?renderEmpty:""}>
  259. <Table
  260. /*rowSelection={{ type: 'checkbox', ...rowSelection, }}*/
  261. columns={columns}
  262. scroll={{ y: 'calc(100vh - 400px)' }}
  263. dataSource={SurgList}
  264. rowKey={record => record.id}
  265. pagination={{
  266. current: current,
  267. pageSize: size,
  268. size: 'small',
  269. showSizeChanger: true,
  270. pageSizeOptions: ['15', '30', '60', '120'],
  271. showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
  272. onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
  273. onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
  274. total: total
  275. }} />
  276. </ConfigProvider>
  277. </div>
  278. <AddTerm formData={formData} termSType={6} termType={6} onOk={saveMatching} title={title} visible={visible} cancel={cancel} flag={flag}/>
  279. <Modal
  280. maskClosable={false}
  281. title="删除手术/操作信息"
  282. okText='确定'
  283. cancelText='关闭'
  284. width={400}
  285. visible={delvisible}
  286. onOk={delSurgeryById}
  287. onCancel={handleCancel}
  288. >
  289. <p>手术信息删除后将无法恢复,确认删除这条手术信息。</p>
  290. </Modal>
  291. </div>
  292. )
  293. }
  294. export default SurgManager;