add.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. (function(vc){
  2. vc.extends({
  3. propTypes: {
  4. callBackListener:vc.propTypes.string, //父组件名称
  5. callBackFunction:vc.propTypes.string //父组件监听方法
  6. },
  7. data:{
  8. add@@TemplateCode@@Info:{
  9. @@templateKey@@:'',
  10. @@templateCodeColumns@@
  11. }
  12. },
  13. _initMethod:function(){
  14. },
  15. _initEvent:function(){
  16. vc.on('add@@TemplateCode@@','openAdd@@TemplateCode@@Modal',function(){
  17. $('#add@@TemplateCode@@Model').modal('show');
  18. });
  19. },
  20. methods:{
  21. add@@TemplateCode@@Validate(){
  22. return vc.validate.validate({
  23. add@@TemplateCode@@Info:vc.component.add@@TemplateCode@@Info
  24. },{
  25. @@addTemplateCodeValidate@@
  26. });
  27. },
  28. save@@TemplateCode@@Info:function(){
  29. if(!vc.component.add@@TemplateCode@@Validate()){
  30. vc.toast(vc.validate.errInfo);
  31. return ;
  32. }
  33. vc.component.add@@TemplateCode@@Info.communityId = vc.getCurrentCommunity().communityId;
  34. //不提交数据将数据 回调给侦听处理
  35. if(vc.notNull($props.callBackListener)){
  36. vc.emit($props.callBackListener,$props.callBackFunction,vc.component.add@@TemplateCode@@Info);
  37. $('#add@@TemplateCode@@Model').modal('hide');
  38. return ;
  39. }
  40. vc.http.apiPost(
  41. '@@templateCode@@.save@@TemplateCode@@',
  42. JSON.stringify(vc.component.add@@TemplateCode@@Info),
  43. {
  44. emulateJSON:true
  45. },
  46. function(json,res){
  47. //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
  48. if(res.status == 200){
  49. //关闭model
  50. $('#add@@TemplateCode@@Model').modal('hide');
  51. vc.component.clearAdd@@TemplateCode@@Info();
  52. vc.emit('@@templateCode@@Manage','list@@TemplateCode@@',{});
  53. return ;
  54. }
  55. vc.message(json);
  56. },
  57. function(errInfo,error){
  58. console.log('请求失败处理');
  59. vc.message(errInfo);
  60. });
  61. },
  62. clearAdd@@TemplateCode@@Info:function(){
  63. vc.component.add@@TemplateCode@@Info = {
  64. @@templateCodeColumns@@
  65. };
  66. }
  67. }
  68. });
  69. })(window.vc);