addMapping.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. (function(vc){
  2. vc.extends({
  3. data:{
  4. addMappingInfo:{
  5. domain:'DOMAIN.COMMON',
  6. name:'',
  7. key:'',
  8. value:'',
  9. remark:'',
  10. }
  11. },
  12. _initMethod:function(){
  13. },
  14. _initEvent:function(){
  15. vc.on('addMapping','openAddMappingModal',function(){
  16. $('#addMappingModel').modal('show');
  17. });
  18. },
  19. methods:{
  20. addMappingValidate(){
  21. return vc.validate.validate({
  22. addMappingInfo:vc.component.addMappingInfo
  23. },{
  24. 'addMappingInfo.domain':[
  25. {
  26. limit:"required",
  27. param:"",
  28. errInfo:"域不能为空"
  29. },
  30. {
  31. limit:"maxLength",
  32. param:"50",
  33. errInfo:"域长度不能超过50"
  34. },
  35. ],
  36. 'addMappingInfo.name':[
  37. {
  38. limit:"required",
  39. param:"",
  40. errInfo:"名称不能为空"
  41. },
  42. {
  43. limit:"maxin",
  44. param:"2,50",
  45. errInfo:"名称必须在2至50字符之间"
  46. },
  47. ],
  48. 'addMappingInfo.key':[
  49. {
  50. limit:"required",
  51. param:"",
  52. errInfo:"键不能为空"
  53. },
  54. {
  55. limit:"maxin",
  56. param:"1,100",
  57. errInfo:"键必须在1至100之间"
  58. },
  59. ],
  60. 'addMappingInfo.value':[
  61. {
  62. limit:"required",
  63. param:"",
  64. errInfo:"值不能为空"
  65. },
  66. {
  67. limit:"maxin",
  68. param:"1,100",
  69. errInfo:"值必须在1至100之间"
  70. },
  71. ],
  72. 'addMappingInfo.remark':[
  73. {
  74. limit:"maxLength",
  75. param:"200",
  76. errInfo:"备注内容不能超过200"
  77. },
  78. ],
  79. });
  80. },
  81. saveMappingInfo:function(){
  82. if(!vc.component.addMappingValidate()){
  83. vc.message(vc.validate.errInfo);
  84. return ;
  85. }
  86. vc.component.addMappingInfo.communityId = vc.getCurrentCommunity().communityId;
  87. vc.http.post(
  88. 'addMapping',
  89. 'save',
  90. JSON.stringify(vc.component.addMappingInfo),
  91. {
  92. emulateJSON:true
  93. },
  94. function(json,res){
  95. //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
  96. if(res.status == 200){
  97. //关闭model
  98. $('#addMappingModel').modal('hide');
  99. vc.component.clearAddMappingInfo();
  100. vc.emit('mappingManage','listMapping',{});
  101. return ;
  102. }
  103. vc.message(json);
  104. },
  105. function(errInfo,error){
  106. console.log('请求失败处理');
  107. vc.message(errInfo);
  108. });
  109. },
  110. clearAddMappingInfo:function(){
  111. vc.component.addMappingInfo = {
  112. domain:'DOMAIN.COMMON',
  113. name:'',
  114. key:'',
  115. value:'',
  116. remark:'',
  117. };
  118. }
  119. }
  120. });
  121. })(window.vc);