editApplicationKey.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. (function(vc,vm){
  2. vc.extends({
  3. data:{
  4. editApplicationKeyInfo:{
  5. applicationKeyId:'',
  6. name:'',
  7. tel:'',
  8. typeCd:'',
  9. sex:'',
  10. age:'',
  11. idCard:'',
  12. startTime:'',
  13. endTime:'',
  14. }
  15. },
  16. _initMethod:function(){
  17. },
  18. _initEvent:function(){
  19. vc.on('editApplicationKey','openEditApplicationKeyModal',function(_params){
  20. vc.component.refreshEditApplicationKeyInfo();
  21. $('#editApplicationKeyModel').modal('show');
  22. vc.copyObject(_params, vc.component.editApplicationKeyInfo );
  23. vc.component.editApplicationKeyInfo.communityId = vc.getCurrentCommunity().communityId;
  24. });
  25. },
  26. methods:{
  27. editApplicationKeyValidate:function(){
  28. return vc.validate.validate({
  29. editApplicationKeyInfo:vc.component.editApplicationKeyInfo
  30. },{
  31. 'editApplicationKeyInfo.name':[
  32. {
  33. limit:"required",
  34. param:"",
  35. errInfo:"姓名不能为空"
  36. },
  37. {
  38. limit:"maxin",
  39. param:"1,64",
  40. errInfo:"姓名不能超过64位"
  41. },
  42. ],
  43. 'editApplicationKeyInfo.tel':[
  44. {
  45. limit:"required",
  46. param:"",
  47. errInfo:"手机号不能为空"
  48. },
  49. {
  50. limit:"phone",
  51. param:"",
  52. errInfo:"手机号格式错误"
  53. },
  54. ],
  55. 'editApplicationKeyInfo.typeCd':[
  56. {
  57. limit:"required",
  58. param:"",
  59. errInfo:"用户类型不能为空"
  60. },
  61. {
  62. limit:"num",
  63. param:"",
  64. errInfo:"用户类型格式错误"
  65. },
  66. ],
  67. 'editApplicationKeyInfo.sex':[
  68. {
  69. limit:"required",
  70. param:"",
  71. errInfo:"性别不能为空"
  72. },
  73. {
  74. limit:"num",
  75. param:"",
  76. errInfo:"性别格式错误"
  77. },
  78. ],
  79. 'editApplicationKeyInfo.age':[
  80. {
  81. limit:"required",
  82. param:"",
  83. errInfo:"年龄不能为空"
  84. },
  85. {
  86. limit:"num",
  87. param:"",
  88. errInfo:"年龄不是有效数字"
  89. },
  90. ],
  91. 'editApplicationKeyInfo.idCard':[
  92. {
  93. limit:"required",
  94. param:"",
  95. errInfo:"身份证号不能为空"
  96. },
  97. {
  98. limit:"idCard",
  99. param:"",
  100. errInfo:"不是有效的身份证号"
  101. },
  102. ],
  103. 'editApplicationKeyInfo.startTime':[
  104. {
  105. limit:"required",
  106. param:"",
  107. errInfo:"开始时间不能为空"
  108. },
  109. {
  110. limit:"dateTime",
  111. param:"",
  112. errInfo:"不是有效的时间格式"
  113. },
  114. ],
  115. 'editApplicationKeyInfo.endTime':[
  116. {
  117. limit:"required",
  118. param:"",
  119. errInfo:"结束时间不能为空"
  120. },
  121. {
  122. limit:"dateTime",
  123. param:"",
  124. errInfo:"不是有效的时间格式"
  125. },
  126. ],
  127. 'editApplicationKeyInfo.applicationKeyId':[
  128. {
  129. limit:"required",
  130. param:"",
  131. errInfo:"钥匙申请ID不能为空"
  132. }]
  133. });
  134. },
  135. editApplicationKey:function(){
  136. if(!vc.component.editApplicationKeyValidate()){
  137. vc.message(vc.validate.errInfo);
  138. return ;
  139. }
  140. vc.http.post(
  141. 'editApplicationKey',
  142. 'update',
  143. JSON.stringify(vc.component.editApplicationKeyInfo),
  144. {
  145. emulateJSON:true
  146. },
  147. function(json,res){
  148. //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
  149. if(res.status == 200){
  150. //关闭model
  151. $('#editApplicationKeyModel').modal('hide');
  152. vc.emit('applicationKeyManage','listApplicationKey',{});
  153. return ;
  154. }
  155. vc.message(json);
  156. },
  157. function(errInfo,error){
  158. console.log('请求失败处理');
  159. vc.message(errInfo);
  160. });
  161. },
  162. refreshEditApplicationKeyInfo:function(){
  163. vc.component.editApplicationKeyInfo= {
  164. applicationKeyId:'',
  165. name:'',
  166. tel:'',
  167. typeCd:'',
  168. sex:'',
  169. age:'',
  170. idCard:'',
  171. startTime:'',
  172. endTime:'',
  173. }
  174. }
  175. }
  176. });
  177. })(window.vc,window.vc.component);