addNoticeView.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. (function(vc){
  2. vc.extends({
  3. data:{
  4. addNoticeViewInfo:{
  5. title:'',
  6. noticeTypeCd:'',
  7. context:'',
  8. startTime:'',
  9. endTime:'',
  10. }
  11. },
  12. _initMethod:function(){
  13. vc.component._initNoticeInfo();
  14. },
  15. _initEvent:function(){
  16. vc.on('addNoticeView','openAddNoticeView',function(){
  17. //vc.component._initNoticeInfo();
  18. });
  19. },
  20. methods:{
  21. addNoticeValidate(){
  22. return vc.validate.validate({
  23. addNoticeViewInfo:vc.component.addNoticeViewInfo
  24. },{
  25. 'addNoticeViewInfo.title':[
  26. {
  27. limit:"required",
  28. param:"",
  29. errInfo:"标题不能为空"
  30. },
  31. {
  32. limit:"maxin",
  33. param:"4,100",
  34. errInfo:"小区名称必须在2至100字符之间"
  35. },
  36. ],
  37. 'addNoticeViewInfo.noticeTypeCd':[
  38. {
  39. limit:"required",
  40. param:"",
  41. errInfo:"公告类型不能为空"
  42. },
  43. {
  44. limit:"maxLength",
  45. param:"200",
  46. errInfo:"公告类型错误"
  47. },
  48. ],
  49. 'addNoticeViewInfo.context':[
  50. {
  51. limit:"required",
  52. param:"",
  53. errInfo:"公告内容不能为空"
  54. },
  55. {
  56. limit:"maxLength",
  57. param:"10000",
  58. errInfo:"公告内容不能超过10000个字"
  59. },
  60. ],
  61. 'addNoticeViewInfo.startTime':[
  62. {
  63. limit:"required",
  64. param:"",
  65. errInfo:"开始时间不能为空"
  66. },
  67. {
  68. limit:"dateTime",
  69. param:"",
  70. errInfo:"开始时间不是有效的日期"
  71. },
  72. ],
  73. 'addNoticeViewInfo.endTime':[
  74. {
  75. limit:"required",
  76. param:"",
  77. errInfo:"开始时间不能为空"
  78. },
  79. {
  80. limit:"dateTime",
  81. param:"",
  82. errInfo:"开始时间不是有效的日期"
  83. },
  84. ],
  85. });
  86. },
  87. saveNoticeInfo:function(){
  88. if(!vc.component.addNoticeValidate()){
  89. vc.message(vc.validate.errInfo);
  90. return ;
  91. }
  92. vc.component.addNoticeViewInfo.communityId = vc.getCurrentCommunity().communityId;
  93. vc.http.post(
  94. 'addNotice',
  95. 'save',
  96. JSON.stringify(vc.component.addNoticeViewInfo),
  97. {
  98. emulateJSON:true
  99. },
  100. function(json,res){
  101. //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
  102. if(res.status == 200){
  103. //关闭model
  104. vc.component.clearaddNoticeViewInfo();
  105. vc.emit('noticeManage','listNotice',{});
  106. return ;
  107. }
  108. vc.message(json);
  109. },
  110. function(errInfo,error){
  111. console.log('请求失败处理');
  112. vc.message(errInfo);
  113. });
  114. },
  115. clearaddNoticeViewInfo:function(){
  116. vc.component.addNoticeViewInfo = {
  117. title:'',
  118. noticeTypeCd:'',
  119. context:'',
  120. startTime:'',
  121. };
  122. },
  123. _initNoticeInfo:function(){
  124. vc.component.addNoticeViewInfo.startTime = vc.dateFormat(new Date().getTime());
  125. $('.noticeStartTime').datetimepicker({
  126. language: 'zh-CN',
  127. format: 'yyyy-mm-dd HH:ii:ss',
  128. initTime: true,
  129. initialDate: new Date(),
  130. autoClose: 1,
  131. todayBtn: true
  132. });
  133. $('.noticeStartTime').datetimepicker()
  134. .on('changeDate', function (ev) {
  135. var value = $(".noticeStartTime").val();
  136. vc.component.addNoticeViewInfo.startTime = value;
  137. });
  138. $('.noticeEndTime').datetimepicker({
  139. language: 'zh-CN',
  140. format: 'yyyy-mm-dd HH:ii:ss',
  141. initTime: true,
  142. initialDate: new Date(),
  143. autoClose: 1,
  144. todayBtn: true
  145. });
  146. $('.noticeEndTime').datetimepicker()
  147. .on('changeDate', function (ev) {
  148. var value = $(".noticeEndTime").val();
  149. vc.component.addNoticeViewInfo.endTime = value;
  150. });
  151. $('.summernote').summernote({
  152. lang:'zh-CN',
  153. height: 300,
  154. placeholder:'必填,请输入公告内容',
  155. callbacks : {
  156. onImageUpload: function(files, editor, $editable) {
  157. sendFile(files);
  158. },
  159. onChange:function(contents,$editable){
  160. vc.component.addNoticeViewInfo.context = contents;
  161. }
  162. },
  163. toolbar: [
  164. ['style', ['style']],
  165. ['font', ['bold', 'italic', 'underline', 'clear']],
  166. ['fontname', ['fontname']],
  167. ['color', ['color']],
  168. ['para', ['ul', 'ol', 'paragraph']],
  169. ['height', ['height']],
  170. ['table', ['table']],
  171. ['insert', ['link', 'picture']],
  172. ['view', ['fullscreen', 'codeview']],
  173. ['help', ['help']]
  174. ],
  175. });
  176. },
  177. closeNoticeInfo:function(){
  178. vc.emit('noticeManage','listNotice',{});
  179. },
  180. sendFile:function(files){
  181. console.log('上传图片');
  182. }
  183. }
  184. });
  185. })(window.vc);