/*
 * Create:      柿子
 * CreateDate:  2022/09/09
 * Describe：   库房 - 入库审核(SightWarehousingReview)/出库审核(SightIssueApproval)/转移入库接收-转移接收(SightTransferReceipt)/退货审核(ReturnVPAudit)/调价单审核(PriceAdjustBillReviewList)/调价单生效(PriceAdjustBillEffect)
 * */
import React, { Component } from 'react';
import { Card, Select, Radio, Button, Tooltip, message, Input, Popconfirm, Tag, Divider } from 'antd';
import { Util, dayFormat } from 'tools';
import { handleExcel } from 'tools/handleExcel';
import store from 'store';
import moment from 'moment';
import PubilcTablePagination from 'pages/common/PubilcTablePagination.jsx';
import RangeDatePicker from 'components/rangePicker/index';
import iconInquire from 'assets/images/icon_Inquire.png';
import iconListvisits from 'assets/images/icon_listvisits.png';

class WarehousingReview extends Component {
  constructor(props) {
    super(props);
    let userData = React.$getSessionData();
    this.state = {
      userData,
      category: '',
      categoryData: {},
      selectData: {},
      queryParams: {
        inOpLocID: undefined, // 科室
        toLocID: undefined, // 请求科室
        vendorID: undefined, // 供应商
        startDate: moment().format(dayFormat), // 开始日期
        endDate: moment().format(dayFormat), // 结束日期
        status: '20', // 状态
        inputDesc: undefined, // 产品名称
      },
      page: 1,
      pageSize: 10,
      total: 0,
      loading: false,
      tableData: [],
      totalWidth: 0,
      columns: [],
      selectedRowKeys: [],
      detailPage: 1,
      detailPageSize: 1,
      detailTotal: 0,
      detailLoading: false,
      detailTableData: [],
      detailTotalWidth: 0,
      detailColumns: [],
      vendorSelectData: [],
      searchLoading: false,
      rowID: '',
      exportLoading: false,
      detailExportBtnLoading: false
    };
    // 主列表表头数据
    this.staticColumns = [{
      key: 1,
      title: '入库单号',
      dataIndex: 'receiptNo',
      align: 'center',
      width: 150
    }, {
      key: 2,
      title: '入库类型',
      dataIndex: 'receiptType',
      align: 'center',
      width: 300
    }, {
      key: 3,
      title: '入库科室',
      dataIndex: 'receiptLocDesc',
      align: 'center',
      width: 100
    }, {
      key: 4,
      title: '入库日期',
      dataIndex: 'receiptDate',
      align: 'center',
      width: 100
    }, {
      key: 5,
      title: '供应商',
      dataIndex: 'supplierDesc',
      align: 'center',
      width: 100
    }, {
      key: 6,
      title: '关联入库单号',
      dataIndex: 'associatedOrderNo',
      align: 'center',
      width: 100
    }, {
      key: 7,
      title: '医院进价金额',
      dataIndex: 'hospRpAmt',
      align: 'center',
      width: 100
    }, {
      key: 8,
      title: '售价金额',
      dataIndex: 'spAmt',
      align: 'center',
      width: 100
    }, {
      key: 9,
      title: '进销差额',
      dataIndex: 'difference',
      align: 'center',
      width: 100
    }, {
      key: 10,
      title: '接收人',
      dataIndex: 'receiverUser',
      align: 'center',
      width: 100
    }, {
      key: 11,
      title: '接收状态',
      dataIndex: 'receiverStatus',
      align: 'center',
      width: 100
    }];
    // 明细列表表头数据
    this.staticDetailColumns = [{
      key: 1,
      title: '产品代码',
      dataIndex: 'productCode',
      align: 'center',
      width: 150
    }, {
      key: 2,
      title: '产品描述',
      dataIndex: 'productDesc',
      align: 'center',
      width: 300
    }, {
      key: 3,
      title: '品牌',
      dataIndex: 'brandDesc',
      align: 'center',
      width: 100
    }, {
      key: 4,
      title: '品种',
      dataIndex: 'varietiesDesc',
      align: 'center',
      width: 100
    }, {
      key: 5,
      title: '规格型号',
      dataIndex: 'stockSpec',
      align: 'center',
      width: 100
    }, {
      key: 6,
      title: '进口国产',
      dataIndex: 'operTypeDesc',
      align: 'center',
      width: 100
    }, {
      key: 7,
      title: '产地',
      dataIndex: 'placeOrigin',
      align: 'center',
      width: 100
    }, {
      key: 8,
      title: '生产厂家',
      dataIndex: 'manufDesc',
      align: 'center',
      width: 100
    }, {
      key: 9,
      title: '厂家生产编号',
      dataIndex: 'manufProductCode',
      align: 'center',
      width: 100
    }, {
      key: 10,
      title: '生产日期',
      dataIndex: 'productionDate',
      align: 'center',
      width: 100
    }, {
      key: 11,
      title: '批号',
      dataIndex: 'batchNumber',
      align: 'center',
      width: 100
    }, {
      key: 12,
      title: '注册证号',
      dataIndex: 'associatedOrderNo',
      align: 'center',
      width: 100
    }, {
      key: 13,
      title: '有效期',
      dataIndex: 'effectiveDate',
      align: 'center',
      width: 100
    }, {
      key: 14,
      title: '数量',
      dataIndex: 'num',
      align: 'center',
      width: 100
    }, {
      key: 15,
      title: '单位',
      dataIndex: 'unitDesc',
      align: 'center',
      width: 100
    }, {
      key: 16,
      title: '发票号',
      dataIndex: 'invoiceNo',
      align: 'center',
      width: 100
    }, {
      key: 17,
      title: '发票日期',
      dataIndex: 'invoiceDate',
      align: 'center',
      width: 100
    }, {
      key: 18,
      title: '医院进价金额',
      dataIndex: 'hospRpAmt',
      align: 'center',
      width: 100
    }, {
      key: 19,
      title: '售价金额',
      dataIndex: 'spAmt',
      align: 'center',
      width: 100
    }, {
      key: 20,
      title: '进销差价',
      dataIndex: 'difference',
      align: 'center',
      width: 100
    }];
  }

