/* eslint-disable react/jsx-closing-tag-location,prefer-destructuring,no-unused-expressions,object-shorthand */
/**
 * Created by mar105 on 2019-04-03.
 */
import React, { Component } from 'react';
import { MinusCircleOutlined, PlusOutlined, SettingOutlined } from '@ant-design/icons';
import { Form, Icon as LegacyIcon } from '@ant-design/compatible';
// import '@ant-design/compatible/assets/index.css';
import { Row, Col, Button, message } from 'antd-v4';
import moment from 'moment';
import commonConfig from '../../utils/config';
import * as commonFunc from './commonFunc';
import * as commonServices from '../../services/services';
import styles from './FastFilter/FastFilter.less';
import * as commonUtils from '../../utils/utils';
import ShowType from './CommonComponent';
import StaticEditTable from './CommonTable';
import * as commonBusiness from '../Common/commonBusiness';/* 单据业务功能 */
import AntdDraggableModal from '../Common/AntdDraggableModal';

const FormItem = Form.Item;

export default class SearchComponent extends Component {
  constructor(props) {
    super(props);
    this.state = {};
    this.sDateFormat = 'YYYY-MM-DD';
  }

  async componentWillMount(sSearchSolutionId) {
    const { token, sModelsId, formSrcRoute } = this.props;
    const dataUrl = `${commonConfig.server_host}syssearch/getSyssearchData/${sModelsId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`; /* 获取快捷查找方案 */
    const dataReturn = (await commonServices.getService(token, dataUrl)).data;
    if (dataReturn.code === 1) {
      const returnData = dataReturn.dataset.rows;
      let addState = {};
      if (!commonUtils.isEmpty(sSearchSolutionId)) { // 保存后重新获取快捷查找，直接默认到最新
        const { masterData, searchRowKeys } = this.props;
        masterData.sSearchSolutionId = sSearchSolutionId;
        masterData.bCheck = true; // 为了复制到
        masterData.sSolutionName = returnData.filter(item => item.sId === sSearchSolutionId)[0].sName;
        if (commonUtils.isNotEmptyArr(searchRowKeys)) {
          searchRowKeys.forEach((item) => {
            masterData[`${item}disabled`] = false;
          });
        }
        addState.masterData = masterData;
        addState.modalVisible = false;
        addState.modalSolutionNameVisible = false;
      } else if (commonUtils.isNotEmptyArr(returnData)) { /* 初始化默认查询方案的参数 */
        const iIndex = returnData.findIndex(item => item.bDefault);
        const defaultSearchSolution = iIndex > -1 ? returnData[iIndex] : returnData[0];
        addState = await this.defaultSearchSolution(defaultSearchSolution);
      }
      this.props.onSaveState({ sGroupByList: addState.sGroupByList, searchSolution: returnData, ...addState });
    } else {
      this.props.getServiceError(dataReturn);
    }
  }

  async componentWillReceiveProps(nextProps) {
    const {
      formData, slaveConfig, bSearchConfig, searchSolution,
    } = nextProps;
    let {
      searchColumns, searchRowKeys, masterData,
    } = nextProps;
    const { sModelsType } = nextProps;
    if (commonUtils.isEmptyArr(searchColumns) && formData.length > 0 && !bSearchConfig) {
      const findFilter = commonFunc.getConfigFieldNameData(slaveConfig, 'bFind');
      searchColumns = [];
      findFilter.forEach((item) => {
        searchColumns.push({
          sValue: item.showName, sId: item.sName, sDropDownType: item.sDropDownType, showDropDown: item.showDropDown, sConfigId: item.sId, sAssignField: item.sAssignField,
        });
      });
      let addState;
      if (commonUtils.isEmptyArr(searchRowKeys)) { /* 初始化没有默认方案时的 默认查询值 */
        searchRowKeys = [];
        if (commonUtils.isNotEmptyArr(searchColumns)) {
          const key = commonUtils.createSid();
          searchRowKeys.push(key);
          masterData = commonUtils.isEmptyObject(masterData) ? (sModelsType === 'commonClassify' ? { bCheck: false } : { bCheck: true }) : masterData;
          const sFirstValue = searchColumns[0].sId;
          masterData[`sFirst-${key}`] = searchColumns[0].sId;
          const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' : sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
          masterData[`sSecond-${key}`] = commonConfig.seaJudge[firstDataIndex][0].sId;
        }
      } else {
        addState = await this.defaultSearchSolution(searchSolution[0]);
      }
      this.props.onSaveState({
        searchColumns, searchRowKeys, masterData, bSearchConfig: true, ...addState,
      });
    }
    const { masterConfig, app } = nextProps;
    if (commonUtils.isNotEmptyObject(masterConfig)) {
      let { searchColumnShowColumn } = nextProps;
      if (commonUtils.isEmptyArr(searchColumnShowColumn)) {
        const searchColumnShowConfig = {};
        const columniOrder = commonFunc.showMessage(app.commonConst, 'columniOrder');/* 排序 */
        const columnShowName = commonFunc.showMessage(app.commonConst, 'columnShowName');/* 显示名 */
        const columniFitWidth = commonFunc.showMessage(app.commonConst, 'columniFitWidth');/* 宽度 */
        const columnbVisible = commonFunc.showMessage(app.commonConst, 'columnbVisible');/* 是否显示 */
        const columnChinese = commonFunc.showMessage(app.commonConst, 'columnChinese');/* 中文 */
        const columnEnglish = commonFunc.showMessage(app.commonConst, 'columnEnglish');/* 英文 */
        const columnBig5 = commonFunc.showMessage(app.commonConst, 'columnBig5');/* 繁体 */
        const columnsType = commonFunc.showMessage(app.commonConst, 'columnsType');/* 汇总类型 */
        const columnSQL = commonFunc.showMessage(app.commonConst, 'columnSQL');/* SQL语句 */
        searchColumnShowConfig.gdsconfigformslave = [
          {
            bVisible: false,
            sName: 'sId',
            bNotEmpty: true,
            showName: 'sId',
          }, {
            bVisible: true,
            sName: 'iOrder',
            bNotEmpty: true,
            showName: '排序',
          }, {
            bVisible: true,
            sName: 'sName',
            bNotEmpty: true,
            bReadonly: true,
            showName: '字段名',
          }, {
            bVisible: true,
            sName: 'sChinese',
            bNotEmpty: true,
            showName: '中文名',
          }, {
            bVisible: true,
            sName: 'sEnglish',
            bNotEmpty: true,
            showName: '英文名',
          }, {
            bVisible: true,
            sName: 'sBig5',
            bNotEmpty: true,
            showName: '繁体',
          }, {
            bVisible: true,
            sName: 'iFitWidth',
            bNotEmpty: true,
            showName: '宽度',
          }, {
            bVisible: true,
            sName: 'sType',
            sDropDownType: 'const',
            bNotEmpty: true,
            showName: '汇总类型',
            iVisCount: 1,
            showDropDown: [{ value: '请选择', sId: '' },
              { value: '分组', sId: 'groupBy' },
              { value: '最大值', sId: 'max' },
              { value: '最小值', sId: 'min' },
              { value: '平均数', sId: 'avg' },
              { value: '求和', sId: 'sum' },
              { value: '行数', sId: 'count' },
              { value: 'sql语句', sId: 'sql' }],
          }, {
            bVisible: true,
            sName: 'sSql',
            bNotEmpty: true,
            showName: 'SQL语句',
          }, {
            bVisible: true,
            sName: 'bShow',
            bNotEmpty: true,
            showName: '是否显示',
          }];
        searchColumnShowColumn = [{
          title: columniOrder,
          dataIndex: 'iOrder',
          width: 60,
        }, {
          title: columnShowName,
          dataIndex: 'sName',
          width: 120,
        }, {
          title: columnChinese,
          dataIndex: 'sChinese',
          width: 80,
        }, {
          title: columnEnglish,
          dataIndex: 'sEnglish',
          width: 80,
        }, {
          title: columnBig5,
          dataIndex: 'sBig5',
          width: 80,
        }, {
          title: columniFitWidth,
          dataIndex: 'iFitWidth',
          width: 80,
        }, {
          title: columnbVisible,
          dataIndex: 'bShow',
          width: 60,
        }, {
          title: columnsType,
          dataIndex: 'sType',
          width: 120,
        }, {
          title: columnSQL,
          dataIndex: 'sSql',
          width: 269,
        }];
        const tableConfig = masterConfig.gdsconfigformslave;
        const searchColumnShowData = [];
        for (const child of tableConfig) {
          if (child.sName !== '' && child.bVisible && child.showName !== '') {
            searchColumnShowData.push({
              sId: child.sId,
              iOrder: child.iOrder,
              sChinese: child.sChinese,
              sEnglish: child.sEnglish,
              sBig5: child.sBig5,
              sName: child.sName,
              iFitWidth: child.iFitWidth,
              sType: '',
              sSql: '',
              bShow: false,
            });
          }
        }
        const searchColumnShowAllData = JSON.parse(JSON.stringify(searchColumnShowData));
        this.props.onSaveState({
          searchColumnShowColumn, searchColumnShowData, searchColumnShowAllData, searchColumnShowConfig,
        });
      }
    }
  }

