| | |
| | | import TabDragElement from '@/templates/tableshare/tabdragelement' |
| | | import TransferForm from '@/components/transferform' |
| | | import SourceElement from '@/templates/tableshare/dragelement/source' |
| | | import CreateFunc from '@/templates/tableshare/createfunc' |
| | | import Source from './source' |
| | | import './index.scss' |
| | | |
| | |
| | | originActions: null, // 原始按钮信息,使用已有用户模板 |
| | | delActions: [], // 删除按钮列表 |
| | | copyActions: [], // 复制按钮组 |
| | | funcLoading: false, // 存储过程创建中 |
| | | showColumnName: false, // 显示列字段名控制 |
| | | tabviews: [], // 所有标签页 |
| | | profileVisible: false, // 验证信息模态框 |
| | |
| | | let btn = res // 按钮信息 |
| | | let newLText = '' // 创建存储过程sql |
| | | let DelText = '' // 删除存储过程sql |
| | | let isExit = false // 存储过程是否存在 |
| | | let sysTVPText = '' // 已有的存储过程语句(云端) |
| | | let localTVPText = '' // 已有的存储过程语句(本地) |
| | | |
| | | // 创建存储过程,必须填写内部函数名 |
| | | if (!btn.innerFunc) { |
| | |
| | | }) |
| | | return |
| | | } |
| | | |
| | | // 创建中 |
| | | this.setState({ |
| | | funcLoading: true |
| | | }) |
| | | |
| | | new Promise(resolve => { |
| | | // 弹窗(表单)类按钮,先获取按钮配置信息,如果尚未配置按钮则会报错并终止。 |
| | |
| | | DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) |
| | | resolve(true) |
| | | } else { |
| | | resolve(false) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '弹窗(表单)按钮,请先配置表单信息!', |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } |
| | | }) |
| | | } else if (btn.OpenType === 'excelIn') { |
| | |
| | | resolve(true) |
| | | } |
| | | }).then(res => { |
| | | // 获取云端及本地,是否已存在该存储过程的信息 |
| | | if (res === false) return res |
| | | if (!res) return |
| | | |
| | | let sysDefer = new Promise(resolve => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_TVP', // 云端获取存储结果 |
| | | TVPName: btn.innerFunc |
| | | }).then(result => { |
| | | resolve(result) |
| | | }) |
| | | }) |
| | | this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => { |
| | | if (result !== 'success') return |
| | | |
| | | let localDefer = new Promise(resolve => { |
| | | let _param = { // 获取本地存储过程信息 |
| | | func: 's_get_userproc', |
| | | LText: btn.innerFunc |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | Api.getLocalConfig(_param).then(result => { |
| | | resolve(result) |
| | | }) |
| | | }) |
| | | |
| | | return Promise.all([sysDefer, localDefer]) |
| | | }).then(res => { |
| | | // 云端结果与新语句不同时,更新云端信息 |
| | | if (res === false) return res |
| | | |
| | | let isError = false |
| | | |
| | | res.forEach((result, index) => { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | isError = true |
| | | } else if (index === 0) { |
| | | sysTVPText = result.TVPText |
| | | } else { |
| | | if (result.Ltext) { // 本地存储过程是否存在 |
| | | isExit = true |
| | | let _action = config.action.map(item => { |
| | | if (item.uuid === btn.uuid) { |
| | | return btn |
| | | } else { |
| | | return item |
| | | } |
| | | localTVPText = Utils.formatOptions(result.Ltext) |
| | | } |
| | | }) |
| | | |
| | | if (isError) return false |
| | | |
| | | if ((newLText === localTVPText) && (newLText === sysTVPText)) { |
| | | return 'drop' |
| | | } else if (!localTVPText || (localTVPText === sysTVPText)) { |
| | | // 本地存储过程不存在,将新的存储过程更新至云端 |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: btn.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }) |
| | | } else { |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig({ // 添加现有的本地存储过程至云端 |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: btn.innerFunc, |
| | | TVPText: localTVPText, |
| | | TypeName: 'P' |
| | | }).then(result => { |
| | | if (result.status) { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端 |
| | | TVPName: btn.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }).then(response => { |
| | | resolve(response) |
| | | }) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | // 云端信息更新后,判断是删除或是直接新建存储过程 |
| | | if (res === false || res === 'drop') return res |
| | | _action = _action.filter(item => !item.origin) |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else if (isExit) { |
| | | return 'drop' |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 删除存储过程 |
| | | if (res === false || res === 'create') return res |
| | | // 判断是否存在操作列 |
| | | let _hasGridbtn = _action.filter(act => act.position === 'grid').length > 0 |
| | | let _gridBtn = config.gridBtn |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: DelText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 根据上述操作结果,判断是否新建存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 新建存储过程 |
| | | if (res === false) return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: newLText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 处理新建结果 |
| | | if (res === false) return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '创建成功', |
| | | duration: 2 |
| | | }) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | // 新建成功后,更新页面按钮信息 |
| | | if (res === false) { |
| | | this.setState({ |
| | | funcLoading: false |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _action = config.action.map(item => { |
| | | if (item.uuid === btn.uuid) { |
| | | return btn |
| | | if (_gridBtn) { |
| | | _gridBtn.display = _hasGridbtn |
| | | } else { |
| | | return item |
| | | _gridBtn = { |
| | | display: _hasGridbtn, |
| | | Align: 'center', |
| | | IsSort: 'false', |
| | | uuid: Utils.getuuid(), |
| | | label: this.state.dict['header.form.column.action'], |
| | | type: 'action', |
| | | style: 'button', |
| | | show: 'horizontal', |
| | | Width: 120 |
| | | } |
| | | } |
| | | }) |
| | | _action = _action.filter(item => !item.origin) |
| | | |
| | | // 判断是否存在操作列 |
| | | let _hasGridbtn = _action.filter(act => act.position === 'grid').length > 0 |
| | | let _gridBtn = config.gridBtn |
| | | |
| | | if (_gridBtn) { |
| | | _gridBtn.display = _hasGridbtn |
| | | } else { |
| | | _gridBtn = { |
| | | display: _hasGridbtn, |
| | | Align: 'center', |
| | | IsSort: 'false', |
| | | uuid: Utils.getuuid(), |
| | | label: this.state.dict['header.form.column.action'], |
| | | type: 'action', |
| | | style: 'button', |
| | | show: 'horizontal', |
| | | Width: 120 |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | config: {...config, action: _action, gridBtn: _gridBtn}, |
| | | funcLoading: false |
| | | this.setState({ |
| | | config: {...config, action: _action, gridBtn: _gridBtn} |
| | | }) |
| | | }) |
| | | }) |
| | | }) |
| | |
| | | Api.getLocalConfig(param) |
| | | } |
| | | |
| | | this.setState({ |
| | | funcLoading: true |
| | | }) |
| | | |
| | | let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, config)) // 创建存储过程sql |
| | | let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 删除存储过程sql |
| | | let isExit = false // 存储过程是否存在 |
| | | |
| | | new Promise(resolve => { |
| | | let sysDefer = new Promise(resolve => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_TVP', // 云端获取存储结果 |
| | | TVPName: setting.innerFunc |
| | | }).then(result => { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | let localDefer = new Promise(resolve => { |
| | | let _param = { // 获取本地存储过程信息 |
| | | func: 's_get_userproc', |
| | | LText: setting.innerFunc |
| | | } |
| | | _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) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | Promise.all([sysDefer, localDefer]).then(result => { |
| | | resolve(result) |
| | | }) |
| | | }).then(res => { |
| | | // 获取云端及本地,是否已存在该存储过程的信息 |
| | | if (res === false) return res |
| | | if (res[0] === false || res[1] === false) return false |
| | | |
| | | let cloudfunc = '' |
| | | let localfunc = '' |
| | | res.forEach((item, index) => { |
| | | if (index === 0 && item && item.TVPText) { |
| | | cloudfunc = item.TVPText |
| | | } else if (index === 1 && item && item.Ltext) { |
| | | isExit = true |
| | | localfunc = Utils.formatOptions(item.Ltext) |
| | | } |
| | | }) |
| | | |
| | | if ((newLText === localfunc) && (newLText === cloudfunc)) { |
| | | return 'drop' |
| | | } else if (!localfunc || (cloudfunc === localfunc)) { |
| | | // 本地存储过程不存在,或云端和本地存储过程一致时,将新的存储过程更新至云端 |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: setting.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }) |
| | | } else { |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig({ // 添加现有的本地存储过程至云端 |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: setting.innerFunc, |
| | | TVPText: localfunc, |
| | | TypeName: 'P' |
| | | }).then(result => { |
| | | if (result.status) { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端 |
| | | TVPName: setting.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }).then(response => { |
| | | resolve(response) |
| | | }) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | // 云端信息更新后,判断是删除或是直接新建存储过程 |
| | | if (res === false || res === 'drop') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else if (isExit) { |
| | | return 'drop' |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 删除存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: DelText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 根据上述操作结果,判断是否新建存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 新建存储过程 |
| | | if (res === false) return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: newLText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 处理新建结果 |
| | | if (res === false) return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '创建成功', |
| | | duration: 2 |
| | | }) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | // 新建成功后,更新页面按钮信息 |
| | | if (res === false) { |
| | | this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { |
| | | if (result === 'success') { |
| | | this.setState({ |
| | | funcLoading: false |
| | | config: {...config, setting: setting} |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | config: {...config, setting: setting} |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | |
| | | maskClosable={false} |
| | | onCancel={this.editModalCancel} |
| | | footer={[ |
| | | modaltype === 'actionEdit' ? <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null, |
| | | modaltype === 'actionEdit' ? <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, |
| | | <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>, |
| | | <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> |
| | | ]} |
| | |
| | | visible={this.state.settingVisible} |
| | | width={700} |
| | | maskClosable={false} |
| | | // onOk={this.settingSave} |
| | | onCancel={() => { // 取消修改 |
| | | this.setState({ |
| | | settingVisible: false |
| | | }) |
| | | }} |
| | | footer={[ |
| | | <Button key="delete" className="mk-btn mk-purple" onClick={this.tableCreatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button>, |
| | | <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" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> |
| | | ]} |
| | |
| | | import MenuForm from '@/templates/tableshare/menuform' |
| | | import TabDragElement from '@/templates/tableshare/tabdragelement' |
| | | import SourceElement from '@/templates/tableshare/dragelement/source' |
| | | import CreateFunc from '@/templates/tableshare/createfunc' |
| | | import Source from './source' |
| | | import './index.scss' |
| | | |
| | |
| | | selectedTables: [], // 已选表名 |
| | | originMenu: null, // 原始菜单 |
| | | delActions: [], // 删除按钮列表 |
| | | funcLoading: false, // 存储过程创建中 |
| | | tabviews: [], // 所有标签页 |
| | | profileVisible: false, // 验证信息模态框 |
| | | editgroup: null, // 当前编辑组 |
| | |
| | | const { menu } = this.props |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | | |
| | | this.formRef.handleConfirm().then(res => { |
| | | let btn = res.values // 按钮信息 |
| | | this.actionFormRef.handleConfirm().then(res => { |
| | | let btn = res // 按钮信息 |
| | | let newLText = '' // 创建存储过程sql |
| | | let DelText = '' // 删除存储过程sql |
| | | let isExit = false // 存储过程是否存在 |
| | | let sysTVPText = '' // 已有的存储过程语句(云端) |
| | | let localTVPText = '' // 已有的存储过程语句(本地) |
| | | |
| | | // 创建存储过程,必须填写内部函数名 |
| | | if (!btn.innerFunc) { |
| | |
| | | }) |
| | | return |
| | | } |
| | | |
| | | // 创建中 |
| | | this.setState({ |
| | | funcLoading: true |
| | | }) |
| | | |
| | | new Promise(resolve => { |
| | | // 弹窗(表单)类按钮,先获取按钮配置信息,如果尚未配置按钮则会报错并终止。 |
| | |
| | | DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) |
| | | resolve(true) |
| | | } else { |
| | | resolve(false) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '弹窗(表单)按钮,请先配置表单信息!', |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | resolve(true) |
| | | } |
| | | }).then(res => { |
| | | // 获取云端及本地,是否已存在该存储过程的信息 |
| | | if (res === false) return res |
| | | if (!res) return |
| | | |
| | | let sysDefer = new Promise(resolve => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_TVP', // 云端获取存储结果 |
| | | TVPName: btn.innerFunc |
| | | }).then(result => { |
| | | resolve(result) |
| | | }) |
| | | }) |
| | | this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => { |
| | | if (result !== 'success') return |
| | | |
| | | let localDefer = new Promise(resolve => { |
| | | let _param = { // 获取本地存储过程信息 |
| | | func: 's_get_userproc', |
| | | LText: btn.innerFunc |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | Api.getLocalConfig(_param).then(result => { |
| | | resolve(result) |
| | | }) |
| | | }) |
| | | |
| | | return Promise.all([sysDefer, localDefer]) |
| | | }).then(res => { |
| | | // 云端结果与新语句不同时,更新云端信息 |
| | | if (res === false) return res |
| | | |
| | | let isError = false |
| | | |
| | | res.forEach((result, index) => { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | isError = true |
| | | } else if (index === 0) { |
| | | sysTVPText = result.TVPText |
| | | } else { |
| | | if (result.Ltext) { // 本地存储过程是否存在 |
| | | isExit = true |
| | | let isupdate = false |
| | | _config.action = _config.action.map(item => { |
| | | if (item.uuid === btn.uuid) { |
| | | isupdate = true |
| | | return btn |
| | | } else { |
| | | return item |
| | | } |
| | | localTVPText = Utils.formatOptions(result.Ltext) |
| | | }) |
| | | |
| | | if (!isupdate) { // 操作不是修改,添加元素至列表 |
| | | _config.action.push(btn) |
| | | } |
| | | }) |
| | | |
| | | if (isError) return false |
| | | |
| | | if ((newLText === localTVPText) && (newLText === sysTVPText)) { |
| | | return 'drop' |
| | | } else if (!localTVPText || (localTVPText === sysTVPText)) { |
| | | // 本地存储过程不存在,将新的存储过程更新至云端 |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: btn.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }) |
| | | } else { |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig({ // 添加现有的本地存储过程至云端 |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: btn.innerFunc, |
| | | TVPText: localTVPText, |
| | | TypeName: 'P' |
| | | }).then(result => { |
| | | if (result.status) { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端 |
| | | TVPName: btn.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }).then(response => { |
| | | resolve(response) |
| | | }) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | // 云端信息更新后,判断是删除或是直接新建存储过程 |
| | | if (res === false || res === 'drop') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else if (isExit) { |
| | | return 'drop' |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 删除存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: DelText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 根据上述操作结果,判断是否新建存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 新建存储过程 |
| | | if (res === false) return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: newLText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 处理新建结果 |
| | | if (res === false) return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '创建成功', |
| | | duration: 2 |
| | | }) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | // 新建成功后,更新页面按钮信息 |
| | | if (res === false) { |
| | | this.setState({ |
| | | funcLoading: false |
| | | config: _config |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let isupdate = false |
| | | _config.action = _config.action.map(item => { |
| | | if (item.uuid === btn.uuid) { |
| | | isupdate = true |
| | | return btn |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | if (!isupdate) { // 操作不是修改,添加元素至列表 |
| | | _config.action.push(btn) |
| | | } |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | | funcLoading: false |
| | | }) |
| | | }) |
| | | }) |
| | |
| | | Api.getLocalConfig(param) |
| | | } |
| | | |
| | | this.setState({ |
| | | funcLoading: true |
| | | }) |
| | | |
| | | let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, config)) // 创建存储过程sql |
| | | let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 删除存储过程sql |
| | | let isExit = false // 存储过程是否存在 |
| | | |
| | | new Promise(resolve => { |
| | | let sysDefer = new Promise(resolve => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_TVP', // 云端获取存储结果 |
| | | TVPName: setting.innerFunc |
| | | }).then(result => { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | let localDefer = new Promise(resolve => { |
| | | let _param = { // 获取本地存储过程信息 |
| | | func: 's_get_userproc', |
| | | LText: setting.innerFunc |
| | | } |
| | | _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) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | Promise.all([sysDefer, localDefer]).then(result => { |
| | | resolve(result) |
| | | }) |
| | | }).then(res => { |
| | | // 获取云端及本地,是否已存在该存储过程的信息 |
| | | if (res === false) return res |
| | | if (res[0] === false || res[1] === false) return false |
| | | |
| | | let cloudfunc = '' |
| | | let localfunc = '' |
| | | res.forEach((item, index) => { |
| | | if (index === 0 && item.TVPText) { |
| | | cloudfunc = item.TVPText |
| | | } else if (index === 1 && item.Ltext) { |
| | | isExit = true |
| | | localfunc = Utils.formatOptions(item.Ltext) |
| | | } |
| | | }) |
| | | |
| | | if ((newLText === localfunc) && (newLText === cloudfunc)) { |
| | | return 'drop' |
| | | } else if (!localfunc || (cloudfunc === localfunc)) { |
| | | // 本地存储过程不存在,或云端和本地存储过程一致时,将新的存储过程更新至云端 |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: setting.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }) |
| | | } else { |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig({ // 添加现有的本地存储过程至云端 |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: setting.innerFunc, |
| | | TVPText: localfunc, |
| | | TypeName: 'P' |
| | | }).then(result => { |
| | | if (result.status) { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端 |
| | | TVPName: setting.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }).then(response => { |
| | | resolve(response) |
| | | }) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | // 云端信息更新后,判断是删除或是直接新建存储过程 |
| | | if (res === false || res === 'drop') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else if (isExit) { |
| | | return 'drop' |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 删除存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: DelText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 根据上述操作结果,判断是否新建存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 新建存储过程 |
| | | if (res === false) return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: newLText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 处理新建结果 |
| | | if (res === false) return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '创建成功', |
| | | duration: 2 |
| | | }) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | // 新建成功后,更新页面按钮信息 |
| | | if (res === false) { |
| | | this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { |
| | | if (result === 'success') { |
| | | this.setState({ |
| | | funcLoading: false |
| | | config: {...config, setting: setting} |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | config: {...config, setting: setting} |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | |
| | | onCancel={this.editModalCancel} |
| | | footer={[ |
| | | this.state.card && this.state.card.btnType !== 'cancel' ? |
| | | <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null, |
| | | <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, |
| | | <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>, |
| | | <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> |
| | | ]} |
| | |
| | | }) |
| | | }} |
| | | footer={[ |
| | | <Button key="delete" className="mk-btn mk-purple" onClick={this.tableCreatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button>, |
| | | <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" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> |
| | | ]} |
| | |
| | | import MenuForm from '@/templates/tableshare/menuform' |
| | | import TransferForm from '@/components/transferform' |
| | | import SourceElement from '@/templates/tableshare/dragelement/source' |
| | | import CreateFunc from '@/templates/tableshare/createfunc' |
| | | import Source from './source' |
| | | import './index.scss' |
| | | |
| | |
| | | originActions: null, // 原始按钮信息,使用已有用户模板 |
| | | delActions: [], // 删除按钮列表 |
| | | copyActions: [], // 复制按钮组 |
| | | funcLoading: false, // 存储过程创建中 |
| | | showColumnName: false, // 显示列字段名控制 |
| | | tabviews: [], // 所有标签页 |
| | | profileVisible: false, // 验证信息模态框 |
| | |
| | | let btn = res // 按钮信息 |
| | | let newLText = '' // 创建存储过程sql |
| | | let DelText = '' // 删除存储过程sql |
| | | let isExit = false // 存储过程是否存在 |
| | | let sysTVPText = '' // 已有的存储过程语句(云端) |
| | | let localTVPText = '' // 已有的存储过程语句(本地) |
| | | |
| | | // 创建存储过程,必须填写内部函数名 |
| | | if (!btn.innerFunc) { |
| | |
| | | }) |
| | | return |
| | | } |
| | | |
| | | // 创建中 |
| | | this.setState({ |
| | | funcLoading: true |
| | | }) |
| | | |
| | | new Promise(resolve => { |
| | | // 弹窗(表单)类按钮,先获取按钮配置信息,如果尚未配置按钮则会报错并终止。 |
| | |
| | | DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) |
| | | resolve(true) |
| | | } else { |
| | | resolve(false) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '弹窗(表单)按钮,请先配置表单信息!', |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } |
| | | }) |
| | | } else if (btn.OpenType === 'excelIn') { |
| | |
| | | resolve(true) |
| | | } |
| | | }).then(res => { |
| | | // 获取云端及本地,是否已存在该存储过程的信息 |
| | | if (res === false) return res |
| | | if (!res) return |
| | | |
| | | let sysDefer = new Promise(resolve => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_TVP', // 云端获取存储结果 |
| | | TVPName: btn.innerFunc |
| | | }).then(result => { |
| | | resolve(result) |
| | | }) |
| | | }) |
| | | this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => { |
| | | if (result !== 'success') return |
| | | |
| | | let localDefer = new Promise(resolve => { |
| | | let _param = { // 获取本地存储过程信息 |
| | | func: 's_get_userproc', |
| | | LText: btn.innerFunc |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | Api.getLocalConfig(_param).then(result => { |
| | | resolve(result) |
| | | }) |
| | | }) |
| | | |
| | | return Promise.all([sysDefer, localDefer]) |
| | | }).then(res => { |
| | | // 云端结果与新语句不同时,更新云端信息 |
| | | if (res === false) return res |
| | | |
| | | let isError = false |
| | | |
| | | res.forEach((result, index) => { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | isError = true |
| | | } else if (index === 0) { |
| | | sysTVPText = result.TVPText |
| | | } else { |
| | | if (result.Ltext) { // 本地存储过程是否存在 |
| | | isExit = true |
| | | _config.action = _config.action.map(item => { |
| | | if (item.uuid === btn.uuid) { |
| | | return btn |
| | | } else { |
| | | return item |
| | | } |
| | | localTVPText = Utils.formatOptions(result.Ltext) |
| | | } |
| | | }) |
| | | |
| | | if (isError) return false |
| | | |
| | | if ((newLText === localTVPText) && (newLText === sysTVPText)) { |
| | | return 'drop' |
| | | } else if (!localTVPText || (localTVPText === sysTVPText)) { |
| | | // 本地存储过程不存在,将新的存储过程更新至云端 |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: btn.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }) |
| | | } else { |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig({ // 添加现有的本地存储过程至云端 |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: btn.innerFunc, |
| | | TVPText: localTVPText, |
| | | TypeName: 'P' |
| | | }).then(result => { |
| | | if (result.status) { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端 |
| | | TVPName: btn.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }).then(response => { |
| | | resolve(response) |
| | | }) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | // 云端信息更新后,判断是删除或是直接新建存储过程 |
| | | if (res === false || res === 'drop') return res |
| | | _config.action = _config.action.filter(item => !item.origin) |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else if (isExit) { |
| | | return 'drop' |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 删除存储过程 |
| | | if (res === false || res === 'create') return res |
| | | // 判断是否存在操作列 |
| | | let _hasGridbtn = _config.action.filter(act => act.position === 'grid').length > 0 |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: DelText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 根据上述操作结果,判断是否新建存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 新建存储过程 |
| | | if (res === false) return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: newLText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 处理新建结果 |
| | | if (res === false) return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '创建成功', |
| | | duration: 2 |
| | | }) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | // 新建成功后,更新页面按钮信息 |
| | | if (res === false) { |
| | | this.setState({ |
| | | funcLoading: false |
| | | }) |
| | | return |
| | | } |
| | | |
| | | _config.action = _config.action.map(item => { |
| | | if (item.uuid === btn.uuid) { |
| | | return btn |
| | | if (_config.gridBtn) { |
| | | _config.gridBtn.display = _hasGridbtn |
| | | } else { |
| | | return item |
| | | _config.gridBtn = { |
| | | display: _hasGridbtn, |
| | | Align: 'center', |
| | | IsSort: 'false', |
| | | uuid: Utils.getuuid(), |
| | | label: this.state.dict['header.form.column.action'], |
| | | type: 'action', |
| | | style: 'button', |
| | | show: 'horizontal', |
| | | Width: 120 |
| | | } |
| | | } |
| | | }) |
| | | _config.action = _config.action.filter(item => !item.origin) |
| | | |
| | | // 判断是否存在操作列 |
| | | let _hasGridbtn = _config.action.filter(act => act.position === 'grid').length > 0 |
| | | |
| | | if (_config.gridBtn) { |
| | | _config.gridBtn.display = _hasGridbtn |
| | | } else { |
| | | _config.gridBtn = { |
| | | display: _hasGridbtn, |
| | | Align: 'center', |
| | | IsSort: 'false', |
| | | uuid: Utils.getuuid(), |
| | | label: this.state.dict['header.form.column.action'], |
| | | type: 'action', |
| | | style: 'button', |
| | | show: 'horizontal', |
| | | Width: 120 |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | | funcLoading: false |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | | }) |
| | | }) |
| | | }) |
| | | }) |
| | |
| | | Api.getLocalConfig(param) |
| | | } |
| | | |
| | | this.setState({ |
| | | funcLoading: true |
| | | }) |
| | | |
| | | 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 |
| | | let isExit = false // 存储过程是否存在 |
| | | |
| | | new Promise(resolve => { |
| | | let sysDefer = new Promise(resolve => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_TVP', // 云端获取存储结果 |
| | | TVPName: setting.innerFunc |
| | | }).then(result => { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | let localDefer = new Promise(resolve => { |
| | | let _param = { // 获取本地存储过程信息 |
| | | func: 's_get_userproc', |
| | | LText: setting.innerFunc |
| | | } |
| | | _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) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | Promise.all([sysDefer, localDefer]).then(result => { |
| | | resolve(result) |
| | | }) |
| | | }).then(res => { |
| | | // 获取云端及本地,是否已存在该存储过程的信息 |
| | | if (res === false) return res |
| | | if (res[0] === false || res[1] === false) return false |
| | | |
| | | let cloudfunc = '' |
| | | let localfunc = '' |
| | | res.forEach((item, index) => { |
| | | if (index === 0 && item.TVPText) { |
| | | cloudfunc = item.TVPText |
| | | } else if (index === 1 && item.Ltext) { |
| | | isExit = true |
| | | localfunc = Utils.formatOptions(item.Ltext) |
| | | } |
| | | }) |
| | | |
| | | if ((newLText === localfunc) && (newLText === cloudfunc)) { |
| | | return 'drop' |
| | | } else if (!localfunc || (cloudfunc === localfunc)) { |
| | | // 本地存储过程不存在,或云端和本地存储过程一致时,将新的存储过程更新至云端 |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: setting.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }) |
| | | } else { |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig({ // 添加现有的本地存储过程至云端 |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: setting.innerFunc, |
| | | TVPText: localfunc, |
| | | TypeName: 'P' |
| | | }).then(result => { |
| | | if (result.status) { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端 |
| | | TVPName: setting.innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }).then(response => { |
| | | resolve(response) |
| | | }) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | // 云端信息更新后,判断是删除或是直接新建存储过程 |
| | | if (res === false || res === 'drop') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else if (isExit) { |
| | | return 'drop' |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 删除存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: DelText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 根据上述操作结果,判断是否新建存储过程 |
| | | if (res === false || res === 'create') return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | // 新建存储过程 |
| | | if (res === false) return res |
| | | |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: newLText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程 |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | // 处理新建结果 |
| | | if (res === false) return res |
| | | |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '创建成功', |
| | | duration: 2 |
| | | }) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | // 新建成功后,更新页面按钮信息 |
| | | if (res === false) { |
| | | |
| | | this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { |
| | | if (result === 'success') { |
| | | this.setState({ |
| | | funcLoading: false |
| | | config: {...config, setting: setting} |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | config: {...config, setting: setting} |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | |
| | | maskClosable={false} |
| | | onCancel={this.editModalCancel} |
| | | footer={[ |
| | | modaltype === 'actionEdit' ? <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null, |
| | | modaltype === 'actionEdit' ? <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, |
| | | <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>, |
| | | <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> |
| | | ]} |
| | |
| | | }) |
| | | }} |
| | | footer={[ |
| | | <Button key="delete" className="mk-btn mk-purple" onClick={this.tableCreatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button>, |
| | | <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" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> |
| | | ]} |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Button, notification } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | | |
| | | class CreateFunc extends Component { |
| | | static propTypes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | trigger: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | loading: false, |
| | | } |
| | | |
| | | exec = (innerFunc, newLText, DelText) => { |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | return new Promise(resolve => { |
| | | this.createExec(resolve, innerFunc, newLText, DelText) |
| | | }) |
| | | } |
| | | |
| | | createExec = (_resolve, innerFunc, newLText, DelText) => { |
| | | let isExist = false // 存储过程是否存在 |
| | | let cloudText = '' // 云端存储结果 |
| | | let localfunc = '' // 本地存储过程 |
| | | |
| | | new Promise(resolve => { |
| | | // 获取云端存储过程信息 |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_TVP', |
| | | TVPName: innerFunc |
| | | }).then(result => { |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | cloudText = result.TVPText |
| | | resolve(true) |
| | | } |
| | | }) |
| | | }).then(res => { |
| | | if (!res) return res |
| | | // 获取本地存储过程信息 |
| | | |
| | | let _param = { |
| | | func: 's_get_userproc', |
| | | LText: innerFunc |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | if (!res) return res |
| | | |
| | | // 处理本地结果 |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | isExist = true |
| | | localfunc = Utils.formatOptions(res.Ltext) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | if (!res) return res |
| | | |
| | | // 根据本地及远端结果判断执行动作 |
| | | if ((newLText === localfunc) && (newLText === cloudText)) { |
| | | return 'drop' |
| | | } else if (!localfunc || (cloudText === localfunc)) { |
| | | // 本地存储过程不存在,或云端和本地存储过程一致时,将新的存储过程更新至云端 |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }) |
| | | } else { |
| | | return new Promise(resolve => { |
| | | Api.getSystemConfig({ // 添加现有的本地存储过程至云端 |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: innerFunc, |
| | | TVPText: localfunc, |
| | | TypeName: 'P' |
| | | }).then(result => { |
| | | if (result.status) { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端 |
| | | TVPName: innerFunc, |
| | | TVPText: newLText, |
| | | TypeName: 'P' |
| | | }).then(response => { |
| | | resolve(response) |
| | | }) |
| | | } else { |
| | | resolve(result) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | if (!res || res === 'drop') return res |
| | | |
| | | // 处理云端更新结果 |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else if (isExist) { |
| | | return 'drop' |
| | | } else { |
| | | return 'create' |
| | | } |
| | | }).then(res => { |
| | | if (!res || res === 'create') return res |
| | | |
| | | // 删除存储过程 |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: DelText, |
| | | TypeCharOne: 'proc' // 删除或创建存储过程标志 |
| | | } |
| | | |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | if (!res || res === 'create') return res |
| | | |
| | | // 删除结果处理 |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | if (!res) return res |
| | | |
| | | // 新建存储过程 |
| | | let _param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: newLText, |
| | | TypeCharOne: 'proc' |
| | | } |
| | | _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) |
| | | |
| | | return Api.getLocalConfig(_param) |
| | | }).then(res => { |
| | | if (!res) return res |
| | | |
| | | // 处理新建结果 |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | return false |
| | | } else { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '创建成功', |
| | | duration: 2 |
| | | }) |
| | | return true |
| | | } |
| | | }).then(res => { |
| | | // 结果处理 |
| | | if (!res) { |
| | | _resolve('error') |
| | | } else { |
| | | _resolve('success') |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | |
| | | return ( |
| | | <Button |
| | | className="mk-btn mk-purple" |
| | | onClick={this.props.trigger} |
| | | loading={this.state.loading} |
| | | > |
| | | {this.props.dict['header.menu.func.create']} |
| | | </Button> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default CreateFunc |