ViewportModel.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Ext.define('school.view.viewport.ViewportModel', {
  2. extend: 'Ext.app.ViewModel',
  3. alias: 'viewmodel.viewport',
  4. data: {
  5. account: null
  6. },
  7. formulas: {
  8. company: function (get) {
  9. var account = get('account');
  10. return account && account.companies.find(function (c) {
  11. return c.id == account.companyId;
  12. });
  13. },
  14. avatarUrl: function (get) {
  15. var account = get('account');
  16. return (account && account.avatarUrl) || 'resources/images/default/user-icon.png'
  17. }
  18. },
  19. stores: {
  20. store_navigationMenu: {
  21. autoLoad: true,
  22. fields: ['text', 'iconCls'],
  23. proxy: {
  24. type: 'ajax',
  25. url: 'resources/json/navigation.json',
  26. reader: {
  27. type: 'json'
  28. }
  29. }
  30. },
  31. store_grade: {
  32. type: 'tree',
  33. autoLoad: true,
  34. // model: 'school.model.Grade',
  35. fields: [{
  36. name: 'text'
  37. }],
  38. proxy: {
  39. type: 'ajax',
  40. // url: 'http://10.1.80.35:9520/grade/read/1',
  41. url: '/grade/read/1',
  42. reader: {
  43. transform: {
  44. fn: function(data) {
  45. let schools = data.data.children;
  46. schools.map(function(s) {
  47. s.id = 'school-' + s.id;
  48. let classes = s.children;
  49. classes.map(function(c) {
  50. c._id = c.id;
  51. c.id = 'class-' + c.id;
  52. return c;
  53. });
  54. return s;
  55. });
  56. return schools;
  57. },
  58. scope: this
  59. }
  60. }
  61. },
  62. root: {
  63. text: '全年级',
  64. type: 'SCHOOL',
  65. expanded: true
  66. },
  67. }
  68. }
  69. });