Browse Source

采购单据构建

hy 7 years ago
parent
commit
38213ec3f9

+ 57 - 0
frontend/saas-web/app/view/core/form/DbfindTrigger.js

@@ -0,0 +1,57 @@
+Ext.define('saas.view.core.form.DbfindTrigger', {
+    extend: 'Ext.form.ComboBox',
+    xtype: 'dbfindtrigger',
+    queryMode: 'local',
+    displayField: 'dispaly',
+    valueField: 'value',
+    triggerCls: 'x-form-search-trigger',
+    GridUtil: Ext.create('saas.util.GridUtil'),
+    initComponent:function() {
+        var me = this;
+        this.displayField='display';	   
+		this.valueField='value';
+		this.queryMode='local';
+		if(me.value){
+			me.store=Ext.create('Ext.data.Store', {
+				   fields: ['display','value'],
+				   data : [{
+					   'display':me.value,
+					   'value':me.value
+				   }]
+			});
+		}
+        this.callParent();
+    },
+    onTriggerClick:function(f){
+        //判断dbfindtrigger归属
+        f.judge(f);
+        var win = Ext.create('Ext.window.Window', {   
+            trigger:f,
+            belong:f.ownerCt,  
+            modal:true,
+            height: '80%',
+            width: '80%',
+            title: '查找',
+            scrollable: true,
+            bodyPadding: 10,
+            constrain: true,
+            closable: true,
+            layout:'fit',
+            renderTo:f.ownerCt.getEl(),
+            items:[{
+                xtype:'core-dbfindgridpanel',
+                configUrl: f.configUrl,
+                dataUrl: f.dataUrl,
+                relative: f.relative
+            }]
+        });
+        win.show();
+    },
+
+    judge:function(f){
+        if(f.ownerCt.xtype.indexOf('FormPanel')>-1){
+            f.belong = 'form'
+        }
+    }
+
+});

+ 51 - 0
frontend/saas-web/app/view/core/grid/DbfindGridPanel.js

@@ -0,0 +1,51 @@
+Ext.define('saas.view.core.grid.DbfindGridPanel', {
+    extend: 'Ext.grid.Panel',
+    xtype: 'core-dbfindgridpanel',
+
+    GridUtil: Ext.create('saas.util.GridUtil'),
+
+    configUrl: '',
+    dataUrl: '',
+
+    initComponent: function() {
+        var me = this;
+        me.configUrl && me.GridUtil.getGridColumns(me, me.configUrl, function() {
+            me.dataUrl && me.GridUtil.loadData(me, me.dataUrl);
+        });
+        me.callParent(arguments);
+    },
+
+    listeners:{
+        itemClick: function(view,record) {
+            var me = this;
+            var relatives = [];
+            Ext.Ajax.request({
+                async:false,
+                url: me.relative,
+                success: function(response, opts) {
+                    relatives = Ext.decode(response.responseText);                   
+                },
+                failure: function(response, opts) {
+                    console.log('server-side failure with status code ' + response.status);
+                }
+            });
+            if(relatives.length>0){
+                for (let index = 0; index < relatives.length; index++) {
+                    var item = relatives[index];
+                    var field = me.ownerCt.belong.down('[name='+item.name+']');
+                    if(field){
+                        var val = record.get(item.name);
+                        if(field.xtype=='dbfindtrigger'){
+                            field.setValue(val);
+                            field.setRawValue(val);
+                            field.lastTriggerValue=val;
+                        }else{
+                            field.setValue(val);
+                        }    
+                    }
+                }
+            }
+            me.ownerCt.close();
+        }
+    }
+});

+ 0 - 1
frontend/saas-web/app/view/core/tab/Panel.js

@@ -2,6 +2,5 @@ Ext.define('saas.view.core.tab.Panel', {
     extend: 'Ext.panel.Panel',
     xtype: 'core-tab-panel',
     controller: 'core-tab-controller',
-
     layout: 'fit'
 });

+ 1 - 1
frontend/saas-web/app/view/main/Main.js

@@ -81,7 +81,7 @@ Ext.define('saas.view.main.Main', {
                 }
             ]
         },
-        {
+        {         
             xtype: 'maincontainerwrap'
         }
     ]

+ 5 - 1
frontend/saas-web/app/view/main/Main.scss

