// var page_size=10;
function queryUndispatchedTask(){
    var data = {
        "start_time": $("#start_time").val(),
        "end_time": $("#end_time").val(),
        "dept": $("#dept").val()
    }
    var cols = [
                {width: 30, text: '序号', type: 'number', flex: true, colClass: 'text-center'},
                {width: 80, text: '任务名称', type: 'date', flex: true, sort: 'down'},
                {width: 80, text: '考核人员', type: 'string', flex: true, colClass: ''},
                {width: 80, text: '考核部门', type: 'date', flex: false, sort: 'down'},
                {width: 80, text: '稽查人员', type: 'string', flex: true, colClass: ''},
                {width: 80, text: '稽查时间段', type: 'date', flex: true, sort: 'down'},
                {width: 80, text: '状态', type: 'string', flex: true, colClass: ''},
                {width: 80, text: '稽查时间', type: 'string', flex: true, colClass: ''},
                {width: 160, text: '操作', type: 'string', flex: true, field: 'id',
                    oper:[
                        {func:'showTaskDetail',text:'稽查',icon_class:'icon-edit'}
                    ]
                }
            ];
    
    // var pager = {
    //     page_size:10
    // }
    $('.datatable').mytable({'cols':cols,
                            'url':"/task/getTaskList/",
                            'param':data}
                            );
}
function showTaskDetail(){
    changePage("/view/mytask/taskDetail.html");
}
function showCheck(){
    $('#code_flag').val('');
    $('#flag_name').val('');
    $('#code_value').val('');
    $('#code_name').val('');
    $('#sort_no').val('');
    $('#remark').val('');
    $("#valid").attr('checked','true');
    showPopup4Common('稽查页面',function(){
        addOrUpdateConstant("/constant/add/");
    },'400px');
}
var cur_id;
function addOrUpdateConstant(url){
    var valid=1;
    if(!$("#valid").is(':checked')) valid=0;
    var param ={
        'id':cur_id,
        'code_flag':$('#code_flag').val(),
        'flag_name':$('#flag_name').val(),
        'code_value':Number($('#code_value').val()),
        'code_name':$('#code_name').val(),
        'sort_no':Number($('#sort_no').val()),
        'remark':$('#remark').val(),
        'valid':valid
    };
    addOrUpdateItem4Common(param,url,queryConstant);
}

function showEditConstant(id){
    cur_id='';
    var rowData=getItemByIdFromArr(id,$('.datatable').mytable('getTableData'));
    if(rowData) {
        cur_id = rowData.id;
        $('#code_flag').val(rowData.code_flag);
        $('#flag_name').val(rowData.flag_name);
        $('#code_value').val(rowData.code_value);
        $('#code_name').val(rowData.code_name);
        $('#sort_no').val(rowData.sort_no);
        $('#remark').val(rowData.remark);
        if(rowData.valid==1){
            $("#valid").attr('checked','true');
        }else{
            $("#valid").attr('checked','false');
        }
        showPopup4Common('修改常量',function(){
            addOrUpdateConstant("/constant/update/");
        },'400px');
    }
}

function deleteConstant(id){
    deleteItem4Common(id,"/constant/delete/",queryConstant);
}