SchoolInfo.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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: '/api/school/school/read',
  12. layout: 'column',
  13. autoScroll: true,
  14. bodyPadding: '12 250 12 250',
  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: 'bottom',
  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: 'textfield',
  40. name: 'school_id',
  41. bind: '{schoolId}',
  42. fieldLabel: '学校ID',
  43. columnWidth: 1,
  44. readOnly: true
  45. }, {
  46. xtype: "textfield",
  47. name: "school_name",
  48. bind: '{schoolName}',
  49. fieldLabel: "学校名称",
  50. allowBlank: false,
  51. columnWidth: 1,
  52. maxLength: 100
  53. }, {
  54. xtype: "textfield",
  55. name: 'school_phone',
  56. bind: '{schoolPhone}',
  57. fieldLabel: '联系电话',
  58. columnWidth: 1,
  59. maxLength: 50
  60. }, {
  61. xtype: "textfield",
  62. name: "school_address",
  63. bind: '{schoolAddress}',
  64. fieldLabel: "学校地址",
  65. allowBlank: true,
  66. columnWidth: 1,
  67. maxLength: 200
  68. }, {
  69. xtype: 'combobox',
  70. name: 'school_status',
  71. bind: '{schoolStatus}',
  72. fieldLabel: '状态',
  73. displayField: 'name',
  74. valueField: 'value',
  75. queryMode: 'local',
  76. editable: false,
  77. store: Ext.create('Ext.data.Store', {
  78. fields: ['name', 'value'],
  79. data: [{
  80. name: '正常',
  81. value: 1
  82. }, {
  83. name: '冻结',
  84. value: 2
  85. }]
  86. }),
  87. columnWidth: 1
  88. }, {
  89. xtype: 'textfield',
  90. name: 'school_appid',
  91. bind: '{schoolAppId}',
  92. fieldLabel: '公众号账号',
  93. readOnly: true,
  94. columnWidth: 1
  95. }, {
  96. xtype: 'textfield',
  97. name: 'school_secret',
  98. bind: '{schoolSecret}',
  99. fieldLabel: '公众号密钥',
  100. columnWidth: 1,
  101. readOnly: true
  102. }, {
  103. xtype: 'textfield',
  104. name: 'school_remarks',
  105. bind: '{schoolRemarks}',
  106. fieldLabel: '备注',
  107. columnWidth: 1,
  108. maxLength: 250
  109. }]
  110. });
  111. this.callParent();
  112. },
  113. onSave: function() {
  114. let me = this,
  115. values = me.getValues();
  116. me.setLoading(true);
  117. school.util.BaseUtil.request({
  118. // url: 'http://10.1.80.35:9560/school/save',
  119. url: '/api/school/school/save',
  120. method: 'POST',
  121. params: JSON.stringify(values)
  122. })
  123. .then(function() {
  124. me.setLoading(false);
  125. school.util.BaseUtil.showSuccessToast('资料更新成功');
  126. me.clearDirty();
  127. })
  128. .catch(function(e) {
  129. me.setLoading(false);
  130. school.util.BaseUtil.showErrorToast('资料更新失败: ' + e.message);
  131. });
  132. },
  133. clearDirty: function() {
  134. let me = this;
  135. let fields = me.getForm().getFields().items;
  136. Ext.Array.each(fields, function(f) {
  137. f.resetOriginalValue ? f.resetOriginalValue() : '';
  138. });
  139. },
  140. //overriders
  141. isValid: function() {
  142. let me = this;
  143. let viewModel = me.getViewModel();
  144. let formItems = me.getForm().getFields().items;
  145. let valid = !Ext.Array.findBy(formItems, function(f) {
  146. return !f.isValid();
  147. });
  148. viewModel.set('formValid', valid);
  149. return valid;
  150. },
  151. });