Procházet zdrojové kódy

学校信息添加上课时间以及推送开关/学校通知通知对象为班级时组件逻辑变更

zhuth před 6 roky
rodič
revize
23b3522d5b

+ 2 - 0
frontend/pc-web/app/view/Interaction/notice/List.js

@@ -11,6 +11,8 @@ Ext.define('school.view.interaction.notice.List', {
 
     initComponent: function () {
         var me = this;
+        Ext.StoreMgr.get('store_grade').load();
+        Ext.StoreMgr.get('store_class').load();
         Ext.apply(this, {
             searchField: [{
                 xtype: 'textfield',

+ 90 - 3
frontend/pc-web/app/view/Interaction/notice/SchoolNotice.js

@@ -19,6 +19,7 @@ Ext.define('school.view.interaction.notice.SchoolNotice', {
     _deleteUrl: '/api/school/notice/delete',
     initId: 0,
     initComponent: function () {
+        var me = this;
         Ext.apply(this, {
             defaultItems: [{
                 xtype: 'hidden',
@@ -69,15 +70,65 @@ Ext.define('school.view.interaction.notice.SchoolNotice', {
                 clearable: false,
                 store: Ext.create('Ext.data.Store', {
                     fields: ['name', 'value'],
-                    data: [{ name: '全体教师', value: -1 }, { name: '全体家长', value: -2 }]
+                    data: [{ name: '全体教师', value: -1 }, { name: '全体家长', value: -2 }, { name: '指定班级', value: -3 }]
                 }),
                 defaultValue: -2,
                 minChars: 0,
                 queryMode: 'local',
                 allowBlank: false,
                 listeners: {
-                    boxready: 'onNotifyClassComboReady',
-                    expand: 'onNotifyClassComboExpand'
+                    change: 'onNotifyClassComboChange'
+                }
+            }, {
+                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",
@@ -125,6 +176,42 @@ Ext.define('school.view.interaction.notice.SchoolNotice', {
         });
         this.callParent();
     },
+    initFormData: function(data) {
+        let me = this;
+        if(data.main.notify_class > 0) {
+            data.main.classId = data.main.notify_class;
+            data.main.notify_class = -3;
+        }
+        me.setFormData(data);
+        me.clearDirty();
+    },
+    isValid: function() {
+        let me = this;
+        let viewModel = me.getViewModel();
+        let formItems = me.formItems || [];
+        let notifyClassValue = me.getForm().findField('notify_class').value;
+        let valid = !Ext.Array.findBy(formItems, function(f) {
+            if(notifyClassValue != -3 && (f.name == 'gradeName' || 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');

+ 15 - 27
frontend/pc-web/app/view/Interaction/notice/SchoolNoticeController.js

@@ -42,35 +42,23 @@ Ext.define('school.view.interaction.notice.SchoolNoticeController', {
         });
     },
 
-    onNotifyClassComboReady: function(classCombo) {
-        var classStore = Ext.StoreMgr.get('store_class');
-        if(classStore.getCount() === 0 || classCombo.store.getCount() === 2) {
-            classStore.load(function(records) {
-                var classData = records.map(function(record) {
-                    var name = record.get('clazz_grade') + ' | '+ record.get('clazz_name');
-                    var value = record.get('clazz_id');
-                    return {name: name, value: value};
-                });
-                classCombo.store.insert(2, classData);
-                classCombo.setValue(classCombo.value); // 重新触发一次setValue以正确显示值
-            });
-        }
+    onNotifyClassComboChange: function(combo, value) {
+        var me = this,
+        form = me.getView(),
+        f = form.getForm(),
+        gradeField = f.findField('gradeName'),
+        classField = f.findField('classzName');
+
+        gradeField.setVisible(value === -3);
+        classField.setVisible(value === -3);
+        
+        form.isValid();
     },
 
-    onNotifyClassComboExpand: function(combo) {
-        var classStore = Ext.StoreMgr.get('store_class');
-        if(classStore.getCount() === 0 || combo.store.getCount() === 2) {
-            combo.setLoading(true);
-            classStore.load(function(records) {
-                var classData = records.map(function(record) {
-                    var name = record.get('clazz_grade') + ' | '+ record.get('clazz_name');
-                    var value = record.get('clazz_id');
-                    return {name: name, value: value};
-                });
-                combo.store.insert(2, classData);
-                classCombo.setValue(classCombo.value);
-                combo.setLoading(false);
-            });
+    getMySaveParams: function(params) {
+        if(params.main.notify_class == -3) {
+            params.main.notify_class = params.main.classId
         }
+        return params.main;
     }
 });

+ 16 - 0
frontend/pc-web/app/view/Interaction/notice/SchoolNoticeModel.js

@@ -9,6 +9,22 @@ Ext.define('school.view.interaction.notice.SchoolNoticeModel', {
                 let view = this.getView();
                 view.setEditable(v != 1);
             }
+        },
+        classId_change: {
+            bind: '{classId}',
+            get: function(v) {
+                if(!v) {
+                    return;
+                }
+                let form = this.getView();
+                let gradeIdField = form.getForm().findField('gradeId');
+                let gradeNameCombo = form.getForm().findField('gradeName');
+                let classNameCombo = form.getForm().findField('classzName');
+                let record = classNameCombo.store.data.items.find(item => item.get('clazz_id') == v);
+                gradeIdField.setValue(record.get('grade_id'));
+                gradeNameCombo.setValue(record.get('clazz_grade'));
+                classNameCombo.setValue(record.get('clazz_name'));
+            }
         }
     }
 

+ 1 - 0
frontend/pc-web/app/view/Interaction/timetable/List.js

@@ -77,6 +77,7 @@ Ext.define('school.view.interaction.timetable.List', {
                     let now = new Date();
                     let year = now.getFullYear();
                     let month = now.getMonth() + 1;
+                    let date = now.getDate();
                     let o1, o2, termPart;
                     
                     o1 = [(year - 1) + '-' + year];

+ 34 - 3
frontend/pc-web/app/view/basic/school/SchoolInfo.js

@@ -6,8 +6,8 @@ Ext.define('school.view.basic.school.SchoolInfo', {
     extend: 'Ext.form.Panel',
     xtype: 'basic-school-schoolinfo',
 
-    // controller: 'purchase-purchase-formpanel',
-    // viewModel: 'purchase-purchase-formpanel',
+    // controller: 'basic-school-schoolinfo',
+    // viewModel: 'basic-school-schoolinfo',
 
     // readUrl: 'http://10.1.80.36:9520/api/school/school/read',
     readUrl: '/api/school/school/read',
@@ -154,6 +154,34 @@ Ext.define('school.view.basic.school.SchoolInfo', {
                 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',
@@ -169,7 +197,10 @@ Ext.define('school.view.basic.school.SchoolInfo', {
     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',

+ 2 - 0
frontend/pc-web/app/view/viewport/ViewportController.js

@@ -64,6 +64,8 @@ Ext.define('school.view.viewport.ViewportController', {
                     schoolAddress: res.data.school_address,
                     schoolStatus: res.data.school_status,
                     schoolSecret: res.data.school_secret,
+                    schoolClassHours: res.data.school_classHours,
+                    schoolWechatPush: res.data.school_wechatPush == -1 ? 'on' : 'off',
                 };
                 me.getViewModel().setData(d);
             }