/* eslint-disable */ 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, Space } from 'antd'; import moment from 'moment'; import * as commonConfig from '@/utils/config'; import * as commonUtils from '@/utils/utils'; import * as commonFunc from '@/components/Common/commonFunc'; import * as commonServices from '@/services/services'; import ShowType from '@/components/Common/CommonComponent'; import StaticEditTable from '@/components//Common/CommonTable'; import * as commonBusiness from '@/components/Common/commonBusiness';/* 单据业务功能 */ import AntdDraggableModal from '@/components/Common/AntdDraggableModal'; import styles from './index.less'; import SvgIcon from "../../SvgIcon"; const FormItem = Form.Item; export default class SearchComponent extends Component { constructor(props) { super(props); 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 && slaveConfig) { 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, sSqlCondition: item.sSqlCondition, }); }); 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; const highlightColor = false; const { sModelsType, app } = this.props; const { userinfo } = app; const masterData = sModelsType && sModelsType.includes('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'); const filterConditionAsync = async () => { for (let i = 0, len = filterCondition.length; i < len; i += 1) { const item = filterCondition[i]; 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 === 'weekPre' || 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 === 'unDayDo') { masterData[`${firstDataIndex}Third-${key}`] = moment().format(this.sDateFormat); } else if (sSecondValue === 'daybefore') { /* 今天之前 */ masterData[`${firstDataIndex}Third-${key}`] = moment().subtract(1,"days").format(this.sDateFormat); } else if (sSecondValue === 'tomorrowbefore') { /* 明天之前 */ masterData[`${firstDataIndex}Third-${key}`] = moment().add(1,"days").format(this.sDateFormat); } else if (sSecondValue === 'aftertomorrowbefore') { /* 后天之前 */ masterData[`${firstDataIndex}Third-${key}`] = moment().add(2,"days").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 (sSecondValue === 'weekPre') { const dateBetween = []; dateBetween.push(moment(moment().week(moment().week() - 1).startOf('week').valueOf())); dateBetween.push(moment(moment().week(moment().week() - 1).endOf('week').valueOf())); masterData[`${firstDataIndex}Third-${key}`] = dateBetween; } else if (item.bFilterCondition === 'between' || item.bFilterCondition === 'betweenTime') { if (item.bFilterValue.split(',').length === 2) { const dateBetween = []; if (item.bFilterValue.split(',')[0] !== 'null') { dateBetween.push(moment(item.bFilterValue.split(',')[0])); dateBetween.push(moment(item.bFilterValue.split(',')[1]).subtract(1, 'days')); /* 日期区间需要将bFilterValue日期减一天 */ } masterData[`${firstDataIndex}Third-${key}`] = dateBetween; } else { masterData[`${firstDataIndex}Third-${key}`] = moment(item.bFilterValue); } } else if (sSecondValue === 'period') { if (firstDataIndex === 'p') { const dateBetween = []; dateBetween.push(moment().startOf('month')); dateBetween.push(moment().endOf('month')); masterData[`${firstDataIndex}Third-${key}`] = dateBetween; } else if (firstDataIndex === 'm') { masterData[`${firstDataIndex}Third-${key}`] = moment(new Date()); } else if (firstDataIndex === 'y') { masterData[`${firstDataIndex}Third-${key}`] = moment(new Date()); } } 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; 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; } } } }; filterConditionAsync(); return { masterData, searchRowKeys, slaveGroupColumn: column, 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: true, formRoute: this.props.formRoute, sSqlCondition:showConfig.sSqlCondition, name: 'master', record: masterData, }; } handleSearch = () => { window.vlistNewSearh = true; const { searchRowKeys, masterData, slaveConfig, slaveInfoConfig, setSearchSlaveInfo, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, slave5Config, slave6Config, slave7Config, slave8Config, slave9Config, slave10Config, slave11Config, slave12Config, slave13Config, slave14Config, slave15Config, } = 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 === 'weekPre' || 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) || firstDataIndex === 'b') { if (firstDataIndex === 'p') { 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); 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); filterCondition.push({ bFilterName: sFirstValue, bFilterCondition: sSecondValue, bFilterValue: `${tStartDate},${tEndDate}`, }); } else if (firstDataIndex === 'm') { const tStartDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm:ss') : moment(thirdValue).startOf('month').format(this.sDateFormat); const tEndDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm:ss') : 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 === 'y') { const tStartDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm:ss') : moment(thirdValue).startOf('year').format(this.sDateFormat); const tEndDate = sSecondValue === 'betweenTime' ? moment(thirdValue).format('YYYY-MM-DD HH:mm:ss') : moment(thirdValue).endOf('year').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 if (firstDataIndex === 'b') { filterCondition.push({ bFilterName: sFirstValue, bFilterCondition: sSecondValue, bFilterValue: thirdValue ? true : false, }); } else { filterCondition.push({ bFilterName: sFirstValue, bFilterCondition: sSecondValue, bFilterValue: thirdValue, }); } } return true; }); this.props.onGetData(slaveConfig, filterCondition); return; /* 判断是否要加载过滤树数据 */ 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动画 */ // 添加props传入的判断条件 // let customfilterCondition = filterCondition.slice(0); // if (customSlaveFilterCondition) { // customfilterCondition = filterCondition.concat(customSlaveFilterCondition); // } this.props.onSaveState({ pageLoading: true }); /* commonListTab搜索时 根据当前Tab页签所在表格进行查询 */ if(commonUtils.isNotEmptyObject(location.pathname) && location.pathname.includes('commonListTab')) { this.props.onGetSearchData(slaveConfig, filterCondition, undefined,undefined,undefined,undefined,undefined,undefined,undefined, slave0Config); } else { this.props.onGetData(slaveConfig, filterCondition, undefined,undefined,undefined,undefined,undefined,undefined,undefined, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, slave5Config, slave6Config, slave7Config, slave8Config, slave9Config, slave10Config, slave11Config, slave12Config, slave13Config, slave14Config, slave15Config); } 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) : masterData[`${firstDataIndex}Third-${key}`]; 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 === 'weekPre' || 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 === 'unDayDo') { masterData[`${firstDataIndex}Third-${key}`] = moment().format(this.sDateFormat); } else if (sSecondValue === 'daybefore') { /* 今天之前 */ masterData[`${firstDataIndex}Third-${key}`] = moment().subtract(1,"days").format(this.sDateFormat); } else if (sSecondValue === 'tomorrowbefore') { /* 明天之前 */ masterData[`${firstDataIndex}Third-${key}`] = moment().add(1,"days").format(this.sDateFormat); } else if (sSecondValue === 'aftertomorrowbefore') { /* 后天之前 */ masterData[`${firstDataIndex}Third-${key}`] = moment().add(2,"days").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 (sSecondValue === 'weekPre') { const dateBetween = []; dateBetween.push(moment(moment().week(moment().week() - 1).startOf('week').valueOf())); dateBetween.push(moment(moment().week(moment().week() - 1).endOf('week').valueOf())); masterData[`${firstDataIndex}Third-${key}`] = dateBetween; } else if (sSecondValue === 'period') { /* 本期间 */ if (firstDataIndex === 'm') { masterData[`${firstDataIndex}Third-${key}`] = moment(new Date()); } else if (firstDataIndex === 'p') { const dateBetween = []; dateBetween.push(moment().startOf('month')); dateBetween.push(moment().endOf('month')); 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 === 'weekPre' || sSecondValue === 'period' || 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 sSqlCondition = ''; 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; sSqlCondition = searchColumnsCurrent[0].sSqlCondition; ([{ showDropDown, sAssignField }] = searchColumnsCurrent); } 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: false, }; const showThirdConfig = { sId, sName: sThirdName, sDropDownType: DropDownType, bNotEmpty: false, showDropDown: DropDownType === 'const' ? undefined : showDropDown, dropDownData: DropDownType === 'const' ? commonUtils.objectToArr(commonUtils.convertStrToObj(showDropDown)) : undefined, sAssignField, sSqlCondition, iVisCount: 1, bCanInput: false, bSearchComponent: 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 === 'unDayDo' || sSecondValue === 'daybefore' || sSecondValue === 'tomorrowbefore' || sSecondValue === 'aftertomorrowbefore' || sSecondValue === 'weekPre' || sSecondValue === 'week' || sSecondValue === 'month' || sSecondValue === 'monthPre');/* showTypeThirdProps.enabled = !disabled */ showTypeFirstProps.formItemLayout = { wrapperCol: { span: 24 } }; showTypeSecondProps.formItemLayout = { wrapperCol: { span: 24 } }; showTypeThirdProps.formItemLayout = { wrapperCol: { span: 24 } }; showTypeThirdProps.allowClear = true; 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:ss'; /* showTime为true显示可以选择具体时间 */ showTypeThirdProps.showTime = sSecondValue === 'betweenTime'; } else if (sSecondValue === 'between') { showThirdConfig.sDateFormat = 'YYYY-MM-DD'; /* showTime为true显示可以选择具体时间 */ showTypeThirdProps.showTime = false; if(firstDataIndex && firstDataIndex === 'm') { showThirdConfig.sDateFormat = 'YYYY-MM'; } else if (firstDataIndex && firstDataIndex === 'y') { showThirdConfig.sDateFormat = 'YYYY'; } } return (