dialogSysUnitSort.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg, $grid;
  4. // 查询列表
  5. function queryGrid1() {
  6. var queryUrl = '/sys/sysUnit/queryAll';// 自行替换此参数
  7. $grid.jqGrid("clearGridData");
  8. $grid.reload({
  9. mtype: 'POST',
  10. url: api(queryUrl),
  11. queryParams: {"unitType": context.unitType}
  12. });
  13. }
  14. //编辑工具栏
  15. var gridToolbarTitle = '单位列表';// 自行替换此参数
  16. var gridToolbar = {
  17. xtype: 'toolbar', title: gridToolbarTitle, items: [
  18. {
  19. text: '上移', iconCls: 'fa fa-arrow-up', onClick: function () {
  20. $grid.moveUp();
  21. }
  22. },
  23. {
  24. text: '下移', iconCls: 'fa fa-arrow-down', onClick: function () {
  25. $grid.moveDown();
  26. }
  27. },
  28. {
  29. text: '保存排序', iconCls: 'fa fa-check-square', onClick: function () {
  30. moveGrid();
  31. }
  32. }
  33. ]
  34. }
  35. //保存排序
  36. function moveGrid() {
  37. var gridData = $grid.jqGrid("getRowData");
  38. var list = [];
  39. for (var i = 0; i < gridData.length; i++) {
  40. list.push(gridData[i].unitId);
  41. }
  42. saveSort("sysUnit", list);
  43. }
  44. function saveSort(name, ids) {
  45. var data = {
  46. "ids": "",
  47. "name": name
  48. };
  49. for (var i = 0; i < ids.length; i++) {
  50. data.ids += ids[i] + ","
  51. }
  52. data.ids = data.ids.substr(0, data.ids.length - 1);
  53. if (data.ids == "") {
  54. return;
  55. }
  56. $.yvan.ajax({
  57. url: api('/core/app/updateCoreSort'),
  58. method: 'post',
  59. data: data,
  60. beforeSend: function () {
  61. $.yvan.progress();
  62. },
  63. success: function () {
  64. $.yvan.msg('操作成功');
  65. $dlg.window('close');
  66. if ($.type(context.confirm) === 'function') {
  67. context.confirm();
  68. }
  69. },
  70. complete: function () {
  71. $.yvan.closep();
  72. }
  73. });
  74. }
  75. return {
  76. xtype: 'dialog',
  77. dialogId: 'dialogSysUnitSort',
  78. title: '维护单位排序',
  79. width: 700,
  80. height: 600,
  81. onOpen: function () {
  82. $dlg = $(this);
  83. },
  84. center: {
  85. border: false,
  86. items: {
  87. onRender: function () {
  88. $grid = $(this);
  89. queryGrid1();
  90. },
  91. xtype: 'grid',
  92. pagination: false,
  93. idField: "sysUnitSort",
  94. toolbar: {
  95. xtype: 'div',
  96. items: [
  97. gridToolbar
  98. ]
  99. },
  100. columns: [[
  101. {title: '单位Id', field: 'unitId', hidden: true},
  102. {title: '单位类型', field: 'unitType', hidden: true},
  103. {title: '单位名称', field: 'unitName'},
  104. {title: '单位编码', field: 'unitMark'},
  105. {title: '基础单位', field: 'isBase', align: 'center', formatter: $.fn.fmatter.yesOrNo},
  106. {title: '启用状态', field: 'status', align: 'center', formatter: $.fn.fmatter.statusView}, //增加字典,显示正常
  107. {title: '备注', field: 'remark'},
  108. ]]
  109. }
  110. }
  111. };
  112. };
  113. });