Explorar o código

sql检测功能添加

zhuth %!s(int64=8) %!d(string=hai) anos
pai
achega
17f927f526

+ 39 - 16
kanban-console/src/main/webapp/resources/app/view/core/trigger/TextTrigger.js

@@ -8,31 +8,22 @@ Ext.define('erp.view.core.trigger.TextTrigger', {
             field: trigger,
             title: trigger.fieldLabel,
             check: trigger.name == 'sql',
-            width:420,
-            height:320,
+            width:637,
+            height:332,
             modal:true,
             layout:'fit',
+            maximizable:true,
             items: [{
                 xtype:'form',
                 layout: 'fit',
-                autoScroll: true,
-                bodyPadding: 10,
                 defaults: {
                     labelAlign: 'top'
                 },
                 items: [{
                     xtype: 'textarea',
-                    fieldLabel: '内容',
+                    grow:true,
                     name: 'text'
-                }],
-                // tbar: [{
-                //     xtype: 'button',
-                //     cls: 'ux-start-button',
-                //     iconCls: 'ux-start-button-icon',
-                //     menuAlign: 'bl-tl',
-                //     text:'引入参数',
-                //     menu:Ext.widget('startmenu'),
-                // }]
+                }]
             }],
             buttonAlign: 'center',
             buttons:[{
@@ -41,8 +32,12 @@ Ext.define('erp.view.core.trigger.TextTrigger', {
                 handler:function(btn){
                     var win = btn.ownerCt.ownerCt;
                     var params = win.getParams(win.getText());
-                    if(win.check && !win.checkParams(params)) {
-                        return;
+                    if(win.check){
+	                    if(!win.checkParams(params)) {
+	                    	return
+	                    }
+	                    if(!win.checkSql(win.getText())) {
+	                    }
                     }
                     var componet = Ext.getCmp(win.field.ownerCt.el.dom.parentNode.id);
                     if(componet) {
@@ -123,6 +118,34 @@ Ext.define('erp.view.core.trigger.TextTrigger', {
                         success = false;
                     }
                 });
+                return success;
+            },
+            /* 检测sql是否正确 **/
+            checkSql: function(sql) {
+            	var me = this;
+            	var success = false;
+            	// 执行检测方法
+            	me.el.mask('loading...');
+            	Ext.Ajax.request({
+                    url:'kanban/validateSQL',
+                    async: false,
+                    method:'POST',
+                    params:{
+                        panelCode: panelCode,
+                        sql: sql
+                    },
+                    callback:function(options,success,response){
+                        me.el.unmask();
+						var res = Ext.decode(response.responseText);
+						if (res.success == false) {
+							showErrorMsg('SQL有误',res.message);
+							success = false;
+						}else {
+							success = true;
+						}
+                    }
+                });
+                
                 return success;
             }
         });

+ 36 - 14
kanban-console/src/main/webapp/resources/app/view/desktop/ParamValueEditor.js

@@ -2,10 +2,11 @@ Ext.define('erp.view.desktop.ParamValueEditor',{
 	extend:'Ext.window.Window',
 	alias:'widget.paramvalueeditor',
 	id:'paramvalueeditor',
-	width:400,
-	height:250,
+	width:637,
+    height:332,
 	modal:true,
     layout:'fit',
+    maximizable:true,
 	initComponent:function(){
         var me = this;
 		me.items = [{
@@ -13,19 +14,11 @@ Ext.define('erp.view.desktop.ParamValueEditor',{
             id:'paramValueForm',
             layout: 'fit',
             hidden: me.paramRecord.get('type') != 'SQL',
-            autoScroll: true,
             items: [{
                 xtype: 'textarea',
+                grow: true,
                 name: 'value'
             }],
-            // tbar: [{
-            //     xtype: 'button',
-            //     text: '执行SQL',
-            //     handler: function(btn) {
-            //         var sql = Ext.getCmp('paramValueForm').getForm().findField('value').getValue();
-            //         alert(sql);
-            //     }
-            // }],
             load: function() {
                 var form = this;
                 var sql = me.paramRecord.get('optionalValues');
@@ -42,6 +35,31 @@ Ext.define('erp.view.desktop.ParamValueEditor',{
             getParamValue: function() {
                 var form = this;
                 return form.getForm().findField('value').getValue();
+            },
+            checkSql: function(sql) {
+            	var formpanel = Ext.getCmp('boardSetForm');
+            	var panelCode = formpanel.getForm().getValues().code;
+            	// 执行检测方法
+            	me.el.mask('loading...');
+            	Ext.Ajax.request({
+                    url:'kanban/validateSQL',
+                    async: false,
+                    method:'POST',
+                    params:{
+                        panelCode: panelCode,
+                        sql: sql
+                    },
+                    callback:function(options,success,response){
+                        me.el.unmask();
+						var res = Ext.decode(response.responseText);
+						if (res.success == false) {
+							showErrorMsg('SQL有误',res.message);
+						}else {
+							me.paramRecord.set('optionalValues', sql);
+        					me.close();
+						}
+                    }
+                });
             }
         }, {
             xtype:'grid',
@@ -106,7 +124,6 @@ Ext.define('erp.view.desktop.ParamValueEditor',{
 		handler:function(btn){
 			var me = Ext.getCmp('paramvalueeditor');
             me.save();
-            btn.ownerCt.ownerCt.close()
 		}
 	},{
 		text:'取消',
@@ -129,6 +146,11 @@ Ext.define('erp.view.desktop.ParamValueEditor',{
         var me = this;
         var item = me.paramRecord.get('type') == 'SQL' ? Ext.getCmp('paramValueForm') : Ext.getCmp('paramValueGrid')
         var value = item.getParamValue();
-        me.paramRecord.set('optionalValues', value);
-    }
+        if(me.paramRecord.get('type') == 'SQL') {
+        	item.checkSql(value);
+        }else {
+	        me.paramRecord.set('optionalValues', value);
+	        me.close()
+        }
+    }    
 });