123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- import React, { Component } from "react";
- import style from "./index.less";
- import {
- timesYMDTime
- } from '@utils/tools';
- class PatInfo extends Component {
- constructor(props){
- super(props)
- this.state ={
- patientInfo: [
- {
- label: 'patientIdNo',
- id: 'patientIdNo',
- value: '330127198912311234',
- title: '卡号',
- maxlength: 50
- },
- {
- label: 'patientName',
- id: 'patientName',
- value: '王明明',
- title: '姓名',
- maxlength: 50
- },
- {
- label: 'patientAge',
- id: 'patientAge',
- value: '50',
- title: '年龄',
- maxlength: 11
- },
- {
- label: 'patientSex',
- id: 'patientSex',
- value: 2,
- title: '性别',
- maxlength: 11
- },
- {
- label: 'systemTime',
- id: 'systemTime',
- value: timesYMDTime(new Date().getTime()),
- title: '就诊时间',
- maxlength: 100
- },
- {
- label: 'hospitalDeptName',
- id: 'hospitalDeptName',
- value: '全科',
- title: '科室',
- maxlength: 50
- },
- {
- label: 'doctorName',
- id: 'doctorName',
- value: '付医生',
- title: '医生',
- maxlength: 50
- },
- {
- label: 'recordId',
- id: 'recordId',
- value: '4332',
- title: '门诊号',
- maxlength: 50
- }
- ]
- }
- this.handleChange = this.handleChange.bind(this)
- }
- componentWillMount() {
- const { getMessage, initPatInfoData } = this.props;
- getMessage && getMessage()
- initPatInfoData && initPatInfoData(this.state.patientInfo)
- // console.log(timesYMDTime(new Date().getTime()),'电脑时间');
- }
- componentWillReceiveProps(nextProps){
- // console.log(nextProps,'nextProps');
- const { patInfoData } = nextProps.patInfo
- this.setState({
- // patientInfo:patInfoData
- })
- }
- handleChange(e){
- const { initPatInfoData } = this.props;
- let { patientInfo } = this.state;
- let newInfo = Object.assign([], patientInfo);
- let patientItem = newInfo.find(item =>{
- return item.id === e.target.id
- })
- // 处理性别
- if (patientItem.id === 'patientSex'){
- if (e.target.value === '1') {
- patientItem.value = 1
- } else if (e.target.value === '2'){
- patientItem.value = 2
- } else {
- patientItem.value = 2 // 默认为女
- }
- } else if (patientItem.id === 'patientAge'){
- patientItem.value = e.target.value.replace(/[^\d]+/, '')
- } else {
- patientItem.value = e.target.value;
- }
- this.setState({
- patientInfo: newInfo
- })
- initPatInfoData && initPatInfoData(newInfo)
- }
- render(){
- const {message} = this.props.patInfo;
- return (
- <div className={style["infoContainer"]}>
- {
- this.state.patientInfo.map((item, index) => {
- return (
- <div className={style["infoItem"]} key={item.id}>
- <label for={item.label}>{item.title}:</label>
- {item.id === 'patientSex' && (
- <select id={item.id} value={item.value} onChange={this.handleChange}>
- <option value='1'>男</option>
- <option value='2'>女</option>
- </select>
- )}
- {item.id === 'patientAge' && (<input id={item.id} type="text" autocomplete="off" maxlength={11} value={item.value} onChange={this.handleChange} />)}
- {/* {item.id === 'patientSex' && (<input id={item.id} type="text" autocomplete="off" value={item.value == 1 ? '男' : '女'} onChange={this.handleChange} />)} */}
- {item.id === 'systemTime' && (<input id={item.id} type="text" autocomplete="off" disabled value={item.value } onChange={this.handleChange} />)}
- {item.id !== 'patientAge' && item.id !== 'patientSex' && item.id !== 'systemTime' && (<input id={item.id} type="text" maxlength={item.maxlength} autocomplete="off" value={item.value} onChange={this.handleChange} />) }
- </div>
- )
- })
- }
- </div>
- );
- }
- }
- export default PatInfo;
|