| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | editform: null, |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | editform: null, |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | editform: null, |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | visible: false |
| | |
| | | type: 'select', |
| | | key: 'popClose', |
| | | label: '关闭后', |
| | | initVal: card.popClose || 'never', |
| | | initVal: card.popClose || 'grid', |
| | | required: true, |
| | | options: [{ |
| | | value: 'never', |
| | |
| | | type: 'select', |
| | | key: 'popClose', |
| | | label: '关闭后', |
| | | initVal: card.popClose || 'never', |
| | | initVal: card.popClose || 'grid', |
| | | required: true, |
| | | options: [{ |
| | | value: 'never', |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | searchlist: _searchlist, |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({visible: false, loading: false, formlist: null}) |
| | | this.props.submitCol(values) |
| | | this.record = null |
| | |
| | | } else { |
| | | this.setState({loading: true}) |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (res.status || res.ErrCode === '-2') { |
| | | this.setState({ |
| | | loading: false, |
| | | editItem: null |
| | |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.datefield) |
| | | _usefulFields.push(item.datefield + '1') |
| | | } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { |
| | | } else if (['dateweek', 'datemonth'].includes(item.type)) { |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.field + '1') |
| | | } else if (item.type === 'daterange') { |
| | | let _skey = item.field |
| | | let _ekey = item.field + '1' |
| | | |
| | | if (/,/.test(item.field)) { |
| | | _skey = item.field.split(',')[0] |
| | | _ekey = item.field.split(',')[1] |
| | | } |
| | | _usefulFields.push(_skey) |
| | | _usefulFields.push(_ekey) |
| | | } else if (item.type === 'date' && _usefulFields.includes(item.field)) { |
| | | _usefulFields.push(item.field + '1') |
| | | } else { |
| | |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.datefield) |
| | | _usefulFields.push(item.datefield + '1') |
| | | } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { |
| | | } else if (['dateweek', 'datemonth'].includes(item.type)) { |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.field + '1') |
| | | } else if (item.type === 'daterange') { |
| | | let _skey = item.field |
| | | let _ekey = item.field + '1' |
| | | |
| | | if (/,/.test(item.field)) { |
| | | _skey = item.field.split(',')[0] |
| | | _ekey = item.field.split(',')[1] |
| | | } |
| | | _usefulFields.push(_skey) |
| | | _usefulFields.push(_ekey) |
| | | } else if (item.type === 'date' && _usefulFields.includes(item.field)) { |
| | | _usefulFields.push(item.field + '1') |
| | | } else { |
| | |
| | | } |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | this.sqlverify(resolve, reject, false, scripts) |
| | | this.sqlverify(resolve, reject, 'script', scripts) |
| | | }) |
| | | } |
| | | |
| | |
| | | loading: false |
| | | }) |
| | | this.getdefaultSql() |
| | | }, true) |
| | | }, 'change') |
| | | }) |
| | | }, () => { |
| | | this.setState({loading: false}) |
| | |
| | | defaultSearch: _search, |
| | | setting: res |
| | | }, () => { |
| | | this.sqlverify(() => { resolve({setting: res, columns, subColumns, scripts, cols }) }, reject, false) |
| | | this.sqlverify(() => { resolve({setting: res, columns, subColumns, scripts, cols }) }, reject, 'submit') |
| | | }) |
| | | }, () => { |
| | | reject() |
| | |
| | | reject() |
| | | return |
| | | } |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, false) |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit') |
| | | } else if (activeKey === 'subcolumns') { |
| | | if (this.subdatasource && this.subdatasource.state.editingKey) { |
| | | notification.warning({ |
| | |
| | | reject() |
| | | return |
| | | } |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, false) |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit') |
| | | } else if (activeKey === 'scripts') { |
| | | let _loading = false |
| | | if (this.scriptsForm && this.scriptsForm.state.editItem) { |
| | |
| | | return |
| | | } |
| | | |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, false) |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit') |
| | | } |
| | | }) |
| | | } |
| | | |
| | | sqlverify = (resolve, reject, change = false, testScripts) => { |
| | | sqlverify = (resolve, reject, type, testScripts) => { |
| | | const { config } = this.props |
| | | const { columns, setting, scripts, searches, defaultSearch, debugId } = this.state |
| | | |
| | |
| | | if (testScripts) { |
| | | _scripts = testScripts.filter(item => item.status !== 'false') |
| | | } |
| | | if (!change && setting.interType === 'system' && setting.execute === 'false' && _scripts.length === 0) { |
| | | if (type !== 'change' && setting.interType === 'system' && setting.execute === 'false' && _scripts.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不执行默认sql时,请添加自定义脚本!', |
| | |
| | | return |
| | | } |
| | | |
| | | if (change && columns.length === 0) { |
| | | if (type === 'change' && columns.length === 0) { |
| | | reject() |
| | | return |
| | | } |
| | |
| | | param.timestamp = timestamp |
| | | param.secretkey = Utils.encrypt('', timestamp) |
| | | |
| | | let sumParam = null |
| | | if (r.sumSql) { |
| | | sumParam = { |
| | | func: 's_debug_sql', |
| | | exec_type: 'y', |
| | | LText: r.sumSql |
| | | } |
| | | sumParam.LText = Utils.formatOptions(sumParam.LText) |
| | | sumParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | sumParam.secretkey = Utils.encrypt('', sumParam.timestamp) |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (sumParam) { |
| | | Api.genericInterface(sumParam).then(res => { |
| | | if (res.status) { |
| | | this.setState({debugId: _debugId}, () => { |
| | | resolve() |
| | | }) |
| | | } else { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({debugId: _debugId}, () => { |
| | | resolve() |
| | | }) |
| | | } else { |
| | | if (type === 'submit') { |
| | | Modal.confirm({ |
| | | title: result.message, |
| | | okText: '知道了', |
| | | cancelText: '强制保存', |
| | | onOk: () => { |
| | | reject() |
| | | Modal.error({ |
| | | title: res.message |
| | | }) |
| | | }, |
| | | onCancel() { |
| | | resolve() |
| | | } |
| | | }) |
| | | } else { |
| | | this.setState({debugId: _debugId}, () => { |
| | | resolve() |
| | | reject() |
| | | Modal.error({ |
| | | title: result.message, |
| | | okText: '知道了' |
| | | }) |
| | | } |
| | | } else { |
| | | reject() |
| | | Modal.error({ |
| | | title: result.message |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | |
| | | this.setState({loading: true}) |
| | | |
| | | this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, false, _scripts) |
| | | this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, 'script', _scripts) |
| | | } |
| | | |
| | | updatefields = (columns) => { |
| | |
| | | if (!item.field) return |
| | | if (item.datefield) { |
| | | _regoptions.push({ |
| | | var: new RegExp('@' + item.datefield, 'ig'), |
| | | reg: new RegExp('@' + item.datefield + '@', 'ig') |
| | | }) |
| | | _regoptions.push({ |
| | | var: new RegExp('@' + item.datefield + '1', 'ig'), |
| | | reg: new RegExp('@' + item.datefield + '1@', 'ig') |
| | | }) |
| | | } |
| | | if (['dateweek', 'datemonth', 'daterange', 'range'].includes(item.type)) { |
| | | if (['dateweek', 'datemonth', 'range'].includes(item.type)) { |
| | | _regoptions.push({ |
| | | var: new RegExp('@' + item.field, 'ig'), |
| | | reg: new RegExp('@' + item.field + '@', 'ig') |
| | | }) |
| | | _regoptions.push({ |
| | | var: new RegExp('@' + item.field + '1', 'ig'), |
| | | reg: new RegExp('@' + item.field + '1@', 'ig') |
| | | }) |
| | | } else if (item.type === 'daterange') { |
| | | let _skey = item.field |
| | | let _ekey = item.field + '1' |
| | | |
| | | if (/,/.test(item.field)) { |
| | | _skey = item.field.split(',')[0] |
| | | _ekey = item.field.split(',')[1] |
| | | } |
| | | |
| | | _regoptions.push({ |
| | | reg: new RegExp('@' + _skey + '@', 'ig') |
| | | }) |
| | | _regoptions.push({ |
| | | reg: new RegExp('@' + _ekey + '@', 'ig') |
| | | }) |
| | | } else if (item.type === 'date') { |
| | | if (_fields.includes(item.field)) { |
| | | _regoptions.push({ |
| | | var: new RegExp('@' + item.field + '1', 'ig'), |
| | | reg: new RegExp('@' + item.field + '1@', 'ig') |
| | | }) |
| | | } else { |
| | | _fields.push(item.field) |
| | | _regoptions.push({ |
| | | var: new RegExp('@' + item.field, 'ig'), |
| | | reg: new RegExp('@' + item.field + '@', 'ig') |
| | | }) |
| | | } |
| | | } else if (item.type === 'text' || item.type === 'select') { |
| | | item.field.split(',').forEach(field => { |
| | | _regoptions.push({ |
| | | var: new RegExp('@' + field, 'ig'), |
| | | reg: new RegExp('@' + field + '@', 'ig') |
| | | }) |
| | | }) |
| | | } else { |
| | | _regoptions.push({ |
| | | var: new RegExp('@' + item.field, 'ig'), |
| | | reg: new RegExp('@' + item.field + '@', 'ig') |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | config: _config, |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | config: _config, |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | group: _group, |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | config: _config, |
| | |
| | | } else { |
| | | this.setState({loading: true}) |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (res.status || res.ErrCode === '-2') { |
| | | this.setState({ |
| | | loading: false, |
| | | editItem: null |
| | |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.datefield) |
| | | _usefulFields.push(item.datefield + '1') |
| | | } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { |
| | | } else if (['dateweek', 'datemonth'].includes(item.type)) { |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.field + '1') |
| | | } else if (item.type === 'daterange') { |
| | | let _skey = item.field |
| | | let _ekey = item.field + '1' |
| | | |
| | | if (/,/.test(item.field)) { |
| | | _skey = item.field.split(',')[0] |
| | | _ekey = item.field.split(',')[1] |
| | | } |
| | | _usefulFields.push(_skey) |
| | | _usefulFields.push(_ekey) |
| | | } else if (item.type === 'date' && _usefulFields.includes(item.field)) { |
| | | _usefulFields.push(item.field + '1') |
| | | } else { |
| | |
| | | param.secretkey = Utils.encrypt('', timestamp) |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({debugId: _debugId}) |
| | | _resolve() |
| | | } else { |
| | |
| | | value: '0' |
| | | }) |
| | | options.push(item) |
| | | } else if (['datemonth', 'dateweek', 'daterange'].includes(search.type)) { |
| | | } else if (['datemonth', 'dateweek'].includes(search.type)) { |
| | | options.push(item) |
| | | options.push({ |
| | | key: item.key + '1', |
| | | value: '0' |
| | | }) |
| | | } else if (search.type === 'daterange') { |
| | | let _skey = search.field |
| | | let _ekey = search.field + '1' |
| | | |
| | | if (/,/.test(search.field)) { |
| | | _skey = search.field.split(',')[0] |
| | | _ekey = search.field.split(',')[1] |
| | | } |
| | | |
| | | options.push({ |
| | | key: _skey, |
| | | value: '0' |
| | | }) |
| | | options.push({ |
| | | key: _ekey, |
| | | value: '0' |
| | | }) |
| | | } else if (search.type === 'text' || search.type === 'select') { |
| | | item.key.split(',').forEach(field => { |
| | | let cell = JSON.parse(JSON.stringify(item)) |
| | |
| | | param.secretkey = Utils.encrypt('', timestamp) |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({debugId: _debugId}) |
| | | _resolve() |
| | | } else { |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | searchlist: _searchlist, |
| | |
| | | |
| | | if (type === 'text' || type === 'select') { |
| | | reTooltip.field = '字段名可以使用逗号分隔,进行综合搜索。' |
| | | } else if (type === 'daterange') { |
| | | reTooltip.field = '字段名可以使用逗号分隔,例如startTime,endTime。' |
| | | } else if (type === 'group') { |
| | | reTooltip.field = '查询数据时(自定义脚本或统计数据源),类型字段将用作替换脚本中的 @字段@ ,类型字段对应值为:日 -> day;周 -> week;月 -> month;季 -> quarter;年 -> year;自定义 -> customized' |
| | | reLabel.field = '类型字段' |
| | |
| | | ] |
| | | if (item.key === 'field' || item.key === 'datefield') { |
| | | rules.push({ |
| | | pattern: (type === 'text' || type === 'select') ? formRule.field.multipattern : formRule.field.pattern, |
| | | pattern: (type === 'text' || type === 'select' || type === 'daterange') ? formRule.field.multipattern : formRule.field.pattern, |
| | | message: formRule.field.message |
| | | }, { |
| | | max: formRule.field.max, |
| | |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | values.uuid = this.props.card.uuid |
| | | |
| | | if (/,/.test(values.field)) { |
| | | values.field = values.field.split(',').filter(Boolean) |
| | | if (values.type === 'daterange' && values.field.length > 2) { |
| | | values.field.length = 2 |
| | | } |
| | | values.field = values.field.join(',') |
| | | } |
| | | |
| | | // 下拉菜单或联动菜单 |
| | | if (['multiselect', 'select', 'link', 'radio'].includes(values.type)) { |
| | | if (values.resourceType === '0') { |
| | |
| | | value: '0' |
| | | }) |
| | | options.push(item) |
| | | } else if (['datemonth', 'dateweek', 'daterange'].includes(search.type)) { |
| | | } else if (['datemonth', 'dateweek'].includes(search.type)) { |
| | | options.push(item) |
| | | options.push({ |
| | | key: item.key + '1', |
| | | value: '0' |
| | | }) |
| | | } else if (search.type === 'daterange') { |
| | | let _skey = search.field |
| | | let _ekey = search.field + '1' |
| | | |
| | | if (/,/.test(search.field)) { |
| | | _skey = search.field.split(',')[0] |
| | | _ekey = search.field.split(',')[1] |
| | | } |
| | | |
| | | options.push({ |
| | | key: _skey, |
| | | value: '0' |
| | | }) |
| | | options.push({ |
| | | key: _ekey, |
| | | value: '0' |
| | | }) |
| | | } else if (search.type === 'text' || search.type === 'select') { |
| | |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | if (sumParam) { |
| | | Api.genericInterface(sumParam).then(res => { |
| | | if (res.status) { |
| | | if (res.status || res.ErrCode === '-2') { |
| | | _resolve() |
| | | } else { |
| | | _reject() |
| | |
| | | |
| | | this.setState({loading: true}) |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | this.setState({ |
| | | loading: false, |
| | | scripts: _scripts, |
| | |
| | | param.secretkey = Utils.encrypt('', timestamp) |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | _resolve() |
| | | } else { |
| | | _reject() |
| | |
| | | type: refresh.length === 0 ? 'radio' : 'select', |
| | | key: 'popClose', |
| | | label: '关闭后', |
| | | initVal: card.popClose || 'never', |
| | | initVal: card.popClose || 'grid', |
| | | required: true, |
| | | options: [{ |
| | | value: 'never', |
| | |
| | | } else { |
| | | this.setState({loading: true}) |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (res.status || res.ErrCode === '-2') { |
| | | this.setState({ |
| | | loading: false, |
| | | editItem: null |
| | |
| | | |
| | | this.setState({loading: true}) |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (res.status || res.ErrCode === '-2') { |
| | | this.setState({ |
| | | loading: false, |
| | | editItem: null |
| | |
| | | } else { |
| | | this.setState({loading: true}) |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (res.status || res.ErrCode === '-2') { |
| | | this.setState({ |
| | | loading: false, |
| | | editItem: null |
| | |
| | | } |
| | | } |
| | | |
| | | newsearches[item.key] = _startval |
| | | newsearches[item.key + '1'] = _endval |
| | | let _skey = item.key |
| | | let _ekey = item.key + '1' |
| | | |
| | | if (/,/.test(item.key)) { |
| | | _skey = item.key.split(',')[0] |
| | | _ekey = item.key.split(',')[1] |
| | | } |
| | | |
| | | newsearches[_skey] = _startval |
| | | newsearches[_ekey] = _endval |
| | | } else if (item.type === 'text' || item.type === 'select') { |
| | | item.key.split(',').forEach(field => { // 综合搜索,所字段拼接 |
| | | newsearches[field] = item.value |
| | |
| | | _endval = val[1] + '.000' |
| | | } |
| | | |
| | | searchText.push('(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')') |
| | | let _skey = item.key |
| | | let _ekey = item.key |
| | | |
| | | if (/,/.test(item.key)) { |
| | | _skey = item.key.split(',')[0] |
| | | _ekey = item.key.split(',')[1] |
| | | } |
| | | |
| | | searchText.push('(' + _skey + ' >= \'' + _startval + '\' AND ' + _ekey + ' < \'' + _endval + '\')') |
| | | } else if (item.type === 'range') { |
| | | let val = item.value.split(',') |
| | | |