factory.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. starter.factory('Task', function ($http, $q, $resource, cfg, global, formatFilter, showPopup, Tool) {
  2. function check(task_item) {
  3. console.log(task_item)
  4. if (task_item.content == null || task_item.content == '') {
  5. showPopup.PopupWindow(0, '请输入任务详情', false);
  6. return false;
  7. } else if (task_item.task_members.length == 0) {
  8. showPopup.PopupWindow(0, '请选择负责人', false);
  9. return false;
  10. } else {
  11. return true;
  12. }
  13. }
  14. return {
  15. task: function (url) {
  16. return url == null ? $resource(formatFilter('{0}task/task/:id/', cfg.api), null, {update: {method: 'PUT'}}) : $resource(url)
  17. },
  18. taskchild: $resource(formatFilter('{0}task/task/:id/children/', cfg.api)),
  19. taskmember: $resource(formatFilter('{0}task/member/', cfg.api)),
  20. taskcomment: function (url) {
  21. return url == null ? $resource(formatFilter('{0}task/comment/:id/', cfg.api)) : $resource(url)
  22. },
  23. taskhistory: function (url) {
  24. return url == null ? $resource(formatFilter('{0}task/history/', cfg.api)) : $resource(url)
  25. },
  26. taskfile: $resource(formatFilter('{0}task/file/', cfg.api)),
  27. taskcommentfile: $resource(formatFilter('{0}task/commentfile/', cfg.api)),
  28. taskpreferences: $resource(formatFilter('{0}preferences/', cfg.api)),
  29. taskdetail: {},
  30. check: function (task_item) {
  31. return check(task_item);
  32. }
  33. }
  34. });