$(document).ready(function(){
    queryTable();   
    function queryTable(){
        var data = {}
        var name = $("#select_name").val();
        if(name!=''){
            data.name = name ;
        }
        var start_time = $("#start-time").val();
        var end_time = $("#end-time").val();
        var dept_select = $("#dept_select").val();
        if(start_time != ''){
            data.start_time = start_time;
        }
        if(end_time != ''){
            data.end_time = end_time;
        }
        if(dept_select!='' && dept_select != 0){
            data.appeal_dept = dept_select;
        }
        var cols = [
                        {width: 30, text: '序号', flex: false, colClass: 'text-center',field:'num'},
                        {width: 100, text: '任务名称', flex: false,colClass: '',field:'name'},
                        {width: 80, text: '考核人员',  flex: false, colClass: '',field:'appeal_man_name'},
                        {width: 100, text: '考核部门',  flex: false, colClass: '',sort: 'down',field:'appeal_dept_name'},
                        {width: 80, text: '稽查人员', type: 'string', flex: false, colClass: '',field:'verify_person_name'},
                        {width: 120, text: '稽查时间段', type: 'string',custom:'-24:00', flex: false, colClass: '',field:'start_time'},
                        {width: 80, text: '状态', type: 'string', flex: false, colClass: '',field:'code_name'},
                        {width: 120, text: '上次稽查时间', type: 'string', flex: false, colClass: '',field:'start_time'},
                        {width: 100, text: '操作',  flex: false, colClass: '',field:'id',field_other:'task_id',oper:[
                            {func:'seeCheckAudit',text:'查看稽查结果',col_class:''},{func:'seeDetail',text:'详情',col_class:''}
                        ]},
                    ] ;
        
        $('.datatable').mytable({'cols':cols,
                                'url':"checkAppeal/getList",
                                'param':data}
                                );
    }
    //条件查询
    $("#conditional_query").click(function(){
        queryTable();
    })

    getDeptList();
    //初始化部门下拉框
    function getDeptList(){
        data ={}
        post_common_service("dept/get/all", data, function(data){
            $("#dept_select").empty();
            $("#dept_select").append('<option value="">全部</option>');
           
            for(i=0;i<data.length;i++){
                $("#dept_select").append('<option value="'+data[i].id+'">'+data[i].organname+'</option>');
            }
        }, function(){

        });
    }


})
//查看稽查结果
function seeCheckAudit(id,task_id){
    // alert("task_id:"+task_id+"---id:"+id)
    // function showTaskDetail1(id){
    var rowData=getItemByIdFromArr(id,$('.datatable').mytable('getTableData'));
    $.checkTask = rowData;
    changePage("/view/mytask/taskDetail.html");
// }
}
//再分配
function distributionAgain(id,task_id){
    alert("task_id:"+task_id+"---id:"+id)
}

//详情
function seeDetail(id,task_id){
    alert("task_id:"+task_id+"---id:"+id)
}

