Переглянути джерело

客户、供应商等辅助类型界面提交

zhouy 7 роки тому
батько
коміт
5f2aab19df

+ 105 - 0
frontend/saas-web/app/view/document/kind/ChildForm.js

@@ -0,0 +1,105 @@
+/**
+ * Created by zhouy on 2018/10/18.
+ */
+Ext.define('KitchenSink.view.binding.ChildForm', {
+    extend: 'Ext.window.Window',
+    xtype: 'document-kind-childwin',
+    layout: 'fit',
+    modal: true,
+    width: 400,
+    height: 220,
+    listeners:{
+      show:function(w){
+          if(w.record){
+              w.down('form').loadRecord(w.record);
+          }
+
+      }
+    },
+    initComponent:function(){
+        var me=this;
+         Ext.apply(me,{
+           items:me.setFormItems()
+        });
+        me.callParent();
+    },
+
+    etc:{
+        customerkind:{
+            items:[{
+                xtype:'hidden',
+                name:'ck_id'
+            },{
+                xtype:'textfield',
+                name:'ck_kind',
+                allowBlank:false,
+                fieldLabel:'类型'
+            }],
+            keyField:'ck_id',
+            saveUrl:''
+        },
+        vendorkind:{
+            items:[{
+                xtype:'hidden',
+                name:'vk_id'
+            },{
+                xtype:'textfield',
+                name:'vk_kind',
+                allowBlank:false,
+                fieldLabel:'类型'
+            }],
+        },
+        productkind:{
+            items:[{
+                xtype:'hidden',
+                name:'pk_id'
+            },{
+                xtype:'textfield',
+                name:'pk_kind',
+                allowBlank:false,
+                fieldLabel:'类型'
+            }],
+        },
+        inoutkind:{
+
+        }
+    },
+    setFormItems:function() {
+        var me = this, kind = me.dataKind;
+        var conf = {
+            xtype: 'form',
+            bodyPadding: 10,
+            border: false,
+            modelValidation: true,
+            layout: {
+                type: 'vbox',
+                align: 'stretch'
+            },
+            defaults: {
+                xtype: 'textfield'
+            },
+            buttons: [{
+                text: '保存',
+                formBind:true,
+                handler: me.onSave,
+                scope:me
+            }, {
+                text: '取消',
+                handler: me.onCancel,
+                scope:me
+            }]
+        };
+        return Ext.apply(conf, me.etc[kind]);
+    },
+    onSave:function(){
+
+        var form=this.down('form');
+        alert('save');
+    },
+    onCancel:function(){
+        alert('cancel');
+        this.hide();
+    }
+
+
+});

+ 108 - 0
frontend/saas-web/app/view/document/kind/Kind.js

@@ -0,0 +1,108 @@
+/**
+ * Created by zhouy on 2018/10/18.
+ */
+Ext.define('saas.view.document.kind.Kind', {
+    extend: 'Ext.panel.Panel',
+    xtype: 'document-kind',
+    controller:'document-kind',
+    viewModel: {
+        type: 'document-kind'
+    },
+    tbar: [{
+        xtype: 'label',
+        text: '类型:',
+        padding: '0 0 0 5'
+    }, {
+        xtype: 'segmentedbutton',
+        reference: 'dataKind',
+        value: 'customerkind',
+        items: [{
+            text: '客户',
+            value: 'customerkind'
+        }, {
+            text: '供应商',
+            value: 'vendorkind'
+        }, {
+            text: '商品',
+            value: 'productkind'
+        }, {
+            text: '收支',
+            value: 'inoutkind'
+        }],
+        listeners: {
+            toggle: 'onKindToggle'
+        }
+    },'->',
+        {
+          xtype:'button',
+          text:'新增',
+          listeners: {
+              click: 'onAdd'
+          }
+        },{
+          xtype:'button',
+          text:'刷新',
+          listeners: {
+             click: 'onRefresh'
+          }
+    }],
+    items:[{
+        xtype:'grid',
+        reference: 'document-kind-Grid',
+        margin: '10 0 0 0',
+        flex: 1,
+        bind:{
+            selection: '{selectedCompany}'
+        },
+        listeners:{
+            render:'loadDefualt'
+        }
+    }],
+    etc:{
+        customerkind:{
+            columns: [{
+                text: '客户类型',
+                dataIndex: 'ck_kind',
+                flex: 1
+            }],
+            formItems:[{
+               xtype:'hidden',
+               name:'ck_id'
+            },{
+                xtype:'textfield',
+                name:'ck_kind',
+                allowBlank:false,
+                fieldLabel:'类型'
+            }],
+            keyField:'ck_id',
+            reqUrl:''
+        },
+        vendorkind:{
+            columns: [{
+                text: '供应商类型',
+                dataIndex: 'vk_kind',
+                flex: 1
+            }],
+            keyField:'vk_id',
+            reqUrl:''
+        },
+        productkind:{
+            columns: [{
+                text: '物料类型',
+                dataIndex: 'pk_kind',
+                flex: 1
+            }],
+            keyField:'pk_id',
+        },
+        inoutkind:{
+            columns: [{
+                text: '收支类型',
+                dataIndex: 'io_kind',
+                flex: 1
+            }],
+            keyField:'io_id'
+        }
+    }
+})
+
+

