Sfoglia il codice sorgente

成绩录入学生只能选择属于所选班级的

zhuth 7 anni fa
parent
commit
ed006d5ec3

+ 50 - 42
frontend/pc-web/app/view/Interaction/score/Detail.js

@@ -31,19 +31,61 @@ Ext.define('school.view.interaction.score.Detail', {
             }, {
                 xtype: 'datefield',
                 name: 'si_examdate',
-                fieldLabel: '考试时间'
+                fieldLabel: '考试时间',
+                allowBlank: false
             }, {
                 xtype: 'textfield',
                 name: 'si_examscope',
                 fieldLabel: '考试范围'
             }, {
+            //     xtype: 'hidden',
+            //     name: 'task_gradeid',
+            //     fieldLabel: '年级ID'
+            // }, {
                 xtype: 'gradecombo',
                 name: 'si_grade',
-                fieldLabel: '年级'
+                fieldLabel: '年级',
+                listeners: {
+                    select: function (combo, record, eOpts) {
+                        let viewModel = me.getViewModel();
+                        // viewModel.set('task_gradeid', record.get('grade_id'));
+                        viewModel.set('clazz_id', null);
+                        viewModel.set('si_class', null);
+                    }
+                },
+                allowBlank: false
+            }, {
+                xtype: 'hidden',
+                name: 'clazz_id',
+                fieldLabel: '班级ID'
             }, {
                 xtype: 'classcombo',
                 name: 'si_class',
-                fieldLabel: '班级'
+                fieldLabel: '班级',
+                listeners: {
+                    expand: function (combo, eOpts) {
+                        combo.store.clearFilter();
+
+                        var gradeCombo = combo.up('form').getForm().findField('si_grade');
+                        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('clazz_id', record.get('clazz_id'));
+                        // viewModel.set('task_gradeid', record.get('grade_id'));
+                        viewModel.set('si_grade', record.get('clazz_grade'));
+                    }
+                },
+                allowBlank: false
             }, {
                 xtype: 'combobox',
                 name: 'si_publish',
@@ -66,7 +108,7 @@ Ext.define('school.view.interaction.score.Detail', {
                 detnoColumn: 'no',
                 storeModel: 'school.model.Score',
                 deleteDetailUrl: '/api/school/score/deleteDetail',
-                allowEmpty: true,
+                allowEmpty: false,
                 showCount: false,
                 emptyRows: 10,
                 rowViewModel: {},
@@ -77,56 +119,21 @@ Ext.define('school.view.interaction.score.Detail', {
                 }, {
                     text: '学生编号',
                     dataIndex: 'sd_stuNumber',
+                    allowBlank: false,
                     editor: {
                         xtype: 'textfield'
                     }
                 }, {
                     text: '姓名',
                     dataIndex: 'sd_stu',
+                    allowBlank: false,
                     editor: {
-                        addTitle: '学生',
                         xtype: 'dbfindtrigger',
-                        //数据接口
-                        dataUrl:'/api/school/student/list',
-                        //联想设置
-                        dbtpls:[{
-                            field:'stu_name',width:150
-                        }],
-                        dbfinds:[{
-                            from: 'stu_name', to: 'sd_stu',
-                        }, {
-                            from: 'stu_number', to: 'sd_stuNumber'
-                        }],
-                        defaultCondition: "1=1",
-                        dbSearchFields:[{
-                            emptyText:'请输入学生学号或姓名',
-                            xtype : "textfield", 
-                            name : "search", 
-                            getCondition: function(v) {
-                                return "(upper(stu_name) like '%"+v.toUpperCase()+"%' or upper(stu_number) like '%"+v.toUpperCase()+"%')";
-                            },
-                            allowBlank : true, 
-                            width:300
-                        }],
-                        //放大镜窗口列表
-                        dbColumns:[{
-                            text: "ID",
-                            dataIndex: "stu_id",
-                            hidden:true,
-                            xtype: "numbercolumn"
-                        }, {
-                            text: '工号',
-                            dataIndex: 'stu_number',
-                            width: 110
-                        }, {
-                            text: "姓名",
-                            dataIndex: "stu_name",
-                            width: 110
-                        }]
                     }
                 }, {
                     text: '科目',
                     dataIndex: 'sd_subject',
+                    allowBlank: false,
                     editor: {
                         xtype: 'subjectcombo',
                         valueField: 'subject_name',
@@ -135,6 +142,7 @@ Ext.define('school.view.interaction.score.Detail', {
                 }, {
                     text: '成绩',
                     dataIndex: 'sd_score',
+                    allowBlank: false,
                     editor: {
                         xtype: 'numberfield',
                         minValue: 0

+ 124 - 1
frontend/pc-web/app/view/Interaction/score/DetailController.js

@@ -2,6 +2,90 @@ Ext.define('school.view.interaction.score.DetailController', {
     extend: 'school.view.core.form.FormPanelController',
     alias: 'controller.interaction-score-detail',
 
+    init: function (form) {
+        var me = this;
+        this.control({
+            'dbfindtrigger[name=sd_stu]':{
+                beforerender:function(f){
+                    Ext.apply(f,{
+                        addTitle: '学生',
+                        //数据接口
+                        dataUrl:'/api/school/student/list',
+                        //联想设置
+                        dbtpls:[{
+                            field:'stu_name',width:150
+                        }],
+                        dbfinds:[{
+                            from: 'stu_name', to: 'sd_stu',
+                        }, {
+                            from: 'stu_number', to: 'sd_stuNumber'
+                        }],
+                        defaultCondition: "1=1",
+                        dbSearchFields:[{
+                            emptyText:'请输入学生学号或姓名',
+                            xtype : "textfield", 
+                            name : "search", 
+                            getCondition: function(v) {
+                                return "(upper(stu_name) like '%"+v.toUpperCase()+"%' or upper(stu_number) like '%"+v.toUpperCase()+"%')";
+                            },
+                            allowBlank : true, 
+                            width:300
+                        }],
+                        //放大镜窗口列表
+                        dbColumns:[{
+                            text: "ID",
+                            dataIndex: "stu_id",
+                            hidden:true,
+                            xtype: "numbercolumn"
+                        }, {
+                            text: '工号',
+                            dataIndex: 'stu_number',
+                            width: 110
+                        }, {
+                            text: "姓名",
+                            dataIndex: "stu_name",
+                            width: 110
+                        }]
+                    }) ; 
+                },
+                beforequery: function(f) {
+                    var defaultCondition = this.getDefaultCondition(1);
+                    if(!defaultCondition) {
+                        return false;
+                    }
+                    Ext.apply(f, {
+                        defaultCondition: defaultCondition
+                    });
+                },
+                beforetriggerclick: function(f) {
+                    var defaultCondition = this.getDefaultCondition(1);
+                    if(!defaultCondition) {
+                        return false;
+                    }
+                    Ext.apply(f, {
+                        defaultCondition: defaultCondition
+                    });
+                }
+            },
+        });
+    },
+
+    getDefaultCondition: function(idx) {
+        var me = this,
+        form = me.getView(),
+        formItems = form.formItems,
+        viewModel = me.getViewModel(),
+        gradeName = viewModel.get('si_grade'),
+        clazzName = viewModel.get('si_class');
+
+        if(gradeName && clazzName) {
+            return 'stu_grade=\'' + gradeName + '\' and stu_class = \'' + clazzName + '\'';
+        }else {
+            school.util.BaseUtil.showErrorToast('请先选择【' + '<span style="color: red;">班级</span>】');
+            return null;
+        }
+    },
+
     onAfterSave: function(localJson) {
         var form = this.getView();
         var id = localJson.data.id;
@@ -36,5 +120,44 @@ Ext.define('school.view.interaction.score.DetailController', {
             view.setLoading(false);
             school.util.BaseUtil.showErrorToast('发布失败: ' + e.message);
         });
-    }
+    },
+
+    /**
+     * 清空所有从表数据
+     */
+    clearDetails: function() {
+        var me = this;
+        
+        me.clearDetail0();
+    },
+
+    /**
+     * 清空第一个从表数据
+     */
+    clearDetail0: function(f, n, o) {
+        var me = this,
+        form = me.getView(),
+        grid = form.query('detailGridField')[0];
+        me.clearDetail(grid);
+    },
+
+    /**
+     * 清空一个从表数据
+     */
+    clearDetail: function(grid) {
+        var datas = [],
+        emptyRows = grid.emptyRows,
+        detnoColumn = grid.detnoColumn,
+        detno = 0,
+        store = grid.getStore();
+        
+        Ext.Array.each(new Array(emptyRows), function() {
+            detno += 1;
+            var data = {};
+            data[detnoColumn] = detno;
+            datas.push(data);
+        })
+        store.removeAll();
+        store.add(datas);
+    },
 });