Skip to content

Commit

Permalink
add handler
Browse files Browse the repository at this point in the history
  • Loading branch information
leelance committed Jan 3, 2017
1 parent 44a4f23 commit f3815b7
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,50 @@ var ProcessManage = {
thiz: null,
grid: '#process-manage-grid',
tbar: '#process-manage-tbar',
form: '#process-manage-form',
dialog: '#process-manage-dialog',

init: function(){
thiz= this;
thiz = this;

//初始化Grid列表数据
thiz.initGrid();
},

//添加模块
addModule: function(){
var d = this.createModuleDialog();
d.dialog({title: "新增模块"}).dialog('open');
//新增按钮事件
addProcess: function() {
var d = thiz.createProcessDialog();
d.dialog({title: "新增流程"}).dialog('open');
},

//修改模块弹出修改框
updateModule: function() {
//修改流程
update: function() {
var message = Ext.getSingleSelected(thiz.grid);
if(message){
return Ext.alert(message);
}

this.update();
},

//执行更新操作
update: function() {
var record = Ext.getRecord(thiz.grid);
var d = this.createModuleDialog();
d.dialog({title: "修改模块--"+record.moduleName}).dialog('open');
var d = this.createProcessDialog();
d.dialog({title: "修改流程--"+record.processName}).dialog('open');

//加载form表单
$("#sysModuleForm").form('load', record)
$(thiz.form).form('load', record)
},

//删除模块
deleteModule: function(){
var message = Ext.getSingleSelected('#sys-module-grid');
//删除流程定义
del: function() {
var message = Ext.getSingleSelected(thiz.grid);
if(message){
return Ext.alert(message);
}

Ext.confirm('您确认要删除这条记录吗?', function(){
Ext.progress('正在删除数据...');
var rows = Ext.getRecord('#sys-module-grid');
$.get("/admin/sysmodule/delete/"+rows.id, function(result){
var row = Ext.getRecord(thiz.grid);
$.get("/admin/process/manage/delete/"+row.id, function(result){
if(result.errorCode==0){
$("#sys-module-grid").datagrid("reload")
$(thiz.grid).datagrid("reload")
}else{
Ext.alert(result.errorText);
}
Expand All @@ -57,104 +54,85 @@ var ProcessManage = {
});
},

searchModule: function() {
$("#sys-module-grid").datagrid("load", {sysModuleName: $('#sysModuleName').val()})
},

//模块详情
detailModule: function(index){
$('#sys-module-grid').datagrid('selectRow',index);
var row = Ext.getRecord('#sys-module-grid');
if(!row){return;}

//弹出Dialog, 并修改Title和隐藏Button
var d = this.createModuleDialog();
d.dialog({title: "查看模块--"+row.moduleName}).dialog('open');
$(".dialog-button a").eq(0).hide();

$("#sysModuleForm").form('load', row)
},

//保存模块
saveModule: function(){
$('#sysModuleForm').form('submit',{
url: '/admin/sysmodule/save',
onSubmit: function(){
var flag = $(this).form('enableValidation').form('validate');
if(flag) {
Ext.progress('正在保存数据...');
}
return flag;
},
success: function(result){
result = $.parseJSON(result);
if(result.errorCode ==0){
var d = Module.createModuleDialog();
d.dialog('close');
$("#sys-module-grid").datagrid("reload");
}else{
Ext.alert(result.errorText);
}

Ext.progressClose();
}
});
//查询流程
search: function() {
$(thiz.grid).datagrid("load", {processName: $('#processName').val()})
},

//初始化表单
initGrid: function(){
$(thiz.grid).datagrid({
toolbar: thiz.tbar,
url:'/admin/sysmodule/list',
url:'/admin/process/manage/list',
method: 'post',
fitColumns: true,
striped: true,
fit: true,
pagination:true,
rownumbers:true,
pagination: true,
rownumbers: true,
ctrlSelect: false,
singleSelect: true,
pageList: [20,40,80,100],
pageSize: 20,
columns:[[
{field:'id',title:'',checkbox:'true', width:20},
{field:'moduleName',title:'模块名称',width:80,formatter:function(v,r,i){return '<a href="javascript:void(0)" onclick="Module.detailModule('+i+')">'+v+'</a>';}},
{field:'moduleUrl',title:'模块路径',width:100},
{field:'moduleParentName',title:'上级模块',width:80},
{field:'moduleRemark',title:'描述',width:120},
{field:'moduleType',title:'类型',width:30,formatter:function(v){return v==1?'菜单':'功能'}},
{field:'sequence',title:'排序',width:30},
{field:'status',title:'是否启用',width:30,formatter:function(v){return v==0?'否':'是'}},
{field:'createDate',title:'创建时间',width:60}
{field:'processName',title:'流程名称',width:80},
{field:'processKey',title:'流程Key',width:80},
{field:'processFile',title:'流程文件',width:120},
{field:'createTime',title:'创建时间',width:80}
]]
});
},

//模块框
createModuleDialog: function() {
$('#sysModuleForm').form('clear');
$('#sysModuleForm input[name=status][value=1]').prop('checked', true);
$('#sysModuleForm input[name=moduleType][value=1]').prop('checked', true);
$('#sysModuleForm input[name=id]').val(0);
//创建新增对话框
createProcessDialog: function(){
$(thiz.form).form('reset');
$(thiz.form).find('input[name=id]').val(0);

var d = $('#sysModuleDialog').dialog({
width:500,
var d = $(thiz.dialog).dialog({
width:400,
minimizable: false,
maximizable: false,
collapsible: false,
resizable: false,
modal: true,
iconCls: 'icon-win',
buttons: [
{text: '保 存', handler: this.saveModule},
{text: '保 存', handler: thiz.saveProcess},
{text: '关 闭', handler: function(){d.dialog('close');}}
]
});
return d;
},

//保存数据
saveProcess: function() {
$(thiz.form).form('submit',{
url: '/admin/process/manage/save',
onSubmit: function(){
var flag = $(this).form('enableValidation').form('validate');
if(flag) {
Ext.progress('正在保存数据...');
}
return flag;
},
success: function(result){
result = $.parseJSON(result);
if(result.errorCode ==0){
var d = thiz.createProcessDialog();
d.dialog('close');
$(thiz.grid).datagrid("reload");
}else{
Ext.alert(result.errorText);
}

Ext.progressClose();
}
});
}
}

//JS入口
(function($) {
$(document).ready(function(){
ProcessManage.init();
})(jQuery);
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,38 @@
<table cellpadding="0" cellspacing="0" style="width:100%">
<tr>
<td>
<a href="#" class="easyui-linkbutton" iconCls="grid-add" plain="true" onclick="Module.addModule()">新增</a>
<a href="#" class="easyui-linkbutton" iconCls="grid-add" plain="true" onclick="ProcessManage.addProcess()">新增</a>
<div class="datagrid-btn-separator" style="vertical-align: middle; height: 15px;display:inline-block;float:none"></div>
<a href="#" class="easyui-linkbutton" iconCls="grid-edit" plain="true" onclick="Module.updateModule()">修改</a>
<a href="#" class="easyui-linkbutton" iconCls="grid-edit" plain="true" onclick="ProcessManage.update()">修改</a>
<div class="datagrid-btn-separator" style="vertical-align: middle; height: 15px;display:inline-block;float:none"></div>
<a href="#" class="easyui-linkbutton" iconCls="grid-del" plain="true" onclick="Module.deleteModule()">删除</a>
<a href="#" class="easyui-linkbutton" iconCls="grid-del" plain="true" onclick="ProcessManage.del()">删除</a>
</td>
<td style="text-align:right">
<input type="text" class="easyui-textbox" id="sysModuleName" data-options="prompt:'输入模块名称'"/>
<a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="Module.searchModule()">查询</a>
<input type="text" class="easyui-textbox" id="processName" data-options="prompt:'输入流程名称'"/>
<a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="ProcessManage.search()">查询</a>
</td>
</tr>
</table>
</div>
</div>

<!-- 窗口Window -->
<div id="process-manage-dialog" style="padding:10px 0px;">
<form id="process-manage-form" class="easyui-form" method="post" data-options="novalidate:true">
<table style="width: 350px;margin: 0 auto;">
<tr>
<td>任务名称</td>
<td><input class="easyui-textbox" name="processName" style="width:100%" data-options="required:true"></td>
<td width="50"></td>
</tr>
<tr>
<td>任务文件</td>
<td><input class="easyui-textbox" name="processFile" style="width:100%" data-options="required:true"></td>
<td width="50"><input type="hidden" name="id" value="0"></td>
</tr>
</table>
</form>
</div>
</div>

<script type="text/javascript" src="/plugin/commons.js"></script>
<script type="text/javascript" src="/js/process/process-manage-list.js"></script>

0 comments on commit f3815b7

Please sign in to comment.