Browse Source

代码提交

hy 5 years ago
parent
commit
c3def36996

+ 4 - 0
app/Application.scss

@@ -53,6 +53,10 @@ $enable-font-awesome: dynamic(true);
   width: 105px;
 }
 
+.x-monthpicker-item {
+  margin: 3px 0 3px;
+}
+
 .x-monthpicker-item-inner {
   margin: 0 5px 0 5px;
   line-height: 22px;

+ 5 - 3
app/controller/Global.js

@@ -98,9 +98,11 @@ Ext.define('uas.controller.Global', {
     },
 
     onTreeNavSelectionChange: function(tree, selected, eOpts) {
-        let target = selected[0].get('target');
-        if(target) {
-            this.redirectTo(target);
+        if(selected.length>0){
+            let target = selected[0].get('target');
+            if(target) {
+                this.redirectTo(target);
+            }
         }
     },
 

+ 7 - 3
app/model/DataListGridModel.js

@@ -10,8 +10,12 @@ Ext.define('uas.model.DataListGridModel', {
         name: 'id',
         type: 'int'
     }, {
-        name: 'company'
+        name: 'auditman'
     }, {
+        name: 'code'
+    },{
+        name: 'currency'
+    },{
         name: 'price',
         type: 'float'
     }, {
@@ -19,9 +23,9 @@ Ext.define('uas.model.DataListGridModel', {
         type: 'date',
         dateFormat: 'Y-m-d'
     }, {
-        name: 'visible',
+        name: 'special',
         type: 'boolean'
     }, {
-        name: 'size'
+        name: 'status'
     }]
 });

+ 1 - 0
app/store/FormGridStore.js

@@ -7,6 +7,7 @@
 Ext.define('uas.store.FormGridStore', {
     extend: 'Ext.data.Store',
     alias: 'store.formGridStore',
+    model: 'uas.model.DataListGridModel',
     pageSize: 100,
     proxy: {
         type: 'ajax',

+ 29 - 0
app/view/form/formpanel/FormPanelController.js

@@ -0,0 +1,29 @@
+Ext.define('uas.view.form.formpanel.FormPanelController', {
+    extend: 'Ext.app.ViewController',
+    alias: 'controller.formpanelcontroller',
+    init: function (form) {
+        var me = this;
+        this.control({
+            //放大镜赋值关系 以及 tpl模板
+            'producttrigger[name=code]':{
+                beforerender:function(f){
+                    Ext.apply(f, {
+                        dbfinds: [{
+                            from: 'code',
+                            to: 'code',
+                            ignore: true
+                        }, {
+                            from: 'price',
+                            to: 'price'
+                        }],
+                        searchUrl:'/api/searchPlanTree',
+                        dataUrl:'/api/productList',
+                        addXtype: 'document-product-formpanel',
+                        addTitle: '物料资料',
+                        defaultCondition: "pr_statuscode='ENABLE'",
+                    });
+                }
+            }
+        });
+    }
+});

+ 5 - 0
app/view/form/formpanel/FormPanelModel.js

@@ -0,0 +1,5 @@
+Ext.define('uas.view.form.formpanel.FormPanelModel', {
+    extend: 'Ext.app.ViewModel',
+    alias: 'viewmodel.formpanelmodel'
+
+});

+ 38 - 2
app/view/form/formpanel/Grid.js

@@ -2,11 +2,31 @@ Ext.define('uas.view.form.formpanel.Grid', {
     extend: 'Ext.grid.Panel',
     xtype: 'formpanel-grid',
 
+    requires: [
+        'Ext.selection.CellModel',
+        'Ext.grid.feature.Summary'
+    ],
+
     emptyText: '无数据',
     loadMask: true,
 
     bind:'{formGridStore}',
 
+    features: [{
+        ftype: 'summary',
+        dock: 'bottom'
+    }],
+
+    selModel: {
+        type: 'cellmodel'
+    },
+
+    plugins: {
+        cellediting: {
+            clicksToEdit: 1
+        }
+    },
+
     initComponent: function () {
         var me = this;
         Ext.apply(me, {
@@ -45,9 +65,13 @@ Ext.define('uas.view.form.formpanel.Grid', {
     columns: [{
         dataIndex: 'id',
         text: '序号',
-        width:60,
+        width:110,
         align:'center',
-        locked: true
+        locked: true,
+        summaryType: 'count',
+        summaryRenderer: function(value, summaryData, dataIndex) {
+            return Ext.String.format('共{0}条', value);
+        }
     }, {
         dataIndex: 'code',
         text: '采购单号',
@@ -55,6 +79,12 @@ Ext.define('uas.view.form.formpanel.Grid', {
         locked: true,
         filter: {
             type:'string'
+        },
+        editor: {
+            name:'code',
+            xtype:'producttrigger',
+            allowBlank: false,
+            selectOnFocus: false
         }
     }, {
         dataIndex: 'status',
@@ -79,11 +109,17 @@ Ext.define('uas.view.form.formpanel.Grid', {
             type:'string'
         }
     }, {
+        xtype:'numbercolumn',
         dataIndex: 'price',
         text: '含税金额',
+        format:'0,000.00',
         width:190,
         filter: {
             type:'number'
+        },
+        summaryType: 'sum',
+        summaryRenderer: function(value, summaryData, dataIndex) {
+            return Ext.String.format('合计:{0} 元', value.toFixed(2));
         }
     },{
         dataIndex: 'special',

+ 2 - 2
app/view/form/formpanel/ViewPort.js

@@ -6,8 +6,8 @@
  */
 Ext.define('uas.view.form.formpanel.ViewPort', {
     extend: 'Ext.form.Panel',
-    // constroller: 'main',
-    // viewModel: 'main',
+    controller: 'formpanelcontroller',
+    viewModel: 'formpanelmodel',
     xtype:'formpanel-viewport',
     layout: 'anchor',
 

+ 53 - 2
app/view/main/Main.js

@@ -7,7 +7,7 @@
 Ext.define('uas.view.main.Main', {
     extend: 'Ext.container.Viewport',
 
-    constroller: 'main',
+    controller: 'main',
     viewModel: 'main',
     layout: 'border',
 
@@ -24,7 +24,58 @@ Ext.define('uas.view.main.Main', {
         layout: 'border',
         items: [{
             region: 'center',
-            xtype: 'navigation-tree'
+            xtype: 'navigation-tree',
+            tbar:{
+                layout:'fit',
+                items:[{
+                    xtype: 'searchfield',
+                    name: 'query',
+                    emptyText: '请输入关键词',
+                    store: 'Navigation',
+                    onClearClick : function(){
+                        var me = this;
+                        me.setValue('');
+                        me.store.clearFilter();
+                        me.getTrigger('clear').hide();
+                        me.updateLayout();
+                    },
+                    onSearchClick : function(){
+                        var me = this,tree = me.ownerCt.ownerCt,
+                            value = me.getValue();
+                 
+                        if (value.length > 0) {
+                            me.store.clearFilter();
+                            me.store.setRemoteFilter(false);
+                            me.store.filter([{
+                                filterFn: function(item) {
+                                    item.expand();
+                                    if(item.id == 'root'){
+                                        return true; 
+                                    }else if(!item.isLeaf()){
+                                        let hasChild = item.findChildBy(function(item){
+                                            return item.get('text').indexOf(value)>-1
+                                        },item,5);
+                                        if(hasChild){
+                                            return true
+                                        }else{
+                                            return false
+                                        }
+                                    }else if(item.get('text').indexOf(value)>-1){
+                                        return true; 
+                                    }else{
+                                        return false;
+                                    }
+                                }
+                            }]);
+                            me.getTrigger('clear').show();
+                            me.updateLayout();
+                        }else{
+                            me.getTrigger('clear').hide();
+                            me.store.clearFilter();
+                        }
+                    }
+                },'->']
+            }
         }]
     }, {
         split:true,

+ 422 - 0
app/view/trigger/DbfindTrigger.js

@@ -0,0 +1,422 @@
+Ext.define('uas.view.trigger.DbfindTrigger', {
+    extend: 'Ext.form.ComboBox',
+    xtype: 'dbfindtrigger',
+    triggerCls: Ext.baseCSSPrefix + 'form-search-trigger',
+    queryMode: 'local',
+    displayField: 'dispaly',
+    valueField: 'value',
+    minChars: 1, // 设置用户输入字符多少时触发查询
+    tpl: '',
+    enableKeyEvents: true,
+    initComponent: function () {
+        var me = this;
+        Ext.apply(me, me.applyConfig());
+        me.callParent();
+    },
+    applyConfig: function() {
+        var me = this,
+        dbtpls = me.dbtpls || [],
+        fields = [],
+        minWidth = 0,
+        cols = '';
+
+        for(let x = 0; x < dbtpls.length; x++) {
+            let dbtpl = dbtpls[x],
+            width = dbtpl.width || 100,
+            field = dbtpl.field;
+
+            fields.push(field);
+            minWidth += width;
+            cols += '<span style="padding:0 10px 0 10px;width:' + width + 'px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;float:left;">{' + field + '}</span>';
+        }
+
+        minWidth += 15;
+
+        cfg = {
+            store: Ext.create('Ext.data.Store', {
+                fields: fields,
+                data: []
+            }),
+            listConfig: {
+                minWidth: minWidth,
+                width: minWidth,
+                maxHeight: 210,
+                autoScroll: true
+            },
+            tpl: Ext.create('Ext.XTemplate',
+                '<ul style="padding-left: 0px;"><tpl for=".">',
+                '<li role="option" class="x-boundlist-item" style="list-style:none; padding: 0;">',
+                '<div style="height:30px;">',
+                '' + cols + '',
+                '</li>',
+                '</tpl></ul>'
+            )
+        };
+
+        return cfg;
+    },
+
+    //输入值之后进行模糊查询
+    doQuery: function (queryString, forceAll, rawQuery) {
+        if (!this.fireEvent('beforequery', this)) {
+            return;
+        };
+        queryString = queryString || '';
+        var me = this;
+        if (me.lastQueryValue != queryString) {
+            me.judge(me);
+            me.lastQueryValue = queryString;
+            if (queryString.trim() == '') {
+                me.collapse();
+            } else {
+                //加载数据
+                var data, dbfinds = me.dbfinds, dbCondition = [];
+                if (dbfinds) {
+                    var dbtplcondition = "";
+                    for (let index = 0; index < dbfinds.length; index++) {
+                        var item = dbfinds[index].from;
+                        if (!dbfinds[index].ignore) {
+                            dbtplcondition += "upper(" + item + ") like '%" + queryString.toUpperCase() + "%' or ";
+                        }
+                    }
+                    dbtplcondition = "(" + dbtplcondition.substring(0, dbtplcondition.length - 4) + ")";
+                    if (dbtplcondition.length > 0) {
+                        dbCondition = [{
+                            type: 'condition',
+                            value: dbtplcondition
+                        }];
+                    }
+                }
+                //添加默认条件
+                if (me.defaultCondition) {
+                    dbCondition.push({
+                        type: 'condition',
+                        value: me.defaultCondition
+                    });
+                }
+                Ext.Ajax.request({
+                    url: me.dataUrl,
+                    params: {
+                        number: 1,
+                        size: 10,
+                        condition: JSON.stringify(dbCondition),
+                        page: 1,
+                        start: 0,
+                        limit: 10
+                    },
+                    method: 'GET',
+                    success: function (response, opts) {
+                        data = Ext.decode(response.responseText);
+                        data = data.data ? data.data.list : [];
+                        if (data != null && data.length > 0 && me.store) {
+                            me.store.loadData(data, false);
+                            me.expand();
+                        } else {
+                            me.store.removeAll();
+                            me.collapse();
+                        }
+                    },
+                    failure: function (response, opts) {}
+                });
+            }
+            return true;
+        } else {
+            return false;
+        }
+    },
+    onTriggerClick: function (f) {
+        var me = this;
+        if (!this.fireEvent('beforetriggerclick', this)) {
+            return;
+        };
+        f.blur(f,null,null,true);
+        //判断dbfindtrigger归属
+        f.judge(f); //form
+        var panel = f.up('content-panel') || Ext.getCmp('content-panel'),
+            panelEl;
+        if (!f.column && f.ownerCt.ownerCt.id.indexOf('window-') > -1 && f.ownerCt.ownerCt.id.indexOf('document-') <0) {
+            panelEl = f.ownerCt.ownerCt.getEl()
+        } else {
+            panelEl = panel.getEl()
+        }
+        var box = panelEl.getBox();
+        var height = box.height;
+        var width = box.width;
+
+        var dbItem = {
+            xtype: 'dbfindtriggerpanel',
+            columns: f.dbColumns,
+            dataUrl: f.dataUrl,
+            searchUrl: f.searchUrl,
+            dbfinds: f.dbfinds,
+            belong: f.belong,
+            dbSearchFields: f.dbSearchFields ? f.dbSearchFields : [],
+            dbfindtrigger: f,
+        };
+
+        if (me.onAddClick) {
+            dbItem.onAddClick = me.onAddClick;
+        }
+
+        var win = panel.add(Ext.create('Ext.window.Window', {
+            cls: 'x-window-dbfind',
+            trigger: f,
+            belong: f.ownerCt,
+            modal: true,
+            height: height * 0.9,
+            width: width * 0.9,
+            title: '查找' + f.addTitle,
+            scrollable: true,
+            bodyPadding: 10,
+            constrain: true,
+            closable: true,
+            layout: 'fit',
+            renderTo: panel.getEl(),
+            items: [dbItem]
+        }));
+        win.show();
+    },
+
+    judge: function (f) {
+        if (f.ownerCt.xtype.trim().toUpperCase().indexOf('QUERYFORMPANEL') > -1 ||
+            (f.ownerCt.ownerCt && (f.ownerCt.ownerCt.xtype.trim().toUpperCase().indexOf('BASEPANEL') > -1 ||
+                f.ownerCt.ownerCt.xtype.trim().toUpperCase().indexOf('EDITDATALIST') > -1))) {
+            f.belong = 'form';
+            return f.ownerCt.ownerCt
+        } else if (f.ownerCt.xtype.trim().toUpperCase().indexOf('FORM') > -1) {
+            f.belong = 'form';
+            return f.ownerCt
+        } else if (f.column) {
+            f.belong = 'grid';
+            return f.column.ownerCt.ownerCt.ownerCt
+        }
+    },
+
+    listeners: {
+        blur: function (f, e, op, isTrigger) {
+            return true;//先不使用
+            var me = f;
+            var dbfinds = me.dbfinds,
+                data;
+            if (f.value && f.value != '') {
+                //添加默认条件
+                var searchField = null;
+                var dbCondition = [];
+                if (me.defaultCondition) {
+                    dbCondition.push({
+                        type: 'condition',
+                        value: me.defaultCondition
+                    });
+                }
+                for (let index = 0; index < dbfinds.length; index++) {
+                    var item = dbfinds[index].to;
+                    if (item == me.name) {
+                        searchField = dbfinds[index].from;
+                    }
+                }
+                dbCondition.push({
+                    type: 'condition',
+                    value: searchField + "='" + me.value + "'"
+                });
+                Ext.Ajax.request({
+                    url: me.dataUrl,
+                    async: false,
+                    params: {
+                        number: 1,
+                        size: 1,
+                        condition: JSON.stringify(dbCondition),
+                        page: 1,
+                        start: 0,
+                        limit: 10
+                    },
+                    method: 'GET',
+                    success: function (response, opts) {
+                        data = Ext.decode(response.responseText);
+                        data = data.data ? data.data.list : [];
+                    },
+                    failure: function (response, opts) {}
+                });
+            }
+            if (!f.value || f.value == '' || data.length > 1 || data.length == 0) {
+                me.dbValues = {};
+                if (dbfinds && dbfinds.length > 0) {
+                    if (me.belong == 'grid') {
+                        for (let index = 0; index < dbfinds.length; index++) {
+                            var item = dbfinds[index];
+                            var rec = me.column.ownerCt.ownerCt.selModel.getLastSelected();
+                            var nowRec = me.column.ownerCt.ownerCt.store.getData().getByKey(rec.id);
+                            if (nowRec.get(item.to) && nowRec.get(item.to) != "") {
+                                nowRec.set(item.to, null);
+                                delete nowRec.modified[item.to];
+                            }
+                            if (me.name == item.to) {
+                                me.column.getEditor().setValue('');
+                            }
+                        }
+                    } else if (me.belong == 'form') {
+                        for (let index = 0; index < dbfinds.length; index++) {
+                            var item = dbfinds[index];
+                            var field = me.ownerCt.down('[name=' + item.to + ']');
+                            if (field) {
+                                let xtypes = field.getXTypes().split('/');
+                                if (xtypes.indexOf('dbfindtrigger') != -1) {
+                                    field.setValue(null);
+                                    field.lastTriggerValue = null;
+                                } else {
+                                    field.setValue(null);
+                                    field.publishState('value', null);
+                                }
+                            }
+                        }
+                    }else {
+                        me.setValue(null);
+                    }
+                }
+                if(!isTrigger){
+                    let rec = {
+                        data:{},
+                        get:function(name){
+                            return this.data[name]
+                        }
+                    }
+                    f.aftertrigger(f,rec);
+                }
+            } else if (data.length == 1) {
+                me.dbValues = data[0];
+                var dbfinds = me.dbfinds;
+                if (dbfinds && dbfinds.length > 0) {
+                    if (me.belong == 'grid') {
+                        for (let index = 0; index < dbfinds.length; index++) {
+                            var item = dbfinds[index];
+                            var rec = me.column.ownerCt.ownerCt.selModel.getLastSelected();
+                            var nowRec = me.column.ownerCt.ownerCt.store.getData().getByKey(rec.id);
+                            nowRec.set(item.to, data[0][item.from]);
+                            if (me.name == item.to) {
+                                me.column.getEditor().setValue(data[0][item.from]);
+                            }
+                        }
+                    } else if (me.belong == 'form') {
+                        for (let index = 0; index < dbfinds.length; index++) {
+                            var item = dbfinds[index];
+                            var field = me.ownerCt.down('[name=' + item.to + ']');
+                            if (field) {
+                                var val = data[0][item.from];
+                                if (field.xtype == 'dbfindtrigger') {
+                                    field.setRawValue(val);
+                                    field.setValue(val);
+                                    field.value = val;
+                                    field.lastTriggerValue = val;
+                                } else {
+                                    field.setValue(val);
+                                }
+                            }
+                        }
+                    }
+                }
+                if(!isTrigger){
+                    let rec = {
+                        data:data[0],
+                        get:function(name){
+                            return this.data[name]
+                        }
+                    }
+                    f.aftertrigger(f,rec);
+                }
+            }
+        },
+        select: function (combo, record, eOpts) {
+            var me = combo;
+            var dbfinds = me.dbfinds;
+            me.dbValues = record.data;
+            if (dbfinds && dbfinds.length > 0) {
+                if (me.belong == 'grid') {
+                    for (let index = 0; index < dbfinds.length; index++) {
+                        var item = dbfinds[index];
+                        var rec = me.column.ownerCt.ownerCt.selModel.getLastSelected();
+                        var nowRec = me.column.ownerCt.ownerCt.store.getData().getByKey(rec.id);
+                        nowRec.set(item.to, record.get(item.from));
+                        if (me.name == item.to) {
+                            me.column.getEditor().setValue(record.get(item.from));
+                        }
+                    }
+                } else if (me.belong == 'form') {
+                    for (let index = 0; index < dbfinds.length; index++) {
+                        var item = dbfinds[index];
+                        var field = me.ownerCt.down('[name=' + item.to + ']');
+                        if (field) {
+                            var val = record.get(item.from);
+                            if (field.xtype == 'dbfindtrigger') {
+                                field.setRawValue(val);
+                                field.setValue(val);
+                                field.value = val;
+                                field.lastTriggerValue = val;
+                            } else {
+                                field.setValue(val);
+                            }
+                        }
+                    }
+                }else {
+                    var dbfind = Ext.Array.findBy(dbfinds, function(d) {
+                        return d.to = me.name;
+                    });
+                    if(dbfind) {
+                        me.setValue(record.get(dbfind.from));
+                    }
+                }
+                
+                me.aftertrigger(me, record);
+            }
+        }
+    },
+
+    aftertrigger: function (f) {
+        return true;
+    },
+
+    setValue: function (v) {
+        this.callParent(arguments);
+        this.publishState('value', v);
+    },
+
+    getValue: function (f) {
+        var me = this,
+            val = me.rawToValue(me.processRawValue(me.getRawValue()));
+        me.value = val;
+        return val;
+    },
+
+    autoSetValue: function (combo, record) {
+        var me = combo;
+        var dbfinds = me.dbfinds;
+        if (dbfinds && dbfinds.length > 0) {
+            if (me.belong == 'grid') {
+                for (let index = 0; index < dbfinds.length; index++) {
+                    var item = dbfinds[index];
+                    var rec = me.column.ownerCt.ownerCt.selModel.getLastSelected();
+                    var nowRec = me.column.ownerCt.ownerCt.store.getData().getByKey(rec.id);
+                    nowRec.set(item.to, record.get(item.from));
+                    if (me.name == item.to) {
+                        me.column.getEditor().setValue(record.get(item.from));
+                    }
+                }
+            } else if (me.belong == 'form') {
+                for (let index = 0; index < dbfinds.length; index++) {
+                    var item = dbfinds[index];
+                    var field = me.ownerCt.down('[name=' + item.to + ']');
+                    if (field) {
+                        var val = record.get(item.from);
+                        if (field.xtype == 'dbfindtrigger') {
+                            field.setRawValue(val);
+                            field.setValue(val);
+                            field.value = val;
+                            field.lastTriggerValue = val;
+                        } else {
+                            field.setValue(val);
+                        }
+                    }
+                }
+            }
+            me.aftertrigger(me, record);
+        }
+    }
+});

+ 373 - 0
app/view/trigger/DbfindTriggerPanel.js

@@ -0,0 +1,373 @@
+Ext.define('uas.view.trigger.DbfindTriggerPanel', {
+    extend: 'Ext.grid.Panel',
+    xtype: 'dbfindtriggerpanel',
+    dataUrl: '',
+    dbSearchFields: [],
+    condition:'',
+    plugins: {
+        gridHeaderFilter: true
+    },
+    dockedItems: [{
+        name:'operateToolbar',
+        cls:'x-grid-operateToolbar',
+        xtype: 'toolbar',
+        dock: 'top',
+        height:32,
+        items:[{
+            cls:'x-btn-blue',
+            xtype:'button',
+            text:'筛选',
+            handler:function(me){
+                const grid = me.up('dbfindtriggerpanel');
+                if(!grid.searchPlanWindow){
+                    grid.searchPlanWindow = Ext.create('widget.searchPlanWindow',{
+                        modal: false,
+                        height:grid.getHeight()*0.8,
+                        width:grid.getWidth()*0.8,
+                        renderTo:grid.ownerCt.getEl(),
+                        grid:grid
+                    }).show();
+                }else{
+                    grid.searchPlanWindow.show();
+                }
+            }
+        },{
+            margin:'0 0 0 6',
+            xtype:'button',
+            text:'批处理'
+        },{
+            margin:'0 0 0 6',
+            xtype:'button',
+            text:'上一页'
+        },{
+            margin:'0 0 0 6',
+            xtype:'button',
+            text:'下一页'
+        },{
+            margin:'0 0 0 6',
+            xtype:'button',
+            text:'导出'
+        },{
+            margin:'0 0 0 6',
+            xtype:'button',
+            text:'个性设置'
+        },{
+            margin:'0 0 0 12',
+            xtype:'button',
+            text:'关闭'
+        }]
+    },{
+        xtype: 'toolbar',
+        dock: 'top',
+        name:'searchPlan',
+        cls:'x-grid-searchPlan',
+        height:32,
+        items:[{
+            xtype:'displayfield',
+            value:'查询方案:'
+        }]
+    },{
+        xtype: 'toolbar',
+        dock: 'top',
+        name:'filterToolbar',
+        cls:'x-grid-filterToolbar',
+        height:32,
+        items:[{
+            xtype:'displayfield',
+            value:'筛选条件:'
+        },'->']
+    },{
+        xtype: 'dataListPaging'
+    }],
+
+    initComponent: function() {
+        var me = this;
+        me.initColumns();
+        if(me.columns){
+            var fields = me.columns.map(column => column.dataIndex);
+            me.store = Ext.create('Ext.data.Store',{
+                fields:fields,
+                autoLoad: true,
+                pageSize: 20,
+                data: [],
+                proxy: {
+                    type: 'ajax',
+                    timeout:8000,
+                    url: me.dataUrl,
+                    actionMethods: {
+                        read: 'GET'
+                    },
+                    reader: {
+                        type: 'json',
+                        rootProperty: 'data.list',
+                        totalProperty: 'data.total',
+                    },
+                    listeners: {
+                        exception: function(proxy, response, operation, eOpts) {
+                            if(operation.success) {
+                                if(response.timedout) {
+                                    saas.util.BaseUtil.showErrorToast('请求超时');
+                                }
+                            }else {
+                                console.error('exception: ', response);
+                                saas.util.BaseUtil.showErrorToast('查询失败:' + (response.responseJson?response.responseJson.message:'请求超时'));
+                            }
+                        }
+                    }
+                },
+                listeners: {
+                    beforeload: function (store, op) {
+                        var condition = me.condition;
+                        if (Ext.isEmpty(condition)) {
+                            condition = [];
+                        }
+                        //添加默认条件
+                        if(me.up('window').trigger.defaultCondition) {
+                            condition.push({
+                                type: 'condition',
+                                value: me.ownerCt.trigger.defaultCondition
+                            });
+                        }
+                        Ext.apply(store.proxy.extraParams, {
+                            number: op._page,
+                            size: store.pageSize,
+                            condition: JSON.stringify(condition)
+                        });
+                    }
+                }
+            });
+        }
+        me.callParent(arguments);
+
+        me.getSearchPlan();
+    },
+
+    listeners:{
+        boxready: function(grid, width, height, eOpts) {
+            var store = grid.getStore(),
+            gridBodyBox = grid.body.dom.getBoundingClientRect(),
+            gridBodyBoxHeight = gridBodyBox.height;
+
+            var pageSize = Math.floor(gridBodyBoxHeight / 33);
+
+            store.setPageSize(pageSize);
+        },
+        itemClick: function(view,record) {
+            var me = this;
+            var dbfinds = me.dbfinds;
+            var ownerTrigger = me.ownerCt.trigger;
+            ownerTrigger.dbValues = record.data;
+
+            if(dbfinds&&dbfinds.length>0){
+                if(me.belong=='grid'){
+                    for (let index = 0; index < dbfinds.length; index++) {
+                        var item = dbfinds[index];
+                        var mainGrid = me.dbfindtrigger.column.ownerCt.ownerCt;
+                        var rec = mainGrid.selModel.getLastSelected();
+                        if(rec){
+                            var nowRec = me.dbfindtrigger.column.ownerCt.ownerCt.store.getData().getByKey(rec.id);
+                            nowRec.set(item.to,record.get(item.from));
+                            //me.column.getEditor().setValue(record.get(item.from));
+                            //mainGrid.up('detailGridField').fireEvent('edit');
+                        }
+                    }
+                }else if(me.belong=='form'){
+                    for (let index = 0; index < dbfinds.length; index++) {
+                        var item = dbfinds[index];
+                        var field = me.ownerCt.belong.down('[name='+item.to+']');
+                        if(field){
+                            var val = record.get(item.from);
+                            if(field.xtype=='dbfindtrigger'){
+                                field.setValue(val);
+                                field.lastTriggerValue=val;
+                            }else{
+                                field.setValue(val);
+                            }    
+                        }
+                    }
+                }else {
+                    var dbfind = Ext.Array.findBy(dbfinds, function(d) {
+                        return d.to = ownerTrigger.name;
+                    });
+                    if(dbfind) {
+                        ownerTrigger.setValue(record.get(dbfind.from));
+                    }
+                }
+                
+                ownerTrigger.aftertrigger(ownerTrigger,record);
+            }
+            me.ownerCt.close();
+        }
+    },
+
+    initColumns: function() {
+        var me = this,
+        columns = me.columns || [];
+
+        Ext.Array.each(columns, function(c) {
+            Ext.applyIf(c, {
+                width: 200
+            });
+        });
+    },
+
+    getSearchFields: function() {
+        var me = this,
+        searchFields = me.dbSearchFields;
+
+        Ext.Array.each(searchFields, function(f) {
+            f.enableKeyEvents = true;
+            f.listeners = {
+                keydown: function(th, e, eOpts) {
+                    if(e.keyCode == 13) {
+                        me.condition = '', items = [];
+                        Ext.Array.each(searchFields,function(f) {
+                            var field = th.ownerCt.down('[name='+f.name+']')
+                            items.push(field);
+                        });
+                        me.condition = me.getCondition(items);
+                        me.store.loadPage(1);
+                    }
+                }
+            }
+        });
+
+        return searchFields;
+    },
+
+    /**
+     * 获得过滤条件
+     */
+    getCondition: function(items) {
+        var me = this,
+        conditions = [];
+
+        for(var i = 0; i < items.length; i++) {
+            var item = items[i];
+            var field = item.name,
+            func = item.getCondition,
+            value = item.value,
+            condition;
+
+            if(value&&value!=''){
+                if(typeof func == 'function') {
+                    condition = {
+                        type: 'condition',
+                        value: func(value)
+                    }
+                }else {
+                    var xtype = item.xtype || 'textfield',
+                    type = item.fieldType || me.getDefaultFieldType(xtype),
+                    operation = item.operation || me.getDefaultFieldOperation(xtype),
+                    conditionValue = me.getConditionValue(xtype, value);
+        
+                    if(!conditionValue) {
+                        continue;
+                    }
+                    condition = {
+                        type: type,
+                        field: field,
+                        operation: operation,
+                        value: conditionValue
+                    }
+                }
+                conditions.push(condition);
+            }
+        };
+        return conditions;
+    },
+
+    getDefaultFieldType: function(xtype) {
+        var type;
+
+        if(Ext.Array.contains(['numberfield'], xtype)) {
+            type = 'number';
+        }else if(Ext.Array.contains(['datefield', 'condatefield'], xtype)) {
+            type = 'date';
+        }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo', 'radiofield', 'radio'], xtype)) {
+            type = 'enum';
+        }else {
+            type = 'string';
+        }
+
+        return type;
+    },
+
+    getDefaultFieldOperation: function(xtype) {
+        var operation;
+
+        if(Ext.Array.contains(['numberfield'], xtype)) {
+            operation = '=';
+        }else if(Ext.Array.contains(['datefield'], xtype)) {
+            operation = '=';
+        }else if(Ext.Array.contains(['condatefield'], xtype)) {
+            operation = 'between';
+        }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo'], xtype)) {
+            operation = 'in';
+        }else {
+            operation = 'like';
+        }
+
+        return operation;
+    },
+
+    /**
+     * 处理部分字段值
+     */
+    getConditionValue: function(xtype, value) {
+        var conditionValue;
+        if(xtype == 'datefield') {
+            conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
+        }else if(xtype == 'condatefield') {
+            var from = value.from,
+            to = value.to;
+
+            conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
+        }else if(xtype == 'combobox' || xtype == 'combo') {
+            conditionValue = '\'' + value + '\'';
+        }else if(xtype == 'multicombo') {
+            conditionValue = value.map(function(v) {
+                return '\'' + v.value + '\'';
+            }).join(',');
+        }else {
+            conditionValue = value;
+        }
+
+        return conditionValue;
+    },
+
+    onAddClick: function(){
+        var grid = this;
+        var trigger = grid.ownerCt.trigger;
+        saas.util.BaseUtil.openTab(trigger.addXtype, '新增'+trigger.addTitle,trigger.addXtype + '_add');
+    },
+
+    getSearchPlan:function(){
+        const me = this;
+        Ext.Ajax.request({
+            url: me.searchUrl,
+            params: '',
+            method: 'GET',
+            async:false,
+            success: function(response, opts) {
+                var _data = Ext.decode(response.responseText);
+                if(_data&&_data.data){
+                    const searchPlan = me.down('[name=searchPlan]');
+                    let items = [];
+                    Ext.Array.each(_data.data,function(p){
+                        if(p.children&&p.children.length>0){
+                            Ext.Array.each(p.children,function(item){
+                                items.push({
+                                    text:item.text,
+                                    xtype:'button'
+                                })
+                            })
+                        }
+                    });
+                    searchPlan.add(items);
+                }
+            },
+            failure: function(response, opts) {}
+        }); 
+    }
+});

+ 59 - 0
app/view/trigger/DbfindTriggerPanel.scss

@@ -0,0 +1,59 @@
+.x-window-dbfind{
+    padding: 0px 0px 0px 0px !important;
+    border:none;
+    .x-window-header{
+        border: none;
+        background-color: #fff;
+    }
+    .x-title-text{
+        padding-left: 7px;
+        font-weight: 550;
+        color: #35baf6;
+    }
+    .x-tbar-page-number .x-form-text{
+        height: 16px !important;
+        min-height: 16px;
+        padding: 0px;
+        text-align: center;
+    }
+    .x-tbar-page-number{
+        width: 40px !important;
+    }
+    .x-title-text::before{
+        margin-left: -10px;
+        content: ' ';
+        display: block;
+        border-style: solid;
+        border-radius: 4px;
+        background-color: #34baf6;
+        position: fixed;
+        width: 0px;
+        margin-top: 2px;
+        height: 10px;
+    }
+    .x-tool-tool-el{
+        color:#35baf6 !important;
+    }
+    .x-window-body{
+        padding-top: 0px !important;
+        // background-image: url(get-resource-path('images/default/win-bg-img.png'));
+    }
+    .x-toolbar-docked-top {
+        padding: 6px 0 12px 0px;
+    }
+    .x-grid-header-ct {
+        border: 1px solid #abdaff !important;
+    }
+    .x-grid-body {
+        border-width: 1px;
+        border-color: #abdaff;
+        border-right-width: 1px !important;
+        border-left-width: 1px !important;
+        border-top-width: 0px !important;
+        border-bottom-width: 1px !important;
+    }
+    .x-grid-paging-toolbar{
+        border: 1px solid #abdaff !important;
+        border-top-width: 0px !important;
+    }
+}

+ 62 - 0
app/view/trigger/define/ProductTrigger.js

@@ -0,0 +1,62 @@
+Ext.define('uas.view.trigger.define.ProductTrigger', {
+    extend: 'uas.view.trigger.DbfindTrigger',
+    xtype: 'producttrigger',
+
+    dbtpls: [{
+        field: 'code',width: 200
+    }, {
+        field: 'price',width: 150
+    }],
+    dbColumns:[{
+        text: "物料ID",
+        hidden: true,
+        dataIndex: "id"
+    }, {
+        text: "物料编号",       
+        dataIndex: "code",
+        width: 250,
+        filter:{
+            type:'string'
+        }
+    },{
+        text: "供应商",
+        width: 190,
+        dataIndex: "vendor",
+        filter:{
+            type:'string'
+        }
+    }, {
+        text : "型号", 
+        dataIndex : "currency", 
+        width : 200.0,
+        filter:{
+            type:'string'
+        }
+    }, {
+        text : "规格", 
+        dataIndex : "currency", 
+        width : 200.0,
+        filter:{
+            type:'string'
+        }
+    },{
+        text: "单位",
+        dataIndex: "currency",
+        width: 65
+    },{
+        text: "类型",
+        dataIndex: "currency",
+        width: 100
+    },{
+        text: "库存",
+        dataIndex: "price",
+        width: 100,
+        xtype: 'numbercolumn',
+        filter:{
+            type:'number'
+        }
+    }, {
+        dataIndex: '',
+        flex: 1
+    }]
+});

+ 2 - 0
app/view/window/searchPlan/ConditionPanel.js

@@ -39,11 +39,13 @@ Ext.define('uas.view.window.searchPlan.ConditionPanel', {
         margin:'0',
         xtype:'tabpanel',
         columnWidth:1,
+        height:300,
         tabBar: {
             layout: {
                 pack: 'center'
             }
         },
+        layout:'fit',
         style:'border-top:1px solid rgb(197, 197, 197)',
         items:[{
             name:'baseConditionGrid',

+ 3 - 1
server/action/index.js

@@ -6,6 +6,7 @@ var upload = require('./file-upload');
 var download = require('./file-download');
 var fileInfo = require('./file-info');
 var formGridList = require('./formGridList');
+var productList = require('./productList');
 
 module.exports = {
     '/bigData': bigData,
@@ -15,5 +16,6 @@ module.exports = {
     '/file/upload': upload,
     '/file/download': download,
     '/file/info': fileInfo,
-    '/formGridList': formGridList
+    '/formGridList': formGridList,
+    '/productList':productList
 }

+ 24 - 0
server/action/productList.js

@@ -0,0 +1,24 @@
+var productList = (function(){
+    let arr = [];
+    for(let i=0;i<5;i++){
+        arr.push({
+            id:(i+1),
+            code:"PU"+(2019081900000001+Number(i))+"",
+            status:(i%5)===0?"已审核":"在录入",
+            date:"2019-08-19",
+            vendor:(i%2)===0?"广东省深圳市南山区供应商A001":"广东省广州市天河区供应商B002",
+            price:(Math.random()*(3000-1000)+10).toFixed(2),
+            currency:"RMB",
+            recordman:"小明",
+            auditman:"大明",
+            special:(i%2)===0?true:false,
+        })
+    }
+    return arr;
+})();
+
+module.exports = function(request, response){
+    return {
+        list: productList
+    };
+}