/**
 * 支付应用管理
 */
$(function(){

    AppPayApply = {
        Events : {'click .btn': function (e, value, row, index) {
			var event = $(e.target).data('event');
			if(event == 'view'){
                AppPayApply.view(value);
			}else if(event == 'edit'){
                AppPayApply.edit(value);
			}
		}},
		add : function(){
			window.location = String.format(Config.ROOT+'/auth/jump_basic?moduleId={0}&url=/dmp/pay_apply/edit', $('#moduleId').val());
		},
		edit: function(oid){
			window.location = String.format(Config.ROOT+'/auth/jump_basic?moduleId={0}&url=/dmp/pay_apply/edit?appId={1}', $('#moduleId').val(), oid);
		},
        view: function(oid){
            window.location = String.format(Config.ROOT+'/auth/jump_basic?moduleId={0}&url=/dmp/pay_apply/edit&editType=view&appId={1}', $('#moduleId').val(), oid);
        },
        search: function () {
            $table.reload(1);
        }
	};
	
	
	//初始化表格
    var $table = new App.Table({
        url: Config.ROOT + '/dmp/pay_apply/list',
        search: false,
        searchParamName: '',
        searchPlaceholder: '',
        columns	:[
            {field:'id', title:'应用ID', formatter: function(v, row, index){
                return row['app_id'];
            }},
            {field:'app_name', title:'应用名称'},
            // {field:'app_secret', title:'应用密钥'},
            {field:'pay_config', title:'支付方式', formatter: function(v, row, index){
                return v['type'];
            }},
            {field:'channel_type', title:'支付渠道'},
            {field:'sign_type', title:'签名方式'},
            {field:'status', title:'状态', tpl: 'tpl_status'},
            {field:'business_notice_url', title:'回调地址'},
            {field:'update_time', title:'修改时间'},
            {field:'app_id', title:'操作', width: 80, toolbar: 'tableRowToolbar', events: AppPayApply.Events}
        ],
        getQueryParam: function () {
            var type = $('#search_type').val() || '';
            var app_id = $('#search_app_id').val() || '';
            var postData = {
                'type'	: type,
                'appId'	: app_id
            };
            return postData;
        }
    });

});