audit.php 2.56 KB
<?php
$this->breadcrumbs=array(
	'审核管理',
);
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="grid-view">
    <tr>
        <td width="8" background="images/tab_12.gif">&nbsp;</td>
        <td class="tabler">
<?php $columns = require_once Yii::app()->basePath. '/config/auditConfig.php';?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'audit-grid',
	'dataProvider'=>$dataProvider,
	//'filter'=>$model,
	'columns'=>$columns[$item]
)); ?>

		<div id="load" style="display: none; text-align:right; width:100%; padding-top:10px"></div>
		</td>
        <td width="8" background="images/tab_15.gif">&nbsp;</td>
    </tr>
</table>

<script type="text/javascript">
/**
 * 请求处理
 */
function request(isAccept) 
{
    var data = new Array();
    var message = null;
    var reqUri = null;
    var error = null;
    var call = null;
    
    // 获取选择的值
    $("input:checkbox[name='id[]']").each(function()
    {
    	if ($(this).attr("checked")==true)
        {
        	data.push($(this).val());
        }
    });
    
    reqUri = window.location.href;
    reqUri = decodeURIComponent(reqUri);
    call = reqUri.substr(reqUri.indexOf('&CALL=')+6, reqUri.length);
    call = call.replace('}','') + ',"id":"' + data.join(',') +'"}';

	// 判断是否有选择
    if (data.length > 0)
    {
        reqUri = reqUri.substr(0, reqUri.indexOf('?r='));
        
        // 判断是批准还是拒绝
        switch (isAccept)
        {
        	case false:
            	reqUri += '?r=audit/reject';
            	message = '<span>审核批量批准操作成功。</span>';
            	error   = '<span class="wrong_text">审核操作批量批准失败。请重试!</span>';
            	break;
        	case true:
        		reqUri += '?r=audit/accept';
        		message = '<span>审核批量拒绝操作成功。</span>';
        		error	= '<span class="wrong_text">审核操作批量批准失败。请重试!</span>';
        		break;
        }
        
		// 提交请求
        $.post(reqUri,{'CALL':call}, function (data) {
            var success = $.parseJSON(data);
            if (success) 
            {
            	$("#load").html(message);
            	$.fn.yiiGridView.update('audit-grid');
            }
            else
            {
            	$("#load").html(error);
            }
            $("#load").show();
        });
    }
    else
    {
        error = '<span class="wrong_text">请先在需要批量操作的应用前面点击打勾选择!</span>';
        
    	$("#load").html(error);
        $("#load").show();
    }
}
</script>