| | |
| | | text: this.state.dict['header.form.refresh.view'] |
| | | }] |
| | | }, |
| | | // { |
| | | // type: 'select', |
| | | // key: 'method', |
| | | // label: this.state.dict['header.form.request.method'], |
| | | // initVal: card.method || 'POST', |
| | | // required: true, |
| | | // options: [{ |
| | | // MenuID: 'POST', |
| | | // text: 'POST' |
| | | // }, { |
| | | // MenuID: 'GET', |
| | | // text: 'GET' |
| | | // }] |
| | | // }, |
| | | { |
| | | type: 'select', |
| | | key: 'icon', |
| | |
| | | initVal: card.sqlType || '', |
| | | tooltip: this.state.dict['header.form.actionhelp.sqlType'], |
| | | required: false, |
| | | options: [{ |
| | | MenuID: '', |
| | | text: this.state.dict['header.form.empty'] |
| | | }, { |
| | | MenuID: 'insert', |
| | | text: this.state.dict['header.form.action.insert'] |
| | | }, { |
| | | MenuID: 'update', |
| | | text: this.state.dict['header.form.action.update'] |
| | | }, { |
| | | MenuID: 'LogicDelete', |
| | | text: this.state.dict['header.form.action.LogicDelete'] |
| | | }, { |
| | | MenuID: 'delete', |
| | | text: this.state.dict['header.form.action.delete'] |
| | | }] |
| | | options: [] |
| | | } |
| | | ] |
| | | }) |
| | |
| | | } |
| | | newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config.columns)) |
| | | DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) |
| | | resolve(false) |
| | | resolve(true) |
| | | } else { |
| | | resolve(false) |
| | | notification.warning({ |
| | |
| | | } |
| | | newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config.columns)) |
| | | DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) |
| | | resolve(false) |
| | | resolve(true) |
| | | } |
| | | }).then(res => { |
| | | // 获取云端及本地,是否已存在该存储过程的信息 |
| | |
| | | |
| | | if ((newLText === localTVPText) && (newLText === sysTVPText)) { |
| | | return 'drop' |
| | | } else if (!localTVPText || (sysTVPText === localTVPText)) { |
| | | // 本地存储过程不存在,或云端和本地存储过程一致时,将新的存储过程更新至云端 |
| | | } else if (!localTVPText || (localTVPText === sysTVPText)) { |
| | | // 本地存储过程不存在,将新的存储过程更新至云端 |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_TVP_InUp', |
| | | TVPName: btn.innerFunc, |
| | |
| | | this.setState({ |
| | | actionloading: false |
| | | }) |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 创建表格存储过程 |
| | | */ |
| | | tableCreatFunc = () => { |
| | | const { menu } = this.props |
| | | let config = JSON.parse(JSON.stringify(this.state.config)) |
| | | |
| | | this.settingRef.handleConfirm().then(res => { |
| | | const setting = res |
| | | if (!(setting.interType === 'inner') || !setting.innerFunc) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '接口类型为-内部,且存在内部函数时,才可以创建存储过程!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (setting.dataresource.length > 50 && config.setting.dataresource !== setting.dataresource) { |
| | | let param = { |
| | | func: 's_DataSrc_Save', |
| | | LText: setting.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) |
| | | } |
| | | |
| | | this.setState({ |
| | | funcLoading: true |
| | | }) |
| | | |
| | | let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, config)) // 创建存储过程sql |
| | | let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 删除存储过程sql |
| | | |
| | | 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) { |
| | | 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 { |
| | | 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 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | config: {...config, setting: setting} |
| | | }) |
| | | }) |
| | | }) |
| | |
| | | date: 'like' |
| | | } |
| | | const selectmatch = { // 选择select时匹配规则 |
| | | text: 'equal', |
| | | number: 'equal', |
| | | datetime: 'equal', |
| | | date: 'equal' |
| | | text: '=', |
| | | number: '=', |
| | | datetime: '=', |
| | | date: '=' |
| | | } |
| | | const datematch = { // 选择dateRange时匹配规则 |
| | | text: 'between', |
| | |
| | | label: item.label, |
| | | field: item.field, |
| | | Hide: 'false', |
| | | IsSort: 'true', |
| | | type: 'text', |
| | | IsSort: item.type === 'picture' ? 'false' : 'true', |
| | | type: item.type, |
| | | Width: 120 |
| | | } |
| | | |
| | |
| | | visible={this.state.visible} |
| | | width={700} |
| | | onCancel={() => { this.setState({ visible: false }) }} |
| | | onOk={this.handleSubmit} |
| | | // onOk={this.handleSubmit} |
| | | footer={[ |
| | | this.state.formtemp === 'action' ? |
| | | <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null, |
| | |
| | | title={this.state.dict['header.edit']} |
| | | visible={this.state.settingVisible} |
| | | width={700} |
| | | onOk={this.settingSave} |
| | | // 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>, |
| | | <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> |
| | | ]} |
| | | destroyOnClose |
| | | > |
| | | <SettingForm |
| | | dict={this.state.dict} |
| | | menu={this.props.menu} |
| | | data={this.state.config.setting} |
| | | columns={this.state.config.columns} |
| | | dict={this.state.dict} |
| | | usefulFields={this.props.permFuncField} |
| | | wrappedComponentRef={(inst) => this.settingRef = inst} |
| | | /> |
| | | </Modal> |