gscloud-idp(二)

动态生成查询条件控件

  1. 用时生成

//动态生成方法
function dynGenerateFilter(father, filters) {
    var temp = {
        "id": "",
        "tbid": "",
        "type": "input",
        "label": "标题",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "25%",
        "calc": [],
        "rules": [],
        "ord": 0,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_input": {},
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {},
        "ishow": true,
        "labelWidth": ""
    }
    for (var i = 0; i < filters.length; i++) {

        var ctrl = $.extend(true, {}, temp, filters[i]);
        $(father).append(
            $('<div class="table-item table-col-25" style="width:25%;"><div class="table-label"><span title="标题" id="lbl_' + ctrl.id + '">' + ctrl.label + '</span></div><div class="table-editor"><input autocomplete="off" type="text" id="' + ctrl.id + '"></div></div>'))
        idp.list.ui.initCtrl(ctrl);
        if (ctrl.type = "dropdown" && ctrl.editor_dropdown && ctrl.editor_dropdown.data) {
            idp.control.get(ctrl.id).setData(ctrl.editor_dropdown.data);
        }

    }

}
//测试方法
function testfunc() {
    //测试数据
    var filters = [{
            "id": "input_111",
            "type": "input",
            "label": "文本测试"
        },
        {
            "id": "dropdown_222",
            "type": "dropdown",
            "label": "下拉测试",
            "editor_dropdown": {
                "datatype": "str",
                "data": [{
                            key: "0",
                            value: "否"
                        }, { 
                            key: "1",
                            value: "是"
                        }
                        ],
                        "json": ""
                        //"json": "MCzlkKY7MSzmmK8="
                    }
                }, {
                    "id": "lookup_333",
                    "type": "lookup",
                    "label": "帮助测试",
                    "editor_lookup": {
                        "sqlid": "652cbba4-6853-05d1-68ad-1cd07aef27ea",
                        "type": "lookup",
                        "id": "lookup_507434",
                        "sqlid_text": "外部ERP帮助",
                        "idfield": "ID",
                        "codefield": "CODE",
                        "namefield": "NAME"
                    }
                }, {
                    "id": "input_444",
                    "type": "date",
                    "label": "时间测试",
                    "editor_date": {
                        "showType": "datetime",
                        "multiple": false,
                        "range": false
                    }
                }, {
                    "id": "input_555",
                    "type": "date",
                    "label": "日期测试",
                    "editor_date": {
                        "showType": ""
                    }
                }
                ]

                dynGenerateFilter("#col_filter", filters);

            }
  1. 表单加载时生成

新建5个动态控件,分别是文本框,复选框,帮助,下拉框,帮助

索引列表

idp.event.bind('mountReady',function(e,self){
    self.viewConfig.layout['layout_filter']['childs'][0]['childs'].push('input_935800');
    self.viewConfig.layout['layout_filter']['childs'][0]['childs'].push('checkbox_864569');
    self.viewConfig.layout['layout_filter']['childs'][0]['childs'].push('lookup_196684');
    self.viewConfig.layout['layout_filter']['childs'][0]['childs'].push('dropdown_457936');
    self.viewConfig.layout['layout_filter']['childs'][0]['childs'].push('lookup_1966847');
    self.viewConfig.controls["input_935800"]= {
        "id": "input_935800",
        "tbid": "",
        "type": "input",
        "label": "标题1",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 0,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_input": {},
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {},
        "ishow": true,
        "labelWidth": ""
    },
    self.viewConfig.controls["checkbox_864569"]={
        "id": "checkbox_864569",
        "tbid": "",
        "type": "checklist",
        "label": "标题3",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 2,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_checklist": {},
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {},
        "ishow": true,
        "labelWidth": ""
    },
    self.viewConfig.controls["lookup_196684"]= {
        "id": "lookup_196684",
        "tbid": "",
        "type": "lookup",
        "label": "标题2",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 1,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_lookup": {
            "sqlid": "00302643-ce39-76d1-9617-4242fde78174",
            "type": "lookup",
            "id": "lookup_196684",
            "sqlid_text": "合并报表核算项目帮助",
            "idfield": "ID",
            "codefield": "CUSITEMCODE",
            "namefield": "CUSITEMNAME"
        },
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {},
        "ishow": true,
        "labelWidth": ""
    },
    self.viewConfig.controls["dropdown_457936"]= {
        "id": "dropdown_457936",
        "tbid": "",
        "type": "dropdown",
        "label": "标题4",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 3,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_dropdown": {
            "datatype": "str",
            "json": "MCwwOzEsMQ=="
        },
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {},
        "ishow": true,
        "labelWidth": ""
    },
    self.viewConfig.controls["lookup_1966847"]= {
        "id": "lookup_1966847",
        "tbid": "",
        "type": "lookup",
        "label": "标题1111",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 1,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_lookup": {
            "sqlid": "00302643-ce39-76d1-9617-4242fde78174",
            "type": "lookup",
            "id": "lookup_196684",
            "sqlid_text": "合并报表核算项目帮助",
            "idfield": "ID",
            "codefield": "CUSITEMCODE",
            "namefield": "CUSITEMNAME"
        },
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {}
    };
    
});

