/** * 学校信息 */ Ext.define('school.view.basic.school.SchoolInfo', { // extend: 'school.view.core.form.FormPanel', extend: 'Ext.form.Panel', xtype: 'basic-school-schoolinfo', // controller: 'purchase-purchase-formpanel', // viewModel: 'purchase-purchase-formpanel', // readUrl: 'http://10.1.80.35:9560/school/read', readUrl: '/api/school/school/read', layout: 'column', autoScroll: true, bodyPadding: '12 250 12 250', fieldDefaults: { margin: '0 0 10 0', labelAlign: 'right', labelWidth: 90, columnWidth: 0.25, }, initComponent: function () { var me = this; Ext.apply(this, { dockedItems: [{ xtype: 'toolbar', dock: 'bottom', items: ['->', { xtype: 'button', text: '更新', bind: { disabled: '{!formValid}' }, handler: function() { me.onSave(); } }, '->'], }], items: [{ xtype: 'hidden', name: 'school_id', bind: '{schoolId}', fieldLabel: 'id', columnWidth: 1 }, { xtype: "textfield", name: "school_name", bind: '{schoolName}', fieldLabel: "学校名称", allowBlank: false, columnWidth: 1 }, { xtype: "textfield", name: 'school_phone', bind: '{schoolPhone}', fieldLabel: '联系电话', columnWidth: 1 }, { xtype: "textfield", name: "school_address", bind: '{schoolAddress}', fieldLabel: "学校地址", allowBlank: true, columnWidth: 1 }, { xtype: 'combobox', name: 'school_status', bind: '{schoolStatus}', fieldLabel: '状态', displayField: 'name', valueField: 'value', queryMode: 'local', editable: false, store: Ext.create('Ext.data.Store', { fields: ['name', 'value'], data: [{ name: '正常', value: 1 }, { name: '冻结', value: 2 }] }), columnWidth: 1 }, { xtype: 'textfield', name: 'school_appid', bind: '{schoolAppId}', fieldLabel: '公众号账号', readOnly: true, columnWidth: 1 }, { xtype: 'textfield', name: 'school_secret', bind: '{schoolSecret}', fieldLabel: '公众号密钥', columnWidth: 1, readOnly: true }, { xtype: 'textfield', name: 'school_remarks', bind: '{schoolRemarks}', fieldLabel: '备注', columnWidth: 1 }] }); this.callParent(); }, onSave: function() { let me = this, values = me.getValues(); me.setLoading(true); school.util.BaseUtil.request({ // url: 'http://10.1.80.35:9560/school/save', url: '/api/school/school/save', method: 'POST', params: JSON.stringify(values) }) .then(function() { me.setLoading(false); school.util.BaseUtil.showSuccessToast('资料更新成功'); me.clearDirty(); }) .catch(function(e) { me.setLoading(false); school.util.BaseUtil.showErrorToast('资料更新失败: ' + e.message); }); }, clearDirty: function() { let me = this; let fields = me.getForm().getFields().items; Ext.Array.each(fields, function(f) { f.resetOriginalValue ? f.resetOriginalValue() : ''; }); }, //overriders isValid: function() { let me = this; let viewModel = me.getViewModel(); let formItems = me.getForm().getFields().items; let valid = !Ext.Array.findBy(formItems, function(f) { return !f.isValid(); }); viewModel.set('formValid', valid); return valid; }, });