// 发药
import React from 'react';
import { Card, Row, Col, Select, Button, Input, DatePicker, Switch, Modal, Table, Checkbox, Icon, Form, message } from 'antd';
import PubilcTablePagination from './../../common/PubilcTablePagination';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import RejectPrescription from './RejectPrescription.jsx'; // 审核拒绝
import FaceRecognitionAuto from 'pages/common/FaceRecognitionAuto';
import store from 'store';
import { $http } from 'containers/config/https';
import { $loopPrint } from 'pages/lodop/Common/Print.js';
import Moment from 'moment';
import './style/outpha.less';
import { $PrintPresc, $PrintLabel, $PrintPYD } from './common/Print';
import ReadCard from 'components/readcard/ReadCard';

import iconMedicine from 'assets/images/icon_medicine.png';
import iconListvisits from 'assets/images/icon_listvisits.png';

const { Option } = Select;
let buttonStatus = true;

let timer = null;
let voiceTimer = null;

class Dispensing extends React.Component {

	constructor(props) {
		super(props);
		var userData = JSON.parse(sessionStorage.getItem('userData'));
		this.state = {
			userData,
			statusSelectData: [], // 审核状态下拉框数据
			startDate: Moment(), // 开始日期
			endDate: Moment(), // 截止日期
			fyFlag: undefined, // 发药标志
			patID: '', // 病人Id
			pat: '', // 回车保存的病人id
			patNo: undefined, // 病人
			tableData: [],
			total: 0,
			page: 1,
			pageSize: 20,
			rowId: '', // 选中行标识 --- 发药列表
			rowData: {}, // 选中行对象 --- 发药列表
			basicHeight: 0,
			detailData: [],
			pharmacistVisible: false, // 选中配药师弹窗
			dispensingChecked: false, // 直接发药
			windowVisible: false, // 选中窗口
			windowDomData: [],
			LTrowId: '', // 左侧列表选中标识 --- 待发药
			LTrowData: {}, // 选中行对象 --- 待发药
			usageData: [], // Rp数据
			usageTableData: [], // 选药列表数据
			selectedRowKeys: [],
			selectedRows: [],
			unfoldTableData: {}, // 点击显示table的行数据
			radioWindowData: {}, // 选中一条发药窗口数据
			parameterSetting: {}, // 3.2.1.6.10.取发药参数设置
			mainInfo: [], // 发药主信息
			detailInfo: [], // 发药明细信息
			PharmacistSelectData: [], // 配药师下拉框数据
			pharmacistValue: undefined, // 配药师
			defaultValue: '', // 默认卡类型
			cardSlectData: [], // 卡类型下拉框数据
			cardType: undefined, // 卡类型
			cardNo: undefined, // 卡号
			LTpatID: '', // 选中行病人id
			// checkedObj: {}, // 选中窗口
			loading: false,
			columns: [],
			widthTotal: 0,
			detailColumns: [], // 待发药
			detailWidthTotal: 0,
			authorityStatus: false,
			FRAVisible: false,
			audioUrl: "",
			voiceTimer: false,
			printBtnLoading: false
		};
		this.columns = [
			{ title: '病人ID', dataIndex: 'patNo', key: '1', width: '100px', align: "center" },
			{ title: '患者', dataIndex: 'patName', key: '2', width: '100px', align: "center" },
			{ title: '处方号', dataIndex: 'ordPrescNo', key: '3', width: '150px', align: "center" },
			{ title: '收费日期', dataIndex: 'dateTime', key: '4', width: '150px', align: "center" },
		];
		this.detailColumns = [
			{ title: '序号', dataIndex: 'key', key: '1', width: '80px', align: "center" },
			{ title: '性名', dataIndex: 'patName', key: '2', align: "center" },
		];
		this.usageColumns = [
			{ title: '执行时间', dataIndex: 'time', key: '1', width: '50%', align: "center" },
			{ title: '数量', dataIndex: 'num', key: '2', align: "center" },
		];
		this.myRef1 = React.createRef();
	}

	componentDidMount() {
		this.getPharmacyWindowData("start");
		this.getSelectData();
		this.getCardSelectData();
		this.getParameterSetting();
		this.getOutpatientWaitingList(); // 获取待发药表头数据
		this.getMainTableColumns(); // 获取发药列表表头数据
		// loading
		this.child.handleLoading();
		this.getPharmacistSelectData();
		this.setState({ basicHeight: document.getElementById("outpha-dispensing-basic").clientHeight });
	}

	componentWillUnmount() {
		// 组件销毁前将静止让setState修改state的状态
		clearInterval(timer);
		clearInterval(voiceTimer);
		this.setState = (state, callback) => { return; }
	}

	//判断医生有没有审核权限
	authorityManagement = () => {
		let data = {
			params: [{
				userID: this.state.userData.userID,
				locID: this.state.userData.locID,
				authDesc: 'DispAuth'
			}]
		}
		$http.post('urlS', this, {
			code: "02030082",
			data: data,
			success: function (res) {
				if (+res.errorCode == '02010015') {
					// message.error(res.errorMessage);
					this.setState({ authorityStatus: true })
				} else {
					this.setState({ authorityStatus: false })
				}
			}
		})
	};

