| | |
| | | import Utils from '@/utils/utils.js' |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import { getMainMenuForm } 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 SettingForm from './settingform' |
| | | import TabForm from '@/templates/zshare/tabform' |
| | | import MenuForm from '@/templates/zshare/menuform' |
| | | import TabDragElement from '@/templates/zshare/tabdragelement' |
| | | 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 CreateFunc from '@/templates/zshare/createfunc' |
| | | // import CreateInterface from '@/templates/zshare/createinterface' |
| | | 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 ComTableConfig extends Component { |
| | | static propTpyes = { |
| | |
| | | menuloading: false, // 菜单保存中 |
| | | menucloseloading: false, // 菜单关闭时,选择保存 |
| | | loading: false, // 加载中,页面spin |
| | | settingVisible: false, // 全局配置模态框 |
| | | closeVisible: false, // 关闭模态框 |
| | | tables: [], // 可用表名 |
| | | selectedTables: [], // 已选表名 |
| | | originMenu: null, // 原始菜单 |
| | | originActions: null, // 原始按钮信息,使用已有用户模板 |
| | | delActions: [], // 删除按钮列表 |
| | |
| | | let _config = '' |
| | | |
| | | if (!_LongParam) { |
| | | _config = JSON.parse(JSON.stringify(Source.baseConfig)) |
| | | _config = fromJS(Source.baseConfig).toJS() |
| | | if (!menu.isSubtable) { // 不是选择主子表时,隐藏标签页 |
| | | _config.tabs = [] |
| | | } |
| | |
| | | |
| | | if (item.OpenType === 'pop') { // 含有子配置项的按钮(表单) |
| | | _oriActions.push({ |
| | | prebtn: JSON.parse(JSON.stringify(item)), |
| | | prebtn: fromJS(item).toJS(), |
| | | curuuid: uuid, |
| | | Template: 'Modal' |
| | | }) |
| | | } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { // 含有子配置项的按钮(标签后当前页打开) |
| | | _oriActions.push({ |
| | | prebtn: JSON.parse(JSON.stringify(item)), |
| | | prebtn: fromJS(item).toJS(), |
| | | curuuid: uuid, |
| | | Template: item.tabTemplate |
| | | }) |
| | |
| | | activeKey: menu.activeKey || '0', |
| | | optionLibs: optionLibs, |
| | | originActions: _oriActions, |
| | | originMenu: JSON.parse(JSON.stringify(menu)), |
| | | selectedTables: _config.tables || [], |
| | | menuformlist: [ |
| | | { |
| | | type: 'select', |
| | | key: 'fstMenuId', |
| | | label: '一级菜单', |
| | | initVal: menu.fstMenuId, |
| | | required: true, |
| | | readonly: false, |
| | | options: menu.fstMenuList |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'parentId', |
| | | label: '二级菜单', |
| | | initVal: menu.ParentID, |
| | | required: true, |
| | | readonly: false, |
| | | options: menu.supMenuList |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'menuName', |
| | | label: this.state.dict['header.menu.menuName'], |
| | | initVal: menu.MenuName, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'menuNo', |
| | | label: this.state.dict['header.menu.menuNo'], |
| | | initVal: menu.MenuNo, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'opentype', |
| | | label: this.state.dict['header.menu.openType'], |
| | | initVal: menu.PageParam.OpenType, |
| | | required: true, |
| | | options: [{ |
| | | MenuID: 'newtab', |
| | | text: this.state.dict['header.form.tab'] |
| | | }, { |
| | | MenuID: 'newpage', |
| | | text: this.state.dict['header.form.newpage'] |
| | | }, { |
| | | MenuID: 'currenttab', |
| | | text: this.state.dict['header.form.currenttab'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'easyCode', |
| | | label: this.state.dict['header.form.easyCode'], |
| | | initVal: _config.easyCode, |
| | | required: false, |
| | | readonly: false |
| | | } |
| | | ] |
| | | originMenu: fromJS(menu).toJS(), |
| | | menuformlist: getMainMenuForm(menu, _config) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 加载完成后 |
| | | * 1、获取系统可使用表 |
| | | * 2、根据配置信息中已使用表获取相关字段信息 |
| | | * 3、获取所有标签页信息 |
| | | * @description 加载完成后, 获取所有标签页信息 |
| | | */ |
| | | componentDidMount () { |
| | | Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => { |
| | | if (res.status) { |
| | | this.setState({ |
| | | tabviews: res.UserTemp.map(temp => { |
| | | return { |
| | | uuid: temp.MenuID, |
| | | value: temp.MenuID, |
| | | text: temp.MenuName, |
| | | type: temp.Template, |
| | | MenuNo: temp.MenuNo |
| | | } |
| | | }) |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | this.reloadTab(false) |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * @description 加载或刷新标签信息 |
| | | */ |
| | | reloadTab = () => { |
| | | reloadTab = (type) => { |
| | | this.setState({ |
| | | loading: true, |
| | | loading: type, |
| | | tabviews: [] |
| | | }) |
| | | Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => { |
| | |
| | | } |
| | | }) |
| | | }) |
| | | notification.success({ |
| | | top: 92, |
| | | message: '刷新成功。', |
| | | duration: 2 |
| | | }) |
| | | |
| | | if (type) { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '刷新成功。', |
| | | duration: 2 |
| | | }) |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 创建表格存储过程 |
| | | */ |
| | | tableCreatFunc = () => { |
| | | const { menu } = this.props |
| | | 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, menu, _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 创建表格接口(读出) |
| | | */ |
| | | tableCreatInterface = () => { |
| | | const { menu } = this.props |
| | | 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: 'main', |
| | | MenuID: menu.MenuID, |
| | | menuName: res.menuName, |
| | | menuNo: res.menuNo |
| | | } |
| | | |
| | | this.refs.tableCreatInterface.triggerOutInterface(_menu, _config) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | deleteElement = (element) => { |
| | | const { config, thawButtons } = this.state |
| | | let _this = this |
| | |
| | | const { menu } = this.props |
| | | const { originMenu, delActions, thawButtons } = this.state |
| | | |
| | | let config = JSON.parse(JSON.stringify(this.state.config)) |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | this.menuformRef.handleConfirm().then(res => { |
| | | if (config.isAdd) { |
| | |
| | | func: 'sPC_Button_AddUpt', |
| | | Type: 40, // 添加菜单下的按钮type为40,按钮下的按钮type为60 |
| | | ParentID: menu.MenuID, |
| | | MenuNo: res.menuNo, |
| | | MenuNo: res.MenuNo, |
| | | Template: menu.PageParam.Template || '', |
| | | PageParam: '', |
| | | LongParam: '', |
| | |
| | | SndID: res.parentId, |
| | | ParentID: res.parentId, |
| | | MenuID: menu.MenuID, |
| | | MenuNo: res.menuNo, |
| | | MenuNo: res.MenuNo, |
| | | EasyCode: res.easyCode, |
| | | Template: menu.PageParam.Template || '', |
| | | MenuName: res.menuName, |
| | | MenuName: res.MenuName, |
| | | PageParam: JSON.stringify(_pageParam), |
| | | LongParam: _LongParam, |
| | | LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), |
| | |
| | | } |
| | | }).then(resp => { |
| | | if (resp === false) return |
| | | let localParam = JSON.parse(JSON.stringify(param)) |
| | | let localParam = fromJS(param).toJS() |
| | | |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | |
| | | ...originMenu, |
| | | LongParam: _config, |
| | | PageParam: _pageParam, |
| | | MenuName: res.menuName, |
| | | MenuNo: res.menuNo, |
| | | MenuName: res.MenuName, |
| | | MenuNo: res.MenuNo, |
| | | ParentID: res.parentId, |
| | | fstMenuId: res.fstMenuId, |
| | | supMenuList: _supMenuList |
| | |
| | | ...originMenu, |
| | | LongParam: _config, |
| | | PageParam: _pageParam, |
| | | MenuName: res.menuName, |
| | | MenuNo: res.menuNo, |
| | | MenuName: res.MenuName, |
| | | MenuNo: res.MenuNo, |
| | | ParentID: res.parentId, |
| | | fstMenuId: res.fstMenuId |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 页面配置信息模态框显示 |
| | | */ |
| | | changeSetting = () => { |
| | | this.setState({ |
| | | settingVisible: true |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 保存页面配置信息 |
| | | */ |
| | | settingSave = () => { |
| | | const { menu } = this.props |
| | | 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: menu.MenuID |
| | | } |
| | | |
| | | 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 && /\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 设置可配置按钮 |
| | | */ |
| | | setSubConfig = (item, type) => { |
| | |
| | | }) |
| | | } else { |
| | | this.menuformRef.handleConfirm().then(res => { |
| | | let _config = {...config, tables: this.state.selectedTables, easyCode: res.easyCode} |
| | | let _config = {...config, easyCode: res.easyCode} |
| | | let _pageParam = {...menu.PageParam, OpenType: res.opentype} |
| | | let _originMenu = { |
| | | ...originMenu, |
| | | LongParam: _config, |
| | | PageParam: _pageParam, |
| | | MenuName: res.menuName, |
| | | MenuNo: res.menuNo, |
| | | MenuName: res.MenuName, |
| | | MenuNo: res.MenuNo, |
| | | ParentID: res.parentId, |
| | | fstMenuId: res.fstMenuId |
| | | } |
| | |
| | | */ |
| | | addTabGroup = () => { |
| | | let _this = this |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | | let _config = fromJS(this.state.config).toJS() |
| | | |
| | | confirm({ |
| | | content: `确定新建标签组吗?`, |
| | |
| | | */ |
| | | delTabGroup = (groupId) => { |
| | | let _this = this |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | | let _config = fromJS(this.state.config).toJS() |
| | | |
| | | confirm({ |
| | | content: `确定删除标签组吗?`, |
| | |
| | | } |
| | | |
| | | handleGroup = (index, type) => { |
| | | let config = JSON.parse(JSON.stringify(this.state.config)) |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | if (type === 'up') { |
| | | config.tabgroups.splice(index, 0, config.tabgroups.splice(index - 1, 1)[0]) |
| | |
| | | /** |
| | | * @description 编辑功能完成更新,包括解冻按钮、粘贴、替换等 |
| | | */ |
| | | updateConfig = (res) => { |
| | | editConfig = (res) => { |
| | | if (res.type === 'thaw') { |
| | | this.setState({ |
| | | thawButtons: res.thawButtons, |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 更新显示列配置信息 |
| | | */ |
| | | updatecolumn = (config) => { |
| | | this.setState({ |
| | | config: config |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 更新图表组配置信息 |
| | | */ |
| | | updatechartgroup = (config, _chartview) => { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 批量添加,更新配置信息 |
| | | * @description 更新配置信息 |
| | | */ |
| | | updatefield = (config) => { |
| | | updateconfig = (config) => { |
| | | this.setState({ |
| | | config: config |
| | | }) |
| | |
| | | |
| | | return ( |
| | | <div className="common-table-board"> |
| | | {/* <div className="ant-modal-mask"></div> */} |
| | | <DndProvider backend={HTML5Backend}> |
| | | {/* 工具栏 */} |
| | | <div className="tools"> |
| | |
| | | config={config} |
| | | type="search" |
| | | tableFields={this.state.tableFields} |
| | | updatefield={this.updatefield} |
| | | updatefield={this.updateconfig} |
| | | /> |
| | | </Panel> |
| | | {/* 按钮添加 */} |
| | |
| | | config={config} |
| | | type="columns" |
| | | tableFields={this.state.tableFields} |
| | | updatefield={this.updatefield} |
| | | updatefield={this.updateconfig} |
| | | /> |
| | | </Panel> |
| | | {/* 添加标签 */} |
| | |
| | | <Card title={ |
| | | <div> |
| | | {this.state.dict['header.menu.page.configurable']} |
| | | <Icon type="redo" style={{marginLeft: '10px'}} title="刷新标签列表" onClick={this.reloadTab} /> |
| | | <Icon type="redo" style={{marginLeft: '10px'}} title="刷新标签列表" onClick={() => this.reloadTab(true)} /> |
| | | </div> |
| | | } bordered={false} extra={ |
| | | <div> |
| | | <EditComponent dict={this.state.dict} type="maintable" config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.updateConfig}/> |
| | | <EditComponent dict={this.state.dict} type="maintable" config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> |
| | | <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> |
| | | <Button type="primary" onClick={this.changeTemplate}>{this.state.dict['header.menu.template.change']}</Button> |
| | | <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['header.save']}</Button> |
| | | <Button onClick={this.cancelConfig}>{this.state.dict['header.return']}</Button> |
| | | </div> |
| | | } style={{ width: '100%' }}> |
| | | <Icon type="setting" onClick={this.changeSetting} /> |
| | | <SettingComponent |
| | | type="main" |
| | | config={config} |
| | | MenuID={this.props.menu.MenuID} |
| | | menuformRef={this.menuformRef} |
| | | permFuncField={this.props.permFuncField} |
| | | updatesetting={this.updateconfig} |
| | | /> |
| | | <SearchComponent |
| | | menu={{MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName}} |
| | | config={config} |
| | |
| | | /> |
| | | <ActionComponent |
| | | type="main" |
| | | menu={{MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName, MenuNo: this.props.menu.MenuNo}} |
| | | menu={{ MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName, MenuNo: this.props.menu.MenuNo }} |
| | | config={config} |
| | | tabs={this.state.tabviews} |
| | | menuformRef={this.menuformRef} |
| | | pasteContent={this.state.pasteContent} |
| | | usefulFields={this.props.permFuncField} |
| | | setSubConfig={(_btn) => this.setSubConfig(_btn, 'button')} |
| | |
| | | menu={this.props.menu} |
| | | sysRoles={this.props.sysRoles} |
| | | pasteContent={this.state.pasteContent} |
| | | updatecolumn={this.updatecolumn} |
| | | updatecolumn={this.updateconfig} |
| | | /> |
| | | {/* 标签组 */} |
| | | {config.tabgroups.map((groupId, index) => { |
| | |
| | | wrappedComponentRef={(inst) => this.tabsFormRef = inst} |
| | | /> |
| | | </Modal> |
| | | {/* 设置全局配置及列表数据源 */} |
| | | <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} |
| | | menu={this.props.menu} |
| | | inputSubmit={this.settingSave} |
| | | data={config.setting} |
| | | columns={config.columns} |
| | | usefulFields={this.props.permFuncField} |
| | | wrappedComponentRef={(inst) => this.settingRef = inst} |
| | | /> |
| | | </Modal> |
| | | {/* 返回时未保存提示 */} |
| | | <Modal |
| | | bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}} |
| | | closable={false} |