editBlock.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import React, {
  2. useState, useEffect, useContext
  3. } from 'react';
  4. import { Form, Col, DatePicker, Button, Radio, TreeSelect, 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. const { RangePicker } = DatePicker;
  10. const { post, api, xPost } = apiObj;
  11. const { TextArea } = Input;
  12. function EditBlock(props) {
  13. useEffect(() => {
  14. }, []);
  15. const [form] = Form.useForm();
  16. const { blockDetail, type } = useContext(BlockContext);
  17. const initialValues = blockDetail;
  18. console.log(initialValues);
  19. const onFinish = values => {
  20. if (type == 1) {
  21. } else if (type == 2) {
  22. dataCompare(values)
  23. } else {
  24. editBlock(values)
  25. }
  26. };
  27. function editBlock(values) {
  28. let params = {
  29. id: blockDetail.id,
  30. isAudited: values.isAudited,
  31. lossCause: values.lossCause
  32. }
  33. post(api.upBlockLossById, params).then((res) => {
  34. if (res.data.code === 200) {
  35. props.userChange()
  36. message.success(res.data.message);
  37. form.resetFields();
  38. } else {
  39. message.error(res.data.message);
  40. }
  41. })
  42. }
  43. //数据对比
  44. function dataCompare(values) {
  45. values.startDate = moment(values.time[0]).format('YYYY-MM-DD 00:00:00');
  46. values.endDate = moment(values.time[1]).format('YYYY-MM-DD 23:23:59');
  47. let params = {
  48. behospitalCode: values.behospitalCode,
  49. endDate: values.endDate,
  50. startDate: values.startDate
  51. }
  52. post(api.dataCompare, params).then((res) => {
  53. if (res.data.code === 200) {
  54. props.userChange()
  55. message.success(res.data.message);
  56. form.resetFields();
  57. } else {
  58. message.error(res.data.message);
  59. }
  60. })
  61. }
  62. function cancel() {
  63. props.userChange()
  64. }
  65. return (
  66. <>
  67. <Form
  68. labelCol={type == 3 ? { span: 8 } : { span: 4 }}
  69. wrapperCol={{ span: 16 }}
  70. form={form}
  71. name="register"
  72. layout={type == 3 ? 'inline' : 'horizontal'}
  73. onFinish={onFinish}
  74. initialValues={initialValues}
  75. >
  76. <Col span={12} hidden={type != 3}>
  77. <Form.Item
  78. name="behospitalCode"
  79. label="住院序号"
  80. >
  81. <span>{initialValues.behospitalCode}</span>
  82. </Form.Item>
  83. </Col>
  84. <Col span={12} hidden={type != 3}>
  85. <Form.Item
  86. name="recId"
  87. label="文书编号"
  88. >
  89. <span>{initialValues.recId}</span>
  90. </Form.Item>
  91. </Col>
  92. <Col span={12} hidden={type != 3}>
  93. <Form.Item
  94. name="recTitle"
  95. label="文书标题"
  96. >
  97. <span>{initialValues.recTitle}</span>
  98. </Form.Item>
  99. </Col>
  100. <Col span={12} hidden={type != 3}>
  101. <Form.Item
  102. name="lossType"
  103. label="丢失类型"
  104. >
  105. <span>{initialValues.lossType == 0 ? '文书丢失' : initialValues.lossType == 1 ? '病案首页丢失' : initialValues.lossType == 2 ? '患者信息丢失' : ''}</span>
  106. </Form.Item>
  107. </Col>
  108. <Col span={12} hidden={type != 3}>
  109. <Form.Item
  110. name="lossWay"
  111. label="丢失途径"
  112. >
  113. <span>{initialValues.lossWay == 0 ? '外部丢失' : initialValues.lossWay == 1 ? '内部丢失' : ''}</span>
  114. </Form.Item>
  115. </Col>
  116. <Col span={12} hidden={type != 3}>
  117. <Form.Item
  118. name="status"
  119. label="状态"
  120. >
  121. <span>{initialValues.status == 0 ? '已丢失' : initialValues.status == 1 ? '已恢复' : ''}</span>
  122. </Form.Item>
  123. </Col>
  124. <Col span={24} hidden={type != 3}>
  125. <Form.Item
  126. name="isAudited"
  127. label="核查结果"
  128. wrapperCol={{ span: 18 }}
  129. >
  130. <Radio.Group>
  131. <Space size={70} >
  132. <Radio value={'1'}>核查通过</Radio>
  133. <Radio value={'0'}>核查未通过</Radio>
  134. </Space>
  135. </Radio.Group>
  136. </Form.Item>
  137. </Col>
  138. <Col span={24} hidden={type != 3}>
  139. <Form.Item
  140. name="lossCause"
  141. label="丢失原因"
  142. wrapperCol={{ span: 18 }}
  143. >
  144. <TextArea
  145. autoSize={{ minRows: 5, maxRows: 5 }}
  146. />
  147. </Form.Item>
  148. </Col>
  149. <Col span={24} hidden={type == 3}>
  150. <Form.Item label="日期" name="time" rules={[{ required: true }]} labelAlign="right">
  151. <RangePicker
  152. placeholder={['开始时间', '结束时间']}
  153. />
  154. </Form.Item>
  155. </Col>
  156. <Col span={24} hidden={type == 3} style={{ marginTop: 15 }}>
  157. <Form.Item label="住院序号" name="behospitalCode">
  158. <Input placeholder="请输入" autoComplete='off' />
  159. </Form.Item>
  160. </Col>
  161. {
  162. type == 1 ?
  163. <div>
  164. 提示:<br />
  165. 1、补录时间范围限制为30天,每一天数据量的同步时间约为1分钟。<br />
  166. 时间范围以患者入院时间为准。<br />
  167. 2、当输入住院序号时,补录将不受时间范围限制。<br />
  168. </div>
  169. :
  170. type == 2 ?
  171. <div>
  172. 提示:将比对所有【已丢失】状态数据和患者入院在时间范围内的数据。
  173. </div>
  174. : ''
  175. }
  176. <Form.Item wrapperCol={type == 3 ? { offset: 24, span: 16 } : { offset: 8, span: 16 }} style={{ marginTop: 15 }}>
  177. <Space size="middle" >
  178. <Button htmlType="button" onClick={e => cancel()}>
  179. 取消
  180. </Button>
  181. <Button type="primary" htmlType="submit">
  182. 保存
  183. </Button>
  184. </Space>
  185. </Form.Item>
  186. </Form>
  187. </>
  188. );
  189. }
  190. export default EditBlock;