index.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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. if (value.time) {
  147. value.behospitalStartDate = moment(value.time[0]).format('YYYY-MM-DD 00:00:00');
  148. value.behospitalEndDate = moment(value.time[1]).format('YYYY-MM-DD 23:23:59');
  149. }
  150. delete value.time
  151. const param = {
  152. ...data,
  153. ...value,
  154. }
  155. setCurrent(1)
  156. setParams(param)
  157. getColumnResultPage(param);
  158. getColumnResultNumber({ behospitalStartDate: value.behospitalStartDate, behospitalEndDate: value.behospitalEndDate })
  159. };
  160. const onReset = () => {
  161. setCurrent(1)
  162. setParams(data)
  163. form.resetFields();
  164. getColumnResultPage(data);
  165. getColumnResultNumber(date)
  166. };
  167. function getCurrentDataFront() {
  168. let time = new Date((new Date() - 30 * 24 * 3600 * 1000)).toLocaleDateString()
  169. return time
  170. }
  171. // 结束时间
  172. function getCurrentData() {
  173. let time = new Date().toLocaleDateString()
  174. return time
  175. }
  176. const columns = [
  177. { title: '序号', dataIndex: 'index', render: (text, record, index) => (current - 1) * params.size + index + 1 },
  178. { title: '住院序号', dataIndex: 'behospitalCode', key: 'behospitalCode' },
  179. {
  180. title: '文书编号', dataIndex: 'hosptialDatatmpCode', key: 'hosptialDatatmpCode', render: (text, record) => {
  181. return record.hosptialDatatmpCode || '-';
  182. }
  183. },
  184. {
  185. title: '文书标题', dataIndex: 'hosptialDatatmpName', key: 'hosptialDatatmpName', render: (text, record) => {
  186. return record.hosptialDatatmpName || '-';
  187. }
  188. },
  189. { title: '质控模块名称', dataIndex: 'modeName', key: 'modeName' },
  190. { title: '表名称(中文)', dataIndex: 'tableCname', key: 'tableCname' },
  191. { title: '表名称(英文)', dataIndex: 'tableEname', key: 'tableEname' },
  192. { title: '字段名称(中文)', dataIndex: 'columnCname', key: 'columnCname' },
  193. { title: '字段名称(英文)', dataIndex: 'columnEname', key: 'columnEname' },
  194. {
  195. title: '上传字段值', dataIndex: 'tableVal', key: 'tableVal', render: (text, record) => {
  196. return record.tableVal ? record.tableVal.length > 8 ? <span title={record.tableVal}>{record.tableVal.substring(0, 8) + '...'}</span> : record.tableVal : '-';
  197. }
  198. },
  199. {
  200. title: '备注', dataIndex: 'description', key: 'description', render: (text, record) => {
  201. return record.description ? record.description.length > 20 ? <span title={record.description}>{record.description.substring(0, 20) + '...'}</span> : record.description : '-';
  202. }
  203. },
  204. {
  205. title: '问题类型', dataIndex: 'type', render: (text, record) => {
  206. return record.type == 1 ? "数据缺失" : record.type == 2 ? "非标准值" : "正则校验失败";
  207. }
  208. },
  209. {
  210. title: '更新时间', dataIndex: 'solveTime', key: 'solveTime', render: (text, record) => {
  211. return record.solveTime || '-';
  212. }
  213. },
  214. {
  215. title: '状态', dataIndex: 'isRequired', key: 'isRequired', render: (text, record) => {
  216. return record.isSolved == 1 ? "已处理" : record.isSolved == 0 ? "未处理" : "-";
  217. }
  218. },
  219. {
  220. title: '操作', dataIndex: 'key', render: (text, record) => (
  221. <Space size="middle">
  222. <a onClick={e => showModal('修改字段校验问题明细', record, 3)}>修改</a>
  223. </Space>
  224. )
  225. }
  226. ];
  227. return (
  228. <div className="wrapper">
  229. <div className="filter-box">
  230. <Form
  231. form={form}
  232. name="normal_login"
  233. onFinish={onFinish}
  234. initialValues={{
  235. isSolved: '', type: '', behospitalStartDate: moment(getCurrentDataFront()), behospitalEndDate: moment(getCurrentData())
  236. }}
  237. >
  238. <Row gutter={24}>
  239. <Col span={7} key={0}>
  240. <Form.Item label="日期" >
  241. <Form.Item name="behospitalStartDate" className='times'>
  242. <DatePicker
  243. allowClear={false}
  244. disabledDate={disabledStartDate}
  245. value={startValue}
  246. placeholder="请选择开始日期"
  247. onChange={onStartChange}
  248. />
  249. </Form.Item>
  250. <span style={{ margin: '0 5px', position: 'relative', top: '2px' }}>-</span>
  251. <Form.Item name="behospitalEndDate" className='times'>
  252. <DatePicker
  253. allowClear={false}
  254. disabledDate={disabledEndDate}
  255. value={endValue}
  256. placeholder="请选择结束始日期"
  257. onChange={onEndChange}
  258. />
  259. </Form.Item>
  260. </Form.Item>
  261. </Col>
  262. <Col span={5} key={1}>
  263. <Form.Item label="住院序号" name="behospitalCode" getValueFromEvent={getValueFromEvent}>
  264. <Input placeholder="住院序号" autoComplete='off' allowClear maxLength='30' />
  265. </Form.Item>
  266. </Col>
  267. <Col span={5} key={2}>
  268. <Form.Item label="文书编号" name="hosptialDatatmpCode" getValueFromEvent={getValueFromEvent}>
  269. <Input placeholder="文书编号" autoComplete='off' allowClear maxLength='30' />
  270. </Form.Item>
  271. </Col>
  272. <Col span={5} key={3}>
  273. <Form.Item label="文书标题" name="hosptialDatatmpName" getValueFromEvent={getValueFromEvent}>
  274. <Input placeholder="文书标题" autoComplete='off' allowClear maxLength='30' />
  275. </Form.Item>
  276. </Col>
  277. <Col span={5} key={4}>
  278. <Form.Item label="质控模块名称" name="modeName" >
  279. <Select showSearch allowClear onSearch={onSearch} placeholder="请选择">
  280. {modeList.map((item, i) => {
  281. return (
  282. <Option value={item} key={i}>{item}</Option>
  283. )
  284. })}
  285. </Select>
  286. </Form.Item>
  287. </Col>
  288. <Col span={5} key={5}>
  289. <Form.Item label="问题类型" name="type">
  290. <Select
  291. placeholder="请选择"
  292. allowClear
  293. >
  294. <Option value="" key={0}>全部</Option>
  295. <Option value="1" key={1}>数据缺失</Option>
  296. <Option value="2" key={2}>非标准值</Option>
  297. <Option value="3" key={3}>正则校验失败</Option>
  298. </Select>
  299. </Form.Item>
  300. </Col>
  301. <Col span={5} key={7}>
  302. <Form.Item label="状态" name="isSolved">
  303. <Select
  304. placeholder="请选择"
  305. allowClear
  306. >
  307. <Option value="" key={3}>全部</Option>
  308. <Option value="0" key={0}>未处理</Option>
  309. <Option value="1" key={1}>已处理</Option>
  310. </Select>
  311. </Form.Item>
  312. </Col>
  313. <Col span={4} key={8}>
  314. <Form.Item>
  315. <Button type="primary" htmlType="submit">
  316. 查询
  317. </Button>
  318. <Button onClick={onReset}>
  319. 重置
  320. </Button>
  321. </Form.Item>
  322. </Col>
  323. </Row>
  324. </Form>
  325. </div>
  326. <div className="table">
  327. <div className="table-header">
  328. <h2 className="table-title">字段校验问题明细</h2>
  329. <Space size="middle">
  330. <Button type="primary" onClick={() => showModal('数据校验设置', { behospitalCode: '', time: '' }, 1)}>数据校验</Button>
  331. </Space>
  332. </div>
  333. <div className="table-data" style={{ justifyContent: 'left' }}>
  334. <Row className="data-box">
  335. <Col span={6} order={1} className="box-item">
  336. <p>{probleData.notSolvedNonnull || probleData.notSolvedNonnull == 0 ? probleData.notSolvedNonnull : '-'}</p>
  337. <p>数据缺失</p>
  338. </Col>
  339. <Col span={6} order={2} className="box-item">
  340. <p>{probleData.notSolvedStandardvalue || probleData.notSolvedStandardvalue == 0 ? probleData.notSolvedStandardvalue : '-'}</p>
  341. <p>非标准值</p>
  342. </Col>
  343. <Col span={6} order={3} className="box-item">
  344. <p>{probleData.notSolvedRegular || probleData.notSolvedRegular == 0 ? probleData.notSolvedRegular : '-'}</p>
  345. <p>正则校验失败</p>
  346. </Col>
  347. <Col span={6} order={4} className="box-item item">
  348. <p>{probleData.notSolved || probleData.notSolved == 0 ? probleData.notSolved : '-'}</p>
  349. <p>未处理</p>
  350. </Col>
  351. </Row>
  352. <Row className="data-box">
  353. <Col span={6} order={1} className="box-item">
  354. <p>{probleData.resolvedNonnull || probleData.resolvedNonnull == 0 ? probleData.resolvedNonnull : '-'}</p>
  355. <p>数据缺失</p>
  356. </Col>
  357. <Col span={6} order={2} className="box-item">
  358. <p>{probleData.resolvedStandardvalue || probleData.resolvedStandardvalue == 0 ? probleData.resolvedStandardvalue : '-'}</p>
  359. <p>非标准值</p>
  360. </Col>
  361. <Col span={6} order={3} className="box-item">
  362. <p>{probleData.resolvedRegular || probleData.resolvedRegular == 0 ? probleData.resolvedRegular : '-'}</p>
  363. <p>正则校验失败</p>
  364. </Col>
  365. <Col span={6} order={4} className="box-item box">
  366. <p>{probleData.resolved || probleData.resolved == 0 ? probleData.resolved : '-'}</p>
  367. <p>已处理</p>
  368. </Col>
  369. </Row>
  370. </div>
  371. <Table
  372. columns={columns}
  373. scroll={{ y: 'calc(100vh - 570px)' }}
  374. dataSource={logList}
  375. rowKey={record => record.id}
  376. pagination={{
  377. pageSize: size,
  378. size: 'small',
  379. current: current,
  380. showSizeChanger: true,
  381. pageSizeOptions: ['15', '30', '60', '120'],
  382. showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
  383. onShowSizeChange: (current, pageSize) => onSizeChange(current, pageSize), // 改变每页数量时更新显示
  384. onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
  385. total: total
  386. }} />
  387. </div>
  388. {visible && problemDetail ?
  389. <Modal
  390. title={title}
  391. okText='确定'
  392. cancelText='取消'
  393. width="500px"
  394. visible={visible}
  395. onCancel={cancel}
  396. footer={null}
  397. forceRender={true}
  398. maskClosable={false}
  399. >
  400. <ProblemContext.Provider value={{ problemDetail, type }}>
  401. <EditProblem cancel={cancel} userChange={userChange} />
  402. </ProblemContext.Provider>
  403. </Modal>
  404. : ''}
  405. </div >
  406. )
  407. }
  408. export default FieldProblem;