| | |
| | | // 权限过滤 |
| | | if (this.props.menuType !== 'HS') { |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | | |
| | | // 字段权限黑名单 |
| | | config.search = config.search.filter(item => { |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | |
| | | let _black = item.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0) { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | |
| | | config.columns = config.columns.filter(col => { |
| | | if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return true |
| | | |
| | | let _black = col.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0) { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | |
| | | // 视图权限 |
| | | config.charts = config.charts.filter(item => { |
| | | if (item.Hide === 'true') return false |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | |
| | | let _black = item.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0 || item.Hide === 'true') { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | } else { |
| | | // 隐藏视图 |
| | | config.charts = config.charts.filter(item => item.Hide !== 'true') |
| | | } |
| | | |
| | | // 字段权限黑名单 |
| | | config.search = config.search.filter(item => { |
| | | item.oriInitval = item.initval |
| | | if (!item.blacklist || item.blacklist.length === 0) return item |
| | | |
| | | let _black = item.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0) { |
| | | item.Hide = 'true' |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | config.columns = config.columns.filter(col => { |
| | | if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return col |
| | | |
| | | let _black = col.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0) { |
| | | col.Hide = 'true' |
| | | } |
| | | |
| | | return col |
| | | }) |
| | | |
| | | // 视图权限 |
| | | config.charts = config.charts.filter(item => { |
| | | if (item.Hide === 'true') return false |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | |
| | | let _black = item.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0 || item.Hide === 'true') { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | |
| | | if (config.charts.length <= 1) { |
| | | config.expand = true |
| | |
| | | arr_field: _arrField.join(','), |
| | | search: Utils.initMainSearch(config.search) // 搜索条件初始化(含有时间格式,需要转化) |
| | | }, () => { |
| | | this.improveSearch() |
| | | |
| | | if (config.setting.onload !== 'false' && valid) { // 初始化可加载 |
| | | this.loadmaindata() |
| | | } |
| | |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 搜索条件下拉选项预加载 |
| | | */ |
| | | improveSearch = () => { |
| | | let searchlist = JSON.parse(JSON.stringify(this.state.searchlist)) |
| | | let deffers = [] |
| | | searchlist.forEach(item => { |
| | | if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return |
| | | if (item.setAll === 'true') { |
| | | item.options.unshift({ |
| | | key: Utils.getuuid(), |
| | | Value: '', |
| | | Text: this.state.dict['main.all'] |
| | | }) |
| | | } |
| | | |
| | | if (item.resourceType === '1' && item.dataSource) { |
| | | let _option = Utils.getSelectQueryOptions(item) |
| | | let _sql = Utils.formatOptions(_option.sql) |
| | | let isSSO = item.database === 'sso' |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: _sql, |
| | | obj_name: 'data', |
| | | arr_field: _option.field |
| | | } |
| | | |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | | } |
| | | if (this.props.dataManager) { // 数据权限 |
| | | param.LText = param.LText.replace(/\$@/ig, '/*') |
| | | param.LText = param.LText.replace(/@\$/ig, '*/') |
| | | } else { |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | } |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | if (this.props.menuType === 'HS') { // 云端数据验证 |
| | | param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) |
| | | } |
| | | |
| | | let defer = new Promise(resolve => { |
| | | Api.getSystemCacheConfig(param, isSSO).then(res => { |
| | | res.search = item |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | deffers.push(defer) |
| | | } else if (item.resourceType === '1' && !item.dataSource) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: item.label + ': ' + this.state.dict['main.datasource.settingerror'], |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.setState({searchlist: JSON.parse(JSON.stringify(searchlist))}) |
| | | |
| | | if (deffers.length === 0) return |
| | | |
| | | Promise.all(deffers).then(result => { |
| | | result.forEach(res => { |
| | | if (res.status) { |
| | | searchlist = searchlist.map(item => { |
| | | if (item.uuid === res.search.uuid) { |
| | | res.data.forEach(cell => { |
| | | item.options.push({ |
| | | key: Utils.getuuid(), |
| | | Value: cell[res.search.valueField], |
| | | Text: cell[res.search.valueText] |
| | | }) |
| | | }) |
| | | } |
| | | return item |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.search.label + ':' + res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | this.setState({searchlist}) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | {loadingview && <Spin />} |
| | | {searchlist && searchlist.length > 0 ? |
| | | <SubSearch |
| | | refreshdata={this.refreshbysearch} |
| | | searchlist={searchlist} |
| | | BID={this.props.BID} |
| | | dict={this.state.dict} |
| | | searchlist={searchlist} |
| | | menuType={this.props.menuType} |
| | | dataManager={this.props.dataManager} |
| | | refreshdata={this.refreshbysearch} |
| | | /> : null |
| | | } |
| | | {config ? <div className="chart-view"> |