87 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Cheetah
		
	
	
	
	
	
			
		
		
	
	
			87 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Cheetah
		
	
	
	
	
	
| {{define "submit"}}
 | ||
| <script src="/statics/plugins/jquery.form/jquery.form.js"></script>
 | ||
| <script>
 | ||
|     // 初始化
 | ||
|     $(function () {
 | ||
|         $('#EditForm').ajaxForm({
 | ||
|             beforeSubmit: function () {
 | ||
| 
 | ||
|                 // 遍历必填的文本框如果值为空就提示 并隐藏进度条
 | ||
|                 $('#EditForm input').each(function () {
 | ||
|                     var $this = $(this);
 | ||
| 
 | ||
|                     if (($this.attr('required') != undefined || $this.attr('validType') != undefined) && $this.attr('class').toString().indexOf('easy') < 0) {
 | ||
|                         if (!$this.validatebox('isValid')) {
 | ||
|                             alert($this.parents("td").prev("th").html() + "数据异常!");
 | ||
|                             $.messager.progress('close');
 | ||
|                         }
 | ||
|                     }
 | ||
| 
 | ||
|                     // 必填项未填,自动定位到Tabs相应位置,提示信息必填
 | ||
|                     var $tabs = $('#EditForm .easyui-tabs');
 | ||
|                     if ($tabs.length > 0 && $this.attr('required') && $this.hasClass('validatebox-invalid')) {
 | ||
|                         var selectTabsIndex = $this.parents('.panel-body').parents('.panel').index();
 | ||
| 
 | ||
|                         $tabs.tabs('select', selectTabsIndex);
 | ||
|                         $.messager.progress('close');
 | ||
|                     }
 | ||
|                 })
 | ||
| 
 | ||
|                 // 提交前验证
 | ||
|                 var isValid = $('#EditForm').form('validate');
 | ||
|                 if (!isValid) {
 | ||
|                     // 如果表单是无效的则隐藏进度条
 | ||
|                     $.messager.progress('close');
 | ||
|                 }
 | ||
| 
 | ||
|                 // 返回false终止表单提交
 | ||
|                 return isValid;
 | ||
|             },
 | ||
|             success: function (data) {
 | ||
| 
 | ||
|                 // 提交成功后
 | ||
|                 $.messager.progress('close');
 | ||
|                 if (data.success) {
 | ||
|                     $.messager.alert('提示', data.message, 'info', function () {
 | ||
|                         window.parent.refreshGrid();
 | ||
|                         if (data.guid != undefined) {
 | ||
|                             window.setGuid(data.guid);
 | ||
|                         }
 | ||
|                     });
 | ||
|                 } else {
 | ||
|                     $.messager.alert('错误', data.message, 'error');
 | ||
|                 }
 | ||
| 
 | ||
|             },
 | ||
|             error: function (data) {
 | ||
| 
 | ||
|                 alert(data);
 | ||
| 
 | ||
|                 // 提交失败
 | ||
|                 $.messager.progress('close');
 | ||
|                 $.messager.alert('错误', '页面提交发生错误,请联系管理员', 'error');
 | ||
|             },
 | ||
|             dataType: 'json'// 数据格式
 | ||
|         });
 | ||
|     });
 | ||
| 
 | ||
|     // 保存
 | ||
|     function save() {
 | ||
|         Loading();
 | ||
|         $("#EditForm").submit();
 | ||
|     }
 | ||
| 
 | ||
|     // 页面载入窗口
 | ||
|     function Loading() {
 | ||
|         $.messager.progress({
 | ||
|             title: '请等待',
 | ||
|             msg: '页面加载中...'
 | ||
|         });
 | ||
|     }
 | ||
| 
 | ||
|     // 页面载入窗口关闭
 | ||
|     function LoadingClose() {
 | ||
|         $.messager.progress('close');
 | ||
|     }
 | ||
| </script>
 | ||
| {{end}} |