// 入库验收
import React from 'react';
import { Card, Row, Col, Form, DatePicker, Select, Button, Icon, Table, Switch, message, Pagination, Input  } from 'antd';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import CommonPagination from 'components/pagination/index';
import { $http } from 'containers/config/https';
import Moment from 'moment';
import store from 'store';
import {printStkAccept} from '../pharmacy/commonPrint/stkPrint';
import './style/index.less';
var serialNumber = 0; //入库单序列号

const { Option } = Select;
const FormItem = Form.Item;
const formItemLayout = {    // label 和input宽度
    labelCol: { span:7 },
    wrapperCol: { span: 17 },
};

const WarehouseAcceptance = Form.create()(
    class extends React.Component {
        constructor() {
            super();
            this.state = {
                userInfo: JSON.parse(window.sessionStorage.userData),
                data: [],
                SelectData: {},
                inOpLocDr:'',
                vendor: '',
                detailsId: '',//入库单ID
                detailsListData:[], //入库单明细数据
                WaListData: [], //入库单数据
                pageSize: 10,
                page: 1,
                pageSize2: 10,
                page2: 1,
                total:0,
                detailTotal: 0,
                warehouseListId: '',
                noData: false,
                detailWidthTotal: '',
                columns: [],
                modalColumns:[],
                modificationList: false,  //默认隐藏修改表头弹窗
                showDetailPopup: false,  //默认隐藏修改表头弹窗
                listLength: '',  //列表长度
                parameterCode: '',
                ChineseEnglishSize: [], //中英文字体

            }
            // 入库单的数据表头
            this.columns = [
                {
                    key: 1,
                    title: '单号',
                    dataIndex: 'No',
                    align: "center",
                    width: '11%'
                },
                {
                    key: 2,
                    title: '入库科室',
                    dataIndex: 'inOperLocDesc',
                    align: "center",
                    width: '9%'
                },
                {
                    key: 3,
                    title: '供应商',
                    dataIndex: 'vendorDesc',
                    align: "center",
                    width: '15%'
                },
                {
                    key: 4,
                    title: '入库日期',
                    dataIndex: 'createDate',
                    align: "center",
                    width: '6%'
                },
                {
                    key: 5,
                    title: '制单人',
                    dataIndex: 'createUserName',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 6,
                    title: '入库类型',
                    dataIndex: 'operTypeDesc',
                    align: "center",
                    width: '6%'
                },
                {
                    key: 7,
                    title: '验收人',
                    dataIndex: 'auditUserName',
                    align: "center",
                    width: '6.5%'
                },
                {
                    key: 8,
                    title: '验收日期',
                    dataIndex: 'auditDate',
                    align: "center",
                    width: '6%'
                },
                {
                    key: 9,
                    title: '订单号',
                    dataIndex: 'orderNo',
                    align: "center",
                    width: '15.5%'
                },
                {
                    key: 10,
                    title: '进价金额',
                    dataIndex: 'rpAmt',
                    align: "center",
                    width: '5%',
                },
                {
                    key: 11,
                    title: '售价金额',
                    dataIndex: 'spAmt',
                    align: "center",
                    width: '5%'
                },
                {
                    key: 12,
                    title: '进销差价',
                    dataIndex: 'difAmt',
                    align: "center",
                    width: '5%'
                }
            ];
            // 入库单详细表头
            this.modalColumns = [
                {
                    key: 1,
                    title: '代码',
                    dataIndex: 'stockCode',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 2,
                    title: '描述',
                    dataIndex: 'stockDesc',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 3,
                    title: '包装规格',
                    dataIndex: 'stockSpec',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 4,
                    title: '生产厂家',
                    dataIndex: 'manfDesc',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 5,
                    title: '批号',
                    dataIndex: 'batNo',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 6,
                    title: '有效期',
                    dataIndex: 'expDate',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 17,
                    title: '检测口岸',
                    dataIndex: 'inspectionPort',
                    align: "center",
                    width: '150px',
                    render: (text, record) => {
                        return(  <span><Input min={0} value={text} onChange={(e) => this.handleFieldChange(e, 'inspectionPort',record.key)} style={{  float: 'left', marginLeft: '6px', width: '90%',padding: '0', paddingLeft: '5px'}}/></span>)

                    }
                },
                {
                    key: 18,
                    title: '检测报告',
                    dataIndex: 'inspectionReport',
                    align: "center",
                    width: '150px',
                    render: (text, record) => {
                        return(  <span><Input min={0} value={text}   onChange={(e) => this.handleFieldChange(e, 'inspectionReport',record.key)} style={{  float: 'left', marginLeft: '6px', width: '90%',padding: '0', paddingLeft: '5px'}}/></span>)

                    }
                },
                {
                    key: 19,
                    title: '检测日期',
                    dataIndex: 'inspectionDate',
                    align: "center",
                    width: '150px',
                    render: (text, record) => {
                        return(  <span><DatePicker  defaultValue={text ? Moment(text, 'YYYY-MM-DD'): undefined} onChange={(e) => this.handleFieldChangeTime(e, 'inspectionDate',record.key)} style={{width: '100%'}} /></span>)

                    }
                },
                {
                    key: 20,
                    title: '注册证号',
                    dataIndex: 'certificateNo',
                    align: "center",
                    width: '150px',
                    render: (text, record) => {
                        return(  <span><Input min={0} value={text}   onChange={(e) => this.handleFieldChange(e, 'certificateNo',record.key)} style={{  float: 'left', marginLeft: '6px', width: '90%',padding: '0', paddingLeft: '5px'}}/></span>)

                    }
                },
                {
                    key: 21,
                    title: '注册证有效期',
                    dataIndex: 'certifiExpDate',
                    align: "center",
                    width: '150px',
                    render: (text, record) => {
                        return(  <span><DatePicker defaultValue={text ? Moment(text, 'YYYY-MM-DD'): undefined} onChange={(e) => this.handleFieldChangeTime(e, 'certifiExpDate',record.key)} style={{width: '100%'}} /></span>)

                    }
                },
                {
                    key: 7,
                    title: '生产日期',
                    dataIndex: 'produceDate',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 8,
                    title: '数量',
                    dataIndex: 'qty',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 9,
                    title: '单位',
                    dataIndex: 'unitDesc',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 10,
                    title: '进价',
                    dataIndex: 'rp',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 11,
                    title: '售价',
                    dataIndex: 'sp',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 12,
                    title: '发票号',
                    dataIndex: 'invNo',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 13,
                    title: '发票日期',
                    dataIndex: 'invDate',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 14,
                    title: '进价金额',
                    dataIndex: 'rpAmt',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 15,
                    title: '售价金额',
                    dataIndex: 'spAmt',
                    align: "center",
                    width: '150px'
                },
                {
                    key: 16,
                    title: '进销差额',
                    dataIndex: 'difAmt',
                    align: "center",
                    width: '150px'
                }
            ]
        }

        componentDidMount() {
            // 初始化数据
            this.getTacitlyApproveData();
            this.getDetailTableColumns();
            this.getDetailListTableColumns();
            let leftList = document.querySelectorAll('.tableListHeight  .ant-table-body');
            if(leftList.length>0){
                leftList[0].style.height = (store.getState().tableHeight.y)/2 + 'px';
            }
            let listData = document.querySelectorAll('.tableDetailHeight  .ant-table-body');
            if(listData.length>0){
                listData[0].style.height = (store.getState().tableHeight.y)/2 + 'px';
            }
        }


        //获取操作行数据对象
        getRowByKey(key, newData) {
            const { detailsListData } = this.state;
            return (newData || detailsListData).filter(item => item.key === key)[0];
        }
        //文本框数据修改
        handleFieldChange=(e, fieldName, key)=>{
            const { detailsListData} = this.state;
            const newData = detailsListData.map(item => ({ ...item }));
            const target = this.getRowByKey(key, newData);
            if (target) {
                target[fieldName] = e.target.value;
                this.setState({detailsListData: newData});
            }
        };
        //日期文本框数据修改
        handleFieldChangeTime=(e, fieldName, key)=>{
            const { detailsListData} = this.state;
            const newData = detailsListData.map(item => ({ ...item }));
            const target = this.getRowByKey(key, newData);
            if (target) {
                target[fieldName] = Moment(e).format('YYYY-MM-DD');
                this.setState({detailsListData: newData});
            }
        };
        // 获取明系列表头数据
        getDetailTableColumns = () => {
            let {userInfo}=this.state;
            let data = {
                params: [{
                    reactCode: ['WarehouseAcceptance'],
                    compontName: 'WarehouseAcceptance',
                    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: 'WarehouseAcceptance'},()=>{
                                    this.columnRef.onOpenModel();
                                }) }}>{userInfo.language =='EN' ? item.enDescripts : item.title}</div>,
                            }
                        }) : '';
                        let filterArr = arr.filter(function(item){ return item.display === 'Y'});
                        this.setState({columns: filterArr, detailWidthTotal: res.totalWidth, ChineseEnglishSize: userInfo.language =='EN' ? res.result.language.EN : res.result.language.CN})
                    }
                }
            })
        };

        // 获取明系列表头数据
        getDetailListTableColumns = () => {
            let {userInfo}=this.state;
            let data = {
                params: [{
                    reactCode: ['WarehouseAcceptanceDetailList'],
                    compontName: 'WarehouseAcceptanceDetailList',
                    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: 'WarehouseAcceptanceDetailList'},()=>{
                                    this.columnRef.onOpenModel();
                                }) }}>{userInfo.language =='EN' ? item.enDescripts : item.title}</div>,
                                render: (text, record) => {
                                    if(item.code == 'certifiExpDate'){
                                        return(  <span><DatePicker defaultValue={text ? Moment(text, 'YYYY-MM-DD'): undefined} onChange={(e) => this.handleFieldChangeTime(e, 'certifiExpDate',record.key)} style={{width: '100%'}} /></span>)
                                    }else if(item.code == 'certificateNo'){
                                        return(  <span><Input min={0} value={text}   onChange={(e) => this.handleFieldChange(e, 'certificateNo',record.key)} style={{  float: 'left', marginLeft: '6px', width: '90%',padding: '0', paddingLeft: '5px'}}/></span>)
                                    }else if(item.code == 'inspectionDate'){
                                        return(  <span><DatePicker  defaultValue={text ? Moment(text, 'YYYY-MM-DD'): undefined} onChange={(e) => this.handleFieldChangeTime(e, 'inspectionDate',record.key)} style={{width: '100%'}} /></span>)
                                    }else if(item.code == 'inspectionReport'){
                                        return(  <span><Input min={0} value={text}   onChange={(e) => this.handleFieldChange(e, 'inspectionReport',record.key)} style={{  float: 'left', marginLeft: '6px', width: '90%',padding: '0', paddingLeft: '5px'}}/></span>)
                                    }else if(item.code == 'inspectionPort'){
                                        return(  <span><Input min={0} value={text} onChange={(e) => this.handleFieldChange(e, 'inspectionPort',record.key)} style={{  float: 'left', marginLeft: '6px', width: '90%',padding: '0', paddingLeft: '5px'}}/></span>)
                                    }else {
                                        return text
                                    }
                                }
                            }
                        }) : '';
                        let filterArr = arr.filter(function(item){ return item.display === 'Y'});
                        this.setState({modalColumns: filterArr, listLength: res.totalWidth})
                    }
                }
            })
        };

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

        // 获取界面默认值
        getTacitlyApproveData() {
            let data = {
                params: []
            };
            // 获取下拉数据
            $http.post('urlS', this, {
                code: "02020298",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({SelectData: res.result[0]})
                    }
                }
            })
        }

        handleQuery=()=>{
            this.setState({page: 1},()=>{
                this.getWarehouseList()
            })
        };

        // 获取入库单列表数据
        getWarehouseList=()=>{
            this.setState({detailsId: '', loading:true});
            let{ ChineseEnglishSize} =this.state;
            this.props.form.validateFields((errors, values) => {
                let obj = JSON.parse(JSON.stringify(values));
                if (errors == null) {
                    let data = {
                        params: [{
                            inOperLocID: obj.inOpLocDr ? obj.inOpLocDr : undefined,
                            startDate: obj.StartDate?Moment(obj.StartDate).format('YYYY-MM-DD'):undefined,
                            endDate: obj.EndData?Moment(obj.EndData).format('YYYY-MM-DD'):undefined,
                            statusID:obj.statusID ? obj.statusID : undefined,
                            recNo: obj.recNo ? obj.recNo : undefined,
                            vendorID: obj.vendor ? obj.vendor : undefined,
                        }],
                        pagination: [
                            {
                                pageSize:this.state.pageSize,
                                currentPage:this.state.page,
                                sort:"ID",
                                dir:"asc",
                            }
                        ],
                    };
                    $http.post('urlS', this, {
                        code: "02020050",
                        data: data,
                        success: function (res) {
                            if(res.result.length > 0){
                                for(let i = 0; i < res.result.length; i++){
                                    res.result[i].key = i;
                                }
                                this.setState({ WaListData: res.result,total: res.total,warehouseListId: res.result[0].inOperID,page2: 1, loading: false});
                                serialNumber = 0;
                                this.getWarehouseEntryDetails(res.result[0].inOperID);

                            }else {
                                this.setState({detailsListData: [], WaListData: [],warehouseListId: ''});
                                if(!this.state.noData){
                                    message.error(ChineseEnglishSize.WarehouseAcceptanceNoData ? ChineseEnglishSize.WarehouseAcceptanceNoData.descripts:"没数据");
                                }else {
                                    this.setState({noData: false})
                                }
                            }
                        },
                        error: function (err) {
                            message.error(err.errorMessage)
                        }
                    });
                }
            })

        };
        // 获取入库单明细
        getWarehouseEntryDetails(id) {
            this.setState({detailsLoading:true});
            let data = {
                params: [{
                    inOperID:id ? id : this.state.warehouseListId,
                }],
                pagination: [
                    {
                        pageSize:this.state.pageSize2,
                        currentPage:id ? 1 : this.state.page2,
                        sort:"ID",
                        dir:"asc",
                    }
                ]
            };
            $http.post('urlS', this, {
                code: "02020062",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        serialNumber = this.state.detailsId ? this.state.detailsId : 0;
                        for(let i = 0; i < res.result[0].rows.length; i++){
                            res.result[0].rows[i].key = i;
                        }
                        this.setState({detailsListData:res.result[0].rows, detailTotal: res.result[0].total , detailsLoading: false});
                    }
                }
            })
        }

        // 提交验收确定
        approveDetermine=()=>{
            let{ ChineseEnglishSize} =this.state;
            let data = {
                params: [{
                    inOperID:this.state.detailsId ? this.state.detailsId : this.state.warehouseListId,
                    detail:this.state.detailsListData
                }]
            };

            //是否有验收的内容
            if(this.state.detailsId || this.state.warehouseListId){
                $http.post('urlS', this, {
                    code: "02020297",
                    data: data,
                    success: function (res) {
                        if(+res.errorCode == '0'){
                            this.setState({noData: true});
                            this.getWarehouseList();
                            message.success(res.errorMessage);
                        }
                    },
                    error: function (err) {
                        message.error(err.errorMessage);
                    }
                });
            }else {
                message.error(ChineseEnglishSize.WarehouseAcceptanceAcobject ? ChineseEnglishSize.WarehouseAcceptanceAcobject.descripts:'请选择验收对象')
            }
        };

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

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

        onShowSizeChange = (current, size) => {
            this.setState({page: current, pageSize: size}, () => {
                // 重新调用查询方法
                this.onChange(current,size);
            })
        };

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

        onShowSizeChange2 = (current, size) => {
            this.setState({page2: current, pageSize2: size}, () => {
                // 重新调用查询方法
                this.onChange2(current,size);
            })
        };
        // 显示分页总条数
        showTotal(total) {
            return `共 ${total} 条`;
        }
        //组件权限编辑器
        onColumnRef = (ref) => {
            this.columnRef = ref;
        };

        render() {
            const { getFieldDecorator } = this.props.form;
            const { modalColumns, columns, listLength, detailWidthTotal, ChineseEnglishSize } = this.state;
            let userInfo = this.state.userInfo ? this.state.userInfo: {};
            //入库科室列表
            let inOpLocDrSelect = [];
            this.state.SelectData.inOpLoc && this.state.SelectData.inOpLoc.map((item, i) => {
                inOpLocDrSelect.push(<Option value={item.id} key={i}>{item.descripts}</Option>)
            });

            return (
                <div className="WarehouseAcceptance">
                    <Row>
                        <Card
                            size="small"
                            title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.WarehouseAcceptanceSearchTitle ? ChineseEnglishSize.WarehouseAcceptanceSearchTitle.descripts:'查询条件'}</div>}
                        >
                            <Col span={18}>
                                <Form>
                                    <Row >
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.WarehouseAcceptanceRecLoc ? ChineseEnglishSize.WarehouseAcceptanceRecLoc.descripts:'入库科室'}>
                                                {getFieldDecorator('inOpLocDr',{
                                                    initialValue: this.state.userInfo.locID ? this.state.userInfo.locID : undefined,
                                                    rules:[{ required : ChineseEnglishSize.WarehouseAcceptanceRecLoc ? ChineseEnglishSize.WarehouseAcceptanceRecLoc.required =='Y'? true:false: false, message: ChineseEnglishSize.WarehouseAcceptanceRecLoc ? ChineseEnglishSize.WarehouseAcceptanceRecLoc.message:'入库科室不能为空'}]
                                                })(
                                                    <Select allowClear>
                                                        {inOpLocDrSelect}
                                                    </Select>
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.WarehouseAcceptanceVendor ? ChineseEnglishSize.WarehouseAcceptanceVendor.descripts:'供应商'}>
                                                {getFieldDecorator('vendor',{
                                                    initialValue: undefined,
                                                    rules:[{ required : ChineseEnglishSize.WarehouseAcceptanceVendor ? ChineseEnglishSize.WarehouseAcceptanceVendor.required =='Y'? true:false: false, message: ChineseEnglishSize.WarehouseAcceptanceVendor ? ChineseEnglishSize.WarehouseAcceptanceVendor.message:'供应商不能为空'}]
                                                })(
                                                    <Select allowClear>
                                                        {this.state.SelectData.vendor && this.state.SelectData.vendor.map((item, i) => {
                                                            return <Option value={item.id} key={i}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.WarehouseAcceptancestatus ? ChineseEnglishSize.WarehouseAcceptancestatus.descripts:'入库状态'}>
                                                {getFieldDecorator('statusID',{
                                                    initialValue: undefined,

                                                })(
                                                    <Select allowClear>
                                                        {this.state.SelectData.inOpStatus && this.state.SelectData.inOpStatus.map((item, i) => {
                                                        return <Option value={item.id} key={i}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                ) }
                                            </FormItem>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.WarehouseAcceptanceStartDate ? ChineseEnglishSize.WarehouseAcceptanceStartDate.descripts:'起初日期'}>
                                                {getFieldDecorator('StartDate',{
                                                    initialValue:  this.state.SelectData.startDate ? Moment(this.state.SelectData.startDate, 'YYYY-MM-DD') : Moment(Moment().format('L'), 'YYYY-MM-DD'),
                                                    rules:[{ required : ChineseEnglishSize.WarehouseAcceptanceStartDate ? ChineseEnglishSize.WarehouseAcceptanceStartDate.required =='Y'? true:false: false, message: ChineseEnglishSize.WarehouseAcceptanceStartDate ? ChineseEnglishSize.WarehouseAcceptanceStartDate.message:'起初日期不能为空'}]
                                                })(
                                                    <DatePicker style={{width: '100%'}} />
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.WarehouseAcceptanceEndDate ? ChineseEnglishSize.WarehouseAcceptanceEndDate.descripts:'截止日期'}>
                                                {getFieldDecorator('EndData',{
                                                    initialValue:this.state.SelectData.endDate ? Moment(this.state.SelectData.endDate, 'YYYY-MM-DD') : Moment(Moment().format('L'), 'YYYY-MM-DD'),
                                                    rules:[{ required : ChineseEnglishSize.WarehouseAcceptanceEndDate ? ChineseEnglishSize.WarehouseAcceptanceEndDate.required =='Y'? true:false: false, message: ChineseEnglishSize.WarehouseAcceptanceEndDate ? ChineseEnglishSize.WarehouseAcceptanceEndDate.message:'截至日期不能为空'}]
                                                })(
                                                    <DatePicker style={{width: '100%'}} />
                                                ) }
                                            </FormItem>
                                        </Col>
                                        <Col span={8}>
                                            <FormItem {...formItemLayout} label={ChineseEnglishSize.WarehouseAcceptanceInboundOrder ? ChineseEnglishSize.WarehouseAcceptanceInboundOrder.descripts:'入库单号'}>
                                                {getFieldDecorator('recNo',{
                                                    initialValue: undefined,
                                                })(
                                                   <Input />
                                                ) }
                                            </FormItem>
                                        </Col>
                                    </Row>
                                </Form>
                            </Col>
                            <Col span={6} style={{paddingLeft: '100px', marginTop: '4px'}} className="button">
                                <Row style={{marginBottom: '18px'}} >
                                    <Button  onClick={this.handleQuery}>{ChineseEnglishSize.WarehouseAcceptancesearch ? ChineseEnglishSize.WarehouseAcceptancesearch.descripts:'查询'}</Button>
                                    <Button style={{marginLeft: '30px'}} type="primary" onClick={this.handleReset}>{ChineseEnglishSize.WarehouseAcceptanceReset ? ChineseEnglishSize.WarehouseAcceptanceReset.descripts:'重置'}</Button>
                                </Row>
                                <Row style={{marginBottom: '18px'}} className="button">
                                    <Button type="primary"  onClick={this.approveDetermine}>{ChineseEnglishSize.WarehouseAcceptanceacceptance ? ChineseEnglishSize.WarehouseAcceptanceacceptance.descripts:'入库验收'}</Button>
                                    <Button type="dashed" style={{marginLeft: '30px'}} onClick={printStkAccept.bind(this,this.state.detailsId)}> {ChineseEnglishSize.WarehouseAcceptanceprint ? ChineseEnglishSize.WarehouseAcceptanceprint.descripts:'打印'}</Button>
                                </Row>
                            </Col>

                        </Card>
                    </Row>
                    <Row>
                        <Col>
                            <Card
                                size="small"
                                title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.WarehouseAcceptanceRecNoTitle ? ChineseEnglishSize.WarehouseAcceptanceRecNoTitle.descripts:'入库单'}</div>}
                                extra={<span style={{color: '#666'}} className='span' onClick={() => {this.setState({parameterCode: 'WarehouseAcceptance'},()=>{
                                    this.columnRef.onOpenModel();
                                })}}><Icon type="setting" title={ChineseEnglishSize.WarehouseAcceptancesettings ? ChineseEnglishSize.WarehouseAcceptancesettings.descripts:'列权限设置'} /></span>}
                            >
                                <div>
                                    <Table
                                        columns={columns.length>0 ? columns : this.columns}
                                        dataSource={this.state.WaListData}
                                        pagination={false}
                                        bordered
                                        scroll={{x: detailWidthTotal ? detailWidthTotal: 1500,y: (store.getState().tableHeight.y)/2 - 85 }}
                                        rowKey={record => record.key}
                                        rowClassName={this.setRowClassName}
                                        className="tableListHeight"
                                        onRow={(record) => {
                                            return {
                                                onClick: () => {
                                                    serialNumber = 9999;
                                                    this.setState({detailsId: record.inOperID,page2: 1, detailsListData: []});
                                                    this.getWarehouseEntryDetails(record.inOperID)
                                                },

                                            };
                                        }}
                                    />
                                    <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>
                    </Row>
                    <Row>
                        <Col>
                            <Card
                                size="small"
                                title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.WarehouseAcceptanceRecDetailTitle ? ChineseEnglishSize.WarehouseAcceptanceRecDetailTitle.descripts:'入库单明细'}</div>}
                                extra={<span style={{color: '#666'}} className='span' onClick={() => {this.setState({parameterCode: 'WarehouseAcceptanceDetailList'},()=>{
                                    this.columnRef.onOpenModel();
                                })}}><Icon type="setting" title={ChineseEnglishSize.WarehouseAcceptancesettings ? ChineseEnglishSize.WarehouseAcceptancesettings.descripts:'列权限设置'} /></span>}
                            >
                                <div>
                                    <Table
                                        columns={modalColumns.length>0 ? modalColumns : this.modalColumns}
                                        dataSource={this.state.detailsListData}
                                        pagination={false}
                                        bordered
                                        // scroll={{ y: (store.getState().tableHeight.y)/2 - 113}}
                                        scroll={{x: listLength? listLength: 3150, y: (store.getState().tableHeight.y)/2 - 90}}
                                        rowKey={record => record.key}
                                        className="tableDetailHeight"
                                    />
                                    <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>
                    <ColumnAuthoritysModel
                        clientWidth='800px'
                        compontName={ this.state.parameterCode}
                        configType="C"
                        onRef={this.onColumnRef}
                        reloadData={() => {
                            if (this.state.parameterCode == 'WarehouseAcceptance') {
                                this.getDetailTableColumns()
                            }else if(this.state.parameterCode == 'WarehouseAcceptanceDetailList'){
                                this.getDetailListTableColumns()
                            }
                        }
                        }
                    />
                </div>
            )
        }
    }
);
export default WarehouseAcceptance;