  componentDidMount() {
    let newCategory;
    if ('paras' in this.props && this.props.paras && this.props.paras.params) { // 侧菜单获取类别参数
      newCategory = this.props.paras.params;
    } else {
      if ('location' in this.props && this.props.location.state && this.props.location.state.params) { // 头菜单获取类别参数
        newCategory = this.props.location.state.params;
        React.$setSessionData('warehousingReview', newCategory, false);
      } else { // 头菜单刷新界面时获取类别
        newCategory = React.$getSessionData('warehousingReview', false);
      }
    }
    let categoryData = Util.getObjByUrlStr(newCategory);
    this.setState({ category: newCategory, categoryData }, () => {
      this.getSelectData();
      this.getTableColumns();
      this.getDetailTableColumns();
    });
  }

  // 获取下拉框数据
  getSelectData = async () => {
    try {
      let { queryParams, userData, category } = this.state;
      let selectCode = Util.getValueByUrlStr(category, 'selectCode');
      let componentName = Util.getValueByUrlStr(category, 'componentName');
      let groupType = Util.getValueByUrlStr(category, 'groupType');
      if (!selectCode) return;
      let data = {
        params: [{
          hospID: userData?.hospID || '',
          groupType
        }]
      }
      let res = await React.$asyncPost(this, selectCode, data);
      queryParams.inOpLocID = componentName === 'SightTransferReceipt' ? undefined : (userData?.locID || undefined); // 转移接收不默认转出科室默认转入科室
      queryParams.toLocID = componentName === 'SightTransferReceipt' ? (userData?.locID || undefined) : undefined;
      queryParams.startDate = res.result?.startDate || queryParams.startDate;
      queryParams.endDate = res.result?.endDate || queryParams.endDate;
      queryParams.status = (componentName === 'SightTransferReceipt' ? '30' : (componentName === 'PriceAdjustBillReviewList' ? 'No' : (componentName === 'PriceAdjustBillEffect' ? 'Audit' : '20')));
      this.setState({ selectData: res.result, queryParams }, () => {
        this.getTableData();
      });
    } catch (error) {
      this.setState({ selectData: {} });
    }
  }

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

