// 物资入库制单
import React from 'react';
import { Card, Row, Col, Form, DatePicker, Select, Switch, Input, Button, message, Popconfirm, Upload, Tooltip, Icon, Menu, Dropdown } from 'antd';
import { $http } from 'containers/config/https';
import { Util } from 'tools'
import Moment from 'moment';
import DetailEntryList from './component/DetailEntryList.jsx';
import InquireWarehouseVoucher from './component/InquireWarehouseVoucher.jsx';
import './style/index.less';
import * as XLSX from 'xlsx';
import AccordingToWarehouse from "./component/AccordingToWarehouse";
import AccordingToChecked from "./component/AccordingToChecked";
import { printInOp } from '../commonPrint/stkPrint';
import CrystalStorageModal from './component/CrystalStorageModal.jsx';

const { Option } = Select;
function isObjEqual(o1, o2) {
	var props1 = Object.getOwnPropertyNames(o1);
	var props2 = Object.getOwnPropertyNames(o2);
	if (props1.length != props2.length) {
		return false;
	}
	for (var i = 0, max = props1.length; i < max; i++) {
		var propName = props1[i];
		if (o1[propName] !== o2[propName]) {
			return false;
		}
	}
	return true;
}
const MaterialWarehouse = Form.create()(
	class extends React.Component {
		constructor() {
			super();
			this.state = {
				userInfo: {},
				SelectData: {}, // 下拉框数据
				detailInfo: [], // 明细列表数据
				rowId: '', // 入库单Id
				inOperLocID: "",
				completeStatus: 0, // 完成取消完成按钮操作状态
				stkCatID: '',
				ChineseEnglishSize: {},
				language: JSON.parse(window.sessionStorage.userData)
			};
			this.myRef1 = React.createRef();
			this.myRef2 = React.createRef();
			this.myRef3 = React.createRef();
			this.myRef4 = React.createRef();
			this.myRef5 = React.createRef();
			this.myRef6 = React.createRef();
			this.myRef7 = React.createRef();
			this.myRef8 = React.createRef();
			this.myRef9 = React.createRef();
		}

		componentDidMount() {
			// 初始化数据
			this.getSelectData();
			this.getInOperLocID();
			this.getInOperLocID();

		}

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

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

		detailOnRef = (ref) => {
			this.childDetail = ref;
		};

		// 获取下拉框的数据
		getSelectData() {
			let data = {
				params: []
			}
			$http.post('urlS', this, {
				code: "02060005",
				data: data,
				success: function (res) {
					if (+res.errorCode === 0) {
						this.setState({ SelectData: res.result[0] })
					} else {
						this.setState({ SelectData: {} })
					}
				}
			})
		}

		// 保存
		saveHandle = () => {
			let { language } = this.state;
			let stateID = this.props.form.getFieldValue('stateID');
			if (+stateID < 20 || !stateID) {
				if (this.childDetail.state.data.length < 1) {
					if (language.language == 'EN') {
						message.error("Detail list cannot be empty");
					} else {
						message.error("明细列表不能为空")
					}
				} else {

					// if (this.childDetail.state.stockID) {
					//     let newObj = this.childDetail.checkFormData();
					//     let beforeObj = this.childDetail.initialDataObj();
					//     if (!isObjEqual(newObj, beforeObj)) {
					//         message.error('有未保存的数据，请先保存');
					//         return
					//     }
					// }
					const { form: { validateFields } } = this.props;
					validateFields((errors, values) => {
						// 验证成功
						if (errors === null) {
							let data = {
								params: []
							}
							let child = {
								mianInfo: [],
								detailInfo: this.childDetail.state.data
							}
							let obj = JSON.parse(JSON.stringify(values));
							// 将开关的值转化
							obj.StartDate = Moment(obj.StartDate).format('YYYY-MM-DD');
							obj.adjCheque = Util.replaceTrueFalse(obj.adjCheque);
							obj.giftFlag = Util.replaceTrueFalse(obj.giftFlag);
							obj.inOperID = this.state.rowId ? this.state.rowId : undefined;
							obj.detailInfo = this.childDetail.state.data
							// child.mianInfo.push(obj);
							data.params.push(obj);
							$http.post('urlADS', this, {
								code: "02060006",
								data: data,
								success: function (res) {
									if (+res.errorCode === 0) {
										// 成功提示
										message.success(res.errorMessage);
										this.resetFieldsFrom()
										if (res.result[0]) {
											this.getEchoData(res.result[0].inOperID);
										}
									}
								}
							})
						}
					})
				}
			} else {
				if (language.language == 'EN') {
					message.error("Can be operated when the document status is saved or empty");
				} else {
					message.error("当单据状态为保存或者为空时才可以进行操作");
				}
			}

		}

		// 保存成功后根据返回回来的inOperID重新查找数据
		getEchoData = (id) => {
			// 重置表单
			this.props.form.resetFields(); //清空所有
			this.setState({ rowId: id }); // 将行id保存起来
			let data = {
				params: [
					{
						inOperID: id
					}
				]
			}
			$http.post('urlS', this, {
				code: "02060012",
				data: data,
				success: function (res) {
					if (+res.errorCode === 0) {
						for (let i = 0; i < res.detail.rows.length; i++) {
							res.detail.rows[i].key = i + "main";
						}
						this.setState({ userInfo: res.main, detailInfo: res.detail.rows, completeStatus: res.main.stateID });
					} else {
						this.setState({ userInfo: {}, detailInfo: [] });
					}
				}
			})
		}

		// //子组件依据订单保存后回调的方法的
		// childAccordingToData=(val)=>{
		//     this.setState({ userInfo: val.mainInfo[0], detailInfo:val.detailInfo });
		// }

		// 获取到入库科室的值
		getInOperLocID() {
			let inOperLocID = this.props.form.getFieldValue('inOperLocID');
			this.setState({ inOperLocID: inOperLocID });
		}

		// 点击查询显示弹框
		inquireHandle = () => {
			let { language } = this.state;
			// let inOperLocID = this.getInOperLocID();
			if (this.state.inOperLocID) {
				this.childModal.showModal(this.state.ChineseEnglishSize);
			} else {
				if (language.language == 'EN') {
					message.error("Please select the storage department first.");
				} else {
					message.info("请先选择入库科室");
				}
			}
		}

		// 重置明细录入
		resetFieldsFrom() {
			this.childDetail.resetFields();
		}

		// 重置所有内容
		resetFieldsAll() {
			this.props.form.resetFields(); //清空所有
			this.setState({ userInfo: {}, detailInfo: [], rowId: "", stkCatID: '', });
			this.childDetail.resetFields();
			this.childDetail.deleteData();
			this.childModal.handleUncheck();
		}

		// 重置表单
		resetFields = () => {
			this.resetFieldsAll()
		}

		// 完成
		setDocumentStatus(statusCode, flag) {
			let data = {
				params: [
					{
						inOperID: this.state.rowId,
					}
				]
			}
			$http.post('urlS', this, {
				code: "02060007",
				data: data,
				success: function (res) {
					if (+res.errorCode === 0) {
						message.success(res.errorMessage);
						this.getEchoData(res.result[0].inOperID);
						if (flag === 'complete') {
							this.setState({ completeStatus: 10 })
						} else if (flag === 'cancelComplete') {
							this.setState({ completeStatus: 20 })
						}
						// this.detailOnRef.deleteData(); // 保存成功后清空明细列表数据
						// this.setState({detailInfo: []})
					}
				}
			})
		}

		// 取消
		setOffStatus(statusCode, flag) {
			let data = {
				params: [
					{
						inOperID: this.state.rowId,
					}
				]
			}
			$http.post('urlS', this, {
				code: "02060008",
				data: data,
				success: function (res) {
					if (+res.errorCode === 0) {
						message.success(res.errorMessage);
						this.getEchoData(res.result[0].inOperID);
						if (flag === 'complete') {
							this.setState({ completeStatus: 10 })
						} else if (flag === 'cancelComplete') {
							this.setState({ completeStatus: 20 })
						}
						// this.detailOnRef.deleteData(); // 保存成功后清空明细列表数据
						// this.setState({detailInfo: []})
					}
				}
			})
		}

		// 完成
		handleComplete = () => {
			this.setDocumentStatus(20, 'complete');
		}

		// 取消完成
		handleCancelComplete = () => {
			this.setOffStatus(10, 'cancelComplete');
		}

		// 删除
		handleDelete = () => {
			let { language } = this.state;
			let stateID = this.props.form.getFieldValue('stateID');
			if (+stateID < 20) {
				let data = {
					params: [
						{
							inOperID: this.state.rowId,
						}
					]
				}
				$http.post('urlS', this, {
					code: "02060009",
					data: data,
					success: function (res) {
						if (+res.errorCode === 0) {
							message.success(res.errorMessage);
							this.resetFieldsAll();
						}
					}
				})
			} else {
				if (language.language == 'EN') {
					message.error("Can only be operated when the document status is saved");
				} else {
					message.error("当单据状态为保存时才可以进行操作");
				}
			}
		}

		// 导入
		beforeUpload = (file, fileList) => {
			let { language } = this.state;
			var rABS = true;
			const f = fileList[0];
			var reader = new FileReader();
			reader.onload = event => {
				try {
					const { result } = event.target;
					// 以二进制流方式读取得到整份excel表格对象
					const workbook = XLSX.read(result, { type: 'binary' });
					// 存储获取到的数据
					let data = [];
					// 遍历每张工作表进行读取（这里默认只读取第一张表）
					for (const sheet in workbook.Sheets) {
						// esline-disable-next-line
						if (workbook.Sheets.hasOwnProperty(sheet)) {
							// 利用 sheet_to_json 方法将 excel 转成 json 数据
							data = data.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet]));
							// break; // 如果只取第一张表，就取消注释这行
						}
					}
					// 最终获取到并且格式化后的 json 数据
					this.disposeImportData(data)
					// this.setState({excelData: data});
				} catch (e) {
					// 这里可以抛出文件类型错误不正确的相关提示
					if (language.language == 'EN') {
						message.error("The file type is incorrect!");
					} else {
						message.error('文件类型不正确！');
					}
				}
			};
			if (rABS) reader.readAsBinaryString(f); else reader.readAsArrayBuffer(f);
			return false;
		}

		// 处理导入的数据
		disposeImportData(data) {
			let { language } = this.state;
			let filterData = [];
			for (let i = 0; i < data.length; i++) {
				if (data[i].药品代码 && data[i].生产企业 && data[i].数量 && data[i].进价 && data[i].售价) {
					filterData.push(data[i])
				}
			}
			if (filterData.length > 0) {
				let excelData = filterData && filterData.map((item, index) => {
					return {
						stockCode: item.药品代码 ? item.药品代码 : '', // 药品代码
						stockDesc: item.药品名称 ? item.药品名称 : '', // 药品名称
						manfDesc: item.生产企业 ? item.生产企业 : '', // 生产企业
						batNo: item.批号 ? item.批号 : '', // 批号
						expDate: item.有效期 ? item.有效期 : '', // 有效期
						qty: item.数量 ? item.数量 : '', // 数量
						rp: item.进价 ? item.进价 : '', // 进价
						sp: item.售价 ? item.售价 : '', // 售价
						invNo: item.发票号 ? item.发票号 : '', // 发票号
						invDate: item.发票日期 ? item.发票日期 : '', // 发票日期
						qualityNo: item.质检单号 ? item.质检单号 : '', // 质检单号
						produceDate: item.生产日期 ? item.生产日期 : '', // 生产日期
						remark: item.备注 ? item.备注 : '', // 备注
						key: index + "import",
					}
				})
				this.setState({ detailInfo: excelData })
				for (var i = 0; i < excelData.length; i++) {
					excelData[i].stockCode && this.getStockID(excelData[i].stockCode);
					excelData[i].manfDesc && this.getmanfID(excelData[i].manfDesc)
				}
			} else {
				if (language.language == 'EN') {
					message.error("The content of the file is incorrect. The content must contain the drug code, manufacturer, quantity, purchase price, price, etc.");
				} else {
					message.error("文件内容有误，内容必须包含药品代码、生产企业、数量、进价、售价等列")
				}
			}
		}

		// 获取库存项id
		getStockID(stockCode) {
			let data = {
				params: [
					{
						stockCode: stockCode,
					}
				]
			}
			$http.post('urlS', this, {
				code: "02020064",
				data: data,
				success: function (res) {
					if (+res.errorCode === 0) {
						let detailInfo = [...this.state.detailInfo]
						for (let i = 0; i < detailInfo.length; i++) {
							if (detailInfo[i].stockCode === stockCode) {
								detailInfo[i].stockID = res.result[0].stockID
							}
						}
						this.setState({ detailInfo: detailInfo })
					}
				}
			})
		}

		// 获取生产企业id
		getmanfID(manfDesc) {
			let data = {
				params: [
					{
						manfDesc: manfDesc,
					}
				]
			}
			$http.post('urlS', this, {
				code: "02020065",
				data: data,
				success: function (res) {
					if (+res.errorCode === 0) {
						let detailInfo = [...this.state.detailInfo]
						for (let i = 0; i < detailInfo.length; i++) {
							if (detailInfo[i].manfDesc === manfDesc) {
								detailInfo[i].manfID = res.result[0].manfID
							}
						}
						this.setState({ detailInfo: detailInfo })
					}
				}
			})
		}

		// 下拉框选中事件
		handleOnSelect = (num) => {
			switch (num) {
				case 1:
					setTimeout(() => {
						this.myRef2.current.focus();
					}, 300)
					break;
				case 2:
					setTimeout(() => {
						this.myRef3.current.focus();
					}, 300)
					break;
				case 3:
					setTimeout(() => {
						this.myRef4.current.focus();
					}, 300)
					break;
				case 4:
					setTimeout(() => {
						this.myRef5.current.focus();
					}, 300)
					break;
				case 5:
					setTimeout(() => {
						this.myRef6.current.focus();
					}, 300)
					break;
				case 6:
					setTimeout(() => {
						this.myRef7.current.focus();
					}, 300)
					break;
				case 7:
					setTimeout(() => {
						this.myRef8.current.focus();
					}, 300)
					break;
				case 8:
					setTimeout(() => {
						this.myRef9.current.focus();
					}, 300)
					break;
				default:
					setTimeout(() => {
						this.myRef1.current.focus();
					}, 300)
			}
		};

		onWarehouseRef = (ref) => {
			this.childWarehouse = ref;
		};
		onCheckedRef = (ref) => {
			this.childChecked = ref;
		};
		//显示依据请求单弹窗
		warehouseRequest = () => {
			this.childWarehouse.showModal(this.state.ChineseEnglishSize);
		}
		//显示依据消耗弹框
		checkedVoucher = () => {
			this.childChecked.showModal(this.state.ChineseEnglishSize);
		}
		changeStkCat = (v) => {
			this.setState({ stkCatID: v, inOperLocID: this.props.form.getFieldValue('inOperLocID') })
		}
		changesDesc = (v) => {
			this.setState({ stkCatID: this.props.form.getFieldValue('stkCatID'), inOperLocID: v })
		}


		//页面中英文翻译
		getDetailTableColumns = (v) => {
			this.setState({ ChineseEnglishSize: v })
		};

		// 晶体扫码入库
		handleCrystalStorageRef = ref => {
			this.crystalStorageChild = ref;
		}

		// 打开晶体入库弹窗
		handleShowCrystalStorageModal = () => {
			this.crystalStorageChild.showModal();
		}

		// 明细列表导出
		exportTableData = () => {
			this.childDetail && this.childDetail.exportTableData && this.childDetail.exportTableData();
		}

		render() {
			const uploadprops = {
				// 这里我们只接受excel2007以后版本的文件，accept就是指定文件选择框的文件类型
				accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
				name: 'file',
				headers: {
					authorization: 'authorization-text',
				},
				showUploadList: false,
				// 把excel的处理放在beforeUpload事件，否则要把文件上传到通过action指定的地址去后台处理
				// 这里我们没有指定action地址，因为没有传到后台
				beforeUpload: this.beforeUpload
			};
			const formItemInput = {
				labelCol: {
					xs: { span: 9 },
					sm: { span: 10 },
					md: { span: 6 }
				},
				wrapperCol: {
					xs: { span: 15 },
					sm: { span: 14 },
					md: { span: 18 }
				},
			};
			const formItemSwitch = {
				labelCol: { span: 12 },
				wrapperCol: { span: 12 },
			};
			const { getFieldDecorator } = this.props.form;
			let userInfo = this.state.userInfo ? this.state.userInfo : {};
			let { ChineseEnglishSize, language } = this.state;
			let user = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
			let completeStatus = +this.state.completeStatus === 10 ? false : true;
			let cancelCompleteStatus = +this.state.completeStatus === 20 ? false : true;
			const menu = (
				<Menu>
					<Menu.Item>
						<a rel="noopener noreferrer" onClick={this.warehouseRequest} >
							{ChineseEnglishSize.MaterialStorageOrderMakingaccordingToOrders ? ChineseEnglishSize.MaterialStorageOrderMakingaccordingToOrders.descripts : '依据订单'}
						</a>
					</Menu.Item>
					<Menu.Item>
						<a rel="noopener noreferrer" onClick={this.checkedVoucher} >
							{ChineseEnglishSize.MaterialStorageOrderMakingauditedReceipts ? ChineseEnglishSize.MaterialStorageOrderMakingauditedReceipts.descripts : '已审核入库单'}
						</a>
					</Menu.Item>
					<Menu.Item>
						<a rel="noopener noreferrer" onClick={this.handleShowCrystalStorageModal}>
							晶体入库制单
						</a>
					</Menu.Item>
				</Menu>
			);
			return (
				<div className="warehouse-voucher">
					<Card
						size="small"
						title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.MaterialStorageOrderMakinginboundForm ? ChineseEnglishSize.MaterialStorageOrderMakinginboundForm.descripts : '入库制单'}</div>}
					// extra={<a href="#">More</a>}
					>
						<Row>
							<Col span={18} className="top-form">
								<Form>
									<Row>
										<Col span={8} style={{ paddingRight: '10px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakinginOperLocID ? ChineseEnglishSize.MaterialStorageOrderMakinginOperLocID.descripts : '入库科室：'} {...formItemInput}>
												{getFieldDecorator('inOperLocID', {
													initialValue: userInfo.inOperLocID ? userInfo.inOperLocID : user.locID,
													rules: [{ required: ChineseEnglishSize.MaterialStorageOrderMakinginOperLocID ? ChineseEnglishSize.MaterialStorageOrderMakinginOperLocID.required == 'Y' ? true : false : false, message: ChineseEnglishSize.MaterialStorageOrderMakinginOperLocID ? ChineseEnglishSize.MaterialStorageOrderMakinginOperLocID.message : '请选择入库科室' }]
												})(
													<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.MaterialStorageOrderMakinginOperLocIDTips ? ChineseEnglishSize.MaterialStorageOrderMakinginOperLocIDTips.descripts : '请选择入库科室'} ref={this.myRef1} onSelect={(v) => { this.handleOnSelect(1); this.changesDesc(v) }}>
														{this.state.SelectData.inOpLoc && this.state.SelectData.inOpLoc.map(item => {
															return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
														})}
													</Select>
												)}
											</Form.Item>
										</Col>
										<Col span={8} style={{ paddingRight: '10px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakingoperTypeID ? ChineseEnglishSize.MaterialStorageOrderMakingoperTypeID.descripts : '入库类型：'} {...formItemInput}>
												{getFieldDecorator('operTypeID', {
													initialValue: userInfo.operTypeID ? userInfo.operTypeID : '11',
													rules: [{ required: ChineseEnglishSize.MaterialStorageOrderMakingoperTypeID ? ChineseEnglishSize.MaterialStorageOrderMakingoperTypeID.required == 'Y' ? true : false : false, message: ChineseEnglishSize.MaterialStorageOrderMakingoperTypeID ? ChineseEnglishSize.MaterialStorageOrderMakingoperTypeID.message : '请选择入库类型' }]
												})(
													<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.MaterialStorageOrderMakingoperTypeIDTips ? ChineseEnglishSize.MaterialStorageOrderMakingoperTypeIDTips.descripts : '请选择入库类型'} ref={this.myRef2} onSelect={() => this.handleOnSelect(2)}>
														{this.state.SelectData.inOpType && this.state.SelectData.inOpType.map(item => {
															return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
														})}
													</Select>
												)}
											</Form.Item>
										</Col>
										<Col span={8} style={{ paddingRight: '30px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakingpurUserID ? ChineseEnglishSize.MaterialStorageOrderMakingpurUserID.descripts : '采购人员：'} {...formItemInput}>
												{getFieldDecorator('purUserID', {
													initialValue: userInfo.purUserID ? userInfo.purUserID : undefined,
												})(
													<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.MaterialStorageOrderMakingpurUserIDTips ? ChineseEnglishSize.MaterialStorageOrderMakingpurUserIDTips.descripts : '请选择采购人员'} ref={this.myRef3} onSelect={() => this.handleOnSelect(3)}>
														{this.state.SelectData.purPlanUser && this.state.SelectData.purPlanUser.map(item => {
															return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
														})}
													</Select>
												)}
											</Form.Item>
										</Col>
									</Row>
									<Row>
										<Col span={8} style={{ paddingRight: '10px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakingvendorID ? ChineseEnglishSize.MaterialStorageOrderMakingvendorID.descripts : '供应商：'} {...formItemInput}>
												{getFieldDecorator('vendorID', {
													initialValue: userInfo.vendorID ? userInfo.vendorID : undefined,
													rules: [{ required: ChineseEnglishSize.MaterialStorageOrderMakingvendorID ? ChineseEnglishSize.MaterialStorageOrderMakingvendorID.required == 'Y' ? true : false : false, message: ChineseEnglishSize.MaterialStorageOrderMakingvendorID ? ChineseEnglishSize.MaterialStorageOrderMakingvendorID.message : '请选择供应商' }]
												})(
													<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.MaterialStorageOrderMakingvendorIDTips ? ChineseEnglishSize.MaterialStorageOrderMakingvendorIDTips.descripts : '请选择供应商'} ref={this.myRef4} onSelect={() => this.handleOnSelect(4)}>
														{this.state.SelectData.vendor && this.state.SelectData.vendor.map(item => {
															return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
														})}
													</Select>
												)}
											</Form.Item>
										</Col>
										<Col span={8} style={{ paddingRight: '10px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakingcreateDate ? ChineseEnglishSize.MaterialStorageOrderMakingcreateDate.descripts : '入库日期：'} {...formItemInput}>
												{getFieldDecorator('createDate', {
													initialValue: userInfo.createDate ? Moment(userInfo.createDate, 'YYYY-MM-DD') : Moment(),
												})(
													<DatePicker style={{ width: '100%' }} format="YYYY-MM-DD" allowClear disabled />
												)}
											</Form.Item>
										</Col>
										<Col span={8} style={{ paddingRight: '30px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakingremark ? ChineseEnglishSize.MaterialStorageOrderMakingremark.descripts : '入库备注：'} {...formItemInput}>
												{getFieldDecorator('remark', {
													initialValue: userInfo.remark ? userInfo.remark : undefined,
												})(
													<Input placeholder={ChineseEnglishSize.MaterialStorageOrderMakingremark ? ChineseEnglishSize.MaterialStorageOrderMakingremark.message : '请输入入库备注'} ref={this.myRef5} onPressEnter={() => this.handleOnSelect(5)} />
												)}
											</Form.Item>
										</Col>
									</Row>
									<Row>
										<Col span={8} style={{ paddingRight: '10px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakingstkCatID ? ChineseEnglishSize.MaterialStorageOrderMakingstkCatID.descripts : '库存大类：'} {...formItemInput}>
												{getFieldDecorator('stkCatID', {
													initialValue: userInfo.stkCatID ? userInfo.stkCatID : undefined,
												})(
													<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.MaterialStorageOrderMakingstkCatIDTips ? ChineseEnglishSize.MaterialStorageOrderMakingstkCatIDTips.descripts : '请选择库存大类'} ref={this.myRef6} onSelect={(v) => { this.handleOnSelect(6); this.changeStkCat(v) }}>
														{this.state.SelectData.stkCat && this.state.SelectData.stkCat.map(item => {
															return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
														})}
													</Select>
												)}
											</Form.Item>
										</Col>
										<Col span={8} style={{ paddingRight: '10px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakinginOperNo ? ChineseEnglishSize.MaterialStorageOrderMakinginOperNo.descripts : '入库单号：'} {...formItemInput}>
												{getFieldDecorator('No', {
													initialValue: userInfo.No ? userInfo.No : undefined,
												})(
													<Input placeholder={ChineseEnglishSize.MaterialStorageOrderMakingNoTips ? ChineseEnglishSize.MaterialStorageOrderMakingNoTips.descripts : '保存成功后生成入库单号'} disabled />
												)}
											</Form.Item>
										</Col>
										<Col span={4}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakinggiftFlag ? ChineseEnglishSize.MaterialStorageOrderMakinggiftFlag.descripts : '赠送标志：'} {...formItemSwitch}>
												{getFieldDecorator('giftFlag', {
													valuePropName: 'checked',
													initialValue: userInfo.giftFlag === "Y" ? true : false,
												})(
													<Switch checkedChildren={ChineseEnglishSize.MaterialStorageOrderMakingY ? ChineseEnglishSize.MaterialStorageOrderMakingY.descripts : '是'}
														unCheckedChildren={ChineseEnglishSize.MaterialStorageOrderMakingN ? ChineseEnglishSize.MaterialStorageOrderMakingN.descripts : '否'} ref={this.myRef7} onChange={() => this.handleOnSelect(7)} />
												)}
											</Form.Item>
										</Col>
										<Col span={4}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakingadjCheque ? ChineseEnglishSize.MaterialStorageOrderMakingadjCheque.descripts : '调价换票：'} {...formItemSwitch}>
												{getFieldDecorator('adjCheque', {
													valuePropName: 'checked',
													initialValue: userInfo.adjCheque === "Y" ? true : false,
												})(
													<Switch checkedChildren={ChineseEnglishSize.MaterialStorageOrderMakingY ? ChineseEnglishSize.MaterialStorageOrderMakingY.descripts : '是'}
														unCheckedChildren={ChineseEnglishSize.MaterialStorageOrderMakingN ? ChineseEnglishSize.MaterialStorageOrderMakingN.descripts : '否'} ref={this.myRef9} onChange={() => this.handleOnSelect(9)} />
												)}
											</Form.Item>
										</Col>
									</Row>
									<Row>
										<Col span={8} style={{ paddingRight: '10px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakingtoLoc ? ChineseEnglishSize.MaterialStorageOrderMakingtoLoc.descripts : '请求科室：'} {...formItemInput}>
												{getFieldDecorator('reqLocID', {
													initialValue: userInfo.reqLocID ? userInfo.reqLocID : undefined,
												})(
													<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.StkCatMaintenancelist ? ChineseEnglishSize.StkCatMaintenancelist.descripts : '请选择请求科室'} ref={this.myRef8} onSelect={() => this.handleOnSelect(8)}>
														{this.state.SelectData.reqLoc && this.state.SelectData.reqLoc.map(item => {
															return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
														})}
													</Select>
												)}
											</Form.Item>
										</Col>
										<Col span={8} style={{ paddingRight: '10px' }}>
											<Form.Item label={ChineseEnglishSize.MaterialStorageOrderMakingstatus ? ChineseEnglishSize.MaterialStorageOrderMakingstatus.descripts : '单据状态：'} {...formItemInput}>
												{getFieldDecorator('stateID', {
													initialValue: userInfo.stateID ? userInfo.stateID : undefined,
												})(
													<Select showSearch optionFilterProp="seatchprop" allowClear placeholder={ChineseEnglishSize.MaterialStorageOrderMakingunsaved ? ChineseEnglishSize.MaterialStorageOrderMakingunsaved.descripts : '未保存'} disabled>
														{this.state.SelectData.inOpStatus && this.state.SelectData.inOpStatus.map(item => {
															return <Option key={item.id} value={item.id} title={item.descripts} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
														})}
													</Select>
												)}
											</Form.Item>
										</Col>
										<Col span={8} style={{ paddingLeft: '8%', marginTop: '3px' }}>
											<Dropdown overlay={menu} placement="bottomLeft">
												<Button>{ChineseEnglishSize.MaterialStorageOrderMakinginboundAuxliary ? ChineseEnglishSize.MaterialStorageOrderMakinginboundAuxliary.descripts : '入库辅助制单'}</Button>
											</Dropdown>
										</Col>
									</Row>
								</Form>
							</Col>
							<Col span={6}>
								<Row style={{ marginBottom: '18px' }}>
									<Button style={{ marginRight: '30px' }} onClick={this.inquireHandle}>{ChineseEnglishSize.MaterialStorageOrderMakingsearch ? ChineseEnglishSize.MaterialStorageOrderMakingsearch.descripts : '查询'}</Button>
									<Popconfirm title={ChineseEnglishSize.MaterialStorageOrderMakingresetTips ? ChineseEnglishSize.MaterialStorageOrderMakingresetTips.descripts : '重置后将初始化数据，你确定要重置吗?'} onConfirm={this.resetFields}
										okText={language.language == 'EN' ? "Yes" : '是'} cancelText={language.language == 'EN' ? "No" : '否'}
									>
										<Button>{ChineseEnglishSize.MaterialStorageOrderMakingReset ? ChineseEnglishSize.MaterialStorageOrderMakingReset.descripts : '重置'}</Button>
									</Popconfirm>
								</Row>
								<Row style={{ marginBottom: '18px' }}>
									<Button type="primary" style={{ marginRight: '30px' }} onClick={this.saveHandle}>{ChineseEnglishSize.MaterialStorageOrderMakingsave ? ChineseEnglishSize.MaterialStorageOrderMakingsave.descripts : '保存'}</Button>
									<Popconfirm title={ChineseEnglishSize.MaterialStorageOrderMakingdeleteTips ? ChineseEnglishSize.MaterialStorageOrderMakingdeleteTips.descripts : '删除不可恢复，你确定要删除吗?'} onConfirm={this.handleDelete}
										okText={language.language == 'EN' ? "Yes" : '是'} cancelText={language.language == 'EN' ? "No" : '否'}
									>
										<Button type="danger">{ChineseEnglishSize.MaterialStorageOrderMakingdelete ? ChineseEnglishSize.MaterialStorageOrderMakingdelete.descripts : '删除'}</Button>
									</Popconfirm>
								</Row>
								<Row style={{ marginBottom: '18px' }}>
									<Button type="primary" style={{ marginRight: '30px' }}
										onClick={this.handleComplete}
										disabled={!this.state.rowId || completeStatus}>{ChineseEnglishSize.MaterialStorageOrderMakingaccomplish ? ChineseEnglishSize.MaterialStorageOrderMakingaccomplish.descripts : '完成'}</Button>
									<Button type="danger"
										onClick={this.handleCancelComplete}
										disabled={!this.state.rowId || cancelCompleteStatus}>{ChineseEnglishSize.MaterialStorageOrderMakingcancelComplete ? ChineseEnglishSize.MaterialStorageOrderMakingcancelComplete.descripts : '取消完成'}</Button>
								</Row>
								<Row style={{ marginBottom: '18px' }}>
									<Button type="dashed" style={{ marginRight: '30px' }} onClick={printInOp.bind(this, this.state.rowId)}>{ChineseEnglishSize.MaterialStorageOrderMakingprint ? ChineseEnglishSize.MaterialStorageOrderMakingprint.descripts : '打印'}</Button>
									<Upload {...uploadprops}>
										<Tooltip title={ChineseEnglishSize.MaterialStorageOrderMakingimportTips ? ChineseEnglishSize.MaterialStorageOrderMakingimportTips.descripts : '导入excel文件'}>
											<Button type="dashed" style={{ marginRight: '30px' }} >
												<Icon type="import" />{ChineseEnglishSize.MaterialStorageOrderMakingimport ? ChineseEnglishSize.MaterialStorageOrderMakingimport.descripts : '导入'}
											</Button>
										</Tooltip>
									</Upload>
									<Button
										type="dashed"
										onClick={this.exportTableData}
									><Icon type="export" />导出</Button>
								</Row>
							</Col>
						</Row>
					</Card>
					<DetailEntryList SelectData={this.state.SelectData} onRef={this.detailOnRef} mainInfo={this.state.userInfo} detailInfo={this.state.detailInfo} handleThis={this} inOperLocID={this.state.inOperLocID} stkCatID={this.state.stkCatID} />
					<InquireWarehouseVoucher SelectData={this.state.SelectData} onRef={this.onRef} inOperLocID={this.state.inOperLocID} handleThis={this} />
					<AccordingToWarehouse onRef={this.onWarehouseRef} handleThis={this} />
					<AccordingToChecked onRef={this.onCheckedRef} handleThis={this} />
					<CrystalStorageModal onRef={this.handleCrystalStorageRef} getEchoData={this.getEchoData} />
				</div>
			)
		}
	}
);
export default MaterialWarehouse;