import React, { Component } from 'react';
import { Form } from '@ant-design/compatible';
// import '@ant-design/compatible/assets/index.css';
import { Layout, Spin, Button, Row, Col, message } from 'antd-v4';
import * as commonFunc from '@/components/Common/commonFunc';/* 通用单据方法 */ /* 通用单据方法 */
import StaticEditTable from '@/components/Common//CommonTable';/* 可编辑表格 */
import StaticEditTree from '@/components/Common/Tree/StaticTree';
import CommonBase from '@/components/Common/CommonBase';/* 获取配置及数据 */
import * as commonBusiness from '@/components/Common//commonBusiness';/* 单据业务功能 */
import SearchComponent from '@/components/Common/SearchComponent';
import AntdDraggableModal from '@/components/Common/AntdDraggableModal';
import * as commonUtils from '@/utils/utils';
import ShowType from '@/components/Common/CommonComponent';
import CommonListEvent from '@/components/Common/CommonListEvent';

const { Content } = Layout;
/**
 此组件是用于色序选择颜色弹窗 区别在于列可编辑
 */
class CommonList extends Component {
  constructor(props) {
    super(props);
    // this.treeName = null;
    // this.treeCheckedKeys = null;
    this.state = {
    };
  }
  componentWillReceiveProps(nextProps) {
    const {
      slaveData, selectedRowKeys, sModelsType, slaveFilterData, slaveSelectedData, sisColorSelectedData,
    } = nextProps;

    if (slaveFilterData === undefined && sModelsType === 'search/sisColor') {
      if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyArr(selectedRowKeys)) {
        /*  点击字段弹窗显示的是修改后的值,而非颜色基础信息 */
        if (commonUtils.isNotEmptyArr(sisColorSelectedData) && sisColorSelectedData.length > 0) {
          sisColorSelectedData.forEach((item) => {
            const iIndex = slaveData.findIndex(child => child.sId === item.sId);
            if (iIndex > -1) {
              slaveData[iIndex].sName = item.sName;
              slaveData[iIndex].dColor = item.dColor;
            }
          });
        }
        // 修改选择色序弹出窗排序后保存的问题
        const slaveFilterData = [];
        selectedRowKeys.forEach((item) => {
          for (let i = 0; i < slaveData.length; i += 1) {
            if (item === slaveData[i].sSlaveId) {
              slaveFilterData.push(slaveData[i]);
              break;
            }
          }
        });
        // const slaveFilterData = slaveData.filter(item => selectedRowKeys.includes(item.sSlaveId));
        if (commonUtils.isNotEmptyArr(slaveFilterData)) {
          this.props.onSaveState({
            slaveFilterData, slaveSelectedRowKeys: selectedRowKeys, slaveData,
          });
        }
      }
    } else if (commonUtils.isEmptyArr(slaveFilterData) && sModelsType === 'search/commonPopup') {
      if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyArr(slaveSelectedData)) {
        this.props.onSaveState({
          slaveFilterData: slaveSelectedData,
        });
      }
    }
  }

  componentDidUpdate() {
    if (Array.isArray(this.props.slaveData) && this.props.slaveData.length) {
      if (!this.hasUpdate) {
        this.hasUpdate = true;
        this.showCacheData();
      }
    }
  }

  // 更新数据
  showCacheData = () => {
    const { props } = this;
    const { slaveSelectedRowKeys = [], app } = props;
    if (app?.isSColorSerialMemo) {
      const selectData = props.app?.sMemoData;
      if (Array.isArray(selectData)) {
        const slaveSelectedRowKeysNew = Array.isArray(selectData) ? selectData.map(i => i && i.sId).filter(Boolean) : [];
        props.onSaveState({
          slaveSelectedRowKeys: [...new Set([...slaveSelectedRowKeysNew, ...slaveSelectedRowKeys])],
          slaveFilterData: selectData.map(i => i && ({ ...i, sSlaveId: i.sId })).filter(Boolean) || [],
        });
      }
    }
  };

  handleSelect = () => {
    const { slaveFilterData, app } = this.props;
    this.props.app.currentPane.select(app.currentPane.name, app.currentPane.config, slaveFilterData);
    this.props.app.currentPane.selectCancel(app.currentPane.name);
    this.props.onSaveState({
      slaveFilterData: [],
    });
  };
  handleDoubleClickSelect = () => {
    const { slaveConfig } = this.props;
    if (commonUtils.isNotEmptyObject(slaveConfig) && !slaveConfig.bMutiSelect) { // 单选时双击选中数据
      this.handleSelect();
    }
  }
  /**   关闭   */
  handleCancelModal = () => {
    const { app } = this.props;
    this.props.app.currentPane.selectCancel(app.currentPane.name);
  };
  /**   树节点多选框选中   */
  handleTreeCheck = (checkedKeys, e) => {
    this.props.onCheck(checkedKeys, e); /* 调用CommonListEvent通用处理 */
  };
  /**   树节点选中   */
  handleTreeSelect = (name, checkedKeys, e) => {
    this.props.onSelect(name, checkedKeys, e); /* 调用CommonListEvent通用处理 */
  };

  handleTableSelectRowChangeContinue = (name, selectedRowKeys, changeValue, chooseProcessParams) => { /* 表格行选择 */
    this.props.onTableSelectRowChange(name, selectedRowKeys);
    if (name === 'slave') { /* 选择工序 从表表 */
      const {
        [`${name}Data`]: tableData, slaveConfig, fatherModelsType, sModelsType,
      } = this.props;
      const { selectedRowKeysLength } = this.props;
      const { slaveFilterData } = this.props;
      const oldSlaveFilterData = slaveFilterData === undefined ? [] : JSON.parse(JSON.stringify(slaveFilterData));
      let newSlaveFilterData = [];
      selectedRowKeys.forEach((key) => {
        const filterDataIndex = oldSlaveFilterData.findIndex(item => item.sSlaveId === key);
        if (filterDataIndex < 0) {
          newSlaveFilterData = JSON.parse(JSON.stringify(oldSlaveFilterData));
          const tableDataIndex = tableData.findIndex(item => item.sSlaveId === key);
          if (tableDataIndex > -1) {
            const newRow = JSON.parse(JSON.stringify(tableData[tableDataIndex]));
            newRow.sId = commonUtils.createSid();
            newRow.sSlaveId = newRow.sId;
            newRow.handleType = 'add';
            newRow.key = newRow.sId;
            newSlaveFilterData.push(newRow);
          }
        } else {
          /* 连续点击 复制数据 */
          newSlaveFilterData = JSON.parse(JSON.stringify(oldSlaveFilterData));
          const newRow = JSON.parse(JSON.stringify(oldSlaveFilterData[filterDataIndex]));
          newRow.sId = commonUtils.createSid();
          newRow.sSlaveId = newRow.sId;
          newRow.handleType = 'add';
          newRow.key = newRow.sId;
          newSlaveFilterData.push(newRow);
        }
      });
      let sDeliverRemark = '';
      if (sModelsType === 'search/commonPopup') { /* 选择成品库存 改变时候 增加数量信息提示 */
        let dChooseProductQty = 0;
        let dSrcQty = 0;
        let dMinsQty = 0; /* 欠数 */
        newSlaveFilterData.forEach((item, index) => {
          if (index === 0) {
            dSrcQty += commonUtils.isNull(item.dSReserve1, 0); /* 源单数量取其中一条 */
          }
          dChooseProductQty += commonUtils.isNull(item.dProductQty, 0); /* 库存数量叠加 */
        });
        dMinsQty = commonUtils.convertFixNum(dSrcQty, 2) - commonUtils.convertFixNum(dChooseProductQty, 2);
        sDeliverRemark = `源单数量：${dSrcQty}  已选数量：${dChooseProductQty}  欠数：${dMinsQty}`;
      }

      this.props.onSaveState({
        slaveFilterData: newSlaveFilterData, sDeliverRemark,
      });
      if (chooseProcessParams) {
        let modalVisible = false;
        let slaveSelectOneData = {};
        let slaveSelectOneDataIndex = -1;
        if (commonUtils.isNotEmptyArr(tableData)) {
          if (selectedRowKeys instanceof Array) { // 多选情况下
            if (commonUtils.isEmpty(selectedRowKeysLength) || (selectedRowKeys.length - selectedRowKeysLength) > 0) {
              modalVisible = true;
            }
            slaveSelectOneDataIndex = tableData.findIndex(item => item.sId === selectedRowKeys[selectedRowKeys.length - 1]); // 多选选择最后一个
          } else { // 单选情况下
            slaveSelectOneDataIndex = tableData.findIndex(item => item.sId === selectedRowKeys);
          }
          if (slaveSelectOneDataIndex > -1) {
            slaveSelectOneData = tableData[slaveSelectOneDataIndex];
          }
        }
        // let masterData = {};
        const sProcessParamsSelects = [];
        let paramType = '';
        if (commonUtils.isNotEmptyObject(slaveSelectOneData) && commonUtils.isNotEmptyObject(fatherModelsType)) {
          if (fatherModelsType.includes('manufacture/')) {
            paramType = slaveSelectOneData.sWorkOrderParam;
            if (commonUtils.isNotEmptyObject(slaveSelectOneData.sWorkOrderParam)) {
              slaveSelectOneData = { ...slaveSelectOneData, ...commonUtils.convertStrToObj(slaveSelectOneData.sWorkOrderParam) };
              tableData[slaveSelectOneDataIndex] = { ...tableData[slaveSelectOneDataIndex], ...slaveSelectOneData };
            }
          } else if (fatherModelsType.includes('quotation/')) {
            paramType = slaveSelectOneData.sProcessParam;
            if (commonUtils.isNotEmptyObject(slaveSelectOneData.sProcessParam)) {
              slaveSelectOneData = { ...slaveSelectOneData, ...commonUtils.convertStrToObj(slaveSelectOneData.sProcessParam) };
              tableData[slaveSelectOneDataIndex] = { ...tableData[slaveSelectOneDataIndex], ...slaveSelectOneData };
            }
          }
        }
        if (commonUtils.isNotEmptyObject(paramType)) {
          // eslint-disable-next-line no-plusplus
          for (let i = 1; i < 31; i++) {
            const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
            if (iIndex > -1 && !commonUtils.isEmpty(slaveSelectOneData[`sParam${i.toString()}`])) {
              slaveConfig.gdsconfigformslave[iIndex].showName = slaveSelectOneData[`sParam${i.toString()}`];
              slaveConfig.gdsconfigformslave[iIndex].bVisible = !slaveSelectOneData[`sParam${i.toString()}`].includes('参数值');
              /* 判断是否是sql下拉 */
              if (!commonUtils.isEmpty(slaveSelectOneData[`sParamDropDown${i.toString()}`])) {
                slaveConfig.gdsconfigformslave[iIndex].sDropDownType = 'sql';
              }
              // masterData = { ...masterNewData, ...commonUtils.convertStrToObj(slaveFilterData[0].sProcessParam) };
              sProcessParamsSelects.push(slaveConfig.gdsconfigformslave[iIndex]);
            } else if (iIndex > -1) {
              slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
            }
          }
        } else {
          modalVisible = false;
          // eslint-disable-next-line no-plusplus
          for (let i = 1; i < 31; i++) {
            const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
            if (iIndex > -1) {
              slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
            }
          }
        }
        this.props.onSaveState({
          sProcessParamsModalVisible: modalVisible,
          sProcessParamsSelects,
          slaveSelectOneDataIndex,
          selectedRowKeysLength: selectedRowKeys.length,
        });
      }
    }
  }

  handleTableSelectRowChange = (name, selectedRowKeys, changeValue, chooseProcessParams) => { /* 表格行选择 */
    const bContinueClick = false;
    if (bContinueClick) { /* 连续点击 */
      this.handleTableSelectRowChangeContinue(name, selectedRowKeys, changeValue, chooseProcessParams);
    } else {
      this.props.onTableSelectRowChange(name, selectedRowKeys);
      if (name === 'slave') { /* 选择工序 从表表 */
        const { [`${name}Data`]: tableData, slaveConfig, fatherModelsType } = this.props;
        const { selectedRowKeysLength, slaveFilterData, slaveData } = this.props;
        const oldSlaveFilterData = slaveFilterData === undefined ? [] : JSON.parse(JSON.stringify(slaveFilterData));
        const newSlaveFilterData = [];
        /* 处理搜索后的右侧选中数据源不在左侧slaveData数据源中问题 */
        if (commonUtils.isNotEmptyArr(oldSlaveFilterData)) {
          oldSlaveFilterData.forEach((item) => {
            const iIndex = slaveData.findIndex(itemFilter => itemFilter.sSlaveId === item.sSlaveId);
            if (iIndex === -1) {
              newSlaveFilterData.push(item);
            }
          });
        }
        selectedRowKeys.forEach((key) => {
          const filterDataIndex = oldSlaveFilterData.findIndex(item => item.sSlaveId === key);
          if (filterDataIndex < 0) {
            const tableDataIndex = tableData.findIndex(item => item.sSlaveId === key);
            newSlaveFilterData.push({ ...tableData[tableDataIndex] });
          } else {
            const iIndex = newSlaveFilterData.findIndex(item => oldSlaveFilterData[filterDataIndex].sSlaveId === item.sSlaveId); /* 解决删除后重新添加相同颜色 重复问题 */
            if (iIndex === -1) {
              newSlaveFilterData.push({ ...oldSlaveFilterData[filterDataIndex] });
            }
          }
        });
        this.props.onSaveState({
          slaveFilterData: newSlaveFilterData,
        });
        if (chooseProcessParams) {
          let modalVisible = false;
          let slaveSelectOneData = {};
          let slaveSelectOneDataIndex = -1;
          if (commonUtils.isNotEmptyArr(tableData)) {
            if (selectedRowKeys instanceof Array) { // 多选情况下
              if (commonUtils.isEmpty(selectedRowKeysLength) || (selectedRowKeys.length - selectedRowKeysLength) > 0) {
                modalVisible = true;
              }
              slaveSelectOneDataIndex = tableData.findIndex(item => item.sId === selectedRowKeys[selectedRowKeys.length - 1]); // 多选选择最后一个
            } else { // 单选情况下
              slaveSelectOneDataIndex = tableData.findIndex(item => item.sId === selectedRowKeys);
            }
            if (slaveSelectOneDataIndex > -1) {
              slaveSelectOneData = tableData[slaveSelectOneDataIndex];
            }
          }
          // let masterData = {};
          const sProcessParamsSelects = [];
          let paramType = '';
          if (commonUtils.isNotEmptyObject(slaveSelectOneData) && commonUtils.isNotEmptyObject(fatherModelsType)) {
            if (fatherModelsType.includes('manufacture/')) {
              paramType = slaveSelectOneData.sWorkOrderParam;
            } else if (fatherModelsType.includes('quotation/')) {
              paramType = slaveSelectOneData.sProcessParam;
            }
          }
          if (commonUtils.isNotEmptyObject(paramType)) {
            // eslint-disable-next-line no-plusplus
            for (let i = 1; i < 7; i++) {
              const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
              if (iIndex > -1 && !commonUtils.isEmpty(slaveSelectOneData[`sParam${i.toString()}`])) {
                slaveConfig.gdsconfigformslave[iIndex].showName = slaveSelectOneData[`sParam${i.toString()}`];
                slaveConfig.gdsconfigformslave[iIndex].bVisible = !slaveSelectOneData[`sParam${i.toString()}`].includes('参数值');
                // masterData = { ...masterNewData, ...commonUtils.convertStrToObj(slaveFilterData[0].sProcessParam) };
                sProcessParamsSelects.push(slaveConfig.gdsconfigformslave[iIndex]);
              } else if (iIndex > -1) {
                slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
              }
            }
          } else {
            modalVisible = false;
            // eslint-disable-next-line no-plusplus
            for (let i = 1; i < 7; i++) {
              const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
              if (iIndex > -1) {
                slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
              }
            }
          }
          this.props.onSaveState({
            sProcessParamsModalVisible: modalVisible,
            sProcessParamsSelects,
            slaveSelectOneDataIndex,
            selectedRowKeysLength: selectedRowKeys.length,
          });
        }
      }
    }
  }
  handleCancelProcessParamsModalVisible = () => {
    this.props.onSaveState({
      sProcessParamsModalVisible: false,
    });
  }
  handleProcessParamsOk = () => {
    const {
      slaveData, slaveSelectOneDataIndex, slaveFilterData, sProcessParamsSelects,
    } = this.props;
    let sProcessParamStr = '';
    if (commonUtils.isNotEmptyArr(slaveData) && !commonUtils.isEmpty(slaveSelectOneDataIndex) && commonUtils.isNotEmptyArr(slaveFilterData) && commonUtils.isNotEmptyArr(sProcessParamsSelects)) {
      // eslint-disable-next-line array-callback-return
      sProcessParamsSelects.map((item) => {
        sProcessParamStr += `${item.showName}:${slaveData[slaveSelectOneDataIndex][item.sName]},`;
      });
      slaveFilterData[slaveFilterData.length - 1].sProcessParamStr = sProcessParamStr;
      slaveFilterData[slaveFilterData.length - 1] = { ...slaveFilterData[slaveFilterData.length - 1], ...slaveData[slaveSelectOneDataIndex] };
    }
    this.props.onSaveState({
      slaveFilterData,
      sProcessParamsModalVisible: false,
    });
  }
  handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData) => {
    /*   从CommonBase获取默认参数   */
    if (name === 'slaveFilter' && (sFieldName === 'sName' || sFieldName === 'dColor')) {
      const { [`${name}Data`]: tableData } = this.props;
      if (commonUtils.isNotEmptyObject(tableData)) {
        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (iIndex > -1) {
          const tableDataRowOld = tableData[iIndex];
          if (sFieldName === 'sName' && commonUtils.isNotEmptyObject(tableDataRowOld.sName) && (tableDataRowOld.sName === 'C' || tableDataRowOld.sName === 'M' || tableDataRowOld.sName === 'Y' || tableDataRowOld.sName === 'K')) {
            message.error('此颜色值禁止更改!');
            return;
          }
          const tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
          tableData[iIndex] = tableDataRow;
          this.props.onSaveState({ [`${name}Data`]: tableData });
        }
      }
    }
  }

  /* 可以刪除选中颜色，同步移除左侧勾选行 */
  handleTableDel = (name, isWait, tableSelectedRowKeys) => {
    const { slaveSelectedRowKeys } = this.props;
    if (commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
      slaveSelectedRowKeys.forEach((item, index) => {
        if (tableSelectedRowKeys.includes(item)) {
          slaveSelectedRowKeys.splice(index, 1);
        }
      });
      this.props.onDataRowDel(name, isWait, tableSelectedRowKeys);
    }
  }
  // ----------------------------数据修改回带end  ---------------------------- //

  handleDrag = (data) => {
    this.props.onSaveState({
      slaveFilterData: data,
    });
  }

  render() {
    const { pageLoading } = this.props;
    return (
      <div style={{ height: '100%' }}>
        <Spin spinning={pageLoading}>
          <div style={{ height: '100%' }}>
            <CommonListComponent
              {...this.props}
              {...this.state}
              onSelect={this.handleSelect}
              onCancel={this.handleCancelModal}
              onDoubleClick={this.handleDoubleClickSelect}
              onCheck={this.handleTreeCheck}
              onSelectTree={this.handleTreeSelect}
              onTableSelectRowChange={this.handleTableSelectRowChange}
              onProcessParamsOk={this.handleProcessParamsOk}
              onCancelProcessParamsModalVisible={this.handleCancelProcessParamsModalVisible}
              onDataChange={this.handleTableChange}
              onDataRowDel={this.handleTableDel}
              onDrag={this.handleDrag}
            />
          </div>
        </Spin>
      </div>
    );
  }
}