  // 获取表头数据
  getTableColumns = async () => {
    try {
      const { category } = this.state;
      let componentName = Util.getValueByUrlStr(category, 'componentName');
      if (!componentName) return;
      let data = {
        params: [{
          compontName: componentName,
          type: 'C',
        }]
      }
      let res = await React.$asyncPost(this, '01040073', data);
      let columns = res.result && res.result.C && res.result.C.length > 0 ? res.result.C : [];
      if (columns && columns.length > 0) {
        columns = columns.map(item => {
          return {
            ...item,
            render: (text, record) => {
              if (item.dataIndex === 'urgentSign' && (text === '一级加急' || text === '二级加急')) { // 加急标志
                return (
                  <Tag style={{ fontWeight: 'normal' }} color={text === '一级加急' ? '#FF3D00' : (text === '二级加急' ? '#FA8C17' : '')}>{text}</Tag>
                );
              } else {
                return (
                  <Tooltip title={text}>
                    <span className="ellipsis" style={{ width: '100%', display: 'block' }}>{text}</span>
                  </Tooltip>
                );
              }
            },
          }
        })
        this.setState({
          columns,
          totalWidth: res.totalWidth
        })
      }
    } catch (error) {
      console.log(error)
    }
  }

  // 修改查询条件
  handleModifyQueryParams = (dataIndex, value) => {
    let { queryParams } = this.state;
    queryParams[dataIndex] = value;
    this.setState({}, () => {
      dataIndex !== 'inputDesc' && this.handleQuery();
    });
  }

  // 查询
  handleQuery = () => {
    this.setState({ page: 1, rowID: '', detailTableData: [], selectedRowKeys: [] }, () => {
      this.getTableData();
    })
  }

  // 获取列表数据
  getTableData = async () => {
    try {
      let { queryParams, pageSize, page, category } = this.state;
      let idIndex = Util.getValueByUrlStr(category, 'idIndex');
      let queryCode = Util.getValueByUrlStr(category, 'queryCode');
      let componentName = Util.getValueByUrlStr(category, 'componentName');
      let groupType = Util.getValueByUrlStr(category, 'groupType');
      if (!queryCode || !idIndex) return;
      this.setState({ loading: true });
      let locKey = componentName === 'SightWarehousingReview' ? 'inOpLocID' : ((componentName === 'SightIssueApproval' || componentName === 'SightTransferReceipt') ? 'frLocID' : 'locID');
      let data = {
        params: [{
          ...queryParams,
          [locKey]: queryParams?.inOpLocID || '',
          statusID: queryParams?.status || '', // 状态
          groupType
        }],
        pagination: [{
          pageSize,
          currentPage: page
        }]
      }
      let res = await React.$asyncPost(this, queryCode, data);
      let tableData = res.result && 'rows' in res.result ? Util.addKeyValueToDataSource(res.result.rows, idIndex) : [];
      this.setState({ tableData, total: res.result.total, loading: false, detailTableData: [] });
    } catch (error) {
      this.setState({ tableData: [], total: 0, loading: false, detailTableData: [] });
    }
  }

  // 分页操作
  compilePage = (page, pageSize) => {
    this.setState({ page, pageSize }, () => {
      this.getTableData();
    })
  }

  // 操作行
  onClickRowPublic = (record) => {
    const { category } = this.state;
    let idIndex = Util.getValueByUrlStr(category, 'idIndex');
    return {
      // 单击行选中
      onClick: () => {
        if (this.state.rowID === '' || (this.state.rowID && (this.state.rowID !== record[idIndex]))) {
          this.setState({ rowID: record[idIndex] }, () => {
            this.queryRowDataByID();
          });
        } else {
          this.setState({ rowID: '', detailTableData: [], selectedRowKeys: [] });
        }
      }
    }
  }

  // 选中行操作
  setRowClassNamePublic = (record) => {
    const { category } = this.state;
    let idIndex = Util.getValueByUrlStr(category, 'idIndex');
    return record[idIndex] === this.state.rowID ? 'clickRowStyle' : '';
  }

