editMapping.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. (function(vc,vm){
  2. vc.extends({
  3. data:{
  4. editMappingInfo:{
  5. id:'',
  6. domain:'DOMAIN.COMMON',
  7. name:'',
  8. key:'',
  9. value:'',
  10. remark:'',
  11. }
  12. },
  13. _initMethod:function(){
  14. },
  15. _initEvent:function(){
  16. vc.on('editMapping','openEditMappingModal',function(_params){
  17. vc.component.refreshEditMappingInfo();
  18. $('#editMappingModel').modal('show');
  19. vc.copyObject(_params, vc.component.editMappingInfo );
  20. // vc.component.editMappingInfo.communityId = vc.getCurrentCommunity().communityId;
  21. });
  22. },
  23. methods:{
  24. editMappingValidate:function(){
  25. return vc.validate.validate({
  26. editMappingInfo:vc.component.editMappingInfo
  27. },{
  28. 'editMappingInfo.domain':[
  29. {
  30. limit:"required",
  31. param:"",
  32. errInfo:"域不能为空"
  33. },
  34. {
  35. limit:"maxLength",
  36. param:"50",
  37. errInfo:"域长度不能超过50"
  38. },
  39. ],
  40. 'editMappingInfo.name':[
  41. {
  42. limit:"required",
  43. param:"",
  44. errInfo:"名称不能为空"
  45. },
  46. {
  47. limit:"maxin",
  48. param:"2,50",
  49. errInfo:"名称必须在2至50字符之间"
  50. },
  51. ],
  52. 'editMappingInfo.key':[
  53. {
  54. limit:"required",
  55. param:"",
  56. errInfo:"键不能为空"
  57. },
  58. {
  59. limit:"maxin",
  60. param:"1,100",
  61. errInfo:"键必须在1至100之间"
  62. },
  63. ],
  64. 'editMappingInfo.value':[
  65. {
  66. limit:"required",
  67. param:"",
  68. errInfo:"值不能为空"
  69. },
  70. {
  71. limit:"maxin",
  72. param:"1,100",
  73. errInfo:"值必须在1至100之间"
  74. },
  75. ],
  76. 'editMappingInfo.remark':[
  77. {
  78. limit:"maxLength",
  79. param:"200",
  80. errInfo:"备注内容不能超过200"
  81. },
  82. ],
  83. 'editMappingInfo.id':[
  84. {
  85. limit:"required",
  86. param:"",
  87. errInfo:"编码ID不能为空"
  88. }]
  89. });
  90. },
  91. editMapping:function(){
  92. if(!vc.component.editMappingValidate()){
  93. vc.message(vc.validate.errInfo);
  94. return ;
  95. }
  96. vc.http.post(
  97. 'editMapping',
  98. 'update',
  99. JSON.stringify(vc.component.editMappingInfo),
  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. $('#editMappingModel').modal('hide');
  108. vc.emit('mappingManage','listMapping',{});
  109. return ;
  110. }
  111. vc.message(json);
  112. },
  113. function(errInfo,error){
  114. console.log('请求失败处理');
  115. vc.message(errInfo);
  116. });
  117. },
  118. refreshEditMappingInfo:function(){
  119. vc.component.editMappingInfo= {
  120. id:'',
  121. domain:'DOMAIN.COMMON',
  122. name:'',
  123. key:'',
  124. value:'',
  125. remark:'',
  126. }
  127. }
  128. }
  129. });
  130. })(window.vc,window.vc.component);