index.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. import React, { useState, useEffect, useRef } from 'react';
  2. import { useSelector, useDispatch } from 'react-redux';
  3. import { Form, Input, Button, Table, Row, Col, Select, Modal, DatePicker, Space, message, Spin } from 'antd';
  4. import '@common/common.less';
  5. import moment from "moment";
  6. import "moment/locale/zh-cn"
  7. import './index.less'
  8. import apiObj from '@api/index';
  9. import EditProblem from './editProblem';
  10. import ProblemContext from './problem-context';
  11. import { getValueFromEvent, disabledDate, getDaysBetween } from '@utils/index'
  12. const { post, api, xPost } = apiObj;
  13. const { Option } = Select;
  14. function FieldProblem() {
  15. const [logList, setLogList] = useState([]);
  16. const [total, setTotal] = useState(0);
  17. const [type, setType] = useState(0);//1新增 2修改
  18. const [visible, setVisible] = useState(false);
  19. const [size, setSize] = useState(15);
  20. const [current, setCurrent] = useState(1);
  21. const [loading, setLoading] = useState(false);
  22. const [probleData, setProbleData] = useState({});
  23. const [problemDetail, setProblemDetail] = useState(null);//详情数据
  24. const [title, setTitle] = useState();//正则式数据
  25. const [modeList, setModeList] = useState([]);//质控模块
  26. const [params, setParams] = useState({
  27. pages: 1,
  28. current: 1,
  29. size: 15,
  30. asc: ['isSolved'],
  31. desc: ['solveTime', 'behospitalCode'],
  32. behospitalStartDate: getCurrentDataFront().split('/').join('-') + ' 00:00:00',
  33. behospitalEndDate: getCurrentData().split('/').join('-') + ' 23:59:59'
  34. });
  35. const [form] = Form.useForm();
  36. let data = {
  37. pages: 1,
  38. current: 1,
  39. size: 15,
  40. asc: ['isSolved'],
  41. desc: ['solveTime', 'behospitalCode'],
  42. behospitalStartDate: getCurrentDataFront().split('/').join('-') + ' 00:00:00',
  43. behospitalEndDate: getCurrentData().split('/').join('-') + ' 23:59:59'
  44. }
  45. let date = {
  46. behospitalStartDate: getCurrentDataFront().split('/').join('-') + ' 00:00:00',
  47. behospitalEndDate: getCurrentData().split('/').join('-') + ' 23:59:59'
  48. }
  49. const { problemNum } = useSelector((state) => {
  50. return state.userInfo;
  51. });
  52. useEffect(() => {
  53. setCurrent(1)
  54. setSize(15)
  55. setParams(data)
  56. form.resetFields();
  57. getColumnResultPage(data);
  58. getColumnResultNumber(date)
  59. getModeName()
  60. }, [problemNum]);
  61. //表格数据
  62. function getColumnResultPage(param) {
  63. const hide = message.loading('加载中...', 0);
  64. post(api.getColumnResultPage, param || params).then((res) => {
  65. hide()
  66. if (res.data.code === 200) {
  67. const data = res.data.data;
  68. setLogList(data.records);
  69. setTotal(data.total)
  70. setLoading(false)
  71. }
  72. }).catch((err) => {
  73. hide()
  74. })
  75. }
  76. function getColumnResultNumber(param) {
  77. post(api.getColumnResultNumber, {
  78. hospitalId: localStorage.getItem('hospitalId'),
  79. ...param
  80. }).then((res) => {
  81. if (res.data.code === 200) {
  82. const data = res.data.data || [];
  83. setProbleData(data)
  84. }
  85. })
  86. }
  87. function getModeName(name) {
  88. post(api.getModeName, {
  89. modeName: name
  90. }).then((res) => {
  91. if (res.data.code === 200) {
  92. const data = res.data.data || [];
  93. setModeList(data)
  94. }
  95. })
  96. }
  97. function onSearch(val) {
  98. getModeName(val)
  99. }
  100. function showModal(title, row, type) {
  101. setVisible(true)
  102. setProblemDetail(row)
  103. setTitle(title)
  104. setType(type)
  105. }
  106. //返回
  107. function cancel() {
  108. setVisible(false)
  109. setProblemDetail(null)
  110. }
  111. function userChange() {
  112. params.current = 1
  113. setParams(params)
  114. setCurrent(1)
  115. setVisible(false)
  116. getColumnResultPage();
  117. getColumnResultNumber({ behospitalStartDate: params.behospitalStartDate, behospitalEndDate: params.behospitalEndDate })
  118. setProblemDetail(null)
  119. }
  120. function onSizeChange(current, pageSize) {
  121. params.current = current
  122. params.size = pageSize
  123. setSize(pageSize)
  124. setCurrent(current)
  125. setParams(params)
  126. }
  127. function changePage(page, pageSize) {
  128. params.current = page
  129. params.size = pageSize
  130. setParams(params)
  131. setCurrent(page)
  132. getColumnResultPage()
  133. }
  134. const onFinish = (value) => {
  135. value.behospitalStartDate = moment(value.behospitalStartDate).format('YYYY-MM-DD 00:00:00');
  136. value.behospitalEndDate = moment(value.behospitalEndDate).format('YYYY-MM-DD 23:59:59');
  137. if (value.behospitalStartDate > value.behospitalEndDate) {
  138. message.warning('开始时间不能大于结束时间');
  139. return
  140. } else if (getDaysBetween(value.behospitalStartDate, value.behospitalEndDate) > 364) {
  141. message.warning('开始时间与结束时间相差不能超过一年');
  142. return
  143. }
  144. const param = {
  145. ...data,
  146. ...value,
  147. }
  148. setCurrent(1)
  149. setParams(param)
  150. getColumnResultPage(param);
  151. getColumnResultNumber({ behospitalStartDate: value.behospitalStartDate, behospitalEndDate: value.behospitalEndDate })
  152. };
  153. const onReset = () => {
  154. setCurrent(1)
  155. setSize(15)
  156. setParams(data)
  157. form.resetFields();
  158. getColumnResultPage(data);
  159. getColumnResultNumber(date)
  160. };
  161. function getCurrentDataFront() {
  162. let time = new Date((new Date() - 30 * 24 * 3600 * 1000)).toLocaleDateString()
  163. return time
  164. }
  165. // 结束时间
  166. function getCurrentData() {
  167. let time = new Date().toLocaleDateString()
  168. return time
  169. }
  170. const columns = [
  171. { title: '序号', dataIndex: 'index', render: (text, record, index) => (current - 1) * params.size + index + 1 },
  172. { title: '住院序号', dataIndex: 'behospitalCode', key: 'behospitalCode' },
  173. {
  174. title: '文书编号', dataIndex: 'hosptialDatatmpCode', key: 'hosptialDatatmpCode', render: (text, record) => {
  175. return record.hosptialDatatmpCode || '-';
  176. }
  177. },
  178. {
  179. title: '文书标题', dataIndex: 'hosptialDatatmpName', key: 'hosptialDatatmpName', render: (text, record) => {
  180. return record.hosptialDatatmpName || '-';
  181. }
  182. },
  183. { title: '质控模块名称', dataIndex: 'modeName', key: 'modeName' },
  184. { title: '表名称(中文)', dataIndex: 'tableCname', key: 'tableCname' },
  185. { title: '表名称(英文)', dataIndex: 'tableEname', key: 'tableEname' },
  186. { title: '字段名称(中文)', dataIndex: 'columnCname', key: 'columnCname' },
  187. { title: '字段名称(英文)', dataIndex: 'columnEname', key: 'columnEname' },
  188. {
  189. title: '上传字段值', dataIndex: 'tableVal', key: 'tableVal', render: (text, record) => {
  190. return record.tableVal ? record.tableVal.length > 8 ? <span title={record.tableVal}>{record.tableVal.substring(0, 8) + '...'}</span> : record.tableVal : '-';
  191. }
  192. },
  193. {
  194. title: '备注', dataIndex: 'description', key: 'description', render: (text, record) => {
  195. return record.description ? record.description.length > 20 ? <span title={record.description}>{record.description.substring(0, 20) + '...'}</span> : record.description : '-';
  196. }
  197. },
  198. {
  199. title: '问题类型', dataIndex: 'type', render: (text, record) => {
  200. return record.type == 1 ? "数据缺失" : record.type == 2 ? "非标准值" : "正则校验失败";
  201. }
  202. },
  203. {
  204. title: '更新时间', dataIndex: 'gmtModified', key: 'gmtModified', render: (text, record) => {
  205. return record.gmtModified || '-';
  206. }
  207. },
  208. {
  209. title: '状态', dataIndex: 'isRequired', key: 'isRequired', render: (text, record) => {
  210. return record.isSolved == 1 ? "已处理" : record.isSolved == 0 ? "未处理" : "-";
  211. }
  212. },
  213. {
  214. title: '操作', dataIndex: 'key', render: (text, record) => (
  215. <Space size="middle">
  216. <a onClick={e => showModal('修改字段校验问题明细', record, 3)}>修改</a>
  217. </Space>
  218. )
  219. }
  220. ];
  221. return (
  222. <div className="wrapper">
  223. <div className="filter-box">
  224. <Form
  225. form={form}
  226. name="normal_login"
  227. onFinish={onFinish}
  228. initialValues={{
  229. isSolved: '', type: '', behospitalStartDate: moment(getCurrentDataFront()), behospitalEndDate: moment(getCurrentData())
  230. }}
  231. >
  232. <Row gutter={24}>
  233. <Col span={7} key={0}>
  234. <Form.Item label="日期" >
  235. <Form.Item name="behospitalStartDate" className='times'>
  236. <DatePicker
  237. allowClear={false}
  238. disabledDate={disabledDate}
  239. placeholder="请选择开始日期"
  240. />
  241. </Form.Item>
  242. <span style={{ margin: '0 5px', position: 'relative', top: '2px' }}>-</span>
  243. <Form.Item name="behospitalEndDate" className='times'>
  244. <DatePicker
  245. allowClear={false}
  246. disabledDate={disabledDate}
  247. placeholder="请选择结束日期"
  248. />
  249. </Form.Item>
  250. </Form.Item>
  251. </Col>
  252. <Col span={5} key={1}>
  253. <Form.Item label="住院序号" name="behospitalCode" getValueFromEvent={getValueFromEvent}>
  254. <Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
  255. </Form.Item>
  256. </Col>
  257. <Col span={5} key={2}>
  258. <Form.Item label="文书编号" name="hosptialDatatmpCode" getValueFromEvent={getValueFromEvent}>
  259. <Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
  260. </Form.Item>
  261. </Col>
  262. <Col span={5} key={3}>
  263. <Form.Item label="文书标题" name="hosptialDatatmpName" getValueFromEvent={getValueFromEvent}>
  264. <Input placeholder="请输入" autoComplete='off' allowClear maxLength='30' />
  265. </Form.Item>
  266. </Col>
  267. <Form.Item label="质控模块名称" name="modeName" >
  268. <Select showSearch allowClear onSearch={onSearch} placeholder="请选择" style={{ width: '159px' }}>
  269. {modeList.map((item, i) => {
  270. return (
  271. <Option value={item} key={i}>{item}</Option>
  272. )
  273. })}
  274. </Select>
  275. </Form.Item>
  276. <Col span={4} key={5}>
  277. <Form.Item label="问题类型" name="type">
  278. <Select
  279. placeholder="请选择"
  280. allowClear
  281. >
  282. <Option value="" key={0}>全部</Option>
  283. <Option value="1" key={1}>数据缺失</Option>
  284. <Option value="2" key={2}>非标准值</Option>
  285. <Option value="3" key={3}>正则校验失败</Option>
  286. </Select>
  287. </Form.Item>
  288. </Col>
  289. <Col span={4} key={7}>
  290. <Form.Item label="状态" name="isSolved">
  291. <Select
  292. placeholder="请选择"
  293. allowClear
  294. >
  295. <Option value="" key={3}>全部</Option>
  296. <Option value="0" key={0}>未处理</Option>
  297. <Option value="1" key={1}>已处理</Option>
  298. </Select>
  299. </Form.Item>
  300. </Col>
  301. <Col span={4} key={8}>
  302. <Form.Item>
  303. <Button type="primary" htmlType="submit">
  304. 查询
  305. </Button>
  306. <Button onClick={onReset}>
  307. 重置
  308. </Button>
  309. </Form.Item>
  310. </Col>
  311. </Row>
  312. </Form>
  313. </div>
  314. <div className="table">
  315. <div className="table-header">
  316. <h2 className="table-title">字段校验问题明细</h2>
  317. <Space size="middle">
  318. <Button type="primary" onClick={() => showModal('数据校验设置', { behospitalCode: '', time: '' }, 1)}>数据校验</Button>
  319. </Space>
  320. </div>
  321. <div className="table-data" style={{ justifyContent: 'left' }}>
  322. <Row className="data-box">
  323. <Col span={6} order={1} className="box-item">
  324. <p>{probleData.notSolvedNonnull || probleData.notSolvedNonnull == 0 ? probleData.notSolvedNonnull : '-'}</p>
  325. <p>数据缺失</p>
  326. </Col>
  327. <Col span={6} order={2} className="box-item">
  328. <p>{probleData.notSolvedStandardvalue || probleData.notSolvedStandardvalue == 0 ? probleData.notSolvedStandardvalue : '-'}</p>
  329. <p>非标准值</p>
  330. </Col>
  331. <Col span={6} order={3} className="box-item">
  332. <p>{probleData.notSolvedRegular || probleData.notSolvedRegular == 0 ? probleData.notSolvedRegular : '-'}</p>
  333. <p>正则校验失败</p>
  334. </Col>
  335. <Col span={6} order={4} className="box-item item">
  336. <p>{probleData.notSolved || probleData.notSolved == 0 ? probleData.notSolved : '-'}</p>
  337. <p>未处理</p>
  338. </Col>
  339. </Row>
  340. <Row className="data-box">
  341. <Col span={6} order={1} className="box-item">
  342. <p>{probleData.resolvedNonnull || probleData.resolvedNonnull == 0 ? probleData.resolvedNonnull : '-'}</p>
  343. <p>数据缺失</p>
  344. </Col>
  345. <Col span={6} order={2} className="box-item">
  346. <p>{probleData.resolvedStandardvalue || probleData.resolvedStandardvalue == 0 ? probleData.resolvedStandardvalue : '-'}</p>
  347. <p>非标准值</p>
  348. </Col>
  349. <Col span={6} order={3} className="box-item">
  350. <p>{probleData.resolvedRegular || probleData.resolvedRegular == 0 ? probleData.resolvedRegular : '-'}</p>
  351. <p>正则校验失败</p>
  352. </Col>
  353. <Col span={6} order={4} className="box-item box">
  354. <p>{probleData.resolved || probleData.resolved == 0 ? probleData.resolved : '-'}</p>
  355. <p>已处理</p>
  356. </Col>
  357. </Row>
  358. </div>
  359. <Table
  360. columns={columns}
  361. scroll={{ y: 'calc(100vh - 570px)' }}
  362. dataSource={logList}
  363. rowKey={record => record.id}
  364. pagination={{
  365. pageSize: size,
  366. size: 'small',
  367. current: current,
  368. showSizeChanger: true,
  369. pageSizeOptions: ['15', '30', '60', '120'],
  370. showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
  371. onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
  372. onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
  373. total: total
  374. }} />
  375. </div>
  376. {visible && problemDetail ?
  377. <Modal
  378. title={title}
  379. okText='确定'
  380. cancelText='取消'
  381. width="500px"
  382. visible={visible}
  383. onCancel={cancel}
  384. footer={null}
  385. forceRender={true}
  386. maskClosable={false}
  387. >
  388. <ProblemContext.Provider value={{ problemDetail, type }}>
  389. <EditProblem cancel={cancel} userChange={userChange} />
  390. </ProblemContext.Provider>
  391. </Modal>
  392. : ''}
  393. </div >
  394. )
  395. }
  396. export default FieldProblem;