editBlock.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. import React, {
  2. useState, useEffect, useContext
  3. } from 'react';
  4. import { Form, Col, DatePicker, Button, Radio, message, Space, Input } from 'antd';
  5. import apiObj from '@api/index';
  6. import BlockContext from './block-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. if(type == 2){
  16. setLimit(true)
  17. }
  18. }, []);
  19. const [form] = Form.useForm();
  20. const [dates, setDates] = useState([]);
  21. const [disable, setDisable] = useState(true);
  22. const [limit, setLimit] = useState(false);
  23. const { blockDetail, type } = useContext(BlockContext);
  24. const initialValues = blockDetail;
  25. const onFinish = values => {
  26. if (type == 1) {
  27. dataRepari(values)
  28. } else if (type == 2) {
  29. dataCompare(values)
  30. } else {
  31. editBlock(values)
  32. }
  33. };
  34. function onChange(e) {
  35. const formData = form.getFieldsValue();
  36. if (formData.behospitalCode || formData.time != '') {
  37. setDisable(false)
  38. } else {
  39. setDisable(true)
  40. }
  41. }
  42. function change(e) {
  43. const formData = form.getFieldsValue();
  44. const { value } = e.target;
  45. if (type == 1) {
  46. if (value) {
  47. setLimit(true)
  48. } else {
  49. setLimit(false)
  50. }
  51. }
  52. if (formData.behospitalCode || formData.time != '') {
  53. setDisable(false)
  54. } else {
  55. setDisable(true)
  56. }
  57. }
  58. function editBlock(values) {
  59. let params = {
  60. id: blockDetail.id,
  61. isAudited: values.isAudited,
  62. lossCause: values.lossCause
  63. }
  64. post(api.upBlockLossById, params).then((res) => {
  65. if (res.data.code === 200) {
  66. props.userChange()
  67. message.success(res.data.message);
  68. form.resetFields();
  69. } else {
  70. message.error(res.data.message);
  71. }
  72. })
  73. }
  74. function disabledDate(current) {
  75. if (!dates || dates.length === 0) {
  76. return current && current >= moment().endOf('day');
  77. }
  78. const tooLate = dates[0] && current.diff(dates[0], 'days') > 29;
  79. const tooEarly = dates[1] && dates[1].diff(current, 'days') > 29;
  80. if (!limit) {
  81. return current && current >= moment().endOf('day') || tooEarly || tooLate;
  82. } else {
  83. return current && current >= moment().endOf('day');
  84. }
  85. };
  86. //数据补录
  87. function dataRepari(values) {
  88. values.startDate = moment(values.time[0]).format('YYYY-MM-DD 00:00:00');
  89. values.endDate = moment(values.time[1]).format('YYYY-MM-DD 23:23:59');
  90. let params = {
  91. behospitalCode: values.behospitalCode,
  92. endDate: values.endDate,
  93. startDate: values.startDate,
  94. isPlacefile:getCookie('isPlacefile')
  95. }
  96. post(api.dataRepari, params).then((res) => {
  97. if (res.data.code === 200) {
  98. props.userChange()
  99. message.success(res.data.message);
  100. form.resetFields();
  101. } else {
  102. message.error(res.data.message);
  103. }
  104. })
  105. }
  106. //数据对比
  107. function dataCompare(values) {
  108. values.startDate = moment(values.time[0]).format('YYYY-MM-DD 00:00:00');
  109. values.endDate = moment(values.time[1]).format('YYYY-MM-DD 23:23:59');
  110. let params = {
  111. behospitalCode: values.behospitalCode,
  112. endDate: values.endDate,
  113. startDate: values.startDate,
  114. }
  115. post(api.dataCompare, params).then((res) => {
  116. if (res.data.code === 200) {
  117. props.userChange()
  118. message.success(res.data.message);
  119. form.resetFields();
  120. } else {
  121. message.error(res.data.message);
  122. }
  123. })
  124. }
  125. function cancel() {
  126. props.cancel()
  127. }
  128. return (
  129. <>
  130. <Form
  131. labelCol={type == 3 ? { span: 8 } : { span: 4 }}
  132. wrapperCol={{ span: 16 }}
  133. form={form}
  134. name="register"
  135. layout={type == 3 ? 'inline' : 'horizontal'}
  136. onFinish={onFinish}
  137. initialValues={initialValues}
  138. className='block'
  139. >
  140. <Col span={12} hidden={type != 3}>
  141. <Form.Item
  142. name="behospitalCode"
  143. label="住院序号"
  144. >
  145. <span>{initialValues.behospitalCode}</span>
  146. </Form.Item>
  147. </Col>
  148. <Col span={12} hidden={type != 3}>
  149. <Form.Item
  150. name="recId"
  151. label="文书编号"
  152. >
  153. <span>{initialValues.recId}</span>
  154. </Form.Item>
  155. </Col>
  156. <Col span={12} hidden={type != 3}>
  157. <Form.Item
  158. name="recTitle"
  159. label="文书标题"
  160. >
  161. <span>{initialValues.recTitle}</span>
  162. </Form.Item>
  163. </Col>
  164. <Col span={12} hidden={type != 3}>
  165. <Form.Item
  166. name="lossType"
  167. label="丢失类型"
  168. >
  169. <span>{initialValues.lossType == 0 ? '文书丢失' : initialValues.lossType == 1 ? '病案首页丢失' : initialValues.lossType == 2 ? '患者信息丢失' : ''}</span>
  170. </Form.Item>
  171. </Col>
  172. <Col span={12} hidden={type != 3}>
  173. <Form.Item
  174. name="lossWay"
  175. label="丢失途径"
  176. >
  177. <span>{initialValues.lossWay == 0 ? '外部丢失' : initialValues.lossWay == 1 ? '内部丢失' : ''}</span>
  178. </Form.Item>
  179. </Col>
  180. <Col span={12} hidden={type != 3}>
  181. <Form.Item
  182. name="status"
  183. label="状态"
  184. >
  185. <span>{initialValues.status == 0 ? '已丢失' : initialValues.status == 1 ? '已恢复' : ''}</span>
  186. </Form.Item>
  187. </Col>
  188. <Col span={24} hidden={type != 3}>
  189. <Form.Item
  190. name="isAudited"
  191. label="核查结果"
  192. wrapperCol={{ span: 18 }}
  193. >
  194. <Radio.Group>
  195. <Space size={70} >
  196. <Radio value={'1'}>核查通过</Radio>
  197. <Radio value={'0'}>核查未通过</Radio>
  198. </Space>
  199. </Radio.Group>
  200. </Form.Item>
  201. </Col>
  202. <Col span={24} hidden={type != 3}>
  203. <Form.Item
  204. name="lossCause"
  205. label="丢失原因"
  206. wrapperCol={{ span: 18 }}
  207. rules={[{ max: 200,message:'丢失原因不能超过200个字符' }]}
  208. >
  209. <TextArea
  210. autoSize={{ minRows: 5, maxRows: 5 }}
  211. placeholder="请输入"
  212. />
  213. </Form.Item>
  214. </Col>
  215. <Col span={24} hidden={type == 3}>
  216. {type != 3 ?
  217. <Form.Item label="日期" name="time" rules={[{ required: true }]} labelAlign="right">
  218. <RangePicker
  219. allowClear={false}
  220. placeholder={['开始时间', '结束时间']}
  221. disabledDate={disabledDate}
  222. onCalendarChange={val => setDates(val)}
  223. onChange={onChange}
  224. />
  225. </Form.Item>
  226. : ''}
  227. </Col>
  228. <Col span={24} hidden={type == 3} style={{ marginTop: 15 }}>
  229. <Form.Item label="住院序号" name="behospitalCode" rules={[{ max: 30,message:'住院序号不能超过30个字符' }]}>
  230. <Input placeholder="请输入" autoComplete='off' onChange={change} />
  231. </Form.Item>
  232. </Col>
  233. {
  234. type == 1 ?
  235. <div style={{ color: '#1690FF' }}>
  236. 提示:<br />
  237. 1、数据补录时间较长,请耐心等待。<br />
  238. 2、当输入住院序号时,补录将不受时间范围限制。<br />
  239. </div>
  240. :
  241. type == 2 ?
  242. <div style={{ color: '#1690FF' }}>
  243. 提示:当输入住院序号时,对比将不受时间范围限制。
  244. </div>
  245. : ''
  246. }
  247. <Form.Item wrapperCol={type == 3 ? { offset: 24, span: 16 } : { offset: 8, span: 16 }} style={{ marginTop: 15 }}>
  248. <Space size="middle" >
  249. <Button htmlType="button" onClick={e => cancel()}>
  250. 取消
  251. </Button>
  252. <Button type="primary" htmlType="submit" disabled={disable}>
  253. {type == 3 ? '保存' : '确定'}
  254. </Button>
  255. </Space>
  256. </Form.Item>
  257. </Form>
  258. </>
  259. );
  260. }
  261. export default EditBlock;