function urlCtrl($scope,Project,Url) {

    let url_fun_str = `async function(ctx,opt){
    //加解密
    /*
    设置返回模板
    */
    //let template;
    //template =  opt.templageRoute["ddeess"].call(this,ctx.request.body.loan_id,null)
    /*
    设置加解密
    */
    //opt.endecode.exec("zfzx",[1,2,3])
    /*
    设置存储／获取数据
    */
    //opt.db.set(ctx,"reconNo")
    //opt.db.get(ctx,"reconNo")
    /*
    设置回调函数
    */
    // opt.call_back.setTimeOut(ctx,"/url",{
    //     url: "/",
    //     method:"GET",
    //     body:"abc"
    // });
    /*
    设置返回内容
    */
    //ctx.body = template
    //return
}`
    
    function url(){
        this.name = "";
        this.path = "/";
        this.fun = url_fun_str;
        this.templates = [];
        this.projects = $scope.current_project._id;
    }

    $scope.new_url = new url();
    $scope.url_template = "list";
    $scope.current_url = null;
    $scope.edit_element_status = {
        name: false,
        path: false
    }
    $scope.changeElementStatus = function(key){
        $scope.edit_element_status[key] = !$scope.edit_element_status[key];
    }


    $scope.saveUrlChange = function(key){
        console.log(key)
        $scope.edit_element_status[key] = !$scope.edit_element_status[key];
    }



    $scope.urls = [];
    $scope.projects = [];
    $scope.saveUrl=function(){
        Url.save($scope.new_url,function(res){
            console.log(res)
            $scope.urls.push(res);
        });
    }

    $scope.editUrl = function(url){
        $scope.current_url = url;
        $scope.url_template = "edit";
    }
    $scope.backList = function(){
        $scope.current_url = null;
        $scope.url_template = "list";
    }

    $scope.getUrls = function(){
        Url.queryItems({_id:$scope.current_project._id},function(res){
            $scope.urls = res;
        })
    }
    $scope.getProjects = function(){
        Project.query({},function(res){
            $scope.projects = res;
        })
    }

    $scope.deleteUrl = function(url){
        Url.delete({_id:url._id},function(res){
            _.remove($scope.urls,{_id:url._id})
        })
    };

    $scope.getProjects()
    $scope.getUrls()
}   
urlCtrl.$inject = ["$scope","Project", "Url"];
BP.controller("urlCtrl", urlCtrl);


