// 物资台账查询
import React from 'react';
import { Card, Row, Col, Form, DatePicker, Select, Button, Modal, Table, Switch, message, Pagination, Input, Checkbox, Icon } from 'antd';
import { $http } from 'containers/config/https';
import Moment from 'moment';
import store from 'store';
import PublicModalTable from "../../common/PublicModalTable";
import { handleExcel } from 'tools/handleExcel.js';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import CommonPagination from 'components/pagination/index';
import './style/index.less'
var standingNumber = 0; //入库单序列号

const { Option } = Select;
const FormItem = Form.Item;
const formItemLayout = {    // label 和input宽度
    labelCol: { span:7 },
    wrapperCol: { span: 17 },
};
const formItemSwitch = {    // label 和input宽度
    labelCol: { span:15 },
    wrapperCol: { span: 8 },
};
const StandingBookQuery = Form.create()(
    class extends React.Component {
        constructor() {
            super();
            this.state = {
                userInfo: JSON.parse(window.sessionStorage.userData),
                data: [],
                queryCondition: {},
                SelectData: {},
                inOpLocDr:'',
                vendor: '',
                detailsId: '',//入库单ID
                detailsListData:[], //入库单明细数据
                WaListData: [], //入库单数据
                pageSize: 10,
                page: 1,
                pageSize2: 10,
                page2: 1,
                total:0,
                modalData: [], // 弹框列表数据
                visible: false,
                CheckboxNumber: 0,
                detailTotal: 0,
                checkMainValue: false,
                checkDetailValue: false,
                show: false,
                modalColumns: [], //表头数据
                detailWidthTotal: '',
                detailWidthTotal2: '',
                columns: [],
                StandingBookQueryListCode: '', // 表头弹窗识别code
                ChineseEnglishSize:{}
            };

            //回车显示的弹窗表头
            this.modalColumns2 = [
                {
                    key: 1,
                    title: this.state.userInfo.language == 'EN'?'Inventory item code':'库存项代码',
                    dataIndex: 'stockCode',
                    align: "center",
                    width: '22%'
                },
                {
                    key: 2,
                    title: this.state.userInfo.language == 'EN'?'Inventory item description':'库存项描述',
                    dataIndex: 'stockDesc',
                    align: "center",
                    width: '24%',
                },
                {
                    key: 5,
                    title: this.state.userInfo.language == 'EN'?'Inventory classification':'库存分类',
                    dataIndex: 'stkSubCatDesc',
                    align: "center",
                    width: '16%',
                },
                {
                    key: 3,
                    title: this.state.userInfo.language == 'EN'?'Packing specification':'包装规格',
                    dataIndex: 'stockSpec',
                    align: "center",
                    width: '12%',
                },
                {
                    key: 6,
                    title: this.state.userInfo.language == 'EN'?'Basic unit':'基本单位',
                    dataIndex: 'baseUnitDesc',
                    align: "center",
                    width: '12%',
                },
                {
                    key: 7,
                    title: this.state.userInfo.language == 'EN'?'Storage unit':'入库单位',
                    dataIndex: 'purUnitDesc',
                    align: "center",
                }
            ];
            // 药品的数据表头
            this.columns = [
                {
                    key: 1,
                    title: '药品名称',
                    dataIndex: 'stockDesc',
                    align: "center",
                    width: '13%'
                },
                {
                    key: 2,
                    title: '入库单位',
                    dataIndex: 'purUnitDesc',
                    align: "center",
                    width: '7%'
                },
                {
                    key: 3,
                    title: '增加数量',
                    dataIndex: 'plusQty',
                    align: "center",
                    width: '6%'
                },
                {
                    key: 4,
                    title: '减少数量',
                    dataIndex: 'minusQty',
                    align: "center",
                    width: '6%'
                },
                {
                    key: 5,
                    title: '基本单位',
                    dataIndex: 'baseUnitDesc',
                    align: "center",
                    width: '6%'
                },

                {
                    key: 6,
                    title: '期始数量(基本)',
                    dataIndex: 'begBaseQty',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 13,
                    title: '期始数量(入库)',
                    dataIndex: 'begPurQty',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 7,
                    title: '期初金额(进价)',
                    dataIndex: 'begRpAmt',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 8,
                    title: '期初金额(售价)',
                    dataIndex: 'begSpAmt',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 9,
                    title: '期末数量(基本)',
                    dataIndex: 'endBaseQty',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 14,
                    title: '期末数量(入库)',
                    dataIndex: 'endPurQty',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 10,
                    title: '期末金额(进价)',
                    dataIndex: 'endRpAmt',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 11,
                    title: '期末金额(售价)',
                    dataIndex: 'endSpAmt',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 12,
                    title: '库存子类',
                    dataIndex: 'stkSubCatDesc',
                    align: "center",
                    width: '6%'
                }
            ];
            // 入库单详细表头
            this.modalColumns = [
                {
                    key: 1,
                    title: '日期时间',
                    dataIndex: 'dateTime',
                    align: "center",
                    width: '6%'
                },
                {
                    key: 2,
                    title: '批号效期',
                    dataIndex: 'expDate',
                    align: "center",
                    width: '6%'
                },
                {
                    key: 3,
                    title: '单位',
                    dataIndex: 'unitDesc',
                    align: "center",
                    width: '5%'
                },
                {
                    key: 4,
                    title: '售价',
                    dataIndex: 'sp',
                    align: "center",
                    width: '5%'
                },
                {
                    key: 5,
                    title: '进价',
                    dataIndex: 'rp',
                    align: "center",
                    width: '5%'
                },
                {
                    key: 6,
                    title: '结余数量',
                    dataIndex: 'endQtyUnit',
                    align: "center",
                    width: '5%'
                },
                {
                    key: 7,
                    title: '数量',
                    dataIndex: 'qty',
                    align: "center",
                    width: '4%'
                },
                {
                    key: 8,
                    title: '进价金额',
                    dataIndex: 'rpAmt',
                    align: "center",
                    width: '5%'
                },
                {
                    key: 9,
                    title: '售价金额',
                    dataIndex: 'spAmt',
                    align: "center",
                    width: '5%'
                },
                {
                    key: 10,
                    title: '处理号',
                    dataIndex: 'intrNo',
                    align: "center",
                    width: '9%',
                    className: 'intrNo'
                },
                {
                    key: 11,
                    title: '处理信息',
                    dataIndex: 'msg',
                    align: "center",
                    width: '6%'
                },
                {
                    key: 12,
                    title: '业务类型',
                    dataIndex: 'type',
                    align: "center",
                    width: '5%'
                },
                {
                    key: 13,
                    title: '结余金额(进价)',
                    dataIndex: 'endRpAmt',
                    align: "center",
                    width: '7%'
                },
                {
                    key: 14,
                    title: '结余金额(售价)',
                    dataIndex: 'endSpAmt',
                    align: "center",
                    width: '7%'
                },
                {
                    key: 15,
                    title: '供应商',
                    dataIndex: 'vendorDesc',
                    align: "center",
                    width: '7%'
                },
                {
                    key: 16,
                    title: '厂家',
                    dataIndex: 'manfDesc',
                    align: "center",
                    width: '7%'
                },
                {
                    key: 17,
                    title: '制作人',
                    dataIndex: 'userName',
                    align: "center",
                    width: '6%'
                }
            ]
        }

        componentDidMount() {
            // 初始化数据
            this.getTacitlyApproveData();
            this.getDetailTableColumns();
            this.getDetailTableColumns2();
            let dom = document.querySelectorAll('.waListHeight  .ant-table-body');
            dom[0].style.height = store.getState().tableHeight.y - 65 + 'px';
            let detailsHeight = document.querySelectorAll('.detailsHeight  .ant-table-body');
            detailsHeight[0].style.height = store.getState().tableHeight.y - 65 + 'px';
        }

        //清空表格内容
        handleReset = () => {
            this.setState({WaListData: [],detailsListData: [],total: 0, detailsId: ''});
            this.props.form.setFieldsValue({stockDr: undefined});
            this.props.form.resetFields();
        };

        // 获取界面默认值
        getTacitlyApproveData() {
            let data = {
                params: []
            };
            // 获取起止时间和是否审核
            // $http.post('urlS', this, {
            //     code: "02060110",
            //     data: data,
            //     success: function (res) {
            //         if (+res.errorCode === 0) {
            //             this.setState({queryCondition: res.result[0]})
            //         }
            //     }
            // });
            // 获取下拉数据 
            $http.post('urlS', this, {
                code: "02060110",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({SelectData: res.result[0]})
                    }
                }
            })
        }

        // 获取药品列表数据
        getWarehouseList=()=>{
            let {ChineseEnglishSize} = this.state;
            this.setState({ loading:true});
            let qLocDr = this.props.form.getFieldValue('locDr');
            let qStockDr = this.props.form.getFieldValue('stockDr');
            let qStkSubCatDr = this.props.form.getFieldValue('stkSubCatDr');
            let qStkCatDr = this.props.form.getFieldValue('stkCatDr');
            let qPoisonDr = this.props.form.getFieldValue('poisonDr');
            let qConsumeTypeDr = this.props.form.getFieldValue('consumeTypeDr');
            let EndData = this.props.form.getFieldValue('EndData');
            let StartDate = this.props.form.getFieldValue('StartDate');
            let data = {
                params: [{
                    startDate: Moment(StartDate).format('YYYY-MM-DD'),
                    endDate: Moment(EndData).format('YYYY-MM-DD'),
                    locID:qLocDr ? qLocDr : '',
                    stockID:this.state.ModalRowData ? (qStockDr ? this.state.ModalRowData.stockID: '') : '',
                    stkSubCatID:qStkSubCatDr ? qStkSubCatDr : '',
                    stkCatID:qStkCatDr ? qStkCatDr : '',
                    poisonID:qPoisonDr ? qPoisonDr : '',
                    consumeTypeID:qConsumeTypeDr ? qConsumeTypeDr : 0,

                }],
                pagination: [
                    {
                        pageSize:this.state.pageSize,
                        currentPage:this.state.page,
                        sort:"ID",
                        dir:"asc",
                    }
                ],
            };
            console.log("data",data);
            $http.post('urlS', this, {
                code: "02060111",
                data: data,
                success: function (res) {
                    if(res.result.rows.length > 0){
                        for(var i = 0; i < res.result.rows.length; i++){
                            res.result.rows[i].key = i;
                        }
                        this.setState({ WaListData: res.result.rows,total: res.result.total,page2: 1, detailsId:  res.result.rows[0].stkLocID, loading: false});
                        standingNumber = 0;
                        this.getWarehouseEntryDetails(res.result.rows[0].stkLocID)
                    }else {
                        this.setState({WaListData: [], detailsListData: []});
                        message.error(ChineseEnglishSize.MaterialAccountInquirynoData ? ChineseEnglishSize.MaterialAccountInquirynoData.descripts:"没数据")
                    }
                },
                error: function (err) {
                    message.error(err.errorMessage)
                }
            });
        };
        // 获取详情列表
        getWarehouseEntryDetails(id) {
            this.setState({detailsLoading: true})
            let approve = this.props.form.getFieldValue('approve');
            let qBusTypeDr = this.props.form.getFieldValue('busTypeDr');
            let EndData = this.props.form.getFieldValue('EndData');
            let StartDate = this.props.form.getFieldValue('StartDate');
            let data = {
                params: [{
                    stkLocID:id?id:this.state.detailsId,
                    startDate: Moment(StartDate).format('YYYY-MM-DD'),
                    endDate: Moment(EndData).format('YYYY-MM-DD'),
                    busTypeID:qBusTypeDr,
                    busLossFlag:approve ? "Y" : "N",
                }],
                pagination: [
                    {
                        pageSize:this.state.pageSize2,
                        currentPage: this.state.page2 ,
                        sort:"ID",
                        dir:"asc",
                    }
                ]
            };
            $http.post('urlS', this, {
                code: "02060112",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        for(let i = 0; i < res.result.rows.length; i++){
                            res.result.rows[i].key = i;
                        }
                        this.setState({detailsListData:res.result.rows, detailTotal: res.result.total, detailsLoading: false });
                    }
                }
            })
        }

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

        // 双击选中行数据的回调
        confirmSelection = (record) => {
            this.setState({ModalRowData: record}, () => {
                // 关闭弹窗
                this.child.handleCancel();
                // 获取单位下拉框数据
                this.props.form.setFieldsValue({stockDr: record.stockDesc});
            })
        };

        //点击行，渲染当前行样式
        setRowClassName = (record) => {
            standingNumber = standingNumber + 1;
            if(record){
                if(this.state.detailsId == record.stkLocID) return 'clickRowStyle';
                else if (standingNumber == 1) return 'clickRowStyle';
                else return '';
                // return this.state.detailsId == record.inOperateID ? 'clickRowStyle ': '';
            }else {
                return '';
            }
        };

        // 页码改变的回调，参数是改变后的页码及每页条数
        onChange = (page, pageSize) => {
            this.setState({page: page, pageSize: this.state.pageSize}, () => {
                // 重新调用查询方法
                this.getWarehouseList();
            });
        };
        // 显示分页总条数
        showTotal(total) {
            return `共 ${total} 条`;
        }
        onShowSizeChange = (current, size) => {
            this.setState({page: current, pageSize: size}, () => {
                // 重新调用查询方法
                this.onChange(current,size);
            })
        };

        // 页码改变的回调，参数是改变后的页码及每页条数 入库单详情
        onChange2 = (page, pageSize) => {
            this.setState({page2: page, pageSize2: this.state.pageSize2}, () => {
                // 重新调用查询方法
                this.getWarehouseEntryDetails(this.state.detailsId);
            });
        };

        onShowSizeChange2 = (current, size) => {
            this.setState({page2: current, pageSize2: size}, () => {
                // 重新调用查询方法
                this.onChange2(current,size);
            })
        };

        // 获取焦点的方法--描述
        stockDescOnFocus = () => {
            let {ChineseEnglishSize} = this.state;
            let inOpLocDr = this.getInOpLocDr();
            if (!inOpLocDr) {
                message.info(ChineseEnglishSize.MaterialAccountInquiryselectTheStorageDeptFirst ? ChineseEnglishSize.MaterialAccountInquiryselectTheStorageDeptFirst.descripts:"请先选择入库科室");
            }
        };
        // 描述回车事件
        stockDescOnPressEnter = (e) => {
            let {ChineseEnglishSize} = this.state;
            let inOpLocDr = this.getInOpLocDr();
            if (inOpLocDr) {
                let top = document.getElementById('stock-desc').getBoundingClientRect().top + 40 + 'px';
                let left = document.getElementById('stock-desc').getBoundingClientRect().left + 100 + 'px';
                this.setState({
                    top: top,
                    left: left
                });
                this.getModalListData(e.target.value);
                this.child.showModal();
            } else {
                message.info(ChineseEnglishSize.MaterialAccountInquiryselectTheStorageDeptFirst ? ChineseEnglishSize.MaterialAccountInquiryselectTheStorageDeptFirst.descripts:"请先选择科室");
            }
        };

        // 当描述失去焦点的时候
        stastockDescOnBlure = (e) => {

            if (this.state.ModalRowData && (e.target.value !== this.state.ModalRowData.stockDesc)) {
                this.props.form.setFieldsValue({stockDesc: undefined});
            }
        };

        // 获取描述列表数据
        getModalListData(alias) {
            let data = {
                params: [
                    {
                        locID: this.props.form.getFieldValue('locDr'),
                        stkCatID: this.props.form.getFieldValue('stkCatDr'),
                        stkSubCatID: this.props.form.getFieldValue('stkSubCatDr'),
                        alias: alias, // 库存项描述别名
                    }
                ]
            };
            $http.post('urlS', this, {
                code: "02060194",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        for(var i = 0; i < res.result.length; i++) {
                            res.result[i].key = i
                        }
                        this.setState({ modalData: res.result})
                    } else {
                        this.setState({ modalData: [] })
                    }
                }
            })
        };

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

        // 操作弹框
        onClickRowPublic = (record) => {
            return {
                onDoubleClick: () => {
                    this.confirmSelection(record);
                }
            }
        };

        //显示下载选择弹窗
        showTableExcel=()=>{
            this.setState({
                visible: true,
            });
        };

        // 取消弹窗
        hiddenTableExcel = () => {
            this.setState({
                visible: false,
            });
        };

