dialogMenu.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg, $form, $comb;
  4. //自动生成助记码
  5. function onblurCustomerName() {
  6. $('body').item('menuName').textbox('setValue', $(this).val());
  7. var customerName = $('body').item('menuName').textbox("getValue");
  8. if (null != customerName && "" != customerName && undefined != customerName) {
  9. $('body').item('menuNamePy').val(top.pinyin.getCamelChars(customerName));
  10. var a = $('body').item('menuNamePy').val();
  11. $('body').item('menuNamePy').textbox('setValue', a);
  12. }
  13. }
  14. //获取平台列表
  15. function getDataSysList() {
  16. var _datas = [];
  17. $.yvan.ajax({
  18. url: api('/sys/system/query'),
  19. data: {status: 1},
  20. method: 'post',
  21. async: false,
  22. success: function (data) {
  23. if (data.data != null && data.data != undefined) {
  24. for (var i = 0; i < data.data.length; i++) {
  25. _datas.push({
  26. "id": data.data[i].sysId,
  27. "text": data.data[i].sysName
  28. })
  29. }
  30. }
  31. }
  32. });
  33. return _datas;
  34. }
  35. //获取一级菜单列表
  36. function getDataMenuList() {
  37. var _datas = [];
  38. _datas.push({
  39. "id": "0",
  40. "text": "一级菜单",
  41. "selected": true
  42. });
  43. var sysId = null;
  44. if ($form) {
  45. sysId = $form.formGet().sysId;
  46. }
  47. $.yvan.ajax({
  48. url: api('/sys/menu/queryAll'),
  49. data: {treeLev: 1, status: 1, sysId: sysId},
  50. method: 'get',
  51. async: false,
  52. success: function (data) {
  53. if (data.data != null && data.data != undefined) {
  54. for (var i = 0; i < data.data.length; i++) {
  55. _datas.push({
  56. "id": data.data[i].menuId,
  57. "text": data.data[i].menuName
  58. })
  59. }
  60. }
  61. }
  62. });
  63. return _datas;
  64. }
  65. return {
  66. xtype: 'dialog',
  67. dialogId: 'dialogMenu',
  68. title: '维护菜单信息',
  69. width: 620,
  70. height: 400,
  71. onOpen: function () {
  72. $dlg = $(this);
  73. if (context.isEdit) {
  74. $.yvan.ajax({
  75. loadingMask: false,
  76. url: api('/sys/menu/queryById'),
  77. type: 'GET',
  78. data: {
  79. menuId: context.menuId
  80. },
  81. success: function (data) {
  82. $dlg.find('form');
  83. $form.formSet(data.data);
  84. }
  85. });
  86. } else {
  87. $form.formSet({
  88. status: '1',
  89. beActive: 'Y',
  90. sysId: context.sysId
  91. });
  92. }
  93. },
  94. center: {
  95. items: {
  96. xtype: 'formgroup',
  97. onRender: function () {
  98. $form = $(this);
  99. },
  100. items: [
  101. [
  102. {
  103. name: 'sysId',
  104. label: '所属平台',
  105. xtype: 'yvselect',
  106. required: true,
  107. width: 350,
  108. disabled: context.isEdit ? "disabled" : "",
  109. data: getDataSysList(),
  110. onChange: function () {
  111. $comb.yvselect({'data': getDataMenuList()});
  112. }
  113. }
  114. ],
  115. [
  116. {
  117. name: 'treeUp',
  118. label: '上级菜单',
  119. xtype: 'yvselect',
  120. panelHeight: 220,
  121. width: 350,
  122. required: true,
  123. disabled: context.isEdit ? "disabled" : "",
  124. data: getDataMenuList(),
  125. onRender: function () {
  126. $comb = $(this);
  127. },
  128. }
  129. ],
  130. [
  131. {name: 'menuId', label: '菜单ID', xtype: 'hidden'},
  132. {name: 'menuName', label: '菜单名称', required: true, events: {blur: onblurCustomerName}},
  133. {name: 'menuNamePy', label: '菜单拼音', xtype: 'hidden'},
  134. {
  135. name: 'status',
  136. label: '启用状态',
  137. xtype: 'yvselect',
  138. required: true,
  139. data: $.yvan.sysDict('status').combo()
  140. },
  141. {name: 'menuCode', label: '菜单编码'},
  142. {
  143. name: 'menuIcon', label: '图标', xtype: 'yvselect', panelHeight: 200, data: [
  144. {id: 'fa fa-desktop', text: '桌面'},
  145. {id: 'fa fa-file-o', text: '文件'},
  146. {id: 'fa fa-wpforms', text: '日历'},
  147. {id: 'fa fa-th-list', text: '一级菜单'},
  148. {id: 'fa fa-list-ul', text: '二级菜单'},
  149. {id: 'fa fa-bars', text: '列表'},
  150. {id: 'fa fa-search', text: '搜索'},
  151. {id: 'fa fa-database', text: '数据库'},
  152. {id: 'fa fa-history', text: '历史'},
  153. {id: 'fa fa-globe', text: '地球'},
  154. {id: 'fa fa-flag', text: '旗帜'},
  155. {id: 'fa fa-filter', text: '漏斗'},
  156. {id: 'fa fa-envelope', text: '信封'},
  157. {id: 'fa fa-diamond', text: '钻石'},
  158. {id: 'fa fa-cubes', text: '立方体'},
  159. {id: 'fa fa-coffee', text: '咖啡'},
  160. {id: 'fa fa-cogs', text: '齿轮组'},
  161. {id: 'fa fa-cog', text: '齿轮'},
  162. {id: 'fa fa-cart-plus', text: '购物车'},
  163. {id: 'fa fa-bell', text: '铃铛'},
  164. {id: 'fa fa-barcode', text: '长形码'},
  165. {id: 'fa fa-university', text: '大学'},
  166. {id: 'fa fa-balance-scale', text: '天秤'},
  167. {id: 'fa fa-asterisk', text: '雪花'},
  168. {id: 'fa fa-podcast', text: '广播'},
  169. {id: 'fa fa-truck', text: '卡车'},
  170. {id: 'fa fa-shopping-basket', text: '购物栏'},
  171. {id: 'fa fa-plug', text: '插头'},
  172. {id: 'fa fa-pie-chart', text: '饼图'},
  173. {id: 'fa fa-magnet', text: '磁铁'},
  174. {id: 'fa fa-user-circle', text: '用户'},
  175. {id: 'fa fa-users', text: '用户组'}
  176. ]
  177. },
  178. {name: 'menuUrl', label: '功能URL', span: 2},
  179. {name: 'remark', label: '备注', span: 2},
  180. ]]
  181. }
  182. },
  183. buttons: [
  184. {
  185. text: "提交", iconCls: "fa fa-save", onClick: function () {
  186. $.yvan.postForm($form, {
  187. url: (context.isEdit ? api('/sys/menu/update') : api('/sys/menu/insert')),
  188. success: function () {
  189. $.yvan.msg('操作成功');
  190. if (context.isEdit) {
  191. $dlg.window('close');
  192. }
  193. if ($.type(context.confirm) === 'function') {
  194. context.confirm();
  195. }
  196. },
  197. error: function (data) {
  198. }
  199. });
  200. }
  201. }, {
  202. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  203. $dlg.dialog('close');
  204. }
  205. }
  206. ]
  207. };
  208. };
  209. });