define(["app", "constant", "config","yCommon", "bootbox","common_tools", "dir_datepicker", "dir_paging", "yService", "dir_table_column_config", "tools_factory","dir_select","dir_file_upload",'dir_echart2'],
    function(app, constant, config, yCommon, bootbox, commonTools) {
        app.register.controller('#(fileDir)ListCtrl', ["$scope", "rootMap", "$state", "yService", "toolsFactory","$stateParams","$sce",
            function($scope, rootMap, $state, yService, toolsFactory,$stateParams,$sce) {
                yService.initService("/#(beanL)");
                var funs = {
                #for(x : fieldList)
                #if(x.tag == "SELECT")
                    #(x.field):function(v) {
                        var arr = #(x.selects);
                        for (i in arr){
                            if (v == arr[i].key){
                                return arr[i]["value"];
                            }
                        }
                        return "";
                    },
                #end
                #end
                };

                yCommon.initScope($scope, $sce,rootMap,funs,yService);
                $scope.queryCondition = yCommon.getConditon($state);
                //conf
                $scope.cfg = {
                    title:"#(remark)#if(pagePath == 'verify')-核验#end"
                    ,url:"/#(bean.toLowerCase())"
                    ,field_label: [#(label)]
                    ,field:[#(field)]
                    ,conditionLabel:"#(conditionLabel)"
                };

                //页面加载
                function pageInit() {
                    //初始化分页数据值
                    $scope.pageOptions = {
                        server: config.services.assetmag,
                        url: $scope.cfg.url,
                        id: "xxPaging"
                    };

                    $scope.query();
                }

                //分页插件查询回调
                $scope.operatePaging = function(total, rows) {
                    $scope.rows = rows;
                    $scope.total = total;

                };

                //条件查询弹出层
                $scope.condition = function(){
                    toolsFactory.openDialog($scope, app.tplsBasePath + '#(pageModel)/#(fileDir)/condition.html');
                }

                //查询功能实现
                $scope.query = function() { //点击查询 更新查询条件缓存
                    #if(pagePath == "verify")
                    $scope.queryCondition.verify = 1;
                    #end
                    $scope.pageOptions.param = angular.copy($scope.queryCondition);
                    $scope.pageOptions.reload = true;
                    toolsFactory.closeDialog();

                    yCommon.setCondition($scope.queryCondition);//预存查询条件
                };

                //回车键查询
                $scope.keySearch = function(e){
                    var keycode = window.event ? e.keyCode : e.which;
                    if(keycode == 13){
                        $scope.query();
                    }
                };

                //重置按钮
                $scope.reset = function() {
                    var queryCondition = $scope.queryCondition;
                    commonTools.resetQueryParmeter(queryCondition);
                };

                $scope.add = function(){
                    $scope.title = "#(remark) 添加";
                    $state.$go('#(pageModel).#(fileDir).edit',{});
                }

                $scope.detail = function(row){
                    $state.$go('#(pageModel).#(fileDir).detail',{row:row});
                }

                $scope.update = function(row){
                    $scope.title = "#(remark) 修改";
                    $state.$go('#(pageModel).#(fileDir).edit',{row:row});
                }

                pageInit();
            }
        ]);
    })