| | |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import { updateCommonTable } from '@/utils/utils-update.js' |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | |
| | |
| | | class ComTableConfig extends Component { |
| | | static propTpyes = { |
| | | menu: PropTypes.any, |
| | | optionLibs: PropTypes.any, |
| | | reloadmenu: PropTypes.func, |
| | | handleView: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | config: null, // 页面配置 |
| | | tableFields: [], // 表格显示列 |
| | | formlist: null, // 搜索条件、按钮、显示列表单字段 |
| | | menuloading: false, // 菜单保存中 |
| | | menucloseloading: false, // 菜单关闭时,选择保存 |
| | | loading: false, // 加载中,页面spin |
| | | closeVisible: false, // 关闭模态框 |
| | | tables: [], // 可用表名 |
| | | originMenu: null, // 原始菜单 |
| | | originActions: null, // 原始按钮信息,使用已有用户模板 |
| | | delActions: [], // 删除按钮列表 |
| | | copyActions: [], // 复制按钮组 |
| | | tabviews: [], // 所有标签页 |
| | | optionLibs: null, // 自定义下拉选项库 |
| | | thawButtons: [], // 已选择要解冻的按钮 |
| | | activeKey: '0', // 默认展开基本信息 |
| | | chartview: null, // 当前视图 |
| | | pasteContent: null, // 粘贴配置信息 |
| | | openEdition: '' // 编辑版本标记,防止多人操作 |
| | | } |
| | | |
| | |
| | | * 2、设置操作类型、原始菜单信息(每次保存后重置)、已使用表及基本信息表单 |
| | | */ |
| | | UNSAFE_componentWillMount () { |
| | | const { menu, optionLibs } = this.props |
| | | const { menu } = this.props |
| | | let _LongParam = menu.LongParam |
| | | let _config = '' |
| | | |
| | |
| | | _config.isAdd = true |
| | | } else { |
| | | _config = _LongParam |
| | | _config.search.forEach(item => { |
| | | if ( |
| | | (item.type === 'select' || item.type === 'multiselect' || item.type === 'link') && |
| | | item.resourceType === '0' && |
| | | item.options && item.options.length > 0 |
| | | ) { |
| | | optionLibs.set(menu.MenuID + item.uuid, { |
| | | uuid: menu.MenuID + item.uuid, |
| | | label: item.label, |
| | | parname: menu.MenuName, |
| | | type: 'search', |
| | | options: item.options |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 页面配置中保留菜单信息,只用于数据传递 |
| | |
| | | _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : '' |
| | | _config.easyCode = _config.easyCode || '' |
| | | |
| | | if (!_config.version || _config.version < '1.0') { |
| | | // 配置默认值,兼容 |
| | | _config.version = '1.0' |
| | | _config.Template = 'CommonTable' |
| | | |
| | | if (!_config.tabgroups) { |
| | | _config.tabgroups = [{ uuid: 'tabs', sublist: [] }] |
| | | } else if (typeof(_config.tabgroups[0]) === 'string') { |
| | | let _tabgroups = [] |
| | | _config.tabgroups.forEach(groupId => { |
| | | let _group = { |
| | | uuid: groupId, |
| | | sublist: fromJS(_config[groupId]).toJS() |
| | | } |
| | | |
| | | delete _config[groupId] |
| | | |
| | | _tabgroups.push(_group) |
| | | }) |
| | | |
| | | _config.tabgroups = _tabgroups |
| | | } |
| | | |
| | | // 兼容图表 |
| | | if (!_config.charts) { |
| | | _config.expand = false |
| | | _config.charts = [{ |
| | | uuid: Utils.getuuid(), |
| | | label: '', |
| | | title: '', |
| | | chartType: 'table', |
| | | icon: 'table', |
| | | Hide: 'false', |
| | | blacklist: [] |
| | | }] |
| | | } else { |
| | | _config.charts.forEach(card => { |
| | | if (card.chartType === 'card') { |
| | | card.details = card.details.map(_cell => { |
| | | if (!_cell.fontSize) { |
| | | _cell.fontSize = 14 |
| | | } |
| | | if (!_cell.width) { |
| | | _cell.width = 100 |
| | | } else if (_cell.width === 'helf') { |
| | | _cell.width = 50 |
| | | } else if (_cell.width === 'third') { |
| | | _cell.width = 33 |
| | | } |
| | | |
| | | if (_cell.bold === 'true') { |
| | | _cell.fontWeight = 'normal' |
| | | } |
| | | |
| | | if (!_cell.height) { |
| | | _cell.height = 1 |
| | | } |
| | | |
| | | return _cell |
| | | }) |
| | | |
| | | if (card.widthType === 'ratio' && card.avatar && card.avatar.widthType !== 'ratio') { |
| | | card.avatar.widthType = 'ratio' |
| | | card.avatar.width = 32 |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // // 兼容接口类型 |
| | | // _config.action = _config.action.map(item => { |
| | | // if (item.intertype === 'inner' && !item.innerFunc) { |
| | | // item.intertype = 'system' |
| | | // } |
| | | // return item |
| | | // }) |
| | | } |
| | | // 版本兼容 |
| | | _config = updateCommonTable(_config) |
| | | |
| | | let _oriActions = [] |
| | | if (_config.type === 'user') { |
| | |
| | | item.linkTab = '' |
| | | } |
| | | |
| | | if (item.OpenType === 'pop') { // 含有子配置项的按钮(表单) |
| | | if (item.OpenType === 'pop' || item.execMode === 'pop') { // 含有子配置项的按钮(表单) |
| | | _oriActions.push({ |
| | | prebtn: fromJS(item).toJS(), |
| | | curuuid: uuid, |
| | | Template: 'Modal' |
| | | }) |
| | | } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { // 含有子配置项的按钮(标签后当前页打开) |
| | | } else if (item.OpenType === 'tab' && item.tabTemplate === 'FormTab') { // 含有子配置项的按钮(标签页打开) |
| | | _oriActions.push({ |
| | | prebtn: fromJS(item).toJS(), |
| | | curuuid: uuid, |
| | | Template: item.tabTemplate |
| | | Template: 'FormTab' |
| | | }) |
| | | } |
| | | |
| | |
| | | config: _config, |
| | | openEdition: menu.open_edition || '', |
| | | activeKey: menu.activeKey || '0', |
| | | optionLibs: optionLibs, |
| | | originActions: _oriActions, |
| | | originMenu: fromJS(_config).toJS() |
| | | }) |
| | |
| | | }) |
| | | } |
| | | |
| | | getFuncNames = (data, funcNames, tableNames) => { |
| | | data.forEach(item => { |
| | | if (item.subfuncs) { |
| | | this.getFuncNames(item.subfuncs, funcNames, tableNames) |
| | | } else { |
| | | if (item.tableName) { |
| | | tableNames.push(item.tableName) |
| | | getFuncNames = (config) => { |
| | | let funcNames = [] |
| | | let tableNames = [] |
| | | |
| | | if (config.setting.tableName) { |
| | | tableNames.push(config.setting.tableName) |
| | | } |
| | | if (config.setting.innerFunc) { |
| | | funcNames.push({func: config.setting.innerFunc, label: config.MenuName || ''}) |
| | | } |
| | | if (config.setting.outerFunc) { |
| | | funcNames.push({func: config.setting.outerFunc, label: config.MenuName || ''}) |
| | | } |
| | | |
| | | config.action.forEach(item => { |
| | | let tablename = item.OpenType === 'excelIn' ? (item.sheet || '') : (item.sql || '') |
| | | |
| | | if (item.OpenType === 'excelOut' && item.intertype === 'system') { |
| | | tablename = config.setting.tableName || '' |
| | | } |
| | | |
| | | if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut', 'funcbutton'].includes(item.OpenType)) { |
| | | if (tablename) { |
| | | tableNames.push(tablename) |
| | | } |
| | | if (item.innerFunc) { |
| | | funcNames.push({func: item.innerFunc, label: item.label || ''}) |
| | | } |
| | | |
| | | if (item.callbackFunc) { |
| | | funcNames.push({func: item.callbackFunc, label: item.label || ''}) |
| | | } |
| | | } |
| | | }) |
| | | |
| | | tableNames = Array.from(new Set(tableNames)) |
| | | |
| | | return { |
| | | func: funcNames, |
| | |
| | | _config.enabled = false |
| | | } |
| | | |
| | | _config.funcs = [] // 页面及子页面存储过程集 |
| | | |
| | | _config.funcs.push({ |
| | | type: 'view', |
| | | subtype: 'view', |
| | | uuid: menu.MenuID, |
| | | intertype: _config.setting.interType || 'system', |
| | | interface: _config.setting.interface || '', |
| | | tableName: _config.setting.tableName || '', |
| | | innerFunc: _config.setting.innerFunc || '', |
| | | outerFunc: _config.setting.outerFunc || '' |
| | | }) |
| | | |
| | | _config.action.forEach(item => { |
| | | let tablename = item.OpenType === 'excelIn' ? (item.sheet || '') : (item.sql || '') |
| | | |
| | | if (item.OpenType === 'excelOut' && item.intertype === 'system') { |
| | | tablename = _config.setting.tableName || '' |
| | | } |
| | | |
| | | if (item.OpenType === 'tab' || item.OpenType === 'blank') { |
| | | _config.funcs.push({ |
| | | type: 'tab', |
| | | subtype: 'btn', |
| | | uuid: item.uuid, |
| | | label: item.label, |
| | | linkTab: item.uuid |
| | | }) |
| | | } else if (item.OpenType === 'popview') { |
| | | _config.funcs.push({ |
| | | type: 'tab', |
| | | subtype: 'btn', |
| | | uuid: item.uuid, |
| | | label: item.label, |
| | | linkTab: item.linkTab |
| | | }) |
| | | } else if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(item.OpenType)) { |
| | | _config.funcs.push({ |
| | | type: 'button', |
| | | subtype: 'btn', |
| | | uuid: item.uuid, |
| | | label: item.label, |
| | | tableName: tablename, |
| | | intertype: item.intertype, |
| | | interface: item.interface || '', |
| | | innerFunc: item.innerFunc || '', |
| | | outerFunc: item.outerFunc || '', |
| | | callbackFunc: item.callbackFunc || '' |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | _config.tabgroups.forEach(group => { |
| | | group.sublist.forEach(tab => { |
| | | _config.funcs.push({ |
| | | type: 'tab', |
| | | subtype: 'tab', |
| | | uuid: tab.uuid, |
| | | label: tab.label, |
| | | linkTab: tab.linkTab |
| | | }) |
| | | }) |
| | | }) |
| | | |
| | | if (this.state.closeVisible) { // 显示关闭对话框时,模态框中保存按钮,显示保存中状态 |
| | | this.setState({ |
| | | menucloseloading: true |
| | |
| | | }) |
| | | } |
| | | |
| | | new Promise(resolve => { |
| | | let deffers = [] |
| | | _config.funcs.forEach(item => { |
| | | if (item.type === 'tab') { |
| | | let deffer = new Promise(resolve => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: item.linkTab |
| | | }).then(result => { |
| | | if (result.status && result.LongParam) { |
| | | let _LongParam = '' |
| | | // 保存时删除配置类型,system 、user |
| | | delete _config.type |
| | | delete _config.isAdd |
| | | |
| | | let _LongParam = '' |
| | | |
| | | try { |
| | | _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '编译错误', |
| | | duration: 5 |
| | | }) |
| | | this.setState({ |
| | | menucloseloading: false, |
| | | menuloading: false |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _sort = 0 |
| | | let btntabs = [] |
| | | |
| | | let btnParam = { // 添加菜单按钮 |
| | | func: 'sPC_Button_AddUpt', |
| | | Type: 40, // 添加菜单下的按钮type为40,按钮下的按钮type为60 |
| | | ParentID: menu.MenuID, |
| | | MenuNo: _config.MenuNo, |
| | | Template: _config.Template || '', |
| | | PageParam: '', |
| | | LongParam: '', |
| | | LText: [] |
| | | } |
| | | |
| | | _config.action.forEach(item => { |
| | | _sort++ |
| | | if (item.OpenType === 'popview') { |
| | | btntabs.push({ |
| | | uuid: item.uuid, |
| | | linkTab: item.linkTab, |
| | | label: item.label, |
| | | sort: _sort |
| | | }) |
| | | } |
| | | |
| | | if (result.LongParam) { |
| | | try { |
| | | _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | _LongParam = '' |
| | | } |
| | | } |
| | | btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | }) |
| | | |
| | | btnParam.LText = btnParam.LText.join(' union all ') |
| | | btnParam.LText = Utils.formatOptions(btnParam.LText) |
| | | btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) |
| | | |
| | | if (_LongParam) { |
| | | item.menuNo = _LongParam.tabNo || '' |
| | | item.subfuncs = _LongParam.funcs || [] |
| | | } |
| | | } |
| | | resolve() |
| | | }) |
| | | }) |
| | | let tabParam = { // 添加菜单tab页 |
| | | func: 'sPC_sMenusTab_AddUpt', |
| | | MenuID: menu.MenuID |
| | | } |
| | | |
| | | deffers.push(deffer) |
| | | } |
| | | }) |
| | | let _LText = [] |
| | | |
| | | if (deffers.length === 0) { |
| | | resolve() |
| | | } else { |
| | | Promise.all(deffers).then(() => { |
| | | resolve() |
| | | }) |
| | | } |
| | | }).then(() => { |
| | | // 保存时删除配置类型,system 、user |
| | | delete _config.type |
| | | delete _config.isAdd |
| | | |
| | | let _LongParam = '' |
| | | |
| | | try { |
| | | _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '编译错误', |
| | | duration: 5 |
| | | }) |
| | | this.setState({ |
| | | menucloseloading: false, |
| | | menuloading: false |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _sort = 0 |
| | | let btntabs = [] |
| | | |
| | | let btnParam = { // 添加菜单按钮 |
| | | func: 'sPC_Button_AddUpt', |
| | | Type: 40, // 添加菜单下的按钮type为40,按钮下的按钮type为60 |
| | | ParentID: menu.MenuID, |
| | | MenuNo: _config.MenuNo, |
| | | Template: _config.Template || '', |
| | | PageParam: '', |
| | | LongParam: '', |
| | | LText: [] |
| | | } |
| | | |
| | | _config.action.forEach(item => { |
| | | btntabs.forEach(item => { |
| | | _LText.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${item.sort * 10}' as Sort`) |
| | | }) |
| | | _config.tabgroups.forEach(group => { |
| | | group.sublist.forEach(item => { |
| | | _sort++ |
| | | if (item.OpenType === 'popview') { |
| | | btntabs.push({ |
| | | uuid: item.uuid, |
| | | linkTab: item.linkTab, |
| | | label: item.label, |
| | | sort: _sort |
| | | _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) |
| | | }) |
| | | }) |
| | | |
| | | _LText = _LText.join(' union all ') |
| | | |
| | | // 清空菜单下关联的标签 |
| | | if (!_LText) { |
| | | _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort` |
| | | } |
| | | |
| | | tabParam.LText = Utils.formatOptions(_LText) |
| | | tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) |
| | | |
| | | let _vals = this.getFuncNames(_config) |
| | | |
| | | let param = { |
| | | func: 'sPC_TrdMenu_AddUpt', |
| | | FstID: _config.fstMenuId, |
| | | SndID: _config.ParentId, |
| | | ParentID: _config.ParentId, |
| | | MenuID: menu.MenuID, |
| | | MenuNo: _config.MenuNo, |
| | | EasyCode: _config.easyCode || '', |
| | | Template: _config.Template || '', |
| | | MenuName: _config.MenuName, |
| | | PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}), |
| | | LongParam: _LongParam, |
| | | LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), |
| | | LTexttb: _vals.table.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`) |
| | | } |
| | | |
| | | if (menu.menuSort) { // 菜单新建时设置排序 |
| | | param.Sort = menu.menuSort |
| | | } |
| | | |
| | | param.LText = param.LText.join(' union all ') |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.LTexttb = param.LTexttb.join(' union all ') |
| | | param.LTexttb = Utils.formatOptions(param.LTexttb) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | if (openEdition) { // 版本管理 |
| | | param.open_edition = openEdition |
| | | } |
| | | |
| | | // 有按钮或标签删除时,先进行删除操作 |
| | | // 删除成功后,保存页面配置 |
| | | new Promise(resolve => { |
| | | if (delActions.length > 0) { |
| | | let deffers = delActions.map(item => { |
| | | let _param = { |
| | | func: 'sPC_MainMenu_Del', |
| | | MenuID: item.card ? item.card.uuid : item.uuid |
| | | } |
| | | |
| | | if (item.type === 'action') { |
| | | let _ParentParam = null |
| | | |
| | | try { |
| | | _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) |
| | | } catch (e) { |
| | | console.warn('Stringify Failure') |
| | | _ParentParam = null |
| | | } |
| | | |
| | | if (_ParentParam) { // 删除按钮时,保存按钮配置信息,用于恢复按钮 |
| | | _param.ParentParam = _ParentParam |
| | | } |
| | | } |
| | | |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig(_param).then(response => { |
| | | resolve(response) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | }) |
| | | |
| | | btnParam.LText = btnParam.LText.join(' union all ') |
| | | btnParam.LText = Utils.formatOptions(btnParam.LText) |
| | | btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) |
| | | |
| | | let tabParam = { // 添加菜单tab页 |
| | | func: 'sPC_sMenusTab_AddUpt', |
| | | MenuID: menu.MenuID |
| | | } |
| | | |
| | | let _LText = [] |
| | | |
| | | btntabs.forEach(item => { |
| | | _LText.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${item.sort * 10}' as Sort`) |
| | | }) |
| | | _config.tabgroups.forEach(group => { |
| | | group.sublist.forEach(item => { |
| | | _sort++ |
| | | _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) |
| | | }) |
| | | }) |
| | | |
| | | _LText = _LText.join(' union all ') |
| | | |
| | | // 清空菜单下关联的标签 |
| | | if (!_LText) { |
| | | _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort` |
| | | } |
| | | |
| | | tabParam.LText = Utils.formatOptions(_LText) |
| | | tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) |
| | | |
| | | let _vals = this.getFuncNames(_config.funcs, [], []) |
| | | let _tables = Array.from(new Set(_vals.table)) |
| | | |
| | | let param = { |
| | | func: 'sPC_TrdMenu_AddUpt', |
| | | FstID: _config.fstMenuId, |
| | | SndID: _config.ParentId, |
| | | ParentID: _config.ParentId, |
| | | MenuID: menu.MenuID, |
| | | MenuNo: _config.MenuNo, |
| | | EasyCode: _config.easyCode || '', |
| | | Template: _config.Template || '', |
| | | MenuName: _config.MenuName, |
| | | PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}), |
| | | LongParam: _LongParam, |
| | | LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), |
| | | LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`) |
| | | } |
| | | |
| | | if (menu.menuSort) { // 菜单新建时设置排序 |
| | | param.Sort = menu.menuSort |
| | | } |
| | | |
| | | param.LText = param.LText.join(' union all ') |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.LTexttb = param.LTexttb.join(' union all ') |
| | | param.LTexttb = Utils.formatOptions(param.LTexttb) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | if (openEdition) { // 版本管理 |
| | | param.open_edition = openEdition |
| | | } |
| | | |
| | | // 有按钮或标签删除时,先进行删除操作 |
| | | // 删除成功后,保存页面配置 |
| | | new Promise(resolve => { |
| | | if (delActions.length > 0) { |
| | | let deffers = delActions.map(item => { |
| | | let _param = { |
| | | func: 'sPC_MainMenu_Del', |
| | | MenuID: item.card ? item.card.uuid : item.uuid |
| | | } |
| | | |
| | | if (item.type === 'action') { |
| | | let _ParentParam = null |
| | | |
| | | try { |
| | | _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card))) |
| | | } catch (e) { |
| | | console.warn('Stringify Failure') |
| | | _ParentParam = null |
| | | } |
| | | |
| | | if (_ParentParam) { // 删除按钮时,保存按钮配置信息,用于恢复按钮 |
| | | _param.ParentParam = _ParentParam |
| | | } |
| | | } |
| | | |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig(_param).then(response => { |
| | | resolve(response) |
| | | }) |
| | | }) |
| | | }) |
| | | Promise.all(deffers).then(result => { |
| | | let error = null |
| | | result.forEach(response => { |
| | | if (!response.status) { |
| | | error = response |
| | | } |
| | | }) |
| | | |
| | | if (error) { |
| | | this.setState({ |
| | | menuloading: false, |
| | | menucloseloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error.message, |
| | | duration: 5 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | this.setState({ |
| | | delActions: [] |
| | | }) |
| | | resolve(true) |
| | | Promise.all(deffers).then(result => { |
| | | let error = null |
| | | result.forEach(response => { |
| | | if (!response.status) { |
| | | error = response |
| | | } |
| | | }) |
| | | } else if (delActions.length === 0) { |
| | | resolve(true) |
| | | } |
| | | }).then(resp => { |
| | | if (resp === false) return |
| | | |
| | | if (thawButtons.length > 0) { |
| | | let defers = thawButtons.map(item => { |
| | | return new Promise((resolve) => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_MainMenu_ReDel', |
| | | MenuID: item |
| | | }).then(res => { |
| | | if (res.status) { |
| | | resolve('') |
| | | } else { |
| | | resolve(res.message) |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | |
| | | return Promise.all(defers) |
| | | } else { |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | if (res === true || res === false) return res |
| | | |
| | | let msg = res.filter(Boolean)[0] |
| | | if (msg) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: msg, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else { |
| | | this.setState({ |
| | | thawButtons: [] |
| | | }) |
| | | return true |
| | | } |
| | | }).then(resp => { |
| | | if (resp === false) return |
| | | let localParam = fromJS(param).toJS() |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | config: _config, |
| | | openEdition: response.open_edition || '', |
| | | originMenu: fromJS(_config).toJS() |
| | | }) |
| | | |
| | | this.props.reloadmenu() |
| | | |
| | | this.submitAction(btnParam, tabParam) |
| | | |
| | | localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' |
| | | delete localParam.LongParam |
| | | delete localParam.PageParam |
| | | delete localParam.Template |
| | | delete localParam.Sort |
| | | delete localParam.EasyCode |
| | | delete localParam.open_edition |
| | | |
| | | Api.getLocalConfig(localParam) |
| | | } else { |
| | | if (error) { |
| | | this.setState({ |
| | | menuloading: false, |
| | | menucloseloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | message: error.message, |
| | | duration: 5 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | this.setState({ |
| | | delActions: [] |
| | | }) |
| | | resolve(true) |
| | | } |
| | | }) |
| | | } else if (delActions.length === 0) { |
| | | resolve(true) |
| | | } |
| | | }).then(resp => { |
| | | if (resp === false) return |
| | | |
| | | if (thawButtons.length > 0) { |
| | | let defers = thawButtons.map(item => { |
| | | return new Promise((resolve) => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_MainMenu_ReDel', |
| | | MenuID: item |
| | | }).then(res => { |
| | | if (res.status) { |
| | | resolve('') |
| | | } else { |
| | | resolve(res.message) |
| | | } |
| | | }) |
| | | }) |
| | | }) |
| | | |
| | | return Promise.all(defers) |
| | | } else { |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | if (res === true || res === false) return res |
| | | |
| | | let msg = res.filter(Boolean)[0] |
| | | if (msg) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: msg, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else { |
| | | this.setState({ |
| | | thawButtons: [] |
| | | }) |
| | | return true |
| | | } |
| | | }).then(resp => { |
| | | if (resp === false) return |
| | | let localParam = fromJS(param).toJS() |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | config: _config, |
| | | openEdition: response.open_edition || '', |
| | | originMenu: fromJS(_config).toJS() |
| | | }) |
| | | |
| | | localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' |
| | | delete localParam.LongParam |
| | | delete localParam.PageParam |
| | | delete localParam.Template |
| | | delete localParam.Sort |
| | | delete localParam.EasyCode |
| | | delete localParam.open_edition |
| | | |
| | | this.submitAction(btnParam, tabParam, localParam) |
| | | } else { |
| | | this.setState({ |
| | | menuloading: false, |
| | | menucloseloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | |
| | | /** |
| | | * @description 保存或修改菜单按钮集 |
| | | */ |
| | | submitAction = (btnParam, tabParam) => { |
| | | submitAction = (btnParam, tabParam, localParam) => { |
| | | const { config } = this.state |
| | | |
| | | new Promise(resolve => { |
| | |
| | | deffers.push(defer) |
| | | } |
| | | |
| | | if (deffers.length === 0) { |
| | | resolve(true) |
| | | } else { |
| | | Promise.all(deffers).then(result => { |
| | | let error = false |
| | | result.forEach(res => { |
| | | if (!res.status) { |
| | | error = res |
| | | } |
| | | }) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error.message, |
| | | duration: 5 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | resolve(true) |
| | | Promise.all(deffers).then(result => { |
| | | let error = false |
| | | result.forEach(res => { |
| | | if (!res.status) { |
| | | error = res |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error.message, |
| | | duration: 5 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | resolve(true) |
| | | } |
| | | }) |
| | | }).then(response => { |
| | | if (response === false) return response |
| | | |
| | |
| | | let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 查看初始化按钮是否存在 |
| | | if (!curBtn) return |
| | | if (curBtn.OpenType !== item.prebtn.OpenType) return |
| | | if (curBtn.OpenType === 'tab' && curBtn.tabTemplate !== 'FormTab') return |
| | | if (curBtn.OpenType === 'funcbutton' && curBtn.execMode !== 'pop') return |
| | | |
| | | oriActions.push({ |
| | | prebtn: item.prebtn, |
| | |
| | | menucloseloading: false |
| | | }) |
| | | } |
| | | this.props.reloadmenu() |
| | | Api.getLocalConfig(localParam) |
| | | } else { |
| | | this.setState({ |
| | | menuloading: false, |
| | |
| | | */ |
| | | setSubConfig = (item, type) => { |
| | | const { menu } = this.props |
| | | const { config, originMenu, optionLibs, activeKey, openEdition } = this.state |
| | | const { config, originMenu, activeKey, openEdition } = this.state |
| | | |
| | | if (config.isAdd) { // 新建菜单,提示菜单尚未保存 |
| | | notification.warning({ |
| | |
| | | duration: 5 |
| | | }) |
| | | } else { |
| | | // 基本信息验证 |
| | | if (!config.fstMenuId || !config.ParentId || !config.MenuName || !config.MenuNo) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['model.menu.basemsg'], |
| | | duration: 5 |
| | | }) |
| | | this.setState({activeKey: '0'}) |
| | | return |
| | | } |
| | | if (!is(fromJS(originMenu), fromJS(config))) { // 菜单信息变化时,提示保存 |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | return |
| | | } |
| | | |
| | | let submenu = menu.fstMenuList.filter(item => item.MenuID === config.fstMenuId)[0] |
| | | let submenu = menu.fstMenuList.filter(_menu => _menu.MenuID === config.fstMenuId)[0] |
| | | |
| | | let _Menu = { |
| | | ...menu, |
| | |
| | | MenuNo: config.MenuNo, |
| | | ParentId: config.ParentId, |
| | | fstMenuId: config.fstMenuId, |
| | | supMenuList: submenu ? submenu.options : [] |
| | | supMenuList: submenu ? submenu.children : [] |
| | | } |
| | | |
| | | // 菜单信息验证通过后,跳转子配置页面 |
| | |
| | | let isbutton = true |
| | | let _btnTab = null |
| | | |
| | | if (type === 'button' && item.OpenType === 'pop') { |
| | | _view = 'Modal' // 表单页面 |
| | | } else if (type === 'button' && (item.OpenType === 'tab' || item.OpenType === 'blank')) { |
| | | _view = item.tabTemplate // 新标签页模板 |
| | | if (type === 'button' && (item.OpenType === 'pop' || item.execMode === 'pop')) { |
| | | _view = 'Modal' // 表单页面 |
| | | } else if (type === 'button' && item.OpenType === 'tab') { |
| | | _view = 'FormTab' // 表单标签页模板 |
| | | _btnTab = item |
| | | } else if (type === 'button' && item.OpenType === 'popview') { |
| | | _view = item.tabType // 新弹窗标签模板 |
| | | _view = 'SubTable' // 新弹窗标签模板 tabType 属性已去除 |
| | | uuid = item.linkTab |
| | | isbutton = false |
| | | } else if (type === 'tab') { |
| | | _view = item.type // 标签模板 |
| | | _view = 'SubTable' // 标签模板 |
| | | uuid = item.linkTab |
| | | isbutton = false |
| | | } |
| | |
| | | _Menu.open_edition = openEdition // 更新版本号 |
| | | |
| | | let param = { |
| | | optionLibs: optionLibs, |
| | | editMenu: _Menu, |
| | | editTab: !isbutton ? item : '', |
| | | tabConfig: null, |
| | |
| | | } |
| | | }) |
| | | |
| | | config.action && config.action.forEach((btn) => { |
| | | if (['prompt', 'exec', 'pop'].includes(btn.OpenType) && btn.Ot === 'required' && btn.verify && btn.verify.scripts && btn.verify.scripts.length > 0) { |
| | | let hascheck = false |
| | | btn.verify.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | |
| | | if (/\$check@|@check\$/ig.test(item.sql)) { |
| | | hascheck = true |
| | | } |
| | | }) |
| | | if (hascheck) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: `可选择多行的按钮《${btn.label}》中 $check@ 或 @check$ 将不会生效!`, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | | if (btn.intertype === 'custom' && btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: `按钮《${btn.label}》未设置回调脚本, 将不会生效!`, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | if (((config.setting.interType === 'inner' && !config.setting.innerFunc) || config.setting.interType === 'system') && config.setting.default !== 'false' && !config.setting.dataresource) { |
| | | return '菜单尚未设置数据源,不可启用!' |
| | | if ((config.setting.interType === 'system' || config.setting.requestMode === 'system') && config.setting.default === 'false' && config.setting.scripts && config.setting.scripts.filter(item => item.status !== 'false').length === 0) { |
| | | return '数据源中不执行默认sql,且未添加自定义脚本,不可启用!' |
| | | } else if (config.setting.interType === 'custom' && config.setting.procMode !== 'inner' && config.setting.preScripts && config.setting.preScripts.filter(item => item.status !== 'false').length === 0) { |
| | | return '数据源未设置前置脚本,不可启用!' |
| | | } else if (config.setting.interType === 'custom' && config.setting.callbackType === 'script' && config.setting.cbScripts && config.setting.cbScripts.filter(item => item.status !== 'false').length === 0) { |
| | | return '数据源未设置回调脚本,不可启用!' |
| | | } else if (!config.setting.primaryKey) { |
| | | return '菜单尚未设置主键,不可启用!' |
| | | } else if (config.columns.length === 0) { |
| | |
| | | config: res.config |
| | | }) |
| | | } else if (res.type === 'paste') { |
| | | this.setState({ |
| | | pasteContent: res.content |
| | | }, () => { |
| | | this.setState({ |
| | | pasteContent: null |
| | | }) |
| | | }) |
| | | this.setState({config: res.config}) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 更新搜索条件配置信息 |
| | | */ |
| | | updatesearch = (config, options) => { |
| | | const { optionLibs } = this.state |
| | | |
| | | updatesearch = (config) => { |
| | | this.setState({ |
| | | config: config, |
| | | optionLibs: options || optionLibs |
| | | config: config |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 更新常用表信息,快捷添加后更新配置信息 |
| | | */ |
| | | updatetable = (config, fields) => { |
| | | const { tableFields } = this.state |
| | | |
| | | this.setState({ |
| | | config: config, |
| | | tableFields: fields ? fields : tableFields |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 更新标签配置信息 |
| | | */ |
| | | updatetabs = (config) => { |
| | | |
| | | this.setState({ |
| | | config: config |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 更新配置信息 |
| | | */ |
| | | updateconfig = (config) => { |
| | |
| | | const { menu } = this.props |
| | | const { activeKey, config, chartview } = this.state |
| | | |
| | | const confActions = config.action.filter(_action => !_action.origin && ['pop', 'popview', 'blank', 'tab'].includes(_action.OpenType)) |
| | | const confActions = config.action.filter(_action => !_action.origin && (['pop', 'popview'].includes(_action.OpenType) || (_action.OpenType === 'tab' && _action.tabTemplate === 'FormTab') || (_action.OpenType === 'funcbutton' && _action.execMode === 'pop'))) |
| | | |
| | | let configTabs = [] |
| | | config.tabgroups.forEach(group => { |
| | |
| | | <TableComponent |
| | | config={config} |
| | | containerId="main-basedata" |
| | | updatetable={this.updatetable} |
| | | updatetable={this.updateconfig} |
| | | /> |
| | | </Panel> |
| | | {/* 搜索条件添加 */} |
| | |
| | | <FieldsComponent |
| | | config={config} |
| | | type="search" |
| | | tableFields={this.state.tableFields} |
| | | updatefield={this.updateconfig} |
| | | /> |
| | | </Panel> |
| | |
| | | <FieldsComponent |
| | | config={config} |
| | | type="columns" |
| | | tableFields={this.state.tableFields} |
| | | updatefield={this.updateconfig} |
| | | /> |
| | | </Panel> |
| | |
| | | </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.editConfig}/> |
| | | <EditComponent dict={this.state.dict} options={['search', 'action', 'columns']} config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> |
| | | <Switch className="big" checkedChildren={this.state.dict['model.enable']} unCheckedChildren={this.state.dict['model.disable']} checked={this.state.config.enabled} onChange={this.onEnabledChange} /> |
| | | <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button> |
| | | <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> |
| | |
| | | <SettingComponent |
| | | config={config} |
| | | MenuID={this.props.menu.MenuID} |
| | | permFuncField={this.props.permFuncField} |
| | | updatesetting={this.updateconfig} |
| | | /> |
| | | <SearchComponent |
| | | menu={{MenuID: this.props.menu.MenuID, MenuName: config.MenuName}} |
| | | config={config} |
| | | pasteContent={this.state.pasteContent} |
| | | sysRoles={this.props.sysRoles} |
| | | optionLibs={this.state.optionLibs} |
| | | updatesearch={this.updatesearch} |
| | | /> |
| | | <div className="chart-view" style={{position: 'relative'}}> |
| | | {/* 视图组 权限 会员等级20+ */} |
| | | {this.props.memberLevel >= 20 ? <ChartGroupComponent |
| | | config={config} |
| | | sysRoles={this.props.sysRoles} |
| | | updatechartgroup={this.updatechartgroup} |
| | | /> : null} |
| | | {config.charts.map(item => { |
| | |
| | | menu={{ MenuID: this.props.menu.MenuID, MenuName: config.MenuName, MenuNo: config.MenuNo, fstMenuList: this.props.menu.fstMenuList }} |
| | | config={config} |
| | | tabs={this.state.tabviews} |
| | | pasteContent={this.state.pasteContent} |
| | | usefulFields={this.props.permFuncField} |
| | | setSubConfig={(_btn) => this.setSubConfig(_btn, 'button')} |
| | | updateaction={this.updateaction} |
| | | /> |
| | | <ColumnComponent |
| | | config={config} |
| | | menu={this.props.menu} |
| | | sysRoles={this.props.sysRoles} |
| | | pasteContent={this.state.pasteContent} |
| | | updatecolumn={this.updateconfig} |
| | | /> |
| | | </Col> |
| | |
| | | config={config} |
| | | tabs={this.state.tabviews} |
| | | setSubConfig={(item) => this.setSubConfig(item, 'tab')} |
| | | updatetabs={this.updatetabs} |
| | | updatetabs={this.updateconfig} |
| | | /> |
| | | </Card> |
| | | </div> |
| | |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | sysRoles: state.sysRoles, |
| | | permFuncField: state.permFuncField, |
| | | memberLevel: state.memberLevel |
| | | } |
| | | } |