  // 获取明细列表表头数据
  getDetailTableColumns = async () => {
    try {
      const { category } = this.state;
      let componentName = Util.getValueByUrlStr(category, 'componentName');
      let isShowDetailTable = componentName === 'PriceAdjustBillReviewList' || componentName === 'PriceAdjustBillEffect' ? 'N' : 'Y';
      if (!componentName || isShowDetailTable === 'N') return;
      let data = {
        params: [{
          compontName: componentName + 'Detail',
          type: 'C',
        }]
      }
      let res = await React.$asyncPost(this, '01040073', data);
      let columns = res.result && res.result.C && res.result.C.length > 0 ? res.result.C : [];
      if (columns && columns.length > 0) {
        columns = columns.map(item => {
          return {
            ...item,
            render: (text, record) => {
              if (item.dataIndex === 'urgentSign' && (text === '一级加急' || text === '二级加急')) { // 加急标志
                return (
                  <Tag style={{ fontWeight: 'normal' }} color={text === '一级加急' ? '#FF3D00' : (text === '二级加急' ? '#FA8C17' : '')}>{text}</Tag>
                );
              } else {
                return (
                  <Tooltip title={text}>
                    <span className="ellipsis" style={{ width: '100%', display: 'block' }}>{text}</span>
                  </Tooltip>
                );
              }
            },
          }
        })
        this.setState({
          detailColumns: columns,
          detailTotalWidth: res.totalWidth
        })
      }
    } catch (error) {
      console.log(error)
    }
  }

  // 查询明细
  queryRowDataByID = async () => {
    try {
      this.setState({ detailLoading: true });
      const { category, rowID } = this.state;
      let idIndex = Util.getValueByUrlStr(category, 'idIndex');
      let queryDetailCode = Util.getValueByUrlStr(category, 'queryDetailCode');
      let groupType = Util.getValueByUrlStr(category, 'groupType');
      if (!queryDetailCode) return;
      let data = {
        params: [{
          [idIndex]: rowID,
          groupType
        }]
      }
      let res = await React.$asyncPost(this, queryDetailCode, data);
      this.setState({ detailTableData: Util.addKeyValueToDataSource(res.result?.detailInfo || []), detailLoading: false });
    } catch (error) {
      console.log(error)
      this.setState({ detailLoading: false });
    }
  }

  // 明细列表分页切换
  // handleDetailPageChange = (page, pageSize) => {
  //   this.setState({ detailPage: page, detailPageSize: pageSize }, () => {
  //     this.getDetailTableData();
  //   })
  // }

  // 供应商搜索事件 
  // handleChargeSearch = (value) => {
  //   this.setState({ searchLoading: true });
  //   this.fetchCharge(value, (data) => {
  //     this.setState({ vendorSelectData: data, searchLoading: false });
  //   });
  // }

  // 获取远程搜索下拉数据
  // fetchCharge = (value, callback) => {
  //   value = value.replace(/^\s+/, '').replace(/\s+$/, '');
  //   if (value === '') {
  //     let resData = [];
  //     callback(resData);
  //     return;
  //   }
  //   if (this.timeout) {
  //     clearTimeout(this.timeout);
  //     this.timeout = null;
  //   }
  //   function fakeCharge() {
  //     let data = {
  //       params: [{
  //         desc: value,
  //         type: 'M'
  //       }]
  //     }
  //     $http.post('urlS', this, {
  //       code: '02020353',
  //       data,
  //       success: function (res) {
  //         if (res.errorCode === '0') {
  //           callback(res?.vendor || []);
  //         }
  //       }
  //     });
  //   }
  //   this.timeout = setTimeout(fakeCharge, 300);
  // }

  // 点击input框时阻止事件冒泡
  handleStopPropagation = (e) => {
    e?.stopPropagation();
  }

  // 行操作审核
  handleExamine = (record, e, isAudit) => {
    this.handleStopPropagation(e);
    const { category } = this.state;
    let idIndex = Util.getValueByUrlStr(category, 'idIndex');
    this.handleBatchApproval([record[idIndex]], isAudit);
  }