// 导出库存信息表
        exportInventoryInformation() {
            let {columns,ChineseEnglishSize} = this.state;
            if(this.state.WaListData.length > 0){
                handleExcel.exportExcel(columns, this.state.WaListData, ChineseEnglishSize.MaterialAccountInquirydrugNameInfo ? ChineseEnglishSize.MaterialAccountInquirydrugNameInfo.descripts:'药名信息表')
            }else {
                message.error(ChineseEnglishSize.MaterialAccountInquirydrugNameInfo ? ChineseEnglishSize.MaterialAccountInquirydrugNameInfo.message:'药名信息表不能为空');
            }
        }



        // 导出批次信息表
        exportBatchInformation() {
            let {modalColumns,ChineseEnglishSize} = this.state;
            if(this.state.detailsListData.length > 0){
                handleExcel.exportExcel(modalColumns, this.state.detailsListData, ChineseEnglishSize.MaterialAccountInquirydrugNameDetailInfo ? ChineseEnglishSize.MaterialAccountInquirydrugNameDetailInfo.descripts:'药名详情信息表')
            }else {
                message.error(ChineseEnglishSize.MaterialAccountInquirydrugNameDetailInfo ? ChineseEnglishSize.MaterialAccountInquirydrugNameDetailInfo.message:'药名详情信息表不能为空');
            }

        }

        //确定导出数据 excel
        TableToExcel = () => {

            let {checkMainValue, checkDetailValue} = this.state;
            if (checkMainValue && checkDetailValue) {// 同时导出两张表
                this.exportInventoryInformation();
                this.exportBatchInformation();
            } else if (checkMainValue) {// 导出库存信息表
                this.exportInventoryInformation()
            } else if (checkDetailValue) {// 导出批次信息表
                this.exportBatchInformation()
            }
        };

        // 操作库存信息Checkbox
        checkedMain = (e) => {
            this.setState({checkMainValue: e.target.checked})
        };

        // 操作批次信息Checkbox
        checkedDetails = (e) => {
            this.setState({checkDetailValue: e.target.checked})
        };
        // 收起明细录入
        packUpHandle = () => {
            this.setState({show: !this.state.show, span: 24})
        };
        // 获取明系列表头数据
        getDetailTableColumns = () => {
            let {userInfo} = this.state;
            let data = {
                params: [{
                    compontName: 'materialSBQueryList',
                    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({StandingBookQueryListCode: 'materialSBQueryList'},()=>{
                                    this.columnRef.onOpenModel();
                                })}}>{userInfo.language== 'EN' ? item.enDescripts : item.title}</div>
                            }
                        }) : '';
                        let filterArr = arr.filter(function(item){ return item.display === 'Y'});
                      //   let obj =  {
                      //       title: '操作',
                      //       key: 13,
                      //       fixed: 'right',
                      //       align: "center",
                      //       width: '100px',
                      //       render: (text, record) => (
                      //           <span>
                      //   <Popconfirm title="删除不可恢复，你确定要删除吗?" onCancel={this.handlePopconfirm} onConfirm={(e) => this.handleDelete(record, e)} onClick={this.handlePopconfirm} >
                      //       <span className='span' style={{color: 'rgba(240,65,52,1)'}}>删除</span>
                      //   </Popconfirm>
                      // </span>
                      //       ),
                      //   };
                      //   filterArr.push(obj);
                        this.setState({modalColumns: filterArr, detailWidthTotal: res.totalWidth})
                    }
                }
            });
        };
        getDetailTableColumns2 = () => {
            let {userInfo} = this.state;
            let data = {
                params: [{
                    reactCode: ['MaterialAccountInquiry'],
                    compontName: 'materialSBQueryDrugList',
                    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({StandingBookQueryListCode: 'materialSBQueryDrugList'},()=>{
                                    this.columnRef.onOpenModel();
                                }) }}>{userInfo.language== 'EN' ? item.enDescripts : item.title}</div>
                            }
                        }) : '';
                        let filterArr = arr.filter(function(item){ return item.display === 'Y'});
                        //   let obj =  {
                        //       title: '操作',
                        //       key: 13,
                        //       fixed: 'right',
                        //       align: "center",
                        //       width: '100px',
                        //       render: (text, record) => (
                        //           <span>
                        //   <Popconfirm title="删除不可恢复，你确定要删除吗?" onCancel={this.handlePopconfirm} onConfirm={(e) => this.handleDelete(record, e)} onClick={this.handlePopconfirm} >
                        //       <span className='span' style={{color: 'rgba(240,65,52,1)'}}>删除</span>
                        //   </Popconfirm>
                        // </span>
                        //       ),
                        //   };
                        //   filterArr.push(obj);
                        this.setState({columns: filterArr, detailWidthTotal2: res.totalWidth,ChineseEnglishSize:userInfo.language=='EN' ? res.result.language.EN : res.result.language.CN})
                    }
                }
            });
        };
        //组件权限编辑器
        onColumnRef = (ref) => {
            this.columnRef = ref;
        };


        render() {
            const { getFieldDecorator } = this.props.form;
            let { detailWidthTotal,modalColumns,columns, detailWidthTotal2,ChineseEnglishSize,userInfo} = this.state;
            //入库科室下拉列表
            let loc = [];
            let busType = [];
            let consumeType = [];
            let poison = [];
            let stkSubCat = [];
            let stkCat = [];
            this.state.SelectData.loc && this.state.SelectData.loc.map((item, i) => {
                loc.push(<Option value={item.id} key={i}>{item.descripts}</Option>)
            });
            this.state.SelectData.busType && this.state.SelectData.busType.map((item, i) => {
                busType.push(<Option value={item.id} key={i}>{item.descripts}</Option>)
            });
            this.state.SelectData.consumeType && this.state.SelectData.consumeType.map((item, i) => {
                consumeType.push(<Option value={item.id} key={i}>{item.descripts}</Option>)
            });
            this.state.SelectData.poison && this.state.SelectData.poison.map((item, i) => {
                poison.push(<Option value={item.id} key={i}>{item.descripts}</Option>)
            });
            this.state.SelectData.stkSubCat && this.state.SelectData.stkSubCat.map((item, i) => {
                stkSubCat.push(<Option value={item.id} key={i}>{item.descripts}</Option>)
            });
            this.state.SelectData.stkCat && this.state.SelectData.stkCat.map((item, i) => {
                stkCat.push(<Option value={item.id} key={i}>{item.descripts}</Option>)
            });

            let param = {
                width: '600px',
                top: this.state.top,
                left: this.state.left,
                minHeight: '200px',
                maxHeight: '500px',
                columns: this.modalColumns2,
                data: this.state.modalData,
                isOnRow: true,
            };
            return (
                <div className="standingBookQuery">
                    <Row>
                        <Card
                            size="small"
                            title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.MaterialAccountInquirySearchTitle ? ChineseEnglishSize.MaterialAccountInquirySearchTitle.descripts:'查询条件'}</div>}
                        >
                            <Col span={18}>
                                <Form>
                                    <Row >
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.MaterialAccountInquiryloc ? ChineseEnglishSize.MaterialAccountInquiryloc.descripts:'科室'}>
                                                {getFieldDecorator('locDr',{
                                                    initialValue: this.state.userInfo.locID ? this.state.userInfo.locID : undefined,
                                                    rules:[{ required : ChineseEnglishSize.MaterialAccountInquiryloc ? ChineseEnglishSize.MaterialAccountInquiryloc.required =='Y'? true:false: false, message: ChineseEnglishSize.MaterialAccountInquiryloc ? ChineseEnglishSize.MaterialAccountInquiryloc.message:'科室不能为空'}] 
                                                })(
                                                    <Select allowClear={true}>
                                                        {loc}
                                                    </Select>
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.MaterialAccountInquiryStkCat ? ChineseEnglishSize.MaterialAccountInquiryStkCat.descripts:'库存大类'}>
                                                {getFieldDecorator('stkCatDr',{
                                                    initialValue: undefined,
                                                    rules:[{required: false,message: '库存大类不能为空'}]
                                                })(
                                                    <Select allowClear={true}>
                                                        {stkCat}
                                                    </Select>
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.MaterialAccountInquirypoisonDr ? ChineseEnglishSize.MaterialAccountInquirypoisonDr.descripts:'管制分类'}>
                                                {getFieldDecorator('poisonDr',{
                                                    initialValue: undefined,
                                                    rules:[{required: false,message: '管制分类不能为空'}]
                                                })(
                                                    <Select allowClear={true}>
                                                        {poison}
                                                    </Select>
                                                ) }
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={8} className="queryTime">
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.MaterialAccountInquiryStartDate ? ChineseEnglishSize.MaterialAccountInquiryStartDate.descripts:'起始日期'}>
                                                {getFieldDecorator('StartDate',{
                                                    initialValue: this.state.queryCondition.startDate ? Moment(this.state.queryCondition.startDate, 'YYYY-MM-DD') : Moment(),
                                                    rules:[{ required : ChineseEnglishSize.MaterialAccountInquiryStartDate ? ChineseEnglishSize.MaterialAccountInquiryStartDate.required =='Y'? true:false: false, message: ChineseEnglishSize.MaterialAccountInquiryStartDate ? ChineseEnglishSize.MaterialAccountInquiryStartDate.message:'起始日期不能为空'}]  
                                                })(
                                                    <DatePicker style={{width: '100%'}}  />
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.MaterialAccountInquirystkSubCatDr ? ChineseEnglishSize.MaterialAccountInquirystkSubCatDr.descripts:'库存子类'}>
                                                {getFieldDecorator('stkSubCatDr',{
                                                    initialValue: undefined,
                                                    rules:[{required: false,message: '库存分类不能为空'}]
                                                })(
                                                    <Select allowClear={true}>
                                                        {stkSubCat}
                                                    </Select>
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.MaterialAccountInquiryconsumeTypeDr ? ChineseEnglishSize.MaterialAccountInquiryconsumeTypeDr.descripts:'统计标志'}>
                                                {getFieldDecorator('consumeTypeDr',{
                                                    initialValue: undefined,
                                                    rules:[{required: false,message: '统计标记不能为空'}]
                                                })(
                                                    <Select allowClear={true}>
                                                        {consumeType}
                                                    </Select>
                                                ) }
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={8}  className="queryTime">
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.MaterialAccountInquirydeadline ? ChineseEnglishSize.MaterialAccountInquirydeadline.descripts:'截止日期'}>
                                                {getFieldDecorator('EndData',{
                                                    initialValue: this.state.queryCondition.endDate ? Moment(this.state.queryCondition.endDate, 'YYYY-MM-DD') : Moment(),
                                                    rules:[{ required : ChineseEnglishSize.MaterialAccountInquirydeadline ? ChineseEnglishSize.MaterialAccountInquirydeadline.required =='Y'? true:false: false, message: ChineseEnglishSize.MaterialAccountInquirydeadline ? ChineseEnglishSize.MaterialAccountInquirydeadline.message:'截止日期不能为空'}] 
                                                })(
                                                    <DatePicker style={{width: '100%'}}  />
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8} id="stock-desc" >
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.MaterialAccountInquirydrugName ? ChineseEnglishSize.MaterialAccountInquirydrugName.descripts:'药品名称'}>
                                                {getFieldDecorator('stockDr',{
                                                    initialValue:  undefined,
                                                    rules:[{required: false,message: '药品名称不能为空'}]
                                                })(
                                                    <Input placeholder={ChineseEnglishSize.MaterialAccountInquirypleaseEnterDesc ? ChineseEnglishSize.MaterialAccountInquirypleaseEnterDesc.descripts:'请输入描述'} onFocus={this.stockDescOnFocus} onPressEnter={this.stockDescOnPressEnter} onBlur={this.stastockDescOnBlure} />
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.MaterialAccountInquirybusTypeDr ? ChineseEnglishSize.MaterialAccountInquirybusTypeDr.descripts:'业务类型'}>
                                                {getFieldDecorator('busTypeDr',{
                                                    initialValue: undefined,
                                                    rules:[{required: false,message: '供应商不能为空'}]
                                                })(
                                                    <Select allowClear={true}>
                                                        {busType}
                                                    </Select>
                                                ) }
                                            </FormItem>
                                        </Col>
                                    </Row>
                                </Form>
                            </Col>
                            <Col span={4}>
                                <Row style={{marginBottom: '18px'}}>
                                    <Col>
                                        <FormItem {...formItemSwitch} label={ChineseEnglishSize.MaterialAccountInquiryshowOrHidden ? ChineseEnglishSize.MaterialAccountInquiryshowOrHidden.descripts:'是否显示业务损益'}>
                                            {getFieldDecorator('defective',{
                                                valuePropName: 'checked',
                                                initialValue: false,
                                                rules:[{required: false}]
                                            })(
                                                userInfo.language == 'EN' ?  <Switch checkedChildren="Yes" unCheckedChildren="No" /> : <Switch checkedChildren="是" unCheckedChildren="否"/>
                                            ) }
                                        </FormItem>
                                    </Col>
                                </Row>
                            </Col>
                            <Col span={2}>
                                <Row style={{marginBottom: '18px',marginTop: '2px'}} className="button">
                                    <Button onClick={this.getWarehouseList} style={{marginLeft: '2px'}}>{ChineseEnglishSize.MaterialAccountInquirysearch ? ChineseEnglishSize.MaterialAccountInquirysearch.descripts:'查询'}</Button>
                                </Row>
                                <Row style={{marginBottom: '18px',marginTop: '2px'}} className="button">
                                    <Button type="primary" onClick={this.handleReset} style={{margin: '0 2px'}}>{ChineseEnglishSize.MaterialAccountInquiryclean ? ChineseEnglishSize.MaterialAccountInquiryclean.descripts:'清屏'}</Button>
                                </Row>
                                <Row style={{marginBottom: '18px',marginTop: '2px'}} className="button">
                                    <Button type="primary" onClick={this.showTableExcel}>{ChineseEnglishSize.MaterialAccountInquiryexport ? ChineseEnglishSize.MaterialAccountInquiryexport.descripts:'导出'}</Button>
                                </Row>

                            </Col>

                        </Card>
                    </Row>
                    <Row>
                        <Col span={9} style={{display: this.state.show ? 'none' : ''}} className={!this.state.show ? "animate-wrap active down-in" : "animate-wrap"}>
                            <Card
                                size="small"
                                title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.MaterialAccountInquirydrugsList ? ChineseEnglishSize.MaterialAccountInquirydrugsList.descripts:'药品列表'}</div>}
                                extra={<span style={{color: '#666'}} className='span' onClick={() => {this.setState({StandingBookQueryListCode: 'materialSBQueryDrugList'},()=>{
                                    this.columnRef.onOpenModel();
                                }) }}><Icon type="setting" title={ChineseEnglishSize.MaterialAccountInquirycolumnSettings ? ChineseEnglishSize.MaterialAccountInquirycolumnSettings.descripts:'列权限设置'} /></span>}
                            >
                                <div className="drugList " style={{height: store.getState().tableHeight.y - 15 + 'px'}}>
                                    <Table
                                        columns={columns.length>0 ? columns : this.columns}
                                        dataSource={this.state.WaListData}
                                        pagination={false}
                                        bordered
                                        scroll={{ x: detailWidthTotal2 ? detailWidthTotal2: 1700, y: store.getState().tableHeight.y - 109}}
                                        rowClassName={this.setRowClassName}
                                        rowKey={record => record.key}
                                        className='waListHeight'
                                        onRow={(record) => {
                                            return {
                                                onClick: () => {
                                                    standingNumber = 9999;
                                                    this.setState({detailsId: record.stkLocID,page2: 1});
                                                    this.getWarehouseEntryDetails(record.stkLocID)
                                                },

                                            };
                                        }}
                                    />
                                    <CommonPagination size='small' current={this.state.page} total={this.state.total} search= 'search'
                                                      onShowSizeChange={this.onShowSizeChange.bind(this)} complete={true} dataSource={this.state.WaListData}
                                                      loading={this.state.loading} onChange={this.onChange.bind(this)} />
                                </div>
                            </Card>
                        </Col>
                        <Col className={this.state.detailsListData.length > 0 ? '' : 'detailsListData'} span={this.state.show ? 24 : 15}>
                            <Card
                                size="small"
                                title={<span><Icon onClick={this.packUpHandle} type={this.state.show ? 'double-right' : 'double-left'} />{ChineseEnglishSize.MaterialAccountInquirydetailList ? ChineseEnglishSize.MaterialAccountInquirydetailList.descripts:'详情列表'}</span>}
                                extra={<span style={{color: '#666'}} className='span'  onClick={() => {this.setState({StandingBookQueryListCode: 'materialSBQueryList'},()=>{
                                    this.columnRef.onOpenModel();
                                }) }}><Icon type="setting" title={ChineseEnglishSize.MaterialAccountInquirycolumnSettings ? ChineseEnglishSize.MaterialAccountInquirycolumnSettings.descripts:'列权限设置'} /></span>}
                            >
                                <div style={{height: store.getState().tableHeight.y - 15 + 'px'}}>
                                    <Table
                                        columns={modalColumns.length>0 ? modalColumns : this.modalColumns}
                                        dataSource={this.state.detailsListData}
                                        pagination={false}
                                        bordered
                                        scroll={{ x: detailWidthTotal?detailWidthTotal:1850, y: store.getState().tableHeight.y - 109 }}
                                        rowKey={record => record.key}
                                        className='detailsHeight'
                                    />
                                    <CommonPagination size='small' current={this.state.page2} total={this.state.detailTotal} search= 'search'
                                                      onShowSizeChange={this.onShowSizeChange2.bind(this)} complete={true} dataSource={this.state.detailsListData}
                                                      loading={this.state.detailsLoading} onChange={this.onChange2.bind(this)} />
                                </div>
                            </Card>
                        </Col>
                    </Row>

                    <PublicModalTable onClickRowPublic={this.onClickRowPublic}  param={param} onRef={this.onRef} />
                    {/* 回车弹框 */}
                    <Modal
                        visible={this.state.visible}
                        title={ChineseEnglishSize.MaterialAccountInquiryexportExcel ? ChineseEnglishSize.MaterialAccountInquiryexportExcel.descripts:'导出Excel表格'}
                        okText={ChineseEnglishSize.MaterialAccountInquirydetermine ? ChineseEnglishSize.MaterialAccountInquirydetermine.descripts:'确定'}
                        onCancel={this.hiddenTableExcel}
                        cancelText={ChineseEnglishSize.MaterialAccountInquirycancel ? ChineseEnglishSize.MaterialAccountInquirycancel.descripts:'取消'}
                        onOk={this.TableToExcel}
                    >
                        <Row className="downloadExcel">
                            <Col>
                                <Col span={12}>
                                    <FormItem {...formItemSwitch} label={ChineseEnglishSize.MaterialAccountInquiryapprove1 ? ChineseEnglishSize.MaterialAccountInquiryapprove1.descripts:'导出药品表单'}>
                                        {getFieldDecorator('approve1',{
                                            valuePropName: 'checkedMain',
                                            initialValue: false,
                                            rules:[{required: false}]
                                        })(
                                            <Checkbox value={this.state.checkMainValue}  onChange={this.checkedMain} />
                                        ) }
                                    </FormItem>
                                </Col>
                                <Col span={12}>
                                    <FormItem {...formItemSwitch} label={ChineseEnglishSize.MaterialAccountInquiryapprove2 ? ChineseEnglishSize.MaterialAccountInquiryapprove2.descripts:'导出药品详情表单'}>
                                        {getFieldDecorator('approve2',{
                                            valuePropName: 'checkedDetails',
                                            initialValue: false,
                                            rules:[{required: false}]
                                        })(
                                            <Checkbox value={this.state.checkDetailValue} onChange={this.checkedDetails}/>
                                        ) }
                                    </FormItem>
                                </Col>
                            </Col>
                        </Row>
                    </Modal>
                    <ColumnAuthoritysModel
                        clientWidth='800px'
                        compontName={ this.state.StandingBookQueryListCode}
                        configType="C"
                        onRef={this.onColumnRef}
                        reloadData={() => {
                            if (this.state.StandingBookQueryListCode == 'materialSBQueryDrugList') {
                                this.getDetailTableColumns2()
                                }else if(this.state.StandingBookQueryListCode == 'materialSBQueryList'){
                                this.getDetailTableColumns()
                                }
                            }
                        }
                    />

                </div>
            )
        }
    }
);
export default StandingBookQuery;