  onKeyUp = (e) => {
    if (e.key === 'Enter') {
      setTimeout(() => {
        this.handleSearch();
      }, 500);
    }
  }

  async defaultSearchSolution(searchSolutionDataRow) {
    /* 判断是否有分组 */
    const sGroupByList = commonUtils.isNotEmptyObject(searchSolutionDataRow) ? searchSolutionDataRow.sGroupByList : '[]';
    const column = [];
    if (commonUtils.isNotEmptyArr(sGroupByList)) {
      /* 有分组查询 */
      for (const child of sGroupByList) {
        if (child.sName !== '' && child.bShow) {
          column.push({
            title: child.sChinese,
            dataIndex: child.sName,
            width: child.iFitWidth,
            bFind: true,
            bNotEmpty: false,
          });
        }
      }
    }
    /* 初始/切换 判断是否展开 */
    const { expand } = false;
    // if (commonUtils.isNotEmptyObject(searchSolutionDataRow)) {
    // /* 当搜索条件有一个为空时，则展开 */
    //   const searchSolutions = JSON.parse(searchSolutionDataRow.sCondition);
    //   const showConfigArr = searchSolutions.filter(item => commonUtils.isEmpty(item.bFilterValue) || item.bFilterValue === false);
    //   /* 当搜索条件只有一行时，不展开 */
    //   if (searchSolutions.length > 1 && commonUtils.isNotEmptyArr(showConfigArr) && showConfigArr.length > 0) {
    //     expand = true;
    //   }
    // }

    // 按照孟总2021.5.28最新的原型图，按钮恒为高亮
    const highlightColor = false;
    // if (commonUtils.isNotEmptyObject(searchSolutionDataRow)) {
    //   const searchSolutions = JSON.parse(searchSolutionDataRow.sCondition);
    //   /* 当搜索条件为多条时，按钮高亮;否则不高亮 */
    //   if (commonUtils.isNotEmptyArr(searchSolutions) && searchSolutions.length > 1) {
    //     highlightColor = true;
    //   }
    // }
    const { sModelsType, app } = this.props;
    // if (sModelsType === 'productionMainPlan/productionMainPlan') {
    //   expand = false;/* 生产主计划搜索方案始终闭合 */
    // }
    const { userinfo } = app;
    const masterData = sModelsType === 'commonClassify' ? { bCheck: false } : { bCheck: true };
    const searchRowKeys = [];
    masterData.sSearchSolutionId = searchSolutionDataRow.sId;
    masterData.sSolutionName = searchSolutionDataRow.sName; /* 修改方案名称，拿到选中方案名称 */
    const filterCondition = JSON.parse(searchSolutionDataRow.sCondition);
    const ownerFlag = userinfo.sId === searchSolutionDataRow.sUserId || (searchSolutionDataRow.sType === 'common' && this.props.app.userinfo.sType === 'sysadmin');
    await filterCondition.forEach(async (item) => {
      const key = commonUtils.createSid();
      searchRowKeys.push(key);
      const sFirstValue = item.bFilterName;
      masterData[`${key}disabled`] = !ownerFlag;
      masterData[`sFirst-${key}`] = sFirstValue;
      const sSecondValue = item.bFilterCondition;
      const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
        (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'week' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
      masterData[`sSecond-${key}`] = item.bFilterCondition;
      if (sSecondValue === 'day') {
        masterData[`${firstDataIndex}Third-${key}`] = moment().format(this.sDateFormat);
      } else if (sSecondValue === 'month') {
        const dateBetween = [];
        dateBetween.push(moment().startOf('month'));
        dateBetween.push(moment().endOf('month'));
        masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
      } else if (sSecondValue === 'monthPre') {
        const dateBetween = [];
        dateBetween.push(moment().startOf('month').subtract('month', 1));
        dateBetween.push(moment().endOf('month').subtract('month', 1).endOf('month'));
        masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
      } else if (sSecondValue === 'week') {
        const dateBetween = [];
        dateBetween.push(moment().startOf('week'));
        dateBetween.push(moment().endOf('week'));
        masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
      } else if (item.bFilterCondition === 'between' || item.bFilterCondition === 'betweenTime') {
        if (item.bFilterValue.split(',').length === 2) {
          const dateBetween = [];
          dateBetween.push(moment(item.bFilterValue.split(',')[0]));
          dateBetween.push(moment(item.bFilterValue.split(',')[1]));
          masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
        } else {
          masterData[`${firstDataIndex}Third-${key}`] = moment(item.bFilterValue);
        }
      } else if (firstDataIndex === 't') {
        masterData[`${firstDataIndex}Third-${key}`] = moment(item.bFilterValue);
      } else {
        const { slaveConfig } = this.props;
        if (commonUtils.isNotEmptyObject(slaveConfig)) {
          const iIndex = slaveConfig.gdsconfigformslave.findIndex(itemData => itemData.sName === sFirstValue);
          if (iIndex > -1 && slaveConfig.gdsconfigformslave[iIndex].sDropDownType === 'sql') {
            const sqlDropDownData = await this.props.getSqlDropDownData(this.props.sModelsId, 'master', slaveConfig.gdsconfigformslave[iIndex]);
            const dropDownData = sqlDropDownData.dropDownData;
            const iValueIndex = dropDownData.findIndex(itemData => itemData.sId === item.bFilterValue);
            if (iValueIndex > -1) {
              masterData[`${firstDataIndex}Third-${key}`] = dropDownData[iValueIndex].sName;
              masterData[`${firstDataIndex}Third-${key}Id`] = item.bFilterValue;
            }
          } else {
            masterData[`${firstDataIndex}Third-${key}`] = item.bFilterValue;
          }
        } else {
          masterData[`${firstDataIndex}Third-${key}`] = item.bFilterValue;
        }
      }
    });
    return {
      masterData, searchRowKeys, slaveGroupColumn: column, sGroupByList: sGroupByList, expand, highlightColor,
    };
  }
  handeToggle = () => {
    /* 是否展开多出的条件内容 */
    const { expand } = this.props;
    this.props.onSaveState({ expand: !expand });
  };

  handleSearchProps(showConfig) {
    const { masterData } = this.props;
    return {
      form: this.props.form,
      getSqlDropDownData: this.props.getSqlDropDownData,
      getSqlCondition: this.props.getSqlCondition,
      handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord,
      getFloatNum: this.props.getFloatNum,
      getDateFormat: this.props.getDateFormat,
      onChange: this.handleMasterChange,
      showConfig,
      formItemLayout: {},
      textArea: false,
      enabled: true,
      dataValue: commonUtils.isNotEmptyObject(masterData) ? masterData[showConfig.sName] : '',
      bTable: false,
      formRoute: this.props.formRoute,
    };
  }

  handleSearch = () => {
    const {
      searchRowKeys, masterData, slaveConfig, slaveInfoConfig, setSearchSlaveInfo,
    } = this.props;
    const filterCondition = []; /* 数据筛选条件 */
    searchRowKeys.map((key) => {
      const { [`sFirst-${key}`]: sFirstValue, [`sSecond-${key}`]: sSecondValue } = masterData;
      const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
        (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'week' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
      const sThirdName = `${firstDataIndex}Third-${key}`;
      let thirdValue = masterData[sThirdName];
      const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === sFirstValue);
      if (iIndex > -1 && slaveConfig.gdsconfigformslave[iIndex].sDropDownType === 'sql') {
        if (!commonUtils.isEmpty(masterData[`${sThirdName}Id`])) {
          thirdValue = masterData[`${sThirdName}Id`];
        } if (!commonUtils.isEmpty(masterData[sFirstValue])) {
          thirdValue = masterData[sFirstValue];
        }
      }
      if (!commonUtils.isEmpty(thirdValue)) {
        if (firstDataIndex === 'p') {
          const tStartDate = sSecondValue === 'betweenTime' ? moment(thirdValue[0]).format('YYYY-MM-DD HH:mm') : moment(thirdValue[0]).format(this.sDateFormat);
          const tEndDate = sSecondValue === 'betweenTime' ? moment(thirdValue[1]).format('YYYY-MM-DD HH:mm') : moment(thirdValue[1]).add(1, 'days').format(this.sDateFormat);
          filterCondition.push({
            bFilterName: sFirstValue,
            bFilterCondition: sSecondValue === 'monthPre' ? 'between' : sSecondValue,
            bFilterValue: `${tStartDate},${tEndDate}`,
          });
        } else if (firstDataIndex === 'm') {
          const tStartDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm') : moment(thirdValue).startOf('month').format(this.sDateFormat);
          const tEndDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm') : moment(thirdValue).endOf('month').add(1, 'days').format(this.sDateFormat);
          filterCondition.push({
            bFilterName: `t${sFirstValue.substring(1, sFirstValue.length)}`,
            bFilterCondition: sSecondValue,
            bFilterValue: `${tStartDate},${tEndDate}`,
          });
        } else if (firstDataIndex === 't') {
          filterCondition.push({
            bFilterName: sFirstValue,
            bFilterCondition: sSecondValue,
            bFilterValue: moment(thirdValue).format(this.sDateFormat),
          });
        } else {
          filterCondition.push({
            bFilterName: sFirstValue,
            bFilterCondition: sSecondValue,
            bFilterValue: thirdValue,
          });
        }
      }
      return true;
    });
    /* 判断是否要加载过滤树数据 */
    const filterTreeConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.bTree);
    if (commonUtils.isNotEmptyArr(filterTreeConfigArr)) {
      const filterTreeConfig = filterTreeConfigArr[0];
      this.props.onGetFilterTreeData(filterTreeConfig, filterCondition, 1);
      let { treeSelectedKeys } = this.props;
      if (commonUtils.isNotEmptyArr(treeSelectedKeys)) { /* 清除原来选中树节点 */
        treeSelectedKeys = [];
        this.props.onSaveState({
          treeSelectedKeys, treeFilterCondition: [],
        });
      }
    }
    /*
      修改日期：2021-03-17
      修改人：吕杰
      区域：以下一行
      需求变更：fix 2135 搜索时添加loading动画
    */
    this.props.onSaveState({ pageLoading: true });
    this.props.onGetData(slaveConfig, filterCondition);
    if (setSearchSlaveInfo === 'Y') {
      if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
        this.props.onGetDataInfo(slaveInfoConfig, filterCondition);
      }
    } else {
      this.props.onSaveState({
        expKeys: [],
        slaveInfoSelectedRowKeys: [],
        slaveInfoSelectedData: [],
        slaveInfoData: [], /* 清除生产主计划,生产排程明细表数据 */
      });
    }
  }

  /** 修改主表数据 */
  handleMasterChange = async (name, sFieldName, changeValue, sId, dropDownData) => {
    // let { expand } = false;
    if (sFieldName === 'sSearchSolutionId') {
      const {
        searchSolution, slaveConfig, slaveInfoConfig, setSearchSlaveInfo,
      } = this.props;
      const iIndex = searchSolution.findIndex(item => item.sId === changeValue[sFieldName]);
      const addState = await this.defaultSearchSolution(searchSolution[iIndex]);
      this.props.onSaveState({ ...addState });
      this.props.onGetData(slaveConfig, JSON.parse(searchSolution[iIndex].sCondition), '', '', '', '', addState.sGroupByList);
      if (setSearchSlaveInfo === 'Y') {
        if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
          this.props.onGetDataInfo(slaveInfoConfig, JSON.parse(searchSolution[iIndex].sCondition));
        }
      }
      // /* 当搜索条件有一个为空时，则展开 */
      // const searchSolutions = JSON.parse(searchSolution[iIndex].sCondition);
      // const showConfigArr = searchSolutions.filter(item => commonUtils.isEmpty(item.bFilterValue) || item.bFilterValue === false);
      // /* 当搜索条件只有一行时，不展开 */
      // if (searchSolutions.length > 1 && commonUtils.isNotEmptyArr(showConfigArr) && showConfigArr.length > 0) {
      //   expand = true;
      // }
      // this.props.onSaveState({ expand });
    } else if (sFieldName.includes('sFirst-')) {
      const { slaveConfig } = this.props;
      const { masterData } = this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true);
      const sFirstValue = masterData[sFieldName];
      const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' : sFirstValue.substring(0, 1);
      const key = sFieldName.substring('sFirst-'.length, sFieldName.length);
      const sSecondConditionPro = firstDataIndex === 's' && sFirstValue.endsWith('_pro'); /* 字段名以s开头，sFilterName以pro结尾，则只有等于条件 */
      const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === sFirstValue);
      masterData[`sSecond-${key}`] = sSecondConditionPro && iIndex > -1 && slaveConfig.gdsconfigformslave[iIndex].sDropDownType === 'sql' ?
        commonConfig.seaJudge.s_proDropDown[0].sId : sSecondConditionPro ?
          commonConfig.seaJudge.s_pro[0].sId : commonConfig.seaJudge[firstDataIndex][0].sId;
      masterData[`${firstDataIndex}Third-${key}`] = firstDataIndex === 'b' ? false : firstDataIndex === 't' ? moment().format(this.sDateFormat) : '';
      this.props.onSaveState({ masterData });
    } else if (sFieldName.includes('sSecond-')) {
      const { masterData } = this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true);
      const sSecondValue = masterData[sFieldName];
      const key = sFieldName.substring('sSecond-'.length, sFieldName.length);
      const sFirstValue = masterData[`sFirst-${key}`];
      const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
        (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'week' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
      if (sSecondValue === 'day') {
        masterData[`${firstDataIndex}Third-${key}`] = moment().format(this.sDateFormat);
      } else if (sSecondValue === 'month') {
        const dateBetween = [];
        dateBetween.push(moment().startOf('month'));
        dateBetween.push(moment().endOf('month'));
        masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
      } else if (sSecondValue === 'monthPre') {
        const dateBetween = [];
        dateBetween.push(moment().startOf('month').subtract('month', 1));
        dateBetween.push(moment().endOf('month').subtract('month', 1).endOf('month'));
        masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
      } else if (sSecondValue === 'week') {
        const dateBetween = [];
        dateBetween.push(moment().startOf('week'));
        dateBetween.push(moment().endOf('week'));
        masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
      }
      this.props.onSaveState({ masterData });
    } else {
      this.props.onChange('master', sFieldName, changeValue, sId, dropDownData);
    }
  };

  handleFields = (searchColumns) => {
    /* 默认快捷过滤 */
    if (commonUtils.isEmptyArr(searchColumns)) { return; }
    const { masterData, searchRowKeys } = this.props;
    const children = searchRowKeys.map((key) => {
      const { [`sFirst-${key}`]: sFirstValue, [`sSecond-${key}`]: sSecondValue, [`${key}disabled`]: disabled } = masterData;
      const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
        (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'week' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
      const showFirstConfig = {
        sId: commonUtils.createSid(),
        sName: `sFirst-${key}`,
        sDropDownType: 'sql',
        iVisCount: 1,
        bNotEmpty: true,
        dropDownData: this.props.searchColumns,
      };

      const sThirdName = `${firstDataIndex}Third-${key}`;
      let DropDownType = '';
      let showDropDown = '';
      let sAssignField = '';
      let sId = '';
      const searchColumnsCurrent = searchColumns.filter(item => item.sId === sFirstValue);
      if (commonUtils.isNotEmptyArr(searchColumnsCurrent) && searchColumnsCurrent.length > 0) {
        sId = searchColumnsCurrent[0].sConfigId;
        DropDownType = searchColumnsCurrent[0].sDropDownType;
        showDropDown = searchColumnsCurrent[0].showDropDown;
        sAssignField = searchColumnsCurrent[0].sAssignField;
      }
      const sSecondConditionPro = firstDataIndex === 's' && sFirstValue.endsWith('_pro'); /* 字段名以s开头，sFilterName以pro结尾，则只有等于条件 */
      const showSecondConfig = {
        sId: commonUtils.createSid(),
        sName: `sSecond-${key}`,
        sDropDownType: 'sql',
        bNotEmpty: true,
        iVisCount: 1,
        dropDownData: sSecondConditionPro && DropDownType === 'sql' ? commonConfig.seaJudge.s_proDropDown : sSecondConditionPro ? commonConfig.seaJudge.s_pro : commonConfig.seaJudge[firstDataIndex],
        bCanInput: true,
      };
      const showThirdConfig = {
        sId,
        sName: sThirdName,
        sDropDownType: DropDownType,
        bNotEmpty: false,
        showDropDown: DropDownType === 'const' ? undefined : showDropDown,
        dropDownData: DropDownType === 'const' ? commonUtils.objectToArr(commonUtils.convertStrToObj(showDropDown)) : undefined,
        sAssignField,
        iVisCount: 1,
        bCanInput: true,
      };
      const showTypeFirstProps = this.handleSearchProps(showFirstConfig);
      const showTypeSecondProps = this.handleSearchProps(showSecondConfig);
      const showTypeThirdProps = this.handleSearchProps(showThirdConfig);
      showTypeFirstProps.enabled = true; /* 管理员设置的方案，普通用户不可编辑  showTypeFirstProps.enabled = !disabled; */
      showTypeSecondProps.enabled = true; /* showTypeSecondProps.enabled = !disabled; */
      showTypeThirdProps.enabled = true && !(sSecondValue === 'day' || sSecondValue === 'week' || sSecondValue === 'month' || sSecondValue === 'monthPre');/* showTypeThirdProps.enabled = !disabled */
      const { dataValue } = showTypeThirdProps;
      if (sThirdName.substring(0, 1) === 'b') {
        showTypeThirdProps.enabled = true; /* 选择框不管什么情况，都是可编辑状态 */
      } else if (commonUtils.isEmptyObject(dataValue) || commonUtils.isEmptyArr(dataValue)) {
        showTypeThirdProps.enabled = true; /* 第三个查找条件值为空时，要能直接输入 */
      }
      if (sSecondValue === 'betweenTime') {
        showThirdConfig.sDateFormat = 'YYYY-MM-DD HH:mm';
        /* showTime为true显示可以选择具体时间 */
        showTypeThirdProps.showTime = sSecondValue === 'betweenTime';
      }

      return (
        <div key={key} className={styles.addFilterBox}>
          <div style={{ width: 180, marginRight: 8, float: 'left' }}>
            <ShowType {...showTypeFirstProps} />
          </div>
          <div style={{ width: 180, marginRight: 8, float: 'left' }}>
            <ShowType {...showTypeSecondProps} />
          </div>
          <div style={{ width: 180, marginRight: 8, float: 'left' }}>
            <ShowType {...showTypeThirdProps} onKeyUp={this.onKeyUp} />
            {
              key > 0 && !disabled ? (
                <div className={styles.minuseIcon} >
                  <div className={styles.advDelectIcon}>
                    <MinusCircleOutlined onClick={() => this.handleRemove(key)} />
                  </div>
                </div>
              ) : null
            }
          </div>
        </div>
      );
    });
    return children;
  };

  handleAdd = () => {
    /* 添加条件 */
    const { searchRowKeys, searchColumns, masterData } = this.props;
    const key = commonUtils.createSid();
    searchRowKeys.push(key);
    const sFirstValue = searchColumns[0].sId;
    masterData[`sFirst-${key}`] = searchColumns[0].sId;
    const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' : sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
    masterData[`sSecond-${key}`] = commonConfig.seaJudge[firstDataIndex][0].sId;
    this.props.onSaveState({ searchRowKeys, masterData });
  };

  handleRemove = (key, disabled) => {
    /* 移除添加条件 */
    const { searchRowKeys } = this.props;
    if (searchRowKeys.length > 1 && !disabled) {
      const iIndex = searchRowKeys.findIndex(item => item === key);
      searchRowKeys.splice(iIndex, 1);
      this.props.onSaveState({ searchRowKeys });
    }
  };

  handleSave = (e) => {
    /* 保存快捷过滤模板 */
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      /*   验证通过与不通过走不同的流程   */
      if (err) { /*   验证失败   */
        /*   直接渲染显示错误提示   */
        for (const sFieldName of Object.keys(err)) {
          const key = sFieldName.substring('Third-'.length + 1, sFieldName.length);
          const sFirstValue = values[`sFirst-${key}`];
          const iIndex = this.props.searchColumns.findIndex(item => item.sId === sFirstValue);
          const showName = iIndex > -1 ? this.props.searchColumns[iIndex].sValue : '';
          message.error(err[sFieldName].errors[0].message.replace('undefined', showName));
        }
      } else { /*   验证成功   */
        this.props.onSaveState({
          modalVisible: true,
        });
      }
    });
  };
  handleUpd= (e) => {
    /* 方案名称修改 */
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      /*   验证通过与不通过走不同的流程   */
      if (err) { /*   验证失败   */
        /*   直接渲染显示错误提示   */
        for (const sFieldName of Object.keys(err)) {
          const key = sFieldName.substring('Third-'.length + 1, sFieldName.length);
          const sFirstValue = values[`sFirst-${key}`];
          const iIndex = this.props.searchColumns.findIndex(item => item.sId === sFirstValue);
          const showName = iIndex > -1 ? this.props.searchColumns[iIndex].sValue : '';
          message.error(err[sFieldName].errors[0].message.replace('undefined', showName));
        }
      } else { /*   验证成功   */
        this.props.onSaveState({
          modalSolutionNameVisible: true,
        });
      }
    });
  };
  /* 列显示配置 */
  handleSaveColumnSetting = async () => {
    const {
      masterData, sModelsId, searchColumnShowAllData, formSrcRoute,
    } = this.props;
    const sSearchSolutionId = commonUtils.isNotEmptyObject(masterData) ? masterData.sSearchSolutionId : '';
    if (commonUtils.isNotEmptyObject(sSearchSolutionId)) {
      const searchUrl = `${commonConfig.server_host}searchgroupby/getSearchgroupbyData/${sModelsId}/${sSearchSolutionId}?token=token&sModelsId=${sModelsId}&sName=${formSrcRoute}`;
      const dataReturn = (await commonServices.getService(this.props.app.token, searchUrl)).data;
      if (dataReturn.code === 1) {
        const returnData = dataReturn.dataset.rows;
        if (commonUtils.isNotEmptyArr(returnData)) {
          const newsearchColumnShowData = JSON.parse(JSON.stringify(searchColumnShowAllData));
          for (const child of returnData) {
            const iIndex = newsearchColumnShowData.findIndex(item => item.sName === child.sName.toString());
            if (iIndex > -1) {
              newsearchColumnShowData[iIndex].iOrder = child.iOrder;
              newsearchColumnShowData[iIndex].sChinese = child.sChinese;
              newsearchColumnShowData[iIndex].sEnglish = child.sEnglish;
              newsearchColumnShowData[iIndex].sBig5 = child.sBig5;
              newsearchColumnShowData[iIndex].iFitWidth = child.iFitWidth;
              newsearchColumnShowData[iIndex].bShow = child.bShow;
              newsearchColumnShowData[iIndex].sType = child.sType;
              newsearchColumnShowData[iIndex].sSql = child.sSql;
            }
          }
          this.props.onSaveState({
            searchColumnShowData: newsearchColumnShowData,
          });
        } else {
          this.props.onSaveState({
            searchColumnShowData: JSON.parse(JSON.stringify(searchColumnShowAllData)),
          });
        }
      } else {
        this.props.getServiceError(dataReturn);
      }
    }
    this.props.onSaveState({
      columnSettingVisible: true,
    });
  }
  handleDefault = async () => {
    const { sModelsId, masterData, formSrcRoute } = this.props;
    const dataUrl = `${commonConfig.server_host}syssearch/updateSyssearch?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
    const value = {
      sFormId: sModelsId,
      sId: masterData.sSearchSolutionId,
      bDefault: true,
    };
    const dataReturn = (await commonServices.postValueService(this.props.app.token, value, dataUrl)).data;
    if (dataReturn.code === 1) {
      const returnData = dataReturn.dataset.rows;
      message.success(dataReturn.msg);
      await this.componentWillMount(returnData[0].sId);
    } else {
      this.props.getServiceError(dataReturn);
    }
  }

  handleOk = (e) => {
    e.preventDefault();
    this.props.form.validateFields(async (err) => {
      /*   验证通过与不通过走不同的流程   */
      if (err) { /*   验证失败   */
        /*   直接渲染显示错误提示   */
        for (const sFieldName of Object.keys(err)) {
          message.error(err[sFieldName].errors[0].message);
        }
      } else { /*   验证成功   */
        const {
          sModelsId, masterData, searchRowKeys, formSrcRoute,
        } = this.props;
        const dataUrl = `${commonConfig.server_host}syssearch/addSyssearch?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
        const filterCondition = [];
        searchRowKeys.map((key) => {
          const { [`sFirst-${key}`]: sFirstValue, [`sSecond-${key}`]: sSecondValue } = masterData;
          const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
            (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'week' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
          const sThirdName = `${firstDataIndex}Third-${key}`;
          const thirdValue = masterData[sThirdName] === undefined ? '' : masterData[sThirdName]; /* 不过滤空条件 */
          if (thirdValue !== undefined) {
            if (firstDataIndex === 'p') {
              const tStartDate = moment(thirdValue[0]).format(this.sDateFormat);
              const tEndDate = moment(thirdValue[1]).add(1, 'days').format(this.sDateFormat);
              filterCondition.push({
                bFilterName: sFirstValue,
                bFilterCondition: sSecondValue === 'monthPre' ? 'between' : sSecondValue,
                bFilterValue: `${tStartDate},${tEndDate}`,
              });
            } else if (firstDataIndex === 't') {
              filterCondition.push({
                bFilterName: sFirstValue,
                bFilterCondition: sSecondValue,
                bFilterValue: moment(thirdValue).format(this.sDateFormat),
              });
            } else {
              filterCondition.push({
                bFilterName: sFirstValue,
                bFilterCondition: sSecondValue,
                bFilterValue: thirdValue,
              });
            }
          }
          return true;
        });
        const value = {
          sFormId: sModelsId,
          sCondition: filterCondition,
          sName: masterData.sSolutionName,
        };
        const dataReturn = (await commonServices.postValueService(this.props.app.token, value, dataUrl)).data;
        if (dataReturn.code === 1) {
          const returnData = dataReturn.dataset.rows;
          message.success(dataReturn.msg);
          await this.componentWillMount(returnData[0].sId);
        } else {
          this.props.getServiceError(dataReturn);
        }
      }
    });
  };

  handleSolutionNameOk = (e) => {
    e.preventDefault();
    this.props.form.validateFields(async (err) => {
      /*   验证通过与不通过走不同的流程   */
      if (err) { /*   验证失败   */
        /*   直接渲染显示错误提示   */
        for (const sFieldName of Object.keys(err)) {
          message.error(err[sFieldName].errors[0].message);
        }
      } else { /*   验证成功   */
        const {
          sModelsId, masterData, searchRowKeys, formSrcRoute,
        } = this.props;
        const dataUrl = `${commonConfig.server_host}syssearch/updateSyssearch?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
        const filterCondition = [];
        searchRowKeys.map((key) => {
          const { [`sFirst-${key}`]: sFirstValue, [`sSecond-${key}`]: sSecondValue } = masterData;
          const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
            (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'week' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
          const sThirdName = `${firstDataIndex}Third-${key}`;
          const thirdValue = masterData[sThirdName] === undefined ? '' : masterData[sThirdName]; /* 不过滤空条件 */
          if (thirdValue !== undefined) {
            if (firstDataIndex === 'p') {
              const tStartDate = moment(thirdValue[0]).format(this.sDateFormat);
              const tEndDate = moment(thirdValue[1]).add(1, 'days').format(this.sDateFormat);
              filterCondition.push({
                bFilterName: sFirstValue,
                bFilterCondition: sSecondValue === 'monthPre' ? 'between' : sSecondValue,
                bFilterValue: `${tStartDate},${tEndDate}`,
              });
            } else if (firstDataIndex === 't') {
              filterCondition.push({
                bFilterName: sFirstValue,
                bFilterCondition: sSecondValue,
                bFilterValue: moment(thirdValue).format(this.sDateFormat),
              });
            } else {
              filterCondition.push({
                bFilterName: sFirstValue,
                bFilterCondition: sSecondValue,
                bFilterValue: thirdValue,
              });
            }
          }
          return true;
        });
        const value = {
          sFormId: sModelsId,
          sCondition: filterCondition,
          sName: masterData.sSolutionName,
          sId: masterData.sSearchSolutionId,
        };
        const dataReturn = (await commonServices.postValueService(this.props.app.token, value, dataUrl)).data;
        if (dataReturn.code === 1) {
          const returnData = dataReturn.dataset.rows;
          message.success(dataReturn.msg);
          await this.componentWillMount(returnData[0].sId);
        } else {
          this.props.getServiceError(dataReturn);
        }
      }
    });
  };
  handleDel = async (e) => {
    /* 删除快捷过滤模板 */
    e.preventDefault(); /* 防止动画删除 */
    const {
      slaveConfig, slaveInfoConfig, masterData, sModelsId, formSrcRoute, setSearchSlaveInfo,
    } = this.props;
    if (commonUtils.isNotEmptyObject(masterData) && !commonUtils.isEmpty(masterData.sSearchSolutionId)) {
      const dataUrl = `${commonConfig.server_host}syssearch/deleteSyssearch/${sModelsId}/${masterData.sSearchSolutionId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
      const dataReturn = (await commonServices.getService(this.props.app.token, dataUrl)).data;
      if (dataReturn.code === 1) {
        message.success(dataReturn.msg);
        await this.componentWillMount();
        const { searchSolution } = this.props;
        if (commonUtils.isNotEmptyArr(searchSolution)) {
          /* 如果初始没有方案,即为[],则进行重置 */
          if (searchSolution[0].sCondition === '[]') {
            this.handleReset();
          }
          this.props.onGetData(slaveConfig, JSON.parse(searchSolution[0].sCondition));
          if (setSearchSlaveInfo === 'Y') {
            if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
              this.props.onGetDataInfo(slaveInfoConfig, JSON.parse(searchSolution[0].sCondition));
            }
          }
        } else {
          this.handleReset();
        }
      } else {
        this.props.getServiceError(dataReturn);
      }
    }
  };

  handleReset = async () => {
    /* 清空搜索条件 */
    const { searchColumns, sModelsType } = this.props;
    const searchRowKeys = [];
    const key = commonUtils.createSid();
    const masterData = sModelsType === 'commonClassify' ? { bCheck: false } : { bCheck: true };
    // masterData.sSearchSolutionId = masterDataOld.sSearchSolutionId;
    searchRowKeys.push(key);
    if (commonUtils.isNotEmptyArr(searchColumns)) {
      const sFirstValue = searchColumns[0].sId;
      masterData[`sFirst-${key}`] = searchColumns[0].sId;
      const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' : sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
      masterData[`sSecond-${key}`] = commonConfig.seaJudge[firstDataIndex][0].sId;
      const { clearArray } = this.props;
      if (!commonUtils.isEmpty(clearArray)) {
        for (const item of clearArray) {
          const { confirm, clearFilters } = item;
          confirm();
          clearFilters();
        }
      }
      await this.props.onSaveState({
        searchRowKeys,
        masterData,
        clearArray: [],
        searchText: '',
        slaveGroupColumn: [],
        sGroupByList: [],
        slaveData: [],
        treeFilterCondition: [],
        treeSelectedKeys: [],
        slaveFilterData: [],
        slaveSelectedRowKeys: [],
        slaveSelectedData: [],
      });
    }
    this.handleSearch();
  };

   handleCancel = async (modelVisible) => {
     /* 关闭弹窗 */
     this.props.onSaveState({ [modelVisible]: false });
   };
   /* 列自定义配置-删除功能 */
  handleCloumnSettingDelete = async (modelVisible) => {
    /* 关闭弹窗 */
    const { masterData, sModelsId, formSrcRoute } = this.props;
    const sSearchSolutionId = commonUtils.isNotEmptyObject(masterData) ? masterData.sSearchSolutionId : '';
    const deleteUrl = `${commonConfig.server_host}searchgroupby/deleteSearchgroupby/${sModelsId}/${sSearchSolutionId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
    const dataReturn = (await commonServices.getService(this.props.app.token, deleteUrl)).data;
    if (dataReturn.code === 1) {
      message.success(dataReturn.msg);
      await this.componentWillMount(sSearchSolutionId); /* 搜索刷新下拉方案 */
      this.handleSearch();
      this.props.onSaveState({ slaveGroupColumn: [], [modelVisible]: false });
    } else {
      this.props.getServiceError(dataReturn);
    }
  };
  /* 列自定义配置窗体保存功能 */
  handleColumnSettingSave =async (modelVisible) => {
    /* 获取勾选是否显示的列的数据/拿到显示参数/调用接口 */
    const {
      searchColumnShowData, masterData, sModelsId, formSrcRoute,
    } = this.props;
    const sSearchSolutionId = commonUtils.isNotEmptyObject(masterData) ? masterData.sSearchSolutionId : '';
    const sSearchgroupbyData = searchColumnShowData.filter(item => item.bShow);
    const addurl = `${commonConfig.server_host}/searchgroupby/addSearchgroupby?token=token&sModelsId=${sModelsId}&sName=${formSrcRoute}`;
    /*   参数   */
    const body = {
      sFormId: sModelsId,
      sSearchId: sSearchSolutionId,
      sSearchgroupbyData: sSearchgroupbyData,
    };
    // /*   获取数据   */
    const json = await commonServices.postValueService(this.props.app.token, body, addurl);
    /*   code为1代表获取数据成功   */
    if (json.data.code === 1) {
      message.success(json.data.msg);
      /* 刷新查询方案 */
      await this.componentWillMount(sSearchSolutionId);
      this.handleCloumnSettingSearch(modelVisible, sSearchgroupbyData);
    } else {
      message.error(json.data.msg);
    }
  }

  /* 列自定义配置-查询结果 */
  handleCloumnSettingSearch = (modelVisible, sGroupByList) => {
    /* 查询结果 */
    /* 表头替换，数据集替换 */
    const {
      searchColumnShowData, slaveConfig, slaveInfoConfig, slaveFilterCondition, setSearchSlaveInfo,
    } = this.props;
    const column = [];
    for (const child of searchColumnShowData) {
      if (child.sName !== '' && child.bShow) {
        column.push({
          title: child.sChinese,
          dataIndex: child.sName,
          width: child.iFitWidth,
          bFind: true,
          bNotEmpty: false,
        });
      }
    }
    /* 调handleSearch搜索 */
    this.props.onGetData(slaveConfig, slaveFilterCondition, '', '', '', '', sGroupByList);
    if (setSearchSlaveInfo === 'Y') {
      if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
        this.props.onGetDataInfo(slaveInfoConfig, slaveFilterCondition);
      }
    }
    this.props.onSaveState({
      slaveGroupColumn: column,
      [modelVisible]: false,
    });
  };
  render() {
    const {
      searchSolution, searchColumns, expand, activeTagId, sType, modalVisible, modalSolutionNameVisible, confirmLoading, masterData, columnSettingVisible, app,
    } = this.props;
    const highlightColor = true;
    const showSearchSolutionConfig = {
      sId: commonUtils.createSid(),
      sName: 'sSearchSolutionId',
      sDropDownType: 'sql',
      iVisCount: 1,
      sVisColumnName: 'sName',
      dropDownData: searchSolution,
      placeholder: commonFunc.showMessage(app.commonConst, 'pleaseChooseSolution'), /* 请选择方案 */
    };
    const showTypeSearchSolutionProps = this.handleSearchProps(showSearchSolutionConfig);
    showTypeSearchSolutionProps.formItemLayout = { style: { width: '183px', padding: '8px 0 0px 8px', float: 'left' } };
    /* 过滤另存方案界面显示 */
    const showSolutionNameConfig = {
      sId: commonUtils.createSid(),
      sName: 'sSolutionName',
      sDropDownType: '',
      bNotEmpty: modalVisible,
      showName: commonFunc.showMessage(app.commonConst, 'solutionName'), /* 方案名称 */
    };
    /* 修改方案名称界面显示 */
    const updSolutionNameConfig = {
      sId: commonUtils.createSid(),
      sName: 'sSolutionName',
      sDropDownType: '',
      bNotEmpty: modalSolutionNameVisible,
      showName: commonFunc.showMessage(app.commonConst, 'solutionName'), /* 方案名称 */
    };
    let bBtnDelDisabled = false;
    let bBtnColumnSetting = false;/* 列显示配置按钮是否可用 */
    if (commonUtils.isNotEmptyArr(searchSolution) && commonUtils.isNotEmptyObject(masterData)) {
      const iIndex = searchSolution.findIndex(item => item.sId === masterData.sSearchSolutionId);
      if (iIndex > -1) {
        bBtnDelDisabled = this.props.app.userinfo.sType !== 'sysadmin' && searchSolution[iIndex].sType === 'common';
        bBtnColumnSetting = bBtnDelDisabled;
      }
      /* 清空方案时,列显示配置按钮不可用 */
      const sSearchSolutionId = commonUtils.isNotEmptyObject(masterData.sSearchSolutionId) ? masterData.sSearchSolutionId : '';
      if (commonUtils.isEmptyObject(sSearchSolutionId)) {
        bBtnColumnSetting = true;
      }
    } else {
      bBtnColumnSetting = true; /* 没有方案时 */
    }
    const showTypeSolutionNameProps = this.handleSearchProps(showSolutionNameConfig);
    const updSolutionNameConfigProps = this.handleSearchProps(updSolutionNameConfig);/* 修改方案名称 */
    /* 列自定义配置 */
    const searchColumnShowProps = {
      ...commonBusiness.getTableTypes('searchColumnShow', this.props),
      tableBelone: 'table',
      enabled: true,
      onDoubleClick: undefined,
      sUseInfo: '',
      tableProps: { rowKey: 'sId' },
    };
    const AddCondition = commonFunc.showMessage(app.commonConst, 'AddCondition');/* 添加条件 */
    const BtnSave = commonFunc.showMessage(app.commonConst, 'BtnSave');/* 保存 */
    const BtnUpd = commonFunc.showMessage(app.commonConst, 'BtnUpd');/* 修改 */
    const setDelete = commonFunc.showMessage(app.commonConst, 'setDelete');/* 删除 */
    const setDefault = commonFunc.showMessage(app.commonConst, 'setDefault');/* 设置默认 */
    const columnDisplaySetting = commonFunc.showMessage(app.commonConst, 'ColumnDisplaySetting');/* 列显示配置 */
    const btnSearch = commonFunc.showMessage(app.commonConst, 'btnSearch');/* 搜索 */
    const clearOut = commonFunc.showMessage(app.commonConst, 'ClearOut');/* 清空 */
    const btnSaveAndSearch = commonFunc.showMessage(app.commonConst, 'btnSaveAndSearch');/* 保存并查询 */

    return (
      <div> {commonUtils.isEmptyArr(searchColumns) ? '' : <div className={[styles.fastFilter, 'search-container', 'clear'].join(' ')}>
        <ShowType {...showTypeSearchSolutionProps} placeholder={commonFunc.showMessage(app.commonConst, 'pleaseChooseSolution')} />
        <Row className={expand ? styles.advRowActive : styles.advRow}>
          {this.handleFields(searchColumns)}
          <Button type="default" className={highlightColor ? styles.advTogIcon_Highlight : styles.advTogIcon_Gray} onClick={this.handeToggle} icon={<LegacyIcon type={expand ? 'up' : 'down'} />} style={{ position: 'absolute', right: 36 }} />
          {
              (activeTagId === 'default' || (sType === 'common' && this.props.app.userinfo.sType !== 'sysadmin')) ?
                <Col span={24} style={{ display: expand ? 'block' : 'none' }}>
                  <Col span={20}>
                    <div className={styles.advButton}>
                      <Button
                        type="primary"
                        onClick={this.handleAdd}
                      >
                        <PlusOutlined /> {AddCondition}
                      </Button>
                    </div>
                  </Col>
                  <Col span={4}>
                    <div className={styles.advButton}>
                      <Button onClick={this.handleSave}>
                        {BtnSave}
                      </Button>
                    </div>
                  </Col>
                </Col>
                :
                <Col span={24} style={{ display: expand ? 'block' : 'none' }}>
                  <Col span={4}>
                    <div className={styles.advButton}>
                      <Button
                        type="primary"
                        onClick={this.handleAdd}
                      >{AddCondition}
                      </Button>
                    </div>
                  </Col>
                  <Col span={3}>
                    <div className={styles.advButton}>
                      <Button onClick={this.handleSave}>
                        {BtnSave}
                      </Button>
                    </div>
                  </Col>
                  <Col span={3}>
                    <div className={styles.advButton}>
                      <Button onClick={this.handleUpd} disabled={bBtnDelDisabled}>
                        {BtnUpd}
                      </Button>
                    </div>
                  </Col>
                  <Col span={3}>
                    <div className={styles.advButton}>
                      <Button style={{ backgroundColor: '#d81e06' }} onClick={this.handleDel} disabled={bBtnDelDisabled}>
                        {setDelete}
                      </Button>
                    </div>
                  </Col>
                  <Col span={4}>
                    <div className={styles.advButton}>
                      <Button onClick={this.handleDefault}>
                        {setDefault}
                      </Button>
                    </div>
                  </Col>
                  <Col span={7}>
                    <div className={styles.advButton}>
                      <Button
                        type="primary"
                        onClick={this.handleSaveColumnSetting}
                        disabled={bBtnColumnSetting}
                      >
                        {columnDisplaySetting}
                        <SettingOutlined />
                      </Button>
                    </div>
                  </Col>
                </Col>
            }
        </Row>
        <div className={`${styles.advCol} FastFilter1`}>
          <Button type="default" onClick={this.handleSearch} className="search-btn">{btnSearch}</Button>
          <Button
            type="default"
            className="reset-btn"
            onClick={this.handleReset}
          >
            {clearOut}
          </Button>
        </div>
        {
          modalVisible ?
            <AntdDraggableModal
              visible={modalVisible}
              title={commonFunc.showMessage(app.commonConst, 'solutionFilterSave')}
              onOk={e => setTimeout(() => {
                this.handleOk(e);
              }, 300)}
              onCancel={this.handleCancel.bind(this, 'modalVisible')}
              okText="确认"
              cancelText="取消"
              confirmLoading={confirmLoading}
              maskClosable={false}
            >
              <FormItem>
                <ShowType {...showTypeSolutionNameProps} />
              </FormItem>
            </AntdDraggableModal>
            : ''
        }
        {
          modalSolutionNameVisible ?
            <AntdDraggableModal visible={modalSolutionNameVisible} title={commonFunc.showMessage(app.commonConst, 'solutionFilterNameUpd')} onOk={this.handleSolutionNameOk} onCancel={this.handleCancel.bind(this, 'modalSolutionNameVisible')} okText="确认" cancelText="取消" confirmLoading={confirmLoading} maskClosable={false}>
              <FormItem>
                <ShowType {...updSolutionNameConfigProps} />
              </FormItem>
            </AntdDraggableModal>
            : ''
        }
        {
          columnSettingVisible ?
            <AntdDraggableModal
              bodyStyle={{ paddingBottom: 0, maxHeight: 460, zIndex: 2000 }}
              width={1100}
              title={columnDisplaySetting}
              onCancel={this.handleCancel.bind(this, 'columnSettingVisible')}
              visible={columnSettingVisible}
              footer={[
                <Button key="back" onClick={this.handleCloumnSettingDelete.bind(this, 'columnSettingVisible')}>{setDelete}</Button>,
                <Button key="primary" onClick={this.handleColumnSettingSave.bind(this, 'columnSettingVisible')}>{btnSaveAndSearch}</Button>,
          ]}
            >
              <div id="searchColumn">
                <div style={{ marginTop: 0, height: '500px', overflowY: 'hidden' }} >
                  <StaticEditTable {...searchColumnShowProps} />
                </div>
              </div>
            </AntdDraggableModal>
          : ''
        }
      </div>}</div>
    );
  }
}
