zhuth пре 7 година
родитељ
комит
70e307d2ea

+ 16 - 4
frontend/saas-web/app/util/BaseUtil.js

@@ -5,16 +5,28 @@ Ext.define('saas.util.BaseUtil', {
      * @param url: 请求路径
      * @param params: 请求参数
      */
-    request: function(url, params) {
+    request: function (config) {
+        var url = config.url,
+            params = config.params,
+            async = config.async || true,
+            method = config.method || 'GET',
+            timeout = config.timeout || 8000;
+
         return new Ext.Promise(function (resolve, reject) {
             Ext.Ajax.request({
                 url: url,
                 params: params,
-                success: function(response, opts) {
+                async: async,
+                method: method,
+                timeout: timeout,
+                header: {
+                    'Access-Control-Allow-Origin': '*'
+                },
+                success: function (response, opts) {
                     resolve(response);
                 },
-                failure: function(response, opts) {
-                    console.log('server-side failure with status code ' + response.status);
+                failure: function (response, opts) {
+                    console.error('server-side failure with status code ' + response.status);
                     return reject(response);
                 }
             });

+ 19 - 5
frontend/saas-web/app/util/FormUtil.js

@@ -1,18 +1,32 @@
 Ext.define('saas.util.FormUtil', {
 
     BaseUtil: Ext.create('saas.util.BaseUtil'),
+
+    /**
+     * 请求页面组件接口模板
+     */
+    baseUrl: 'http://192.168.0.181:8560/api/ui/co_view/config?name={xtype}',
     
     /**
      * 获得form的字段配置
      * @param form: form组件
      * @param url: url
      */
-    getFormItems: function(form, url, callback) {
-        this.BaseUtil.request(url)
+    getFormItems: function(form) {
+        var me = this,
+            xtype = form.xtype,
+            reg = /(.*){xtype}(.*)/g,
+            url = me.baseUrl.replace(reg, '$1' + xtype);
+        
+        this.BaseUtil.request({url})
         .then(function(response) {
-            var items = Ext.decode(response.responseText);
-            form.add(items);
-        }).catch(function(response) {
+            var res = Ext.decode(response.responseText);
+            if(res.success) {
+                var config = res.data;
+                form.add(config.items);
+            }
+        })
+        .catch(function(response) {
             console.log(response);
         });
     }

+ 2 - 2
frontend/saas-web/app/util/GridUtil.js

@@ -8,7 +8,7 @@ Ext.define('saas.util.GridUtil', {
      * @param url 请求url
      */
     setColumns: function(grid, url) {
-        this.BaseUtil.request(url)
+        this.BaseUtil.request({url})
         .then(function(response) {
             var columns = Ext.decode(response.responseText);
             var fields = columns.map(column => column.dataIndex);
@@ -33,7 +33,7 @@ Ext.define('saas.util.GridUtil', {
      * @param url 请求url
      */
     loadData: function(grid, url) {
-        this.BaseUtil.request(url)
+        this.BaseUtil.request({url})
         .then(function(response) {
             var data = Ext.decode(response.responseText);
                 grid.getStore().loadData(data);

+ 7 - 9
frontend/saas-web/app/view/core/form/FormPanel.js

@@ -32,22 +32,20 @@ Ext.define('saas.view.core.form.FormPanel', {
         }, '->', {
             xtype: 'button',
             text: '新增',
+            handler: 'add'
         }, {
             xtype: 'button',
-            text: '保存'
+            text: '保存',
+            handler: 'save'
         }, {
             xtype: 'button',
-            text: '审核'
+            text: '审核',
+            handler: "audit"
         }]
     }],
 
     items: [],
+
+    remoteConfig: true // 是否需要从远端读取form配置
     
-    configUrl: '',
-    
-    initComponent: function() {
-        var me = this;
-        me.configUrl && me.FormUtil.getFormItems(me, me.configUrl);
-        me.callParent(arguments);
-    }
 });

+ 14 - 1
frontend/saas-web/app/view/core/form/FormPanelController.js

@@ -2,5 +2,18 @@ Ext.define('saas.view.core.form.FormPanelController', {
     extend: 'Ext.app.ViewController',
     alias: 'controller.core-form-formpanel',
 
-    
+    FormUtil: Ext.create('saas.util.FormUtil'),
+
+    init: function() {
+        var me = this,
+        form = me.getView(),
+        remoteConfig = form.remoteConfig;
+        
+        remoteConfig && me.FormUtil.getFormItems(form);
+    },
+
+    add: Ext.emptyFn,
+    save: Ext.emptyFn,
+    audit: Ext.emptyFn,
+
 });

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

@@ -47,6 +47,11 @@ Ext.define('saas.view.main.MainModel', {
                                         text: '测试-采购单明细界面',
                                         viewType: 'test-order-formpanel',
                                         leaf: true
+                                    }, {
+                                        id: 'myform',
+                                        text: '测试-明细界面',
+                                        viewType: 'test-myform-formpanel',
+                                        leaf: true
                                     },
                                     {
                                         id: 'ghdd',

+ 1 - 1
frontend/saas-web/app/view/purchase/order/FormModel.js

@@ -1,5 +1,5 @@
 Ext.define('saas.view.purchase.order.FormModel', {
-    extend: 'Ext.app.ViewModel',
+    extend: 'saas.view.core.form.FormPanelModel',
     alias: 'viewmodel.purchase-order-formmodel',
 
     data: {

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

@@ -1,5 +1,5 @@
 Ext.define('saas.view.purchase.panel.FormPanelController', {
-    extend: 'Ext.app.ViewController',
+    extend: 'saas.view.core.form.FormPanelController',
     alias: 'controller.purchase-panel-FormPanelController',
 
     control: {

+ 1 - 1
frontend/saas-web/app/view/sale/salelist/FormController.js

@@ -1,5 +1,5 @@
 Ext.define('saas.view.sale.salelist.FormController', {
-    extend: 'Ext.app.ViewController',
+    extend: 'saas.view.core.grid.GridPanelController',
     alias: 'controller.saledetail',
 
 });

+ 1 - 1
frontend/saas-web/app/view/sale/salelist/FormModel.js

@@ -1,5 +1,5 @@
 Ext.define('saas.view.sale.salelist.FormModel', {
-    extend: 'Ext.app.ViewModel',
+    extend: 'saas.view.core.form.FormPanelModel',
     alias: 'viewmodel.saledetail',
 
     formulas: {

+ 1 - 1
frontend/saas-web/app/view/sale/salelist/GridController1.js

@@ -1,5 +1,5 @@
 Ext.define('saas.view.sale.salelist.GridController1', {
-    extend: 'Ext.app.ViewController',
+    extend: 'saas.view.core.grid.GridPanelController',
     alias: 'controller.salelist1',
 
     control: {

+ 1 - 1
frontend/saas-web/app/view/sale/salelist/GridController2.js

@@ -1,5 +1,5 @@
 Ext.define('saas.view.sale.salelist.GridController2', {
-    extend: 'Ext.app.ViewController',
+    extend: 'saas.view.core.grid.GridPanelController',
     alias: 'controller.salelist2',
 
     listen: {

+ 12 - 0
frontend/saas-web/app/view/test/myform/FormPanel.js

@@ -0,0 +1,12 @@
+
+Ext.define('saas.view.test.myform.FormPanel',{
+    extend: 'saas.view.core.form.FormPanel',
+    xtype: 'test-myform-formpanel',
+
+    controller: 'test-myform-formpanel',
+    viewModel: {
+        type: 'test-myform-formpanel'
+    },
+
+    configUrl: 'http://192.168.0.181:8560/api/ui/co_view/config?name=purchase.list',
+});

+ 5 - 0
frontend/saas-web/app/view/test/myform/FormPanelController.js

@@ -0,0 +1,5 @@
+Ext.define('saas.view.test.myform.FormPanelController', {
+    extend: 'saas.view.core.form.FormPanelController',
+    alias: 'controller.test-myform-formpanel'
+
+});

+ 9 - 0
frontend/saas-web/app/view/test/myform/FormPanelModel.js

@@ -0,0 +1,9 @@
+Ext.define('saas.view.test.myform.FormPanelModel', {
+    extend: 'saas.view.core.form.FormPanelModel',
+    alias: 'viewmodel.test-myform-formpanel',
+    
+    data: {
+        name: 'saas'
+    }
+
+});

+ 1 - 1
frontend/saas-web/app/view/test/order/FormModel.js

@@ -1,5 +1,5 @@
 Ext.define('saas.view.test.order.FormModel', {
-    extend: 'Ext.app.ViewModel',
+    extend: 'saas.view.core.form.FormPanelModel',
     alias: 'viewmodel.test-order-formmodel',
 
     data: {

+ 69 - 61
frontend/saas-web/resources/json/formItems.json

@@ -1,61 +1,69 @@
-[{
-    "xtype": "textfield",
-    "name": "text",
-    "bind": "{text}",
-    "fieldLabel": "文本",
-    "allowBlank": true,
-    "columnWidth": 1
-}, {
-    "xtype": "numberfield",
-    "name": "num1",
-    "bind": "{num1}",
-    "fieldLabel": "加数",
-    "allowBlank": false,
-    "columnWidth": 0.5
-}, {
-    "xtype": "numberfield",
-    "name": "num2",
-    "bind": "{num2}",
-    "fieldLabel": "加数",
-    "allowBlank": false,
-    "columnWidth": 0.5
-}, {
-    "xtype": "numberfield",
-    "name": "sum",
-    "bind": "{sum}",
-    "fieldLabel": "和",
-    "allowBlank": false,
-    "columnWidth": 1
-}, {
-    "xtype": "detailGridField",
-    "columnWidth": 1,
-    "configUrl": "resources/json/detailGridColumns1.json"
-}, {
-    "xtype": "datefield",
-    "name": "createTime",
-    "bind": "{createTime}",
-    "fieldLabel": "制单日期",
-    "allowBlank": true,
-    "columnWidth": 0.25 
-}, {
-    "xtype": "textfield",
-    "name": "creator",
-    "bind": "{creator}",
-    "fieldLabel": "制单人",
-    "allowBlank": true,
-    "columnWidth": 0.25 
-}, {
-    "xtype": "textfield",
-    "name": "field1",
-    "bind": "{field1}",
-    "fieldLabel": "field1",
-    "allowBlank": true,
-    "columnWidth": 1 
-}, {
-    "xtype": "textfield",
-    "name": "field2",
-    "bind": "{field2}",
-    "fieldLabel": "field2",
-    "allowBlank": true,
-    "columnWidth": 1 
-}]
+{
+    "success": true,
+    "code": 0,
+    "message": null,
+    "data": {
+        "xtype": "formpanel",
+        "items": [{
+            "xtype": "textfield",
+            "name": "text",
+            "bind": "{text}",
+            "fieldLabel": "文本",
+            "allowBlank": true,
+            "columnWidth": 1
+        }, {
+            "xtype": "numberfield",
+            "name": "num1",
+            "bind": "{num1}",
+            "fieldLabel": "加数",
+            "allowBlank": false,
+            "columnWidth": 0.5
+        }, {
+            "xtype": "numberfield",
+            "name": "num2",
+            "bind": "{num2}",
+            "fieldLabel": "加数",
+            "allowBlank": false,
+            "columnWidth": 0.5
+        }, {
+            "xtype": "numberfield",
+            "name": "sum",
+            "bind": "{sum}",
+            "fieldLabel": "和",
+            "allowBlank": false,
+            "columnWidth": 1
+        }, {
+            "xtype": "detailGridField",
+            "columnWidth": 1,
+            "configUrl": "resources/json/detailGridColumns1.json"
+        }, {
+            "xtype": "datefield",
+            "name": "createTime",
+            "bind": "{createTime}",
+            "fieldLabel": "制单日期",
+            "allowBlank": true,
+            "columnWidth": 0.25 
+        }, {
+            "xtype": "textfield",
+            "name": "creator",
+            "bind": "{creator}",
+            "fieldLabel": "制单人",
+            "allowBlank": true,
+            "columnWidth": 0.25 
+        }, {
+            "xtype": "textfield",
+            "name": "field1",
+            "bind": "{field1}",
+            "fieldLabel": "field1",
+            "allowBlank": true,
+            "columnWidth": 1 
+        }, {
+            "xtype": "textfield",
+            "name": "field2",
+            "bind": "{field2}",
+            "fieldLabel": "field2",
+            "allowBlank": true,
+            "columnWidth": 1 
+        }]
+    }
+}

+ 50 - 42
frontend/saas-web/resources/json/purchase/formItems.json

@@ -1,42 +1,50 @@
-[{
-    "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",
-    "dbfinds":[{
-        "from":"pu_vendorcode",
-        "to":"pu_vendorcode"
-    },{
-        "from":"pu_vendorname",
-        "to":"pu_vendorname"
-    }],
-    "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
-}]
+{
+    "success": true,
+    "code": 0,
+    "message": null,
+    "data": {
+        "xtype": "formpanel",
+        "items": [{
+            "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",
+            "dbfinds":[{
+                "from":"pu_vendorcode",
+                "to":"pu_vendorcode"
+            },{
+                "from":"pu_vendorname",
+                "to":"pu_vendorname"
+            }],
+            "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
+        }]
+    }
+}