From 75347779d54c3c8a0893166dbb9c03bc06ea1eee Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 21 十二月 2019 16:58:31 +0800 Subject: [PATCH] 2019-12-21 --- src/templates/comtableconfig/source.jsx | 11 +- src/templates/comtableconfig/index.jsx | 76 ++++++++++++------ src/utils/option.js | 21 +++++ src/tabviews/commontable/mainSearch/index.jsx | 29 +++++-- src/utils/utils.js | 59 +++++++++----- 5 files changed, 137 insertions(+), 59 deletions(-) diff --git a/src/tabviews/commontable/mainSearch/index.jsx b/src/tabviews/commontable/mainSearch/index.jsx index 78ff563..e65725f 100644 --- a/src/tabviews/commontable/mainSearch/index.jsx +++ b/src/tabviews/commontable/mainSearch/index.jsx @@ -14,26 +14,39 @@ state = { match: null, // 鎼滅储鏉′欢鍖归厤瑙勫垯 - style: null + style: null, + searchlist: null } UNSAFE_componentWillMount () { let match = {} let style = {} + let _list = [] + let fieldMap = new Map() + this.props.searchlist.forEach(item => { + if (fieldMap.has(item.field)) { + item.field = item.field + '@tail@' + } + fieldMap.set(item.field, true) + match[item.field] = item.match style[item.field] = item.type + + _list.push(item) }) + this.setState({ match: match, - style: style + style: style, + searchlist: _list }) } getFields() { const { getFieldDecorator } = this.props.form const fields = [] - this.props.searchlist.forEach((item, index) => { + this.state.searchlist.forEach((item, index) => { if (item.type === 'text') { // 鏂囨湰鎼滅储 fields.push( <Col span={6} key={index}> @@ -186,7 +199,7 @@ } search.push({ type: this.state.style[key], - key: key, + key: key.replace(/@tail@$/, ''), value: _value, match: this.state.match[key] }) @@ -197,7 +210,7 @@ } search.push({ type: this.state.style[key], - key: key, + key: key.replace(/@tail@$/, ''), value: _value, match: this.state.match[key] }) @@ -208,7 +221,7 @@ } search.push({ type: this.state.style[key], - key: key, + key: key.replace(/@tail@$/, ''), value: _value, match: this.state.match[key] }) @@ -219,14 +232,14 @@ } search.push({ type: this.state.style[key], - key: key, + key: key.replace(/@tail@$/, ''), value: _value, match: this.state.match[key] }) } else { search.push({ type: this.state.style[key], - key: key, + key: key.replace(/@tail@$/, ''), value: values[key].replace(/(^\s*|\s*$)/ig, ''), match: this.state.match[key] }) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index f1a2f66..db0e52a 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -113,7 +113,6 @@ } _config.tabs = _config.tabs || [] - _config.subtabs = _config.subtabs || [] this.setState({ originActions: _oriActions, @@ -287,7 +286,7 @@ this.handleAction(card) } else if (type === 'columns') { this.handleColumn(card) - } else if (type === 'tabs' || type === 'subtabs') { + } else if (type === 'tabs') { this.handleTab(card) } }) @@ -913,6 +912,28 @@ } handleTab = (card) => { + const { config } = this.state + + let menus = [] + + config.tabs.forEach(item => { + if (item.origin || card.uuid === item.uuid) return + + let menu = { + value: item.uuid, + text: item.label + } + + menus.push(menu) + }) + + if (card.supMenu && card.supMenu !== 'mainTable') { + let _menu = menus.filter(item => item.value === card.supMenu)[0] + if (!_menu) { + card.supMenu = '' + } + } + this.setState({ visible: true, formtemp: 'tabs', @@ -939,22 +960,22 @@ }, { type: 'select', - key: 'linkId', + key: 'linkTab', label: '鍏宠仈鏍囩', - initVal: card.linkId || '', - required: true, + initVal: card.linkTab || '', + required: false, options: [{ - value: 'table', - text: 'table' + value: '', + text: '鏂板缓' }, { - value: 'bar-chart', - text: 'bar-chart' + value: 'jadisfjiasodjIjjaidfoasdf', + text: '瀛愯〃1' }, { - value: 'pie-chart', - text: 'pie-chart' + value: 'dasjfsioafjiaga', + text: '瀛愯〃2' }, { - value: 'line-chart', - text: 'line-chart' + value: 'jadsifjasgfisag', + text: '瀛愯〃3' }] }, { @@ -981,11 +1002,21 @@ }] }, { - type: 'text', - key: 'description', - label: this.state.dict['header.form.description'], - initVal: card.description || '', - required: false + type: 'select', + key: 'supMenu', + label: '鍏宠仈鑿滃崟', + initVal: card.supMenu || '', + required: false, + options: [ + { + value: '', + text: this.state.dict['header.form.empty'] + }, { + value: 'mainTable', + text: '涓昏〃' + }, + ...menus + ] } ] }) @@ -1718,9 +1749,6 @@ if (config.tabs[0] && config.tabs[0].origin) { config.tabs = config.tabs.filter(item => !item.origin) } - if (config.subtabs[0] && config.subtabs[0].origin) { - config.subtabs = config.subtabs.filter(item => !item.origin) - } let _LongParam = '' let _config = {...config, tables: this.state.selectedTables} @@ -1977,8 +2005,7 @@ (config.search[0] && config.search[0].origin) || (config.action[0] && config.action[0].origin) || (config.columns[0] && config.columns[0].origin) || - (config.tabs[0] && config.tabs[0].origin) || - (config.subtabs[0] && config.subtabs[0].origin) + (config.tabs[0] && config.tabs[0].origin) ) { isAdd = true } @@ -2339,8 +2366,7 @@ (config.search[0] && config.search[0].origin) || (config.action[0] && config.action[0].origin) || (config.columns[0] && config.columns[0].origin) || - (config.tabs[0] && config.tabs[0].origin) || - (config.subtabs[0] && config.subtabs[0].origin) + (config.tabs[0] && config.tabs[0].origin) ) { isAdd = true } diff --git a/src/templates/comtableconfig/source.jsx b/src/templates/comtableconfig/source.jsx index c95b5f3..e502372 100644 --- a/src/templates/comtableconfig/source.jsx +++ b/src/templates/comtableconfig/source.jsx @@ -206,8 +206,8 @@ label: 'tab1', icon: '', type: 'SubTable', - linkId: '', - description: '' + linkTab: '', + supMenu: '' }, { origin: true, @@ -215,11 +215,10 @@ label: 'tab2', icon: '', type: 'SubTable', - linkId: '', - description: '' + linkTab: '', + supMenu: '' } - ], - subtabs: [] + ] } searchItems = [ diff --git a/src/utils/option.js b/src/utils/option.js index b97f0eb..13e7123 100644 --- a/src/utils/option.js +++ b/src/utils/option.js @@ -138,4 +138,25 @@ }, { MenuID: 'gray', text: '鐏拌壊' +}, { + MenuID: 'dashed', + text: '鐧藉簳铏氭' +}, { + MenuID: 'border-primary', + text: '鐧藉簳钃濇' +}, { + MenuID: 'border-yellow', + text: '鐧藉簳榛勬' +}, { + MenuID: 'border-danger', + text: '鐧藉簳绾㈡' +}, { + MenuID: 'border-green', + text: '鐧藉簳缁挎' +}, { + MenuID: 'border-dgreen', + text: '鐧藉簳娣辩豢妗�' +}, { + MenuID: 'border-purple', + text: '鐧藉簳绱' }] diff --git a/src/utils/utils.js b/src/utils/utils.js index 46e4704..e5648a1 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -242,17 +242,21 @@ searches.forEach(item => { if (item.type === 'date') { let timetail = '' + let _val = item.value if (item.match === '<' || item.match === '<=') { - timetail = ' 23:59:59.999' + timetail = ' 00:00:00.000' + if (_val) { + _val = moment(_val, 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + } } else if (item.match === '>' || item.match === '>=') { timetail = ' 00:00:00.000' } if (newsearches[item.key]) { - newsearches[item.key + '1'] = item.value ? item.value + timetail : null + newsearches[item.key + '1'] = _val ? _val + timetail : null } else { - newsearches[item.key] = item.value ? item.value + timetail : null + newsearches[item.key] = _val ? _val + timetail : null } } else if (item.type === 'datemonth') { // 鏈�-杩囨护鏉′欢锛屼粠鏈堝紑濮嬭嚦缁撴潫 @@ -261,19 +265,27 @@ if (item.value) { _startval = moment(item.value, 'YYYY-MM').startOf('month').format('YYYY-MM-DD') + ' 00:00:00.000' - _endval = moment(item.value, 'YYYY-MM').endOf('month').format('YYYY-MM-DD') + ' 23:59:59.999' + _endval = moment(item.value, 'YYYY-MM').endOf('month').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' } newsearches[item.key] = _startval newsearches[item.key + '1'] = _endval } else if (item.type === 'dateweek') { + let _endval = '' + if (item.value) { + _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + } newsearches[item.key] = item.value ? item.value[0] + ' 00:00:00.000' : null - newsearches[item.key + '1'] = item.value ? item.value[1] + ' 23:59:59.999' : null + newsearches[item.key + '1'] = item.value ? _endval + ' 00:00:00.000' : null } else if (item.type === 'daterange') { + let _endval = '' + if (item.value) { + _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + } newsearches[item.key] = item.value ? item.value[0] + ' 00:00:00.000' : null - newsearches[item.key + '1'] = item.value ? item.value[1] + ' 23:59:59.999' : null + newsearches[item.key + '1'] = item.value ? _endval + ' 00:00:00.000' : null } else { newsearches[item.key] = item.value } @@ -301,30 +313,37 @@ // eslint-disable-next-line searchText += item.key + ' ' + item.match + ' ' + '\'' + str + item.value + str + '\'' } else if (item.type === 'date') { + let _val = item.value let timetail = ' 00:00:00.000' - if (item.match === '<' || item.match === '<=') { - timetail = ' 23:59:59.999' + let _match = item.match + + if (item.match === '<' || item.match === '<=') { // 鏃堕棿涓�<=鏃讹紝鍖归厤鍚庝竴澶╃殑0鐐癸紝鍖归厤鏂瑰紡涓�< + _match = '<' + _val = moment(_val, 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') } else if (item.match === '=') { timetail = '' } + // eslint-disable-next-line - searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value + timetail + '\')' - } else if (item.type === 'datemonth') { - // 鏈�-杩囨护鏉′欢锛屼粠鏈堝紑濮嬭嚦缁撴潫 + searchText += '(' + item.key + ' ' + _match + ' ' + '\'' + _val + timetail + '\')' + } else if (item.type === 'datemonth') { // 鏈�-杩囨护鏉′欢锛屼粠鏈堝紑濮嬭嚦缁撴潫锛岀粨鏉熸椂闂翠负鏈堟湯鍔犱竴澶╃殑0鐐癸紝鏂瑰紡涓�< let _startval = moment(item.value, 'YYYY-MM').startOf('month').format('YYYY-MM-DD') + ' 00:00:00.000' - let _endval = moment(item.value, 'YYYY-MM').endOf('month').format('YYYY-MM-DD') + ' 23:59:59.999' + let _endval = moment(item.value, 'YYYY-MM').endOf('month').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' + // eslint-disable-next-line - searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + _startval + '\' AND \'' + _endval + '\')' - } else if (item.type === 'dateweek') { - let stimetail = ' 00:00:00.000' - let etimetail = ' 23:59:59.999' + searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')' + } else if (item.type === 'dateweek') { // 鍛�-杩囨护鏉′欢 + let _startval = item.value[0] + ' 00:00:00.000' + let _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' + // eslint-disable-next-line - searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value[0] + stimetail + '\' AND \'' + item.value[1] + etimetail + '\')' + searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')' } else if (item.type === 'daterange') { - let stimetail = ' 00:00:00.000' - let etimetail = ' 23:59:59.999' + let _startval = item.value[0] + ' 00:00:00.000' + let _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' + // eslint-disable-next-line - searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value[0] + stimetail + '\' AND \'' + item.value[1] + etimetail + '\')' + searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')' } else { // eslint-disable-next-line searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value + '\')' -- Gitblit v1.8.0