PC表单

idp.event.bind('mountReady',function(e,self){
    debugger;
    
    self.viewConfig.layout['layout_center']['childs'][0]['childs'].push('input_935800');
    self.viewConfig.layout['layout_center']['childs'][0]['childs'].push('checkbox_864569');
    self.viewConfig.layout['layout_center']['childs'][0]['childs'].push('lookup_196684');
    self.viewConfig.layout['layout_center']['childs'][0]['childs'].push('dropdown_457936');
    self.viewConfig.layout['layout_center']['childs'][0]['childs'].push('lookup_1966847');
    self.viewConfig.controls["input_935800"]= {
        "id": "input_935800",
        "tbid": "",
        "type": "input",
        "label": "标题1",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 0,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_input": {},
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {},
        "ishow": true,
        "labelWidth": ""
    },
    self.viewConfig.controls["checkbox_864569"]={
        "id": "checkbox_864569",
        "tbid": "",
        "type": "checklist",
        "label": "标题3",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 2,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_checklist": {},
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {},
        "ishow": true,
        "labelWidth": ""
    },
    self.viewConfig.controls["lookup_196684"]= {
        "id": "lookup_196684",
        "tbid": "",
        "type": "lookup",
        "label": "标题2",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 1,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_lookup": {
            "sqlid": "00302643-ce39-76d1-9617-4242fde78174",
            "type": "lookup",
            "id": "lookup_196684",
            "sqlid_text": "合并报表核算项目帮助",
            "idfield": "ID",
            "codefield": "CUSITEMCODE",
            "namefield": "CUSITEMNAME"
        },
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {},
        "ishow": true,
        "labelWidth": ""
    },
    self.viewConfig.controls["dropdown_457936"]= {
        "id": "dropdown_457936",
        "tbid": "",
        "type": "dropdown",
        "label": "标题4",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 3,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_dropdown": {
            "datatype": "str",
            "json": "MCwwOzEsMQ=="
        },
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {},
        "ishow": true,
        "labelWidth": ""
    },
    self.viewConfig.controls["lookup_1966847"]= {
        "id": "lookup_1966847",
        "tbid": "",
        "type": "lookup",
        "label": "标题1111",
        "visible": true,
        "disabled": false,
        "align": "",
        "width": "",
        "isfix": false,
        "issum": false,
        "sumtype": "",
        "colspan": "50%",
        "calc": [],
        "rules": [],
        "ord": 1,
        "used": true,
        "props": {
            "type": "3",
            "qrySyncMark": "1"
        },
        "fparams": {},
        "link": {},
        "editor_lookup": {
            "sqlid": "00302643-ce39-76d1-9617-4242fde78174",
            "type": "lookup",
            "id": "lookup_196684",
            "sqlid_text": "合并报表核算项目帮助",
            "idfield": "ID",
            "codefield": "CUSITEMCODE",
            "namefield": "CUSITEMNAME"
        },
        "express": {
            "number": {
                "express": ""
            },
            "text": {
                "express": ""
            },
            "require": {
                "express": ""
            },
            "readonly": {
                "express": ""
            },
            "hide": {
                "express": ""
            }
        },
        "filter": {}
    };
    
});

猜你喜欢

转载自blog.csdn.net/qq_32076957/article/details/128935173
今日推荐