| | |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import { getSubMenuForm } from '@/templates/zshare/formconfig' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import TableComponent from '@/templates/sharecomponent/tablecomponent' |
| | | import FieldsComponent from '@/templates/sharecomponent/fieldscomponent' |
| | | import ChartGroupComponent from '@/templates/sharecomponent/chartgroupcomponent' |
| | |
| | | import ActionComponent from '@/templates/sharecomponent/actioncomponent' |
| | | import ColumnComponent from '@/templates/sharecomponent/columncomponent' |
| | | |
| | | import SettingForm from './settingform' |
| | | import MenuForm from '@/templates/zshare/menuform' |
| | | import EditComponent from '@/templates/zshare/editcomponent' |
| | | import SourceElement from '@/templates/zshare/dragsource' |
| | | import CreateFunc from '@/templates/zshare/createfunc' |
| | | import CreateInterface from '@/templates/zshare/createinterface' |
| | | import ChartComponent from '@/templates/zshare/chartcomponent' |
| | | import Source from './source' |
| | | import './index.scss' |
| | |
| | | const { Panel } = Collapse |
| | | const { confirm } = Modal |
| | | const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS |
| | | const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent')) |
| | | |
| | | class SubTableConfig extends Component { |
| | | static propTpyes = { |
| | |
| | | menuloading: false, // 菜单保存中 |
| | | menucloseloading: false, // 菜单关闭时,选择保存 |
| | | loading: false, // 加载中,页面spin |
| | | settingVisible: false, // 全局配置模态框 |
| | | closeVisible: false, // 关闭模态框 |
| | | originConfig: null, // 原配置 |
| | | originActions: null, // 原始按钮信息,使用已有用户模板 |
| | |
| | | optionLibs: null, // 自定义下拉选项库 |
| | | thawButtons: [], // 已选择要解冻的按钮 |
| | | activeKey: '0', // 默认展开基本信息 |
| | | sqlVerifing: false, // sql验证 |
| | | chartview: null, // 当前视图 |
| | | pasteContent: null // 粘贴内容 |
| | | } |
| | |
| | | config: _config, |
| | | activeKey: _activeKey || '0', |
| | | originConfig: _config, |
| | | menuformlist: [ |
| | | { |
| | | type: 'text', |
| | | key: 'tabName', |
| | | label: this.state.dict['header.menu.viewName'], |
| | | initVal: _config.tabName, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'tabNo', |
| | | label: this.state.dict['header.menu.menuNo'], |
| | | initVal: _config.tabNo, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'Remark', |
| | | label: this.state.dict['header.menu.Remark'], |
| | | initVal: _config.Remark, |
| | | required: false, |
| | | readonly: false |
| | | } |
| | | ] |
| | | menuformlist: getSubMenuForm(_config) |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 创建表格存储过程 |
| | | */ |
| | | tableCreatFunc = () => { |
| | | const { config } = this.state |
| | | |
| | | this.settingRef.handleConfirm().then(setting => { |
| | | |
| | | if (!(setting.interType === 'inner') || !setting.innerFunc) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '接口类型为-内部,且存在内部函数时,才可以创建存储过程!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _config = {...config, setting: setting} |
| | | let newLText = Utils.formatOptions(Utils.getTableFunc(setting, {MenuID: _config.uuid, MenuName: _config.tabName, MenuNo: _config.tabNo}, _config)) // 创建存储过程sql |
| | | let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 删除存储过程sql |
| | | |
| | | this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { |
| | | if (result === 'success') { |
| | | this.setState({ |
| | | config: _config |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 标签页保存 |
| | | */ |
| | | submitConfig = () => { |
| | |
| | | } |
| | | |
| | | let _LongParam = '' |
| | | let _config = {...config, ...res} |
| | | let _config = {...config, tabName: res.MenuName, tabNo: res.MenuNo, Remark: res.Remark} |
| | | |
| | | // 未设置数据源或主键时,启用状态为false |
| | | if (_config.setting.interType === 'inner' && !_config.setting.innerFunc && !_config.setting.dataresource) { |
| | |
| | | func: 'sPC_Button_AddUpt', |
| | | Type: 40, |
| | | ParentID: _config.uuid, |
| | | MenuNo: res.tabNo, |
| | | MenuNo: res.MenuNo, |
| | | Template: 'SubTable', |
| | | PageParam: '', |
| | | LongParam: '', |
| | |
| | | let param = { |
| | | func: 'sPC_Tab_AddUpt', |
| | | MenuID: _config.uuid, |
| | | MenuNo: res.tabNo, |
| | | MenuNo: res.MenuNo, |
| | | Template: 'SubTable', |
| | | MenuName: res.tabName, |
| | | MenuName: res.MenuName, |
| | | Remark: res.Remark, |
| | | Sort: 0, |
| | | PageParam: JSON.stringify({Template: 'SubTable'}), |
| | |
| | | } |
| | | } |
| | | |
| | | changeSetting = () => { |
| | | this.setState({ |
| | | settingVisible: true |
| | | }) |
| | | } |
| | | |
| | | settingSave = () => { |
| | | const { config } = this.state |
| | | |
| | | this.settingRef.handleConfirm().then(res => { |
| | | if ( |
| | | res.interType === 'inner' && |
| | | !res.innerFunc && |
| | | /[^\s]+\s+[^\s]+/ig.test(res.dataresource) && |
| | | config.setting.dataresource !== res.dataresource |
| | | ) { |
| | | let param = { |
| | | func: 's_DataSrc_Save', |
| | | LText: res.dataresource, |
| | | MenuID: config.uuid |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | Api.getLocalConfig(param) |
| | | } |
| | | |
| | | if (res.interType === 'inner' && !res.innerFunc && res.dataresource && /\s/.test(res.dataresource)) { |
| | | this.setState({ |
| | | sqlVerifing: true |
| | | }) |
| | | |
| | | let _dataresource = res.dataresource |
| | | |
| | | if (res.queryType === 'statistics') { |
| | | let fieldmap = new Map() |
| | | let options = config.search.map(item => { |
| | | let _field = item.key |
| | | let _val = '' |
| | | |
| | | if (fieldmap.has(_field)) { |
| | | _field = _field + '1' |
| | | } |
| | | |
| | | fieldmap.set(item.key, true) |
| | | |
| | | if (/date/.test(item.type)) { |
| | | _val = '1900-01-01' |
| | | } |
| | | |
| | | return { |
| | | reg: new RegExp('@' + _field + '@', 'ig'), |
| | | value: _val |
| | | } |
| | | }) |
| | | |
| | | options.forEach(item => { |
| | | _dataresource = _dataresource.replace(item.reg, `'${item.value}'`) |
| | | }) |
| | | } |
| | | |
| | | let param = { |
| | | func: 's_debug_sql', |
| | | LText: _dataresource |
| | | } |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | Api.getLocalConfig(param).then(result => { |
| | | if (result.status) { |
| | | this.setState({ |
| | | sqlVerifing: false, |
| | | config: {...config, setting: res}, |
| | | settingVisible: false |
| | | }) |
| | | } else { |
| | | this.setState({sqlVerifing: false}) |
| | | |
| | | Modal.error({ |
| | | title: result.message |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | config: {...config, setting: res}, |
| | | settingVisible: false |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 设置可配置按钮 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 创建表格接口 |
| | | */ |
| | | tableCreatInterface = () => { |
| | | const { config } = this.state |
| | | |
| | | this.menuformRef.handleConfirm().then(res => { |
| | | this.settingRef.handleConfirm().then(setting => { |
| | | if (setting.interType !== 'inner' || setting.innerFunc) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '接口类型为-内部,且不存在内部函数时,才可以创建接口!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _config = {...config, setting: setting} |
| | | let _menu = { |
| | | type: 'subtable', |
| | | MenuID: config.uuid, |
| | | menuName: res.tabName, |
| | | menuNo: res.tabNo |
| | | } |
| | | |
| | | this.refs.tableCreatInterface.triggerOutInterface(_menu, _config) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 编辑功能完成更新,包括解冻按钮、粘贴、替换等 |
| | | */ |
| | | updateConfig = (res) => { |
| | |
| | | /** |
| | | * @description 更新显示列配置信息 |
| | | */ |
| | | updatecolumn = (config) => { |
| | | updateconfig = (config) => { |
| | | this.setState({ |
| | | config: config |
| | | }) |
| | |
| | | <Button onClick={this.cancelConfig}>{this.state.dict['header.return']}</Button> |
| | | </div> |
| | | } style={{ width: '100%' }}> |
| | | <Icon type="setting" onClick={this.changeSetting} /> |
| | | <SettingComponent |
| | | type="subtable" |
| | | config={config} |
| | | MenuID={config.uuid} |
| | | menuformRef={this.menuformRef} |
| | | permFuncField={this.props.permFuncField} |
| | | updatesetting={this.updateconfig} |
| | | /> |
| | | <SearchComponent |
| | | menu={{MenuID: this.state.config.uuid, MenuName: this.state.config.tabName}} |
| | | menu={{MenuID: config.uuid, MenuName: config.tabName}} |
| | | config={config} |
| | | pasteContent={this.state.pasteContent} |
| | | sysRoles={this.props.sysRoles} |
| | |
| | | menu={{MenuID: config.uuid, MenuName: config.tabName, MenuNo: config.tabNo}} |
| | | config={config} |
| | | tabs={this.state.tabviews} |
| | | menuformRef={this.menuformRef} |
| | | pasteContent={this.state.pasteContent} |
| | | usefulFields={this.props.permFuncField} |
| | | setSubConfig={this.setSubConfig} |
| | |
| | | menu={this.props.menu} |
| | | sysRoles={this.props.sysRoles} |
| | | pasteContent={this.state.pasteContent} |
| | | updatecolumn={this.updatecolumn} |
| | | updatecolumn={this.updateconfig} |
| | | /> |
| | | </Col> |
| | | ) |
| | |
| | | </Card> |
| | | </div> |
| | | </DndProvider> |
| | | {/* 设置全局配置及列表数据源 */} |
| | | <Modal |
| | | title={this.state.dict['model.edit']} |
| | | visible={this.state.settingVisible} |
| | | width={750} |
| | | maskClosable={false} |
| | | onCancel={() => { // 取消修改 |
| | | this.setState({ |
| | | settingVisible: false |
| | | }) |
| | | }} |
| | | footer={[ |
| | | <CreateInterface key="interface" dict={this.state.dict} ref="tableCreatInterface" trigger={this.tableCreatInterface}/>, |
| | | <CreateFunc key="create" dict={this.state.dict} ref="tableCreatFunc" trigger={this.tableCreatFunc}/>, |
| | | <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>, |
| | | <Button key="confirm" type="primary" loading={this.state.sqlVerifing} onClick={this.settingSave}>{this.state.dict['model.confirm']}</Button> |
| | | ]} |
| | | destroyOnClose |
| | | > |
| | | <SettingForm |
| | | dict={this.state.dict} |
| | | tabId={this.state.config.uuid} |
| | | inputSubmit={this.settingSave} |
| | | data={this.state.config.setting} |
| | | columns={this.state.config.columns} |
| | | usefulFields={this.props.permFuncField} |
| | | wrappedComponentRef={(inst) => this.settingRef = inst} |
| | | /> |
| | | </Modal> |
| | | <Modal |
| | | bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}} |
| | | closable={false} |