index.js 8.6 KB

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