Browse Source

添加重设默认按钮属性逻辑

zhuth 6 years ago
parent
commit
b2fc34cf68

+ 8 - 0
frontend/pc-web/app/view/Interaction/homework/Release.js

@@ -122,6 +122,14 @@ Ext.define('school.view.interaction.homework.Release', {
                 name: 'accessory',
                 fieldLabel: '附件'
             }],
+            applyBtns: [{
+                apply: true,
+                text: '保存',
+                bind: {
+                    hidden: '{!showSaveBtn || task_status == 1}',
+                    disabled: '{!base.valid}'
+                }
+            }],
             toolBtns: [{
                 xtype: 'button',
                 text: '发布',

+ 8 - 0
frontend/pc-web/app/view/Interaction/notice/SchoolNotice.js

@@ -79,6 +79,14 @@ Ext.define('school.view.interaction.notice.SchoolNotice', {
                 name: 'accessory',
                 fieldLabel: '附件'
             }],
+            applyBtns: [{
+                apply: true,
+                text: '保存',
+                bind: {
+                    hidden: '{!showSaveBtn || notify_status == 1}',
+                    disabled: '{!base.valid}'
+                }
+            }],
             toolBtns: [{
                 xtype: 'button',
                 text: '发布',

+ 20 - 8
frontend/pc-web/app/view/core/form/FormPanel.js

@@ -23,7 +23,8 @@ Ext.define('school.view.core.form.FormPanel', {
     },
 
     items: [],
-    toolBtns: [],
+    applyBtns: [], // 重设默认按钮属性
+    toolBtns: [], // 添加自定义按钮
 
     _idField: 'id',
 
@@ -48,9 +49,20 @@ Ext.define('school.view.core.form.FormPanel', {
     },
 
     getToolBarItems: function() {
-        let me = this, items = [];
+        let me = this, items = [],
+        toolBtns = me.toolBtns,
+        applyBtns = me.applyBtns,
+        _addBtn = Ext.Array.findBy(applyBtns, function(b) {
+            return b.apply && b.text == '新增';
+        }),
+        _saveBtn = Ext.Array.findBy(applyBtns, function(b) {
+            return b.apply && b.text == '保存';
+        }),
+        _deleteBtn = Ext.Array.findBy(applyBtns, function(b) {
+            return b.apply && b.text == '删除';
+        });
         
-        me.defaultToolBtns = [{
+        me.defaultToolBtns = [Ext.apply({
             cls: 'x-formpanel-btn-blue',
             xtype: 'button',
             text: '新增',
@@ -59,7 +71,7 @@ Ext.define('school.view.core.form.FormPanel', {
                 hidden: '{!showAddBtn || !' + me._idField + '}'
             },
             handler: 'add'
-        }, {
+        }, _addBtn), {
             hidden: true,
             xtype: 'button',
             text: '复制',
@@ -67,7 +79,7 @@ Ext.define('school.view.core.form.FormPanel', {
             bind: {
                 hidden: '{!showCopyBtn || !'+ me._idField + '}',
             }
-        }, {
+        }, Ext.apply({
             hidden: true,
             xtype: 'button',
             text: '保存',
@@ -76,7 +88,7 @@ Ext.define('school.view.core.form.FormPanel', {
                 hidden: '{!showSaveBtn}',
                 disabled: '{!base.valid}'
             }
-        }, {
+        }, _saveBtn), Ext.apply({
             hidden: true,
             xtype: 'button',
             text: '删除',
@@ -84,7 +96,7 @@ Ext.define('school.view.core.form.FormPanel', {
                 hidden: '{!showDeleteBtn || !'+ me._idField + '}'
             },
             handler: 'delete'
-        }, {
+        }, _deleteBtn), {
             cls: 'x-formpanel-btn-white',
             xtype: 'button',
             text: '刷新',
@@ -103,7 +115,7 @@ Ext.define('school.view.core.form.FormPanel', {
             handler:"showMessageLog"
         }];
 
-        items = Ext.Array.merge(['->'], me.toolBtns, me.defaultToolBtns);
+        items = Ext.Array.merge(['->'], toolBtns, me.defaultToolBtns);
 
         return items;
     },