editMenu.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. (function(vc,vm){
  2. vc.extends({
  3. data:{
  4. editMenuInfo:{
  5. mId:'',
  6. name:'',
  7. url:'',
  8. seq:'',
  9. isShow:'',
  10. description:'',
  11. }
  12. },
  13. _initMethod:function(){
  14. },
  15. _initEvent:function(){
  16. vc.on('editMenu','openEditMenuModal',function(_params){
  17. vc.component.refreshEditMenuInfo();
  18. $('#editMenuModel').modal('show');
  19. vc.copyObject(_params, vc.component.editMenuInfo );
  20. vc.component.editMenuInfo.communityId = vc.getCurrentCommunity().communityId;
  21. });
  22. },
  23. methods:{
  24. editMenuValidate:function(){
  25. return vc.validate.validate({
  26. editMenuInfo:vc.component.editMenuInfo
  27. },{
  28. 'editMenuInfo.name':[
  29. {
  30. limit:"required",
  31. param:"",
  32. errInfo:"菜单名称不能为空"
  33. },
  34. {
  35. limit:"maxin",
  36. param:"2,10",
  37. errInfo:"菜单名称必须在2至10字符之间"
  38. },
  39. ],
  40. 'editMenuInfo.url':[
  41. {
  42. limit:"required",
  43. param:"",
  44. errInfo:"菜单地址不能为空"
  45. },
  46. {
  47. limit:"maxLength",
  48. param:"200",
  49. errInfo:"菜单地址不能超过200"
  50. },
  51. ],
  52. 'editMenuInfo.seq':[
  53. {
  54. limit:"required",
  55. param:"",
  56. errInfo:"序列不能为空"
  57. },
  58. {
  59. limit:"num",
  60. param:"",
  61. errInfo:"序列必须为整数"
  62. },
  63. ],
  64. 'editMenuInfo.isShow':[
  65. {
  66. limit:"required",
  67. param:"",
  68. errInfo:"菜单显示不能为空"
  69. },
  70. {
  71. limit:"maxin",
  72. param:"1,12",
  73. errInfo:"菜单显示错误"
  74. },
  75. ],
  76. 'editMenuInfo.description':[
  77. {
  78. limit:"maxLength",
  79. param:"200",
  80. errInfo:"备注内容不能超过200"
  81. },
  82. ],
  83. 'editMenuInfo.mId':[
  84. {
  85. limit:"required",
  86. param:"",
  87. errInfo:"菜单ID不能为空"
  88. }]
  89. });
  90. },
  91. editMenu:function(){
  92. if(!vc.component.editMenuValidate()){
  93. vc.message(vc.validate.errInfo);
  94. return ;
  95. }
  96. vc.http.post(
  97. 'editMenu',
  98. 'update',
  99. JSON.stringify(vc.component.editMenuInfo),
  100. {
  101. emulateJSON:true
  102. },
  103. function(json,res){
  104. //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
  105. if(res.status == 200){
  106. //关闭model
  107. $('#editMenuModel').modal('hide');
  108. vc.emit('menuManage','listMenu',{});
  109. return ;
  110. }
  111. vc.message(json);
  112. },
  113. function(errInfo,error){
  114. console.log('请求失败处理');
  115. vc.message(errInfo);
  116. });
  117. },
  118. refreshEditMenuInfo:function(){
  119. vc.component.editMenuInfo= {
  120. mId:'',
  121. name:'',
  122. url:'',
  123. seq:'',
  124. isShow:'',
  125. description:'',
  126. }
  127. }
  128. }
  129. });
  130. })(window.vc,window.vc.component);