define(function(require) {
	//加载JS库
	var $ = require('jquery');
	var IFA = require('util');
	require('grid')($);
	require('dialog')($);
	require('uriTemplate')($);
	require('../../../styles/cim/jquery-ui-1.8.14.custom.css');
	require('../../../styles/cim/cim-grid.css');   
	$(function(){
		search();
		$("#search").bind("click",search);
	});
	function search(){
	var queryUrl = $("#searchUrl").val();
	var editUrl = new $.Template($("#editUrl").val());
	var updateUrl = $("#updateUrl").val();
	var grid = $("#payMethodList").grid({
		url:queryUrl,
		root:"result",  
  		method:'POST',
  		isREST:false,
  		paging:false,
  		pageSize:50,
  		pageTheme:'Theme1',
  		defaultParams:$("#payMethodForm").serialize(),
  		fields:[
  				{
  					name:i18n['Entity.payMethod.name'],id:"name",style:"width:40%"
  				},
  				{
  					name:i18n['Entity.payMethod.value'],id:"value",style:"width:5%"
  				},
  				{
  					name:i18n['Entity.payMethod.mainType'],id:"mainTypeName",style:"width:10%"
  				},
  				{
  					name:i18n['Entity.payMethod.descs'],id:"descs",style:"width:40%"
  				},
  				{name:i18n["Entity.Operation"],operation:[{text:i18n['Entity.page.edit'],display:true,action:function(data){
  				   var params = {'id':data.id};
  				   var url = editUrl.expand(params);
  				   location.href=url;
  				}},{text:function(data){
  					return data.available==0?i18n["Entity.payMethod.attribute.recovery"]:i18n['Entity.page.Delete'];},dispaly:true,action:function(data){
  					var grid = this;
  					$.msg.confirm(i18n['Page.Dialog.title'],i18n['Entity.payMethod.attribute.execution.confirm'],function(){},{buttons:
  						IFA.generateJson(i18n['ConditionMap.ok'],function(){
  							$.post(updateUrl,{id:data.id,available:(data.available==0?"1":"0"),_method:'PUT'},function(){
  		  						grid.render();
  		  					});
  							$(this).dialog('close');
  						},
  						i18n['ConditionMap.cancel'],function(){
  							$(this).dialog('close');
  						}
  						)});
  				
  				}}]
  				}
  				
  			]
  			
  		
		
	});
	}
	
	
	
});