Ver código fonte

作业/通知列表过滤条件逻辑优化

zhuth 6 anos atrás
pai
commit
35b1ea3cbe

+ 21 - 2
frontend/pc-web/app/view/Interaction/homework/List.js

@@ -68,12 +68,31 @@ Ext.define('school.view.interaction.homework.List', {
                     fields: ['name', 'value'],
                     data: [
                         ['已发布', 1],
-                        ['未发布', 0]
+                        ['未发布', 2]
                     ]
                 }),
                 minChars: 0,
-                queryMode: 'local'
+                queryMode: 'local',
+                listeners: {
+                    select: function (combo, record, e) {
+                        let condatefield = combo.up('form').down('condatefield')
+                        if (record.data.value == 1) {
+                            condatefield.setHidden(false);
+                            condatefield.ignore = false;
+                        } else {
+                            condatefield.setHidden(true);
+                            condatefield.ignore = true;
+                        }
+                    },
+                    clear: function (combo) {
+                        let condatefield = combo.up('form').down('condatefield')
+                        condatefield.setHidden(true);
+                        condatefield.ignore = true;
+                    }
+                }
             }, {
+                hidden: true,
+                ignore: true,
                 xtype: 'condatefield',
                 name: 'publish_date',
                 fieldLabel: '发布时间',

+ 40 - 18
frontend/pc-web/app/view/Interaction/notice/List.js

@@ -9,13 +9,13 @@ Ext.define('school.view.interaction.notice.List', {
     dataUrl: '/api/school/notice/list',
     _title: '学校通知',
 
-    initComponent: function() {
+    initComponent: function () {
         var me = this;
         Ext.apply(this, {
             searchField: [{
                 xtype: 'textfield',
                 name: 'keyword',
-                fieldLabel:'关键字',
+                fieldLabel: '关键字',
                 getCondition: function (value) {
                     return ' (notify_title like\'%' + value + '%\' or notify_details like \'%' + value + '%\') ';
                 }
@@ -33,17 +33,39 @@ Ext.define('school.view.interaction.notice.List', {
                 clearable: true,
                 store: Ext.create('Ext.data.ArrayStore', {
                     fields: ['name', 'value'],
-                    data: [['已发布', 1], ['未发布', 2]]
+                    data: [
+                        ['已发布', 1],
+                        ['未发布', 2]
+                    ]
                 }),
                 minChars: 0,
-                queryMode: 'local'
+                queryMode: 'local',
+                listeners: {
+                    select: function (combo, record, e) {
+                        let condatefield = combo.up('form').down('condatefield')
+                        if (record.data.value == 1) {
+                            condatefield.setHidden(false);
+                            condatefield.ignore = false;
+                        } else {
+                            condatefield.setHidden(true);
+                            condatefield.ignore = true;
+                        }
+                    },
+                    clear: function (combo) {
+                        let condatefield = combo.up('form').down('condatefield')
+                        condatefield.setHidden(true);
+                        condatefield.ignore = true;
+                    }
+                }
             }, {
+                hidden: true,
+                ignore: true,
                 xtype: 'condatefield',
                 name: 'publish_date',
                 fieldLabel: '发布时间',
                 columnWidth: 0.5
             }],
-        
+
             gridConfig: {
                 addTitle: '学校通知',
                 addXtype: 'interaction-notice-schoolnotice',
@@ -56,33 +78,33 @@ Ext.define('school.view.interaction.notice.List', {
                 totalProperty: 'data.total',
                 actionColumn: [],
                 selModel: {
-                    checkOnly:true,
-                    type:'checkboxmodel',
-                    mode : "MULTI" ,
-                    ignoreRightMouseSelection : false
+                    checkOnly: true,
+                    type: 'checkboxmodel',
+                    mode: "MULTI",
+                    ignoreRightMouseSelection: false
                 },
                 hiddenTools: false,
                 toolBtns: [{
                     xtype: 'button',
                     text: '新增',
-                    handler: function() {
+                    handler: function () {
                         school.util.BaseUtil.openTab('interaction-notice-schoolnotice', '新增学校通知', 'interaction-notice-schoolnotice-add');
                     }
                 }, {
                     xtype: 'button',
                     text: '删除',
-                    handler: function() {
+                    handler: function () {
                         let grid = this.up('grid'),
-                        selectedRecords = grid.getSelection();
+                            selectedRecords = grid.getSelection();
                         let data;
 
-                        data = selectedRecords.map(function(r) {
+                        data = selectedRecords.map(function (r) {
                             return {
                                 id: r.get('notify_id')
                             };
                         });
 
-                        if(data.length == 0) {
+                        if (data.length == 0) {
                             school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
                             return;
                         }
@@ -95,17 +117,17 @@ Ext.define('school.view.interaction.notice.List', {
                             params: JSON.stringify({
                                 baseDTOs: data
                             })
-                        }).then(function(res) {
+                        }).then(function (res) {
                             grid.setLoading(false);
                             school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
                             grid.store.loadPage(grid.store.currentPage);
-                        }).catch(function(e) {
+                        }).catch(function (e) {
                             grid.setLoading(false);
                             school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
                         });
                     }
                 }],
-                columns : [{
+                columns: [{
                     text: 'id',
                     dataIndex: 'notify_id',
                     hidden: true
@@ -134,7 +156,7 @@ Ext.define('school.view.interaction.notice.List', {
                     text: '发布状态',
                     dataIndex: 'notify_status',
                     width: 120,
-                    renderer: function(v) {
+                    renderer: function (v) {
                         return !!v ? (v == 2 ? '未发布' : '已发布') : '未发布'
                     }
                 }, {

+ 2 - 1
frontend/pc-web/app/view/core/base/BasePanel.js

@@ -130,11 +130,12 @@ Ext.define('school.view.core.base.BasePanel', {
         for(let i = 0; i < items.length; i++) {
             var item = items[i];
             var field = item.name,
+            ignore = item.ignore,
             func = item.getCondition,
             value = item.value,
             condition;
 
-            if(value !== undefined && value !== null && value !== ''){
+            if(!ignore && value !== undefined && value !== null && value !== ''){
                 if(typeof func == 'function') {
                     condition = {
                         type: 'condition',

+ 1 - 0
frontend/pc-web/overrides/form/field/ComboBox.js

@@ -23,6 +23,7 @@ Ext.define("school.override.form.field.ComboBox", {
                     if(this.clearable) {
                         this.setValue(null)
                         this.triggers.clear.setHidden(true)
+                        this.fireEvent('clear', this);
                     }
                 }
             },