  // 批量审核/接收
  handleBatchApproval = async (batchData, isAudit = 'Y') => {
    try {
      const { category, selectedRowKeys } = this.state;
      let examineCode = Util.getValueByUrlStr(category, 'examineCode');
      let componentName = Util.getValueByUrlStr(category, 'componentName');
      let idIndex = Util.getValueByUrlStr(category, 'idIndex');
      let groupType = Util.getValueByUrlStr(category, 'groupType');
      let idIndexArr = idIndex + 'Arr';
      if (!examineCode || !idIndexArr) return;
      let data = {
        params: [{
          [idIndexArr]: batchData && batchData.length > 0 ? batchData : selectedRowKeys,
          // 状态;审核audit  撤销审核 cancelAudit  生效 effect
          status: componentName === 'PriceAdjustBillReviewList' ? (isAudit === 'Y' ? 'audit' : 'cancelAudit') : (componentName === 'PriceAdjustBillEffect' ? 'effect' : undefined),
          groupType
        }]
      }
      let res = await React.$asyncPost(this, examineCode, data);
      message.success(res?.errorMessage || '操作成功');
      this.setState({ selectedRowKeys: [] });
      this.getTableData();
    } catch (error) {
      console.log(error);
    }
  }

  // 根据组件名获取对应的描述
  getTitleByComponentName = () => {
    const { category } = this.state;
    const componentName = Util.getValueByUrlStr(category, 'componentName');
    return componentName === 'SightWarehousingReview' ? '入库' : (
      componentName === 'SightIssueApproval' ? '出库' : (
        componentName === 'ReturnVPAudit' ? '退货' : (
          componentName === 'SightTransferReceipt' ? '转出' : (
            componentName === 'PriceAdjustBillReviewList' || componentName === 'PriceAdjustBillEffect' ? '调价' : '单据'))))
  }

  setDetailRowClassName = (record) => {
    return record?.presChange === '是' ? 'common-row-color-FDECF2' : '';
  }

  // 导出
  handleExport = async () => {
    try {
      let { categoryData, queryParams, pageSize, page, category } = this.state;
      let idIndex = Util.getValueByUrlStr(category, 'idIndex');
      let queryCode = Util.getValueByUrlStr(category, 'queryCode');
      let componentName = Util.getValueByUrlStr(category, 'componentName');
      let groupType = Util.getValueByUrlStr(category, 'groupType');
      if (!queryCode || !idIndex) return;
      this.setState({ exportLoading: true });
      let locKey = componentName === 'SightWarehousingReview' ? 'inOpLocID' : ((componentName === 'SightIssueApproval' || componentName === 'SightTransferReceipt') ? 'frLocID' : 'locID');
      let data = {
        params: [{
          ...queryParams,
          [locKey]: queryParams?.inOpLocID || '',
          statusID: queryParams?.status || '', // 状态
          groupType
        }],
        pagination: [{
          pageSize,
          currentPage: page
        }]
      }
      let res = await React.$asyncPost(this, categoryData.mainListExportCode, data);
      if (categoryData?.ReactExportERPFlag === 'Y') { // 前端导出ERP标志
        let columns = res.result?.columns || [];
        let tableData = res.result?.rows || [];
        if (columns && columns.length > 0 && tableData && tableData.length > 0) {
          handleExcel.exportExcel(columns, tableData, res.result?.fileName || '出库审核', '', res.result?.type || 'xlsx', res.result?.sheetName || 'mySheet');
        } else {
          message.error('前端导出异常，请检查返回数据！');
        }
      } else {
        handleExcel.downloadExcel(res.result);
      }
      this.setState({ exportLoading: false });
    } catch (error) {
      this.setState({ exportLoading: false });
    }
  }

  // 明细导出
  handleDetailExport = async (record, e) => {
    try {
      this.handleStopPropagation(e);
      const { categoryData } = this.state;
      if (!(categoryData && categoryData.idIndex && categoryData.detailExportCode)) {
        message.error('导出接口未配置或主列表id未定义，请检查配置项！');
        return
      };
      this.setState({ detailExportBtnLoading: true });
      let data = {
        params: [{
          [categoryData.idIndex]: record[idIndex],
          groupType: categoryData?.groupType || undefined, //  H 医院   G集团
        }]
      }
      let res = await React.$asyncPost(this, categoryData.detailExportCode, data);
      handleExcel.downloadExcel(res.result);
      this.setState({ detailExportBtnLoading: false });
    } catch (error) {
      this.setState({ detailExportBtnLoading: false });
    }
  }