+ 88 - 0
frontend/saas-web/app/view/document/kind/KindController.js

@@ -0,0 +1,88 @@
+/**
+ * Created by zhouy on 2018/10/18.
+ */
+Ext.define('saas.view.document.kind.KindController', {
+    extend: 'Ext.app.ViewController',
+    alias: 'controller.document-kind',
+    loadDefualt:function(grid){
+        var me=this,
+            view = me.getView(),
+            vm = me.getViewModel(),
+            defaultKind=vm.getData()['dataKind'].value,
+            etc = view.etc[defaultKind];
+        grid.reconfigure(vm.getStore(defaultKind), me.insertActionColumn(etc.columns));
+    },
+    onKindToggle:function(container, button, pressed){
+       var me = this,
+            name = button.value,
+            view = me.getView(),
+            grid = me.lookup('document-kind-Grid'),
+            vm = me.getViewModel(),
+            etc = view.etc[name],
+            store=vm.getStore(name);
+       var columns=me.insertActionColumn(etc.columns);
+        grid.reconfigure(store, columns);
+        if(store) store.reload();
+        vm.set('title', button.text);
+    },
+    onAdd:function(){
+        var me=this,
+            dataKind=me.getViewModel().getData()['dataKind'].value;
+        me.createDialog(dataKind);
+    },
+    onRefresh:function(){
+
+    },
+    insertActionColumn:function(columns){
+        var me=this;
+        if(columns.length>0 && columns[0].xtype!='actioncolumn'){
+            return Ext.Array.insert(columns,0,[{
+                xtype:'actioncolumn',
+                items: [{
+                    tooltip: '编辑',
+                    iconCls: 'x-fa fa-pencil fa-fw',
+                    handler: me.onEdit,
+                    scope:this
+                },{
+                    text:'删除',
+                    iconCls:'x-fa fa-trash-o fa-fw',
+                    tooltip: '删除',
+                    handler: me.onDelete,
+                    scope:this
+                }]
+            }]);
+        }
+        return columns;
+    },
+    onEdit:function(grid,row,col){
+        var me=this,
+            view=me.getView(),
+            dataKind=me.getViewModel().getData()['dataKind'].value;
+            rec = grid.getStore().getAt(row);
+        var keyField=rec.get(view.etc[dataKind].keyField);
+        this.createDialog(dataKind,rec);
+    },
+    onDelete:function(grid,row,col){
+        var me=this,
+            view=me.getView(),
+            dataKind=me.getViewModel().getData()['dataKind'].value;
+        rec = grid.getStore().getAt(row);
+        var keyV=rec.get(view.etc[dataKind].keyField);
+        alert('删除ID:'+keyV);
+    },
+    createDialog: function(dataKind,record) {
+        var view = this.getView();var me=this;
+
+        this.isEdit = !!record;
+        this.dialog = view.add({
+            xtype: 'document-kind-childwin',
+            bind: {
+                title: record ? '修改{title}类型' : '新增{title}类型'
+            },
+            dataKind:dataKind,
+            record:record,
+            session: true
+        });
+        this.dialog.show();
+    }
+});

+ 57 - 0
frontend/saas-web/app/view/document/kind/KindModel.js

@@ -0,0 +1,57 @@
+/**
+ * Created by zhouy on 2018/10/18.
+ */
+Ext.define('saas.view.document.kind.KindModel', {
+    extend: 'Ext.app.ViewModel',
+    alias: 'viewmodel.document-kind',
+    data: {
+        title: '客户'
+    },
+    stores: {
+        customerkind: {
+            fields:[
+                {name: 'ck_id', type: 'int'},
+                {name: 'ck_kind',  type: 'string'}
+            ],
+            proxy: {
+                type: 'ajax',
+                url: 'resources/json/customer.json',
+                reader: {
+                    type: 'json'
+                }
+            },
+            pageSize: null,
+            autoLoad: true
+
+        },
+        vendorkind:{
+            fields:[
+                {name: 'vk_id', type: 'int'},
+                {name: 'vk_kind',  type: 'string'}
+            ],
+            proxy: {
+                type: 'ajax',
+                url: 'resources/json/vendor.json',
+                reader: {
+                    type: 'json'
+                }
+            },
+            pageSize: null,
+            autoLoad: false
+        },
+        productkind:{
+            fields:[
+                {name: 'pk_id', type: 'int'},
+                {name: 'pk_kind',  type: 'string'}
+            ],
+            data:[]
+        },
+        inoutkind:{
+            fields:[
+                {name: 'io_id', type: 'int'},
+                {name: 'io_kind',  type: 'string'}
+            ],
+            data:[]
+        },
+    }
+});

+ 7 - 0
frontend/saas-web/resources/json/customer.json

@@ -0,0 +1,7 @@
+[{
+  "ck_id":1,
+  "ck_kind":"kind1"
+},{
+  "ck_id":2,
+  "ck_kind":"kind2"
+}]

+ 7 - 0
frontend/saas-web/resources/json/vendor.json

@@ -0,0 +1,7 @@
+[{
+  "vk_id":1,
+  "vk_kind":"供应商类型1"
+},{
+  "vk_id":2,
+  "vk_kind":"供应商类型2"
+}]