index.js 8.2 KB

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