index.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import React, { useState, useEffect, useRef } from 'react';
  2. import { Form, Input, Button, Table, Pagination, Row, Col, Select, Modal,DatePicker } from 'antd';
  3. import '@common/common.less';
  4. import apiObj from '@api/index';
  5. import moment from "moment";
  6. import "moment/locale/zh-cn"
  7. import {message} from "antd/lib/index";
  8. const { post, api, xPost } = apiObj;
  9. const { RangePicker } = DatePicker;
  10. const { Option } = Select;
  11. function DutyRecord() {
  12. useEffect(() => {
  13. getDutyRecord();
  14. }, []);
  15. const [logList, setLogList] = useState([]);
  16. const [total, setTotal] = useState(0);
  17. const [visible, setVisible] = useState(false);
  18. const [size, setSize] = useState(15);
  19. const [current, setCurrent] = useState(1);
  20. const [selectedRowKeys, setSelectedRowKeys] = useState([]);
  21. const [params, setParams] = useState({
  22. pages: 1,
  23. current: 1,
  24. size: 15
  25. });
  26. const [form] = Form.useForm();
  27. const typeMap = {
  28. '1':'职务变更',
  29. '2':'职称变更'
  30. };
  31. let data = {
  32. pages: 1,
  33. current: 1,
  34. size: size
  35. }
  36. //表格数据
  37. function getDutyRecord(param) {
  38. post(api.getOfficialCapacityPage, param || params).then((res) => {
  39. if (res.data.code === 200) {
  40. const data = res.data.data;
  41. setLogList(data.records);
  42. setTotal(data.total)
  43. }
  44. })
  45. }
  46. //删除记录
  47. function delRecord(){
  48. post(api.delOfficialCapacityPage, {id:selectedRowKeys}).then((res) => {
  49. if (res.data.code === 200) {
  50. //刷新列表
  51. getDutyRecord()
  52. }else{
  53. message.warning(res.data.msg||'操作失败,请重试~');
  54. }
  55. });
  56. showDelModal(false);
  57. }
  58. //删除弹窗确认
  59. function showDelModal(flag){
  60. if(flag&&!selectedRowKeys.length){
  61. message.warning("请先选择要删除的记录~",1);
  62. return;
  63. }
  64. setVisible(flag)
  65. }
  66. function onSizeChange(current, pageSize) {
  67. params.current = current
  68. params.size = pageSize
  69. setSize(pageSize)
  70. setCurrent(current)
  71. setParams(params)
  72. getDutyRecord()
  73. }
  74. function changePage(page, pageSize) {
  75. params.current = page
  76. params.size = pageSize
  77. setParams(params)
  78. setCurrent(page)
  79. getDutyRecord()
  80. }
  81. function onTypeChange(){
  82. }
  83. function onSelectChange(selectedRowKeys){
  84. setSelectedRowKeys(selectedRowKeys);
  85. };
  86. const onFinish = (value) => {
  87. if (value.changeTime){
  88. value.changeTimeStart = moment(value.changeTime[0]).format('YYYY-MM-DD 00:00:00')
  89. value.changeTimeEnd = moment(value.changeTime[1]).format('YYYY-MM-DD 23:23:59')
  90. }
  91. const param = {
  92. ...data,
  93. ...value,
  94. }
  95. setCurrent(1)
  96. setParams(param)
  97. getDutyRecord(param);
  98. };
  99. const onReset = () => {
  100. setCurrent(1)
  101. setParams(data)
  102. form.resetFields();
  103. getDutyRecord(data);
  104. };
  105. const columns = [
  106. { title: '医生姓名', dataIndex: 'doctorName', key: 'doctorName' },
  107. { title: '科室', dataIndex: 'deptName', key: 'deptName' },
  108. { title: '工号', dataIndex: 'doctorCode', key: 'doctorCode' },
  109. { title: '变更时间', dataIndex: 'changeTime', key: 'changeTime' },
  110. { title: '职务/职称名称', dataIndex: 'name', key: 'name' },
  111. { title: '变更类型', dataIndex: 'type', key: 'type',render:(text,record)=>{
  112. return typeMap[record.type];
  113. } },
  114. ];
  115. const rowSelection = {
  116. selectedRowKeys,
  117. onChange: onSelectChange,
  118. };
  119. return (
  120. <div className="wrapper">
  121. <div className="filter-box">
  122. <Form
  123. form={form}
  124. name="normal_login"
  125. onFinish={onFinish}
  126. >
  127. <Row gutter={24}>
  128. <Col span={5} key={0}>
  129. <Form.Item label="医生姓名" name="doctorName">
  130. <Input placeholder="请输入" autoComplete='off'/>
  131. </Form.Item>
  132. </Col>
  133. <Col span={5} key={1}>
  134. <Form.Item label="科室" name="deptName">
  135. <Input placeholder="请输入" autoComplete='off'/>
  136. </Form.Item>
  137. </Col>
  138. <Col span={5} key={2}>
  139. <Form.Item label="工号" name="doctorCode">
  140. <Input placeholder="请输入" autoComplete='off'/>
  141. </Form.Item>
  142. </Col>
  143. <Col span={5} key={3}>
  144. <Form.Item label="职务/职称名称" name="name">
  145. <Input placeholder="请输入" autoComplete='off'/>
  146. </Form.Item>
  147. </Col>
  148. <Col span={5} key={4}>
  149. <Form.Item label="变更类型" name="type">
  150. <Select
  151. placeholder="请选择"
  152. onChange={onTypeChange}
  153. allowClear
  154. >
  155. <Option value="0" key={0}>全部</Option>
  156. <Option value="1" key={1}>{typeMap['1']}</Option>
  157. <Option value="2" key={2}>{typeMap['2']}</Option>
  158. </Select>
  159. </Form.Item>
  160. </Col>
  161. <Col span={7} key={5}>
  162. <Form.Item label="变更时间" name="changeTime">
  163. <RangePicker
  164. placeholder={['开始时间', '结束时间']}
  165. />
  166. </Form.Item>
  167. </Col>
  168. <Col span={6} key={6}>
  169. <Form.Item>
  170. <Button type="primary" htmlType="submit">
  171. 查询
  172. </Button>
  173. <Button onClick={onReset}>
  174. 重置
  175. </Button>
  176. </Form.Item>
  177. </Col>
  178. </Row>
  179. </Form>
  180. </div>
  181. <div className="table">
  182. <div className="table-header">
  183. <h2 className="table-title">职务职称变更记录</h2>
  184. <Button type="primary" onClick={()=>showDelModal(true)}>删除</Button>
  185. </div>
  186. <Table
  187. columns={columns}
  188. rowSelection={rowSelection}
  189. scroll={{ y: 'calc(100vh - 360px)' }}
  190. dataSource={logList}
  191. rowKey={record => record.id}
  192. pagination={{
  193. pageSize: size,
  194. size: 'small',
  195. current: current,
  196. showSizeChanger: true,
  197. pageSizeOptions: ['15', '30', '60', '120'],
  198. showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
  199. onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
  200. onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
  201. total: total
  202. }} />
  203. </div>
  204. <Modal
  205. title="删除职务职称变更记录"
  206. okText='确定'
  207. cancelText='取消'
  208. width={400}
  209. visible={visible}
  210. onOk={delRecord}
  211. /*confirmLoading={confirmLoading}*/
  212. onCancel={()=>showDelModal(false)}
  213. >
  214. <p>职务职称变更记录删除后将无法恢复,确认删除这{selectedRowKeys.length}条变更记录?</p>
  215. </Modal>
  216. </div >
  217. )
  218. }
  219. export default DutyRecord;