Commit 9de8ae1ec5a695165a9704241af5582eeaa396f1

Authored by Min
1 parent 8bf2654f

1.commonListTab 独立搜索组件

src/components/Common/SearchTabComponent/index.js 0 → 100644
  1 +/* eslint-disable */
  2 +import React, { Component } from 'react';
  3 +import { MinusCircleOutlined, PlusOutlined, SettingOutlined } from '@ant-design/icons';
  4 +import { Form, Icon as LegacyIcon } from '@ant-design/compatible';
  5 +// import '@ant-design/compatible/assets/index.css';
  6 +import { Row, Col, Button, message, Space } from 'antd-v4';
  7 +import moment from 'moment';
  8 +import commonConfig from '@/utils/config';
  9 +import * as commonUtils from '@/utils/utils';
  10 +import * as commonFunc from '@/components/Common/commonFunc';
  11 +import * as commonServices from '@/services/services';
  12 +import ShowType from '@/components/Common/CommonComponent';
  13 +import StaticEditTable from '@/components//Common/CommonTable';
  14 +import * as commonBusiness from '@/components/Common/commonBusiness';/* 单据业务功能 */
  15 +import AntdDraggableModal from '@/components/Common/AntdDraggableModal';
  16 +import styles from './index.less';
  17 +import SvgIcon from "../../SvgIcon";
  18 +
  19 +const FormItem = Form.Item;
  20 +
  21 +export default class SearchComponent extends Component {
  22 + constructor(props) {
  23 + super(props);
  24 + this.sDateFormat = 'YYYY-MM-DD';
  25 + }
  26 +
  27 + async componentWillMount(sSearchSolutionId) {
  28 + const { token, sModelsId, formSrcRoute, sModelsType, app} = this.props;
  29 + const dataUrl = `${commonConfig.server_host}syssearch/getSyssearchData/${sModelsId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`; /* 获取快捷查找方案 */
  30 + const dataReturn = (await commonServices.getService(token, dataUrl)).data;
  31 + if (dataReturn.code === 1) {
  32 + const returnData = dataReturn.dataset.rows;
  33 + let addState = {};
  34 + if (!commonUtils.isEmpty(sSearchSolutionId)) { // 保存后重新获取快捷查找,直接默认到最新
  35 + const { masterData, searchRowKeys } = this.props;
  36 + masterData.sSearchSolutionId = sSearchSolutionId;
  37 + masterData.bCheck = true; // 为了复制到
  38 + masterData.sSolutionName = returnData.filter(item => item.sId === sSearchSolutionId)[0].sName;
  39 + if (commonUtils.isNotEmptyArr(searchRowKeys)) {
  40 + searchRowKeys.forEach((item) => {
  41 + masterData[`${item}disabled`] = false;
  42 + });
  43 + }
  44 + addState.masterData = masterData;
  45 + addState.modalVisible = false;
  46 + addState.modalSolutionNameVisible = false;
  47 + } else if (commonUtils.isNotEmptyArr(returnData)) { /* 初始化默认查询方案的参数 */
  48 + const iIndex = returnData.findIndex(item => item.bDefault);
  49 + const defaultSearchSolution = iIndex > -1 ? returnData[iIndex] : returnData[0];
  50 + addState = await this.defaultSearchSolution(defaultSearchSolution);
  51 + if(commonUtils.isNotEmptyArr(addState.newFilterCondition)) {
  52 + const newFilterConditionStr = JSON.stringify(addState.newFilterCondition) ;
  53 + const newConditionStr = JSON.stringify(defaultSearchSolution.sCondition) ;
  54 + if(commonUtils.isNotEmptyObject(newFilterConditionStr) && commonUtils.isNotEmptyObject(newConditionStr)){
  55 + if(newFilterConditionStr !== defaultSearchSolution.sCondition){
  56 + returnData[0].sCondition = newFilterConditionStr;
  57 + }
  58 + }
  59 + }
  60 + }
  61 + this.props.onSaveState({ sGroupByList: addState.sGroupByList, searchSolution: returnData, ...addState });
  62 + } else {
  63 + this.props.getServiceError(dataReturn);
  64 + }
  65 + }
  66 +
  67 + async componentWillReceiveProps(nextProps) {
  68 + const {
  69 + formData, slaveConfig, bSearchConfig, searchSolution,
  70 + } = nextProps;
  71 + let {
  72 + searchColumns, searchRowKeys, masterData,
  73 + } = nextProps;
  74 + const { sModelsType } = nextProps;
  75 + if (commonUtils.isEmptyArr(searchColumns) && formData.length > 0 && !bSearchConfig && slaveConfig) {
  76 + const findFilter = commonFunc.getConfigFieldNameData(slaveConfig, 'bFind');
  77 + searchColumns = [];
  78 + findFilter.forEach((item) => {
  79 + searchColumns.push({
  80 + sValue: item.showName, sId: item.sName, sDropDownType: item.sDropDownType, showDropDown: item.showDropDown, sConfigId: item.sId, sAssignField: item.sAssignField,
  81 + sSqlCondition: item.sSqlCondition,
  82 + });
  83 + });
  84 + let addState;
  85 + if (commonUtils.isEmptyArr(searchRowKeys)) { /* 初始化没有默认方案时的 默认查询值 */
  86 + searchRowKeys = [];
  87 + if (commonUtils.isNotEmptyArr(searchColumns)) {
  88 + const key = commonUtils.createSid();
  89 + searchRowKeys.push(key);
  90 + masterData = commonUtils.isEmptyObject(masterData) ? (sModelsType === 'commonClassify' ? { bCheck: false } : { bCheck: true }) : masterData;
  91 + const sFirstValue = searchColumns[0].sId;
  92 + masterData[`sFirst-${key}`] = searchColumns[0].sId;
  93 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' : sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
  94 + masterData[`sSecond-${key}`] = commonConfig.seaJudge[firstDataIndex][0].sId;
  95 + }
  96 + } else {
  97 + addState = await this.defaultSearchSolution(searchSolution[0]);
  98 + }
  99 + this.props.onSaveState({
  100 + searchColumns, searchRowKeys, masterData, bSearchConfig: true, ...addState,
  101 + });
  102 + }
  103 + const { masterConfig, app } = nextProps;
  104 + if (commonUtils.isNotEmptyObject(masterConfig)) {
  105 + let { searchColumnShowColumn } = nextProps;
  106 + if (commonUtils.isEmptyArr(searchColumnShowColumn)) {
  107 + const searchColumnShowConfig = {};
  108 + const columniOrder = commonFunc.showMessage(app.commonConst, 'columniOrder');/* 排序 */
  109 + const columnShowName = commonFunc.showMessage(app.commonConst, 'columnShowName');/* 显示名 */
  110 + const columniFitWidth = commonFunc.showMessage(app.commonConst, 'columniFitWidth');/* 宽度 */
  111 + const columnbVisible = commonFunc.showMessage(app.commonConst, 'columnbVisible');/* 是否显示 */
  112 + const columnChinese = commonFunc.showMessage(app.commonConst, 'columnChinese');/* 中文 */
  113 + const columnEnglish = commonFunc.showMessage(app.commonConst, 'columnEnglish');/* 英文 */
  114 + const columnBig5 = commonFunc.showMessage(app.commonConst, 'columnBig5');/* 繁体 */
  115 + const columnsType = commonFunc.showMessage(app.commonConst, 'columnsType');/* 汇总类型 */
  116 + const columnSQL = commonFunc.showMessage(app.commonConst, 'columnSQL');/* SQL语句 */
  117 + searchColumnShowConfig.gdsconfigformslave = [
  118 + {
  119 + bVisible: false,
  120 + sName: 'sId',
  121 + bNotEmpty: true,
  122 + showName: 'sId',
  123 + }, {
  124 + bVisible: true,
  125 + sName: 'iOrder',
  126 + bNotEmpty: true,
  127 + showName: '排序',
  128 + }, {
  129 + bVisible: true,
  130 + sName: 'sName',
  131 + bNotEmpty: true,
  132 + bReadonly: true,
  133 + showName: '字段名',
  134 + }, {
  135 + bVisible: true,
  136 + sName: 'sChinese',
  137 + bNotEmpty: true,
  138 + showName: '中文名',
  139 + }, {
  140 + bVisible: true,
  141 + sName: 'sEnglish',
  142 + bNotEmpty: true,
  143 + showName: '英文名',
  144 + }, {
  145 + bVisible: true,
  146 + sName: 'sBig5',
  147 + bNotEmpty: true,
  148 + showName: '繁体',
  149 + }, {
  150 + bVisible: true,
  151 + sName: 'iFitWidth',
  152 + bNotEmpty: true,
  153 + showName: '宽度',
  154 + }, {
  155 + bVisible: true,
  156 + sName: 'sType',
  157 + sDropDownType: 'const',
  158 + bNotEmpty: true,
  159 + showName: '汇总类型',
  160 + iVisCount: 1,
  161 + showDropDown: [{ value: '请选择', sId: '' },
  162 + { value: '分组', sId: 'groupBy' },
  163 + { value: '最大值', sId: 'max' },
  164 + { value: '最小值', sId: 'min' },
  165 + { value: '平均数', sId: 'avg' },
  166 + { value: '求和', sId: 'sum' },
  167 + { value: '行数', sId: 'count' },
  168 + { value: 'sql语句', sId: 'sql' }],
  169 + }, {
  170 + bVisible: true,
  171 + sName: 'sSql',
  172 + bNotEmpty: true,
  173 + showName: 'SQL语句',
  174 + }, {
  175 + bVisible: true,
  176 + sName: 'bShow',
  177 + bNotEmpty: true,
  178 + showName: '是否显示',
  179 + }];
  180 + searchColumnShowColumn = [{
  181 + title: columniOrder,
  182 + dataIndex: 'iOrder',
  183 + width: 60,
  184 + }, {
  185 + title: columnShowName,
  186 + dataIndex: 'sName',
  187 + width: 120,
  188 + }, {
  189 + title: columnChinese,
  190 + dataIndex: 'sChinese',
  191 + width: 80,
  192 + }, {
  193 + title: columnEnglish,
  194 + dataIndex: 'sEnglish',
  195 + width: 80,
  196 + }, {
  197 + title: columnBig5,
  198 + dataIndex: 'sBig5',
  199 + width: 80,
  200 + }, {
  201 + title: columniFitWidth,
  202 + dataIndex: 'iFitWidth',
  203 + width: 80,
  204 + }, {
  205 + title: columnbVisible,
  206 + dataIndex: 'bShow',
  207 + width: 60,
  208 + }, {
  209 + title: columnsType,
  210 + dataIndex: 'sType',
  211 + width: 120,
  212 + }, {
  213 + title: columnSQL,
  214 + dataIndex: 'sSql',
  215 + width: 269,
  216 + }];
  217 + const tableConfig = masterConfig.gdsconfigformslave;
  218 + const searchColumnShowData = [];
  219 + for (const child of tableConfig) {
  220 + if (child.sName !== '' && child.bVisible && child.showName !== '') {
  221 + searchColumnShowData.push({
  222 + sId: child.sId,
  223 + iOrder: child.iOrder,
  224 + sChinese: child.sChinese,
  225 + sEnglish: child.sEnglish,
  226 + sBig5: child.sBig5,
  227 + sName: child.sName,
  228 + iFitWidth: child.iFitWidth,
  229 + sType: '',
  230 + sSql: '',
  231 + bShow: false,
  232 + });
  233 + }
  234 + }
  235 + const searchColumnShowAllData = JSON.parse(JSON.stringify(searchColumnShowData));
  236 + this.props.onSaveState({
  237 + searchColumnShowColumn, searchColumnShowData, searchColumnShowAllData, searchColumnShowConfig,
  238 + });
  239 + }
  240 + }
  241 + }
  242 +
  243 + componentDidMount() {
  244 + this.props.onSaveState({ onBtnSearch: this.handleSearch });
  245 + }
  246 +
  247 + onKeyUp = (e) => {
  248 + if (e.key === 'Enter') {
  249 + setTimeout(() => {
  250 + this.handleSearch();
  251 + }, 500);
  252 + }
  253 + }
  254 +
  255 + async defaultSearchSolution(searchSolutionDataRow) {
  256 + /* 判断是否有分组 */
  257 + const sGroupByList = commonUtils.isNotEmptyObject(searchSolutionDataRow) ? searchSolutionDataRow.sGroupByList : '[]';
  258 + const column = [];
  259 + if (commonUtils.isNotEmptyArr(sGroupByList)) {
  260 + /* 有分组查询 */
  261 + for (const child of sGroupByList) {
  262 + if (child.sName !== '' && child.bShow) {
  263 + column.push({
  264 + title: child.sChinese,
  265 + dataIndex: child.sName,
  266 + width: child.iFitWidth,
  267 + bFind: true,
  268 + bNotEmpty: false,
  269 + });
  270 + }
  271 + }
  272 + }
  273 + const { expand } = false;
  274 + const highlightColor = false;
  275 + const { sModelsType, sModelsId, app } = this.props;
  276 + const { userinfo } = app;
  277 + const masterData = sModelsType && sModelsType.includes('commonClassify') ? { bCheck: false } : { bCheck: true };
  278 + const searchRowKeys = [];
  279 + masterData.sSearchSolutionId = searchSolutionDataRow.sId;
  280 + masterData.sSolutionName = searchSolutionDataRow.sName; /* 修改方案名称,拿到选中方案名称 */
  281 + const filterCondition = JSON.parse(searchSolutionDataRow.sCondition);
  282 + const ownerFlag = userinfo.sId === searchSolutionDataRow.sUserId || (searchSolutionDataRow.sType === 'common' && this.props.app.userinfo.sType === 'sysadmin');
  283 + const filterConditionAsync = async () => {
  284 + for (let i = 0, len = filterCondition.length; i < len; i += 1) {
  285 + const item = filterCondition[i];
  286 + const key = commonUtils.createSid();
  287 + searchRowKeys.push(key);
  288 + const sFirstValue = item.bFilterName;
  289 + masterData[`${key}disabled`] = !ownerFlag;
  290 + masterData[`sFirst-${key}`] = sFirstValue;
  291 + const sSecondValue = item.bFilterCondition;
  292 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
  293 + (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'betweenDay' || sSecondValue === 'betweenYestday' || sSecondValue === 'week'|| sSecondValue === 'weekPre' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
  294 + masterData[`sSecond-${key}`] = item.bFilterCondition;
  295 + if (sSecondValue === 'day') {
  296 + masterData[`${firstDataIndex}Third-${key}`] = moment().format(this.sDateFormat);
  297 + } else if (sSecondValue === 'unDayDo') {
  298 + masterData[`${firstDataIndex}Third-${key}`] = moment().format(this.sDateFormat);
  299 + } else if (sSecondValue === 'daybefore') { /* 今天之前 */
  300 + masterData[`${firstDataIndex}Third-${key}`] = moment().subtract(1,"days").format(this.sDateFormat);
  301 + if(sFirstValue?.includes('_pro')){
  302 + item.bFilterValue = masterData[`${firstDataIndex}Third-${key}`]
  303 + }
  304 + } else if (sSecondValue === 'tomorrowbefore') { /* 明天之前 */
  305 + masterData[`${firstDataIndex}Third-${key}`] = moment().add(1,"days").format(this.sDateFormat);
  306 + if(sFirstValue?.includes('_pro')){
  307 + item.bFilterValue = masterData[`${firstDataIndex}Third-${key}`]
  308 + }
  309 + } else if (sSecondValue === 'aftertomorrowbefore') { /* 后天之前 */
  310 + masterData[`${firstDataIndex}Third-${key}`] = moment().add(2,"days").format(this.sDateFormat);
  311 + if(sFirstValue?.includes('_pro')){
  312 + item.bFilterValue = masterData[`${firstDataIndex}Third-${key}`]
  313 + }
  314 + } else if (sSecondValue === 'betweenDay') {
  315 + const dateBetween = [];
  316 + console.log('bFilterValue', item.bFilterValue);
  317 + if(commonUtils.isEmptyObject(item.bFilterValue) || item.bFilterValue.split(',').length < 2) {
  318 + dateBetween.push(moment());
  319 + dateBetween.push(moment());
  320 + if(sFirstValue?.includes('_pro') && commonUtils.isNotEmptyArr(dateBetween)){
  321 + const tStartDate = moment(dateBetween[0]).format(this.sDateFormat);
  322 + const tEndDate = moment(dateBetween[1]).add(1,"days").format(this.sDateFormat);
  323 + let bFilterNewValue = `${tStartDate},${tEndDate}`;
  324 + item.bFilterValue = bFilterNewValue;
  325 + }
  326 + } else if (item.bFilterValue.split(',').length === 2) {
  327 + if (item.bFilterValue.split(',')[0] !== 'null') {
  328 + dateBetween.push(moment(item.bFilterValue.split(',')[0]));
  329 + dateBetween.push(moment(item.bFilterValue.split(',')[1]).subtract(1, 'days')); /* 日期区间需要将bFilterValue日期减一天 */
  330 + }
  331 + }
  332 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  333 + } else if (sSecondValue === 'betweenYestday') {
  334 + const dateBetween = [];
  335 + if(commonUtils.isEmptyObject(item.bFilterValue) || item.bFilterValue.split(',').length < 2) {
  336 + dateBetween.push(moment().subtract(1,"days"));
  337 + dateBetween.push(moment().subtract(1,"days"));
  338 + if(sFirstValue?.includes('_pro') && commonUtils.isNotEmptyArr(dateBetween)){
  339 + const tStartDate = moment(dateBetween[0]).format(this.sDateFormat);
  340 + const tEndDate = moment(dateBetween[1]).add(1,"days").format(this.sDateFormat);
  341 + let bFilterNewValue = `${tStartDate},${tEndDate}`;
  342 + item.bFilterValue = bFilterNewValue;
  343 + }
  344 + } else if (item.bFilterValue.split(',').length === 2) {
  345 + if (item.bFilterValue.split(',')[0] !== 'null') {
  346 + dateBetween.push(moment(item.bFilterValue.split(',')[0]));
  347 + dateBetween.push(moment(item.bFilterValue.split(',')[1]).subtract(1, 'days')); /* 日期区间需要将bFilterValue日期减一天 */
  348 + }
  349 + }
  350 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  351 + } else if (sSecondValue === 'month') {
  352 + const dateBetween = [];
  353 + dateBetween.push(moment().startOf('month'));
  354 + dateBetween.push(moment().endOf('month'));
  355 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  356 + } else if (sSecondValue === 'monthPre') {
  357 + const dateBetween = [];
  358 + dateBetween.push(moment().startOf('month').subtract('month', 1));
  359 + dateBetween.push(moment().endOf('month').subtract('month', 1).endOf('month'));
  360 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  361 + } else if (sSecondValue === 'week') {
  362 + const dateBetween = [];
  363 + dateBetween.push(moment().startOf('week'));
  364 + dateBetween.push(moment().endOf('week'));
  365 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  366 + } else if (sSecondValue === 'weekPre') {
  367 + const dateBetween = [];
  368 + dateBetween.push(moment(moment().week(moment().week() - 1).startOf('week').valueOf()));
  369 + dateBetween.push(moment(moment().week(moment().week() - 1).endOf('week').valueOf()));
  370 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  371 + } else if (item.bFilterCondition === 'between' || item.bFilterCondition === 'betweenTime') {
  372 + if (item.bFilterValue.split(',').length === 2) {
  373 + const dateBetween = [];
  374 + if (item.bFilterValue.split(',')[0] !== 'null') {
  375 + dateBetween.push(moment(item.bFilterValue.split(',')[0]));
  376 + dateBetween.push(moment(item.bFilterValue.split(',')[1]).subtract(1, 'days')); /* 日期区间需要将bFilterValue日期减一天 */
  377 + }
  378 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  379 + } else {
  380 + masterData[`${firstDataIndex}Third-${key}`] = moment(item.bFilterValue);
  381 + }
  382 + } else if (sSecondValue === 'period') {
  383 + if (firstDataIndex === 'p') {
  384 + const dateBetween = [];
  385 + dateBetween.push(moment().startOf('month'));
  386 + dateBetween.push(moment().endOf('month'));
  387 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  388 + } else if (firstDataIndex === 'm') {
  389 + masterData[`${firstDataIndex}Third-${key}`] = moment(new Date());
  390 + } else if (firstDataIndex === 'y') {
  391 + masterData[`${firstDataIndex}Third-${key}`] = moment(new Date());
  392 + }
  393 + } else if (firstDataIndex === 't') {
  394 + masterData[`${firstDataIndex}Third-${key}`] = moment(item.bFilterValue);
  395 + } else if(sModelsId === '12710101117200946822170' && sFirstValue === 'sTXT50' && commonUtils.isEmptyObject(item.bFilterValue)){
  396 + if(commonUtils.isNotEmptyObject(app)&& commonUtils.isNotEmptyObject(app.currentPane)) {
  397 + const { conditonValues } = app.currentPane;
  398 + if(commonUtils.isNotEmptyObject(conditonValues)) {
  399 + masterData[`${firstDataIndex}Third-${key}`] = commonUtils.isNotEmptyObject(conditonValues.sAnlnName) ?
  400 + conditonValues.sAnlnName : '';
  401 + }
  402 + }
  403 + } else {
  404 + const { slaveConfig } = this.props;
  405 + if (commonUtils.isNotEmptyObject(slaveConfig)) {
  406 + const iIndex = slaveConfig.gdsconfigformslave.findIndex(itemData => itemData.sName === sFirstValue);
  407 + if (iIndex > -1 && slaveConfig.gdsconfigformslave[iIndex].sDropDownType === 'sql') {
  408 + const sqlDropDownData = await this.props.getSqlDropDownData(this.props.sModelsId, 'master', slaveConfig.gdsconfigformslave[iIndex]);
  409 + const { dropDownData } = sqlDropDownData;
  410 + const iValueIndex = dropDownData.findIndex(itemData => itemData.sId === item.bFilterValue);
  411 + if (iValueIndex > -1) {
  412 + masterData[`${firstDataIndex}Third-${key}`] = dropDownData[iValueIndex].sName;
  413 + masterData[`${firstDataIndex}Third-${key}Id`] = item.bFilterValue;
  414 + }
  415 + } else {
  416 + masterData[`${firstDataIndex}Third-${key}`] = item.bFilterValue;
  417 + }
  418 + } else {
  419 + masterData[`${firstDataIndex}Third-${key}`] = item.bFilterValue;
  420 + }
  421 + }
  422 + }
  423 + };
  424 + filterConditionAsync();
  425 + return {
  426 + masterData, searchRowKeys, slaveGroupColumn: column, sGroupByList, expand, highlightColor, newFilterCondition: filterCondition
  427 + };
  428 + }
  429 + handeToggle = () => {
  430 + /* 是否展开多出的条件内容 */
  431 + const { expand } = this.props;
  432 + this.props.onSaveState({ expand: !expand });
  433 + };
  434 +
  435 + handleSearchProps(showConfig) {
  436 + const { masterData } = this.props;
  437 + return {
  438 + form: this.props.form,
  439 + getSqlDropDownData: this.props.getSqlDropDownData,
  440 + getSqlCondition: this.props.getSqlCondition,
  441 + handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord,
  442 + getFloatNum: this.props.getFloatNum,
  443 + getDateFormat: this.props.getDateFormat,
  444 + onChange: this.handleMasterChange,
  445 + showConfig,
  446 + formItemLayout: {},
  447 + textArea: false,
  448 + enabled: true,
  449 + dataValue: commonUtils.isNotEmptyObject(masterData) ? masterData[showConfig.sName] : '',
  450 + bTable: false,
  451 + formRoute: this.props.formRoute,
  452 + sSqlCondition:showConfig.sSqlCondition,
  453 + name: 'master',
  454 + record: masterData,
  455 + noDebounce: true
  456 + };
  457 + }
  458 +
  459 + handleSearch = (_, isQueryCondition) => {
  460 + window.vlistNewSearh = true;
  461 + const {
  462 + searchRowKeys, masterData, slaveConfig, slaveInfoConfig, setSearchSlaveInfo,
  463 + slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, slave5Config, slave6Config, slave7Config, slave8Config, slave9Config, slave10Config, slave11Config, slave12Config,
  464 + slave13Config, slave14Config, slave15Config, slaveOrderBy, sModelsId,
  465 + } = this.props;
  466 + const filterCondition = []; /* 数据筛选条件 */
  467 + searchRowKeys.map((key) => {
  468 + const { [`sFirst-${key}`]: sFirstValue, [`sSecond-${key}`]: sSecondValue } = masterData;
  469 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
  470 + (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'betweenDay' || sSecondValue === 'betweenYestday' || sSecondValue === 'week'|| sSecondValue === 'weekPre' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
  471 + const sThirdName = `${firstDataIndex}Third-${key}`;
  472 + let thirdValue = masterData[sThirdName];
  473 + const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === sFirstValue);
  474 + if (iIndex > -1 && slaveConfig.gdsconfigformslave[iIndex].sDropDownType === 'sql') {
  475 + if (!commonUtils.isEmpty(masterData[`${sThirdName}Id`])) {
  476 + thirdValue = masterData[`${sThirdName}Id`];
  477 + } if (!commonUtils.isEmpty(masterData[sFirstValue])) {
  478 + thirdValue = masterData[sFirstValue];
  479 + }
  480 + }
  481 + if (!commonUtils.isEmpty(thirdValue) || firstDataIndex === 'b') {
  482 + if (firstDataIndex === 'p') {
  483 + const tStartDate = sSecondValue === 'betweenTime' ? (commonUtils.isNotEmptyObject(thirdValue[0]) ? moment(thirdValue[0]).format('YYYY-MM-DD HH:mm:ss') : null) : (commonUtils.isNotEmptyObject(thirdValue[0]) ? moment(thirdValue[0]).format(this.sDateFormat) : null);
  484 + const tEndDate = sSecondValue === 'betweenTime' ? (commonUtils.isNotEmptyObject(thirdValue[1]) ? moment(thirdValue[1]).format('YYYY-MM-DD HH:mm:ss') : null) : (commonUtils.isNotEmptyObject(thirdValue[1]) ? moment(thirdValue[1]).add(1, 'days').format(this.sDateFormat) : null);
  485 + filterCondition.push({
  486 + bFilterName: sFirstValue,
  487 + bFilterCondition: sSecondValue,
  488 + bFilterValue: `${tStartDate},${tEndDate}`,
  489 + });
  490 + } else if (firstDataIndex === 'm') {
  491 + const tStartDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm:ss') : moment(thirdValue).startOf('month').format(this.sDateFormat);
  492 + const tEndDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm:ss') : moment(thirdValue).endOf('month').add(1, 'days').format(this.sDateFormat);
  493 + filterCondition.push({
  494 + bFilterName: `t${sFirstValue.substring(1, sFirstValue.length)}`,
  495 + bFilterCondition: sSecondValue,
  496 + bFilterValue: `${tStartDate},${tEndDate}`,
  497 + });
  498 + }else if (firstDataIndex === 'y') {
  499 + const tStartDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm:ss') : moment(thirdValue).startOf('year').format(this.sDateFormat);
  500 + const tEndDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm:ss') : moment(thirdValue).endOf('year').add(1, 'days').format(this.sDateFormat);
  501 + filterCondition.push({
  502 + bFilterName: `t${sFirstValue.substring(1, sFirstValue.length)}`,
  503 + bFilterCondition: sSecondValue,
  504 + bFilterValue: `${tStartDate},${tEndDate}`,
  505 + });
  506 + } else if (firstDataIndex === 't') {
  507 + filterCondition.push({
  508 + bFilterName: sFirstValue,
  509 + bFilterCondition: sSecondValue,
  510 + bFilterValue: moment(thirdValue).format(this.sDateFormat),
  511 + });
  512 + } else if (firstDataIndex === 'b') {
  513 + filterCondition.push({
  514 + bFilterName: sFirstValue,
  515 + bFilterCondition: sSecondValue,
  516 + bFilterValue: thirdValue ? true : false,
  517 + });
  518 + } else {
  519 + filterCondition.push({
  520 + bFilterName: sFirstValue,
  521 + bFilterCondition: sSecondValue,
  522 + bFilterValue: thirdValue,
  523 + });
  524 + }
  525 + }
  526 + return true;
  527 + });
  528 + /* 判断是否要加载过滤树数据 */
  529 + const filterTreeConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.bTree);
  530 + if (commonUtils.isNotEmptyArr(filterTreeConfigArr)) {
  531 + const filterTreeConfig = filterTreeConfigArr[0];
  532 + this.props.onGetFilterTreeData(filterTreeConfig, filterCondition, 1);
  533 + let { treeSelectedKeys } = this.props;
  534 + if (commonUtils.isNotEmptyArr(treeSelectedKeys)) { /* 清除原来选中树节点 */
  535 + treeSelectedKeys = [];
  536 + this.props.onSaveState({
  537 + treeSelectedKeys, treeFilterCondition: [],
  538 + });
  539 + }
  540 + }
  541 + /*
  542 + 修改日期:2021-03-17
  543 + 修改人:吕杰
  544 + 区域:以下一行
  545 + 需求变更:fix 2135 搜索时添加loading动画
  546 + */
  547 + // 添加props传入的判断条件
  548 + // let customfilterCondition = filterCondition.slice(0);
  549 + // if (customSlaveFilterCondition) {
  550 + // customfilterCondition = filterCondition.concat(customSlaveFilterCondition);
  551 + // }
  552 +
  553 + /**
  554 + * 获取 bFilterName 首字母为t
  555 + */
  556 + if (isQueryCondition && sModelsId === '12710101117253309349270') {
  557 + return filterCondition.filter(i => i && ['t', 'p'].includes(i.bFilterName?.[0]));;
  558 + }
  559 +
  560 + this.props.onSaveState({ pageLoading: true });
  561 + /* commonListTab搜索时 根据当前Tab页签所在表格进行查询 */
  562 + if(commonUtils.isNotEmptyObject(location.pathname) && location.pathname.includes('commonListTab')) {
  563 + this.props.onGetSearchData(slaveConfig, filterCondition, undefined,undefined,undefined,undefined,undefined,undefined,undefined, slave0Config);
  564 + } else {
  565 + this.props.onGetData(slaveConfig, filterCondition, undefined,undefined,slaveOrderBy,undefined,undefined,undefined,undefined,
  566 + slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, slave5Config, slave6Config, slave7Config, slave8Config, slave9Config, slave10Config, slave11Config, slave12Config, slave13Config, slave14Config, slave15Config);
  567 + }
  568 + if (setSearchSlaveInfo === 'Y') {
  569 + if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
  570 + this.props.onGetDataInfo(slaveInfoConfig, filterCondition);
  571 + }
  572 + } else {
  573 + this.props.onSaveState({
  574 + expKeys: [],
  575 + slaveInfoSelectedRowKeys: [],
  576 + slaveInfoSelectedData: [],
  577 + slaveInfoData: [], /* 清除生产主计划,生产排程明细表数据 */
  578 + });
  579 + }
  580 + }
  581 +
  582 + /**
  583 + * @param {*} name json
  584 + * @param {*} bFilterName 首字母修改
  585 + * @returns
  586 + */
  587 + handleFirstNameEqual = (name, bFilterName) => {
  588 + if (typeof bFilterName === 'string' && typeof name === 'string' && ['m', 'y'].includes(name[0])) {
  589 + return bFilterName.substring(1) === name.substring(1);
  590 + }
  591 + }
  592 +
  593 + /** 修改主表数据 */
  594 + handleMasterChange = async (name, sFieldName, changeValue, sId, dropDownData) => {
  595 + // let { expand } = false;
  596 + if (sFieldName === 'sSearchSolutionId' && false && !location.pathname.toLowerCase().includes('productionmainplan')) {
  597 + const {
  598 + searchSolution, slaveConfig, slaveInfoConfig, setSearchSlaveInfo,
  599 + } = this.props;
  600 +
  601 + const searchCondition = this.handleSearch(_ , true);
  602 + const iIndex = searchSolution.findIndex(item => item.sId === changeValue[sFieldName]);
  603 + let filterCondition = JSON.parse(searchSolution[iIndex].sCondition || "[]");
  604 + if (Array.isArray(searchCondition) && searchCondition.length) {
  605 + if (Array.isArray(filterCondition) && filterCondition.length) {
  606 + const keys = searchCondition.map(i => i?.bFilterName).filter(Boolean);
  607 + filterCondition = filterCondition.filter(i => !keys.includes(i?.bFilterName) && !keys.find(j => this.handleFirstNameEqual(i?.bFilterName, j)));
  608 + }
  609 + filterCondition = [...searchCondition, ...filterCondition || []];
  610 + }
  611 +
  612 + const addState = await this.defaultSearchSolution({ ...searchSolution[iIndex] || {}, sCondition: JSON.stringify(filterCondition) });
  613 + this.props.onSaveState({ ...addState }, () => {
  614 + this.props.onGetData(slaveConfig, filterCondition, '', '', '', '', addState.sGroupByList,);
  615 + });
  616 + /* 判断是否要加载过滤树数据 */
  617 + const filterTreeConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.bTree);
  618 + if (commonUtils.isNotEmptyArr(filterTreeConfigArr)) {
  619 + const filterTreeConfig = filterTreeConfigArr[0];
  620 + this.props.onGetFilterTreeData(filterTreeConfig, filterCondition, 1);
  621 + let { treeSelectedKeys } = this.props;
  622 + if (commonUtils.isNotEmptyArr(treeSelectedKeys)) { /* 清除原来选中树节点 */
  623 + treeSelectedKeys = [];
  624 + this.props.onSaveState({
  625 + treeSelectedKeys, treeFilterCondition: [],
  626 + });
  627 + }
  628 + }
  629 + if (setSearchSlaveInfo === 'Y') {
  630 + if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
  631 + this.props.onGetDataInfo(slaveInfoConfig, JSON.parse(searchSolution[iIndex].sCondition));
  632 + }
  633 + }
  634 + // /* 当搜索条件有一个为空时,则展开 */
  635 + // const searchSolutions = JSON.parse(searchSolution[iIndex].sCondition);
  636 + // const showConfigArr = searchSolutions.filter(item => commonUtils.isEmpty(item.bFilterValue) || item.bFilterValue === false);
  637 + // /* 当搜索条件只有一行时,不展开 */
  638 + // if (searchSolutions.length > 1 && commonUtils.isNotEmptyArr(showConfigArr) && showConfigArr.length > 0) {
  639 + // expand = true;
  640 + // }
  641 + // this.props.onSaveState({ expand });
  642 + } else if (sFieldName === 'sSearchSolutionId' ) {
  643 + const {
  644 + searchSolution, slaveConfig, slaveInfoConfig, setSearchSlaveInfo,
  645 + } = this.props;
  646 + const iIndex = searchSolution.findIndex(item => item.sId === changeValue[sFieldName]);
  647 + const addState = await this.defaultSearchSolution(searchSolution[iIndex]);
  648 + const filterCondition = JSON.parse(searchSolution[iIndex].sCondition);
  649 +
  650 + this.props.onSaveState({ ...addState }, () => {
  651 + this.props.onGetData(slaveConfig, JSON.parse(searchSolution[iIndex].sCondition), '', '', '', '', addState.sGroupByList);
  652 + });
  653 + /* 判断是否要加载过滤树数据 */
  654 + const filterTreeConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.bTree);
  655 + if (commonUtils.isNotEmptyArr(filterTreeConfigArr)) {
  656 + const filterTreeConfig = filterTreeConfigArr[0];
  657 + this.props.onGetFilterTreeData(filterTreeConfig, filterCondition, 1);
  658 + let { treeSelectedKeys } = this.props;
  659 + if (commonUtils.isNotEmptyArr(treeSelectedKeys)) { /* 清除原来选中树节点 */
  660 + treeSelectedKeys = [];
  661 + this.props.onSaveState({
  662 + treeSelectedKeys, treeFilterCondition: [],
  663 + });
  664 + }
  665 + }
  666 + if (setSearchSlaveInfo === 'Y') {
  667 + if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
  668 + this.props.onGetDataInfo(slaveInfoConfig, JSON.parse(searchSolution[iIndex].sCondition));
  669 + }
  670 + }
  671 + } else if (sFieldName.includes('sFirst-')) {
  672 + const { slaveConfig } = this.props;
  673 + const { masterData } = this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true);
  674 + const sFirstValue = masterData[sFieldName];
  675 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' : sFirstValue.substring(0, 1);
  676 + const key = sFieldName.substring('sFirst-'.length, sFieldName.length);
  677 + const sSecondConditionPro = firstDataIndex === 's' && sFirstValue.endsWith('_pro'); /* 字段名以s开头,sFilterName以pro结尾,则只有等于条件 */
  678 + const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === sFirstValue);
  679 + masterData[`sSecond-${key}`] = sSecondConditionPro && iIndex > -1 && slaveConfig.gdsconfigformslave[iIndex].sDropDownType === 'sql' ?
  680 + commonConfig.seaJudge.s_proDropDown[0].sId : sSecondConditionPro ?
  681 + commonConfig.seaJudge.s_pro[0].sId : commonConfig.seaJudge[firstDataIndex][0].sId;
  682 + masterData[`${firstDataIndex}Third-${key}`] = firstDataIndex === 'b' ? false : firstDataIndex === 't' ? moment().format(this.sDateFormat) : masterData[`${firstDataIndex}Third-${key}`];
  683 + this.props.onSaveState({ masterData });
  684 + } else if (sFieldName.includes('sSecond-')) {
  685 + const { masterData } = this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true);
  686 + const sSecondValue = masterData[sFieldName];
  687 + const key = sFieldName.substring('sSecond-'.length, sFieldName.length);
  688 + const sFirstValue = masterData[`sFirst-${key}`];
  689 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
  690 + (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'betweenDay' || sSecondValue === 'betweenYestday' || sSecondValue === 'week' || sSecondValue === 'weekPre' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
  691 + if (sSecondValue === 'day') {
  692 + masterData[`${firstDataIndex}Third-${key}`] = moment().format(this.sDateFormat);
  693 + }else if (sSecondValue === 'unDayDo') {
  694 + masterData[`${firstDataIndex}Third-${key}`] = moment().format(this.sDateFormat);
  695 + } else if (sSecondValue === 'daybefore') { /* 今天之前 */
  696 + masterData[`${firstDataIndex}Third-${key}`] = moment().subtract(1,"days").format(this.sDateFormat);
  697 + } else if (sSecondValue === 'tomorrowbefore') { /* 明天之前 */
  698 + masterData[`${firstDataIndex}Third-${key}`] = moment().add(1,"days").format(this.sDateFormat);
  699 + } else if (sSecondValue === 'aftertomorrowbefore') { /* 后天之前 */
  700 + masterData[`${firstDataIndex}Third-${key}`] = moment().add(2,"days").format(this.sDateFormat);
  701 + } else if (sSecondValue === 'betweenDay') {
  702 + const dateBetween = [];
  703 + dateBetween.push(moment());
  704 + dateBetween.push(moment());
  705 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  706 + } else if (sSecondValue === 'betweenYestday') {
  707 + const dateBetween = [];
  708 + dateBetween.push(moment().subtract(1,"days"));
  709 + dateBetween.push(moment().subtract(1,"days"));
  710 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  711 + } else if (sSecondValue === 'month') {
  712 + const dateBetween = [];
  713 + dateBetween.push(moment().startOf('month'));
  714 + dateBetween.push(moment().endOf('month'));
  715 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  716 + } else if (sSecondValue === 'monthPre') {
  717 + const dateBetween = [];
  718 + dateBetween.push(moment().startOf('month').subtract('month', 1));
  719 + dateBetween.push(moment().endOf('month').subtract('month', 1).endOf('month'));
  720 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  721 + } else if (sSecondValue === 'week') {
  722 + const dateBetween = [];
  723 + dateBetween.push(moment().startOf('week'));
  724 + dateBetween.push(moment().endOf('week'));
  725 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  726 + } else if (sSecondValue === 'weekPre') {
  727 + const dateBetween = [];
  728 + dateBetween.push(moment(moment().week(moment().week() - 1).startOf('week').valueOf()));
  729 + dateBetween.push(moment(moment().week(moment().week() - 1).endOf('week').valueOf()));
  730 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  731 + } else if (sSecondValue === 'period') { /* 本期间 */
  732 + if (firstDataIndex === 'm') {
  733 + masterData[`${firstDataIndex}Third-${key}`] = moment(new Date());
  734 + } else if (firstDataIndex === 'p') {
  735 + const dateBetween = [];
  736 + dateBetween.push(moment().startOf('month'));
  737 + dateBetween.push(moment().endOf('month'));
  738 + masterData[`${firstDataIndex}Third-${key}`] = dateBetween;
  739 + }
  740 + }
  741 + this.props.onSaveState({ masterData });
  742 + } else {
  743 + this.props.onChange('master', sFieldName, changeValue, sId, dropDownData);
  744 + }
  745 + };
  746 +
  747 + handleFields = (searchColumns) => {
  748 + /* 默认快捷过滤 */
  749 + if (commonUtils.isEmptyArr(searchColumns)) { return; }
  750 + const { masterData, searchRowKeys, app } = this.props;
  751 + const children = searchRowKeys.map((key) => {
  752 + const { [`sFirst-${key}`]: sFirstValue, [`sSecond-${key}`]: sSecondValue, [`${key}disabled`]: disabled } = masterData;
  753 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
  754 + (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'betweenDay' || sSecondValue === 'betweenYestday' || sSecondValue === 'week' || sSecondValue === 'weekPre' || sSecondValue === 'period' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
  755 + const showFirstConfig = {
  756 + sId: commonUtils.createSid(),
  757 + sName: `sFirst-${key}`,
  758 + sDropDownType: 'sql',
  759 + iVisCount: 1,
  760 + bNotEmpty: true,
  761 + dropDownData: this.props.searchColumns,
  762 + };
  763 +
  764 + const sThirdName = `${firstDataIndex}Third-${key}`;
  765 + let DropDownType = '';
  766 + let showDropDown = '';
  767 + let sAssignField = '';
  768 + let sSqlCondition = '';
  769 + let sId = '';
  770 + const searchColumnsCurrent = searchColumns.filter(item => item.sId === sFirstValue);
  771 + if (commonUtils.isNotEmptyArr(searchColumnsCurrent) && searchColumnsCurrent.length > 0) {
  772 + sId = searchColumnsCurrent[0].sConfigId;
  773 + DropDownType = searchColumnsCurrent[0].sDropDownType;
  774 + sSqlCondition = searchColumnsCurrent[0].sSqlCondition;
  775 + ([{ showDropDown, sAssignField }] = searchColumnsCurrent);
  776 + }
  777 + const sSecondConditionPro = firstDataIndex === 's' && sFirstValue?.endsWith('_pro'); /* 字段名以s开头,sFilterName以pro结尾,则只有等于条件 */
  778 + const showSecondConfig = {
  779 + sId: commonUtils.createSid(),
  780 + sName: `sSecond-${key}`,
  781 + sDropDownType: 'sql',
  782 + bNotEmpty: true,
  783 + iVisCount: 1,
  784 + dropDownData: this.getTranslatedSeaJudge(
  785 + sSecondConditionPro && DropDownType === 'sql' ? 's_proDropDown' :
  786 + sSecondConditionPro ? 's_pro' : firstDataIndex,
  787 + app?.userinfo?.sLanguage
  788 + ), bCanInput: false,
  789 + };
  790 + const showThirdConfig = {
  791 + sId,
  792 + sName: sThirdName,
  793 + sDropDownType: DropDownType,
  794 + bNotEmpty: false,
  795 + showDropDown: DropDownType === 'const' ? undefined : showDropDown,
  796 + dropDownData: DropDownType === 'const' ? commonUtils.objectToArr(commonUtils.convertStrToObj(showDropDown)) : undefined,
  797 + sAssignField,
  798 + sSqlCondition,
  799 + iVisCount: 1,
  800 + bCanInput: false,
  801 + bSearchComponent: true, /* 是否是搜素方案的下拉 */
  802 + };
  803 + const showTypeFirstProps = this.handleSearchProps(showFirstConfig);
  804 + const showTypeSecondProps = this.handleSearchProps(showSecondConfig);
  805 + const showTypeThirdProps = this.handleSearchProps(showThirdConfig);
  806 + showTypeFirstProps.enabled = true; /* 管理员设置的方案,普通用户不可编辑 showTypeFirstProps.enabled = !disabled; */
  807 + showTypeSecondProps.enabled = true; /* showTypeSecondProps.enabled = !disabled; */
  808 + showTypeThirdProps.enabled = true && !(sSecondValue === 'day' || sSecondValue === 'unDayDo' || sSecondValue === 'daybefore' || sSecondValue === 'tomorrowbefore' || sSecondValue === 'aftertomorrowbefore' || sSecondValue === 'weekPre' || sSecondValue === 'week' || sSecondValue === 'month' || sSecondValue === 'monthPre');/* showTypeThirdProps.enabled = !disabled */
  809 + showTypeFirstProps.formItemLayout = { wrapperCol: { span: 24 } };
  810 + showTypeSecondProps.formItemLayout = { wrapperCol: { span: 24 } };
  811 + showTypeThirdProps.formItemLayout = { wrapperCol: { span: 24 } };
  812 + showTypeThirdProps.allowClear = true;
  813 + const { dataValue } = showTypeThirdProps;
  814 + if (sThirdName.substring(0, 1) === 'b') {
  815 + showTypeThirdProps.enabled = true; /* 选择框不管什么情况,都是可编辑状态 */
  816 + } else if (commonUtils.isEmptyObject(dataValue) || commonUtils.isEmptyArr(dataValue)) {
  817 + showTypeThirdProps.enabled = true; /* 第三个查找条件值为空时,要能直接输入 */
  818 + }
  819 + if (sSecondValue === 'betweenTime') {
  820 + showThirdConfig.sDateFormat = 'YYYY-MM-DD HH:mm:ss';
  821 + /* showTime为true显示可以选择具体时间 */
  822 + showTypeThirdProps.showTime = sSecondValue === 'betweenTime';
  823 + } else if (sSecondValue === 'between' || sSecondValue === 'betweenDay' || sSecondValue === 'betweenYestday' ) {
  824 + showThirdConfig.sDateFormat = 'YYYY-MM-DD';
  825 + /* showTime为true显示可以选择具体时间 */
  826 + showTypeThirdProps.showTime = false;
  827 +
  828 + if(firstDataIndex && firstDataIndex === 'm') {
  829 + showThirdConfig.sDateFormat = 'YYYY-MM';
  830 + } else if (firstDataIndex && firstDataIndex === 'y') {
  831 + showThirdConfig.sDateFormat = 'YYYY';
  832 + }
  833 + }
  834 +
  835 + return (
  836 + <div key={key} className={styles.addFilterBox}>
  837 + <Space>
  838 + <div style={{ width: 180 }}>
  839 + <ShowType {...showTypeFirstProps} />
  840 + </div>
  841 + <div style={{ width: 180 }}>
  842 + <ShowType {...showTypeSecondProps} />
  843 + </div>
  844 + <div style={{ width: 180 }}>
  845 + <ShowType {...showTypeThirdProps} onKeyUp={this.onKeyUp} />
  846 + {
  847 + key > 0 && !disabled ? (
  848 + <MinusCircleOutlined className={styles.removeBtn} onClick={() => this.handleRemove(key)} />
  849 + ) : null
  850 + }
  851 + </div>
  852 + </Space>
  853 + </div>
  854 + );
  855 + });
  856 + return children;
  857 + };
  858 +
  859 + handleAdd = () => {
  860 + /* 添加条件 */
  861 + const { searchRowKeys, searchColumns, masterData } = this.props;
  862 + const key = commonUtils.createSid();
  863 + searchRowKeys.push(key);
  864 + const sFirstValue = searchColumns[0].sId;
  865 + masterData[`sFirst-${key}`] = searchColumns[0].sId;
  866 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' : sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
  867 + masterData[`sSecond-${key}`] = commonConfig.seaJudge[firstDataIndex][0].sId;
  868 + this.props.onSaveState({ searchRowKeys, masterData });
  869 + };
  870 +
  871 + handleRemove = (key, disabled) => {
  872 + /* 移除添加条件 */
  873 + const { searchRowKeys } = this.props;
  874 + if (searchRowKeys.length > 1 && !disabled) {
  875 + const iIndex = searchRowKeys.findIndex(item => item === key);
  876 + searchRowKeys.splice(iIndex, 1);
  877 + this.props.onSaveState({ searchRowKeys });
  878 + }
  879 + };
  880 +
  881 + handleSave = (e) => {
  882 + /* 保存快捷过滤模板 */
  883 + e.preventDefault();
  884 + this.props.form.validateFields((err, values) => {
  885 + /* 验证通过与不通过走不同的流程 */
  886 + if (err) { /* 验证失败 */
  887 + /* 直接渲染显示错误提示 */
  888 + for (const sFieldName of Object.keys(err)) {
  889 + const key = sFieldName.substring('Third-'.length + 1, sFieldName.length);
  890 + const sFirstValue = values[`sFirst-${key}`];
  891 + const iIndex = this.props.searchColumns.findIndex(item => item.sId === sFirstValue);
  892 + const showName = iIndex > -1 ? this.props.searchColumns[iIndex].sValue : '';
  893 + message.error(err[sFieldName].errors[0].message.replace('undefined', showName));
  894 + }
  895 + } else { /* 验证成功 */
  896 + this.props.onSaveState({
  897 + modalVisible: true,
  898 + });
  899 + }
  900 + });
  901 + };
  902 + handleUpd= (e) => {
  903 + /* 方案名称修改 */
  904 + e.preventDefault();
  905 + this.props.form.validateFields((err, values) => {
  906 + /* 验证通过与不通过走不同的流程 */
  907 + if (err) { /* 验证失败 */
  908 + /* 直接渲染显示错误提示 */
  909 + for (const sFieldName of Object.keys(err)) {
  910 + const key = sFieldName.substring('Third-'.length + 1, sFieldName.length);
  911 + const sFirstValue = values[`sFirst-${key}`];
  912 + const iIndex = this.props.searchColumns.findIndex(item => item.sId === sFirstValue);
  913 + const showName = iIndex > -1 ? this.props.searchColumns[iIndex].sValue : '';
  914 + message.error(err[sFieldName].errors[0].message.replace('undefined', showName));
  915 + }
  916 + } else { /* 验证成功 */
  917 + this.props.onSaveState({
  918 + modalSolutionNameVisible: true,
  919 + });
  920 + }
  921 + });
  922 + };
  923 + /* 列显示配置 */
  924 + handleSaveColumnSetting = async () => {
  925 + const {
  926 + masterData, sModelsId, searchColumnShowAllData, formSrcRoute,
  927 + } = this.props;
  928 + const sSearchSolutionId = commonUtils.isNotEmptyObject(masterData) ? masterData.sSearchSolutionId : '';
  929 + if (commonUtils.isNotEmptyObject(sSearchSolutionId)) {
  930 + const searchUrl = `${commonConfig.server_host}searchgroupby/getSearchgroupbyData/${sModelsId}/${sSearchSolutionId}?token=token&sModelsId=${sModelsId}&sName=${formSrcRoute}`;
  931 + const dataReturn = (await commonServices.getService(this.props.app.token, searchUrl)).data;
  932 + if (dataReturn.code === 1) {
  933 + const returnData = dataReturn.dataset.rows;
  934 + if (commonUtils.isNotEmptyArr(returnData)) {
  935 + const newsearchColumnShowData = JSON.parse(JSON.stringify(searchColumnShowAllData));
  936 + for (const child of returnData) {
  937 + const iIndex = newsearchColumnShowData.findIndex(item => item.sName === child.sName.toString());
  938 + if (iIndex > -1) {
  939 + newsearchColumnShowData[iIndex].iOrder = child.iOrder;
  940 + newsearchColumnShowData[iIndex].sChinese = child.sChinese;
  941 + newsearchColumnShowData[iIndex].sEnglish = child.sEnglish;
  942 + newsearchColumnShowData[iIndex].sBig5 = child.sBig5;
  943 + newsearchColumnShowData[iIndex].iFitWidth = child.iFitWidth;
  944 + newsearchColumnShowData[iIndex].bShow = child.bShow;
  945 + newsearchColumnShowData[iIndex].sType = child.sType;
  946 + newsearchColumnShowData[iIndex].sSql = child.sSql;
  947 + }
  948 + }
  949 + this.props.onSaveState({
  950 + searchColumnShowData: newsearchColumnShowData,
  951 + });
  952 + } else {
  953 + this.props.onSaveState({
  954 + searchColumnShowData: JSON.parse(JSON.stringify(searchColumnShowAllData)),
  955 + });
  956 + }
  957 + } else {
  958 + this.props.getServiceError(dataReturn);
  959 + }
  960 + }
  961 + this.props.onSaveState({
  962 + columnSettingVisible: true,
  963 + });
  964 + }
  965 + handleDefault = async () => {
  966 + const { sModelsId, masterData, formSrcRoute } = this.props;
  967 + const dataUrl = `${commonConfig.server_host}syssearch/updateSyssearch?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
  968 + const value = {
  969 + sFormId: sModelsId,
  970 + sId: masterData.sSearchSolutionId,
  971 + bDefault: true,
  972 + };
  973 + const dataReturn = (await commonServices.postValueService(this.props.app.token, value, dataUrl)).data;
  974 + if (dataReturn.code === 1) {
  975 + const returnData = dataReturn.dataset.rows;
  976 + message.success(dataReturn.msg);
  977 + await this.componentWillMount(returnData[0].sId);
  978 + } else {
  979 + this.props.getServiceError(dataReturn);
  980 + }
  981 + }
  982 +
  983 + handleOk = (e) => {
  984 + e.preventDefault();
  985 + this.props.form.validateFields(async (err) => {
  986 + /* 验证通过与不通过走不同的流程 */
  987 + if (err) { /* 验证失败 */
  988 + /* 直接渲染显示错误提示 */
  989 + for (const sFieldName of Object.keys(err)) {
  990 + message.error(err[sFieldName].errors[0].message);
  991 + }
  992 + } else { /* 验证成功 */
  993 + const {
  994 + sModelsId, masterData, searchRowKeys, formSrcRoute,
  995 + } = this.props;
  996 + const dataUrl = `${commonConfig.server_host}syssearch/addSyssearch?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
  997 + const filterCondition = [];
  998 + searchRowKeys.map((key) => {
  999 + const { [`sFirst-${key}`]: sFirstValue, [`sSecond-${key}`]: sSecondValue } = masterData;
  1000 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
  1001 + (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'betweenDay' || sSecondValue === 'betweenYestday' || sSecondValue === 'week' || sSecondValue === 'weekhPre' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
  1002 + const sThirdName = `${firstDataIndex}Third-${key}`;
  1003 + const thirdValue = masterData[sThirdName] === undefined ? '' : masterData[sThirdName]; /* 不过滤空条件 */
  1004 + if (thirdValue !== undefined) {
  1005 + if (firstDataIndex === 'p') {
  1006 + const tStartDate = commonUtils.isNotEmptyObject(thirdValue[0]) ? moment(thirdValue[0]).format(this.sDateFormat) : null;
  1007 + const tEndDate = commonUtils.isNotEmptyObject(thirdValue[0]) ? moment(thirdValue[1]).add(1, 'days').format(this.sDateFormat) : null;
  1008 + let bFilterNewValue = `${tStartDate},${tEndDate}`;
  1009 + if(sSecondValue === 'betweenDay' || sSecondValue === 'betweenYestday') {
  1010 + bFilterNewValue = '';
  1011 + }
  1012 + filterCondition.push({
  1013 + bFilterName: sFirstValue,
  1014 + bFilterCondition: sSecondValue,
  1015 + bFilterValue: bFilterNewValue,
  1016 + });
  1017 + } else if (firstDataIndex === 't') {
  1018 + filterCondition.push({
  1019 + bFilterName: sFirstValue,
  1020 + bFilterCondition: sSecondValue,
  1021 + bFilterValue: moment(thirdValue).format(this.sDateFormat),
  1022 + });
  1023 + } else {
  1024 + filterCondition.push({
  1025 + bFilterName: sFirstValue,
  1026 + bFilterCondition: sSecondValue,
  1027 + bFilterValue: thirdValue,
  1028 + });
  1029 + }
  1030 + }
  1031 + return true;
  1032 + });
  1033 + const value = {
  1034 + sFormId: sModelsId,
  1035 + sCondition: filterCondition,
  1036 + sName: masterData.sSolutionName,
  1037 + };
  1038 + const dataReturn = (await commonServices.postValueService(this.props.app.token, value, dataUrl)).data;
  1039 + if (dataReturn.code === 1) {
  1040 + const returnData = dataReturn.dataset.rows;
  1041 + message.success(dataReturn.msg);
  1042 + await this.componentWillMount(returnData[0].sId);
  1043 + } else {
  1044 + this.props.getServiceError(dataReturn);
  1045 + }
  1046 + }
  1047 + });
  1048 + };
  1049 +
  1050 + handleSolutionNameOk = (e) => {
  1051 + e.preventDefault();
  1052 + this.props.form.validateFields(async (err) => {
  1053 + /* 验证通过与不通过走不同的流程 */
  1054 + if (err) { /* 验证失败 */
  1055 + /* 直接渲染显示错误提示 */
  1056 + for (const sFieldName of Object.keys(err)) {
  1057 + message.error(err[sFieldName].errors[0].message);
  1058 + }
  1059 + } else { /* 验证成功 */
  1060 + const {
  1061 + sModelsId, masterData, searchRowKeys, formSrcRoute,
  1062 + } = this.props;
  1063 + const dataUrl = `${commonConfig.server_host}syssearch/updateSyssearch?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
  1064 + const filterCondition = [];
  1065 + searchRowKeys.map((key) => {
  1066 + const { [`sFirst-${key}`]: sFirstValue, [`sSecond-${key}`]: sSecondValue } = masterData;
  1067 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' :
  1068 + (sSecondValue === 'betweenTime' || sSecondValue === 'between' || sSecondValue === 'betweenDay' || sSecondValue === 'betweenYestday'|| sSecondValue === 'week' || sSecondValue === 'weekPre' || sSecondValue === 'month' || sSecondValue === 'monthPre') && sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
  1069 + const sThirdName = `${firstDataIndex}Third-${key}`;
  1070 + const thirdValue = masterData[sThirdName] === undefined ? '' : masterData[sThirdName]; /* 不过滤空条件 */
  1071 + if (thirdValue !== undefined) {
  1072 + if (firstDataIndex === 'p') {
  1073 + const tStartDate = moment(thirdValue[0]).format(this.sDateFormat);
  1074 + const tEndDate = moment(thirdValue[1]).add(1, 'days').format(this.sDateFormat);
  1075 + let bFilterNewValue = `${tStartDate},${tEndDate}`;
  1076 + if(sSecondValue === 'betweenDay' || sSecondValue === 'betweenYestday') {
  1077 + bFilterNewValue = '';
  1078 + }
  1079 + filterCondition.push({
  1080 + bFilterName: sFirstValue,
  1081 + bFilterCondition: sSecondValue === 'monthPre' ? 'between' : sSecondValue,
  1082 + bFilterValue: bFilterNewValue,
  1083 + });
  1084 + } else if (firstDataIndex === 't') {
  1085 + filterCondition.push({
  1086 + bFilterName: sFirstValue,
  1087 + bFilterCondition: sSecondValue,
  1088 + bFilterValue: moment(thirdValue).format(this.sDateFormat),
  1089 + });
  1090 + } else {
  1091 + filterCondition.push({
  1092 + bFilterName: sFirstValue,
  1093 + bFilterCondition: sSecondValue,
  1094 + bFilterValue: thirdValue,
  1095 + });
  1096 + }
  1097 + }
  1098 + return true;
  1099 + });
  1100 + const value = {
  1101 + sFormId: sModelsId,
  1102 + sCondition: filterCondition,
  1103 + sName: masterData.sSolutionName,
  1104 + sId: masterData.sSearchSolutionId,
  1105 + };
  1106 + const dataReturn = (await commonServices.postValueService(this.props.app.token, value, dataUrl)).data;
  1107 + if (dataReturn.code === 1) {
  1108 + const returnData = dataReturn.dataset.rows;
  1109 + message.success(dataReturn.msg);
  1110 + await this.componentWillMount(returnData[0].sId);
  1111 + } else {
  1112 + this.props.getServiceError(dataReturn);
  1113 + }
  1114 + }
  1115 + });
  1116 + };
  1117 + handleDel = async (e) => {
  1118 + /* 删除快捷过滤模板 */
  1119 + e.preventDefault(); /* 防止动画删除 */
  1120 + const {
  1121 + slaveConfig, slaveInfoConfig, masterData, sModelsId, formSrcRoute, setSearchSlaveInfo,
  1122 + } = this.props;
  1123 + if (commonUtils.isNotEmptyObject(masterData) && !commonUtils.isEmpty(masterData.sSearchSolutionId)) {
  1124 + const dataUrl = `${commonConfig.server_host}syssearch/deleteSyssearch/${sModelsId}/${masterData.sSearchSolutionId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
  1125 + const dataReturn = (await commonServices.getService(this.props.app.token, dataUrl)).data;
  1126 + if (dataReturn.code === 1) {
  1127 + message.success(dataReturn.msg);
  1128 + await this.componentWillMount();
  1129 + const { searchSolution } = this.props;
  1130 + if (commonUtils.isNotEmptyArr(searchSolution)) {
  1131 + /* 如果初始没有方案,即为[],则进行重置 */
  1132 + if (searchSolution[0].sCondition === '[]') {
  1133 + this.handleReset();
  1134 + }
  1135 + this.props.onGetData(slaveConfig, JSON.parse(searchSolution[0].sCondition));
  1136 + if (setSearchSlaveInfo === 'Y') {
  1137 + if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
  1138 + this.props.onGetDataInfo(slaveInfoConfig, JSON.parse(searchSolution[0].sCondition));
  1139 + }
  1140 + }
  1141 + } else {
  1142 + this.handleReset();
  1143 + }
  1144 + } else {
  1145 + this.props.getServiceError(dataReturn);
  1146 + }
  1147 + }
  1148 + };
  1149 +
  1150 + handleReset = async () => {
  1151 + /* 清空搜索条件 */
  1152 + const { searchColumns, sModelsType } = this.props;
  1153 + const searchRowKeys = [];
  1154 + const key = commonUtils.createSid();
  1155 + const masterData = sModelsType && sModelsType.includes('commonClassify') ? { bCheck: false } : { bCheck: true };
  1156 + // masterData.sSearchSolutionId = masterDataOld.sSearchSolutionId;
  1157 + searchRowKeys.push(key);
  1158 + if (commonUtils.isNotEmptyArr(searchColumns)) {
  1159 + const sFirstValue = searchColumns[0].sId;
  1160 + masterData[`sFirst-${key}`] = searchColumns[0].sId;
  1161 + const firstDataIndex = commonUtils.isEmpty(sFirstValue) ? 's' : sFirstValue.substring(0, 1) === 't' ? 'p' : sFirstValue.substring(0, 1);
  1162 + masterData[`sSecond-${key}`] = commonConfig.seaJudge[firstDataIndex][0].sId;
  1163 + const { clearArray } = this.props;
  1164 + if (!commonUtils.isEmpty(clearArray)) {
  1165 + for (const item of clearArray) {
  1166 + const { confirm, clearFilters } = item;
  1167 + confirm();
  1168 + clearFilters();
  1169 + }
  1170 + }
  1171 +
  1172 + let obj = {
  1173 + searchRowKeys,
  1174 + masterData,
  1175 + clearArray: [],
  1176 + searchText: '',
  1177 + slaveFilterCondition: [],
  1178 + // slaveGroupColumn: [],
  1179 + // sGroupByList: [],
  1180 + // slaveData: [],
  1181 + // treeFilterCondition: [],
  1182 + // treeSelectedKeys: [],
  1183 + // slaveFilterData: [],
  1184 + // slaveSelectedRowKeys: [],
  1185 + // slaveSelectedData: [],
  1186 + };
  1187 + await this.props.onSaveState(obj);
  1188 + }
  1189 + // this.handleSearch();
  1190 + };
  1191 +
  1192 + handleCancel = async (modelVisible) => {
  1193 + /* 关闭弹窗 */
  1194 + this.props.onSaveState({ [modelVisible]: false });
  1195 + };
  1196 + /* 列自定义配置-删除功能 */
  1197 + handleCloumnSettingDelete = async (modelVisible) => {
  1198 + /* 关闭弹窗 */
  1199 + const { masterData, sModelsId, formSrcRoute } = this.props;
  1200 + const sSearchSolutionId = commonUtils.isNotEmptyObject(masterData) ? masterData.sSearchSolutionId : '';
  1201 + const deleteUrl = `${commonConfig.server_host}searchgroupby/deleteSearchgroupby/${sModelsId}/${sSearchSolutionId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
  1202 + const dataReturn = (await commonServices.getService(this.props.app.token, deleteUrl)).data;
  1203 + if (dataReturn.code === 1) {
  1204 + message.success(dataReturn.msg);
  1205 + await this.componentWillMount(sSearchSolutionId); /* 搜索刷新下拉方案 */
  1206 + this.handleSearch();
  1207 + this.props.onSaveState({ slaveGroupColumn: [], [modelVisible]: false });
  1208 + } else {
  1209 + this.props.getServiceError(dataReturn);
  1210 + }
  1211 + };
  1212 + /* 列自定义配置窗体保存功能 */
  1213 + handleColumnSettingSave =async (modelVisible) => {
  1214 + /* 获取勾选是否显示的列的数据/拿到显示参数/调用接口 */
  1215 + const {
  1216 + searchColumnShowData, masterData, sModelsId, formSrcRoute,
  1217 + } = this.props;
  1218 + const sSearchSolutionId = commonUtils.isNotEmptyObject(masterData) ? masterData.sSearchSolutionId : '';
  1219 + const sSearchgroupbyData = searchColumnShowData.filter(item => item.bShow);
  1220 + const addurl = `${commonConfig.server_host}/searchgroupby/addSearchgroupby?token=token&sModelsId=${sModelsId}&sName=${formSrcRoute}`;
  1221 + /* 参数 */
  1222 + const body = {
  1223 + sFormId: sModelsId,
  1224 + sSearchId: sSearchSolutionId,
  1225 + sSearchgroupbyData,
  1226 + };
  1227 + // /* 获取数据 */
  1228 + const json = await commonServices.postValueService(this.props.app.token, body, addurl);
  1229 + /* code为1代表获取数据成功 */
  1230 + if (json.data.code === 1) {
  1231 + message.success(json.data.msg);
  1232 + /* 刷新查询方案 */
  1233 + await this.componentWillMount(sSearchSolutionId);
  1234 + this.handleCloumnSettingSearch(modelVisible, sSearchgroupbyData);
  1235 + } else {
  1236 + message.error(json.data.msg);
  1237 + }
  1238 + }
  1239 +
  1240 + /* 列自定义配置-查询结果 */
  1241 + handleCloumnSettingSearch = (modelVisible, sGroupByList) => {
  1242 + /* 查询结果 */
  1243 + /* 表头替换,数据集替换 */
  1244 + const {
  1245 + searchColumnShowData, slaveConfig, slaveInfoConfig, slaveFilterCondition, setSearchSlaveInfo,
  1246 + } = this.props;
  1247 + const column = [];
  1248 + for (const child of searchColumnShowData) {
  1249 + if (child.sName !== '' && child.bShow) {
  1250 + column.push({
  1251 + title: child.sChinese,
  1252 + dataIndex: child.sName,
  1253 + width: child.iFitWidth,
  1254 + bFind: true,
  1255 + bNotEmpty: false,
  1256 + });
  1257 + }
  1258 + }
  1259 + /* 调handleSearch搜索 */
  1260 + this.props.onGetData(slaveConfig, slaveFilterCondition, '', '', '', '', sGroupByList);
  1261 + if (setSearchSlaveInfo === 'Y') {
  1262 + if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
  1263 + this.props.onGetDataInfo(slaveInfoConfig, slaveFilterCondition);
  1264 + }
  1265 + }
  1266 + this.props.onSaveState({
  1267 + slaveGroupColumn: column,
  1268 + [modelVisible]: false,
  1269 + sGroupByList,
  1270 + });
  1271 + };
  1272 + /* 在类中添加一个方法用于处理多语言转换*/
  1273 + getTranslatedSeaJudge = (type, sLanguage) => {
  1274 + const { seaJudge } = commonConfig;
  1275 + const judgeMap = seaJudge[type] || [];
  1276 +
  1277 + // 定义翻译映射
  1278 + const translations = {
  1279 + sEnglish: {
  1280 + '包含': 'Contains',
  1281 + '不包含': 'Not Contains',
  1282 + '等于': 'Equal',
  1283 + '大于': 'Greater Than',
  1284 + '小于': 'Less Than',
  1285 + '大于等于': 'Greater Than or Equal',
  1286 + '小于等于': 'Less Than or Equal',
  1287 + '区间': 'Between',
  1288 + '区间(默认今天)': 'Between (Default Today)',
  1289 + '区间(默认昨天)': 'Between (Default Yesterday)',
  1290 + '区间时间': 'Between Time',
  1291 + '今日': 'Today',
  1292 + '今日未清': 'Unfinished Today',
  1293 + '今天之前': 'Before Today',
  1294 + '明天之前': 'Before Tomorrow',
  1295 + '后天之前': 'Before Day After Tomorrow',
  1296 + '本月': 'This Month',
  1297 + '上月': 'Last Month',
  1298 + '本周': 'This Week',
  1299 + '上周': 'Last Week',
  1300 + '本期间': 'This Period'
  1301 + },
  1302 + sBig5: {
  1303 + '包含': '包含',
  1304 + '不包含': '不包含',
  1305 + '等于': '等於',
  1306 + '大于': '大於',
  1307 + '小于': '小於',
  1308 + '大于等于': '大於等於',
  1309 + '小于等于': '小於等於',
  1310 + '区间': '區間',
  1311 + '区间(默认今天)': '區間(默認今天)',
  1312 + '区间(默认昨天)': '區間(默認昨天)',
  1313 + '区间时间': '區間時間',
  1314 + '今日': '今日',
  1315 + '今日未清': '今日未清',
  1316 + '今天之前': '今天之前',
  1317 + '明天之前': '明天之前',
  1318 + '后天之前': '後天之前',
  1319 + '本月': '本月',
  1320 + '上月': '上月',
  1321 + '本周': '本周',
  1322 + '上周': '上周',
  1323 + '本期间': '本期間'
  1324 + }
  1325 + };
  1326 +
  1327 + if (sLanguage === 'sEnglish' || sLanguage === 'sBig5') {
  1328 + return judgeMap.map(item => ({
  1329 + ...item,
  1330 + value: translations[sLanguage][item.value] || item.value
  1331 + }));
  1332 + }
  1333 +
  1334 + return judgeMap;
  1335 +};
  1336 +
  1337 + render() {
  1338 + const {
  1339 + searchSolution, searchColumns, expand, activeTagId, sType, modalVisible, modalSolutionNameVisible, confirmLoading, masterData, columnSettingVisible, app,
  1340 + } = this.props;
  1341 + const highlightColor = true;
  1342 + const showSearchSolutionConfig = {
  1343 + sId: commonUtils.createSid(),
  1344 + sName: 'sSearchSolutionId',
  1345 + sDropDownType: 'sql',
  1346 + iVisCount: 1,
  1347 + sVisColumnName: 'sName',
  1348 + dropDownData: searchSolution,
  1349 + placeholder: commonFunc.showMessage(app.commonConst, 'pleaseChooseSolution'), /* 请选择方案 */
  1350 + };
  1351 + const showTypeSearchSolutionProps = this.handleSearchProps(showSearchSolutionConfig);
  1352 + showTypeSearchSolutionProps.formItemLayout = { wrapperCol: { span: 24 } };
  1353 + /* 过滤另存方案界面显示 */
  1354 + const showSolutionNameConfig = {
  1355 + sId: commonUtils.createSid(),
  1356 + sName: 'sSolutionName',
  1357 + sDropDownType: '',
  1358 + bNotEmpty: modalVisible,
  1359 + showName: commonFunc.showMessage(app.commonConst, 'solutionName'), /* 方案名称 */
  1360 + };
  1361 + /* 修改方案名称界面显示 */
  1362 + const updSolutionNameConfig = {
  1363 + sId: commonUtils.createSid(),
  1364 + sName: 'sSolutionName',
  1365 + sDropDownType: '',
  1366 + bNotEmpty: modalSolutionNameVisible,
  1367 + showName: commonFunc.showMessage(app.commonConst, 'solutionName'), /* 方案名称 */
  1368 + };
  1369 + let bBtnDelDisabled = false;
  1370 + let bBtnColumnSetting = false;/* 列显示配置按钮是否可用 */
  1371 + if (commonUtils.isNotEmptyArr(searchSolution) && commonUtils.isNotEmptyObject(masterData)) {
  1372 + const iIndex = searchSolution.findIndex(item => item.sId === masterData.sSearchSolutionId);
  1373 + if (iIndex > -1) {
  1374 + bBtnDelDisabled = this.props.app.userinfo.sType !== 'sysadmin' && searchSolution[iIndex].sType === 'common';
  1375 + bBtnColumnSetting = bBtnDelDisabled;
  1376 + }
  1377 + /* 清空方案时,列显示配置按钮不可用 */
  1378 + const sSearchSolutionId = commonUtils.isNotEmptyObject(masterData.sSearchSolutionId) ? masterData.sSearchSolutionId : '';
  1379 + if (commonUtils.isEmptyObject(sSearchSolutionId)) {
  1380 + bBtnColumnSetting = true;
  1381 + }
  1382 + } else {
  1383 + bBtnColumnSetting = true; /* 没有方案时 */
  1384 + }
  1385 + const showTypeSolutionNameProps = this.handleSearchProps(showSolutionNameConfig);
  1386 + const updSolutionNameConfigProps = this.handleSearchProps(updSolutionNameConfig);/* 修改方案名称 */
  1387 + /* 列自定义配置 */
  1388 + const searchColumnShowProps = {
  1389 + ...commonBusiness.getTableTypes('searchColumnShow', this.props),
  1390 + tableBelone: 'table',
  1391 + enabled: true,
  1392 + onDoubleClick: undefined,
  1393 + sUseInfo: '',
  1394 + tableProps: { rowKey: 'sId', AutoTableHeight: 450 },
  1395 + };
  1396 + const AddCondition = commonFunc.showMessage(app.commonConst, 'AddCondition');/* 添加条件 */
  1397 + const BtnSave = commonFunc.showMessage(app.commonConst, 'BtnSave');/* 保存 */
  1398 + const BtnUpd = commonFunc.showMessage(app.commonConst, 'BtnUpd');/* 修改 */
  1399 + const setDelete = commonFunc.showMessage(app.commonConst, 'setDelete');/* 删除 */
  1400 + const setDefault = commonFunc.showMessage(app.commonConst, 'setDefault');/* 设置默认 */
  1401 + const columnDisplaySetting = commonFunc.showMessage(app.commonConst, 'ColumnDisplaySetting');/* 列显示配置 */
  1402 + const btnSearch = commonFunc.showMessage(app.commonConst, 'btnSearch');/* 搜索 */
  1403 + const clearOut = commonFunc.showMessage(app.commonConst, 'ClearOut');/* 清空 */
  1404 + const btnSaveAndSearch = commonFunc.showMessage(app.commonConst, 'btnSaveAndSearch');/* 保存并查询 */
  1405 + const solutionFilterSave = commonFunc.showMessage(app.commonConst, 'solutionFilterSave');
  1406 + const solutionFilterNameUpd = commonFunc.showMessage(app.commonConst, 'solutionFilterNameUpd');
  1407 +
  1408 + const modalCom = (
  1409 + <AntdDraggableModal
  1410 + visible={modalVisible}
  1411 + title={solutionFilterSave}
  1412 + onOk={e => setTimeout(() => {
  1413 + this.handleOk(e);
  1414 + }, 300)}
  1415 + onCancel={this.handleCancel.bind(this, 'modalVisible')}
  1416 + okText="确认"
  1417 + cancelText="取消"
  1418 + confirmLoading={confirmLoading}
  1419 + maskClosable={false}
  1420 + >
  1421 + <FormItem>
  1422 + <ShowType {...showTypeSolutionNameProps} />
  1423 + </FormItem>
  1424 + </AntdDraggableModal>
  1425 + );
  1426 + const modalSolutionNameCom = (
  1427 + <AntdDraggableModal visible={modalSolutionNameVisible} title={solutionFilterNameUpd} onOk={this.handleSolutionNameOk} onCancel={this.handleCancel.bind(this, 'modalSolutionNameVisible')} okText="确认" cancelText="取消" confirmLoading={confirmLoading} maskClosable={false}>
  1428 + <FormItem>
  1429 + <ShowType {...updSolutionNameConfigProps} />
  1430 + </FormItem>
  1431 + </AntdDraggableModal>
  1432 + );
  1433 + const columnSettingCom = (
  1434 + <AntdDraggableModal
  1435 + bodyStyle={{ paddingBottom: 0, maxHeight: 460, zIndex: 2000 }}
  1436 + width={1100}
  1437 + title={columnDisplaySetting}
  1438 + onCancel={this.handleCancel.bind(this, 'columnSettingVisible')}
  1439 + visible={columnSettingVisible}
  1440 + footer={[
  1441 + <Button key="back" onClick={this.handleCloumnSettingDelete.bind(this, 'columnSettingVisible')}>{setDelete}</Button>,
  1442 + <Button key="primary" onClick={this.handleColumnSettingSave.bind(this, 'columnSettingVisible')}>{btnSaveAndSearch}</Button>,
  1443 + ]}
  1444 + >
  1445 + <div id="searchColumn">
  1446 + <div style={{ marginTop: 0, height: '500px', overflowY: 'hidden' }} >
  1447 + <StaticEditTable {...searchColumnShowProps} noVlist />
  1448 + </div>
  1449 + </div>
  1450 + </AntdDraggableModal>
  1451 + );
  1452 + return (
  1453 + <div style={{ overFlow: 'hidden', maxHeight: '100%' }}>
  1454 + {commonUtils.isEmptyArr(searchColumns) ? '' :
  1455 + <div className={`${styles.fastFilter} searchComponentContainer_${app.currentPane.key || 0}`}>
  1456 + <div className={styles.solutionList} >
  1457 + <ShowType {...showTypeSearchSolutionProps} placeholder={commonFunc.showMessage(app.commonConst, 'pleaseChooseSolution')} />
  1458 + </div>
  1459 + <div className={`${styles.advRow} ${expand ? styles.advRowActive : ''}`}>
  1460 + <div className={styles.filterList}>
  1461 + {this.handleFields(searchColumns)}
  1462 + <div className={styles.filterBtn}>
  1463 + {
  1464 + (activeTagId === 'default' || (sType === 'common' && this.props.app.userinfo.sType !== 'sysadmin')) ?
  1465 + <Row>
  1466 + <Col span={20}>
  1467 + <div className={styles.advButton}>
  1468 + <Button
  1469 + type="primary"
  1470 + onClick={this.handleAdd}
  1471 + >
  1472 + <PlusOutlined /> {AddCondition}
  1473 + </Button>
  1474 + </div>
  1475 + </Col>
  1476 + <Col span={4}>
  1477 + <div className={styles.advButton}>
  1478 + <Button onClick={this.handleSave}>
  1479 + {BtnSave}
  1480 + </Button>
  1481 + </div>
  1482 + </Col>
  1483 + </Row>
  1484 + :
  1485 + <Row>
  1486 + <Col span={4}>
  1487 + <div className={styles.advButton}>
  1488 + <Button
  1489 + type="primary"
  1490 + onClick={this.handleAdd}
  1491 + >{AddCondition}
  1492 + </Button>
  1493 + </div>
  1494 + </Col>
  1495 + <Col span={3}>
  1496 + <div className={styles.advButton}>
  1497 + <Button onClick={this.handleSave}>
  1498 + {BtnSave}
  1499 + </Button>
  1500 + </div>
  1501 + </Col>
  1502 + <Col span={3}>
  1503 + <div className={styles.advButton}>
  1504 + <Button onClick={this.handleUpd} disabled={bBtnDelDisabled}>
  1505 + {BtnUpd}
  1506 + </Button>
  1507 + </div>
  1508 + </Col>
  1509 + <Col span={3}>
  1510 + <div className={styles.advButton}>
  1511 + <Button type="danger" onClick={this.handleDel} disabled={bBtnDelDisabled}>
  1512 + {setDelete}
  1513 + </Button>
  1514 + </div>
  1515 + </Col>
  1516 + <Col span={4}>
  1517 + <div className={styles.advButton}>
  1518 + <Button onClick={this.handleDefault}>
  1519 + {setDefault}
  1520 + </Button>
  1521 + </div>
  1522 + </Col>
  1523 + <Col span={7}>
  1524 + <div className={styles.advButton}>
  1525 + <Button
  1526 + type="primary"
  1527 + onClick={this.handleSaveColumnSetting}
  1528 + disabled={bBtnColumnSetting}
  1529 + >
  1530 + {columnDisplaySetting}
  1531 + <SettingOutlined />
  1532 + </Button>
  1533 + </div>
  1534 + </Col>
  1535 + </Row>
  1536 + }
  1537 + </div>
  1538 + </div>
  1539 + </div>
  1540 + <div className={styles.toggleBtn}>
  1541 + <Button type="primary" className={highlightColor ? styles.advTogIcon_Highlight : styles.advTogIcon_Gray} onClick={this.handeToggle} icon={<LegacyIcon type={expand ? 'up' : 'down'} />} />
  1542 + </div>
  1543 + <div className={styles.advCol}>
  1544 + <Space>
  1545 + <Button type="primary" onClick={this.handleSearch} className="search-btn"><SvgIcon iconClass="search" offsetY="2" size="12" fill="#fff"></SvgIcon>&nbsp;{btnSearch}</Button>
  1546 + <Button type="default" className="reset-btn" onClick={this.handleReset}><SvgIcon iconClass="close" offsetY="2" size="12" fill="rgba(0, 0, 0, 0.85)"></SvgIcon>&nbsp;{clearOut}</Button>
  1547 + </Space>
  1548 + </div>
  1549 + {modalVisible && modalCom}
  1550 + {modalSolutionNameVisible && modalSolutionNameCom}
  1551 + {columnSettingVisible && columnSettingCom}
  1552 + </div>
  1553 + }
  1554 + </div>
  1555 + );
  1556 + }
  1557 +}
src/components/Common/SearchTabComponent/index.less 0 → 100644
  1 +@import '~@/variable.less';
  2 +.fastFilter {
  3 + position: relative;
  4 + background: #fff;
  5 + margin: 0 10px;
  6 + padding: 10px 8px 3px 8px;
  7 + z-index: 20;
  8 + .clear_both();
  9 + .solutionList{
  10 + width: 180px;
  11 + float: left;
  12 + .clear_both();
  13 + }
  14 + .advRow {
  15 + float: left;
  16 + width: 600px;
  17 + height: 34px;
  18 + overflow: hidden;
  19 + position: relative;
  20 + .clear_both();
  21 + .filterList{
  22 + padding-left: 8px;
  23 + position: absolute;
  24 + top: 0;
  25 + left: 0;
  26 + z-index: 10;
  27 + width: 100%;
  28 + background: #fff;
  29 + .filterBtn{
  30 + display: none;
  31 + width: 100%;
  32 + }
  33 + }
  34 + }
  35 + .advRowActive {
  36 + overflow: unset;
  37 + .filterList{
  38 + padding-top: 8px;
  39 + background: #eef1f6;
  40 + box-shadow: 0 0 1px 1px @active_color;
  41 + .filterBtn{
  42 + display: block;
  43 + }
  44 + }
  45 + }
  46 + .toggleBtn{
  47 + width: 32px;
  48 + margin-left: 8px;
  49 + float: left;
  50 + }
  51 + .advCol {
  52 + float: left;
  53 + margin-left: 16px;
  54 + }
  55 +}
  56 +.addFilterBox {
  57 + display: block;
  58 + overflow: hidden;
  59 + position: relative;
  60 + z-index: 9;
  61 + margin-bottom: 0px;
  62 + padding-right: 36px;
  63 + height: 34px;
  64 + &:first-child{
  65 + .removeBtn{
  66 + display: none;
  67 + }
  68 + }
  69 + .removeBtn{
  70 + position: absolute;
  71 + top: 9px;
  72 + right: 11px;
  73 + z-index: 5;
  74 + }
  75 +}
  76 +.minuseIcon {
  77 + position: absolute;
  78 + right: 1px;
  79 + top: -5px;
  80 + z-index: 10
  81 +}
  82 +
  83 +.advButton {
  84 + position: relative;
  85 + margin-right: 7px;
  86 + margin-bottom: 7px;
  87 +}
  88 +
  89 +.advButton button {
  90 + width: 100%;
  91 +}
  92 +