index.js 19 KB

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