  render() {
    let { category, categoryData, selectData, queryParams, page, total, loading, tableData, totalWidth, columns, selectedRowKeys, detailLoading, detailTableData, detailTotalWidth, detailColumns, exportLoading } = this.state;
    let rowSelection = {
      selectedRowKeys,
      onChange: (selectedRowKeys, selectedRows) => {
        this.setState({
          selectedRowKeys,
        })
      },
      getCheckboxProps: record => ({
        disabled: componentName === 'SightTransferReceipt' ? record.statusCode !== '30' : (componentName === 'PriceAdjustBillReviewList' ? false : (componentName === 'PriceAdjustBillEffect' ? record.statusCode !== 'Audit' : record.statusCode !== '20')),
      }),
    };

    // 入库审核(SightWarehousingReview)/出库审核(SightIssueApproval)/转移入库接收(SightTransferReceipt)
    let componentName = Util.getValueByUrlStr(category, 'componentName');
    let isShowDetailTable = componentName === 'PriceAdjustBillReviewList' || componentName === 'PriceAdjustBillEffect' ? 'N' : 'Y';

    // 列表操作
    const operationObj = {
      width: categoryData?.detailExportCode ? 120 : 100,
      title: '操作',
      align: 'center',
      fixed: isShowDetailTable === 'N' ? 'right' : null,
      key: 'operation',
      render: (text, record) => (
        <>
          {record && ((componentName === 'SightTransferReceipt' && record.statusCode === '30') || record.statusCode === '20' || (componentName === 'PriceAdjustBillReviewList' && record.statusCode === 'No') || (componentName === 'PriceAdjustBillEffect' && record.statusCode === 'Audit')) ? (
            <span className="span" onClick={(e) => this.handleExamine(record, e)}>
              {componentName === 'SightTransferReceipt' ? '接收' : (componentName === 'PriceAdjustBillEffect' ? '立即生效' : '审核')}
            </span>
          ) : (componentName === 'PriceAdjustBillReviewList' && record.statusCode === 'Audit' ? (
            <Popconfirm
              title="撤销后不可恢复，确定撤销吗?"
              onConfirm={(e) => this.handleExamine(record, e, 'N')}
            >
              <span className="span common-record-delete-span">撤销审核</span>
            </Popconfirm>
          ) : (
            <span
              style={{ color: '#999', cursor: 'no-drop', fontWeight: 'normal' }}
              onClick={this.handleStopPropagation}
            >
              {componentName === 'SightTransferReceipt' ? '接收' : (componentName === 'PriceAdjustBillEffect' ? '立即生效' : '审核')}
            </span>
          ))}
          {categoryData?.detailExportCode ? (
            <>
              <Divider type="vertical" />
              <span className="span" onClick={(e) => this.handleDetailExport(record, e)}>
                {categoryData?.detailExportBtnTitle || '导出'}
              </span>
            </>
          ) : ''}
        </>
      ),
    };

    let locKey = componentName === 'SightWarehousingReview' ? 'inOpLoc' : 'loc';
    return (
      <div className="table-body-height">
        <Card
          size="small"
          bordered={false}
          title={(
            <div className="card-title-left-img">
              <img src={iconInquire} alt="" />
              {this.getTitleByComponentName()}单列表
            </div>
          )}
        >
          <div className="flex-between-center" style={{ marginBottom: 12 }}>
            <div className="flex-align-items">
              {componentName === 'PriceAdjustBillReviewList' || componentName === 'PriceAdjustBillEffect' ? '' : ( // 调价单审核和生效不展示
                <>
                  <span className="common-input-label">{this.getTitleByComponentName()}科室：</span>
                  <Select
                    allowClear
                    showSearch
                    placeholder="请选择"
                    optionFilterProp="seachprop"
                    value={queryParams.inOpLocID}
                    onChange={e => this.handleModifyQueryParams('inOpLocID', e)}
                    style={{ width: '160px', marginRight: 12 }}
                  >
                    {React.$SelectOptions(selectData && locKey in selectData ? selectData[locKey] : [])}
                  </Select>

                  <span className="common-input-label">{componentName === 'SightIssueApproval' || componentName === 'SightTransferReceipt' ? '转入科室' : '供应商'}：</span>
                  {componentName === 'SightIssueApproval' || componentName === 'SightTransferReceipt' ? (
                    <Select
                      allowClear
                      showSearch
                      placeholder="请选择"
                      optionFilterProp="seachprop"
                      value={queryParams.toLocID}
                      onChange={e => this.handleModifyQueryParams('toLocID', e)}
                      style={{ width: '160px', marginRight: 12 }}
                    >
                      {React.$SelectOptions(selectData?.toLoc || [])}
                    </Select>
                  ) : (
                    <Select
                      allowClear
                      showSearch
                      placeholder="请选择"
                      optionFilterProp="seachprop"
                      value={queryParams.vendorID}
                      style={{ width: '160px', marginRight: 12 }}
                      onChange={e => this.handleModifyQueryParams('vendorID', e)}
                    >
                      {React.$SelectOptions(selectData?.vendor || [])}
                    </Select>
                  )}
                </>
              )}
              <span className="common-input-label">
                {(
                  componentName === 'SightIssueApproval' ? '出库' : (
                    componentName === 'SightTransferReceipt' ? '操作' : (
                      componentName === 'ReturnVPAudit' ? '制单' : (
                        componentName === 'PriceAdjustBillReviewList' || componentName === 'PriceAdjustBillEffect' ? '调价' : '入库')))) + '日期：'}
              </span>
              <RangeDatePicker
                width="300px"
                format="YYYY-MM-DD"
                margin="0 12px"
                isChange={true}
                endDate={queryParams.endDate}
                startDate={queryParams.startDate}
                label=""
                endChange={e => this.handleModifyQueryParams('endDate', e)}
                startChange={e => this.handleModifyQueryParams('startDate', e)}
              />
              {componentName === 'PriceAdjustBillReviewList' || componentName === 'PriceAdjustBillEffect' ? ( // 调价单审核和生效展示产品名称
                <>
                  <span className="common-input-label">产品名称：</span>
                  <Input
                    title="输入内容后可回车检索"
                    placeholder="请输入名称后回车确定产品目录"
                    style={{ width: '250px', marginRight: 12 }}
                    value={queryParams.inputDesc}
                    onChange={e => this.handleModifyQueryParams('inputDesc', e.target.value)}
                    onPressEnter={this.handleQuery}
                  />
                </>
              ) : ''}
              <span className="common-input-label">{componentName === 'SightTransferReceipt' ? '接收状态' : (componentName === 'PriceAdjustBillEffect' ? '生效状态' : '审核状态')}：</span>
              <Radio.Group
                value={queryParams.status}
                style={{ marginRight: 12 }}
                onChange={e => this.handleModifyQueryParams('status', e.target.value)}
              >
                <Radio value={componentName === 'SightTransferReceipt' ? '30' : (componentName === 'PriceAdjustBillReviewList' ? 'No' : (componentName === 'PriceAdjustBillEffect' ? 'Audit' : '20'))}>
                  {componentName === 'SightTransferReceipt' ? '未接收' : (componentName === 'PriceAdjustBillEffect' ? '未生效' : '未审核')}
                </Radio>
                <Radio value={componentName === 'SightTransferReceipt' ? '40' : (componentName === 'PriceAdjustBillReviewList' ? 'Audit' : (componentName === 'PriceAdjustBillEffect' ? 'Yes' : '30'))}>
                  {componentName === 'SightTransferReceipt' ? '已接收' : (componentName === 'PriceAdjustBillEffect' ? '已生效' : '已审核')}
                </Radio>
              </Radio.Group>
              <Button type="primary" onClick={this.handleQuery}>查询</Button>
              {categoryData?.mainListExportCode ? (
                <Button ghost type="primary" style={{ marginLeft: '12px' }} loading={exportLoading} onClick={this.handleExport}>
                  {categoryData?.mainListExportBtnTitle || '导出'}
                </Button>
              ) : ''}
            </div>
            <div>
              {componentName === 'PriceAdjustBillReviewList' && queryParams.status === 'Audit' ? ( // 生效单审核界面可以撤销审核
                selectedRowKeys && selectedRowKeys.length > 0 ? (
                  <Popconfirm
                    title="撤销后不可恢复，确定撤销吗?"
                    onConfirm={() => this.handleBatchApproval('', 'N')}
                  >
                    <Button
                      ghost
                      type="danger"
                    >
                      撤销审核
                    </Button>
                  </Popconfirm>
                ) : (
                  <Button
                    ghost
                    disabled
                    type="danger"
                  >
                    撤销审核
                  </Button>
                )
              ) : (
                <Button
                  ghost
                  type="primary"
                  disabled={!(selectedRowKeys && selectedRowKeys.length > 0)}
                  onClick={() => this.handleBatchApproval('')}
                >
                  批量{componentName === 'SightTransferReceipt' ? '接收' : (componentName === 'PriceAdjustBillEffect' ? '生效' : '审核')}
                </Button>
              )}
            </div>
          </div>
          <PubilcTablePagination
            param={{
              page,
              total,
              loading,
              componentName,
              data: tableData, // 表格数据
              x: totalWidth, // 表格的宽度
              y: isShowDetailTable === 'N' ? store.getState().tableHeight.y + 49 : store.getState().tableHeight.y / 2 - 50,
              height: isShowDetailTable === 'N' ? store.getState().tableHeight.y + 99 : store.getState().tableHeight.y / 2 + 'px',
              columns: columns && columns.length > 0 ? [...columns, operationObj] : [...this.staticColumns, operationObj], // 表头配置
            }}
            rowSelectionPublic={rowSelection}
            compilePage={this.compilePage}
            getColumns={this.getTableColumns}
            onClickRowPublic={this.onClickRowPublic}
            setRowClassNamePublic={this.setRowClassNamePublic}
          />
        </Card>
        {isShowDetailTable === 'N' ? '' : (
          <>
            <div className="common-query-split-line" style={{ height: 8 }}></div>
            <Card
              size="small"
              bordered={false}
              title={(
                <div className="card-title-left-img">
                  <img src={iconListvisits} alt="" />
                  {this.getTitleByComponentName()}单明细
                </div>
              )}
            >
              <PubilcTablePagination
                param={{
                  // page: detailPage,
                  // total: detailTotal,
                  loading: detailLoading,
                  data: detailTableData, // 表格数据
                  x: detailTotalWidth, // 表格的宽度
                  y: store.getState().tableHeight.y / 2 - 30,
                  componentName: componentName + 'Detail',
                  height: store.getState().tableHeight.y / 2 + 27 + 'px',
                  columns: detailColumns && detailColumns.length > 0 ? detailColumns : this.staticDetailColumns, // 表头配置
                }}
                // compilePage={this.handleDetailPageChange}
                getColumns={this.getDetailTableColumns}
                setRowClassNamePublic={this.setDetailRowClassName}
              />
            </Card>
          </>
        )}
      </div>
    )
  }
};

