layui.define([ 'form', 'laydate', 'table' ], function(exports) {
    var form = layui.form;
    var laydate = layui.laydate;
    var table = layui.table;
    var budgetVerificationTable = null;
    var budgetId=$("#budgetId").val();
    var view ={
        init:function(){
            this.initTable();
            this.initSearchForm();
            this.initToolBar();
            window.dataReload = function(){
                Lib.doSearchForm($("#searchForm"),budgetVerificationTable)
            }
        },
        initTable:function(){
        	budgetVerificationTable = table.render({
      	        elem : '#budgetVerificationTable',
      	        height : Lib.getTableHeight(1),
      	        cellMinWidth: 100,
      	        method : 'post',
      	        url : Common.ctxPath + '/dubget/budgetVerification/list.json?budgetId='+budgetId// 数据接口
      	        ,page : Lib.tablePage // 开启分页
      	        ,limit : 10,
      	        cols : [ [ // 表头
      	         /*    {
      	                //type : 'checkbox',
      	                fixed:'left',
      	            }, */
      	          {

        	            field : 'deptName', 
        	                title : '科室名称',
        	        },
      	        {

      	            field : 'number', 
      	                title : '编号',
      	        },
      	      {
     	        	 field : 'implementMatter', 
  	                title : '执行事项',
     	        },
      	        {

      	            field : 'execute', 
      	                title : '执行金额',
      	        },
      	        {

      	            field : 'chargeOff', 
      	                title : '核销金额',
      	        },
      	      
      	        {

      	            field : 'stateText', 
      	                title : '状态',
      	        },
      	        
      	        {
      	            title: '操作',
      	            //rowspan: 2,
      	            align: 'center',
      	            fixed: 'right',
      	            minWidth: '160',
      	            templet: function (d) {
      	            	 var edit='<button type="button" class="layui-btn layui-btn-sm layui-btn-warm" lay-event="view" title="查看">查看</button>';
      	                return edit;
      	            }
      	        }

      	] ]

      	});
      	  table.on('tool(budgetVerificationTable)', function(obj){
      	      var budget = obj.data;
      	      if(obj.event === 'dit'){  
      	          var url = "/dubget/budgetVerification/audit.do?id="+budget.id;
      	          Common.openDlg(url,"执行管理>编辑");
      	      }else if(obj.event === 'view'){
      	        var url = "/dubget/budgetVerification/view.do?id="+budget.id;
    	          Common.openDlg(url,"执行管理>编辑");
      	      }
      	  })
      },

        initSearchForm:function(){
            Lib.initSearchForm( $("#searchForm"),budgetVerificationTable,form);
        },
        initToolBar:function(){
            toolbar = {
                add : function() { // 获取选中数据
                    var url = "/dubget/budgetVerification/add.do";
                    Common.openDlg(url,"执行子表管理>新增");
                },
                edit : function() { // 获取选中数目
                    var data = Common.getOneFromTable(table,"budgetVerificationTable");
                    if(data==null){
                        return ;
                    }
                    var url = "/dubget/budgetVerification/edit.do?id="+data.id;
                    Common.openDlg(url,"执行子表管理>"+data.id+">编辑");
                },
                del : function() {
                    layui.use(['del'], function(){
                        var delView = layui.del
                        delView.delBatch();
                    });
                }
        };
            $('.ext-toolbar').on('click', function() {
                var type = $(this).data('type');
                toolbar[type] ? toolbar[type].call(this) : '';
            });
        }
    }
    exports('viewindex',view);

});