(function(){
    X.pageLogic['dropdownlist'] = {
        init : function(parms){
            var me = this;
            this.parms = parms;
            this.callback = parms.callback;
            var listdata = parms.extData;
            // console.log('aaa',listdata);

            X.laytpldata("#dropdownlist-con-box-dot",listdata,".dropdownlist-con-box");

            // $(document).off("bind",'.dropdownlist-input').on("bind",".dropdownlist-input",function(){
            //     var title = $(this).val();
            //     console.log(title);
            // });

            $('.dropdownlist-input').bind('input propertychange', function() {
                var title = $(this).val();
                if(title != ""){
                    var filteringdata = [];
                    for(let i in listdata){
                        if(listdata[i]['title'].indexOf(title) != -1 || listdata[i]['id'].indexOf(title) != -1){
                            filteringdata.push(listdata[i]);
                        }
                    }
                    // console.log(filteringdata);
                    X.laytpldata("#dropdownlist-con-box-dot",filteringdata,".dropdownlist-con-box");
                }else{
                    X.laytpldata("#dropdownlist-con-box-dot",listdata,".dropdownlist-con-box");
                }
            })

            $(document).off('click','.dropdownlist-list').on('click','.dropdownlist-list',function(){
                var index = $(this).attr("data-index");
                var id = $(this).attr("data-id");
                var title = $(this).attr("data-title");
                for(let i in listdata){
                    if(listdata[i]['id'] == id && title == listdata[i]['title']){
                        var dataArr = listdata[i];
                    }
                }
                me.callback && me.callback(dataArr);
                layer.close( me.parms.layIndex );
            })

        }
    };
})();
