SchoolInfo.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * 学校信息
  3. */
  4. Ext.define('school.view.basic.school.SchoolInfo', {
  5. // extend: 'school.view.core.form.FormPanel',
  6. extend: 'Ext.form.Panel',
  7. xtype: 'basic-school-schoolinfo',
  8. // controller: 'purchase-purchase-formpanel',
  9. // viewModel: 'purchase-purchase-formpanel',
  10. // readUrl: 'http://10.1.80.35:9560/school/read',
  11. readUrl: '/school/read',
  12. layout: 'column',
  13. autoScroll: true,
  14. bodyPadding: '8 12 8 12',
  15. fieldDefaults: {
  16. margin: '0 0 10 0',
  17. labelAlign: 'right',
  18. labelWidth: 90,
  19. columnWidth: 0.25,
  20. },
  21. initComponent: function () {
  22. var me = this;
  23. Ext.apply(this, {
  24. dockedItems: [{
  25. xtype: 'toolbar',
  26. dock: 'top',
  27. items: ['->', {
  28. xtype: 'button',
  29. text: '更新',
  30. bind: {
  31. disabled: '{!formValid}'
  32. },
  33. handler: function() {
  34. me.onSave();
  35. }
  36. }],
  37. }],
  38. items: [{
  39. xtype: 'hidden',
  40. name: 'school_id',
  41. bind: '{schoolId}',
  42. fieldLabel: 'id'
  43. }, {
  44. xtype: "textfield",
  45. name: "school_name",
  46. bind: '{schoolName}',
  47. fieldLabel: "学校名称",
  48. allowBlank: false,
  49. columnWidth: 0.5
  50. }, {
  51. xtype: 'textfield',
  52. name: 'school_status',
  53. bind: '{schoolStatus}',
  54. fieldLabel: '状态',
  55. }, {
  56. xtype: "textfield",
  57. name: "school_address",
  58. bind: '{schoolAddress}',
  59. fieldLabel: "学校地址",
  60. allowBlank: true,
  61. columnWidth: 1
  62. }, {
  63. xtype: "textfield",
  64. name: 'school_phone',
  65. bind: '{schoolPhone}',
  66. fieldLabel: '联系电话'
  67. }, {
  68. xtype: 'textfield',
  69. name: 'school_appid',
  70. bind: '{schoolAppId}',
  71. fieldLabel: '绑定微信号'
  72. }, {
  73. xtype: 'textfield',
  74. name: 'school_remarks',
  75. bind: '{schoolRemarks}',
  76. fieldLabel: '备注',
  77. columnWidth: 1
  78. }]
  79. });
  80. this.callParent();
  81. },
  82. onSave: function() {
  83. let me = this,
  84. values = me.getValues();
  85. me.setLoading(true);
  86. school.util.BaseUtil.request({
  87. // url: 'http://10.1.80.35:9560/school/save',
  88. url: '/school/save',
  89. method: 'POST',
  90. params: JSON.stringify(values)
  91. })
  92. .then(function() {
  93. me.setLoading(false);
  94. school.util.BaseUtil.showSuccessToast('资料更新成功');
  95. me.clearDirty();
  96. })
  97. .catch(function(e) {
  98. me.setLoading(false);
  99. school.util.BaseUtil.showErrorToast('资料更新失败: ' + e.message);
  100. });
  101. },
  102. clearDirty: function() {
  103. let me = this;
  104. let fields = me.getForm().getFields().items;
  105. Ext.Array.each(fields, function(f) {
  106. f.resetOriginalValue ? f.resetOriginalValue() : '';
  107. });
  108. },
  109. //overriders
  110. isValid: function() {
  111. let me = this;
  112. let viewModel = me.getViewModel();
  113. let formItems = me.getForm().getFields().items;
  114. let valid = !Ext.Array.findBy(formItems, function(f) {
  115. return !f.isValid();
  116. });
  117. viewModel.set('formValid', valid);
  118. return valid;
  119. },
  120. });