| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- /**
- * 学校通知
- */
- Ext.define('school.view.interaction.notice.SchoolNotice', {
- extend: 'school.view.core.form.FormPanel',
- xtype: 'interaction-notice-schoolnotice',
- controller: 'interaction-notice-schoolnotice',
- viewModel: 'interaction-notice-schoolnotice',
- //字段属性
- _title: '学校通知',
- _idField: 'notify_id',
- _codeField: null,
- // _readUrl: 'http://10.1.80.101:9520/api/school/notice/read',
- _readUrl: '/api/school/notice/read',
- // _saveUrl: 'http://10.1.80.101:9520/api/school/notice/save',
- _saveUrl: '/api/school/notice/save',
- _deleteUrl: '/api/school/notice/delete',
- initId: 0,
- initComponent: function () {
- var me = this;
- Ext.apply(this, {
- defaultItems: [{
- xtype: 'hidden',
- name: 'notify_id',
- fieldLabel: 'id'
- }, {
- xtype: "textfield",
- name: "notify_creator",
- fieldLabel: "发布人id",
- columnWidth: 0.5,
- defaultValue: school.util.BaseUtil.getCurrentUser().teacher_id,
- hidden: true
- }, {
- xtype: "textfield",
- name: "creator",
- fieldLabel: "发布人",
- columnWidth: 0.25,
- defaultValue: school.util.BaseUtil.getCurrentUser().username,
- readOnly: true
- }, {
- xtype: 'combobox',
- name: 'notify_status',
- fieldLabel: '发布状态',
- displayField: 'name',
- valueField: 'value',
- editable: false,
- readOnly: true,
- defaultValue: 2,
- store: Ext.create('Ext.data.ArrayStore', {
- fields: ['name', 'value'],
- data: [['未发布', 2], ['已发布', 1]]
- }),
- minChars: 0,
- queryMode: 'local'
- }, {
- xtype: 'datefield',
- name: 'publish_date',
- fieldLabel: '发布时间',
- format: 'Y-m-d H:i:s',
- readOnly: true
- }, {
- xtype: 'combobox',
- fieldLabel: '通知对象',
- name: 'notify_target',
- displayField: 'name',
- valueField: 'value',
- editable: false,
- clearable: false,
- store: Ext.create('Ext.data.Store', {
- fields: ['name', 'value'],
- data: [{ name: '全体教师', value: 'teacher' }, { name: '全体家长', value: 'parent' }, { name: '指定年级', value: 'grade'}, { name: '指定班级', value: 'class' }]
- }),
- defaultValue: 'parent',
- minChars: 0,
- queryMode: 'local',
- allowBlank: false,
- listeners: {
- change: 'onNotifyTargetComboChange'
- }
- }, {
- xtype: 'hidden',
- name: 'gradeId',
- fieldLabel: '年级ID'
- }, {
- xtype: 'gradecombo',
- name: 'gradeName',
- fieldLabel: '年级',
- visible: false,
- allowBlank: false,
- listeners: {
- select: function (combo, record, eOpts) {
- let viewModel = me.getViewModel();
- viewModel.set('gradeId', record.get('grade_id'));
- viewModel.set('classId', null);
- viewModel.set('classzName', null);
- }
- }
- }, {
- xtype: 'hidden',
- name: 'classId',
- fieldLabel: '班级ID'
- }, {
- xtype: 'classcombo',
- name: 'classzName',
- fieldLabel: '班级',
- visible: false,
- allowBlank: false,
- listeners: {
- expand: function (combo, eOpts) {
- combo.store.clearFilter();
- var gradeCombo = combo.up('form').getForm().findField('gradeName');
- var gradeName = gradeCombo.getValue();
- var filter = new Ext.util.Filter({
- property: 'clazz_grade',
- value: gradeName
- });
- if (!!gradeName) {
- combo.store.setFilters([filter]);
- }
- },
- select: function (combo, record, eOpts) {
- let viewModel = me.getViewModel();
- viewModel.set('classId', record.get('clazz_id'));
- viewModel.set('gradeId', record.get('grade_id'));
- viewModel.set('gradeName', record.get('clazz_grade'));
- }
- }
- }, {
- xtype: "textfield",
- name: "notify_title",
- fieldLabel: "标题",
- columnWidth: 1,
- allowBlank: false
- }, {
- xtype: "textareafield",//文本域
- name: 'notify_details',
- fieldLabel: "内容",
- height: 300,
- columnWidth: 1,
- allowBlank: false,
- maxLength: 5000
- }, {
- xtype: 'mfilefield',
- name: 'notify_files',
- fieldLabel: '附件',
- fileRegex: /\.(jpeg|jpg|png|gif)$/
- }],
- applyBtns: [{
- apply: true,
- text: '保存',
- bind: {
- hidden: '{!showSaveBtn || notify_status == 1}',
- disabled: '{!base.valid}'
- }
- }, {
- apply: true,
- text: '删除',
- bind: {
- hidden: '{!showDeleteBtn || !notify_id || notify_status == 1}'
- },
- }],
- toolBtns: [{
- xtype: 'button',
- text: '发布',
- hidden: true,
- bind: {
- hidden: '{!notify_id || notify_status == 1}'
- },
- handler: 'onPublish'
- }]
- });
- this.callParent();
- },
- initFormData: function(data) {
- let me = this;
- if(data.main.notify_target == 'grade') {
- data.main.gradeId = data.main.notify_targetId;
- }else if(data.main.notify_target == 'class') {
- data.main.classId = data.main.notify_targetId;
- }
- me.setFormData(data);
- me.clearDirty();
- },
- isValid: function() {
- let me = this;
- let viewModel = me.getViewModel();
- let formItems = me.formItems || [];
- let notifyTargetValue = me.getForm().findField('notify_target').value;
- let valid = !Ext.Array.findBy(formItems, function(f) {
- if(notifyTargetValue == 'teacher' || notifyTargetValue == 'parent') {
- if(f.name == 'gradeName' || f.name == 'classzName') {
- return false;
- }
- }else if(notifyTargetValue == 'grade') {
- if(f.name == 'classzName') {
- return false;
- }
- }
- return !f.isValid();
- });
- let detailGrids = me.query('detailGridField');
- for(let i = 0; i < detailGrids.length; i++) {
- let g = detailGrids[i];
- if(!g.isValid()) {
- valid = false;
- break;
- }
- }
- viewModel.set('base.valid', valid);
- return valid;
- },
- refresh: function() {
- Ext.StoreMgr.get('store_grade').load();
- Ext.StoreMgr.get('store_class').load();
- },
- listeners: {
- load: function(form, data) {
- let fileField = form.down('mfilefield');
- fileField.value = data.main.notify_files
- fileField.renderMF(fileField);
- }
- }
- });
|