@@ -28,7 +28,7 @@ $treelist-nav-ui: (
         item-text-over-color: mix(white, $panel-navigation-item-text-color, 50%),
         item-text-font-size: 14px,
         item-icon-font-size: 18px,
-        item-icon-width: 44px,
+        //item-icon-width: 44px,
         item-expander-font-size: 16px,
         item-expander-width: 24px,
         row-indicator-width: 5px,
@@ -37,6 +37,10 @@ $treelist-nav-ui: (
         row-indicator-over-color: transparent
 );
 
+.x-treelist-item-text{
+    padding-left: 10px;
+}
+
 .main-logo-wrap {
     background-color: $base-color;
     height: 65px;

+ 1 - 0
frontend/saas-web/app/view/main/MainContainerWrap.js

@@ -44,6 +44,7 @@ Ext.define('saas.view.main.MainContainerWrap', {
             xtype: 'tabpanel',
             region: 'center',
             flex: 1,
+            id:'main-tab-panel',
             reference: 'mainTabPanel',
             cls: 'main-right-tabpanel',
             itemId: 'contentPanel',

+ 45 - 11
frontend/saas-web/app/view/main/MainController.js

@@ -9,27 +9,23 @@ Ext.define('saas.view.main.MainController', {
 
     onNavigationTreeSelectionChange: function (tree, node) {
         if (node && node.get('viewType')) {
-            this.setActiveTab(node.getData());
+            this.setActiveTab(node.get('id'), node.get('viewType'), node.get('text'));
         }
     },
 
-    setActiveTab: function(nodeData) {
+    setActiveTab: function(id, type, title) {
+        debugger
         var me = this,
             refs = me.getReferences(),
             mainTab = refs.mainTabPanel,
             // existingItem = mainTab.child(type),
-            newView,
-            id = 'tab-' + nodeData.id,
-            title = nodeData.text;
             existingItem = mainTab.down('[id=' + id + ']'),
-            lastView = mainTab.getActiveTab();
+            newView;
+
+        lastView = mainTab.getActiveTab();
 
         if (!existingItem) {
-            newView = Ext.create('saas.view.core.tab.Panel', {
-                id: id,
-                title: title,
-                tabConfig: nodeData
-            });
+            newView = me.createTab({ type: type, title: title, id: id });
         }
 
         if (!newView || !newView.isWindow) {
@@ -56,6 +52,44 @@ Ext.define('saas.view.main.MainController', {
         }
     },
 
+    createTab: function(tabConfig) {
+        var me = this,
+            type = tabConfig.type;
+        
+        if(type == 'grid') {
+            return me.createGrid(tabConfig);
+        }else if(type == 'form') {
+            return me.createForm(tabConfig);
+        }else {
+            var { id, title } = tabConfig;
+            return Ext.create('Ext.panel.Panel', {
+                id,
+                title,
+                html: '无效类型'
+            });
+        }
+    },
+
+    createGrid: function(tabConfig) {
+        var me = this;
+        var { id, title } = tabConfig;
+        var grid = Ext.create('saas.view.purchase.list.GridPanel', {
+            id,
+            title
+        });
+        return grid;
+    },
+
+    createForm: function(tabConfig) {
+        var me = this;
+        var { id, title } = tabConfig;
+        var form = Ext.create('saas.view.core.form.Panel', {
+            id,
+            title
+        });
+        return form;
+    },
+
     onToggleNavigationSize: function () {
         var me = this,
             refs = me.getReferences(),

+ 7 - 7
frontend/saas-web/app/view/main/MainModel.js

@@ -26,22 +26,22 @@ Ext.define('saas.view.main.MainModel', {
                                 text: '采购单据',
                                 children: [
                                     {
-                                        id: 'list1',
-                                        text: '列表界面1',
-                                        viewType: 'purchase-list-gridpanel',
+                                        id: 'purchaseList',
+                                        text: '采购单',
+                                        viewType: 'grid',
                                         leaf: true
                                     },
                                     {
                                         id: 'list2',
                                         text: '列表界面2',
-                                        viewType: 'purchase-list-gridpanel',
+                                        viewType: 'grid',
                                         leaf: true
                                     },
                                     {
                                         id: 'form1',
-                                        text: '主从表界面1',
-                                        viewType: 'form',
-                                        leaf: true
+                                        text: '采购订单',
+                                        viewType: 'panel',
+                                        leaf: true                                     
                                     },
                                     {
                                         id: 'ghdd',

+ 16 - 2
frontend/saas-web/app/view/purchase/list/ListController.js

@@ -4,9 +4,23 @@ Ext.define('saas.view.purchase.list.ListController', {
 
     control: {
         'grid': {
-            itemClick: function() {
+            itemClick: function(view,record) {
                 console.log('grid1: click.....');
+                var id = record.get('id');
+                var mainTab = Ext.getCmp('main-tab-panel');
+                var title = '采购单明细',
+                existingItem = mainTab.down('[id=' + id + ']');
+
+                lastView = mainTab.getActiveTab();
+
+                if (!existingItem) {
+                    var form = Ext.create('saas.view.purchase.panel.FormPanel', {
+                        id,
+                        title
+                    });
+                    mainTab.setActiveTab(mainTab.add(form));
+                }
             }
         }
-    },
+    }
 });

+ 28 - 0
frontend/saas-web/app/view/purchase/panel/FormPanel.js

@@ -0,0 +1,28 @@
+Ext.define('saas.view.purchase.panel.FormPanel', {
+    extend: 'saas.view.core.form.FormPanel',
+    xtype: 'purchase-panel-FormPanel',
+    controller: 'purchase-panel-FormPanelController',
+
+    frame: true,
+    resizable: true,
+    width: 610,
+    minWidth: 610,
+    minHeight: 300,
+
+    layout: 'column',
+
+    defaults: {
+        columnWidth:0.25,
+        xtype: 'textfield',
+        margin:'5'
+    },
+
+    configUrl: 'resources/json/purchase/formItems.json',
+
+   
+
+    tbar: ['->',
+        { text: '保存' , handler: 'onOK' },
+        { text: '关闭', handler: 'onCancel' }
+    ]
+});

+ 19 - 0
frontend/saas-web/app/view/purchase/panel/FormPanelController.js

@@ -0,0 +1,19 @@
+Ext.define('saas.view.purchase.panel.FormPanelController', {
+    extend: 'Ext.app.ViewController',
+    alias: 'controller.purchase-panel-FormPanelController',
+
+    control: {
+        // '#pu_code':{
+        //     beforerender:function(f){
+        //         Ext.configIf(f,{
+        //             dbfinds:[
+        //                 {from:'ve_code',to:'pu_vendcode'},
+        //                 {from:'ve_name',to:'pu_vendname'}],
+        //             fields:[],
+        //             url:
+        //         }) ;   
+
+        //     }
+        // }
+    },
+});

+ 11 - 0
frontend/saas-web/app/view/purchase/panel/GridPanel.js

@@ -0,0 +1,11 @@
+Ext.define('saas.view.purchase.grid.GridPanel', {
+    extend: 'saas.view.core.grid.GridPanel',
+    xtype: 'purchase-panel-GridPanel',
+
+    configUrl: 'resources/json/gridColumns1.json',
+    dataUrl: 'resources/json/gridData1.json',
+
+    frame:true,
+
+    margin:'3'
+});

+ 36 - 0
frontend/saas-web/resources/json/purchase/formItems.json

@@ -0,0 +1,36 @@
+[{
+    "xtype": "textfield",
+    "name": "pu_code",
+    "bind": "{pu_code}",
+    "fieldLabel": "采购单号",
+    "allowBlank": true,
+    "columnWidth": 0.25
+}, {
+    "xtype": "textfield",
+    "name": "pu_kind",
+    "bind": "{pu_kind}",
+    "fieldLabel": "采购类型",
+    "allowBlank": true,
+    "columnWidth": 0.25
+}, {
+    "xtype": "dbfindtrigger",
+    "configUrl":"resources/json/purchase/vendorColumnsDbfind.json",
+    "dataUrl":"resources/json/purchase/vendorDataDbfind.json",
+    "relative":"resources/json/purchase/vendorRelativeDbfind.json",
+    "name": "pu_vendorcode",
+    "bind": "{pu_vendorcode}",
+    "fieldLabel": "供应商编号",
+    "allowBlank": true,
+    "columnWidth": 0.25
+}, {
+    "xtype": "textfield",
+    "name": "pu_vendorname",
+    "bind": "{pu_vendorname}",
+    "fieldLabel": "供应商简称",
+    "allowBlank": true,
+    "columnWidth": 0.25
+}, {
+    "xtype": "purchase-panel-GridPanel",
+    "allowBlank": true,
+    "columnWidth":1
+}]

+ 21 - 0
frontend/saas-web/resources/json/purchase/vendorColumnsDbfind.json

@@ -0,0 +1,21 @@
+[{
+    "text": "供应商编号",
+    "flex": 1,
+    "dataIndex": "pu_vendorcode",
+    "width": 100,
+    "xtype": "",
+    "items": null
+}, {
+    "text": "供应商名称",
+    "flex": 1,
+    "dataIndex": "pu_vendorname",
+    "xtype": "",
+    "items": null
+}, {
+    "text": "业务员",
+    "flex": 0,
+    "dataIndex": "saller",
+    "width": 200,
+    "xtype": "",
+    "items": null
+}]

+ 17 - 0
frontend/saas-web/resources/json/purchase/vendorDataDbfind.json

@@ -0,0 +1,17 @@
+[{
+    "pu_vendorcode": "TEST0000001",
+    "pu_vendorname": "测试供应商0000001",
+    "saller": "小李"
+}, {
+    "pu_vendorcode": "TEST0000002",
+    "pu_vendorname": "测试供应商0000002",
+    "saller": "小王"
+}, {
+    "pu_vendorcode": "TEST0000003",
+    "pu_vendorname": "测试供应商0000003",
+    "saller": "小明"
+}, {
+    "pu_vendorcode": "TEST0000004",
+    "pu_vendorname": "测试供应商0000004",
+    "saller": "小黄"
+}]

+ 5 - 0
frontend/saas-web/resources/json/purchase/vendorRelativeDbfind.json

@@ -0,0 +1,5 @@
+[{
+    "name": "pu_vendorcode"
+}, {
+    "name": "pu_vendorname"
+}]