// 药品维护
import React from 'react';
import { Row, Col, Card, Tabs, Input, Button, Tree, Icon, Select, Divider, Tooltip } from 'antd';
import store from 'store';
import { $http } from 'containers/config/https';

import PubilcTablePagination from 'pages/common/PubilcTablePagination.jsx';
import AddDrugInformation from './component/AddDrugInformation.jsx'; // 新增药品信息
import AddGeneralNameChemistry from './component/AddGeneralNameChemistry.jsx'; // 新增化学通用名
import AddGeneralNamePrescription from './component/AddGeneralNamePrescription.jsx'; // 新增处方通用名
import AddDoctorAdvice from './component/AddDoctorAdvice.jsx'; // 新增医嘱项
import AddInventoryItem from './component/AddInventoryItem.jsx'; // 新增库存项
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';

import './style/index.less';
import 'assets/css/common.css';

const { TabPane } = Tabs;
const { TreeNode } = Tree;
let { Option } = Select;

let timeout;

export default class DrugMaintenance extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			activeTabPaneKey: '4', // 当前视图展现的tab
			chemistryColumns: [], // 化学通用名
			chemistryTableData: [], // 化学通用名列表数据
			chemistryTotal: 0,
			chemistryPage: 1,
			chemistryPageSize: 20,
			chemistryRowId: '',
			chemistryRowData: {},
			prescriptionColumns: [], // 处方通用名
			prescriptionTableData: [], // 处方通用名列表数据
			prescriptionTotal: 0,
			prescriptionPage: 1,
			prescriptionPageSize: 20,
			prescriptionRowId: '',
			prescriptionRowData: {},
			medicalOrderItemColumns: [], // 医嘱项
			medicalOrderItemTableData: [], // 医嘱项列表数据
			medicalOrderItemTotal: 0,
			medicalOrderItemPage: 1,
			medicalOrderItemPageSize: 20,
			medicalOrderItemRowId: '',
			inventoryItemColumns: [], // 库存项
			inventoryItemTableData: [], // 库存项列表数据
			inventoryItemTotal: 0,
			inventoryItemPage: 1,
			inventoryItemPageSize: 20,
			inventoryItemRowId: '',
			expandedKeys: [],
			autoExpandParent: true,
			treeData: [],
			inputValue: "",
			phCatID: '',
			phCatCode: '',
			phCatDesc: '',
			rightCardTitle: JSON.parse(window.sessionStorage.userData).language == 'EN' ? 'New pharmacologic class' : '新增药理学分类',
			treeRowData: {}, // 选中树数据对象
			phCatFlag: 'add', // 药理学分类flag
			selectedKeys: [], // 选中树节点
			prescriptionSelectData: {}, // 处方通用名下拉框数据
			prescriptionChemicDesc: undefined, // 化学通用名
			prescriptionForm: undefined, // 剂型
			prescriptionStatus: undefined, // 处方通用名状态
			medicalOrderSelectData: {}, // 医嘱项下拉列表数据
			medicalOrderStatus: "U", // 医嘱项状态
			inventoryItemSelectData: {}, // 库存项下拉列表数据
			// doubleGenerData: {}, // 处方通用名行数据
			doubleMedData: {}, // 医嘱项行数据
			loading: false,
			medicalGenerID: undefined,
			medItemData: [],
			medValue: undefined,
			medFormValue: undefined, // 医嘱项剂型
			isSaveAnother: 'compile', // 是否为另存
			isSaveAnotherInventoryItem: 'compile',
			language: JSON.parse(window.sessionStorage.userData),
			ChineseEnglishSize: {},
			parameterCode: '',
			medicalOrderItemTotalWidth: '',
			inventoryItemTotalWidth: '',
			ordSubCatID: undefined,
		};
		this.chemistryColumns = [ // 化学通用名
			{
				title: '化学通用名代码',
				dataIndex: 'chemicCode',
				width: '100px',
				align: "center",
			},
			{
				title: '化学通用名描述',
				dataIndex: 'chemicDesc',
				width: '300px',
				align: "center"
			}
		];
		this.prescriptionColumns = [ // 处方通用名
			{
				title: '处方通用名代码',
				dataIndex: 'generCode',
				width: '80px',
				align: "center",
			},
			{
				title: '处方通用名描述',
				dataIndex: 'generDesc',
				width: '120px',
				align: "center"
			},
			{
				title: '化学通用名',
				dataIndex: 'chemicDesc',
				width: '120px',
				align: "center"
			},
			{
				title: '药理学分类',
				dataIndex: 'phCatDesc',
				width: '80px',
				align: "center"
			}
		];
		this.medicalOrderItemColumns = [ // 医嘱项
			{
				title: '医嘱项代码',
				dataIndex: 'medCode',
				width: '80px',
				align: "center",
			},
			{
				title: '医嘱项描述',
				dataIndex: 'medDesc',
				width: '200px',
				align: "center"
			},
			{
				title: '含量规格',
				dataIndex: 'medSpec',
				width: '80px',
				align: "center"
			},
			{
				title: '医嘱子类',
				dataIndex: 'medSubCatDesc',
				width: '100px',
				align: "center"
			},
			{
				title: '处方通用名',
				dataIndex: 'generDesc',
				width: '100px',
				align: "center"
			},
			{
				title: '剂型',
				dataIndex: 'medFormDesc',
				width: '80px',
				align: "center"
			},
			{
				title: '生产企业',
				dataIndex: 'manfDesc',
				width: '80px',
				align: "center"
			},
			{
				title: '批准文号',
				dataIndex: 'apprNo',
				width: '80px',
				align: "center"
			},
			{
				title: '操作',
				align: "center",
				width: 130,
				fixed: "right",
				render: (text, record) => (
					<span>
						<Icon type="edit" style={{ color: '#1890ff' }}></Icon>
						<span className='span' onClick={() => this.medicalOrderCompileRowData(record, 'compile')}>编辑</span>
						{/* 分割线 */}
						<Divider type="vertical" />
						<Icon type="edit" style={{ color: '#1999db' }}></Icon>
						<span className='span' style={{ color: "#1999db" }} onClick={() => this.medicalOrderCompileRowData(record, 'saveAnother')}>另存</span>
					</span>
				),
			}
		];
		this.inventoryItemColumns = [
			{
				title: '库存项代码',
				dataIndex: 'stockCode',
				width: '120px',
				align: "center",
			},
			{
				title: '库存项描述',
				dataIndex: 'stockDesc',
				width: '300px',
				align: "center"
			},
			{
				title: '包装规格',
				dataIndex: 'stockSpec',
				width: '120px',
				align: "center"
			},
			{
				title: '库存分类',
				dataIndex: 'stkSubCatDesc',
				width: '80px',
				align: "center"
			},
			{
				title: '基本单位',
				dataIndex: 'baseUnitDesc',
				width: '120px',
				align: "center"
			},
			{
				title: '医嘱项描述',
				dataIndex: 'medDesc',
				width: '300px',
				align: "center"
			},
			{
				title: '操作',
				align: "center",
				width: 130,
				fixed: "right",
				render: (text, record) => (
					<span>
						<Icon type="edit" style={{ color: '#1890ff' }}></Icon>
						<span className='span' onClick={() => this.inventoryItemCompile(record, 'compile')}>编辑</span>
						{/* 分割线 */}
						<Divider type="vertical" />
						<Icon type="edit" style={{ color: '#1999db' }}></Icon>
						<span className='span' style={{ color: "#1999db" }} onClick={() => this.inventoryItemCompile(record, 'saveAnother')}>另存</span>
					</span>
				),
			}
		];
	}

	componentDidMount() {
		this.getChemistryColumns();
		this.publicTableRef && this.publicTableRef.handleLoading();
		// this.getTreeData();
		this.getMedicalOrderItemColumns();
		this.getMedicalOrderItemTableData();
		this.getMedicalOrderSelectData();
	}

	// 获取化学通用名列表头数据
	getChemistryColumns = () => {
		let { language } = this.state;
		let data = {
			params: [{
				reactCode: ['DrugMaintenance'],
				compontName: 'ChemicalCommonName',
				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.setState({ parameterCode: 'ChemicalCommonName' }, () => {
									this.columnRef.onOpenModel();
								})
							}}>{language.language == 'EN' ? item.enDescripts : item.title}</div>
						}
					}) : '';
					let filterArr = arr.filter(function (item) { return item.display === 'Y' });
					this.setState({ chemistryColumns: filterArr, detailWidthTotal: res.totalWidth, ChineseEnglishSize: language.language == 'EN' ? res.result.language.EN : res.result.language.CN })
				}
			}
		})
	};

	// 获取处方通用名列表头数据
	getPrescriptionColumns = () => {
		let { language } = this.state;
		let data = {
			params: [{
				compontName: 'PrescriptionCommonNameList',
				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.setState({ parameterCode: 'PrescriptionCommonNameList' }, () => {
									this.columnRef.onOpenModel();
								})
							}}>{language.language == 'EN' ? item.enDescripts : item.title}</div>
						}
					}) : '';
					let filterArr = arr.filter(function (item) { return item.display === 'Y' });
					this.setState({ prescriptionColumns: filterArr })
				}
			}
		})
	};

	// 获取医嘱项列表头数据
	getMedicalOrderItemColumns = () => {
		let { language } = this.state;
		let data = {
			params: [{
				compontName: 'OrderList',
				type: 'C',
			}]
		}
		$http.post('urlS', this, {
			code: '01040073',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					var totalWidth = 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,
							widthNum: parseInt(item.width),
							title: <div onDoubleClick={() => {
								this.setState({ parameterCode: 'OrderList' }, () => {
									this.columnRef.onOpenModel();
								})
							}}
							>{language.language == 'EN' ? item.enDescripts : item.title}</div>,
							render: (text, record) => {
								return (
									<Tooltip title={text}>
										<span className='ellipsis' style={{ width: '100%', display: 'block' }}>{text}</span>
									</Tooltip>
								);
							},
						}
					}) : '';
					let filterArr = arr.filter(function (item) { return item.display === 'Y' });
					let obj = {
						title: language.language == 'EN' ? 'Operation' : '操作',
						key: 14,
						align: "center",
						width: '130px',
						fixed: "right",
						widthNum: 130,
						render: (text, record) => (
							<span>
								<Icon type="edit" style={{ color: '#1890ff' }}></Icon>
								<span className='span' onClick={() => this.medicalOrderCompileRowData(record, 'compile')}>{language.language == 'EN' ? 'edit' : '编辑'}</span>
								{/* 分割线 */}
								<Divider type="vertical" />
								<Icon type="edit" style={{ color: '#1999db' }}></Icon>
								<span className='span' style={{ color: "#1999db" }} onClick={() => this.medicalOrderCompileRowData(record, 'saveAnother')}>{language.language == 'EN' ? 'Save as' : '另存'}</span>
							</span>
						),
					};
					filterArr.push(obj);
					for (var i = 0; i < filterArr.length; i++) {
						totalWidth += filterArr[i].widthNum;
					}
					this.setState({ medicalOrderItemColumns: filterArr, medicalOrderItemTotalWidth: totalWidth })
				}
			}
		})
	};

	// 获取库存项列表头数据
	getInventoryItemColumns = () => {
		let { language } = this.state;
		let data = {
			params: [{
				compontName: 'InventoryItemList',
				type: 'C',
			}]
		}
		$http.post('urlS', this, {
			code: '01040073',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0) {
					var totalWidth = 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,
							widthNum: parseInt(item.width),
							title: <div onDoubleClick={() => {
								this.setState({ parameterCode: 'InventoryItemList' }, () => {
									this.columnRef.onOpenModel();
								})
							}}>{language.language == 'EN' ? item.enDescripts : item.title}</div>,
							render: (text, record) => {
								return (
									<Tooltip title={text}>
										<span className='ellipsis' style={{ width: '100%', display: 'block' }}>{text}</span>
									</Tooltip>
								);
							},
						}
					}) : '';
					let filterArr = arr.filter(function (item) { return item.display === 'Y' });
					let obj = {
						title: language.language == 'EN' ? 'Operation' : '操作',
						key: 14,
						fixed: 'right',
						align: "center",
						width: '130px',
						widthNum: 130,
						render: (text, record) => (
							<span>
								<Icon type="edit" style={{ color: '#1890ff' }}></Icon>
								<span className='span' onClick={() => this.inventoryItemCompile(record, 'compile')}>{language.language == 'EN' ? 'edit' : '编辑'}</span>
								{/* 分割线 */}
								<Divider type="vertical" />
								<Icon type="edit" style={{ color: '#1999db' }}></Icon>
								<span className='span' style={{ color: "#1999db" }} onClick={() => this.inventoryItemCompile(record, 'saveAnother')}>{language.language == 'EN' ? 'Save as' : '另存'}</span>
							</span>
						),
					};
					filterArr.push(obj);
					for (var i = 0; i < filterArr.length; i++) {
						totalWidth += filterArr[i].widthNum;
					}
					this.setState({ inventoryItemColumns: filterArr, inventoryItemTotalWidth: totalWidth })
				}
			}
		})
	};
	// 公共table组件
	onPublicTableRef = ref => {
		this.publicTableRef = ref;
	}

	// 切换药品维护页签
	toggleTabPane = key => {
		this.setState({ activeTabPaneKey: key, inputValue: "" }, () => {
			this.publicTableRef.handleLoading();
			this.compileRightCardTitleAndGetColumnsData();
		})
	}

	// 修改右侧card描述以及获取对应表头数据
	compileRightCardTitleAndGetColumnsData = () => {
		let { activeTabPaneKey, phCatFlag, chemistryRowId, prescriptionRowId, medicalOrderItemRowId, inventoryItemRowId, ChineseEnglishSize } = this.state;
		if (activeTabPaneKey === '1') {
			if (phCatFlag === 'add') {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddPC ? ChineseEnglishSize.DrugMaintenanceaddPC.descripts : '新增药理学分类' })
			} else {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditPC ? ChineseEnglishSize.DrugMaintenanceeditPC.descripts : '编辑药理学分类' })
			}
		} else if (activeTabPaneKey === '2') {
			if (!(this.state.chemistryColumns && this.state.chemistryColumns.length > 0)) {
				this.getChemistryTableData();
			}
			this.getChemistryTableData();
			if (chemistryRowId) {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditCGN ? ChineseEnglishSize.DrugMaintenanceeditCGN.descripts : '编辑化学通用名' })
			} else {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddPGN ? ChineseEnglishSize.DrugMaintenanceaddPGN.descripts : '新增化学通用名' })
			}
		} else if (activeTabPaneKey === '3') {
			if (!(this.state.prescriptionColumns && this.state.prescriptionColumns.length > 0)) {
				this.getPrescriptionColumns();
			}
			this.getPrescriptionTableData();
			this.getPrescriptionSelectData();
			if (prescriptionRowId) {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditPGN ? ChineseEnglishSize.DrugMaintenanceeditPGN.descripts : '编辑处方通用名' })
			} else {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddPGN ? ChineseEnglishSize.DrugMaintenanceaddPGN.descripts : '新增处方通用名' })
			}
		} else if (activeTabPaneKey === '4') {
			if (!(this.state.medicalOrderItemColumns && this.state.medicalOrderItemColumns.length > 0)) {
				this.getMedicalOrderItemColumns();
			}
			this.getMedicalOrderItemTableData();
			this.getMedicalOrderSelectData();
			if (medicalOrderItemRowId) {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditOI ? ChineseEnglishSize.DrugMaintenanceeditOI.descripts : '编辑医嘱项' })
			} else {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditOI ? ChineseEnglishSize.DrugMaintenanceeditOI.descripts : '新增医嘱项' })
			}
		} else if (activeTabPaneKey === '5') {
			if (!(this.state.inventoryItemColumns && this.state.inventoryItemColumns.length > 0)) {
				this.getInventoryItemColumns();
			}
			this.getInventoryItemTableData();
			this.getInventoryItemSelectData();
			if (inventoryItemRowId) {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditII ? ChineseEnglishSize.DrugMaintenanceeditII.descripts : '编辑库存项' })
			} else {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddII ? ChineseEnglishSize.DrugMaintenanceaddII.descripts : '新增库存项' })
			}
		}
	}

	handleCommonQuery = () => {
		let { activeTabPaneKey } = this.state;
		if (activeTabPaneKey === '2') {
			// 修改page，或者pageSize
			this.setState({ chemistryPage: 1, chemistryRowId: "", chemistryRowData: {} }, () => {
				// 重新调用查询方法
				this.getChemistryTableData();
			})
		} else if (activeTabPaneKey === '3') {
			this.setState({ prescriptionPage: 1 }, () => {
				// 重新调用查询方法
				this.getPrescriptionTableData();
			})
		} else if (activeTabPaneKey === '4') {
			this.setState({ medicalOrderItemPage: 1 }, () => {
				// 重新调用查询方法
				this.getMedicalOrderItemTableData();
			})
		} else if (activeTabPaneKey === '5') {
			this.setState({ inventoryItemPage: 1 }, () => {
				// 重新调用查询方法
				this.getInventoryItemTableData();
			})
		}
	}

	// 提供修改page和pageSize的回调函数
	compilePage(page, pageSize) {
		let { activeTabPaneKey } = this.state;
		if (activeTabPaneKey === '2') {
			// 修改page，或者pageSize
			this.setState({ chemistryPage: page, chemistryPageSize: pageSize }, () => {
				// 重新调用查询方法
				this.getChemistryTableData();
				this.childChemistry.resetFields();
			})
		} else if (activeTabPaneKey === '3') {
			// 修改page，或者pageSize
			this.setState({ prescriptionPage: page, prescriptionPageSize: pageSize }, () => {
				// 重新调用查询方法
				this.getPrescriptionTableData();
				this.childPrescription.resetFields();
			})
		} else if (activeTabPaneKey === '4') {
			// 修改page，或者pageSize
			this.setState({ medicalOrderItemPage: page, medicalOrderItemPageSize: pageSize }, () => {
				// 重新调用查询方法
				this.getMedicalOrderItemTableData();
			})
		} else if (activeTabPaneKey === '5') {
			// 修改page，或者pageSize
			this.setState({ inventoryItemPage: page, inventoryItemPageSize: pageSize }, () => {
				// 重新调用查询方法
				this.getInventoryItemTableData();
			})
		}
	}

	// 获取化学通用名table数据
	getChemistryTableData = () => {
		this.setState({ loading: true });
		let { inputValue, chemistryPage, chemistryPageSize } = this.state;
		let data = {
			params: [{
				chemicAlias: inputValue,
			}],
			pagination: [{
				pageSize: chemistryPageSize,
				currentPage: chemistryPage,
				sort: "ID",
				dir: "desc"
			}]
		}
		$http.post('urlS', this, {
			code: '02020216',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					for (var i = 0; i < res.result.rows.length; i++) {
						res.result.rows[i].key = i;
					}
					this.setState({
						chemistryTableData: res.result.rows, chemistryTotal: res.result.total,
						chemistryRowId: '', chemistryRowData: {}, rightCardTitle: '新增化学通用名',
						loading: false
					});
				} else {
					this.setState({ loading: false })
				}
			},
			error: function () {
				this.setState({ loading: false })
			}
		})
	}

	// 获取处方通用名下拉框数据
	getPrescriptionSelectData = () => {
		let data = {
			params: [{}],
		}
		$http.post('urlS', this, {
			code: "02020218",
			data: data,
			success: function (res) {
				if (res.errorCode === '0') {
					this.setState({ prescriptionSelectData: res })
				}
			}
		});
	}

	// 获取处方通用名table数据
	getPrescriptionTableData = () => {
		this.setState({ loading: true });
		let { inputValue, prescriptionChemicDesc, prescriptionForm, prescriptionStatus, prescriptionPage, prescriptionPageSize, ChineseEnglishSize } = this.state;
		let data = {
			params: [{
				phCatID: '', // 化学通用名双击行数据
				generAlias: inputValue,
				chemicID: prescriptionChemicDesc,
				formID: prescriptionForm,
				statusID: prescriptionStatus,
			}],
			pagination: [{
				pageSize: prescriptionPageSize,
				currentPage: prescriptionPage,
				sort: "ID",
				dir: "desc"
			}]
		}
		$http.post('urlS', this, {
			code: '02020220',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					for (var i = 0; i < res.result.rows.length; i++) {
						res.result.rows[i].key = i
					}
					this.setState({
						prescriptionTableData: res.result.rows, prescriptionTotal: res.result.total,
						prescriptionRowId: "", prescriptionRowData: {}, rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddPGN ? ChineseEnglishSize.DrugMaintenanceaddPGN.descripts : '新增处方通用名',
						loading: false
					});
				} else {
					this.setState({ loading: false })
				}
			},
			error: function () {
				this.setState({ loading: false })
			}
		})
	}

	// 获取医嘱项下拉列表数据
	getMedicalOrderSelectData = () => {
		let data = {
			params: [{}],
		}
		$http.post('urlS', this, {
			code: "02020221",
			data: data,
			success: function (res) {
				if (res.errorCode === '0') {
					this.setState({ medicalOrderSelectData: res })
				}
			}
		});
	}

	medicalOrderItemRef = ref => {
		this.medicalOrderItemChild = ref
	}

	medicalOrderCompileRowData = (record, flag) => {
		this.medicalOrderItemChild.resetFieldsEditingKey();
		if (flag === 'compile') {
			this.setState({ medicalOrderItemRowId: record.medID, rightCardTitle: '编辑医嘱项', isSaveAnother: flag })
		} else {
			this.setState({ medicalOrderItemRowId: record.medID, rightCardTitle: '新增医嘱项', isSaveAnother: 'saveAnother' })
		}
	}

	// 获取医嘱项名table数据
	getMedicalOrderItemTableData = () => {
		this.setState({ loading: true });
		let { inputValue, medicalGenerID, medicalOrderStatus, medicalOrderItemPage, medicalOrderItemPageSize, medFormValue, ChineseEnglishSize, ordSubCatID } = this.state;
		let data = {
			params: [{
				generID: medicalGenerID, // doubleGenerData&&doubleGenerData.generID ? doubleGenerData.generID : ''
				medAlias: inputValue,
				formID: medFormValue,
				statusID: medicalOrderStatus,
				ordSubCatID,
			}],
			pagination: [{
				pageSize: medicalOrderItemPageSize,
				currentPage: medicalOrderItemPage,
				sort: "ID",
				dir: "desc"
			}]
		}
		$http.post('urlS', this, {
			code: '02020222',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					for (var i = 0; i < res.result.rows.length; i++) {
						res.result.rows[i].key = i
					}
					this.setState({
						medicalOrderItemTableData: res.result.rows, medicalOrderItemTotal: res.result.total,
						medicalOrderItemRowId: '',
						loading: false,
						isSaveAnother: 'compile',
						rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditOI ? ChineseEnglishSize.DrugMaintenanceeditOI.descripts : '新增医嘱项'
					});
					this.medicalOrderItemChild.handleNewlyAdded();
				} else {
					this.setState({ loading: false })
				}
			},
			error: function () {
				this.setState({ loading: false })
			}
		})
	}

	// 获取库存项下拉框数据
	getInventoryItemSelectData = () => {
		let data = {
			params: [{}],
		}
		$http.post('urlS', this, {
			code: "02020237",
			data: data,
			success: function (res) {
				if (res.errorCode === '0') {
					this.setState({ inventoryItemSelectData: res })
				}
			}
		});
	}

	inventoryItemRef = ref => {
		this.inventoryItemChild = ref;
	}

	inventoryItemCompile = (record, flag) => {
		this.inventoryItemChild.resetFieldsEditingKey();
		if (flag === 'compile') {
			this.setState({ inventoryItemRowId: record.stockID, rightCardTitle: '编辑库存项', isSaveAnotherInventoryItem: flag });
		} else {
			this.setState({ inventoryItemRowId: record.stockID, rightCardTitle: '新增库存项', isSaveAnotherInventoryItem: flag })
		}

	}

	// 获取库存项名table数据
	getInventoryItemTableData = () => {
		this.setState({ loading: true });
		let { inputValue, stkSubCatID, doubleMedData, inventoryItemPage, inventoryItemPageSize, medValue } = this.state;
		let data = {
			params: [{
				medID: doubleMedData && doubleMedData.medID ? doubleMedData.medID : medValue, // 医嘱项ID
				stockAlias: inputValue,
				stkSubCatID: stkSubCatID,
			}],
			pagination: [{
				pageSize: inventoryItemPageSize,
				currentPage: inventoryItemPage,
				sort: "ID",
				dir: "desc"
			}]
		}
		$http.post('urlS', this, {
			code: '02020233',
			data: data,
			success: function (res) {
				if (+res.errorCode === 0 && res.result) {
					for (var i = 0; i < res.result.rows.length; i++) {
						res.result.rows[i].key = i
					}
					this.setState({
						inventoryItemTableData: res.result.rows, inventoryItemTotal: res.result.total,
						inventoryItemRowId: '', loading: false,
						isSaveAnotherInventoryItem: 'compile'
					}, () => {
						this.inventoryItemChild.handleNewlyAdded()
					});
				} else {
					this.setState({ loading: false })
				}
			},
			error: function () {
				this.setState({ loading: false })
			}
		})
	}

	// 病区、病人行操作
	handleOnClickRowPublic = (record) => {
		let { ChineseEnglishSize } = this.state;
		return {
			// 单击行选中
			onClick: () => {
				if (this.state.activeTabPaneKey === '2') {
					this.childChemistry.resetFields(); // 重置化学通用名form表单
					if (this.state.chemistryRowId === '') {
						// 保存行数据以及ID
						this.setState({ chemistryRowId: record.chemicID, chemistryRowData: record, rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditCGN ? ChineseEnglishSize.DrugMaintenanceeditCGN.descripts : '编辑化学通用名' });
					} else {
						if (this.state.chemistryRowId !== record.chemicID) {
							this.setState({ chemistryRowId: record.chemicID, chemistryRowData: record, rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditCGN ? ChineseEnglishSize.DrugMaintenanceeditCGN.descripts : '编辑化学通用名' });
						} else {
							this.setState({ chemistryRowId: "", chemistryRowData: {}, rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddCGN ? ChineseEnglishSize.DrugMaintenanceaddCGN.descripts : '新增化学通用名' });
						}
					}
				} else if (this.state.activeTabPaneKey === '3') {
					this.childPrescription.resetFields(); // 重置处方通用名form表单
					if (this.state.prescriptionRowId === '') {
						// 保存行数据以及ID
						this.setState({ prescriptionRowId: record.generID, prescriptionRowData: record, rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditPGN ? ChineseEnglishSize.DrugMaintenanceeditPGN.descripts : '编辑处方通用名' });
					} else {
						if (this.state.prescriptionRowId !== record.generID) {
							this.setState({ prescriptionRowId: record.generID, prescriptionRowData: record, rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditPGN ? ChineseEnglishSize.DrugMaintenanceeditPGN.descripts : '编辑处方通用名' });
						} else {
							this.setState({ prescriptionRowId: "", prescriptionRowData: {}, rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddPGN ? ChineseEnglishSize.DrugMaintenanceaddPGN.descripts : '新增处方通用名' });
						}
					}
				}
			},
			onDoubleClick: () => {
				if (this.state.activeTabPaneKey === '2') {
					this.setState({ prescriptionChemicDesc: record.chemicID }, () => {
						this.toggleTabPane('3');
					});
				} else if (this.state.activeTabPaneKey === '3') {
					this.setState({ medicalGenerID: record.generID, medicalOrderItemTableData: [], medicalOrderItemTotal: 0, }, () => {
						this.toggleTabPane('4')
					});
				} else if (this.state.activeTabPaneKey === '4') {
					this.setState({ medValue: record.medDesc, doubleMedData: record, inventoryItemTableData: [], inventoryItemTotal: 0 }, () => {
						this.toggleTabPane('5');
					});
				}
			}
		}
	}

	handleSetRowClassNamePublic = (record) => {
		if (this.state.activeTabPaneKey === '2') { // 化学通用名
			return record.chemicID === this.state.chemistryRowId ? 'clickRowStyle' : '';
		} else if (this.state.activeTabPaneKey === '3') {// 处方通用名
			return record.generID === this.state.prescriptionRowId ? 'clickRowStyle' : '';
		} else if (this.state.activeTabPaneKey === '4') {// 医嘱项
			return record.medID === this.state.medicalOrderItemRowId ? 'clickRowStyle' : '';
		} else if (this.state.activeTabPaneKey === '5') {// 库存项
			return record.stockID === this.state.inventoryItemRowId ? 'clickRowStyle' : '';
		}
	}

	// 获取药理学分类数据
	getTreeData = () => {
		let { ChineseEnglishSize } = this.state;
		var params = {
			params: [{}],
		}
		$http.post('url', this, {
			code: "02020214",
			data: params,
			success: function (res) {
				if (+res.errorCode === 0) {
					this.setState({
						treeData: res.result,
						selectedKeys: [],
						phCatID: '',
						phCatCode: '',
						phCatDesc: '',
						treeRowData: {},
						phCatFlag: 'add',
						rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddPC ? ChineseEnglishSize.DrugMaintenanceaddPC.descripts : '新增药理学分类'
					}, () => {
						this.generateList(this.state.treeData);
					})
				}
			}
		});
	}

	//以下是Tree展开搜索
	dataList = [];
	generateList = (data) => {
		for (let i = 0; i < data.length; i++) {
			const node = data[i];
			const key = node.key;
			this.dataList.push({ key, title: node.title });
			if (node.children) {
				this.generateList(node.children);
			}
		}
	};

	onExpand = (expandedKeys) => {
		this.setState({
			expandedKeys,
			autoExpandParent: false,
		});
	}

	renderTreeNodes = data => data.map((item) => {
		const index = item.title.indexOf(this.state.inputValue);
		const beforeStr = item.title.substr(0, index);
		const afterStr = item.title.substr(index + this.state.inputValue.length);
		const title = index > -1 ? (
			<span>
				{beforeStr}
				<span style={{ color: '#FF7F00' }}>{this.state.inputValue}</span>
				{afterStr}
			</span>
		) : <span>{item.title}</span>;
		if (item.children) {
			return (
				<TreeNode title={title} key={item.key} dataRef={item}>
					{this.renderTreeNodes(item.children)}
				</TreeNode>
			);
		}
		return <TreeNode title={title} key={item.key} dataRef={item} />;
	})

	// 选中树结构数据
	selectTree = (selectedKeys, e) => {
		let { ChineseEnglishSize } = this.state;
		if (selectedKeys.length > 0) {
			this.setState({
				selectedKeys,
				phCatID: selectedKeys[0],
				phCatCode: e.selectedNodes[0].props.dataRef.code,
				phCatDesc: e.selectedNodes[0].props.dataRef.title,
			}, () => {
				this.PharmacologicalClassification('compile');
			})
		} else {
			this.setState({
				selectedKeys: [],
				phCatID: '',
				phCatCode: '',
				phCatDesc: '',
				treeRowData: {},
				phCatFlag: 'add',
				rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddPC ? ChineseEnglishSize.DrugMaintenanceaddPC.descripts : '新增药理学分类'
			})
		}
	}

	// 修改input框当中的值
	onChangeInput = (e) => {
		const CatDesc = e.target.value;
		const expandedKeys = this.dataList.map((item) => {
			if (CatDesc.length === 0) return null;
			if (item.title.indexOf(CatDesc) > -1) {
				return this.getParentKey(item.key, this.state.treeData);
			}
			return null;
		}).filter((item, i, self) => item && self.indexOf(item) === i);
		this.setState({
			expandedKeys,
			inputValue: CatDesc,
			autoExpandParent: true,
		});
	}

	getParentKey = (key, tree) => {
		let parentKey;
		for (let i = 0; i < tree.length; i++) {
			const node = tree[i];
			if (node.children) {
				if (node.children.some(item => item.key === key)) {
					parentKey = node.key;
				} else if (this.getParentKey(key, node.children)) {
					parentKey = this.getParentKey(key, node.children);
				}
			}
		}
		return parentKey;
	};

	// 新增
	PharmacologicalClassification = (flag) => {
		let { ChineseEnglishSize } = this.state
		this.childPhCat.resetFields();
		this.setState({ treeRowData: {}, phCatFlag: flag }, () => {
			let { phCatID, phCatCode, phCatDesc } = this.state;
			let obj = {
				phCatID,
				phCatCode,
				phCatDesc,
			}
			this.setState({ treeRowData: obj })
			if (this.state.phCatFlag === 'add') {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceaddPC ? ChineseEnglishSize.DrugMaintenanceaddPC.descripts : '新增药理学分类' })
			} else {
				this.setState({ rightCardTitle: ChineseEnglishSize.DrugMaintenanceeditPC ? ChineseEnglishSize.DrugMaintenanceeditPC.descripts : '编辑药理学分类' })
			}
		})

	}

	phCatOnRef = ref => { // 药理学分类
		this.childPhCat = ref;
	}

	chemistryOnRef = ref => { // 化学通用名
		this.childChemistry = ref;
	}

	prescriptionOnRef = ref => { // 处方通用名
		this.childPrescription = ref;
	}

	// 化学通用名
	handlePrescriptionChemicDesc = e => {
		this.setState({ prescriptionChemicDesc: e })
	}

	// 处方通用名
	handleGenerID = e => {
		this.setState({ generID: e })
	}

	// 剂型
	handlePrescriptionForm = e => {
		let { activeTabPaneKey } = this.state;
		activeTabPaneKey === '3' ? this.setState({ prescriptionForm: e }) : this.setState({ medFormValue: e })
	}

	// 处方通用名状态
	handlePrescriptionStatus = e => {
		this.setState({ prescriptionStatus: e })
	}

	// 医嘱项状态
	handleMedicalOrderStatus = e => {
		this.setState({ medicalOrderStatus: e })
	}

	// 医嘱子类
	handleOrdSubCatID = e => {
		this.setState({ ordSubCatID: e })
	}

	// 处方通用名
	handleMedicalMedicalGenerID = e => {
		this.setState({ medicalGenerID: e })
	}

	// 库存分类
	handleStkSubCatID = e => {
		this.setState({ stkSubCatID: e })
	}

	//医嘱项
	handleMedSearch = (value) => {
		this.fetchMed(value, medItemData => this.setState({ medItemData }));
	}

	fetchMed = (value, callback) => {
		value = value.replace(/^\s+/, "").replace(/\s+$/, "");
		if (value === "") {
			let data = [];
			callback(data);
			return;
		}
		if (timeout) {
			clearTimeout(timeout);
			timeout = null;
		}
		function fakeMed() {
			let data = {}
			data = {
				params: [{
					alias: value,
				}],
			}
			$http.post('urlS', this, {
				code: "02020070",
				data: data,
				success: function (res) {
					let data = [];
					if (res.errorCode === '0') {
						var j;
						for (j = 0; j < res.result.length; j++) {
							data.push({
								value: res.result[j].id,
								text: res.result[j].descripts,
							});
						}
						callback(data);
					}
				}
			})
		}
		timeout = setTimeout(fakeMed, 300);
	}

	handleMedValue = e => {
		if (!e) {
			this.setState({ doubleMedData: {} });
		}
		this.setState({ medValue: e })
	}

	//组件权限编辑器
	onColumnRef = (ref) => {
		this.columnRef = ref;
	}

	render() {
		let { activeTabPaneKey, chemistryColumns, prescriptionColumns, medicalOrderItemColumns, inventoryItemColumns, chemistryTableData, prescriptionTableData,
			medicalOrderItemTableData, inventoryItemTableData, chemistryTotal, prescriptionTotal, medicalOrderItemTotal, inventoryItemTotal, chemistryPage,
			prescriptionPage, medicalOrderItemPage, inventoryItemPage, expandedKeys, autoExpandParent, treeData, inputValue, rightCardTitle, treeRowData,
			phCatFlag, selectedKeys, chemistryRowId, chemistryRowData, prescriptionRowId, prescriptionRowData, prescriptionSelectData, prescriptionChemicDesc,
			prescriptionForm, prescriptionStatus, medicalOrderSelectData, medicalOrderStatus, medicalOrderItemRowId, inventoryItemSelectData, stkSubCatID,
			inventoryItemRowId, loading, medicalGenerID, medValue, medFormValue, isSaveAnother, isSaveAnotherInventoryItem, ChineseEnglishSize,
			medicalOrderItemTotalWidth, inventoryItemTotalWidth, ordSubCatID
		} = this.state;
		let columns = activeTabPaneKey === '2' ? (chemistryColumns && chemistryColumns.length > 0 ? chemistryColumns : this.chemistryColumns) :
			(activeTabPaneKey === '3' ? (prescriptionColumns && prescriptionColumns.length > 0 ? prescriptionColumns : this.prescriptionColumns) :
				(activeTabPaneKey === '4' ? (medicalOrderItemColumns && medicalOrderItemColumns.length > 0 ? medicalOrderItemColumns : this.medicalOrderItemColumns) :
					(inventoryItemColumns && inventoryItemColumns.length > 0 ? inventoryItemColumns : this.inventoryItemColumns)));
		let tableData = activeTabPaneKey === '2' ? chemistryTableData : (activeTabPaneKey === '3' ? prescriptionTableData : (activeTabPaneKey === '4' ? medicalOrderItemTableData : inventoryItemTableData));
		let total = activeTabPaneKey === '2' ? chemistryTotal : (activeTabPaneKey === '3' ? prescriptionTotal : (activeTabPaneKey === '4' ? medicalOrderItemTotal : inventoryItemTotal));
		let page = activeTabPaneKey === '2' ? chemistryPage : (activeTabPaneKey === '3' ? prescriptionPage : (activeTabPaneKey === '4' ? medicalOrderItemPage : inventoryItemPage));
		let tableWidth = activeTabPaneKey === '2' ? 400 : (activeTabPaneKey === '3' ? 400 : (activeTabPaneKey === '4' ? (medicalOrderItemColumns && medicalOrderItemColumns.length > 0 ? medicalOrderItemTotalWidth : 770) : (inventoryItemColumns && inventoryItemColumns.length > 0 ? inventoryItemTotalWidth : 1160)));
		let param = {
			// 表头配置
			columns,
			// 表格数据
			data: tableData,
			// 数据总条数
			total,
			// 当前页数
			page,
			// 表格的宽度
			x: tableWidth,
			y: store.getState().tableHeight.y - 15,
			height: store.getState().tableHeight.y + 30 + 'px',
			isOnRow: true,
			rowClassName: true,
			TableClassName: "common-table-height",
			loading: false,
			pageSize: "20"
		}

		// 化学通用名
		let chemicDescOption = prescriptionSelectData && prescriptionSelectData.chemistry && prescriptionSelectData.chemistry.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 剂型
		let formDescOption = prescriptionSelectData && prescriptionSelectData.form && prescriptionSelectData.form.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 处方通用名状态
		let prescriptionStatusOption = prescriptionSelectData && prescriptionSelectData.status && prescriptionSelectData.status.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 医嘱项状态
		let medicalOrderStatusOption = medicalOrderSelectData && medicalOrderSelectData.status && medicalOrderSelectData.status.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 医嘱子类
		let ordSubCatOption = medicalOrderSelectData && medicalOrderSelectData.ordSubCat && medicalOrderSelectData.ordSubCat.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 医嘱项剂型
		let medFormDescOption = medicalOrderSelectData && medicalOrderSelectData.form && medicalOrderSelectData.form.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 处方通用名
		let generIDOption = medicalOrderSelectData && medicalOrderSelectData.generic && medicalOrderSelectData.generic.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 库存分类
		let stkSubCatIDOption = inventoryItemSelectData && inventoryItemSelectData.stkSubCat && inventoryItemSelectData.stkSubCat.map((item, index) => {
			return (<Option key={index} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)
		})

		// 医嘱项
		let optionsMed = this.state.medItemData.map(d => <Option title={d.text} key={d.value}>{d.text}</Option>);

		let inputPlaceholder = activeTabPaneKey === '2' ? ChineseEnglishSize.DrugMaintenancechemicCommonName ? (ChineseEnglishSize.DrugMaintenancechemicCommonName.descripts + '···') : '化学通用名···' : (activeTabPaneKey === '3' ? ChineseEnglishSize.DrugMaintenancegenerID ? (ChineseEnglishSize.DrugMaintenancegenerID.descripts + '···') : '处方通用名···' : (activeTabPaneKey === '4' ? ChineseEnglishSize.DrugMaintenancemedID ? (ChineseEnglishSize.DrugMaintenancemedID.descripts + '···') : '医嘱项···' : (activeTabPaneKey === '5' ? ChineseEnglishSize.DrugMaintenanceinventoryItem ? (ChineseEnglishSize.DrugMaintenanceinventoryItem.descripts + '···') : '库存项···' : ChineseEnglishSize.DrugMaintenancepharmacologyClassification ? (ChineseEnglishSize.DrugMaintenancepharmacologyClassification.descripts + '···') : '药理学分类···')));
		let queryModule = (
			<div style={{ padding: '12px' }}>
				<Input placeholder={inputPlaceholder} value={inputValue} style={{ width: '150px' }} onChange={this.onChangeInput} onPressEnter={this.handleCommonQuery} />
				<Select value={prescriptionChemicDesc} onChange={this.handlePrescriptionChemicDesc} style={{ display: activeTabPaneKey === '3' ? 'inline-block' : 'none', margin: '0 6px', width: '150px' }} placeholder={ChineseEnglishSize.DrugMaintenancechemicCommonName ? ChineseEnglishSize.DrugMaintenancechemicCommonName.descripts : '化学通用名'} showSearch optionFilterProp="seatchprop" allowClear>
					{chemicDescOption}
				</Select>
				<Select value={medicalGenerID} onChange={this.handleMedicalMedicalGenerID} style={{ display: activeTabPaneKey === '4' ? 'inline-block' : 'none', marginLeft: '6px', width: '150px' }} placeholder={ChineseEnglishSize.DrugMaintenancegenerID ? ChineseEnglishSize.DrugMaintenancegenerID.descripts : '处方通用名'} showSearch optionFilterProp="seatchprop" allowClear>
					{generIDOption}
				</Select>
				<Select value={activeTabPaneKey === '3' ? prescriptionForm : medFormValue} onChange={this.handlePrescriptionForm} style={{ display: activeTabPaneKey === '4' ? 'inline-block' : 'none', width: '100px', marginLeft: '6px' }} placeholder={ChineseEnglishSize.DrugMaintenancedosageForm ? ChineseEnglishSize.DrugMaintenancedosageForm.descripts : '剂型'} showSearch optionFilterProp="seatchprop" allowClear>
					{activeTabPaneKey === '3' ? formDescOption : medFormDescOption}
				</Select>
				<Select value={prescriptionStatus} onChange={this.handlePrescriptionStatus} style={{ display: activeTabPaneKey === '3' ? 'inline-block' : 'none', marginLeft: '6px', width: '100px' }} placeholder={ChineseEnglishSize.DrugMaintenancestate ? ChineseEnglishSize.DrugMaintenancestate.descripts : '状态'} showSearch optionFilterProp="seatchprop" allowClear>
					{prescriptionStatusOption}
				</Select>
				<Select value={medicalOrderStatus} onChange={this.handleMedicalOrderStatus} style={{ display: activeTabPaneKey === '4' ? 'inline-block' : 'none', marginLeft: '6px', width: '100px' }} placeholder={ChineseEnglishSize.DrugMaintenancestate ? ChineseEnglishSize.DrugMaintenancestate.descripts : '状态'} showSearch optionFilterProp="seatchprop" allowClear>
					{medicalOrderStatusOption}
				</Select>
				<Select value={ordSubCatID} onChange={this.handleOrdSubCatID} style={{ display: activeTabPaneKey === '4' ? 'inline-block' : 'none', marginLeft: '6px', width: '150px' }} placeholder="医嘱子类" showSearch optionFilterProp="seatchprop" allowClear>
					{ordSubCatOption}
				</Select>
				<Select
					allowClear={true}
					showSearch
					style={{ display: activeTabPaneKey === '5' ? 'inline-block' : 'none', marginLeft: '6px', width: '150px' }}
					defaultActiveFirstOption={false}
					showArrow={false}
					filterOption={false}
					onSearch={this.handleMedSearch}
					notFoundContent={null}
					value={medValue}
					onChange={this.handleMedValue}
					placeholder={ChineseEnglishSize.DrugMaintenancesearchTips ? ChineseEnglishSize.DrugMaintenancesearchTips.descripts : '回车查询医嘱项信息'}
				>
					{optionsMed}
				</Select>
				<Select value={stkSubCatID} onChange={this.handleStkSubCatID} style={{ display: activeTabPaneKey === '5' ? 'inline-block' : 'none', marginLeft: '6px', width: '150px' }} placeholder={ChineseEnglishSize.DrugMaintenancestkSubCatID ? ChineseEnglishSize.DrugMaintenancestkSubCatID.descripts : '库存分类'} showSearch optionFilterProp="seatchprop" allowClear>
					{stkSubCatIDOption}
				</Select>
				<Button type="primary" style={{ display: activeTabPaneKey === '1' ? 'inline-block' : 'none', margin: '0 12px' }} onClick={() => this.PharmacologicalClassification('add')}>{ChineseEnglishSize.DrugMaintenanceadd ? ChineseEnglishSize.DrugMaintenanceadd.descripts : '新增'}</Button>
				<Button type="dashed" style={{ display: activeTabPaneKey === '1' ? 'inline-block' : 'none' }} onClick={() => this.PharmacologicalClassification('compile')} disabled={selectedKeys && selectedKeys.length > 0 ? false : true}>{ChineseEnglishSize.DrugMaintenancerevise ? ChineseEnglishSize.DrugMaintenancerevise.descripts : '修改'}</Button>
				<Button style={{ display: activeTabPaneKey !== '1' ? 'inline-block' : 'none', margin: '0 12px' }} onClick={this.handleCommonQuery}>{ChineseEnglishSize.DrugMaintenancesearch ? ChineseEnglishSize.DrugMaintenancesearch.descripts : '查询'}</Button>
				{/* <Button type="primary" style={{display: activeTabPaneKey === '2' ? 'inline-block' : 'none', marginRight: '12px'}}>关联药理学分类</Button> */}
				{/* <Button type="primary" style={{display: (activeTabPaneKey === '4' || activeTabPaneKey === '5') ? 'inline-block' : 'none', marginRight: '12px'}}>另存</Button> */}
			</div>
		);
		let TreeModule = (
			<Tree
				selectedKeys={selectedKeys}
				autoExpandParent={autoExpandParent}
				onExpand={this.onExpand}
				expandedKeys={expandedKeys}
				onSelect={this.selectTree}
			>
				{this.renderTreeNodes(treeData)}
			</Tree>
		);
		let tableModule = (
			<div style={{ padding: '0 12px' }}>
				<PubilcTablePagination
					param={param}
					handelThis={this}
					onRef={this.onPublicTableRef}
					onClickRowPublic={this.handleOnClickRowPublic}
					setRowClassNamePublic={this.handleSetRowClassNamePublic}
				/>
			</div>
		)
		return (
			<div className="drug-mainenance">
				<Row>
					<Col span={12}>
						<Card
							size="small"
							title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.DrugMaintenancedrugMaintenance ? ChineseEnglishSize.DrugMaintenancedrugMaintenance.descripts : '药品维护'}</div>}
						>
							<div style={{ height: store.getState().tableHeight.y + 203 + 'px' }}>
								<Tabs activeKey={activeTabPaneKey} onChange={this.toggleTabPane} className="drug-maintenance-tabs">
									{/* <TabPane tab={<span><Icon type="github" />{ChineseEnglishSize.DrugMaintenancepharmacologyClassification ? ChineseEnglishSize.DrugMaintenancepharmacologyClassification.descripts : '药理学分类'}</span>} key="1">
										<div>
											{queryModule}
										</div>
										<div style={{ height: store.getState().tableHeight.y + 102 + 'px', overflow: 'auto', borderTop: '1px solid #e8e8e8' }}>
											{TreeModule}
										</div>
									</TabPane>
									<TabPane tab={<span><Icon type="github" />{ChineseEnglishSize.DrugMaintenancechemicCommonName ? ChineseEnglishSize.DrugMaintenancechemicCommonName.descripts : '化学通用名'}</span>} key="2">
										<div>
											{queryModule}
										</div>
										<div>
											{tableModule}
										</div>
									</TabPane>
									<TabPane tab={<span><Icon type="github" />{ChineseEnglishSize.DrugMaintenanceprescriptionGenericName ? ChineseEnglishSize.DrugMaintenanceprescriptionGenericName.descripts : '处方通用名'}</span>} key="3">
										<div>
											{queryModule}
										</div>
										<div>
											{tableModule}
										</div>
									</TabPane> */}
									<TabPane tab={<span><Icon type="github" />{ChineseEnglishSize.DrugMaintenancemedID ? ChineseEnglishSize.DrugMaintenanceorderItem.descripts : '医嘱项'}</span>} key="4">
										<div>
											{queryModule}
										</div>
										<div>
											{tableModule}
										</div>
									</TabPane>
									<TabPane tab={<span><Icon type="github" />{ChineseEnglishSize.DrugMaintenanceinventoryItem ? ChineseEnglishSize.DrugMaintenanceinventoryItem.descripts : '库存项'}</span>} key="5">
										<div>
											{queryModule}
										</div>
										<div>
											{tableModule}
										</div>
									</TabPane>
								</Tabs>
							</div>
						</Card>
					</Col>
					<Col span={12}>
						<div style={{ paddingLeft: '6px', position: 'relative' }}>
							<Card
								size="small"
								title={<div className="card-title-left-icon"><div></div>{rightCardTitle}</div>}
							>
								<div style={{ height: store.getState().tableHeight.y + 203 + 'px', overflow: 'auto' }}>
									{activeTabPaneKey === '1' ? (
										<AddDrugInformation ChineseEnglishSize={this.state.ChineseEnglishSize} treeRowData={treeRowData} handleQuery={this.getTreeData} flag={phCatFlag} onRef={this.phCatOnRef} />
									) : activeTabPaneKey === '2' ? (
										<AddGeneralNameChemistry ChineseEnglishSize={this.state.ChineseEnglishSize} chemistryRowId={chemistryRowId} chemistryRowData={chemistryRowData} handleQuery={this.getChemistryTableData} onRef={this.chemistryOnRef} />
									) : activeTabPaneKey === '3' ? (
										<AddGeneralNamePrescription ChineseEnglishSize={this.state.ChineseEnglishSize} rowID={prescriptionRowId} rowData={prescriptionRowData} selectData={prescriptionSelectData} handleQuery={this.getPrescriptionTableData} onRef={this.prescriptionOnRef} />
									) : activeTabPaneKey === '4' ? (
										<AddDoctorAdvice ChineseEnglishSize={this.state.ChineseEnglishSize} onRef={this.medicalOrderItemRef} rowId={medicalOrderItemRowId} isSaveAnother={isSaveAnother} medicalOrderSelectData={medicalOrderSelectData} handleQuery={this.getMedicalOrderItemTableData} />
									) : (
										<AddInventoryItem ChineseEnglishSize={this.state.ChineseEnglishSize} onRef={this.inventoryItemRef} rowId={inventoryItemRowId} isSaveAnother={isSaveAnotherInventoryItem} inventoryItemSelectData={inventoryItemSelectData} handleQuery={this.getInventoryItemTableData} />
									)}
								</div>
							</Card>
							<div style={{ width: '6px', background: 'rgba(240, 242, 245, 1)', position: 'absolute', top: 0, left: 0, height: '100%' }}></div>
						</div>
					</Col>
				</Row>
				<ColumnAuthoritysModel
					clientWidth='800px'
					compontName={this.state.parameterCode}
					configType="C"
					onRef={this.onColumnRef}
					reloadData={() => {
						if (this.state.parameterCode == 'OrderList') {
							this.getMedicalOrderItemColumns()
						} else if (this.state.parameterCode == 'InventoryItemList') {
							this.getInventoryItemColumns()
						} else if (this.state.parameterCode == 'PrescriptionCommonNameList') {
							this.getPrescriptionColumns()
						} else if (this.state.parameterCode == 'ChemicalCommonName') {
							this.getChemistryColumns()
						}
					}
					}
				/>
			</div>
		)
	}
}