	// 获取数据列表columns
	getMainTableColumns = () => {
		let { userData } = this.state;
		let data = {
			params: [{
				compontName: "DrugDistribution",
				reactCode: ['DrugDistribution'],
				type: 'C',
			}]
		}
		$http.post('urlS', this, {
			code: '01040073',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let arr = res.result.C && res.result.C.length > 0 ? JSON.parse(JSON.stringify(res.result.C)).map((item, index) => {
						return {
							...item,
							key: index + 1,
							title: <div onDoubleClick={() => this.mainColumnRef.onOpenModel()}>{userData.language == 'EN' ? (item && item.enDescripts ? item.enDescripts : item.title) : item.title}</div>
						}
					}) : '';
					let filterArr = arr.filter(function (item) { return item.display === 'Y' });
					this.setState({
						columns: filterArr, widthTotal: res.totalWidth,
						localeProvider: userData.language == 'EN' ? res.result.language.EN : res.result.language.CN
					})
				}
			}
		})
	}

	onMainColumnRef = (ref) => {
		this.mainColumnRef = ref;
	}

	//国际化
	setMessage = (name, message, defaultTitle) => {
		return this.state.localeProvider && this.state.localeProvider[name] ? this.state.localeProvider[name][message] : defaultTitle
	}

	// 获取门诊发药待发药列头
	getOutpatientWaitingList = () => {
		let { userData } = this.state;
		let data = {
			params: [{
				compontName: "OutpatientWaitingList",
				type: 'C',
			}]
		}
		$http.post('urlS', this, {
			code: '01040073',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let arr = res.result.C && res.result.C.length > 0 ? JSON.parse(JSON.stringify(res.result.C)).map((item, index) => {
						return {
							...item,
							key: index + 1,
							title: <div onDoubleClick={() => this.detailColumnRef.onOpenModel()}>{userData.language == 'EN' ? (item && item.enDescripts ? item.enDescripts : item.title) : item.title}</div>
						}
					}) : '';
					let filterArr = arr.filter(function (item) { return item.display === 'Y' });
					this.setState({ detailColumns: filterArr, detailWidthTotal: res.totalWidth })
				}
			}
		})
	}

	onDetailColumnRef = (ref) => {
		this.detailColumnRef = ref;
	}

	// 3.2.1.6.10.取发药 参数设置
	getParameterSetting = () => {
		let { userData } = this.state;
		let data = {
			params: []
		}
		$http.post('urlS', this, {
			code: "02030044",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let directDispFlag = res.result && res.result.length ? res.result[0].directDispFlag : 0;
					this.setState({
						parameterSetting: res.result[0],
						startDate: res.result[0].startDate ? Moment(res.result[0].startDate) : Moment(),
						endDate: res.result[0].endDate ? Moment(res.result[0].endDate) : Moment(),
						dispensingChecked: +directDispFlag === 1 ? true : false,
						mode: +directDispFlag === 1 ? 2 : 1,
						pharmacistValue: +directDispFlag === 1 ? (userData && userData.userID ? userData.userID : undefined) : undefined,
					})
				}
			}
		})
	}

	// 获取取药窗口信息
	getPharmacyWindowData = (flag) => {
		let data = {
			params: []
		}
		$http.post('urlS', this, {
			code: "02030035",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let arr = res.result[0] && res.result[0].rows && JSON.parse(JSON.stringify(res.result[0].rows)).map((item, index) => {
						return {
							key: index + 1,
							checked: false,
							disabled: false,
							dispWinDesc: item.dispWinDesc, // 发药窗口描述
							dispWinID: item.dispWinID, // 发药窗口ID
							statusID: item.statusID, // 状态ID
							statusDesc: item.statusDesc, // 状态描述
							prescNum: item.prescNum, // 窗口数量
						}
					})
					if (this.state.radioWindowData && this.state.radioWindowData.dispWinID) {
						for (let i = 0; i < arr.length; i++) {
							if (arr[i].dispWinID === this.state.radioWindowData.dispWinID) {
								arr[i].checked = this.state.radioWindowData.checked;
							}
						}
					}
					this.setState({ windowDomData: arr }, () => {
						if (flag === "start") {
							this.showModal("window")
						}
					})
				}
			}
		})
	}

	filterDspInfo = (data) => {
		let rowsData = data[0].rows;
		let obj = {};
		let batInfo = [];
		let filterBatInfo = [];
		for (var i = 0; i < rowsData.length; i++) {
			batInfo = batInfo.concat(rowsData[i].batInfo)
		}
		for (var i = 0; i < batInfo.length; i++) {
			if (!obj[batInfo[i].batNo]) {
				obj[batInfo[i].batNo] = batInfo[i].batNo;
				filterBatInfo.push(batInfo[i]);
			} else {
				for (var j = 0; j < filterBatInfo.length; j++) {
					if (filterBatInfo[j].batNo === batInfo[i].batNo) {
						filterBatInfo[j].qty += batInfo[i].qty;
					}
				}
			}
		}
		let dspInfo = [];
		rowsData[0].batInfo = filterBatInfo
		let batInfoObj = {
			rows: rowsData
		}
		dspInfo.push(batInfoObj);
		return dspInfo
	}

	// 3.2.1.6.6.获取发药明细信息
	getDetailInformation = (record) => {
		let data = {
			params: [
				{
					dispID: record.dispID ? record.dispID : '', // 发药表ID
					ordPrescNo: record.ordPrescNo ? record.ordPrescNo : '', // 处方号
				}
			]
		}
		$http.post('urlS', this, {
			code: "02030040",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let detailInfo = res.result[0] ? JSON.parse(JSON.stringify(res.result[0].detailInfo)) : [];
					let usageData = detailInfo && detailInfo.length > 0 ? JSON.parse(JSON.stringify(detailInfo[0].rows)) : [];
					// let selectedRows = usageData[0].dspInfo[0].rows&&usageData[0].dspInfo[0].rows.length > 0 ? JSON.parse(JSON.stringify(usageData[0].dspInfo[0].rows)) : [];
					// let selectedRowKeys = [];
					// for(var i = 0; i < selectedRows.length; i++) {
					//     selectedRowKeys.push(selectedRows[i].dspID)
					// }
					for (var i = 0; i < usageData.length; i++) {
						usageData[i].visible = false;
						usageData[i].filterDd = usageData[i].ordQty;
						usageData[i].dspInfo = this.filterDspInfo(usageData[i].dspInfo)
					}
					// console.log(usageData)
					this.setState({
						mainInfo: res.result[0] ? res.result[0].mainInfo : [],
						usageData: usageData,
						// selectedRowKeys, // 默认选中的Key值
						// selectedRows, // 默认选中的行数据
					})
				} else {
					this.setState({ mainInfo: [], usageData: [], selectedRowKeys: [], selectedRows: [] })
				}
			}
		})
	}

	// 3.2.1.6.4.获取发药 等候队列
	getMedicationWaitingQueue = () => {
		let { mode, startDate, endDate, radioWindowData } = this.state;
		let data = {
			params: [
				{
					mode: mode ? mode : 1, // 发药模式
					dispWinID: radioWindowData && radioWindowData.dispWinID ? radioWindowData.dispWinID : undefined, // 发药窗口ID
					startDate: startDate ? Moment(startDate).format('YYYY-MM-DD') : Moment().format('YYYY-MM-DD'), // 开始日期
					endDate: endDate ? Moment(endDate).format('YYYY-MM-DD') : Moment().format('YYYY-MM-DD'), // 截止日期
				}
			]
		}
		$http.post('urlS', this, {
			code: "02030038",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					for (var i = 0; i < res.result[0].rows.length; i++) {
						res.result[0].rows[i].key = res.result[0].rows[i].patID
					}
					let arr = res.result[0].rows;
					if (JSON.stringify(arr) !== JSON.stringify(this.state.detailData)) {
						this.setState({ detailData: arr }, () => {
							// this.handleFYClick("dfy-list");
						})
					}
				}
			}
		})
	}

	getTableData(mode, startDate, endDate, fyFlag, patID, isVoice) {
		let { pageSize, page, radioWindowData, LTpatID, patNo } = this.state;
		let data = {
			params: [{
				mode: mode ? mode : 1, // 发药模式
				dispWinID: radioWindowData && radioWindowData.dispWinID ? radioWindowData.dispWinID : undefined, // 发药窗口ID
				startDate: startDate ? Moment(startDate).format('YYYY-MM-DD') : Moment().format('YYYY-MM-DD'), // 开始日期
				endDate: endDate ? Moment(endDate).format('YYYY-MM-DD') : Moment().format('YYYY-MM-DD'), // 截止日期
				fyFlag: fyFlag, // 发药标志
				patID: LTpatID ? LTpatID : (this.isNumber(patNo) ? patID : ""), // 病人ID
				patName: LTpatID ? "" : (this.isNumber(patNo) ? "" : patNo),
			}],
			pagination: [{
				pageSize: pageSize,
				currentPage: page
			}]
		}
		setTimeout(() => {
			var gundong = document.querySelector("#fy-list .ant-table-body");
			gundong.scrollTop = 0;
		}, 100)
		$http.post('urlS', this, {
			code: "02030039",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					if (+res.result[0].total === 0) {
						message.warning('暂无发药记录...')
					}

					let arr = res.result[0].rows ? res.result[0].rows : []
					for (var i = 0; i < arr.length; i++) {
						arr[i].key = i + 1;
						arr[i].dateTime = arr[i].date + ' ' + arr[i].time
					}
					let rowData = arr && arr.length > 0 ? arr[0] : {};
					let audioUrl = isVoice === 'voice' && fyFlag === "0" && arr && arr.length > 0 ? "https://chis.e24health.com/images/Voice/dispWarnning.mp3" : ""; // 是否为语言播报查询
					this.setState({ tableData: arr, total: res.result[0].total, rowId: rowData && rowData.key ? rowData.key : "", rowData, patNo: undefined, audioUrl }, () => {
						if (this.state.rowId) {
							this.getDetailInformation(this.state.rowData);
							// this.handleFYClick("fy-list");
						}
						if (this.state.audioUrl) {
							var myAuto = document.getElementById('a_player_audio');
							myAuto.play();
						}
						setTimeout(() => {
							this.myRef1 && this.myRef1.current && this.myRef1.current.focus();
						}, 300)
					})
					// 数据加载成功关闭loading
					this.child.handleLoading();
				} else {
					this.setState({ tableData: [], total: 0, rowId: "", rowData: {}, patNo: undefined, audioUrl: '' })
					// 数据加载失败关闭loading
					this.child.handleLoading();
					setTimeout(() => {
						this.myRef1 && this.myRef1.current && this.myRef1.current.focus();
					}, 300)
				}
			},
			error: function (error) {
				this.setState({ tableData: [], total: 0, rowId: "", rowData: {}, patNo: undefined, audioUrl: '' }, () => {
					// 数据加载成功关闭loading
					this.child.handleLoading();
					setTimeout(() => {
						this.myRef1 && this.myRef1.current && this.myRef1.current.focus();
					}, 300)
				})
			}
		})
	}

	// 重置操作数据
	resetData = () => {
		this.setState({ rowId: '', rowData: {}, mainInfo: [], usageData: [] });
		this.getMedicationWaitingQueue(); // 重新查询待发药列表
	}

	// 获取表格数据
	handleQuery = () => {
		setTimeout(() => {
			this.setState({ page: 1, rowId: '', rowData: {}, mainInfo: [], usageData: [], LTrowId: '', LTpatID: '' }, () => {
				this.refreshTableData();
				this.getMedicationWaitingQueue();
			})
		}, 300)
	}

	// 按照输入条件重新查询数据
	refreshTableData = (isVoice) => {
		let { mode, startDate, endDate, fyFlag, patID } = this.state;
		this.getTableData(mode, startDate, endDate, fyFlag, patID, isVoice)
	}


	// 提供修改page和pageSize的回调函数
	compilePage = (page, pageSize) => {
		// 修改page，或者pageSize
		this.setState({ page: page, pageSize: pageSize }, () => {
			// 重新调用查询方法
			this.refreshTableData();
		})
	}

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

	onModalRef = (ref) => {
		this.modalChild = ref;
	}

	// 操作行 --- 左侧列表待发药
	onClickRowLeftTable = (record) => {
		return {
			// 单击行选中
			onClick: () => {
				if (this.state.LTrowId === '') {
					// 保存行数据以及ID
					this.setState({ LTrowId: record.key, LTpatID: record.patID, page: 1, rowId: '', rowData: {}, mainInfo: [], usageData: [] }, () => {
						this.refreshTableData();
					})
				} else {
					if (this.state.LTrowId !== record.key) {
						this.setState({ LTrowId: record.key, LTpatID: record.patID, page: 1, rowId: '', rowData: {}, mainInfo: [], usageData: [] }, () => {
							this.refreshTableData();
						})
					}
				}
			}
		}
	}

	// 选中行操作 --- 左侧列表
	setRowClassNameLeftTable = (record) => {
		return record.key === this.state.LTrowId ? 'clickRowStyle' : '';
	}

	// 操作行 --- 发药列表
	onClickRowPublic = (record) => {
		return {
			// 单击行选中
			onClick: () => {
				if (this.state.rowId === '') {
					// 保存行数据以及ID
					this.setState({ rowId: record.key, rowData: record }, () => {
						this.getDetailInformation(this.state.rowData)
					})
				} else {
					if (this.state.rowId !== record.key) {
						this.setState({ rowId: record.key, rowData: record }, () => {
							this.getDetailInformation(this.state.rowData)
						})
					}
				}
			}
		}
	}

	// 选中行操作 --- 发药列表
	setRowClassNamePublic = (record) => {
		return (record.dispStatus === "Y") && (record.key === this.state.rowId) ? "select-and-row" : (record.dispStatus === "Y" ? "select-color" : (record.key === this.state.rowId ? 'clickRowStyle' : ""));
	}

	// 直接发药模式
	onClickSwitch = () => {
		if (!this.state.dispensingChecked) {
			this.showModal('pharmacist')
		} else {
			this.setState({ dispensingChecked: false, pharmacistValue: undefined, mode: 1 }, () => {
				this.refreshTableData(); // 发药列表
				this.resetData(); // 重置操作数据以及刷新待发药列表
			})
		}
	}

	// 切换窗口
	switchingWindow = () => {
		this.setState({
			windowVisible: true,
		}, () => {
			this.getPharmacyWindowData();
		});
	}

	// 打开弹窗
	showModal = (flag) => {
		if (flag === 'pharmacist') {
			this.setState({
				pharmacistVisible: true,
			});
		} else if (flag === 'window') {
			let { windowDomData } = this.state;
			if (windowDomData && windowDomData.length === 1) { // 如果窗口数等于1的话直接默认为当前窗口
				let arr = JSON.parse(JSON.stringify(windowDomData));
				arr[0].checked = true;
				this.setState({ windowDomData: arr }, () => {
					this.windowHandleOk();
				})
			} else {
				this.setState({
					windowVisible: true,
				});
			}
		}

	};

	// 选择配药师弹窗 --- 确定
	pharmacistHandleOk = () => {
		// 当选择配药师之后直接发药模式变成是并且关闭选择模态框
		if (this.state.pharmacistValue) {
			// 点击确定并且成功之后将开关切换为是并且关闭弹窗
			this.setState({ dispensingChecked: true, mode: 2 }, () => {
				this.handleCancel('pharmacist');
				this.handleQuery();
			})
		} else {
			message.info(this.setMessage("DrugDistributionpleaseSelectPharmacist", "descripts", "请选择配药师"), this.state.userData && this.state.userData.messageTime)
		}
	};

	// 切换窗口 --- 确定
	windowHandleOk = () => {
		let messageTrue = true;
		let obj = {};
		let windowDomData = JSON.parse(JSON.stringify(this.state.windowDomData));
		if (windowDomData && windowDomData.length > 0) {
			for (let i = 0; i < windowDomData.length; i++) {
				if (windowDomData[i].checked == true) {
					messageTrue = true
					obj = windowDomData[i];
					break;
				} else {
					messageTrue = false
				}
			}
		}
		// console.log(arr)
		if (messageTrue === false) {
			message.error(this.setMessage("DrugDistributionpleaseSelectDrugDispensingWin", "descripts", "请选择发药窗口"))
		} else {
			this.authorityManagement();
			this.setState({ radioWindowData: obj }, () => {
				let date = this.state.parameterSetting.refreshTime ? this.state.parameterSetting.refreshTime * 1000 : 10 * 1000; // 将秒转为毫秒
				// console.log(date)
				timer = setInterval(() => {
					this.getMedicationWaitingQueue();
				}, date);
				this.handleQuery();
				this.handleCancel('window');
			})
		}
	}

	// 关闭弹窗
	handleCancel = (flag) => {
		if (flag === 'pharmacist') {// 关闭直接发药模式刷新待发药、发药列表、处方笺三栏的数据
			this.setState({
				pharmacistVisible: false,
			});
		} else if (flag === 'window') {
			if (this.state.radioWindowData && this.state.radioWindowData.dispWinID) {
				let windowDomData = JSON.parse(JSON.stringify(this.state.windowDomData));
				let index;
				for (var i = 0; i < windowDomData.length; i++) {
					windowDomData[i].checked = false;
					if (windowDomData[i].dispWinID === this.state.radioWindowData.dispWinID) {
						index = i;
					}
				}
				windowDomData[index].checked = this.state.radioWindowData.checked;
				this.setState({
					windowVisible: false,
					windowDomData
				}, () => {
					setTimeout(() => {
						this.myRef1.current.focus();
					}, 300)
				});
			} else {
				message.error(this.setMessage("DrugDistributionpleaseSelectDrugDispensingWin", "descripts", "请选择发药窗口"), this.state.userData && this.state.userData.messageTime)
			}
		}
	};

	// Checkbox的onChange事件
	compileChecked = (item, index) => {
		let windowDomData = [...this.state.windowDomData];
		for (var i = 0; i < windowDomData.length; i++) {
			let indexChecked = windowDomData[index].checked;
			windowDomData[i].checked = false;
			windowDomData[index].checked = indexChecked;
			if (windowDomData[i] === item) {
				windowDomData[i].checked = !windowDomData[i].checked;
			}
		}
		this.setState({ windowDomData: windowDomData })
	}

	// 点击切换Icon并且显示弹窗
	handleISModal = (item) => {
		this.getExecutionRecord(item); // 切换Icon请求执行记录
		let arr = [...this.state.usageData];

		// console.log(item, arr)
		for (var i = 0; i < arr.length; i++) {
			if (arr[i].ordID === item.ordID) {
				arr[i].visible = !arr[i].visible
			} else {
				arr[i].visible = false;
			}
		}
		this.setState({ usageData: arr, unfoldTableData: item })
	}

	// 药品选择 --- 确定
	handleConfirm = (item) => {
		let { selectedRows } = this.state;
		let batInfo = []; // 批次
		let arr = [];
		let obj = {};
		let filterBatInfo = [];
		for (var i = 0; i < selectedRows.length; i++) {
			arr.push(selectedRows[i].qty);
			batInfo = batInfo.concat(selectedRows[i].batInfo)
		}
		for (var i = 0; i < batInfo.length; i++) {
			if (!obj[batInfo[i].batNo]) {
				obj[batInfo[i].batNo] = batInfo[i].batNo;
				filterBatInfo.push(batInfo[i]);
			} else {
				for (var j = 0; j < filterBatInfo.length; j++) {
					if (filterBatInfo[j].batNo === batInfo[i].batNo) {
						filterBatInfo[j].qty += batInfo[i].qty;
					}
				}
			}
		}
		let dspInfo = [];
		selectedRows && selectedRows.length > 0 ? selectedRows[0].batInfo = filterBatInfo : "";
		let batInfoObj = {
			rows: [
				...selectedRows
			]
		}
		dspInfo.push(batInfoObj);
		let num = eval(arr.join('+'));
		let usageData = [...this.state.usageData];
		for (var i = 0; i < usageData.length; i++) {
			if (usageData[i] === item) {
				usageData[i].filterDd = num ? num : 0;
				usageData[i].visible = !usageData[i].visible;
				usageData[i].dspInfo = dspInfo
			}
		}
		this.setState({ usageData: usageData }, () => {
			// this.getInventoryInformation(item)
		})
	}

	// 修改发药窗口状态
	compileWindowStatus = (item, status) => {
		let data = {
			params: [
				{
					dispWinID: item.dispWinID,
					statusID: status,
				}
			]
		}
		$http.post('urlS', this, {
			code: "02030036",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					message.success(res.errorMessage, this.state.userData && this.state.userData.messageTime)
				} else {
					message.error(res.errorMessage, this.state.userData && this.state.userData.messageTime)
				}
			}
		})
	}

	// 修改弹窗中的有人无人
	handleSwitch = (item, e) => {
		let windowDomData = [...this.state.windowDomData];
		let status = e ? 'O' : 'C';
		for (var i = 0; i < windowDomData.length; i++) {
			if (windowDomData[i] === item) {
				windowDomData[i].statusID = status;
			}
		}
		this.setState({ windowDomData: windowDomData }, () => {
			this.compileWindowStatus(item, status)
		});
	}

	// 查询条件 --- 开始日期
	handleStartDate = (e) => {
		this.setState({ startDate: e });
	}

	// 查询条件 --- 截止日期
	handleEndDate = (e) => {
		this.setState({ endDate: e });
	}

	// 查询条件 --- 审核状态
	handlestatusID = (e) => {
		this.setState({ fyFlag: e });
	}

	// 选择配药师
	handlePharmacistValue = (e, flag) => {
		if (flag) {
			if (this.state.dispensingChecked) {
				this.setState({ pharmacistValue: e });
			} else {
				message.info("直接发药模式下才支持选择配药师。", this.state.userData && this.state.userData.messageTime)
			}
		} else {
			this.setState({ pharmacistValue: e });
		}
	}

	// 3.2.1.6.3.取发药状态下拉框数据集
	getSelectData = () => {
		let data = {
			params: []
		}
		$http.post('urlS', this, {
			code: "02030037",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					this.setState({ statusSelectData: res.result, fyFlag: res.result[0].id })
				} else {
					this.setState({ statusSelectData: [] })
				}
			}
		})
	}

	// 病人id
	handlePatientOnChange = (e) => {
		if (!e.target.value) {
			setTimeout(() => {
				this.setState({ patID: '' })
			}, 500);
		}
		this.setState({ patNo: e.target.value })
	}

	// 病人id失去焦点事件
	handlePatientOnBlur = (e) => {
		if (e.target.value !== this.state.pat) {
			this.setState({ patNo: undefined, patID: '', pat: '' })
		}
	}

	isNumber = (val) => {
		var regPos = /^\d+(\.\d+)?$/; //非负浮点数
		var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
		if (regPos.test(val) || regNeg.test(val)) {
			return true;
		} else {
			return false;
		}
	}

	// 查询病人id
	handlePatient = (e, name) => {
		if (!e.target.value) {
			this.setState({ patID: '' })
			return;
		}
		if (this.isNumber(e.target.value)) {
			this.setState({ cardNo: undefined, cardType: this.state.defaultValue }, () => {
				this.getPatientInformation('patient', name);
			})
		} else {
			this.setState({ LTrowId: '', LTpatID: '', page: 1, mainInfo: [], usageData: [], rowData: {}, rowId: '', patID: "" }, () => {
				this.refreshTableData();
			})
		}
	}

	// 3.2.1.6.7.根据医嘱ID获取执行记录
	getExecutionRecord = (item) => {
		let dspInfo = item.dspInfo && item.dspInfo[0].rows ? item.dspInfo[0].rows : [];
		let data = {
			params: [
				{
					dispID: item.dispID, // 发药表ID
					ordID: item.ordID, // 医嘱ID
				}
			]
		}
		$http.post('urlS', this, {
			code: "02030041",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					let arr = res.result[0] && res.result[0].rows.length > 0 ? res.result[0].rows.map((itemChild, index) => {
						return {
							...itemChild,
							num: itemChild.qty + itemChild.unitDesc,
							time: itemChild.reqExeDate + ' ' + itemChild.reqExeTime,
							key: itemChild.dspID
						}
					}) : [];
					let selectedRowKeys = [];
					for (var i = 0; i < dspInfo.length; i++) {
						selectedRowKeys.push(dspInfo[i].dspID)
					}
					this.setState({ usageTableData: arr, selectedRows: dspInfo, selectedRowKeys })
				}
			}
		})
	}

	// 3.2.1.6.8.根据选中打包表记录获取 库存信息
	getInventoryInformation = (item) => {
		let arr = JSON.parse(JSON.stringify(this.state.selectedRows)).map(item => {
			return {
				dspID: item.dspID
			}
		})
		let data = {
			params: [
				{
					dspInfo: arr
				}
			]
		}
		$http.post('urlS', this, {
			code: "02030042",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					let usageData = [...this.state.usageData];
					for (i = 0; i < usageData.length; i++) {
						if (usageData[i].dspInfo === item) {
							usageData[i].dspInfo = res.result[0] ? res.result[0].rows : []
						}
					}
					this.setState({ usageData })
				}
			}
		})
	}

	// 修改该条已发药数据的状态
	modifyDispStatus = (rowData) => {
		let tableData = JSON.parse(JSON.stringify(this.state.tableData));
		for (var i = 0; i < tableData.length; i++) {
			if (tableData[i].key === rowData.key) {
				tableData[i].dispStatus = "Y";
				break;
			}
		}
		this.setState({ tableData, rowData: {}, rowId: "" })
	}

	// 获取配药师下拉框数据
	getPharmacistSelectData = () => {
		let data = {
			params: []
		}
		$http.post('urlS', this, {
			code: "02030119",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					this.setState({ PharmacistSelectData: res.result })
				} else {
					this.setState({ PharmacistSelectData: [] })
				}
			}
		})
	}

	// 卡号
	handleCardNoChange = (e) => {
		if (!e.target.value) {
			setTimeout(() => {
				this.setState({ patID: '' })
			}, 500);
		}
		this.setState({ cardNo: e.target.value })
	}

	// 卡类型
	handleCardTypeOnChange = (e) => {
		var { cardSlectData } = this.state;
		for (var i = 0; i < cardSlectData.length; i++) {
			if (e == cardSlectData[i].id) {
				this.setState({
					cardType: e,
					equipManagerObj: cardSlectData[i].equipManagerObj
				})
			}
		}
	}

	// 读卡 --- 根据卡号取病人信息
	handleReadCard = () => {
		if (!buttonStatus) {
			return;
		}
		let { cardType } = this.state;
		this.readCard.ReadCard(cardType, "R", (json) => {
			this.setState({ patID: json && json.patInfo ? json.patInfo.patID : 'aaaaa', cardNo: +cardType === 8 ? '' : json.cardNo, patNo: +cardType === 8 || +cardType === 11 ? json.patInfo.patNo : '' }, () => {
				if (+cardType === 8 || +cardType === 11) {
					this.getPatientInformation('patient', 'enter');
				} else {
					this.refreshTableData(); // 调取查询接口
				}
			})
		}, this.state.equipManagerObj?.readCardCode)
	};

	handleReadCardOnBlur = (e, name) => {
		if (!e.target.value) {
			this.setState({ patID: '' })
			return;
		}
		if (name === 'blur') {
			buttonStatus = false;
			this.setState({ patNo: undefined }, () => {
				this.getPatientInformation('readCard', name);
			})
		} else {
			this.setState({ patNo: undefined, LTrowId: '', LTpatID: '', page: 1, mainInfo: [], usageData: [], rowData: {}, rowId: '' }, () => {
				this.getPatientInformation('readCard', name);
			})
		}
	}

	// 获取卡类型下拉框数据
	getCardSelectData = () => {
		let data = {
			params: [{}]
		}
		$http.post('urlS', this, {
			code: '02030052',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let defaultValue = '';
					for (var i = 0; i < res.result.length; i++) {
						if (res.result[i].defaultFlag === 'Y') {
							defaultValue = res.result[i].id;
						}
					}
					this.setState({ cardSlectData: res.result, cardType: defaultValue, defaultValue: defaultValue })
				}
			}
		})
	}

	// 3.2.1.3.13.根据卡号取病人信息
	getPatientInformation = (flag, name) => {
		this.setState({ loading: true });
		let data = {
			params: [{
				number: this.state.patNo, // 病人登记号/证件号
				cardTypeID: flag === 'readCard' ? this.state.cardType : undefined, // 卡类型id
				cardNo: this.state.cardNo, // 卡号
			}]
		}
		setTimeout(() => {
			buttonStatus = true;
		}, 500)
		$http.post('urlS', this, {
			code: '03040004',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let cardNo = flag === "readCard" && res.data && res.data.patCardNo ? res.data.patCardNo : undefined; // 给卡号赋值
					// patNo: res.data && res.data.patNo ? res.data.patNo : '', 病人ID赋值-自动补零
					this.setState({ patID: res.data && res.data.patID ? res.data.patID : '', loading: false, cardNo }, () => {
						if (name === 'enter') {
							this.refreshTableData()
						}
					})
				} else if (res.errorFlag === 'N') {
					this.setState({ tableData: [], total: 0, patID: 'aaaaa', loading: false, LTrowId: '', LTpatID: '', page: 1, mainInfo: [], usageData: [], rowData: {}, rowId: '', patNo: undefined })
					message.error(res.errorMessage, this.state.userData && this.state.userData.messageTime)
				} else {
					this.setState({ loading: false, LTrowId: '', LTpatID: '', page: 1, mainInfo: [], usageData: [], rowData: {}, rowId: '', patNo: undefined });
				}
			},
			error: function () {
				this.setState({ loading: false, LTrowId: '', LTpatID: '', page: 1, mainInfo: [], usageData: [], rowData: {}, rowId: '', patNo: undefined });
			}
		})
	}

	//打印处方
	handlePrintPresc = () => {
		let { rowData } = this.state;
		let params;
		params = {
			dispID: rowData.dispID,
			prescno: rowData.ordPrescNo,
			phFlag: 1,
		}
		$PrintPresc(params);
	}

	//打印标签
	handlePrintLabel = () => {
		let { rowData } = this.state;
		let params;
		params = {
			dispID: rowData.dispID,
			prescno: rowData.ordPrescNo,
			phFlag: 1,
		}
		$PrintLabel(params);
	}

	//打印配药单
	handlePrintPYD = () => {
		let { rowData } = this.state;
		let params;
		params = {
			dispID: rowData.dispID,
			prescno: rowData.ordPrescNo,
			phFlag: 1,
		}
		$PrintPYD(params);
	}

	inciseData = () => {
		var { usageData } = this.state
		var result = [];
		for (var i = 0, len = usageData.length; i < len; i += 4) {
			result.push(usageData.slice(i, i + 4));
		}
		return result
	}

	// 西药时需要处理关联医嘱
	processAssociatedData = (data) => {
		let tempArr = [];
		let afterData = [];
		if (!(data && data.length > 0)) {
			return afterData;
		}
		for (let i = 0; i < data.length; i++) {
			if (tempArr.indexOf(data[i].ordMainID) === -1) {
				afterData.push({
					ordMainID: data[i].ordMainID,
					children: [data[i]]
				});
				tempArr.push(data[i].ordMainID);
			} else {
				for (let j = 0; j < afterData.length; j++) {
					if (afterData[j].ordMainID == data[i].ordMainID) {
						afterData[j].children.push(data[i]);
						break;
					}
				}
			}
		}
		return afterData;
	}

	// 发药公共方法
	dispensingCommon = (rowData, usageData, selectedRows, type, index) => {
		let { pharmacistValue, fyFlag, tableData } = this.state;
		let arr = JSON.parse(JSON.stringify(selectedRows)).map(item => {
			return {
				dspID: item.dspID
			}
		})
		let ordInfo = usageData && usageData.length > 0 && usageData.map(item => {
			return {
				ordID: item.ordID,
				dspInfo: arr
			}
		});
		let data = {
			params: [
				{
					dispID: rowData.dispID, // 发药表ID
					ordPrescNo: rowData.ordPrescNo, // 处方号
					PDFlag: fyFlag, // 部分发药标志
					prepUserID: pharmacistValue, // 配药师
					ordInfo: ordInfo, // 医嘱记录
				}
			]
		}
		$http.post('urlS', this, {
			code: "02030043",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					if (type === "all") {
						if (tableData.length - 1 === index) {
							message.success('一键发药成功', this.state.userData && this.state.userData.messageTime);
						}
					} else {
						message.success('发药成功', this.state.userData && this.state.userData.messageTime);
						this.handleFYClick("fy-list");
					}
					// this.modifyDispStatus(rowData); // 修改当条发药状态
					this.setState({ mainInfo: {}, usageData: [] }, () => {
						this.getMedicationWaitingQueue(); // 刷新代发药列表
						this.refreshTableData(); // 获取发药列表重新
						setTimeout(() => {
							this.myRef1.current.focus();
						}, 300)
					})
				}
			},
			error: function (error) {
				message.error(error, this.state.userData && this.state.userData.messageTime);
			}
		})
	}

	// 发药
	handleDispensing = () => {
		let { rowData, usageData, selectedRows } = this.state;
		this.dispensingCommon(rowData, usageData, selectedRows, "noneAll")
	}

	getDetailInformationAll = (record, i) => {
		let { selectedRows } = this.state;
		let data = {
			params: [
				{
					dispID: record.dispID ? record.dispID : '', // 发药表ID
					ordPrescNo: record.ordPrescNo ? record.ordPrescNo : '', // 处方号
				}
			]
		}
		$http.post('urlS', this, {
			code: "02030040",
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					let detailInfo = res.result[0] ? JSON.parse(JSON.stringify(res.result[0].detailInfo)) : [];
					let usageData = detailInfo && detailInfo.length > 0 ? JSON.parse(JSON.stringify(detailInfo[0].rows)) : [];
					for (var i = 0; i < usageData.length; i++) {
						usageData[i].visible = false;
						usageData[i].filterDd = usageData[i].ordQty;
						usageData[i].dspInfo = this.filterDspInfo(usageData[i].dspInfo)
					}
					this.dispensingCommon(record, usageData, selectedRows, "all", i)
				}
			}
		})
	}

	// 全发
	handleFullDose = () => {
		let { tableData } = this.state;
		for (var i = 0; i < tableData.length; i++) {
			if (tableData[i].ordPrescNo) {
				this.getDetailInformationAll(tableData[i], i)
			}
		}
	}

	handleDFYOnKeydown = (e) => {
		var e = window.event || e;
		let id = '';
		let obj = {};
		let scroll_height = 32;
		let oneArr = this.state.detailData && this.state.detailData.length > 0 ? this.state.detailData : [];
		switch (e.keyCode) {
			case 38: //上
				if (this.state.LTrowId) {
					for (var i = 0; i < oneArr.length; i++) {
						if (oneArr[i].key === this.state.LTrowId) {
							id = i > 0 ? oneArr[i - 1].key : oneArr[0].key;
							obj = i > 0 ? oneArr[i - 1] : oneArr[0];
							break;
						}
					}
					this.setState({ LTrowId: id, LTpatID: obj.patID, page: 1, rowId: '', rowData: {}, mainInfo: [], usageData: [] }, () => {
						this.refreshTableData();
					})
					setTimeout(() => {
						var gundong = document.querySelector("#dfy-list .ant-table-body");
						gundong.scrollTop = gundong.scrollTop - scroll_height;
					}, 100)
				} else {
					this.setState({ LTrowId: oneArr[0].key, LTpatID: oneArr[0].patID, page: 1, rowId: '', rowData: {}, mainInfo: [], usageData: [] }, () => {
						this.refreshTableData();
					})
				}
				break;
			case 39: //  右
				if (this.state.tableData && this.state.tableData.length > 0) {
					this.handleFYClick("fy-list")
					this.setState({ rowId: this.state.tableData[0].key, rowData: this.state.tableData[0] }, () => {
						this.getDetailInformation(this.state.rowData)
					})
				}
				break;
			case 40: //下
				if (this.state.LTrowId) {
					for (let i = 0; i < oneArr.length; i++) {
						if (oneArr[i].key === this.state.LTrowId) {
							id = i + 1 >= oneArr.length ? oneArr[oneArr.length - 1].key : oneArr[i + 1].key;
							obj = i + 1 >= oneArr.length ? oneArr[oneArr.length - 1] : oneArr[i + 1];
							break;
						}
					}
					this.setState({ LTrowId: id, LTpatID: obj.patID, page: 1, rowId: '', rowData: {}, mainInfo: [], usageData: [] }, () => {
						this.refreshTableData();
					})
					setTimeout(() => {
						var gundong = document.querySelector("#dfy-list .ant-table-body");
						gundong.scrollTop = gundong.scrollTop + scroll_height;
					}, 100)
				} else {
					this.setState({ LTrowId: oneArr[0].key, LTpatID: oneArr[0].patID, page: 1, rowId: '', rowData: {}, mainInfo: [], usageData: [] }, () => {
						this.refreshTableData();
					})
				}
				break;
		}
	}

	handleFYLBOnKeydown = (e) => {
		var e = window.event || e;
		let id = '';
		let obj = {};
		let scroll_height = 32;
		let oneArr = this.state.tableData && this.state.tableData.length > 0 ? this.state.tableData : [];
		switch (e.keyCode) {
			case 13: //  回车发药
				this.handleDispensing();
				break;
			case 37: //  左
				if (this.state.detailData && this.state.detailData.length > 0) {
					this.handleFYClick("dfy-list")
					this.setState({ LTrowId: this.state.LTrowId, LTpatID: this.state.LTpatID, page: 1, rowId: '', rowData: {}, mainInfo: [], usageData: [] })
				}
				break;
			case 38: //上
				if (this.state.rowId) {
					for (var i = 0; i < oneArr.length; i++) {
						if (oneArr[i].key === this.state.rowId) {
							id = i > 0 ? oneArr[i - 1].key : oneArr[0].key;
							obj = i > 0 ? oneArr[i - 1] : oneArr[0];
							break;
						}
					}
					this.setState({ rowId: id, rowData: obj }, () => {
						this.getDetailInformation(this.state.rowData)
					})
					setTimeout(() => {
						var gundong = document.querySelector("#fy-list .ant-table-body");
						gundong.scrollTop = gundong.scrollTop - scroll_height;
					}, 100)
				} else {
					this.setState({ rowId: oneArr[0].key, rowData: oneArr[0] }, () => {
						this.getDetailInformation(this.state.rowData)
					})
				}
				break;
			case 40: //下
				if (this.state.rowId) {
					for (let i = 0; i < oneArr.length; i++) {
						if (oneArr[i].key === this.state.rowId) {
							id = i + 1 >= oneArr.length ? oneArr[oneArr.length - 1].key : oneArr[i + 1].key;
							obj = i + 1 >= oneArr.length ? oneArr[oneArr.length - 1] : oneArr[i + 1];
							break;
						}
					}
					this.setState({ rowId: id, rowData: obj }, () => {
						this.getDetailInformation(this.state.rowData)
					})
					setTimeout(() => {
						var gundong = document.querySelector("#fy-list .ant-table-body");
						// console.log(gundong)
						gundong.scrollTop = gundong.scrollTop + scroll_height;
					}, 100)
				} else {
					this.setState({ rowId: oneArr[0].key, rowData: oneArr[0] }, () => {
						this.getDetailInformation(this.state.rowData)
					})
				}
				break;
		}
	}

	handleFYClick = (id) => {
		let dom = document.getElementById(id);
		dom.focus();
	}

	onFaceRecognitionAutoRefs = ref => {
		this.faceRecognitionAutoChild = ref;
	}

	handleFRAClose = () => {
		this.setState({ FRAVisible: false });
		if (this.faceRecognitionAutoChild) {
			this.faceRecognitionAutoChild.clearVideo()
		}
	}

	handleFRAShowModal = () => {
		this.setState({ FRAVisible: true })
	}

	onSubmit = (data) => {
		this.handleFRAClose();
		console.log(data)
		if (data && data.length > 0) {
			this.setState({ patNo: data[0].patNo, patID: data[0].patID, LTrowId: '', LTpatID: '', page: 1, mainInfo: [], usageData: [], rowData: {}, rowId: '' }, () => {
				this.refreshTableData();
			})
		}
	}

	// 语音提醒切换
	handleVoiceReminderSwitch = e => {
		this.setState({ voiceReminder: e }, () => {
			if (this.state.voiceReminder) {
				this.timingQueryTableData();
			} else {
				clearInterval(voiceTimer); // 取消语言播报
			}
		})
	}

	// 语音播报 -- 定时查询下拉列表
	timingQueryTableData = () => {
		if (voiceTimer) {
			clearInterval(voiceTimer);
		}
		console.log("触发了timingQueryTableData")
		this.refreshTableData("voice");
		voiceTimer = setInterval(() => {
			this.refreshTableData("voice");
		}, 30000)
	}

	// 打印确认单
	handlePrintConfirmationForm = async () => {
		try {
			let { rowData } = this.state;
			this.setState({ printBtnLoading: true });
			let data = {
				params: [{
					dispID: rowData?.dispID || '',
					prescno: rowData?.ordPrescNo || '',
				}]
			}
			let res = await React.$asyncPost(this, '02030131', data);
			this.setState({ printBtnLoading: false });
			let dataArr = res?.result || [];
			dataArr && dataArr.map((item, i) => {
				$loopPrint(item.template, item.printStr);
			})
		} catch (error) {
			console.log(error);
			this.setState({ printBtnLoading: false });
		}
	}

	// 获取打印样式
	getPrintDom = (item, index, mainIndex, childLen) => {
		let currentIndex = index + (mainIndex || 0)
		return (
			<div key={currentIndex}>
				<div className="flex-between-center">
					<span style={{ flex: 1 }} className="ellipsis" title={item?.medDesc || ''}>{currentIndex + 1}、{item?.medDesc || ''}</span>
					<span style={{ fontSize: '12px', flex: 1 }} className="ellipsis" title={item?.medSpec || ''}>
						<strong style={{ marginRight: '4px', fontSize: '16px' }}>{childLen && childLen > 1 ? (index === 0 ? '┑' : (index === childLen - 1 ? '┙' : '|')) : ''}</strong>
						{item?.medSpec || ''}
					</span>
					<span>{item?.ordQty + item?.ordUnitDesc}</span>
				</div>
				<div style={{ fontWeight: 900, paddingLeft: '60px', color: '#000' }}>
					<span>用法：{(item?.ordFreqDesc || '')}</span>
					<span style={{ margin: '0 6px' }}>每次{(item?.ordDoseUnitDesc || '')}</span>
					{item?.ordUsageDesc || ''}
					<span style={{ marginLeft: '12px' }}>{item?.ordEyePart || ''}</span>
				</div>
			</div>
		)
	}

	render() {
		let {
			tableData, total, page, basicHeight, windowDomData, fyFlag, startDate, endDate, patNo, mainInfo, usageData, PharmacistSelectData, voiceReminder, printBtnLoading, parameterSetting,
			rowId, rowData, windowVisible, pharmacistVisible, dispensingChecked, usageTableData, statusSelectData, selectedRowKeys, selectedRows, detailData,
			pharmacistValue, radioWindowData, loading, detailWidthTotal, detailColumns, columns, widthTotal, userData, FRAVisible
		} = this.state;
		let mainInfoObj = mainInfo && mainInfo.length > 0 ? mainInfo[0] : {};
		const { getFieldDecorator } = this.props.form;
		const rowSelection = {
			selectedRowKeys,
			selectedRows,
			onChange: (selectedRowKeys, selectedRows) => {
				this.setState({ selectedRowKeys, selectedRows })
			},
		};
		// 组件所需参数
		const param = {
			// 表头配置
			columns: columns && columns.length > 0 ? columns : this.columns,
			// 表格数据
			data: tableData,
			// 数据总条数
			total: total,
			// 当前页数
			page: page,
			pageSize: "20",
			// 表格的宽度
			x: columns && columns.length > 0 ? widthTotal : 500,
			y: store.getState().tableHeight.y + 91 - basicHeight,
			height: store.getState().tableHeight.y + 136 - basicHeight + 'px',
			isOnRow: true,
			rowClassName: true,
			loading,

		};
		let colTop = {
			xs: { span: 12 },
			sm: { span: 12 },
			md: { span: 10 },
			lg: { span: 10 },
			xl: { span: 10 },
			xxl: { span: 10 }
		};
		let colBottom = {
			xs: { span: 12 },
			sm: { span: 12 },
			md: { span: 14 },
			lg: { span: 14 },
			xl: { span: 14 },
			xxl: { span: 14 }
		}
		let windowDom = (
			windowDomData && windowDomData.map((item, index) => {
				return (
					<div key={index} style={{ margin: (index + 1) % 5 == 0 ? '0 0 20px 0' : '0 20px 20px 0' }}>
						<div className="check-box">
							<div className="prep-win-desc" style={{ background: item.checked ? '#1890FF' : '#69C0FF' }}>{item.dispWinDesc}</div>
							<div className="presc-num" style={{ color: item.checked ? '#1890FF' : '#69C0FF' }}>{item.prescNum}</div>
							<span>
								<Checkbox checked={item.checked} onChange={() => this.compileChecked(item, index)} />
							</span>
						</div>
						<Row className="check-row">
							<Switch checkedChildren={this.setMessage("DrugDistributionsomeone", "descripts", "有人")} unCheckedChildren={this.setMessage("DrugDistributionnobody", "descripts", "无人")} checked={item.statusID === 'O' ? true : false} onChange={(e) => this.handleSwitch(item, e)} />
						</Row>
					</div>
				)
			})
		)
		let medicalAdviceDom = (
			<div>
				<div style={{ borderBottom: '1px solid #ccc' }}>
					<h1 style={{ textAlign: 'center', position: 'relative', fontSize: '24px', marginBottom: '24px' }}>
						{mainInfoObj.hospName ? mainInfoObj.hospName : userData && userData.hospDesc ? userData.hospDesc : ""}{this.setMessage("DrugDistributionprescriptionNotes", "descripts", "处方笺")}
						<span style={{ position: 'absolute', right: '10px', top: '10px', fontSize: '14px', fontWeight: 100, textAlign: 'right', color: 'rgba(153,153,153,1)' }}>
							<Row>{mainInfoObj.prescType}</Row>
							{/*<Row>{this.setMessage("DrugDistributionordPrescNo", "descripts", "处方号：")}{mainInfoObj.ordPrescNo}</Row>*/}
						</span>
					</h1>
					<div style={{ padding: '0 48px 12px', fontSize: '14px' }}>
						<Row>
							{/*<Col span={6}>*/}
							{/*{this.setMessage("DrugDistributionloc", "descripts", "科室：")}{mainInfoObj.ordLocDesc}*/}
							{/*</Col>*/}
							{/*<Col span={6}>*/}
							{/*{this.setMessage("DrugDistributionpatID", "descripts", "病人ID：")}{mainInfoObj.patNo}*/}
							{/*</Col>*/}
							{/*<Col span={6}>*/}
							{/*{this.setMessage("DrugDistributiondate", "descripts", "日期：")}{mainInfoObj.ordDate}*/}
							{/*</Col>*/}
							{/*<Col span={6}>*/}
							{/*{this.setMessage("DrugDistributioncostCategory", "descripts", "费别：")}{mainInfoObj.admReasonDesc}*/}
							{/*</Col>*/}

							<Col span={8}>
								{this.setMessage("DrugDistributioncostCategory", "descripts", "费别")}{mainInfoObj.admReasonDesc}
							</Col>
							<Col span={8}>
								{this.setMessage("DrugDistributionordPrescNo", "descripts", "处方号")}{mainInfoObj.ordPrescNo}
							</Col>
							<Col span={8}>
								{this.setMessage("DrugDistributiondate", "descripts", "开具日期")}{mainInfoObj.ordDate}
							</Col>
						</Row>
						<Row style={{ margin: '4px 0' }}>

							<Col span={8}>
								{this.setMessage("DrugDistributionpatName", "descripts", "患者")}{mainInfoObj.patName}
							</Col>
							<Col span={8}>
								{this.setMessage("DrugDistributionpatSexDesc", "descripts", "性别")}{mainInfoObj.patSexDesc}
							</Col>
							<Col span={8}>
								{this.setMessage("DrugDistributionpatAge", "descripts", "年龄")}{mainInfoObj.patAge}
							</Col>
						</Row>
						{/*<Row>*/}
						{/*{this.setMessage("DrugDistributionadmDiag", "descripts", "诊断：")}{mainInfoObj.admDiag}*/}
						{/*</Row>*/}
						<Row>
							<Col span={8}>
								{this.setMessage("DrugDistributionpatNo", "descripts", "登记号")}{mainInfoObj.patNo}
							</Col>
							{/*<Col span={6}>*/}
							{/*{this.props.setMessage("DrugDistributionpatWeight", "descripts", "体重")}{mainInfoObj.patWeight}*/}
							{/*</Col>*/}
							<Col span={8}>
								{this.setMessage("DrugDistributionloc", "descripts", "科室")}{mainInfoObj.ordLocDesc}
							</Col>
							<Col span={8}>
								{this.setMessage("DrugDistributiondrugLoc", "descripts", "发药科室")}{mainInfoObj.drugLoc}
							</Col>
						</Row>

						<Row style={{ margin: '4px 0' }}>
							{this.setMessage("DrugDistributionphoneAddress", "descripts", "电话/地址：")}{mainInfoObj.phoneAddress}
						</Row>
						<Row>
							{this.setMessage("DrugDistributionadmDiag", "descripts", "临床诊断")}{mainInfoObj.admDiag}
						</Row>
					</div>
				</div>
				<div
					style={{
						borderBottom: '1px solid #ccc', padding: '0 24px',
						height: store.getState().tableHeight.y - 116 - this.state.basicHeight + 'px', overflow: 'auto'
					}}
					className="pr-style prescription-bar"
				>
					<h1 style={{ fontSize: '20px' }}>Rp:</h1>
					{mainInfoObj.cmPrescFlag === '1' ? <div className="marginRight">
						<div>
							{this.inciseData().map((data, key) => {
								return (
									<Row key={key}>
										{data && data.map((item, index) => {
											return (
												<Col span={6} key={index} style={{ marginBottom: '20px', paddingRight: "8px" }}>
													<span style={{ fontWeight: 900 }}>
														{item.medDesc}
													</span>
													<span style={{ marginLeft: '8px', position: 'relative', display: 'inline-block', fontWeight: 900 }}>
														{item.ordQty + item.ordUnitDesc}
														{item.ordCMNote ? <b style={{ position: 'absolute', top: '-8px', right: '-30px', fontWeight: 900, fontSize: '12px', color: 'blue' }}>{'(' + item.ordCMNote + ')'}</b> : ''}
													</span>
													<div style={{ marginLeft: '10px', fontSize: '12px' }}>
														{item.stkInfo[0] && item.stkInfo[0].rows.length > 1 ? item.stkInfo[0].rows.map((child, childIndex) => {
															return (
																<div key={childIndex}>
																	{child.stockDesc}
																	<span style={{ marginLeft: '8px' }}>{child.qty + child.baseUnitDesc}</span>
																</div>
															)
														}) : ''}
													</div>
												</Col>
											)
										})}
									</Row>
								)
							})}
						</div>
						<div style={{ textAlign: 'center', paddingRight: '150px' }}>
							--------------------------------------------------
							<span style={{ fontWeight: '900' }}>{this.setMessage("DrugDistributionblank", "descripts", "(以下空白)")}</span>
							--------------------------------------------------
						</div>
						<div className="marginRight" style={{ fontWeight: '900', }}>
							{this.setMessage("DrugDistributionusage", "descripts", "用法：")}{mainInfoObj.cmFreqDesc + '，' + mainInfoObj.cmExplainDesc + '，' + mainInfoObj.cmUsageDesc}
							<span style={{ margin: '0 15px' }}>{this.setMessage("DrugDistributiontotal", "descripts", "共：") + mainInfoObj.cmFac + this.setMessage("DrugDistributiondoses", "descripts", "剂")}</span>
							{mainInfoObj.cmCookTypeDesc}
						</div>
					</div> : (mainInfoObj.cmPrescFlag == '0' ? ( // 需求 #1432：界面显示需和打印出来的处方格式保持一致
						<div style={{ fontSize: '14px', fontWeight: 'normal', padding: '0 24px' }}>
							<div style={{ color: '#333' }}>
								{this.processAssociatedData(usageData).map((item, index) => {
									let currentIndex = index;
									let childLen = item && 'children' in item && Array.isArray(item.children) ? item.children.length : 0;
									return (
										<div key={currentIndex} style={{ lineHeight: '30px' }}>
											{item.children && item.children.length > 0 && item.children.map((childItem, childIndex) => {
												return this.getPrintDom(childItem, childIndex, currentIndex, childLen)
											})}
										</div>
									)
								})}
							</div>
							<div style={{ textAlign: 'center', marginTop: '24px' }}>{this.setMessage("DrugDistributionblank", "descripts", "(以下空白)")}</div>
						</div>
					) : ( // 正常处方样式
						<div>
							<ul style={{ fontSize: '14px', padding: '0 24px' }}>
								{this.processAssociatedData(usageData).map((item, index) => {
									let num = item.children && item.children.length ? item.children.length : 0;
									return (
										<li key={index} id={'usage' + index} style={{ position: 'relative' }}>
											<div style={{ paddingLeft: '24px', position: 'relative' }} className="prescription-list">
												<span style={{ position: 'absolute', left: 0, top: 0, display: 'inline-block', lineHeight: '30px' }}>{index + 1}、</span>
												{item.children && item.children.map((childItem, childIndex) => {
													return (
														<div key={childIndex} style={{ lineHeight: '30px', height: '30px' }}>
															<div style={{ float: 'left', width: '300px' }} className="ellipsis-nowrap-scroll-no">
																{childItem.medDesc}
																<span>
																	({childItem.dspInfo && childItem.dspInfo[0] && childItem.dspInfo[0].rows[0] && childItem.dspInfo[0].rows[0].batInfo.map((batInfoItem, index) => {
																		return (
																			// batNo - 批号 qty - 数量 manfDesc - 厂家
																			<span key={index} style={{ marginLeft: '4px', fontSize: '12px' }} title={(batInfoItem?.manfDesc || batInfoItem?.batNo) + '：' + batInfoItem.qty}>
																				{(batInfoItem?.manfDesc || batInfoItem?.batNo) + '：' + batInfoItem.qty}
																			</span>
																		)
																	})})
																</span>
															</div>
															<div style={{ float: 'left', width: childItem.partDispFlag > 0 ? '260px' : '320px', margin: '0 36px 0 12px', textAlign: 'right', height: '30px' }}>
																{childItem.medSpec}
																<span style={{ margin: '0 6px' }}>x</span>
																{childItem.partDispFlag > 0 ? <Input
																	value={childItem.filterDd}
																	style={{
																		width: '40px',
																		background: mainInfoObj && mainInfoObj.backGroupColor ? mainInfoObj.backGroupColor : '#fff'
																	}}
																	className="input-botder-bottom"
																/> : childItem.filterDd}
																{childItem.partDispFlag > 0 ? <span>({this.setMessage('DrugDistributiontotalOrdQty', 'descripts', '总数：') + childItem.totalOrdQty})</span> : ''}
																{childItem.ordUnitDesc}
																{childItem.partDispFlag > 0 ? <span onClick={() => this.handleISModal(childItem)} className="span" style={{ marginLeft: '12px' }} title={this.setMessage('DrugDistributionselectDurgNumTips', 'descripts', '点击可选需要给药的数量')}><Icon style={{ color: '#999' }} type={childItem.visible ? 'caret-down' : 'caret-left'} /></span> : ''}
																{childItem.partDispFlag > 0 ? '' : (
																	<span style={{ fontSize: '12px', color: '#999', fontWeight: 'normal' }}>
																		{/* （金额：{childItem && 'amt' in childItem ? childItem.amt : 0}元  库存：{childItem && 'stkQty' in childItem ? childItem.stkQty : ''}{childItem?.stkUnit || ''}） */}
																	</span>
																)}
															</div>
															<div style={{ display: num > 1 ? 'inline-block' : 'none', float: 'left', width: '60px', textAlign: 'right', borderRight: '1px solid #333', paddingRight: '10px' }}>
																{childItem.ordDoseUnitDesc}
															</div>
															<div style={{ display: num > 1 ? 'inline-block' : 'none', float: 'left' }} className={num > 1 ? 'show-last-span' : ''}>
																<span style={{ margin: '0 10px' }}>X</span> {childItem.ordDurationDesc}
															</div>

															<Row style={{ display: childItem.visible ? 'block' : 'none', marginTop: '12px', position: 'unset' }}>
																<Col span={10}></Col>
																<Col span={14}>
																	<div style={{ background: '#fff', width: '80%', textAlign: 'right', position: "absolute", zIndex: 10 }} className="draw-triangle">
																		<div className="arrow"></div>
																		<Table
																			columns={this.usageColumns}
																			dataSource={usageTableData}
																			bordered
																			pagination={false}
																			rowSelection={rowSelection}
																			className="arrow-table"
																		/>
																		<div style={{ border: '1px solid #E1E1E1', borderTop: '0', padding: '6px 24px' }}>
																			<Button type="primary" style={{ background: '#007AFF', color: '#fff' }} onClick={() => this.handleConfirm(childItem)}>{this.setMessage("DrugDistributiondetermine", "descripts", "确定")}</Button>
																		</div>
																	</div>
																</Col>
															</Row>
														</div>
													)
												})}
											</div>
											{/* <Row>
                                            <Col span={10}>{(index + 1) + '、' + item.medDesc}</Col>
                                            <Col span={14}>
                                                {item.medSpec ? item.medSpec : '--'}
                                                <span style={{margin: '0 6px'}}>x</span>
                                                {item.partDispFlag > 0 ? <Input
                                                    value={item.filterDd}
                                                    style={{
                                                        width: '40px',
                                                        background: mainInfoObj&&mainInfoObj.backGroupColor ? mainInfoObj.backGroupColor : '#fff'
                                                    }}
                                                    className="input-botder-bottom"
                                                /> : item.filterDd}
                                                {item.partDispFlag > 0 ? <span>(总数：{item.totalOrdQty})</span> : ''}
                                                {item.ordUnitDesc}
                                                {item.partDispFlag > 0 ? <span onClick={() => this.handleISModal(item)} className="span" style={{marginLeft: '20px'}} title="点击可选需要给药的数量"><Icon style={{color: '#999'}} type={item.visible ? 'caret-down' : 'caret-left'} /></span> : ''}
                                            </Col>
                                        </Row> */}
											<div className="marginRight">{this.setMessage("DrugDistributionusage", "descripts", "用法：")}{
												(item && item.children && item.children.length > 1 ? '' : item.children[0].ordDoseUnitDesc) + ' ' +
												(item && item.children && item.children[0] && item.children[0].ordFreqDesc ? item.children[0].ordFreqDesc : "") + ' ' +
												(item && item.children && item.children[0] && item.children[0].ordUsageDesc ? item.children[0].ordUsageDesc : "") + ' ' +
												(item && item.children && item.children.length > 1 ? '' : item.children[0].ordDurationDesc)}
												<span style={{ marginLeft: '50px' }}>
													{item && item.children && item.children.length > 1 ? '' : item.children[0].note}
												</span>
												<span style={{ marginLeft: '20px' }}>
													{item && item.children && item.children.length > 1 ? '' : item.children[0].skinTestWayDesc}
												</span>
											</div>
											{/* <Row>
                                            {item.stkInfo[0].rows&&item.stkInfo[0].rows.length > 0&&item.stkInfo[0].rows.map((child, childIdex) => {
                                                return (
                                                    <span key={childIdex} style={{marginRight: '20px', color: 'rgba(249, 94, 90, 1)', fontSize: '12px'}}>
                                                        {child.stockDesc + '[' + child.stockSpec + ']' + ' ' + 'x' + ' ' + child.qty + child.baseUnitDesc}
                                                    </span>
                                                )
                                            })}
                                        </Row> */}
										</li>
									)
								})}
							</ul>
							<div className="diagonal"></div>
						</div>
					))}
				</div>
				<div style={{ padding: '12px' }}>
					<Row style={{ marginBottom: '4px' }}>
						<Col span={8}>
							<Row>
								<Col {...colTop} className="alignRight">{this.setMessage("DrugDistributiondoctorSignName", "descripts", "医生签名：")}</Col>
								<Col {...colBottom} style={{ position: "relative" }}>
									{/* {mainInfoObj.ordDocDesc} */}
									{mainInfoObj && mainInfoObj.docStamp ? (
										// <span style={{
										// 	display: "inline-block", position: "absolute",
										// 	width: "100px", height: "36px", top: "-10px",
										// 	background: "url(" + mainInfoObj.docStamp + ") no-repeat",
										// 	backgroundSize: "contain"
										// }}></span>
										<img style={{ position: "absolute", width: "100px", height: "36px", top: "-10px" }} src={mainInfoObj.docStamp} alt="" />
									) : (
										<span>{mainInfoObj.ordDocDesc}</span>
									)}
								</Col>
							</Row>
						</Col>
						<Col span={8}>
							<Row>
								<Col {...colTop} className="alignRight">{this.setMessage("DrugDistributioncheck", "descripts", "审核：")}</Col>
								<Col {...colBottom} style={{ position: "relative" }}>
									{/* {mainInfoObj.auditUserName} */}
									{mainInfoObj && mainInfoObj.dispUserStamp ? (
										// <span style={{
										// 	display: "inline-block", position: "absolute",
										// 	width: "100px", height: "36px", top: "-10px",
										// 	background: "url(" + mainInfoObj.dispUserStamp + ") no-repeat",
										// 	backgroundSize: "contain" }}></span>
										<img style={{ position: "absolute", width: "100px", height: "36px", top: "-10px" }} src={mainInfoObj.dispUserStamp} alt="" />
									) : (
										<span>{mainInfoObj.auditUserName}</span>
									)}
								</Col>
							</Row>
						</Col>
						<Col span={8}>
							<Row>
								<Col {...colTop} className="alignRight">{this.setMessage("DrugDistributionamount", "descripts", "金额：")}</Col>
								<Col {...colBottom}>{mainInfoObj.prescAmt}</Col>
							</Row>
						</Col>
					</Row>
					<Row>
						<Col span={8}>
							<Row>
								<Col {...colTop} className="alignRight">{this.setMessage("DrugDistributionprovisioning", "descripts", "调配：")}</Col>
								<Col {...colBottom}>{mainInfoObj.prepUserName}</Col>
							</Row>
						</Col>
						<Col span={8}>
							<Row>
								<Col {...colTop} className="alignRight">{this.setMessage("DrugDistributionverify", "descripts", "核对：")}</Col>
								<Col {...colBottom}>{mainInfoObj.printUserName}</Col>
							</Row>
						</Col>
						<Col span={8}>
							<Row>
								<Col {...colTop} className="alignRight">{this.setMessage("DrugDistributiondrugDistribution", "descripts", "发药：")}</Col>
								<Col {...colBottom}>{mainInfoObj.dispUserName}</Col>
							</Row>
						</Col>
					</Row>
					{/* <p style={{textAlign: 'center', marginTop: '12px', marginBottom: 0}}>本处方当前有效</p> */}
				</div>
			</div>
		)

		// 审核状态
		let auditStatus = statusSelectData && statusSelectData.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})
		// 卡类型
		let cardTypeOption = this.state.cardSlectData && this.state.cardSlectData.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		let pharmacistSelect = PharmacistSelectData && PharmacistSelectData.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 提供给拒绝窗口的行数据
		let modalRowData = {
			statusID: 'Before',
			...rowData
		}
		// console.log(modalRowData)

		return (
			<div className="dispensing">
				{/* 语音播报插件 */}
				<div style={{ display: 'node' }}>
					<audio id="a_player_audio" src={this.state.audioUrl}></audio>
				</div>
				<Row id="outpha-dispensing-basic" style={{ padding: '0 12px 0 20px' }}>
					<Col xs={12} sm={12} md={12} lg={12} xl={16} className="input-padding-right">
						<Row style={{ marginBottom: '20px' }}>
							<Select value={this.state.cardType} onChange={this.handleCardTypeOnChange} showSearch optionFilterProp="seatchprop" allowClear placeholder={this.setMessage("DrugDistributionperHealthCard", "descripts", "居民健康卡")} style={{ width: '109px', margin: '22px 10px 0 0' }}>
								{cardTypeOption}
							</Select>
							<Input value={this.state.cardNo} allowClear onChange={this.handleCardNoChange} onBlur={(e) => this.handleReadCardOnBlur(e, 'blur')} onPressEnter={(e) => this.handleReadCardOnBlur(e, 'enter')} placeholder={this.setMessage("DrugDistributioncardNumTips", "descripts", "请输入卡号(Enter)")} style={{ width: '142px', marginTop: '22px', borderRight: '0' }} />
							<Button style={{ margin: '0 10px', marginTop: "22px", background: '#007AFF', color: '#fff' }} onClick={this.handleReadCard}>{this.setMessage("DrugDistributionCardReading", "descripts", "读卡")}</Button>
							<Input
								title={this.setMessage("DrugDistributionenterToSeachPatID", "descripts", "回车触发病人ID查询")}
								allowClear
								placeholder={this.setMessage("DrugDistributionpatId/CardNum", "descripts", "病人ID/证件号(Enter)")}
								ref={this.myRef1}
								style={{ width: '160px', margin: '22px 10px 0 0' }}
								value={patNo}
								onBlur={(e) => this.handlePatient(e, 'blur')}
								onChange={this.handlePatientOnChange}
								onPressEnter={(e) => this.handlePatient(e, 'enter')}
							/>
							<div style={{ display: 'inline-block' }}>
								<span className="d-form-label">{this.setMessage("DrugDistributionchargeDate", "descripts", "收费日期：")}</span>
								<DatePicker className="d-start-date" value={startDate} onChange={this.handleStartDate} style={{ width: '125px', marginTop: '8px' }} placeholder={this.setMessage("DrugDistributionstartDate", "descripts", "开始日期")} />
								<span className="d-form-label form-label-date">{this.setMessage("DrugDistributionto", "descripts", "到")}</span>
								<DatePicker className="d-end-date" value={endDate} onChange={this.handleEndDate} style={{ width: '125px', marginRight: '8px' }} placeholder={this.setMessage("DrugDistributiondeadline", "descripts", "结束日期")} />
								<Select value={fyFlag} onChange={this.handlestatusID} showSearch optionFilterProp="seatchprop" allowClear placeholder={this.setMessage("DrugDistributionstate", "descripts", "状态")} style={{ width: '125px', margin: '8px 10px 0 0' }}>
									{auditStatus}
								</Select>
								<Button type="primary" style={{ margin: '8px 10px 0 0' }} onClick={this.handleQuery}>{this.setMessage("DrugDistributionsearch", "descripts", "查询")}</Button>
								<Button style={{ marginTop: '8px' }} onClick={this.handleFRAShowModal}>人脸识别</Button>
							</div>
						</Row>
					</Col>
					<Col xs={12} sm={12} md={12} lg={12} xl={8} className="d-operation-right">
						<span style={{ marginRight: '24px', display: dispensingChecked ? "flex" : "none", alignItems: "center" }}>
							<span className="d-form-label" style={{ width: "72px", marginTop: '0' }}>{this.setMessage("DrugDistributionpharmacist", "descripts", "配药师：")}</span>
							<Select placeholder="请选择" style={{ width: '150px' }} showSearch optionFilterProp="seatchprop" allowClear value={pharmacistValue} onChange={(e) => this.handlePharmacistValue(e, true)}>
								{pharmacistSelect}
							</Select>
						</span>
						<span>
							{this.setMessage("DrugDistributiondirectModel", "descripts", "直接发药：")}<Switch checkedChildren="是" unCheckedChildren="否" checked={dispensingChecked} onClick={this.onClickSwitch} />
						</span>
						<div className="dor-switch-win">
							<span>{this.setMessage("DrugDistributioncurrentWin", "descripts", "当前窗口：")}{radioWindowData && radioWindowData.dispWinDesc ? radioWindowData.dispWinDesc : this.setMessage("DrugDistributionNonSelectedWin", "descripts", "未选择窗口")}</span>
							<span onClick={this.switchingWindow} style={{ color: "#007AFF", marginTop: "8px" }}>
								<Icon type="swap" />
								{this.setMessage("DrugDistributionswitchWin", "descripts", "切换窗口")}
								{/* <Button type="dashed" ></Button> */}
							</span>
						</div>

					</Col>
				</Row>
				<div style={{ height: '6px', background: 'rgba(240, 242, 245, 1)', width: '100%' }}></div>
				<Row>
					<Col
						span={4}
						tabIndex={1}
						onKeyDown={this.handleDFYOnKeydown}
						style={{ outline: 'none' }}
						id="dfy-list"
					>
						<Card
							size="small"
							title={<div className="card-title-left-img">
								<img src={iconMedicine} alt=""></img>{this.setMessage("DrugDistributionwaitForDelivery", "descripts", "待发药")}
							</div>}
						>
							<div style={{ height: store.getState().tableHeight.y + 174 - basicHeight + 'px' }}>
								<Table
									columns={detailColumns && detailColumns.length > 0 ? detailColumns : this.detailColumns}
									dataSource={detailData}
									bordered
									pagination={false}
									scroll={{ x: detailColumns && detailColumns.length > 0 ? detailWidthTotal : '200', y: store.getState().tableHeight.y + 91 - basicHeight }}
									onRow={this.onClickRowLeftTable}
									rowClassName={this.setRowClassNameLeftTable}
									className="table-scroll-height"
								/>
							</div>
						</Card>
					</Col>
					<Col
						span={8}
						tabIndex={1}
						onKeyDown={this.handleFYLBOnKeydown}
						style={{ outline: 'none' }}
						id="fy-list"
					>
						<div style={{ paddingLeft: '6px', position: 'relative' }}>
							<Card
								size="small"
								title={<div className="card-title-left-img" style={{ position: "relative" }}>
									<div>
										<img src={iconListvisits} alt="" />{this.setMessage("DrugDistributiondistributingDrugList", "descripts", "发药列表")}
									</div>
									<div style={{ position: "absolute", top: "-8px", right: "12px", height: "38px", display: "flex", alignItems: "center" }}>
										语音提醒：
										<Switch checkedChildren="是" unCheckedChildren="否" checked={voiceReminder} onChange={this.handleVoiceReminderSwitch} />
									</div>
								</div>}
								className="dispensing-list"
							>
								<PubilcTablePagination param={param} handelThis={this} onRef={this.onRef} onClickRowPublic={this.onClickRowPublic} setRowClassNamePublic={this.setRowClassNamePublic} />
							</Card>
							<div style={{ width: '6px', background: 'rgba(240, 242, 245, 1)', position: 'absolute', top: 0, left: 0, height: '100%' }}></div>
						</div>
					</Col>
					<Col span={12}>
						<div style={{ paddingLeft: '6px', position: 'relative' }}>
							<div className="prescription-btn">
								{parameterSetting?.confirmPrint === 'Y' ? (
									<Button
										ghost
										type="danger"
										disabled={!rowId}
										loading={printBtnLoading}
										style={{ marginRight: '30px', color: !rowId ? '#d9d9d9' : '#1890FF', borderColor: !rowId ? '#d9d9d9' : '#1890FF' }}
										onClick={this.handlePrintConfirmationForm}
									>{parameterSetting?.confirmPrintText || '打印确认单'}</Button>
								) : ''}
								<Button
									type="danger"
									onClick={this.handlePrintLabel}
									style={{ marginRight: '30px', color: !rowId ? '#d9d9d9' : '#1890FF', borderColor: !rowId ? '#d9d9d9' : '#1890FF' }}
									disabled={!rowId}
									ghost
								>{this.setMessage("DrugDistributionprintLabel", "descripts", "打印标签")}</Button>
								<Button
									type="danger"
									onClick={this.handlePrintPresc}
									style={{ marginRight: '30px', color: !rowId ? '#d9d9d9' : '#1890FF', borderColor: !rowId ? '#d9d9d9' : '#1890FF' }}
									disabled={!rowId}
									ghost
								>{this.setMessage("DrugDistributionprintPre", "descripts", "打印处方")}</Button>
								<Button
									type="danger"
									onClick={this.handlePrintPYD}
									style={{ marginRight: '30px', color: !rowId ? '#d9d9d9' : '#1890FF', borderColor: !rowId ? '#d9d9d9' : '#1890FF' }}
									disabled={!rowId}
									ghost
								>{this.setMessage("DrugDistributionprintPYD", "descripts", "打印配药单")}</Button>
								<Button
									type="danger"
									onClick={() => this.modalChild.showModal(modalRowData, usageData)}
									style={{ marginRight: '30px' }}
									disabled={!rowId || rowData.dispStatus === 'Y' || this.state.authorityStatus}
									ghost
								>{this.setMessage("DrugDistributionrefusingToDistribute", "descripts", "拒绝发药")}</Button>
								<Button
									type="primary"
									onClick={this.handleDispensing}
									style={{ marginRight: '30px' }}
									disabled={!rowId || rowData.dispStatus === 'Y' || this.state.authorityStatus}
								>{this.setMessage("DrugDistributiondrugDelibery", "descripts", "发药")}</Button>
								<Button
									type="primary"
									onClick={this.handleFullDose}
									disabled={tableData && tableData.length > 0 ? this.state.authorityStatus ? true : false : true}
								>一键发药</Button>
							</div>
							<Card
								size="small"
								// title={this.setMessage("DrugDistributionprescriptionNotes", "descripts", "处方笺")}
								title=""
								// extra={<a href="#">More</a>}
								className="prescription"
							// className="catd-head-bg-img prescription"
							>
								<div className="prescription-bar" style={{
									height: store.getState().tableHeight.y + 175 - basicHeight + 'px',
									overflow: 'auto',
									background: mainInfoObj && mainInfoObj.backGroupColor ? mainInfoObj.backGroupColor : '#fff'
								}}>
									<p style={{ textAlign: 'center', display: !(mainInfo && mainInfo.length > 0) ? 'block' : 'none', textDecoration: 'underline', paddingTop: "24px" }}>{this.setMessage("DrugDistributionviewPrescriptionFormTips", "descripts", "选择左侧处方来查看处方单")}</p>
									<div style={{
										width: '100%',
										height: '100%',
										paddingTop: "24px",
										display: mainInfo && mainInfo.length > 0 ? 'block' : 'none',
									}}>
										{medicalAdviceDom}
									</div>
								</div>
							</Card>
							<div style={{ width: '6px', background: 'rgba(240, 242, 245, 1)', position: 'absolute', top: 0, left: 0, height: '100%' }}></div>
						</div>
					</Col>
				</Row>
				{/* <Row style={{ height: '40px', lineHeight: '40px' }}>
                    <Col span={6}></Col>
                    <Col span={14}>

                    </Col>
                    <Col span={4}></Col>
                </Row> */}
				<Modal
					title={<div><div className="modal-title-top"></div>{this.setMessage("DrugDistributionselectPharmacist", "descripts", "选择配药师")}</div>}
					visible={pharmacistVisible}
					onOk={this.pharmacistHandleOk}
					onCancel={() => this.handleCancel("pharmacist")}
					className="modal-header-line"
				>
					<div style={{ minHeight: '100px' }}>
						{this.setMessage("DrugDistributionpharmacist", "descripts", "配药师：")}<Select style={{ width: '200px' }} showSearch optionFilterProp="seatchprop" allowClear value={pharmacistValue} onChange={(e) => this.handlePharmacistValue(e, false)}>
							{pharmacistSelect}
						</Select>
					</div>
				</Modal>
				<Modal
					title={<div><div className="modal-title-top"></div>{this.setMessage("DrugDistributionselectWin", "descripts", "选择窗口")}</div>}
					visible={windowVisible}
					style={{ minWidth: '680px' }}
					closable={radioWindowData && radioWindowData.dispWinID ? true : false}
					className="modal-header-line modal-body-padding"
					maskClosable={radioWindowData && radioWindowData.dispWinID ? true : false}
					onCancel={() => this.handleCancel("window")}
					footer={
						<div>
							{radioWindowData && radioWindowData.dispWinID ? <Button style={{ marginRight: '8px' }} onClick={() => this.handleCancel("window")}>{this.setMessage("DrugDistributioncancel", "descripts", "取消")}</Button> : ''}
							<Button onClick={this.windowHandleOk} style={{ backgroundColor: '#1890ff', borderColor: '#1890ff', color: '#fff' }}>{this.setMessage("DrugDistributiondetermine", "descripts", "确认")}</Button>
						</div>
					}
				>
					<div style={{ color: '#F5222D', fontSize: '4px', background: '#FFF1F0', height: '32px', lineHeight: '32px', paddingLeft: '24px' }}>
						<Icon type="exclamation-circle" style={{ marginRight: '4px' }} />{this.setMessage("DrugDistributionswitchingWinTips", "descripts", "切换窗口时请选择需要切换的窗口并点击确定按钮。")}
					</div>
					<Form style={{ padding: '0 24px' }}>
						<Form.Item label={this.setMessage("DrugDistributionPleaseSelectWin", "descripts", "请选择窗口：")}>
							{getFieldDecorator('window', {
								rules: [{ required: true }],
							})(
								<Row className="ad-window li-window" style={{ padding: '0 20px' }}>
									{windowDom}
								</Row>
							)}
						</Form.Item>
					</Form>
				</Modal>
				<RejectPrescription onRef={this.onModalRef} handleThis={this} modalTitle={this.setMessage("DrugDistributionrefusingToDistribute", "descripts", "拒绝发药")} />
				<ReadCard ref={r => this.readCard = r} />
				<ColumnAuthoritysModel
					clientWidth='800px'
					compontName='DrugDistribution'
					configType="C"
					onRef={this.onMainColumnRef}
					reloadData={this.getMainTableColumns}
				/>
				<ColumnAuthoritysModel
					clientWidth='800px'
					compontName='OutpatientWaitingList'
					configType="C"
					onRef={this.onDetailColumnRef}
					reloadData={this.getOutpatientWaitingList}
				/>
				<Modal className='face-recognition-modal'
					title={'人脸识别'}
					maskClosable={false}
					footer={null}
					visible={FRAVisible}
					onCancel={this.handleFRAClose}
					onOk={this.onSubmit}>
					<div style={{ display: "flex", justifyContent: "center", marginTop: "-36px" }}>
						{FRAVisible ? <FaceRecognitionAuto businessCode={'001'} faceType='patient' loadDara={this.onSubmit}
							hospID={userData.hospID}
							locID={userData.locID}
							doctorID={userData.userID}
							closeModal={this.handleFRAClose}
							ref={this.onFaceRecognitionAutoRefs} /> : null}
					</div>
				</Modal>

			</div>
		)
	}
};
const DispensingForm = Form.create()(Dispensing);
export default DispensingForm;
