index.js 18 KB

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