editProblem.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. import React, {
  2. useState, useEffect, useContext
  3. } from 'react';
  4. import { Form, Col, DatePicker, Button, message, Space, Input } from 'antd';
  5. import apiObj from '@api/index';
  6. import BlockContext from './problem-context';
  7. import moment from "moment";
  8. import "moment/locale/zh-cn"
  9. import { getCookie } from '@utils/index'
  10. const { RangePicker } = DatePicker;
  11. const { post, api, xPost } = apiObj;
  12. const { TextArea } = Input;
  13. function EditBlock(props) {
  14. useEffect(() => {
  15. }, []);
  16. const [form] = Form.useForm();
  17. const [dates, setDates] = useState([]);
  18. const [limit, setLimit] = useState(false);
  19. const { problemDetail, type } = useContext(BlockContext);
  20. const initialValues = problemDetail;
  21. const onFinish = values => {
  22. if (type == 1) {
  23. dataCheck(values)
  24. } else {
  25. editProblem(values)
  26. }
  27. };
  28. function change(e) {
  29. const { value } = e.target;
  30. if (value) {
  31. setLimit(true)
  32. } else {
  33. setLimit(false)
  34. }
  35. }
  36. function editProblem(values) {
  37. let params = {
  38. id: problemDetail.id,
  39. description: values.description,
  40. }
  41. post(api.updateColumnResult, params).then((res) => {
  42. if (res.data.code === 200) {
  43. props.userChange()
  44. message.success(res.data.message);
  45. form.resetFields();
  46. } else {
  47. message.error(res.data.message);
  48. }
  49. })
  50. }
  51. //数据对比
  52. function dataCheck(values) {
  53. values.startDate = moment(values.time[0]).format('YYYY-MM-DD 00:00:00');
  54. values.endDate = moment(values.time[1]).format('YYYY-MM-DD 23:23:59');
  55. let params = {
  56. behospitalCode: values.behospitalCode,
  57. dateEnd: values.endDate,
  58. dateStart: values.startDate,
  59. isPlacefile:getCookie('isPlacefile')
  60. }
  61. post(api.dataCheck, params).then((res) => {
  62. if (res.data.code === 200) {
  63. props.userChange()
  64. message.success(res.data.message);
  65. form.resetFields();
  66. } else {
  67. message.error(res.data.message);
  68. }
  69. })
  70. }
  71. function disabledDate(current) {
  72. if (!dates || dates.length === 0) {
  73. return current && current >= moment().endOf('day');
  74. }
  75. const tooLate = dates[0] && current.diff(dates[0], 'days') > 29;
  76. const tooEarly = dates[1] && dates[1].diff(current, 'days') > 29;
  77. if(!limit){
  78. return current && current >= moment().endOf('day') || tooEarly || tooLate;
  79. }else{
  80. return current && current >= moment().endOf('day');
  81. }
  82. };
  83. function cancel() {
  84. props.userChange()
  85. }
  86. return (
  87. <>
  88. <Form
  89. labelCol={type == 3 ? { span: 16 } : { span: 4 }}
  90. wrapperCol={type == 3 ? { span: 12 } : { span: 16 }}
  91. form={form}
  92. name="register"
  93. layout={type == 3 ? 'inline' : 'horizontal'}
  94. onFinish={onFinish}
  95. initialValues={initialValues}
  96. className='problem'
  97. >
  98. <Col span={12} hidden={type != 3}>
  99. <Form.Item
  100. name="behospitalCode"
  101. label="住院序号"
  102. labelAlign="right"
  103. >
  104. <span>{initialValues.behospitalCode}</span>
  105. </Form.Item>
  106. </Col>
  107. <Col span={12} hidden={type != 3}>
  108. <Form.Item
  109. name="hosptialDatatmpCode"
  110. label="文书编号"
  111. >
  112. <span>{initialValues.hosptialDatatmpCode}</span>
  113. </Form.Item>
  114. </Col>
  115. <Col span={12} hidden={type != 3}>
  116. <Form.Item
  117. name="hosptialDatatmpName"
  118. label="文书标题"
  119. >
  120. <span>{initialValues.hosptialDatatmpName}</span>
  121. </Form.Item>
  122. </Col>
  123. <Col span={12} hidden={type != 3}>
  124. <Form.Item
  125. name="modeName"
  126. label="质控模块名称"
  127. >
  128. <span>{initialValues.modeName}</span>
  129. </Form.Item>
  130. </Col>
  131. <Col span={12} hidden={type != 3}>
  132. <Form.Item
  133. name="tableCname"
  134. label="表名称(中文)"
  135. >
  136. <span>{initialValues.tableCname}</span>
  137. </Form.Item>
  138. </Col>
  139. <Col span={12} hidden={type != 3}>
  140. <Form.Item
  141. name="tableEname"
  142. label="表名称(英文)"
  143. >
  144. <span>{initialValues.tableEname}</span>
  145. </Form.Item>
  146. </Col>
  147. <Col span={12} hidden={type != 3}>
  148. <Form.Item
  149. name="columnCname"
  150. label="字段名称(中文)"
  151. >
  152. <span>{initialValues.columnCname}</span>
  153. </Form.Item>
  154. </Col>
  155. <Col span={12} hidden={type != 3}>
  156. <Form.Item
  157. name="columnEname"
  158. label="字段名称(英文)"
  159. >
  160. <span>{initialValues.columnEname}</span>
  161. </Form.Item>
  162. </Col>
  163. <Col span={12} hidden={type != 3}>
  164. <Form.Item
  165. name="tableVal"
  166. label="上传字段值"
  167. >
  168. <span>{initialValues.tableVal}</span>
  169. </Form.Item>
  170. </Col>
  171. <Col span={12} hidden={type != 3}>
  172. <Form.Item
  173. name="type"
  174. label="问题类型"
  175. >
  176. <span>{initialValues.type == 1 ? "数据缺失" : initialValues.type == 2 ? "非标准值" : "正则校验失败"}</span>
  177. </Form.Item>
  178. </Col>
  179. <Col span={24} hidden={type != 3}>
  180. <Form.Item
  181. name="status"
  182. label="状态"
  183. >
  184. <span>{initialValues.isSolved == 1 ? "已解决" : "未解决"}</span>
  185. </Form.Item>
  186. </Col>
  187. <Col span={24} hidden={type != 3}>
  188. <Form.Item
  189. name="description"
  190. label="备注"
  191. wrapperCol={{ span: 18 }}
  192. rules={[{ max: 200,message:'备注不能超过200个字符' }]}
  193. >
  194. <TextArea
  195. autoSize={{ minRows: 5, maxRows: 5 }}
  196. />
  197. </Form.Item>
  198. </Col>
  199. <Col span={24} hidden={type == 3}>
  200. {type != 3 ?
  201. <Form.Item label="日期" name="time" rules={[{ required: true }]} labelAlign="right">
  202. <RangePicker
  203. allowClear={false}
  204. placeholder={['开始时间', '结束时间']}
  205. disabledDate={disabledDate}
  206. onCalendarChange={val => setDates(val)}
  207. />
  208. </Form.Item>
  209. : ''}
  210. </Col>
  211. <Col span={24} hidden={type == 3} style={{ marginTop: 15 }}>
  212. <Form.Item label="住院序号" name="behospitalCode" rules={[{ max: 30,message:'住院序号不能超过30个字符' }]}>
  213. <Input placeholder="请输入" autoComplete='off' onChange={change}/>
  214. </Form.Item>
  215. </Col>
  216. {
  217. type == 1 ?
  218. <div style={{ color: '#1690FF' }}>
  219. 提示:<br />
  220. 1、校验时间范围限制为30天,每一天数据量的校验时间约为1分钟。<br />
  221. 时间范围以患者入院时间为准。<br />
  222. 2、当输入住院序号时,校验将不受时间范围限制。<br />
  223. </div>
  224. : ''
  225. }
  226. <Form.Item wrapperCol={type == 3 ? { offset: 24, span: 16 } : { offset: 8, span: 16 }} style={{ marginTop: 15 }}>
  227. <Space size="middle" >
  228. <Button htmlType="button" onClick={e => cancel()}>
  229. 取消
  230. </Button>
  231. <Button type="primary" htmlType="submit">
  232. {type == 1 ? '确定' : '保存'}
  233. </Button>
  234. </Space>
  235. </Form.Item>
  236. </Form>
  237. </>
  238. );
  239. }
  240. export default EditBlock;