const CommonListComponent = Form.create({
  mapPropsToFields(props) {
    const { masterData } = props;
    const obj = commonFunc.mapPropsToFields(masterData, Form);
    return obj;
  },
})((props) => {
  const {
    form,
    onReturnForm,
    slavePagination,
    app,
    slaveData,
    sProcessParamsSelects,
    slaveSelectedRowKeys: selectedRowKeys,
    sModelsType,
  } = props;
  /*   回带表单   */
  onReturnForm(form);
  const pagination = {
    ...slavePagination,
    size: 'large',
    pageSize: 1000,
    showQuickJumper: true,
    hideOnSinglePage: true,
  };
  const tableProps = {
    ...commonBusiness.getTableTypes('slave', props),
    tableProps: {
      rowKey: 'sSlaveId', pagination, onChange: props.onTitleChange, chooseProcessParams: true, sModelsType, AutoTableHeight: 350, // chooseProcessParams为选择工序中点击工序名称表格行出现弹窗
    },
    // bContinueClick: true,
  };

  const tableFilterProps = {
    ...commonBusiness.getTableTypes('slaveFilter', props),
    tableProps: {
      rowSelection: null, rowKey: 'sSlaveId', onChange: props.onTitleChange, AutoTableHeight: 350,
    },
    onDrag: props.onDrag,
    enabled: props.enabled,
    setOpterationColumn: 'Y',
  };
  const name = 'filterTree';
  const treeProps = {
    ...commonBusiness.getTreeTypes('tree', props),
    isSearch: false,
    checkable: false,
    [`${name}Column`]: props[`${name}Column`],
    [`${name}Config`]: props[`${name}Config`],
    [`${name}Data`]: props[`${name}Data`],
    getFloatNum: props.getFloatNum,
    getSqlDropDownData: props.getSqlDropDownData,
    getSqlCondition: props.getSqlCondition,
    handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
    getDateFormat: props.getDateFormat,
    onDoubleClick: props.onDoubleClick,
    onCheck: props.onCheck,
    onSelect: props.onSelectTree,
    disabled: false,
    checkedAll: false,
    unChecked: false,
    defaultExpandAll: true,
    multiple: false,
    expandedKeys: props.expandedKeys,
  };
  const tableBelone = commonUtils.isNotEmptyObject(app.currentPane) && commonUtils.isNotEmptyObject(app.currentPane.name) && app.currentPane.bEdit ? 'none' : 'list';
  const sProcessParams = commonFunc.showMessage(app.commonConst, 'sProcessParams');/* 选择工艺参数标题 */
  const displayLeft = (sModelsType !== 'search/sisColor' && sModelsType !== 'search/commonPopup');

  const BtnSure = commonFunc.showLocalMessage(props, 'BtnSure', '确定');
  const BtnCancel = commonFunc.showLocalMessage(props, 'BtnCancel', '取消');
  return (
    <div className="modalChooseProcessContent">
      <Form >
        <Layout>
          <Layout>
            <div id="modalChooseProcess">
              <div style={{ maxHeight: '100%', zIndex: 20 }}>
                <SearchComponent {...props} />
              </div>
              <Content
                className="xly-normal-list"
                style={{ paddingLeft: '10px' }}
              >
                <Row gutter={[8, 0]}>
                  {displayLeft ?
                    <Col span={4}>
                      <div className="xly-tree-box">
                        <div className="xly-tree-title">过滤项</div>
                        <StaticEditTree {...treeProps} />
                      </div>
                    </Col> : ''
                  }
                  <Col span={sModelsType === 'search/commonPopup' ? 15 : 5}>
                    <StaticEditTable {...tableProps} footer="hidden" tableBelone="list" noVlist showConfig={props.showConfig} />
                  </Col>
                  <Col span={displayLeft ? 15 : sModelsType === 'search/commonPopup' ? 9 : 19} >
                    <StaticEditTable {...tableFilterProps} footer="hidden" tableBelone={tableBelone} noVlist dragHandle showConfig={props.showConfig} />
                  </Col>
                </Row>
              </Content>
            </div>
          </Layout>
          <div style={{ textAlign: 'right', marginRight: '9px', marginBottom: '9px' }}>
            <Button key="back" style={{ marginRight: '8px' }} onClick={props.onCancel}>{BtnCancel}</Button>
            <Button type="primary" onClick={props.onSelect}>{BtnSure}</Button>
          </div>
        </Layout>
        {
          props.sProcessParamsModalVisible ?
            <AntdDraggableModal
              width="33%"
              title={sProcessParams}
              visible={props.sProcessParamsModalVisible}
              onOk={props.onProcessParamsOk}
              onCancel={props.onCancelProcessParamsModalVisible}
              // footer={null}
            >
              <div className="sProcessParamsModal" style={{ height: '80%', overflowY: 'auto' }}>
                { commonUtils.isNotEmptyArr(sProcessParamsSelects) && commonUtils.isNotEmptyArr(selectedRowKeys) ?
                  sProcessParamsSelects.map((child) => {
                    const sMemo = child.sName.toLowerCase().endsWith('memo');
                    let enabledNew = !child.bReadonly;
                    if (child.iTag === 1) {
                      enabledNew = false;
                    } else if (child.iTag === 3) {
                      enabledNew = true;
                    }
                    const slaveSelectOneDataIndex = slaveData.findIndex(item => item.sId === selectedRowKeys[selectedRowKeys.length - 1]); // 多选选择最后一个
                    const showTypeProps = {
                      name: 'slave',
                      form: props.form,
                      record: slaveData[slaveSelectOneDataIndex],
                      sId: slaveData[slaveSelectOneDataIndex].sId,
                      getSqlDropDownData: props.getSqlDropDownData,
                      getSqlCondition: props.getSqlCondition,
                      handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
                      getFloatNum: props.getFloatNum,
                      onChange: props.onDataChange,
                      showConfig: child,
                      formItemLayout: {},
                      textArea: sMemo,
                      enabled: enabledNew,
                      dataValue: slaveData[slaveSelectOneDataIndex][child.sName],
                      bTable: true,
                      formRoute: props.formRoute,
                    };
                    return (
                      <div className="sProcessParamsModalType">
                        <span>{`${child.showName}:`}</span>
                        <ShowType {...showTypeProps} />
                      </div>
                    );
                  }) : ''
                }
              </div>
            </AntdDraggableModal>
            : ''
        }
      </Form>
    </div>
  );
});

export default CommonBase(CommonListEvent(CommonList));
