index.jsx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import React, { Component } from "react";
  2. import style from "./index.less";
  3. import Select from './Select/index'
  4. import { timesYMDTime, timestampToTime} from '@utils/tools';
  5. import config from '@config/index';
  6. import Notify from '@commonComp/Notify';
  7. import { getHospitalInfo } from '@store/async-actions/historyTemplates';
  8. import store from '@store';
  9. import { embedPush } from '../../store/async-actions/pushMessage'
  10. class PatInfo extends Component {
  11. constructor(props){
  12. super(props)
  13. this.state ={
  14. patientInfo: [
  15. {
  16. label: 'patientIdNo',
  17. id: 'patientIdNo',
  18. value: '330127198912311234',
  19. title: '卡号',
  20. maxlength: 50
  21. },
  22. {
  23. label: 'patientName',
  24. id: 'patientName',
  25. value: '王明明',
  26. title: '姓名',
  27. maxlength: 50
  28. },
  29. {
  30. label: 'patientAge',
  31. id: 'patientAge',
  32. value: '50',
  33. title: '年龄',
  34. maxlength: 11
  35. },
  36. {
  37. label: 'patientSex',
  38. id: 'patientSex',
  39. value: 2,
  40. title: '性别',
  41. maxlength: 11
  42. },
  43. {
  44. label: 'systemTime',
  45. id: 'systemTime',
  46. // value: timesYMDTime(new Date().getTime()),
  47. value: timestampToTime(new Date().getTime()),
  48. title: '就诊时间',
  49. maxlength: 100
  50. },
  51. {
  52. label: 'hospitalDeptName',
  53. id: 'hospitalDeptName',
  54. value: '全科',
  55. title: '科室',
  56. maxlength: 50
  57. },
  58. // {
  59. // label: 'doctorName',
  60. // id: 'doctorName',
  61. // value: '付医生',
  62. // title: '医生',
  63. // maxlength: 50
  64. // },
  65. {
  66. label: 'doctorName',
  67. id: 'doctorName',
  68. value: '医师',
  69. title: '医生职称',
  70. maxlength: 50
  71. },
  72. {
  73. label: 'recordId',
  74. id: 'recordId',
  75. value: '4332',
  76. title: '门诊号',
  77. maxlength: 50
  78. }
  79. ],
  80. timer: null,
  81. }
  82. this.handleChange = this.handleChange.bind(this)
  83. this.handleSexChange = this.handleSexChange.bind(this)
  84. this.inputOnFocus = this.inputOnFocus.bind(this)
  85. }
  86. componentWillMount() {
  87. const { getMessage, initPatInfoData } = this.props;
  88. getMessage && getMessage()
  89. initPatInfoData && initPatInfoData(this.state.patientInfo)
  90. store.dispatch(getHospitalInfo())
  91. // console.log(timesYMDTime(new Date().getTime()),'电脑时间');
  92. }
  93. componentWillReceiveProps(nextProps){
  94. // console.log(nextProps,'nextProps');
  95. const { patInfoData } = nextProps.patInfo
  96. this.setState({
  97. patientInfo:patInfoData
  98. })
  99. }
  100. handleChange(e){
  101. const tempTimer = this.state.timer
  102. const { initPatInfoData } = this.props;
  103. let { patientInfo } = this.state;
  104. let newInfo = Object.assign([], patientInfo);
  105. let patientItem = newInfo.find(item =>{
  106. return item.id === e.target.id
  107. })
  108. // if (patientItem.id === 'patientAge'){
  109. // let temp = Math.round(e.target.value.replace(/[^\d\.]+/, ''))
  110. // if (isNaN(temp)){
  111. // patientItem.value = 50
  112. // Notify.info('请输入正确的年龄')
  113. // return
  114. // }else {
  115. // patientItem.value = temp
  116. // }
  117. // } else {
  118. // patientItem.value = e.target.value;
  119. // }
  120. patientItem.value = e.target.value; // 20201014 取消年龄格式限制 lcq
  121. if (patientItem.id === 'patientAge' && +patientItem.value > 200) {
  122. Notify.info('年龄不能超过200')
  123. // return false
  124. }
  125. this.setState({
  126. patientInfo: newInfo
  127. })
  128. initPatInfoData && initPatInfoData(newInfo)
  129. // 年龄/科室改变时,默认延迟推送
  130. if (patientItem.id === 'patientAge' || patientItem.id === 'hospitalDeptName') {
  131. clearTimeout(tempTimer)
  132. let timer =setTimeout(() => {
  133. store.dispatch(embedPush({
  134. action: "info",
  135. mode: 1
  136. }))
  137. clearTimeout(tempTimer)
  138. }, config.delayPushTime);
  139. this.setState({
  140. timer
  141. })
  142. }
  143. }
  144. handleSexChange (item){
  145. const { initPatInfoData } = this.props;
  146. let { patientInfo } = this.state;
  147. let newInfo = Object.assign([], patientInfo);
  148. newInfo[3] = item
  149. this.setState({
  150. patientInfo: 'newInfo'
  151. })
  152. initPatInfoData && initPatInfoData(newInfo)
  153. }
  154. // 获取焦点推送
  155. inputOnFocus(){
  156. store.dispatch(embedPush({
  157. action: "info",
  158. mode: 1
  159. }))
  160. }
  161. render(){
  162. const {message} = this.props.patInfo;
  163. return (
  164. <div className={style["infoContainer"]}>
  165. {
  166. this.state.patientInfo.map((item, index) => {
  167. return (
  168. <div className={style["infoItem"]} key={item.id}>
  169. <label for={item.label}>{item.title}:</label>
  170. {item.id === 'patientSex' && (
  171. <Select
  172. default={this.state.patientInfo[3]}
  173. label=""
  174. placeholder="请选择"
  175. onChange={(item) => this.handleSexChange(item)}
  176. ></Select>
  177. )}
  178. {item.id === 'patientAge' && (<input id={item.id} type="text" autocomplete="off" maxlength={11} value={item.value} onChange={this.handleChange} onFocus={this.inputOnFocus}/>)}
  179. {item.id === 'systemTime' && (<input id={item.id} type="text" autocomplete="off" disabled value={item.value.split(' ')[0]} onChange={this.handleChange} onFocus={this.inputOnFocus}/>)}
  180. {item.id !== 'patientAge' && item.id !== 'patientSex' && item.id !== 'systemTime' && (<input id={item.id} type="text" maxlength={50} autocomplete="off" value={item.value} onChange={this.handleChange} onFocus={this.inputOnFocus}/>) }
  181. </div>
  182. )
  183. })
  184. }
  185. </div>
  186. );
  187. }
  188. }
  189. export default PatInfo;