// 查用户
import React from 'react';
import { Row, Col, Select, Button, Input,Card,Icon,message} from 'antd';
import OfficePanel from './OfficePanel'
import { $http } from 'containers/config/https';

const { Option } = Select;
export default class Office extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			// 用户
			visitType: "userCode",
			// 用户的ID
			value: undefined,
		};
	}

	// 查询条件 ---  用户工号
	onChangeVisitType = (value) => {
		this.setState({ visitType: value });
	}

	// 查询条件 ---  用户ID
	// onChangeSelectPhysician = (e) => {
	// 	this.setState({ value: e.target.value });
	// }
	//查询条件 ---  用户ID
	onChangeSelectPhysician = (e) => {
		this.setState({
			value: e.target.value 
		})
	}
	//查询用户
	onSearchClick = () => {
		var userData = JSON.parse(sessionStorage.getItem('userData'));
		let credTypeId = "";
		if (this.state.visitType === "credNo") {
			credTypeId = "1";
		}
		const data = {
			params: [{
				hospID: userData.hospID,
				[this.state.visitType]: this.state.value,
				userCredTypeID: credTypeId,
				userTypeFlag:"Y",
				locID: this.props.locID,

			}],
		}

		$http.post('urlS', this, {
			code: "01040051",
			data: data,
			success: (res) => { 
				if (+res.errorCode === 0) {
					// console.log(res)
					// this.refs.OfficePanel.setThisState(
                    //     "dataSource",res.result
					// )
					this.setState({
						newData: res.result
					})
				
                }
			}
		})
	}


    goback() {
		//console.log(this.props.editStauts)
		let {goback, handleThis} = this.props;
		handleThis.handleQuery()
		goback && goback();
		this.props.changeEditStatus()
		setTimeout(() => {
			handleThis.closeListLoading()
		}, 300)
    }
	render() {
		return (
			<div>
               
				<div style={{ width: '100%', height: '100%' }}>
					{this.props.editStauts ? null : <div className="table-operations">
						<Row style={{ height: '80px', padding: '0 24px', paddingTop: '10px' }}>
							<Col span={24}>
								查找类别：<Select allowClear value={this.state.visitType} onChange={this.onChangeVisitType} style={{ width: '150px', marginRight: '20px' }} placeholder="请选择查找类别">
									<Option value="userCode">工号</Option>
									<Option value="userCredNo">居民身份证</Option>
									<Option value="userName">用户名</Option>
									<Option value="userMobile">手机号</Option>
								</Select>
								<Input allowClear onChange={this.onChangeSelectPhysician}  onPressEnter={this.onSearchClick} value={this.state.value} style={{ width: '260px', marginRight: '20px' }} />
								<Button style={{ marginRight: '15px', background: 'rgba(255,255,255,1)' }} onClick={this.onSearchClick}>查询</Button>
							</Col>
						
								<p style={{height:'36px',paddingLeft: '70px', color: 'red' }}>说明：此处为科内人员授权处理，维护科室人员前，需先添加人员基本资料到"用户信息"菜单</p>
							

						</Row>
					</div>}
					<div style={{ widht: '100%', height: '10px', background: '#f0f2f5' }}></div>
					<OfficePanel
						dataSource={this.props.dataSource}
						locID={this.props.locID}
						goback={this.goback.bind(this)}
						ref="OfficePanel"
						newData={this.state.newData}
						handThis={this}
					>
					</OfficePanel>
				</div>
			</div>

		)
	}
}