| | |
| | | |
| | | 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}> |
| | |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | key: key, |
| | | key: key.replace(/@tail@$/, ''), |
| | | value: _value, |
| | | match: this.state.match[key] |
| | | }) |
| | |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | key: key, |
| | | key: key.replace(/@tail@$/, ''), |
| | | value: _value, |
| | | match: this.state.match[key] |
| | | }) |
| | |
| | | } |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | key: key, |
| | | key: key.replace(/@tail@$/, ''), |
| | | value: _value, |
| | | match: this.state.match[key] |
| | | }) |
| | |
| | | } |
| | | 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] |
| | | }) |
| | |
| | | } |
| | | |
| | | _config.tabs = _config.tabs || [] |
| | | _config.subtabs = _config.subtabs || [] |
| | | |
| | | this.setState({ |
| | | originActions: _oriActions, |
| | |
| | | this.handleAction(card) |
| | | } else if (type === 'columns') { |
| | | this.handleColumn(card) |
| | | } else if (type === 'tabs' || type === 'subtabs') { |
| | | } else if (type === 'tabs') { |
| | | this.handleTab(card) |
| | | } |
| | | }) |
| | |
| | | } |
| | | |
| | | 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', |
| | |
| | | }, |
| | | { |
| | | 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' |
| | | }] |
| | | }, |
| | | { |
| | |
| | | }] |
| | | }, |
| | | { |
| | | 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 |
| | | ] |
| | | } |
| | | ] |
| | | }) |
| | |
| | | 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} |
| | |
| | | (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 |
| | | } |
| | |
| | | (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 |
| | | } |
| | |
| | | label: 'tab1', |
| | | icon: '', |
| | | type: 'SubTable', |
| | | linkId: '', |
| | | description: '' |
| | | linkTab: '', |
| | | supMenu: '' |
| | | }, |
| | | { |
| | | origin: true, |
| | |
| | | label: 'tab2', |
| | | icon: '', |
| | | type: 'SubTable', |
| | | linkId: '', |
| | | description: '' |
| | | linkTab: '', |
| | | supMenu: '' |
| | | } |
| | | ], |
| | | subtabs: [] |
| | | ] |
| | | } |
| | | |
| | | searchItems = [ |
| | |
| | | }, { |
| | | 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: '白底紫框' |
| | | }] |
| | |
| | | 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') { |
| | | // 月-过滤条件,从月开始至结束 |
| | |
| | | |
| | | 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 |
| | | } |
| | |
| | | // 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 + '\')' |