glj.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Created by Mai on 2017/4/1.
  3. */
  4. var GLJ = {
  5. createNew: function (project) {
  6. // 用户定义private方法
  7. var tools = {};
  8. // 所有通过this访问的属性,都不应在此单元外部进行写入操作
  9. var glj = function (proj) {
  10. this.project = proj;
  11. this.datas = null;
  12. var sourceType = ModuleNames.GLJ;
  13. this.getSourceType = function () {
  14. return sourceType;
  15. }
  16. proj.registerModule(ModuleNames.GLJ, this);
  17. };
  18. // 从后台获取数据
  19. glj.prototype.pullData = function (){
  20. this.project.pullData(
  21. '/glj/getData',
  22. {projectID: this.project.ID},
  23. function(result){
  24. if (result.error ===0){
  25. this.loadDatas(result.data);
  26. }
  27. else {
  28. // to do: 错误处理需要细化
  29. alert(result.message);
  30. }
  31. },
  32. function (){/* to do: 错误处理需要细化*/}
  33. )
  34. };
  35. // prototype用于定义public方法
  36. glj.prototype.loadDatas = function (datas) {
  37. this.datas = datas;
  38. };
  39. // 提交数据后的错误处理方法
  40. glj.prototype.doAfterUpdate = function(err, data){
  41. // to do
  42. };
  43. return new glj(project);
  44. }
  45. };