define(function (require) { return function (context) { var $dlg, $grid; // 查询列表 function queryGrid1() { var queryUrl = '/sys/wfStep/queryAll';// 自行替换此参数 $grid.jqGrid("clearGridData"); $grid.reload({ mtype: 'GET', url: api(queryUrl), queryParams: {"wfId": context.wfId, "stepId": context.treeUp, "treeUp": context.treeUp} }); } //编辑工具栏 var gridToolbarTitle = '业务流程列表';// 自行替换此参数 var gridToolbar = { xtype: 'toolbar', title: gridToolbarTitle, items: [ { text: '上移', iconCls: 'fa fa-arrow-up', onClick: function () { $grid.moveUp(); } }, { text: '下移', iconCls: 'fa fa-arrow-down', onClick: function () { $grid.moveDown(); } }, { text: '保存排序', iconCls: 'fa fa-check-square', onClick: function () { moveGrid(); } } ] } //保存排序 function moveGrid() { var gridData = $grid.jqGrid("getRowData"); var list = []; for (var i = 0; i < gridData.length; i++) { list.push(gridData[i].stepId); } var treeCode = ""; if (context.treeLev > 1) { treeCode = context.treeCode.substr(0, 3); } saveSort("sysWfStep", list, context.wfId, treeCode); } function saveSort(name, ids, sysid, codeup) { var data = { "ids": "", "name": name, "sysId": sysid, "codeUp": codeup, }; for (var i = 0; i < ids.length; i++) { data.ids += ids[i] + "," } data.ids = data.ids.substr(0, data.ids.length - 1); if (data.ids == "") { return; } $.yvan.ajax({ url: api('/core/app/updateCoreSortCode'), method: 'post', data: data, beforeSend: function () { $.yvan.progress(); }, success: function () { $.yvan.msg('操作成功'); $dlg.window('close'); if ($.type(context.confirm) === 'function') { context.confirm(); } }, complete: function () { $.yvan.closep(); } }); } return { xtype: 'dialog', dialogId: 'dialogWfStepSort', title: '维护业务流程排序', width: 900, height: 650, onOpen: function () { $dlg = $(this); }, center: { border: false, items: { onRender: function () { $grid = $(this); queryGrid1(); }, xtype: 'grid', pagination: false, idField: "WfStepSort", toolbar: { xtype: 'div', items: [ gridToolbar ] }, columns: [[ {title: '步骤ID', field: 'stepId', hidden: true}, {title: '步骤名称', field: 'stepName'}, {title: '步骤编码', field: 'stepCode'}, // {title: '流程名称', field: 'taskType'}, {title: '启用状态', field: 'status', align: 'center', formatter: $.fn.fmatter.statusView}, //增加字典,显示正常 ]] } } }; }; });