/** * 学校信息 */ Ext.define('school.view.basic.school.SchoolInfo', { // extend: 'school.view.core.form.FormPanel', extend: 'Ext.form.Panel', xtype: 'basic-school-schoolinfo', // controller: 'basic-school-schoolinfo', // viewModel: 'basic-school-schoolinfo', // readUrl: 'http://10.1.80.36:9520/api/school/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: 'textfield', name: 'school_id', bind: '{schoolId}', fieldLabel: '学校ID', columnWidth: 1, readOnly: true }, { xtype: "textfield", name: "school_name", bind: '{schoolName}', fieldLabel: "学校名称", allowBlank: false, columnWidth: 1, maxLength: 100 }, { xtype: "hidden", name: 'teacher_id', bind: '{TeacherId}', fieldLabel: '校长ID', columnWidth: 1 }, { name: 'teacher_name', bind: '{TeacherName}', fieldLabel: '校长', columnWidth: 1, maxLength: 20, addTitle: '教师', xtype: 'dbfindtrigger', //数据接口 dataUrl:'/api/school/mirror/findTeacher', //联想设置 dbtpls:[{ field:'teacher_name',width:150 }], dbfinds:[{ from: 'teacher_name', to: 'teacher_name', }, { from: 'teacher_id', to: 'teacher_id' }], defaultCondition: "1=1", dbSearchFields:[{ emptyText:'请输入教师工号或姓名', xtype : "textfield", name : "search", getCondition: function(v) { return "(upper(teacher_name) like '%"+v.toUpperCase()+"%' or upper(teacher_number) like '%"+v.toUpperCase()+"%')"; }, allowBlank : true, width:300 }], //放大镜窗口列表 dbColumns:[{ text: "ID", dataIndex: "teacher_id", hidden:true, xtype: "numbercolumn" }, { text: '工号', dataIndex: 'teacher_number', width: 110 }, { text: "姓名", dataIndex: "teacher_name", width: 110 }] }, { xtype: "textfield", name: 'school_phone', bind: '{schoolPhone}', fieldLabel: '联系电话', columnWidth: 1, maxLength: 50 }, { xtype: "textfield", name: "school_address", bind: '{schoolAddress}', fieldLabel: "学校地址", allowBlank: true, columnWidth: 1, maxLength: 200 }, { 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: 'timefield', name: 'school_classHours', bind: '{schoolClassHours}', fieldLabel: '上课时间', minValue: '6:00', maxValue: '18:00', format: 'H:i', columnWidth: 0.5, listeners: { change: function(f) { if(!f.value) { f.up('form').getForm().findField('school_wechatPush').setValue(false); } } } }, { xtype: 'checkbox', style: { float: 'right' }, name: 'school_wechatPush', readOnly: true, bind: { readOnly: '{!schoolClassHours}', value: '{schoolWechatPush}', }, fieldLabel: '推送迟到信息', }, { xtype: 'textfield', name: 'school_remarks', bind: '{schoolRemarks}', fieldLabel: '备注', columnWidth: 1, maxLength: 250 }] }); this.callParent(); }, onSave: function() { let me = this, values = me.getValues(); values.school_wechatPush = (values.school_wechatPush == 'on' || values.school_wechatPush == '1' || values.school_wechatPush == true || values.school_wechatPush == 'true' ) ? '-1' : '0'; 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; }, });