ClassDetailController.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Ext.define('school.view.basic.class.ClassDetailController', {
  2. extend: 'school.view.core.form.FormPanelController',
  3. alias: 'controller.classdetail',
  4. onAfterSave: function(localJson) {
  5. let me = this;
  6. me.refresh(localJson.data.id);
  7. },
  8. refresh: function(id) {
  9. let me = this,
  10. view = me.getView();
  11. school.util.BaseUtil.request({
  12. url: view._readUrl + '/' + id
  13. }).then(function(res) {
  14. view.setLoading(false);
  15. if(res.success) {
  16. let d = res.data;
  17. let o = {
  18. main: d.main
  19. };
  20. if(d.hasOwnProperty('items')) {
  21. o.detail0 = d.items;
  22. }else {
  23. let idx = 1;
  24. while(d.hasOwnProperty('items' + idx)) {
  25. o['detail' + (idx - 1)] = d['items' + idx];
  26. idx++;
  27. }
  28. }
  29. view.initFormData(o);
  30. view.fireEvent('load', classDetail, o);
  31. }
  32. }).catch(function(e) {
  33. school.util.BaseUtil.showErrorToast('请求数据失败: ' + e.message);
  34. });
  35. }
  36. });