| | |
| | | }) |
| | | } |
| | | |
| | | if (!card.linkurl && (!card.linkmenu || card.linkmenu.length === 0)) { |
| | | card.perspective = '' |
| | | } |
| | | |
| | | return [ |
| | | { |
| | | type: 'text', |
| | |
| | | type: 'radio', |
| | | key: 'perspective', |
| | | label: '字段透视', |
| | | initVal: card.perspective || 'linkmenu', |
| | | initVal: card.perspective || '', |
| | | options: [{ |
| | | value: '', |
| | | text: '无' |
| | | }, { |
| | | value: 'linkmenu', |
| | | text: '菜单' |
| | | }, { |
| | |
| | | key: 'linkmenu', |
| | | label: Formdict['model.menu'], |
| | | initVal: card.linkmenu || [], |
| | | required: false, |
| | | required: true, |
| | | options: menulist |
| | | }, |
| | | { |
| | |
| | | key: 'linkurl', |
| | | label: '链接地址', |
| | | initVal: card.linkurl || '', |
| | | required: false |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'multiselect', |
| | | key: 'linkfields', |
| | | label: '关联字段', |
| | | initVal: card.linkfields || [], |
| | | required: false, |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'multiselect', |
| | |
| | | let formlist = getColumnForm(column, menulist, this.props.fields) |
| | | let _options = fromJS(columnTypeOptions[column.type]).toJS() |
| | | if (column.type === 'text' || column.type === 'number') { |
| | | if (column.perspective !== 'linkurl') { |
| | | _options.push('linkmenu') |
| | | } else { |
| | | if (column.perspective === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields') |
| | | } else if (column.perspective === 'linkurl') { |
| | | _options.push('linkurl') |
| | | } |
| | | } |
| | |
| | | if (key === 'type') { |
| | | let _options = fromJS(columnTypeOptions[value]).toJS() |
| | | |
| | | if (value === 'text' || value === 'number') { |
| | | _options.push('linkmenu') |
| | | } |
| | | |
| | | this.setState({ |
| | | type: value, |
| | | formlist: this.state.formlist.map(item => { |
| | |
| | | if (value === 'link' || value === 'textarea' || value === 'picture') { |
| | | this.props.form.setFieldsValue({IsSort: 'false'}) |
| | | } else if (value === 'text' || value === 'number') { |
| | | this.props.form.setFieldsValue({perspective: 'linkmenu'}) |
| | | this.props.form.setFieldsValue({perspective: ''}) |
| | | } else if (value === 'action' || value === 'colspan') { |
| | | this.props.form.setFieldsValue({Align: 'center'}) |
| | | } |
| | |
| | | if (key === 'perspective') { |
| | | let _options = fromJS(columnTypeOptions[this.state.type]).toJS() |
| | | |
| | | if (value !== 'linkurl') { |
| | | _options.push('linkmenu') |
| | | } else { |
| | | if (value === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields') |
| | | } else if (value === 'linkurl') { |
| | | _options.push('linkurl') |
| | | } |
| | | |
| | |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | > |
| | | {item.options.map((option, i) => |
| | | <Select.Option id={i} key={i} value={option.value}>{option.text}</Select.Option> |
| | | <Select.Option id={i} key={i} value={option.value || option.field}>{option.text || option.label}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || [] |
| | | initialValue: item.initVal || [], |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <Cascader |
| | | options={item.options} |
| | |
| | | _dataresource = _dataresource.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | |
| | | if (window.GLOB.urlFields) { |
| | | window.GLOB.urlFields.forEach(field => { |
| | | let reg = new RegExp('@' + field + '@', 'ig') |
| | | _dataresource = _dataresource.replace(reg, '0') |
| | | _customScript = _customScript.replace(reg, '0') |
| | | }) |
| | | } |
| | | |
| | | |
| | | // 正则替换 |
| | | let _regoptions = [] |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Icon, Modal, Tooltip, notification } from 'antd' |
| | | |
| | | import SettingForm from './settingform' |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | class UrlFieldComponent extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.any, |
| | | updateConfig: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | visible: false, |
| | | urlFields: this.props.config.urlFields || [] |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | editDataSource = () => { |
| | | this.setState({ |
| | | visible: true |
| | | }) |
| | | } |
| | | |
| | | verifySubmit = () => { |
| | | const { urlFields } = this.state |
| | | const { config } = this.props |
| | | |
| | | this.verifyRef.handleConfirm().then(res => { |
| | | if (urlFields.filter(field => field === res.field).length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _urlFields = [...urlFields, res.field] |
| | | |
| | | this.setState({ |
| | | visible: false, |
| | | urlFields: _urlFields |
| | | }) |
| | | |
| | | if (window.GLOB.urlFields) { |
| | | window.GLOB.urlFields = _urlFields |
| | | } |
| | | |
| | | this.props.updateConfig({...config, urlFields: _urlFields}) |
| | | }) |
| | | } |
| | | |
| | | deleteField = (field) => { |
| | | let config = JSON.stringify(this.props.config) |
| | | const _this = this |
| | | |
| | | if (new RegExp(field, 'ig').test(config)) { |
| | | confirm({ |
| | | title: `配置中存在@${field}@,确定删除吗?`, |
| | | content: '', |
| | | onOk() { |
| | | _this.execDelete(field) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | this.execDelete(field) |
| | | } |
| | | } |
| | | |
| | | execDelete = (_field) => { |
| | | const { config } = this.props |
| | | let _urlFields = this.state.urlFields.filter(field => field !== _field) |
| | | |
| | | this.setState({ |
| | | urlFields: _urlFields |
| | | }) |
| | | |
| | | if (window.GLOB.urlFields) { |
| | | window.GLOB.urlFields = _urlFields |
| | | } |
| | | |
| | | this.props.updateConfig({...config, urlFields: _urlFields}) |
| | | } |
| | | |
| | | render () { |
| | | const { visible, urlFields } = this.state |
| | | |
| | | return ( |
| | | <div className="url-field-component"> |
| | | <div className="field-plus"> |
| | | <Tooltip placement="topLeft" title="页面可接收的参数字段,在查询数据源或自定义脚本中使用 @字段@ 接收。"> |
| | | <Icon type="question-circle" /> |
| | | url变量 |
| | | </Tooltip> |
| | | <Icon type="plus" title="添加" onClick={() => this.editDataSource()} /> |
| | | </div> |
| | | <div> |
| | | {urlFields.map((field, index) => { |
| | | return ( |
| | | <div className="field-item" key={index}> |
| | | <Icon type="close" title="删除" onClick={() => this.deleteField(field)} /> |
| | | {field} |
| | | </div> |
| | | ) |
| | | })} |
| | | </div> |
| | | <Modal |
| | | title="字段添加" |
| | | visible={visible} |
| | | width={500} |
| | | maskClosable={false} |
| | | onOk={this.verifySubmit} |
| | | onCancel={() => { this.setState({ visible: false }) }} |
| | | destroyOnClose |
| | | > |
| | | <SettingForm |
| | | inputSubmit={this.verifySubmit} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> |
| | | </Modal> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default UrlFieldComponent |
New file |
| | |
| | | .url-field-component { |
| | | margin-bottom: 15px; |
| | | .field-plus { |
| | | line-height: 35px; |
| | | >.anticon-plus { |
| | | color: #26C281; |
| | | padding: 2px 5px; |
| | | margin-left: 5px; |
| | | } |
| | | .anticon-question-circle { |
| | | color: #c49f47; |
| | | margin-right: 3px; |
| | | } |
| | | } |
| | | .field-item { |
| | | position: relative; |
| | | border: 1px solid #e8e8e8; |
| | | padding: 5px 10px; |
| | | border-radius: 4px; |
| | | |
| | | >.anticon-close { |
| | | position: absolute; |
| | | right: 5px; |
| | | top: 3px; |
| | | font-size: 13px; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Input } from 'antd' |
| | | |
| | | import './index.scss' |
| | | |
| | | class SettingForm extends Component { |
| | | static propTpyes = { |
| | | inputSubmit: PropTypes.func // 回车事件 |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | resolve(values) |
| | | } else { |
| | | reject(err) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | handleSubmit = (e) => { |
| | | e.preventDefault() |
| | | |
| | | if (this.props.inputSubmit) { |
| | | this.props.inputSubmit() |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { getFieldDecorator } = this.props.form |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 8 } |
| | | }, |
| | | wrapperCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 14 } |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <div className="url-field-form"> |
| | | <Form {...formItemLayout}> |
| | | <Form.Item label="字段名"> |
| | | {getFieldDecorator('field', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入字段名!' |
| | | }, |
| | | { |
| | | pattern: /^[a-zA-Z0-9_]*$/ig, |
| | | message: '字段可使用英文、数字或_' |
| | | } |
| | | ] |
| | | })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} |
| | | </Form.Item> |
| | | </Form> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(SettingForm) |
| | |
| | | let roleId = sessionStorage.getItem('role_id') || '' |
| | | config.search = config.search.map(item => { |
| | | item.oriInitval = item.initval |
| | | if (['text', 'select', 'link'].includes(item.type) && param) { |
| | | if (param.searchkey === item.field) { |
| | | item.initval = param.searchval |
| | | } else if (param.data && param.data[item.field]) { |
| | | item.initval = param.data[item.field] |
| | | } |
| | | if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | if (item.required === 'true' && !item.initval) { |
| | |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | } |
| | | if (config.urlFields) { |
| | | let _param = param || {} |
| | | config.urlFields.forEach(field => { |
| | | let reg = new RegExp('@' + field + '@', 'ig') |
| | | let val = `'${_param[field] || ''}'` |
| | | config.setting.dataresource = config.setting.dataresource.replace(reg, val) |
| | | _customScript = _customScript.replace(reg, val) |
| | | }) |
| | | } |
| | | |
| | | config.setting.customScript = _customScript |
| | | } |
| | | |
| | | this.setState({ |
| | | BID: param && param.BID ? param.BID : '', |
| | | BID: param && param.$BID ? param.$BID : '', |
| | | loadingview: false, |
| | | config: config, |
| | | userConfig: userConfig, |
| | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (nextProps.param && !is(fromJS(this.props.param), fromJS(nextProps.param))) { |
| | | let search = this.state.search.map(item => { |
| | | if (item.type === 'text' && item.key === nextProps.param.searchkey) { |
| | | item.value = nextProps.param.searchval |
| | | } |
| | | return item |
| | | }) |
| | | this.refreshbysearch(search) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | // 字段权限黑名单 |
| | | config.search = config.search.map(item => { |
| | | item.oriInitval = item.initval |
| | | if (['text', 'select', 'link'].includes(item.type) && param) { |
| | | if (param.searchkey === item.field) { |
| | | item.initval = param.searchval |
| | | } else if (param.data && param.data[item.field]) { |
| | | item.initval = param.data[item.field] |
| | | } |
| | | if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | if (!item.blacklist || item.blacklist.length === 0) return item |
| | |
| | | config.setting.laypage = config.setting.laypage !== 'false' // 是否分页,转为boolean 统一格式 |
| | | config.setting.execute = config.setting.default !== 'false' // 默认sql是否执行,转为boolean 统一格式 |
| | | config.setting.customScript = '' // 自定义脚本 |
| | | config.setting.dataresource = config.setting.dataresource || '' |
| | | |
| | | if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) { |
| | | if (config.setting.scripts && config.setting.scripts.length > 0) { |
| | |
| | | |
| | | if (!config.setting.execute) { // 默认sql 不执行时 置空 |
| | | config.setting.dataresource = '' |
| | | } else { |
| | | config.setting.dataresource = config.setting.dataresource || '' |
| | | } |
| | | if (/\s/.test(config.setting.dataresource)) { |
| | | config.setting.dataresource = '(' + config.setting.dataresource + ') tb' |
| | |
| | | } else { |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') |
| | | } |
| | | if (config.urlFields) { |
| | | let _param = param || {} |
| | | config.urlFields.forEach(field => { |
| | | let reg = new RegExp('@' + field + '@', 'ig') |
| | | let val = `'${_param[field] || ''}'` |
| | | config.setting.dataresource = config.setting.dataresource.replace(reg, val) |
| | | config.setting.customScript = config.setting.customScript.replace(reg, val) |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | actions: _actions, |
| | | columns: _columns, |
| | | arr_field: _arrField.join(','), |
| | | BID: param && param.BID ? param.BID : '', |
| | | BID: param && param.$BID ? param.$BID : '', |
| | | search: Utils.initMainSearch(config.search), // 搜索条件初始化(含有时间格式,需要转化) |
| | | hasReqFields |
| | | }, () => { |
| | |
| | | if (selectTab && selectTab.MenuID === this.props.MenuID) { |
| | | this.setShortcut() |
| | | } |
| | | } else if (nextProps.param && !is(fromJS(this.props.param), fromJS(nextProps.param))) { |
| | | let search = this.state.search.map(item => { |
| | | if (item.type === 'text' && item.key === nextProps.param.searchkey) { |
| | | item.value = nextProps.param.searchval |
| | | } |
| | | return item |
| | | }) |
| | | this.refreshbysearch(search) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (card.setting.joint === 'true') { |
| | | newtab.param.BID = item.$$uuid |
| | | newtab.param.$BID = item.$$uuid |
| | | } |
| | | |
| | | if (['linkage_navigation', 'linkage'].includes(window.GLOB.navBar)) { |
| | |
| | | } |
| | | |
| | | if (item.setting.joint === 'true') { |
| | | newtab.param.BID = item.setting.primaryId |
| | | newtab.param.$BID = item.setting.primaryId || '' |
| | | } |
| | | |
| | | if (['linkage_navigation', 'linkage'].includes(window.GLOB.navBar)) { |
| | |
| | | } |
| | | |
| | | if (card.setting.joint === 'true') { |
| | | newtab.param.BID = item.$$uuid |
| | | newtab.param.$BID = item.$$uuid |
| | | } |
| | | |
| | | if (['linkage_navigation', 'linkage'].includes(window.GLOB.navBar)) { |
| | |
| | | } |
| | | |
| | | if (item.setting.joint === 'true') { |
| | | newtab.param.BID = item.setting.primaryId |
| | | newtab.param.$BID = item.setting.primaryId |
| | | } |
| | | |
| | | if (['linkage_navigation', 'linkage'].includes(window.GLOB.navBar)) { |
| | |
| | | ...menu, |
| | | selected: true, |
| | | param: { |
| | | BID: primaryId, |
| | | data: data |
| | | $BID: primaryId |
| | | } |
| | | } |
| | | |
| | |
| | | ...menu, |
| | | selected: true, |
| | | param: { |
| | | BID: primaryId, |
| | | data: data |
| | | $BID: primaryId |
| | | } |
| | | } |
| | | |
| | |
| | | let tabmenu = item.linkThdMenu |
| | | |
| | | tabmenu.param = { |
| | | searchkey: item.field, |
| | | searchval: record[item.field] || '', |
| | | BID: record.$$uuid |
| | | $searchkey: item.field, |
| | | $searchval: record[item.field] || '', |
| | | $BID: record.$$uuid |
| | | } |
| | | |
| | | if (item.linkfields && item.linkfields.length > 0) { |
| | | item.linkfields.forEach(field => { |
| | | tabmenu.param[field] = record[field] || '' |
| | | }) |
| | | } |
| | | |
| | | tabmenu.selected = true |
| | |
| | | let _url = item.linkurl.split('paramsmain/')[0] + 'paramsmain/' |
| | | let _param = JSON.parse(window.decodeURIComponent(window.atob(item.linkurl.split('paramsmain/')[1]))) |
| | | let dataparam = { |
| | | searchkey: item.field, |
| | | searchval: record[item.field] || '', |
| | | $searchkey: item.field, |
| | | $searchval: record[item.field] || '', |
| | | BID: record.$$uuid |
| | | } |
| | | _param.UserID = sessionStorage.getItem('UserID') |
| | |
| | | |
| | | component.search = component.search.map(item => { |
| | | item.oriInitval = item.initval |
| | | if (['text', 'select', 'link'].includes(item.type) && param) { |
| | | if (param.searchkey === item.field) { |
| | | item.initval = param.searchval |
| | | } else if (param.data && param.data[item.field]) { |
| | | item.initval = param.data[item.field] |
| | | } |
| | | if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | return item |
| | |
| | | }) |
| | | |
| | | let params = [] |
| | | let BID = param && param.BID ? param.BID : '' |
| | | let BID = param && param.$BID ? param.$BID : '' |
| | | let inherit = {} |
| | | |
| | | if (config.cacheUseful === 'true') { // 缓存继承 |
| | |
| | | inherit.cacheTime = config.cacheTime |
| | | } |
| | | |
| | | config.components = this.formatSetting(config.components, params, mainSearch, inherit) |
| | | let regs = [] |
| | | |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | regs.push({ |
| | | reg: /@db@/ig, |
| | | value: window.GLOB.externalDatabase |
| | | }) |
| | | } |
| | | if (config.urlFields) { |
| | | config.urlFields.forEach(field => { |
| | | let val = `'${param ? (param[field] || '') : ''}'` |
| | | regs.push({ |
| | | reg: new RegExp(field, 'ig'), |
| | | value: val |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs) |
| | | |
| | | this.setState({ |
| | | BID: BID, |
| | |
| | | } |
| | | |
| | | // 格式化默认设置 |
| | | formatSetting = (components, params, mainSearch, inherit) => { |
| | | formatSetting = (components, params, mainSearch, inherit, regs) => { |
| | | return components.map(component => { |
| | | if (component.type === 'tabs') { |
| | | component.subtabs = component.subtabs.map(tab => { |
| | | tab.components = this.formatSetting(tab.components, [], [], inherit) |
| | | tab.components = this.formatSetting(tab.components, [], [], inherit, regs) |
| | | tab = {...tab, ...inherit} |
| | | return tab |
| | | }) |
| | | return component |
| | | } else if (component.type === 'group') { |
| | | component.components = this.formatSetting(component.components, [], [], inherit) |
| | | component.components = this.formatSetting(component.components, [], [], inherit, regs) |
| | | component = {...component, ...inherit} |
| | | return component |
| | | } |
| | |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | } |
| | | |
| | | // 外联数据库替换 |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | regs.forEach(cell => { |
| | | component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value) |
| | | _customScript = _customScript.replace(cell.reg, cell.value) |
| | | }) |
| | | |
| | | component.setting.customScript = _customScript // 整理后自定义脚本 |
| | | |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | BID: param && param.BID ? param.BID : '', |
| | | BID: param && param.$BID ? param.$BID : '', |
| | | loadingview: false, |
| | | config: config, |
| | | setting: config.setting, |
| | |
| | | } |
| | | |
| | | let primaryId = '' |
| | | let _data = null |
| | | |
| | | if (btn.Ot === 'requiredSgl') { |
| | | primaryId = data[0][setting.primaryKey] || '' |
| | | _data = data[0] |
| | | } |
| | | |
| | | let newtab = {} |
| | |
| | | ...menu, |
| | | selected: true, |
| | | param: { |
| | | BID: primaryId, |
| | | data: _data |
| | | $BID: primaryId |
| | | } |
| | | } |
| | | } |
| | |
| | | let tabmenu = item.linkThdMenu |
| | | |
| | | tabmenu.param = { |
| | | searchkey: item.field, |
| | | searchval: record[item.field] || '', |
| | | BID: record.$$uuid |
| | | $searchkey: item.field, |
| | | $searchval: record[item.field] || '', |
| | | $BID: record.$$uuid |
| | | } |
| | | |
| | | if (item.linkfields && item.linkfields.length > 0) { |
| | | item.linkfields.forEach(field => { |
| | | tabmenu.param[field] = record[field] || '' |
| | | }) |
| | | } |
| | | |
| | | tabmenu.selected = true |
| | |
| | | let _url = item.linkurl.split('paramsmain/')[0] + 'paramsmain/' |
| | | let _param = JSON.parse(window.decodeURIComponent(window.atob(item.linkurl.split('paramsmain/')[1]))) |
| | | let dataparam = { |
| | | searchkey: item.field, |
| | | searchval: record[item.field] || '', |
| | | $searchkey: item.field, |
| | | $searchval: record[item.field] || '', |
| | | BID: record[setting.primaryKey] |
| | | } |
| | | _param.UserID = sessionStorage.getItem('UserID') |
| | |
| | | const { Panel } = Collapse |
| | | const { confirm } = Modal |
| | | |
| | | const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) |
| | | const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent')) |
| | | const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcalcomponent')) |
| | | const TabComponent = asyncComponent(() => import('./tabcomponent')) |
| | |
| | | dict={this.state.dict} |
| | | updatemenu={this.updateconfig} |
| | | /> |
| | | {config ? <UrlFieldComponent |
| | | config={config} |
| | | updateConfig={this.updateconfig} |
| | | /> : null} |
| | | {/* 表名添加 */} |
| | | <TableComponent |
| | | config={config} |
| | |
| | | |
| | | const { Panel } = Collapse |
| | | const { confirm } = Modal |
| | | const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) |
| | | const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent')) |
| | | const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent')) |
| | | const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) |
| | |
| | | dict={this.state.dict} |
| | | updatemenu={this.updateconfig} |
| | | /> |
| | | {config ? <UrlFieldComponent |
| | | config={config} |
| | | updateConfig={this.updateconfig} |
| | | /> : null} |
| | | {/* 表名添加 */} |
| | | <TableComponent |
| | | config={config} |
| | |
| | | |
| | | let _options = JSON.parse(JSON.stringify(columnTypeOptions[card.type])) |
| | | if (card.type === 'text' || card.type === 'number') { |
| | | if (card.perspective !== 'linkurl') { |
| | | _options.push('linkmenu') |
| | | } else { |
| | | if (card.perspective === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields') |
| | | } else if (card.perspective === 'linkurl') { |
| | | _options.push('linkurl') |
| | | } |
| | | } |
| | |
| | | let _options = JSON.parse(JSON.stringify(columnTypeOptions[value])) |
| | | |
| | | if (card.type === 'text' || card.type === 'number') { |
| | | if (card.perspective !== 'linkurl') { |
| | | _options.push('linkmenu') |
| | | } else { |
| | | if (card.perspective === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields') |
| | | } else if (card.perspective === 'linkurl') { |
| | | _options.push('linkurl') |
| | | } |
| | | } |
| | |
| | | changeRadio = (key, value) => { |
| | | if (key === 'perspective') { |
| | | let _options = JSON.parse(JSON.stringify(columnTypeOptions[this.state.type])) |
| | | |
| | | if (value !== 'linkurl') { |
| | | _options.push('linkmenu') |
| | | } else { |
| | | if (value === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields') |
| | | } else if (value === 'linkurl') { |
| | | _options.push('linkurl') |
| | | } |
| | | |
| | |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || [] |
| | | initialValue: item.initVal || [], |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <Cascader |
| | | options={this.state.menulist} |
| | |
| | | */ |
| | | handleColumn = (card) => { |
| | | const { menu } = this.props |
| | | const { columnlist } = this.state |
| | | |
| | | if (card.type !== 'colspan') { |
| | | let menulist = [] |
| | |
| | | return fst |
| | | }) |
| | | } |
| | | |
| | | let fields = [] |
| | | columnlist.forEach(col => { |
| | | if (!col.field) return |
| | | fields.push({ |
| | | value: col.field, |
| | | text: col.label |
| | | }) |
| | | }) |
| | | |
| | | this.setState({ |
| | | modaltype: 'columns', |
| | | card: card, |
| | | formlist: getColumnForm(card, menulist) |
| | | formlist: getColumnForm(card, menulist, fields) |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | |
| | | let param = { |
| | | func: 's_debug_sql', |
| | | exec_type: 'y', |
| | | LText: SettingUtils.getDebugSql(setting, _scripts, columns, Utils.getRegOptions(searches), config.calendar) |
| | | LText: SettingUtils.getDebugSql(setting, _scripts, columns, Utils.getRegOptions(searches), config.calendar, config.urlFields) |
| | | } |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | |
| | | * @return {Object} setting 页面设置 |
| | | * @return {Array} columns 显示字段 |
| | | */ |
| | | static getDebugSql (setting, scripts, columns, searches, calendar) { |
| | | static getDebugSql (setting, scripts, columns, searches, calendar, urlFields = []) { |
| | | let sql = '' |
| | | let _dataresource = '' |
| | | let _customScript = '' |
| | |
| | | } |
| | | |
| | | if (setting.execute !== 'false') { |
| | | _dataresource = setting.dataresource |
| | | _dataresource = setting.dataresource || '' |
| | | } |
| | | |
| | | if (_dataresource) { |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | } |
| | | if (_customScript) { |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | } |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | |
| | | // 外联数据库替换 |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | _dataresource = _dataresource.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | |
| | | urlFields.forEach(field => { |
| | | _dataresource = _dataresource.replace(new RegExp('@' + field + '@', 'ig'), '0') |
| | | _customScript = _customScript.replace(new RegExp('@' + field + '@', 'ig'), '0') |
| | | }) |
| | | |
| | | // 正则替换 |
| | | let _regoptions = [] |
| | |
| | | _regoptions.push({ |
| | | reg: new RegExp('@calendarDate@', 'ig'), |
| | | value: `'1970-01-01 00:00:00.000'` |
| | | }) |
| | | _regoptions.push({ |
| | | }, { |
| | | reg: new RegExp('@calendarDate1@', 'ig'), |
| | | value: `'2030-12-31 23:59:59.999'` |
| | | }) |
| | | } |
| | | |
| | | _regoptions.push({ |
| | | reg: new RegExp('@userName@', 'ig'), |
| | | value: `''` |
| | | }, { |
| | | reg: new RegExp('@fullName@', 'ig'), |
| | | value: `''` |
| | | }) |
| | | |
| | | if ((setting.queryType === 'statistics' || calendar.refresh === 'true') && _dataresource) { |
| | | _regoptions.forEach(item => { |
| | | _dataresource = _dataresource.replace(item.reg, item.value) |
| | |
| | | status.requestMode = status.requestMode || 'system' |
| | | status.procMode = status.procMode || 'script' |
| | | status.callbackType = status.callbackType || 'script' |
| | | let regoptions = Utils.getRegOptions(search) |
| | | |
| | | if (config.urlFields && config.urlFields.length > 0) { |
| | | config.urlFields.forEach(field => { |
| | | regoptions.push({ |
| | | key: field, |
| | | value: '0', |
| | | type: 'url' |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | setting: _setting, |
| | | search: _search, |
| | | arr_field: arr_field.join(','), |
| | | regoptions: Utils.getRegOptions(search), // 搜索条件,正则替换 |
| | | regoptions: regoptions, // 搜索条件,正则替换 |
| | | columns: columns, |
| | | scripts: _scripts, |
| | | preScripts: _preScripts, |
| | |
| | | let _regoptions = regoptions.map(item => { |
| | | return { |
| | | reg: new RegExp('@' + item.key + '@', 'ig'), |
| | | value: `'0'` |
| | | value: `'0'`, |
| | | type: item.type || '' |
| | | } |
| | | }) |
| | | |
| | | _regoptions.push({ |
| | | reg: new RegExp('@userName@', 'ig'), |
| | | value: `''` |
| | | }, { |
| | | reg: new RegExp('@fullName@', 'ig'), |
| | | value: `''` |
| | | }, { |
| | | reg: new RegExp('@orderBy@', 'ig'), |
| | | value: setting.order |
| | | }, { |
| | |
| | | _dataresource = _dataresource.replace(item.reg, item.value) |
| | | }) |
| | | _search = '' |
| | | } else if (_dataresource) { |
| | | _regoptions.forEach(item => { |
| | | if (item.type !== 'url') return |
| | | _dataresource = _dataresource.replace(item.reg, item.value) |
| | | }) |
| | | } |
| | | |
| | | if (_customScript) { |
| | |
| | | * @param {object} card // 搜索条件对象 |
| | | * @param {Array} menulist // 菜单列表-用于字段透视 |
| | | */ |
| | | export function getColumnForm (card, menulist = []) { |
| | | export function getColumnForm (card, menulist = [], fields = []) { |
| | | let roleList = sessionStorage.getItem('sysRoles') |
| | | if (roleList) { |
| | | try { |
| | |
| | | } |
| | | } else { |
| | | roleList = [] |
| | | } |
| | | |
| | | if (!card.linkurl && (!card.linkmenu || card.linkmenu.length === 0)) { |
| | | card.perspective = '' |
| | | } |
| | | |
| | | return [ |
| | |
| | | type: 'radio', |
| | | key: 'perspective', |
| | | label: '字段透视', |
| | | initVal: card.perspective || 'linkmenu', |
| | | initVal: card.perspective || '', |
| | | options: [{ |
| | | value: '', |
| | | text: '无' |
| | | }, { |
| | | value: 'linkmenu', |
| | | text: '菜单' |
| | | }, { |
| | |
| | | key: 'linkmenu', |
| | | label: Formdict['model.menu'], |
| | | initVal: card.linkmenu || [], |
| | | required: false, |
| | | required: true, |
| | | options: menulist |
| | | }, |
| | | { |
| | |
| | | key: 'linkurl', |
| | | label: '链接地址', |
| | | initVal: card.linkurl || '', |
| | | required: false |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'multiselect', |
| | | key: 'linkfields', |
| | | label: '关联字段', |
| | | initVal: card.linkfields || [], |
| | | required: false, |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'multiselect', |
| | |
| | | }) |
| | | regoptions.push({ |
| | | reg: new RegExp('@userName@', 'ig'), |
| | | value: userName |
| | | value: `'${userName}'` |
| | | }, { |
| | | reg: new RegExp('@fullName@', 'ig'), |
| | | value: fullName |
| | | value: `'${fullName}'` |
| | | }, { |
| | | reg: new RegExp('@orderBy@', 'ig'), |
| | | value: orderBy |
| | |
| | | }) |
| | | regoptions.push({ |
| | | reg: new RegExp('@userName@', 'ig'), |
| | | value: userName |
| | | value: `'${userName}'` |
| | | }, { |
| | | reg: new RegExp('@fullName@', 'ig'), |
| | | value: fullName |
| | | value: `'${fullName}'` |
| | | }, { |
| | | reg: new RegExp('@orderBy@', 'ig'), |
| | | value: orderBy |
| | |
| | | }) |
| | | regoptions.push({ |
| | | reg: new RegExp('@userName@', 'ig'), |
| | | value: userName |
| | | value: `'${userName}'` |
| | | }, { |
| | | reg: new RegExp('@fullName@', 'ig'), |
| | | value: fullName |
| | | value: `'${fullName}'` |
| | | }) |
| | | |
| | | regoptions.forEach(item => { |
| | |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | } |
| | | |
| | | // 外联数据库替换 |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | component.setting.dataresource = component.setting.dataresource.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | |
| | | component.setting.customScript = _customScript // 整理后自定义脚本 |
| | | |
| | |
| | | const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) |
| | | const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) |
| | | const SysInterface = asyncComponent(() => import('@/menu/sysinterface')) |
| | | const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) |
| | | const PictureController = asyncComponent(() => import('@/menu/picturecontroller')) |
| | | const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) |
| | | const StyleCombController = asyncComponent(() => import('@/menu/stylecombcontroller')) |
| | |
| | | sessionStorage.setItem('editMenuType', 'menu') // 编辑菜单类型 |
| | | document.body.className = '' |
| | | window.GLOB.UserComponentMap = new Map() // 缓存用户自定义组件 |
| | | window.GLOB.urlFields = [] // url变量 |
| | | |
| | | class MenuDesign extends Component { |
| | | state = { |
| | |
| | | } |
| | | |
| | | config.open_edition = result.open_edition || '' |
| | | window.GLOB.urlFields = config.urlFields || [] |
| | | |
| | | this.setState({ |
| | | oriConfig: config, |
| | |
| | | MenuNo={MenuNo} |
| | | updateConfig={this.updateConfig} |
| | | /> : null} |
| | | {config && MenuType === 'custom' ? <UrlFieldComponent |
| | | config={config} |
| | | updateConfig={this.updateConfig} |
| | | /> : null} |
| | | {config && MenuType === 'home' ? <HomeForm |
| | | dict={dict} |
| | | config={config} |
| | |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { config } = this.props |
| | | if (!config && nextProps.config) { |
| | | this.props.form.setFieldsValue({easyCode: nextProps.config.easyCode}) |
| | | } |
| | | } |
| | | |
| | | // 一二级菜单切换 |
| | | selectChange = (key, value) => { |
| | | const { config } = this.props |