// 物资退货制单
import React from 'react';
import { Card, Row, Col, Form, Select, Input, Button, message, Popconfirm, notification } from 'antd';
import Moment from 'moment';
import { $http } from 'containers/config/https';
import SalesReturnDetailList from './component/SalesReturnDetailList.jsx';
import InquireList from './component/InquireList.jsx';
import './style/index.less';
import { printStkRet } from '../commonPrint/stkPrint';
import AccordingToWarehouse from "./component/AccordingToWarehouseByRet";

const { Option } = Select;
const { TextArea } = Input;

const SalesReturnVouching = Form.create()(
    class extends React.Component {
        constructor() {
            super();
            this.state = {
                userInfo: {},
                SelectData: {}, // 下拉框数据
                detailInfo: [], // 明细列表数据
                rowId: '', // 入库单Id
                pageSize: 10,
                page: 1,
                User: JSON.parse(window.sessionStorage.userData),
                statusCode: '',
                statusId: '',
                inOpLocDr: '',
                stkCat: '',
                vendor: '',
                language: JSON.parse(window.sessionStorage.userData),
                ChineseEnglishSize: {},
                returnID:'', //退货ID
                exportStatus:'' , //导出状态
            };
            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.getInOpLocDr();
            const sessionObj = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : {};
            const ipconfigObj = React.$getSessionData('ipConfig');
            this.setState({ sessionObj, ipconfigObj });
        }

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

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

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

        onSelectRef = (ref) => {
            this.childSelect = ref;
        }

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

        // 保存
        saveHandle = () => {
            let { ChineseEnglishSize } = this.state;
            if (this.childDetail.state.data.length < 1) {
                message.error(ChineseEnglishSize.MaterialReturnOrderdetailUnitTips ? ChineseEnglishSize.MaterialReturnOrderdetailUnitTips.descripts : "明细列表不能为空")
            } else {
                // if(this.childDetail.state.stockID){
                //     let newObj =  this.childDetail.checkFormData();
                //     let beforeObj = this.childDetail.initialDataObj();
                //     if (!isObjEqual(newObj,beforeObj)){
                //         message.error('有未保存的数据，请先保存');
                //         return
                //     }
                // }
                this.props.form.validateFields((errors, values) => {
                    let obj = JSON.parse(JSON.stringify(values));
                    if (errors == null) {
                        let remark = this.props.form.getFieldValue('remark2');
                        let listId = this.childModal.state.rowId ? this.childModal.state.rowId : this.state.userInfo.stkReturnID;
                        let data = {
                            params: [{
                                stkReturnID: listId ? listId : undefined,
                                locID: obj.loc ? obj.loc : undefined,
                                stkCatID: obj.stkCat ? obj.stkCat : undefined,
                                remark: remark ? remark : undefined,
                                reasonID: obj.reasonDesc ? obj.reasonDesc : undefined,
                                vendorID: obj.vendor ? obj.vendor : undefined,
                                detail: this.childDetail.state.data
                            }]
                        };
                        $http.post('urlS', this, {
                            code: "02060050",
                            data: data,
                            success: function (res) {
                                if (+res.errorCode === 0) {
                                    // 成功提示
                                    message.success(res.errorMessage);
                                    this.setState({ statusCode: res.result.main.stateID, statusId: res.result.main.stkReturnID });
                                    this.childModal.setState({ tableData: [], total: 0 });
                                    this.getEchoData(res.result.main.stkReturnID);
                                } else {
                                    // this.getEchoData(this.childModal.state.rowId);
                                }
                            },
                            error: function (err) {
                                console.log(err)
                            }
                        })
                    }
                })
            }
        }

        // 保存成功后根据返回回来的inOperateID重新查找数据
        getEchoData(id) {
            // 重置表单
            this.props.form.resetFields(); //清空所有
            this.setState({ rowId: id , returnID : id }); // 将行id保存起来
            let data = {
                params: [
                    {
                        stkReturnID: id
                    }
                ],
                pagination: [
                    {
                        pageSize: this.state.pageSize,
                        currentPage: this.state.page,
                    }
                ],
            };
            $http.post('urlS', this, {
                code: "02060053",
                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 });
                        // this.props.form.setFieldsValue(res.result[0].mainInfo[0]); // 将查询出来的数据回显
                    } else {
                        this.setState({ userInfo: {}, detailInfo: [] });
                    }
                }
            })
        }

        //延时执行
        sleep = (millisecond) => {
            return new Promise(resolve => {
                setTimeout(() => {
                    resolve()
                }, millisecond)
            })
        };

        // 导出
        exportFun = async () => {
            //导出状态
            this.setState({
                exportStatus: true,
                loading: true
            });

            let { sessionObj, ipconfigObj } = this.state;
            let { returnID } = this.state;
            console.log('returnID',returnID);
            let data = {
                params: [{
                    queryParams: {
                        params: [
                            {
                                stkReturnID: returnID
                            }
                        ],
                        code: '02060053',
                        pagination: [{
                            pageSize: this.state.pageSize,
                            currentPage: this.state.page,
                        }],
                        session: [{
                            userID: sessionObj.userID,
                            locID: sessionObj.locID,
                            groupID: sessionObj.groupID,
                            hospID: sessionObj.hospID,
                            sessionID: sessionObj.sessionID,
                            hospCode: sessionObj.hospCode,
                            language: sessionObj.language,
                            hostName: ipconfigObj?.hostName || '',
                            ipv4: ipconfigObj?.ipv4 || '',
                            ipv6: ipconfigObj?.ipv6 || '',
                            mac: ipconfigObj?.mac || ''
                        }]
                    },
                    queryCode: '02060053',
                    componentCode: 'SalesReturnVouchingDetail'
                }],
                pagination: [{
                    pageSize: this.state.pageSize,
                    currentPage: this.state.page,
                }],
                session: [{
                    userID: sessionObj.userID,
                    locID: sessionObj.locID,
                    groupID: sessionObj.groupID,
                    hospID: sessionObj.hospID,
                    sessionID: sessionObj.sessionID,
                    hospCode: sessionObj.hospCode,
                    language: sessionObj.language,
                    hostName: ipconfigObj?.hostName || '',
                    ipv4: ipconfigObj?.ipv4 || '',
                    ipv6: ipconfigObj?.ipv6 || '',
                    mac: ipconfigObj?.mac || ''
                }]
            };
            await this.sleep(1000); //延时，按钮效果
            const resObj = await React.$asyncPost(this, "11020007", data);
            if (resObj) {
                let errorCode = resObj.errorCode;
                if (+errorCode === 0) {
                    let downLoadUrl = resObj.result.downloadURL;
                    //异步--消息提醒
                    if (downLoadUrl === '') {
                        this.exportNotification(); //提示栏
                        store.dispatch({
                            type: 'downloadTask',
                            value: {
                                timeStamp: new Date().getTime(),
                                startDate: Moment(new Date()).format('YYYY-MM-DD'),
                                endDate: Moment(new Date()).format('YYYY-MM-DD'),
                            }
                        })
                    } else { //同步-直接取到链接后下载
                        window.open(downLoadUrl, '_parent')
                    }

                    this.setState({
                        exportStatus: false,
                        loading: false
                    });
                } else {
                    this.setState({
                        exportStatus: false,
                        loading: false
                    });
                    message.error(resObj.errorMessage)
                }
            }
        };

        //右上角提示栏
        exportNotification = () => {
            const msgValue = (<p>数据正在导出，导出完成后可在右上角<span style={{ color: 'red' }}>↗</span><span style={{ fontWeight: 'bold' }}>【导出任务列表】</span>中下载</p>);
            notification.info({
                message: '导出中..',
                description: msgValue,
                placement: 'topRight',
                style: {
                    top: 30,
                },
            });
        };

        // 获取到部门的值
        getInOpLocDr = () => {
            let inOpLocDr = this.props.form.getFieldValue('loc');
            let stkCat = this.props.form.getFieldValue('stkCat');
            let vendorID = this.props.form.getFieldValue('vendor');
            this.setState({ inOpLocDr: inOpLocDr, stkCat: stkCat, vendor: vendorID });
            return inOpLocDr
        }

        // 点击查询显示弹框
        inquireHandle = () => {
            this.getInOpLocDr();
            this.childModal.showModal(this.state.ChineseEnglishSize);
        }

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

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

        // 删除
        handleDelete = () => {
            let data2 = {
                params: {
                    detail: [{
                        stkReturnDetailID: this.childDetail.state.userInfo && this.childDetail.state.userInfo.stkReturnDetailID ? this.childDetail.state.userInfo.stkReturnDetailID : undefined,
                    }]
                }
            };
            let data3 = {
                params: {
                    main: [
                        {
                            stkReturnID: this.childModal.state.rowId ? this.childModal.state.rowId : this.state.statusId ? this.state.statusId : undefined,
                        }
                    ]
                }
            };
            $http.post('urlS', this, {
                code: "02060051",
                data: this.childDetail.state.userInfo && this.childDetail.state.userInfo.stkReturnDetailID ? data2 : data3,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        message.success(res.errorMessage);
                        this.resetFieldsAll();
                        this.childModal.setState({ tableData: [], total: 0, userInfo: {} })
                    }
                }
            })
        }

        //完成
        accomplishSalesReturn = () => {
            let userPOID = this.state.userInfo.stkReturnID ? this.state.userInfo.stkReturnID : undefined;
            let data = {
                params: [{
                    stkReturnID: this.state.statusId ? this.state.statusId : userPOID
                }]
            };
            $http.post('urlS', this, {
                code: "02060055",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        message.success(res.errorMessage);
                        this.setState({ statusCode: '' });
                        this.getEchoData(res.result.main.stkReturnID);
                        this.setState({
                            returnID:res.result.main.stkReturnID
                        });
                        this.childModal.setState({ tableData: [], total: 0 })
                    }
                }
            })
        }

        //取消完成
        offAccomplishSalesReturn = () => {
            let userPOID = this.state.userInfo.stkReturnID ? this.state.userInfo.stkReturnID : undefined;
            let data = {
                params: [{
                    stkReturnID: this.state.statusId ? this.state.statusId : userPOID
                }]
            };
            $http.post('urlS', this, {
                code: "02060056",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        message.success(res.errorMessage);
                        this.getEchoData(res.result.main.stkReturnID);
                        this.setState({
                            returnID:''
                        });
                        this.childModal.setState({ tableData: [], total: 0 })
                    }
                }
            })
        }

        //请求单弹窗双击后需要请求的数据
        onDoubleClickRequisition = (id) => {
            let data = {
                params: [
                    {
                        stkReqID: id
                    }
                ]
            };
            $http.post('urlS', this, {
                code: "02020118",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        for (let i = 0; i < res.result.detail.rows.length; i++) {
                            res.result.detail.rows[i].key = i + "main";
                        }
                        this.setState({ userInfo: res.result.main, detailInfo: res.result.detail.rows });
                        message.success(res.errorMessage);
                        this.childDetail.setState({ userInfo: {}, getBatchDetail: {} });
                        this.childSelect.setState({ getBatchDetail: [] })
                    } else {
                        this.setState({ userInfo: {}, detailInfo: [] });
                        this.childDetail.setState({ userInfo: {}, getBatchDetail: {} });
                        this.childSelect.setState({ getBatchDetail: [] })
                    }
                }
            })

        }

        //获取药品详情回调，显示供应商
        vendorData = (v) => {
            if (v) {
                // this.props.form.setFieldsValue({vendor: ''});
                this.setState({ vendor: v + '' });
            }
        }

        getDetailTableColumn = (v) => {
            this.setState({ ChineseEnglishSize: v })
        }

        // 获取供给科室
        getFrLoc = () => {
            let frLoc = this.props && this.props.form && this.props.form.getFieldValue('loc') ? this.props.form.getFieldValue('loc') : undefined;
            return frLoc;
        }

        //显示入库单
        checkedVoucher = () => {
            this.childWarehouse.showModal(this.state.ChineseEnglishSize);
        }

        onWarehouseRef = (ref) => {
            this.childWarehouse = ref;
        }

        changesDesc = (v) => {
            this.setState({ inOpLocDr: v })
        };

        /**
         * @ByShizi: 切换退货科室名称回车查询科室ID没有改变
         * Create 2021-09-27
         * */
        render() {
            const formItemInput = {
                labelCol: { span: 6 },
                wrapperCol: { span: 18 },
            };
            const { getFieldDecorator } = this.props.form;
            let { ChineseEnglishSize } = this.state;
            let userInfo = this.state.userInfo ? this.state.userInfo : {};
            let user = this.state.User.locID ? this.state.User.locID : undefined;
            let userStatusCode = this.state.userInfo.stateID ? this.state.userInfo.stateID : '';
            return (
                <div className="inventoryBreakageVouching">
                    <Card
                        size="small"
                        title={<div className="card-title-left-icon"><div></div>{ChineseEnglishSize.MaterialReturnOrderreturnForm ? ChineseEnglishSize.MaterialReturnOrderreturnForm.descripts : '退货制单'}</div>}
                    >
                        <Row>
                            <Col span={18} className="top-form">
                                <Form>
                                    <Row>
                                        <Col span={8}>
                                            <Form.Item label={ChineseEnglishSize.MaterialReturnOrderloc ? ChineseEnglishSize.MaterialReturnOrderloc.descripts : '退货科室：'} {...formItemInput}>
                                                {getFieldDecorator('loc', {
                                                    initialValue: userInfo.frLocID ? userInfo.frLocID + '' : user,
                                                    rules: [{ required: ChineseEnglishSize.MaterialReturnOrderloc ? ChineseEnglishSize.MaterialReturnOrderloc.required == 'Y' ? true : false : false, message: ChineseEnglishSize.MaterialReturnOrderloc ? ChineseEnglishSize.MaterialReturnOrderloc.message : '退货科室不能为空' }]
                                                })(
                                                    <Select
                                                        showSearch
                                                        allowClear
                                                        placeholder={ChineseEnglishSize.MaterialReturnOrderlocTips ? ChineseEnglishSize.MaterialReturnOrderlocTips.descripts : '请选择退货科室'}
                                                        onChange={this.changesDesc}
                                                    >
                                                        {this.state.SelectData.loc && this.state.SelectData.loc.map(item => {
                                                            return <Option key={item.id} value={item.id} >{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8}>
                                            <Form.Item label={ChineseEnglishSize.MaterialReturnOrderstkReturnNO ? ChineseEnglishSize.MaterialReturnOrderstkReturnNO.descripts : '退货单号：'} {...formItemInput}>
                                                {getFieldDecorator('stkReturnNO', {
                                                    initialValue: userInfo.stkReturnNO ? userInfo.stkReturnNO : undefined,
                                                })(
                                                    <Input disabled />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8}>
                                            <Form.Item label={ChineseEnglishSize.MaterialReturnOrderreasonDesc ? ChineseEnglishSize.MaterialReturnOrderreasonDesc.descripts : '退货原因：'} {...formItemInput}>
                                                {getFieldDecorator('reasonDesc', {
                                                    initialValue: userInfo.reasonID ? userInfo.reasonID : undefined,
                                                    rules: [{ required: ChineseEnglishSize.MaterialReturnOrderreasonDesc ? ChineseEnglishSize.MaterialReturnOrderreasonDesc.required == 'Y' ? true : false : false, message: ChineseEnglishSize.MaterialReturnOrderreasonDesc ? ChineseEnglishSize.MaterialReturnOrderreasonDesc.message : '退货原因不能为空' }]
                                                })(
                                                    <Select showSearch allowClear placeholder={ChineseEnglishSize.MaterialReturnOrderreasonDescTips ? ChineseEnglishSize.MaterialReturnOrderreasonDescTips.descripts : '请选择退货原因'} >
                                                        {this.state.SelectData.reason && this.state.SelectData.reason.map(item => {
                                                            return <Option key={item.id} value={item.id} >{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                    </Row>
                                    <Row>
                                        <Col span={8}>
                                            <Form.Item label={ChineseEnglishSize.MaterialReturnOrderstkCatID ? ChineseEnglishSize.MaterialReturnOrderstkCatID.descripts : '库存大类：'} {...formItemInput}>
                                                {getFieldDecorator('stkCat', {
                                                    initialValue: userInfo.stkCatID ? userInfo.stkCatID + '' : undefined,
                                                    rules: [{ required: ChineseEnglishSize.MaterialReturnOrderstkCatID ? ChineseEnglishSize.MaterialReturnOrderstkCatID.required == 'Y' ? true : false : false, message: ChineseEnglishSize.MaterialReturnOrderstkCatID ? ChineseEnglishSize.MaterialReturnOrderstkCatID.message : '库存大类不能为空' }]
                                                })(
                                                    <Select showSearch allowClear placeholder={ChineseEnglishSize.MaterialReturnOrderstkCatTips ? ChineseEnglishSize.MaterialReturnOrderstkCatTips.descripts : '请选择库存大类'} >
                                                        {this.state.SelectData.stkCat && this.state.SelectData.stkCat.map(item => {
                                                            return <Option key={item.id} value={item.id}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8}>
                                            <Form.Item label={ChineseEnglishSize.MaterialReturnOrdercreateUserName ? ChineseEnglishSize.MaterialReturnOrdercreateUserName.descripts : '制单人：'} {...formItemInput}>
                                                {getFieldDecorator('createUserName', {
                                                    initialValue: userInfo.createUserName ? userInfo.createUserName : undefined,
                                                    rules: [{ required: false }]
                                                })(
                                                    <Input disabled />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8}>
                                            <Form.Item label={ChineseEnglishSize.MaterialReturnOrderstatus ? ChineseEnglishSize.MaterialReturnOrderstatus.descripts : '单据状态：'} {...formItemInput}>
                                                {getFieldDecorator('stkCat2', {
                                                    initialValue: userInfo.stateID ? userInfo.stateID : undefined,
                                                    rules: [{ required: false }]
                                                })(
                                                    <Select showSearch allowClear disabled>
                                                        {this.state.SelectData.state && this.state.SelectData.state.map(item => {
                                                            return <Option key={item.id} value={item.id}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>

                                    </Row>
                                    <Row>
                                        <Col span={8}>
                                            <Form.Item label={ChineseEnglishSize.MaterialReturnOrdervendor ? ChineseEnglishSize.MaterialReturnOrdervendor.descripts : '供应商：'} {...formItemInput}>
                                                {getFieldDecorator('vendor', {
                                                    initialValue: userInfo.vendorID ? userInfo.vendorID : this.state.vendor ? this.state.vendor : undefined,
                                                    rules: [{ required: ChineseEnglishSize.MaterialReturnOrdervendor ? ChineseEnglishSize.MaterialReturnOrdervendor.required == 'Y' ? true : false : false, message: ChineseEnglishSize.MaterialReturnOrdervendor ? ChineseEnglishSize.MaterialReturnOrdervendor.message : '供应商不能为空' }]
                                                })(
                                                    <Select
                                                        showSearch
                                                        allowClear
                                                        optionFilterProp="search"
                                                    >
                                                        {this.state.SelectData.vendor && this.state.SelectData.vendor.map(item => {
                                                            return <Option key={item.id} value={item.id} search={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>
                                                        })}
                                                    </Select>
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8}>
                                            <Form.Item label={ChineseEnglishSize.MaterialReturnOrdercrStartDate ? ChineseEnglishSize.MaterialReturnOrdercrStartDate.descripts : '制单日期：'} {...formItemInput}>
                                                {getFieldDecorator('StartDate', {
                                                    initialValue: userInfo.createDate ? userInfo.createDate : undefined,
                                                })(
                                                    <Input disabled />
                                                )}
                                            </Form.Item>
                                        </Col>
                                        <Col span={8}>
                                            <Form.Item label={ChineseEnglishSize.MaterialReturnOrderremark2 ? ChineseEnglishSize.MaterialReturnOrderremark2.descripts : '备注：'} {...formItemInput}>
                                                {getFieldDecorator('remark2', {
                                                    initialValue: userInfo.remark ? userInfo.remark : undefined,
                                                })(
                                                    <TextArea rows={1} style={{ width: '100%' }} />
                                                )}
                                            </Form.Item>
                                        </Col>
                                    </Row>
                                </Form>
                            </Col>
                            <Col span={5} style={{ marginLeft: '33px' }}>
                                <Row style={{ marginBottom: '20px', marginTop: '5px' }}>
                                    <Button style={{ marginRight: '30px' }} onClick={this.inquireHandle}>{ChineseEnglishSize.MaterialReturnOrdersearch ? ChineseEnglishSize.MaterialReturnOrdersearch.descripts : '查询'}</Button>
                                    <Button type="primary" style={{ marginRight: '30px' }} onClick={this.saveHandle}>{ChineseEnglishSize.MaterialReturnOrdersave ? ChineseEnglishSize.MaterialReturnOrdersave.descripts : '保存'}</Button>
                                    <Button disabled={this.state.statusCode == 10 ? false : userStatusCode == 10 ? false : true} onClick={this.accomplishSalesReturn}>{ChineseEnglishSize.MaterialReturnOrderaccomplish ? ChineseEnglishSize.MaterialReturnOrderaccomplish.descripts : '完成'}</Button>
                                </Row>
                                <Row>
                                    <Popconfirm title={ChineseEnglishSize.MaterialReturnOrderresetTips ? ChineseEnglishSize.MaterialReturnOrderresetTips.descripts : '重置后将初始化数据，你确定要重置吗?'} onConfirm={this.resetFields}
                                        okText={this.state.User.language == 'EN' ? "Yes" : '是'} cancelText={this.state.User.language == 'EN' ? "No" : '否'}>
                                        <Button style={{ marginRight: '30px' }} >{ChineseEnglishSize.MaterialReturnOrderReset ? ChineseEnglishSize.MaterialReturnOrderReset.descripts : '重置'}</Button>
                                    </Popconfirm>
                                    <Popconfirm title={ChineseEnglishSize.MaterialReturnOrderdeleteTips ? ChineseEnglishSize.MaterialReturnOrderdeleteTips.descripts : '删除不可恢复，你确定要删除吗?'} onConfirm={this.handleDelete}
                                        okText={this.state.User.language == 'EN' ? "Yes" : '是'} cancelText={this.state.User.language == 'EN' ? "No" : '否'}>
                                        <Button type="danger" style={{ marginRight: '30px' }}>{ChineseEnglishSize.MaterialReturnOrderdelete ? ChineseEnglishSize.MaterialReturnOrderdelete.descripts : '删除'}</Button>
                                    </Popconfirm>
                                    <Button disabled={this.state.statusCode == 20 ? false : userStatusCode == 20 ? false : true} onClick={this.offAccomplishSalesReturn}>{ChineseEnglishSize.MaterialReturnOrdercancelComplete ? ChineseEnglishSize.MaterialReturnOrdercancelComplete.descripts : '取消完成'}</Button>
                                </Row>
                                <Row style={{ marginTop: '20px' }}>
                                    <Button type="dashed" onClick={printStkRet.bind(this, this.state.rowId)}>{ChineseEnglishSize.MaterialReturnOrderprint ? ChineseEnglishSize.MaterialReturnOrderprint.descripts : '打印'}</Button>
                                    <Button style={{ marginLeft: '30px' }} type="dashed" onClick={this.checkedVoucher}>{ChineseEnglishSize.MaterialReturnOrderreceiptPreparation ? ChineseEnglishSize.MaterialReturnOrderreceiptPreparation.descripts : '快速制单'}</Button>
                                    <Button style={{ marginLeft: '30px' }} type="primary" disabled={this.state.returnID !=='' ? false : true} onClick={this.exportFun}>导出</Button>
                                </Row>
                            </Col>
                        </Row>
                    </Card>
                    <SalesReturnDetailList
                        SelectData={this.state.SelectData} onRef={this.detailOnRef} detailInfo={this.state.detailInfo}
                        handleThis={this} inOpLocDr={this.state.inOpLocDr} stkCat={this.state.stkCat}
                        getFrLoc={this.getFrLoc}
                    />
                    <AccordingToWarehouse onRef={this.onWarehouseRef} handleThis={this} />
                    <InquireList SelectData={this.state.SelectData} onRef={this.onRef} vendor={this.state.vendor} inOpLocDr={this.state.inOpLocDr ? this.state.inOpLocDr : ''} handleThis={this} />
                </div>
            )
        }
    }
);
export default SalesReturnVouching;