| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- /**
- * 学校信息
- */
- 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',
- layout: 'column',
- autoScroll: true,
- bodyPadding: '8 12 8 12',
- 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: 'top',
- items: ['->', {
- xtype: 'button',
- text: '更新',
- bind: {
- disabled: '{!formValid}'
- },
- handler: function() {
- me.onSave();
- }
- }],
- }],
- items: [{
- xtype: 'hidden',
- name: 'school_id',
- bind: '{schoolId}',
- fieldLabel: 'id'
- }, {
- xtype: "textfield",
- name: "school_name",
- bind: '{schoolName}',
- fieldLabel: "学校名称",
- allowBlank: false,
- columnWidth: 0.5
- }, {
- xtype: 'textfield',
- name: 'school_status',
- bind: '{schoolStatus}',
- fieldLabel: '状态',
- }, {
- xtype: "textfield",
- name: "school_address",
- bind: '{schoolAddress}',
- fieldLabel: "学校地址",
- allowBlank: true,
- columnWidth: 1
- }, {
- xtype: "textfield",
- name: 'school_phone',
- bind: '{schoolPhone}',
- fieldLabel: '联系电话'
- }, {
- xtype: 'textfield',
- name: 'school_appid',
- bind: '{schoolAppId}',
- fieldLabel: '绑定微信号'
- }, {
- 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',
- 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;
- },
-
- });
|