SchoolInfo.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.36:9520/api/school/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: "hidden",
  55. name: 'teacher_id',
  56. bind: '{TeacherId}',
  57. fieldLabel: '校长ID',
  58. columnWidth: 1
  59. }, {
  60. name: 'teacher_name',
  61. bind: '{TeacherName}',
  62. fieldLabel: '校长',
  63. columnWidth: 1,
  64. maxLength: 20,
  65. addTitle: '教师',
  66. xtype: 'dbfindtrigger',
  67. //数据接口
  68. dataUrl:'/api/school/mirror/findTeacher',
  69. //联想设置
  70. dbtpls:[{
  71. field:'teacher_name',width:150
  72. }],
  73. dbfinds:[{
  74. from: 'teacher_name', to: 'teacher_name',
  75. }, {
  76. from: 'teacher_id', to: 'teacher_id'
  77. }],
  78. defaultCondition: "1=1",
  79. dbSearchFields:[{
  80. emptyText:'请输入教师工号或姓名',
  81. xtype : "textfield",
  82. name : "search",
  83. getCondition: function(v) {
  84. return "(upper(teacher_name) like '%"+v.toUpperCase()+"%' or upper(teacher_number) like '%"+v.toUpperCase()+"%')";
  85. },
  86. allowBlank : true,
  87. width:300
  88. }],
  89. //放大镜窗口列表
  90. dbColumns:[{
  91. text: "ID",
  92. dataIndex: "teacher_id",
  93. hidden:true,
  94. xtype: "numbercolumn"
  95. }, {
  96. text: '工号',
  97. dataIndex: 'teacher_number',
  98. width: 110
  99. }, {
  100. text: "姓名",
  101. dataIndex: "teacher_name",
  102. width: 110
  103. }]
  104. }, {
  105. xtype: "textfield",
  106. name: 'school_phone',
  107. bind: '{schoolPhone}',
  108. fieldLabel: '联系电话',
  109. columnWidth: 1,
  110. maxLength: 50
  111. }, {
  112. xtype: "textfield",
  113. name: "school_address",
  114. bind: '{schoolAddress}',
  115. fieldLabel: "学校地址",
  116. allowBlank: true,
  117. columnWidth: 1,
  118. maxLength: 200
  119. }, {
  120. xtype: 'combobox',
  121. name: 'school_status',
  122. bind: '{schoolStatus}',
  123. fieldLabel: '状态',
  124. displayField: 'name',
  125. valueField: 'value',
  126. queryMode: 'local',
  127. editable: false,
  128. store: Ext.create('Ext.data.Store', {
  129. fields: ['name', 'value'],
  130. data: [{
  131. name: '正常',
  132. value: 1
  133. }, {
  134. name: '冻结',
  135. value: 2
  136. }]
  137. }),
  138. columnWidth: 1
  139. }, {
  140. xtype: 'textfield',
  141. name: 'school_appid',
  142. bind: '{schoolAppId}',
  143. fieldLabel: '公众号账号',
  144. readOnly: true,
  145. columnWidth: 1
  146. }, {
  147. xtype: 'textfield',
  148. name: 'school_secret',
  149. bind: '{schoolSecret}',
  150. fieldLabel: '公众号密钥',
  151. columnWidth: 1,
  152. readOnly: true
  153. }, {
  154. xtype: 'textfield',
  155. name: 'school_remarks',
  156. bind: '{schoolRemarks}',
  157. fieldLabel: '备注',
  158. columnWidth: 1,
  159. maxLength: 250
  160. }]
  161. });
  162. this.callParent();
  163. },
  164. onSave: function() {
  165. let me = this,
  166. values = me.getValues();
  167. me.setLoading(true);
  168. school.util.BaseUtil.request({
  169. // url: 'http://10.1.80.35:9560/school/save',
  170. url: '/api/school/school/save',
  171. method: 'POST',
  172. params: JSON.stringify(values)
  173. })
  174. .then(function() {
  175. me.setLoading(false);
  176. school.util.BaseUtil.showSuccessToast('资料更新成功');
  177. me.clearDirty();
  178. })
  179. .catch(function(e) {
  180. me.setLoading(false);
  181. school.util.BaseUtil.showErrorToast('资料更新失败: ' + e.message);
  182. });
  183. },
  184. clearDirty: function() {
  185. let me = this;
  186. let fields = me.getForm().getFields().items;
  187. Ext.Array.each(fields, function(f) {
  188. f.resetOriginalValue ? f.resetOriginalValue() : '';
  189. });
  190. },
  191. //overriders
  192. isValid: function() {
  193. let me = this;
  194. let viewModel = me.getViewModel();
  195. let formItems = me.getForm().getFields().items;
  196. let valid = !Ext.Array.findBy(formItems, function(f) {
  197. return !f.isValid();
  198. });
  199. viewModel.set('formValid', valid);
  200. return valid;
  201. },
  202. });