index.js 8.5 KB

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