// 科室基本信息
import React from 'react';
import { Form, Row, Col, Input, Select, TimePicker, Switch, Upload, Button, Icon, message, DatePicker } from 'antd';
import { $http } from '../../../containers/config/https';
import { Util } from '../../../tools';
import store from 'store';
import Moment from 'moment';
import PublicModalTable from '../../common/PublicModalTable.jsx';

const { Option } = Select;
const InputGroup = Input.Group;
const { TextArea } = Input;

const DepartmentBasicInformation = Form.create()(
	class extends React.Component {
		constructor() {
			super();
			this.state = {
				loading: false,
				imageUrl: '',
				selectData: {}, // 下拉框数据
				hospitalData: [], // 所属医院下拉框数据
				docterPage: 1,
				docterPageSize: 10,
				doctorData: [],
				doctorTotal: 0,
				doctorRowData: {}, // 选中的行医生数据
				doctorValue: '', //
				docterTop: 0,
				docterLeft: 0,
				docterAndNurse: 'docter', // 回车点击的是科主任还是护士长
				nursePage: 1,
				nursePageSize: 10,
				nurseData: [],
				nurseTotal: 0,
				nurseRowData: {},
				nurseTop: 0,
				nurseLeft: 0,
				user: {},
				isTransitionStart: false, // 上班时间
				isTransitionStop: false, // 上班时间
			}
			this.myRef1 = React.createRef();
			this.myRef2 = React.createRef();
			this.myRef3 = React.createRef();
			this.myRef4 = React.createRef();
			this.myRef5 = React.createRef();
			this.myRef6 = React.createRef();
			this.myRef7 = React.createRef();
			this.myRef8 = React.createRef();
			this.myRef9 = React.createRef();
			this.myRef10 = React.createRef();
			this.myRef11 = React.createRef();
			this.myRef12 = React.createRef();
			this.myRef13 = React.createRef();
			this.myRef14 = React.createRef();
			this.myRef15 = React.createRef();
			this.myRef16 = React.createRef();
			this.myRef17 = React.createRef();
			this.myRef18 = React.createRef();
			this.myRef19 = React.createRef();
			this.myRef20 = React.createRef();
			this.myRef21 = React.createRef();
			this.myRef22 = React.createRef();
			this.myRef23 = React.createRef();
			this.myRef24 = React.createRef();
			this.myRef25 = React.createRef();
			this.myRef26 = React.createRef();
			this.myRef27 = React.createRef();
			this.myRef28 = React.createRef();
			this.myRef29 = React.createRef();
			this.columns = [
				{
					key: 1,
					title: 'code',
					dataIndex: 'code',
					align: "center",
				},
				{
					key: 2,
					title: '性名',
					dataIndex: 'descripts',
					align: "center",
				},
				{
					key: 3,
					title: '手机号',
					dataIndex: 'mobile',
					align: "center",
				}
			];
		}

		componentDidMount() {
			let user = sessionStorage ? JSON.parse(sessionStorage.getItem('userData')) : {};
			this.setState({ user }, () => {
				// 初始化数据
				this.getSelectData();
				this.loadHospitalMsg();
				this.handleOnOpenChangeStart();
				this.handleOnOpenChangeStop();
			})
			this.props.onRef(this);
			this.loadLocList();
			this.loadspecialtyGrade()
		}

		// 获取下拉框数据
		getSelectData() {
			let data = {
				params: [
					{
						locTypeFlag: '1',
						buildFlag: '1',
						floorFlag: '1',
						sexFlag: '1'
					}
				]
			}
			$http.post('urlS', this, {
				code: "01040009",
				data: data,
				success: function (res) {
					if (+res.errorCode === 0) {
						this.setState({ selectData: res })
					} else {
						this.setState({ selectData: {} })
					}
				}
			})
		}

		//获取所属医院
		loadHospitalMsg() {
			let { user } = this.state;
			var data = {
				params: [{
					hospID: '', // 医院id
					logonGroupID: user.groupID ? user.groupID : '', //登录角色id
					logonHospID: user.hospID ? user.hospID : '', // 登录医院id
				}]
			}
			$http.post('urlS', this, {
				code: "01040001",
				data: data,
				success: function (res) {
					// console.log(res)
					if (+res.errorCode === 0) {
						this.setState({
							hospitalData: res.depDoctor
						})
					}
				}
			});
		}
		//获取科室表下拉
		loadLocList() {
			var data = {
				params: [{
				}]
			}
			$http.post('urlS', this, {
				code: "01040187",
				data: data,
				success: function (res) {
					// console.log(res)
					if (+res.errorCode === 0) {
						this.setState({
							locListData: res.result.data
						})
					}
				}
			});
		}
		//获取重点专科级别下拉
		loadspecialtyGrade() {
			var data = {
				params: [{

				}]
			}
			$http.post('urlS', this, {
				code: "01040186",
				data: data,
				success: function (res) {
					// console.log(res)
					if (+res.errorCode === 0) {
						this.setState({
							specialtyGradeData: res.result.data
						})
					}
				}
			});
		}

		handelFunction(code) {
			this.props.form.validateFields((err, values) => {
				if (!err) {
					// 将true和false转换为Y/N
					values.locWorkStartTime = values.locWorkStartTime ? Moment(values.locWorkStartTime).format('HH:mm') : '';
					values.locWorkStopTime = values.locWorkStopTime ? Moment(values.locWorkStopTime).format('HH:mm') : '';
					values.locID = this.props.flag === 'compile' ? this.props.userInfo.locID : "";
					values.locOrdDsp = Util.replaceTrueFalse(values.locOrdDsp);
					values.locRecOthHospItem = Util.replaceTrueFalse(values.locRecOthHospItem);
					values.locToOthHospItem = Util.replaceTrueFalse(values.locToOthHospItem);
					values.locGetRecLoc = Util.replaceTrueFalse(values.locGetRecLoc);
					values.locIsObstetricsDep = Util.replaceTrueFalse(values.locIsObstetricsDep);
					values.locQualityCareDep = Util.replaceTrueFalse(values.locQualityCareDep);
					values.locCBLocID = values.locCBLocID || "";
					values.locSpecialtyGradeID = values.locSpecialtyGradeID || "";
					values.locStopDate = values.locStopDate ? Moment(values.locStopDate).format('YYYY-MM-DD') : undefined; // 失效日期
					values.locDirectorID = values.locDirectorName && this.state.doctorRowData.id ? this.state.doctorRowData.id : (this.props.userInfo ? this.props.userInfo.locDirectorID : '');
					values.locHeadNurID = values.locHeadNurName && this.state.nurseRowData.id ? this.state.nurseRowData.id : (this.props.userInfo ? this.props.userInfo.locHeadNurID : '');
					let data = {
						params: []
					}
					data.params.push(values)
					$http.post('urlADS', this, {
						code: code,
						data: data,
						success: function (res) {
							if (+res.errorCode === 0) {
								// 成功提示
								this.props.handleThis.compilelocID(res.locID ? res.locID : '', res.locTypeCode ? res.locTypeCode : '', values);
								if (this.props.flag === 'add') {
									message.success('新增成功');
								} else {
									message.success('编辑成功');
								}
							}
						}
					})
				}
			});
		}

		// 保存
		handelSave = (e) => {
			// e.preventDefault();
			this.handelFunction('01050004');
			// let { flag } = this.props;
			// if (flag === 'compile') {
			// 	this.handelFunction('01050004', '编辑');
			// } else {
			// 	this.handelFunction('01050002', '新增');
			// }
		}

		// 图片上传操作
		normFile = (info) => {
			// console.log(info);
			if (info.file.status === 'uploading') {
				this.setState({ loading: true });
				// return;
			}
			if (info.file.status === 'done') {
				this.getBase64(info.file.originFileObj, imageUrl => this.setState({
					imageUrl,
					loading: false,
				}));
			}
			setTimeout(() => {
				this.setState({ loading: false })
			}, 5000)
		}

		// 文件正式上传前执行的操作，返回true才会继续上传
		beforeUpload = (file) => {
			// const isJPG = file.type === 'image/jpeg';
			// if (!isJPG) {
			//   message.error('只能上传Jpg格式的图片!');
			// }
			const isLt2M = file.size / 1024 / 1024 < 2;
			if (!isLt2M) {
				message.error('图像必须小于2MB!');
			}
			// return isJPG && isLt2M;
			return isLt2M
		}

		// 将图片转成 base64， 可以用于图片预览
		getBase64 = (img, callback) => {
			const reader = new FileReader();
			reader.addEventListener('load', () => callback(reader.result));
			reader.readAsDataURL(img);
		}

		// 下拉框选中事件
		handleOnSelect = (num) => {
			switch (num) {
				case 1:
					setTimeout(() => {
						this.myRef2.current.focus();
					}, 300)
					break;
				case 2:
					setTimeout(() => {
						this.myRef3.current.focus();
					}, 300)
					break;
				case 3:
					setTimeout(() => {
						this.myRef4.current.focus();
					}, 300)
					break;
				case 4:
					setTimeout(() => {
						this.myRef28.current.focus();
					}, 300)
					break;
				case 27:
					setTimeout(() => {
						this.myRef29.current.focus();
					}, 300)
					break;
				case 28:
					setTimeout(() => {
						this.myRef5.current.focus();
					}, 300)
					break;
				case 5:
					setTimeout(() => {
						this.myRef6.current.focus();
					}, 300)
					break;
				case 6:
					setTimeout(() => {
						this.myRef7.current.focus();
					}, 300)
					break;
				case 7:
					setTimeout(() => {
						this.myRef8.current.focus();
					}, 300)
					break;
				case 8:
					setTimeout(() => {
						this.myRef9.current.focus();
					}, 300)
					break;
				case 9:
					setTimeout(() => {
						this.myRef10.current.focus();
					}, 300)
					break;
				case 10:
					setTimeout(() => {
						this.myRef11.current.focus();
					}, 300)
					break;
				case 11:
					setTimeout(() => {
						this.myRef12.current.focus();
					}, 300)
					break;
				case 12:
					setTimeout(() => {
						this.myRef13.current.focus();
					}, 300)
					break;
				case 13:
					setTimeout(() => {
						this.myRef14.current.focus();
					}, 300)
					break;
				case 14:
					setTimeout(() => {
						this.myRef15.current.focus();
					}, 300)
					break;
				case 15:
					setTimeout(() => {
						this.myRef16.current.focus();
					}, 300)
					break;
				case 18:
					setTimeout(() => {
						this.myRef19.current.focus();
					}, 300)
					break;
				case 19:
					setTimeout(() => {
						this.myRef20.current.focus();
					}, 300)
					break;
				case 20:
					setTimeout(() => {
						this.myRef21.current.focus();
					}, 300)
					break;
				case 21:
					setTimeout(() => {
						this.myRef22.current.focus();
					}, 300)
					break;
				case 22:
					setTimeout(() => {
						this.myRef23.current.focus();
					}, 300)
					break;
				case 23:
					setTimeout(() => {
						this.myRef24.current.focus();
					}, 300)
					break;
				case 24:
					setTimeout(() => {
						this.myRef27.current.focus();
					}, 300)
					break;
				case 25:
					setTimeout(() => {
						this.myRef26.current.buttonNode.focus();
					}, 300)
					break;
				case 26:
					setTimeout(() => {
						this.myRef25.current.focus();
					}, 300)
					break;
				default:
					setTimeout(() => {
						this.myRef26.current.buttonNode.focus();
					}, 300)
			}
		}

		// 接受年龄范围后面输入的年龄必须比前面大
		handleAgeTo = (rule, value, callback) => {
			const { getFieldValue } = this.props.form;
			if (!(/^[0-9]\d*$/).test(value) && value) {
				callback('年龄范围只能为整数, 如1、2、3、4');
			}
			if (value && +value < +getFieldValue('locAgeFrom')) {
				callback('应当大于初始年龄');
			}
			// Note: 必须总是返回一个 callback，否则 validateFieldsAndScroll 无法响应
			callback();
		}

		// 上下班时间后面输入的时间必须比前面大
		handleWorkStopDate = (rule, value, callback) => {
			const { getFieldValue } = this.props.form;
			let start = Moment(getFieldValue('locWorkStartTime')).format('HH:mm:ss');
			let end = Moment(value).format('HH:mm:ss');
			// console.log(start > end)
			if (value && end < start) {
				callback('应当晚于上班时间');
			}
			callback();
		}

		// 返回到列表页面
		goBack = () => {
			this.props.handleThis.goBack()
		}

		// 获取医生列表数据
		getDocterListData(values) {
			let { docterPage, docterPageSize } = this.state;
			let data = {
				params: [
					{
						input: values,
					}
				],
				pagination: [
					{
						currentPage: docterPage,
						pageSize: docterPageSize
					}
				]

			}
			$http.post('urlS', this, {
				code: "01040003",
				data: data,
				success: function (res) {
					// console.log(res)
					if (+res.errorCode === 0) {
						for (var i = 0; i < res.Data.length; i++) {
							res.Data[i].key = i
						}
						this.setState({ doctorData: res.Data, doctorTotal: res.TotalCount })
					}
				}
			})
		}

		// 获取护士长信息
		getNurseListData(values) {
			let { nursePage, nursePageSize } = this.state;
			let data = {
				params: [
					{
						input: values,
					}
				],
				pagination: [
					{
						currentPage: nursePage,
						pageSize: nursePageSize
					}
				]

			}
			$http.post('urlS', this, {
				code: "01040004",
				data: data,
				success: function (res) {
					// console.log(res)
					if (+res.errorCode === 0) {
						for (var i = 0; i < res.Data.length; i++) {
							res.Data[i].key = i
						}
						this.setState({ nurseData: res.Data, nurseTotal: res.TotalCount })
					}
				}
			})
		}

		// 获取科主任信息
		getDoctorData = (e) => {
			this.setState({ docterAndNurse: 'docter' });
			let top = document.getElementById('director-dr').getBoundingClientRect().top + 40 + 32 + 'px';
			let left = document.getElementById('director-dr').getBoundingClientRect().left + 8 + 'px';
			this.setState({
				docterTop: top,
				docterLeft: left,
				docterPage: 1,
				docterPageSize: 10,
				doctorValue: e.target.value
			}, () => {
				let { doctorValue } = this.state;
				this.getDocterListData(doctorValue);
			});
			this.child.showModal();
		}

		// 获取护士长信息
		getHeadNurseDr = (e) => {
			this.setState({ docterAndNurse: 'nurse' })
			let top = document.getElementById('head-nurse').getBoundingClientRect().top + 40 + 32 + 'px';
			let left = document.getElementById('head-nurse').getBoundingClientRect().left + 8 + 'px';
			this.setState({
				nurseTop: top,
				nurseLeft: left,
				nursePage: 1,
				nursePageSize: 10,
				nurseValue: e.target.value
			}, () => {
				let { nurseValue } = this.state;
				this.getNurseListData(nurseValue);
			});
			this.child.showModal();
		}

		onRef = (ref) => {
			this.child = ref;
		}

		// 科主任操作弹框
		onClickRowDoctor = (record) => {
			return {
				onDoubleClick: () => {
					this.confirmSelectionDoctor(record);
				}
			}
		}

		// 双击选中科主任行数据的回调
		confirmSelectionDoctor = (record) => {
			this.setState({ doctorRowData: record }, () => {
				this.props.form.setFieldsValue({ locDirectorTel: record.mobile, locDirectorName: record.descripts })
				// 关闭弹窗
				this.child.handleCancel();
				this.handleOnSelect(9)
			})
		}

		compileDoctorPage = (page, pageSize) => {
			this.setState({ docterPage: page, docterPageSize: pageSize }, () => {
				this.getDocterListData()
			})
		}

		// 护士长操作弹框
		onClickRowNurse = (record) => {
			return {
				onDoubleClick: () => {
					this.confirmSelectionNurse(record);
				}
			}
		}

		// 双击选中护士长行数据的回调
		confirmSelectionNurse = (record) => {
			this.setState({ nurseRowData: record }, () => {
				this.props.form.setFieldsValue({ locHeadNurTel: record.mobile, locHeadNurName: record.descripts })
				// 关闭弹窗
				this.child.handleCancel();
				this.handleOnSelect(11)
			})
		}

		compileNursePage = (page, pageSize) => {
			this.setState({ nursePage: page, nursePageSize: pageSize }, () => {
				this.getNurseListData()
			})
		}

		// 当科主任失去焦点后
		onBlurDirector = (e) => {
			let doctorRowData = this.state.doctorRowData
			let descripts = doctorRowData && doctorRowData.descripts ? doctorRowData.descripts : (this.props.userInfo && this.props.userInfo.locDirectorName ? this.props.userInfo.locDirectorName : '')
			if (e.target.value !== descripts) {
				this.props.form.setFieldsValue({ locDirectorName: undefined });
			}
		}

		// 当科主任失去焦点后
		onBlurHeadNurse = (e) => {
			let nurseRowData = this.state.nurseRowData
			let descripts = nurseRowData && nurseRowData.descripts ? nurseRowData.descripts : (this.props.userInfo && this.props.userInfo.locHeadNurName ? this.props.userInfo.locHeadNurName : '')
			if (e.target.value !== descripts) {
				this.props.form.setFieldsValue({ locHeadNurName: undefined });
			}
		}

		handleLocWorkStartTimeOnSelect = (e) => {
			this.props.form.setFieldsValue({ locWorkStartTime: e });
			setTimeout(() => {
				this.myRef17.current.focus();
			}, 300)
		}

		// 展开/关闭上班时间
		handleOnOpenChangeStart = (status) => {
			if (!status) {
				this.setState({ isTransitionStart: true })
			} else {
				this.setState({ isTransitionStart: false })
			}
		}

		// 展开/关闭下班时间
		handleOnOpenChangeStop = (status) => {
			if (!status) {
				this.setState({ isTransitionStop: true })
			} else {
				this.setState({ isTransitionStop: false })
			}
		}

		handleLocWorkStopTimeOnSelect = (e) => {
			this.props.form.setFieldsValue({ locWorkStopTime: e });
			setTimeout(() => {
				this.myRef18.current.focus();
			}, 300)
		}

		// 重置表单
		resetFields = () => {
			this.props.form.resetFields();
		}

		render() {
			const { getFieldDecorator } = this.props.form;
			let userInfo = this.props.userInfo ? this.props.userInfo : {};
			const uploadButton = (
				<div>
					<Icon type={this.state.loading ? 'loading' : 'plus'} />
					<div className="ant-upload-text">上传</div>
				</div>
			);
			const imageUrl = this.state.imageUrl;
			let param = {
				width: 540,
				top: this.state.docterAndNurse === 'docter' ? this.state.docterTop : this.state.nurseTop,
				left: this.state.docterAndNurse === 'docter' ? this.state.docterLeft : this.state.nurseLeft,
				height: 400,
				columns: this.columns,
				data: this.state.docterAndNurse === 'docter' ? this.state.doctorData : this.state.nurseData,
				isOnRow: true,
				showPagination: true,
				total: this.state.docterAndNurse === 'docter' ? this.state.doctorTotal : this.state.nurseTotal,
				page: this.state.docterAndNurse === 'docter' ? this.state.docterPage : this.state.nursePage
			}
			return (
				<div style={{ height: store.getState().tableHeight.y + 178 + 'px', overflow: 'auto' }}>
					<Form layout="vertical" className="depart-form" style={{ margin: '12px 100px 0 12px', }}>
						{/* 第一行 */}
						<Row gutter={16}>
							<Col span={6}>
								<Form.Item label="所属医院">
									{getFieldDecorator('locHospID', {
										initialValue: userInfo.locHospID ? +userInfo.locHospID : undefined,
										rules: [{ required: true, message: '请选择所属医院' }]
									})(
										<Select showSearch optionFilterProp="seatchprop" placeholder="请选择所属医院" ref={this.myRef1} onSelect={() => this.handleOnSelect(1)}>
											{this.state.hospitalData && this.state.hospitalData.map(item => {
												return <Option value={+item.id} key={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
											})}
										</Select>
									)}
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="科室代码">
									{getFieldDecorator('locCode', {
										initialValue: userInfo.locCode ? userInfo.locCode : '',
										rules: [{ required: true, message: '请输入科室代码' }],
									})(
										<Input placeholder="请输入科室代码" className='input' ref={this.myRef2} onPressEnter={() => this.handleOnSelect(2)} />
									)}
								</Form.Item>
							</Col>
							<Col span={3}>
								<Form.Item label="科室名称">
									{getFieldDecorator('locDesc', {
										initialValue: userInfo.locDesc ? userInfo.locDesc : '',
										rules: [{ required: true, message: '请输入科室名称' }],
									})(
										<Input placeholder="请输入科室名称" className='input' ref={this.myRef3} onPressEnter={() => this.handleOnSelect(3)} />
									)}
								</Form.Item>
							</Col>
							<Col span={3}>
								<Form.Item label="科室类型">
									{getFieldDecorator('locTypeID', {
										initialValue: userInfo.locTypeID ? userInfo.locTypeID : undefined,
										rules: [{ required: true, message: '请选择科室类型' }]
									})(
										<Select showSearch optionFilterProp="seatchprop" placeholder="请选择科室类型" ref={this.myRef4} onSelect={() => this.handleOnSelect(4)}>
											{this.state.selectData.locType && this.state.selectData.locType.map(item => {
												return <Option value={item.id} key={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
											})}
										</Select>
									)}
								</Form.Item>
							</Col>
							<Col span={3}>
								<Form.Item label="科室表">
									{getFieldDecorator('locCBLocID', {
										initialValue: userInfo.locCBLocID ? userInfo.locCBLocID : '',
										rules: [{ required: false, message: '' }],
									})(
										<Select showSearch allowClear optionFilterProp="seatchprop" placeholder="请选择科室表" ref={this.myRef28} onSelect={() => this.handleOnSelect(27)}>
											{this.state.locListData && this.state.locListData.map(item => {
												return <Option value={item.id} key={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
											})}
										</Select>
									)}
								</Form.Item>
							</Col>
							<Col span={3}>
								<Form.Item label="重点专科级别">
									{getFieldDecorator('locSpecialtyGradeID', {
										initialValue: userInfo.locSpecialtyGradeID ? userInfo.locSpecialtyGradeID : undefined,
										rules: [{ required: false, message: '' }]
									})(
										<Select showSearch allowClear optionFilterProp="seatchprop" placeholder="请选择专科级别" ref={this.myRef29} onSelect={() => this.handleOnSelect(28)}>
											{this.state.specialtyGradeData && this.state.specialtyGradeData.map(item => {
												return <Option value={item.id} key={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
											})}
										</Select>
									)}
								</Form.Item>
							</Col>
						</Row>
						{/* 第二行 */}
						<Row gutter={16}>
							<Col span={6}>
								<Form.Item label="科室地址">
									{getFieldDecorator('locAddress', {
										initialValue: userInfo.locIPAddress ? userInfo.locIPAddress : (userInfo.locOPAddress ? userInfo.locOPAddress : ''),
										rules: [{ required: true, message: '请输入科室地址' }]
									})(
										<Input placeholder="请输入科室地址" className='input' ref={this.myRef5} onPressEnter={() => this.handleOnSelect(5)} />
									)}
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="科室楼号">
									{getFieldDecorator('locBuildID', {
										initialValue: userInfo.locBuildID ? userInfo.locBuildID : undefined,
										rules: [{ required: true, message: '请选择科室楼号' }]
									})(
										<Select showSearch optionFilterProp="seatchprop" placeholder="请选择科室楼号" ref={this.myRef6} onSelect={() => this.handleOnSelect(6)}>
											{this.state.selectData.build && this.state.selectData.build.map(item => {
												return <Option value={item.id} key={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
											})}
										</Select>
									)}
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="科室楼层">
									{getFieldDecorator('locFloorID', {
										initialValue: userInfo.locFloorID ? userInfo.locFloorID : undefined,
										rules: [{ required: true, message: '请选择科室楼层' }]
									})(
										<Select showSearch optionFilterProp="seatchprop" placeholder="请选择科室楼层" ref={this.myRef7} onSelect={() => this.handleOnSelect(7)}>
											{this.state.selectData.floor && this.state.selectData.floor.map(item => {
												return <Option value={item.id} key={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
											})}
										</Select>
									)}
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="科室电话">
									{getFieldDecorator('locTel', {
										initialValue: userInfo.locTel ? userInfo.locTel : undefined,
										rules: [{ pattern: /^1[34578]\d{9}$/, message: '请输入正确的手机号' }],
									})(
										<Input placeholder="请输入科室电话" className='input' ref={this.myRef8} onPressEnter={() => this.handleOnSelect(8)} />
									)}
								</Form.Item>
							</Col>
						</Row>
						{/* 第三行 */}
						<Row gutter={16}>
							<Col span={6} id="director-dr">
								<Form.Item label="科主任">
									{getFieldDecorator('locDirectorName', {
										initialValue: userInfo.locDirectorName ? userInfo.locDirectorName : undefined,
									})(
										<Input placeholder="回车检索科主任相关信息" ref={this.myRef9} onPressEnter={this.getDoctorData} onBlur={this.onBlurDirector} />
									)}
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="科主任电话">
									{getFieldDecorator('locDirectorTel', {
										initialValue: userInfo.locDirectorTel ? userInfo.locDirectorTel : undefined,
										rules: [{ pattern: /^1[34578]\d{9}$/, message: '请输入正确的手机号' }],
									})(
										<Input type="number" placeholder="请输入科主任电话" className='input input-number' ref={this.myRef10} onPressEnter={() => this.handleOnSelect(10)} />
									)}
								</Form.Item>
							</Col>
							<Col span={6} id='head-nurse'>
								<Form.Item label="护士长">
									{getFieldDecorator('locHeadNurName', {
										initialValue: userInfo.locHeadNurName ? userInfo.locHeadNurName : undefined,
									})(
										<Input placeholder="回车检索护士长相关信息" ref={this.myRef11} onPressEnter={this.getHeadNurseDr} onBlur={this.onBlurHeadNurse} />
									)}
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="护士长电话">
									{getFieldDecorator('locHeadNurTel', {
										initialValue: userInfo.locHeadNurTel ? userInfo.locHeadNurTel : undefined,
										rules: [{ pattern: /^1[34578]\d{9}$/, message: '请输入正确的手机号' }],
									})(
										<Input type="number" placeholder="请输入护士长电话" className='input input-number' ref={this.myRef12} onPressEnter={() => this.handleOnSelect(12)} />
									)}
								</Form.Item>
							</Col>
						</Row>
						{/* 第四行 */}
						<Row gutter={16}>
							<Col span={6}>
								<Form.Item label="接收病人年龄范围">
									<InputGroup>
										<Row gutter={16} style={{ lineHeight: '32px' }}>
											<Col span={10} style={{ paddingLeft: 0, paddingRight: 0 }}>
												{getFieldDecorator('locAgeFrom', {
													initialValue: userInfo.locAgeFrom ? userInfo.locAgeFrom : undefined,
													rules: [{ pattern: /^[0-9]\d*$/, message: '年龄范围只能为整数, 如1、2、3、4' }]
												})(
													<Input placeholder="初始年龄" type="number" className="input-number" ref={this.myRef13} onPressEnter={() => this.handleOnSelect(13)} />
												)}
											</Col>
											<Col span={2}>至</Col>
											<Col span={10} style={{ paddingRight: 0 }}>
												<Form.Item>
													{getFieldDecorator('locAgeTo', {
														initialValue: userInfo.locAgeTo ? userInfo.locAgeTo : undefined,
														rules: [{ validator: this.handleAgeTo }]
													})(
														<Input placeholder="" type="number" className="input-number" ref={this.myRef14} onPressEnter={() => this.handleOnSelect(14)} />
													)}
												</Form.Item>
											</Col>
											<Col span={2}>岁</Col>
										</Row>
									</InputGroup>
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="接收病人性别">
									{getFieldDecorator('locSexID', {
										initialValue: userInfo.locSexID ? userInfo.locSexID : undefined,
									})(
										<Select showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择性别" ref={this.myRef15} onSelect={() => this.handleOnSelect(15)}>
											{this.state.selectData.sex && this.state.selectData.sex.map(item => {
												return <Option value={item.id} key={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
											})}
										</Select>
									)}
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="上下班时间">
									<Row gutter={16} style={{ lineHeight: '32px' }}>
										<Col span={9} className="input_group-time_picker">
											{getFieldDecorator('locWorkStartTime', {
												initialValue: userInfo.locWorkStartTime ? Moment(userInfo.locWorkStartTime, 'HH:mm') : Moment("00:00:00", 'HH:mm'),
											})(
												<TimePicker separator=":" showToday format={this.state.isTransitionStart ? 'HH:mm' : 'HHmm'} onOpenChange={this.handleOnOpenChangeStart} style={{ width: '100%' }} placeholder="上班时间" ref={this.myRef16} onChange={this.handleLocWorkStartTimeOnSelect} />
											)}
										</Col>
										<Col span={2}>至</Col>
										<Col span={9} className="input_group-time_picker" style={{ marginLeft: '8px' }}>
											<Form.Item style={{ width: '100%' }}>
												{getFieldDecorator('locWorkStopTime', {
													initialValue: userInfo.locWorkStopTime ? Moment(userInfo.locWorkStopTime, 'HH:mm') : Moment("23:59:00", 'HH:mm'),
													// rules: [{
													// 	validator: this.handleWorkStopDate
													// }],
												})(
													<TimePicker separator=":" showToday format={this.state.isTransitionStop ? 'HH:mm' : 'HHmm'} onOpenChange={this.handleOnOpenChangeStop} style={{ width: '100%' }} placeholder="下班时间" ref={this.myRef17} onChange={this.handleLocWorkStopTimeOnSelect} />
												)}
											</Form.Item>
										</Col>
									</Row>
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="会诊地址">
									{getFieldDecorator('locConsultLocation', {
										initialValue: userInfo.locConsultLocation ? userInfo.locConsultLocation : undefined,
									})(
										<Input placeholder="请输入会诊地址" className='input' ref={this.myRef18} onPressEnter={() => this.handleOnSelect(18)} />
									)}
								</Form.Item>
							</Col>
						</Row>
						{/* 第五行 */}
						<Row gutter={16}>
							<Col span={6}>
								<Form.Item label="失效日期：">
									{getFieldDecorator('locStopDate', {
										initialValue: userInfo.locStopDate ? Moment(userInfo.locStopDate, 'YYYY-MM-DD') : undefined,
									})(
										<DatePicker style={{ width: '100%' }} format="YYYY-MM-DD" allowClear ref={this.myRef19} onChange={() => this.handleOnSelect(19)} />
									)}
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="更新时间">
									{getFieldDecorator('locUpdateTime', {
										initialValue: userInfo.locUpdateDate && userInfo.locUpdateTime ? userInfo.locUpdateDate + " " + userInfo.locUpdateTime : Moment().format('YYYY-MM-DD HH:mm:ss'),
									})(
										<Input placeholder="更新时间" disabled />
									)}
								</Form.Item>
							</Col>
							<Col span={6}>
								<Form.Item label="操作员">
									{getFieldDecorator('locUpdateUserDesc', {
										initialValue: userInfo.locUpdateUserDesc ? userInfo.locUpdateUserDesc : (this.state.user && this.state.user.userName ? this.state.user.userName : ''),
									})(
										<Input placeholder="请输入操作员" className='input' disabled />
									)}
								</Form.Item>
							</Col>
						</Row>
						{/* 第六行 */}
						<Row gutter={16} style={{ position: 'relative' }}>
							<Col span={4}>
								<Form.Item label="按开单科室发药">
									{getFieldDecorator('locOrdDsp', {
										valuePropName: 'checked',
										initialValue: userInfo.locOrdDsp === "Y" ? true : false,
									})(
										<Switch checkedChildren="是" unCheckedChildren="否" ref={this.myRef20} onChange={() => this.handleOnSelect(20)} />
									)}
								</Form.Item>
							</Col>
							<Col span={4}>
								<Form.Item label="接收外院项目">
									{getFieldDecorator('locRecOthHospItem', {
										valuePropName: 'checked',
										initialValue: userInfo.locRecOthHospItem === "Y" ? true : false,
									})(
										<Switch checkedChildren="是" unCheckedChildren="否" ref={this.myRef21} onChange={() => this.handleOnSelect(21)} />
									)}
								</Form.Item>
							</Col>
							<Col span={4}>
								<Form.Item label="可向外院开单">
									{getFieldDecorator('locToOthHospItem', {
										valuePropName: 'checked',
										initialValue: userInfo.locToOthHospItem === "Y" ? true : false,
									})(
										<Switch checkedChildren="是" unCheckedChildren="否" ref={this.myRef22} onChange={() => this.handleOnSelect(22)} />
									)}
								</Form.Item>
							</Col>
							<Col span={4}>
								<Form.Item label="本科接收">
									{getFieldDecorator('locGetRecLoc', {
										valuePropName: 'checked',
										initialValue: userInfo.locGetRecLoc === "Y" ? true : false,
									})(
										<Switch checkedChildren="是" unCheckedChildren="否" ref={this.myRef23} onChange={() => this.handleOnSelect(23)} />
									)}
								</Form.Item>
							</Col>
							<Col span={4}>
								<Form.Item label="产科">
									{getFieldDecorator('locIsObstetricsDep', {
										valuePropName: 'checked',
										initialValue: userInfo.locIsObstetricsDep === "Y" ? true : false,
									})(
										<Switch checkedChildren="是" unCheckedChildren="否" ref={this.myRef24} onChange={() => this.handleOnSelect(24)} />
									)}
								</Form.Item>
							</Col>
							<Col span={4}>
								<Form.Item label="优质护理">
									{getFieldDecorator('locQualityCareDep', {
										valuePropName: 'checked',
										initialValue: userInfo.locQualityCareDep === "Y" ? true : false,
									})(
										<Switch checkedChildren="是" unCheckedChildren="否" ref={this.myRef27} onChange={() => this.handleOnSelect(26)} />
									)}
								</Form.Item>
							</Col>
							<Col span={4} style={{ position: 'absolute', top: '-108%', right: '-6%' }}>
								<Form.Item label="上传图片">
									{getFieldDecorator('Upload', {
										valuePropName: 'fileList',
										getValueFromEvent: this.normFile,
										initialValue: userInfo.Image ? userInfo.Image : undefined,
									})(
										<Upload
											accept=".jpg, .jpeg, .png"
											name="avatar"
											listType="picture-card"
											className="avatar-uploader"
											showUploadList={false}
											action="http://139.159.205.187:57772"
											beforeUpload={this.beforeUpload}
										>
											{imageUrl ? <img src={imageUrl} alt="avatar" /> : uploadButton}
										</Upload>
									)}
								</Form.Item>
							</Col>
						</Row>
						{/* 第七行 */}
						<Row gutter={16}>
							<Col span={24}>
								<Form.Item label="科室简介">
									{getFieldDecorator('locIntroduce', {
										initialValue: userInfo.locIntroduce ? userInfo.locIntroduce : undefined,
									})(
										<TextArea rows={3} ref={this.myRef25} onPressEnter={() => this.handleOnSelect(25)} />
									)}
								</Form.Item>
							</Col>
						</Row>
						{/* 第九行 */}
						<Row gutter={16} style={{ width: '100%', textAlign: 'center' }}>
							<Button onClick={this.handelSave} ref={this.myRef26} style={{ marginRight: '15px', background: 'rgba(66,185,131,1)', color: '#fff' }}>保存</Button>
							{/* {this.props.handleThis ? <Button onClick={this.goBack}>返回</Button> : ''} */}
						</Row>
					</Form>
					<PublicModalTable
						onClickRowPublic={this.state.docterAndNurse === 'docter' ? this.onClickRowDoctor : this.onClickRowNurse}
						compilePage={this.state.docterAndNurse === 'docter' ? this.compileDoctorPage : this.compileNursePage}
						param={param} onRef={this.onRef}
					/>
				</div>
			)
		}
	}
);
export default DepartmentBasicInformation;