From 5e1d4d5155c57c43739d61914e2d29a64f9bb683 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 27 八月 2023 17:40:38 +0800 Subject: [PATCH] Merge branch 'develop' --- src/templates/zshare/createfunc/index.jsx | 256 +++++++++++++++++--------------------------------- 1 files changed, 89 insertions(+), 167 deletions(-) diff --git a/src/templates/zshare/createfunc/index.jsx b/src/templates/zshare/createfunc/index.jsx index 6fca05b..d464a7f 100644 --- a/src/templates/zshare/createfunc/index.jsx +++ b/src/templates/zshare/createfunc/index.jsx @@ -4,203 +4,125 @@ import moment from 'moment' import Utils from '@/utils/utils.js' +import FuncUtils from './utils.js' import Api from '@/api' // import './index.scss' class CreateFunc extends Component { static propTypes = { - trigger: PropTypes.func + getMsg: PropTypes.func } state = { - loading: false, + loading: false } - exec = (innerFunc, newLText, DelText) => { + trigger = () => { + this.props.getMsg().then(config => { + let newLText = '' + let func = '' + + if (config.$type === 'table') { + func = config.func + newLText = FuncUtils.getTableFunc(config) + } else if (config.$type === 'excelIn') { + func = config.func + newLText = FuncUtils.getexcelInfunc(config) + } else if (config.$type === 'btn') { + func = config.func + newLText = FuncUtils.getfunc(config) + } + + if (!newLText || !func) return + + this.createExec(func, newLText) + }) + } + + createExec = (func, newLText) => { + let dropfunc = `IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('${func}') AND type in (N'P', N'PC')) mdrpk PROCEDURE ${func}` + // 鍒犻櫎瀛樺偍杩囩▼ + let droparam = { + func: 'sPC_TableData_InUpDe', + LText: Utils.formatOptions(dropfunc), + TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋嬫爣蹇� + } + + droparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + droparam.secretkey = Utils.encrypt(droparam.LText, droparam.timestamp) + droparam.open_key = Utils.encryptOpenKey(droparam.secretkey, droparam.timestamp) + + // 鏂板缓瀛樺偍杩囩▼ + let _param = { + func: 'sPC_TableData_InUpDe', + LText: Utils.formatOptions(newLText), + TypeCharOne: 'proc' + } + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) + _param.open_key = Utils.encryptOpenKey(_param.secretkey, _param.timestamp) + + let saveParam = { + func: 's_proc_save', + sql_script: window.btoa(window.encodeURIComponent(newLText)), + proc_name: func, + save_type: 'auto' + } + this.setState({ loading: true }) - this.createExec(innerFunc, newLText, DelText) - } - - createExec = (innerFunc, newLText, DelText) => { - let isExist = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 - let cloudText = '' // 浜戠瀛樺偍缁撴灉 - let localfunc = '' // 鏈湴瀛樺偍杩囩▼ - - new Promise(resolve => { - // 鑾峰彇浜戠瀛樺偍杩囩▼淇℃伅 - Api.getCloudConfig({ - func: 'sPC_Get_TVP', - TVPName: innerFunc - }).then(result => { + Api.genericInterface(droparam).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + this.setState({ + loading: false + }) + return + } + Api.genericInterface(_param).then(result => { if (!result.status) { notification.warning({ top: 92, message: result.message, duration: 5 }) - 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') - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.genericInterface(_param) - }).then(res => { - if (!res) return res - - // 澶勭悊鏈湴缁撴灉 - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - 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.getCloudConfig({ - func: 'sPC_TVP_InUp', - TVPName: innerFunc, - TVPText: newLText, - TypeName: 'P' - }) - } else { - return new Promise(resolve => { - Api.getCloudConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: innerFunc, - TVPText: localfunc, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getCloudConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } + this.setState({ + loading: false }) + return + } + + Api.genericInterface(saveParam).then(response => { + this.setState({loading: false}) + if (!response.status) { + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + } else { + notification.success({ + top: 92, + message: '鍒涘缓鎴愬姛銆�', + duration: 5 + }) + } }) - } - }).then(res => { - if (!res || res === 'drop') return res - - // 澶勭悊浜戠鏇存柊缁撴灉 - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - 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') - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - _param.open_key = Utils.encryptOpenKey(_param.secretkey, _param.timestamp) - - return Api.genericInterface(_param) - }).then(res => { - if (!res || res === 'create') return res - - // 鍒犻櫎缁撴灉澶勭悊 - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - 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') - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - _param.open_key = Utils.encryptOpenKey(_param.secretkey, _param.timestamp) - - return Api.genericInterface(_param) - }).then(res => { - this.setState({ - loading: false }) - - if (!res) return res - - // 澶勭悊鏂板缓缁撴灉 - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - } }) } render() { - return ( <Button className="mk-btn mk-purple" - onClick={this.props.trigger} + onClick={this.trigger} loading={this.state.loading} > 鍒涘缓瀛樺偍杩囩▼ -- Gitblit v1.8.0