export default WarehousingReview;

/*
 * 菜单参数配置及说明
 * 示例：params=componentName:SightWarehousingReview&selectCode:17030029&queryCode:17030030&idIndex:metStkRecID&examineCode:17030039&queryDetailCode:17030031
 * componentName - 组件名
 * selectCode - 初始化接口对应的code
 * queryCode - 查询接口
 * idIndex - 主列表行ID字段名
 * examineCode - 审核接口对应code
 * queryDetailCode - 明细列表对应code
 * 入库审核：params=componentName:SightWarehousingReview&selectCode:17030029&queryCode:17030030&idIndex:metStkRecID&examineCode:17030039&queryDetailCode:17030031
 * 转移审核：params=componentName:SightIssueApproval&selectCode:17030059&queryCode:17030060&idIndex:metStkTransferID&examineCode:17030066&queryDetailCode:17030061
 * 转移入库接收：params=componentName:SightTransferReceipt&selectCode:17030059&queryCode:17030060&idIndex:metStkTransferID&examineCode:17030067&queryDetailCode:17030061
 * 退货审核：params=componentName:ReturnVPAudit&selectCode:17030036&queryCode:17030040&idIndex:stkReturnID&examineCode:17030045&queryDetailCode:17030041
 * 调价单审核: params=componentName:PriceAdjustBillReviewList&selectCode:17060015&queryCode:17060016&idIndex:metAdjPriceID&examineCode:17060020
 * 调价单生效: params=componentName:PriceAdjustBillEffect&selectCode:17060015&queryCode:17060016&idIndex:metAdjPriceID&examineCode:17060020
 * */