project_glj.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * 工料机汇总相关数据
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/9/14
  6. * @version
  7. */
  8. function ProjectGLJ() {
  9. this.datas = null;
  10. this.isLoading = false;
  11. }
  12. /**
  13. * 加载数据
  14. *
  15. * @return {boolean}
  16. */
  17. ProjectGLJ.prototype.loadData = function () {
  18. let self = this;
  19. if (self.isLoading) {
  20. return false;
  21. }
  22. // 加载工料机数据
  23. $.ajax({
  24. url: '/glj/getData',
  25. type: 'post',
  26. dataType: 'json',
  27. data: {project_id: scUrlUtil.GetQueryString('project')},
  28. error: function() {
  29. // alert('数据传输错误');
  30. },
  31. beforeSend: function() {
  32. self.isLoading = true;
  33. },
  34. success: function(response) {
  35. if (response.err === 1) {
  36. let msg = response.msg !== undefined && response.msg !== '' ? response.msg : '读取工料机数据失败!';
  37. alert(msg);
  38. return false;
  39. }
  40. self.datas = response.data;
  41. // 存入缓存
  42. projectObj.project.projectGLJ = self;
  43. }
  44. });
  45. };
  46. /**
  47. * 获取对应工料机数据
  48. *
  49. * @param {String} code
  50. * @return {Object}
  51. */
  52. ProjectGLJ.prototype.getDataByCode = function (code) {
  53. let result = {};
  54. if (this.datas === null) {
  55. return result;
  56. }
  57. let gljList = this.datas.gljList;
  58. if (gljList === undefined) {
  59. return result;
  60. }
  61. for(let tmp of gljList) {
  62. if (tmp.code === code) {
  63. result = tmp;
  64. break;
  65. }
  66. }
  67. return result;
  68. };
  69. /**
  70. * 修改工料机数据
  71. *
  72. * @param {String} code
  73. * @param {Object} data
  74. * @return {boolean}
  75. */
  76. ProjectGLJ.prototype.updateData = function(code, data) {
  77. };