全选与批量删除

来源:互联网 发布:伊的家网络销售好做么 编辑:程序博客网 时间:2024/06/06 02:26

<div style="clear: both; padding: 15px 15px 0 15px;" class="row">

 
</div>
<div style="height:30px;padding-left:30px;">
        <font style="color:red;font-weight:bold">以下数据仅供参考~~!</font>
</div>
<section class="content">
<div class="box">
<div class="box-body">
<div class="table-responsive fn-table overflow-x-hidden">
<div id="DataTables_Table_0_wrapper"
class="dataTables_wrapper form-inline dt-bootstrap no-footer">
<div class="row">
<div class="col-sm-6"></div>
<div class="col-sm-6"></div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="dataTables_scroll">


<div class="dataTables_scrollBody"
style="overflow: auto; width: 100%;">
<table
class="table table-bordered table-striped table-hover fn-table-list dataTable no-footer"
id="DataTables_Table_0" role="grid">
<thead>
<tr role="row">
<th class="padding-rewrite sorting_disabled" rowspan="1"
colspan="1" width="5%">
<div class="dataTables_sizing">
<input type="checkbox" class="checkbox-all" value="all" />
</div>
</th>

</tr>
</thead>
<tbody id="company_list">
<volist name="lists" id="l">
<tr role="row" class="odd">
<td class=" padding-rewrite">
<input type="checkbox" class="checkbox-one" value="{$l.pid}" name="contractId" id="chk[]" onclick="clickCheckbox(this)"/>
</td>
<td>{$i}</td>
<td>{$l.plant_create_date}</td>
<td>{$l.plant_id}</td>
<td>{$l.cunumber}</td>
<td>{$l.plant_name}</td>
<td>{$l.user_state}{$l.user_city}{$l.user_address1}{$l.user_address2}</td>
<td>
<if condition="$l['plant_inverter_man'] eq 1" >
                                 兆能
<elseif condition="$l['plant_inverter_man'] eq 2" />
                               古瑞瓦特
<elseif condition="$l['plant_inverter_man'] eq 3" />
                                欧姆尼克
<elseif condition="$l['plant_inverter_man'] eq 4" />
  固德威
</if>
</td>
<td>{$l.plant_today_energy}</td>
<td>{$l.plant_monthly_energy}</td>
<td>{$l.plant_yearly_energy}</td>
<td>{$l.plant_total_energy}</td>
<td>{$l.user_install_size}</td>
<td>
<if condition="$l['user_state'] eq '上海'">
<if condition="(($year - substr($l['user_signing_date'],0,4)) egt 0) and (($year - substr($l['user_signing_date'],0,4)) lt 5)">
{$l['plant_total_energy']*$s15|number_format=2}
<elseif condition="(($year - substr($l['user_signing_date'],0,4)) gt 4) and (($year - substr($l['user_signing_date'],0,4)) lt 20)"/>
{$l['plant_total_energy']*$s620|number_format=2}
<elseif condition="(($year - substr($l['user_signing_date'],0,4)) gt 19) and (($year - substr($l['user_signing_date'],0,4)) lt 25)"/>
{$l['plant_total_energy']*$s2125|number_format=2}
</if>
<else/>
<if condition="(($year - substr($l['user_signing_date'],0,4)) egt 0) and (($year - substr($l['user_signing_date'],0,4)) lt 21)">
{$l['plant_total_energy']*$j120|number_format=2}
<elseif condition="(($year - substr($l['user_signing_date'],0,4)) gt 19) and (($year - substr($l['user_signing_date'],0,4)) lt 25)"/>
{$l['plant_total_energy']*$j2125|substr=0,-2}
</if>
</if>
</td>
<td>
<a href="{:U('index/plantsel',array('id'=>$l['pid']))}" title="查看" style="color: #8c8c8c;">
<i class="fa fa-eye fa-lg fa-fw"></i>
</a>
<!-- <a href="#" style="color: #8c8c8c;">
<i class="fa fa-trash fa-lg fa-fw"></i>
</a> -->
</td>
</tr>
</volist>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="clearfix fn-table-page ">
<div class="pull-left all_dlt padding-rewrite">
<input type="checkbox" class="checkbox-all" value="all"  name="check_all" onclick = "checkAll()"/>
<span>全选</span>
<input type="hidden" id="id_list" value="" />
<a  
   onclick = "clickDelete()" type = "button" style="color: #337ab8;" data-toggle="modal"
data-target="#myModal" onclick="return confirmAct()" title="删除">
<i class="fa fa-trash fa-lg fa-fw"></i>
</a>
</div>
<form id="page_form" action="#" method="post">
<input type="hidden" name="goods_name" value="<?php echo $goods_name;?>"/>
</form>
<div id="page_containter">
{$show}
</div>
</div>
</section>
<script type="text/javascript">  
function confirmAct() {
if ({$adminInfo['admin_level']} == 1 || {$adminInfo['admin_level']} == 2){
alert("您无此操作权限,请与系统管理员联系");
return false;
} else if (({$adminInfo['admin_level']} == 0) && (confirm('确定要执行此操作吗?'))) {
return true;
}else{
   return false;
}
}
$(function(){
$("#search").click(function(){
var number = $("#user_communication_number").val();
var plantid = $("#plant_id").val();
var name = $("#user_name").val();
var uadd = $("#uadd").val();
var company=$("#interface_company").val();

function clickModify(pid){
if(({$adminInfo['admin_level']} == 0)||({$adminInfo['admin_level']} == 1)){
window.location.href = "<?php echo REWRITE_BASE?>"+"/Admin/index/plantModify/type/1/id/"+pid+".html";
return true;
}else{
alert("您无此操作权限,请与系统管理员联系");
return false;
}
}
function confirmActe() {
if ({$adminInfo['admin_level']} == 2){
alert("您无此操作权限,请与系统管理员联系");
return false;
} else{
return true;
}
}
//全选
function checkAll(){
var id_list = "";
var arr = document.getElementsByName('check_all');
$('#company_list #chk\\[\\]').each(function(i, e) {
e.checked = arr[0].checked;
if (arr[0].checked) {
id_list += (id_list == "" ? "" : ",") + $(this).val();
}
});
$('#id_list').val(id_list);
}
//单独选中
function clickCheckbox(obj) {
var id_list = "";
var all = true;
var total = 0;
$('#company_list #chk\\[\\]').each(function(i, e) {
if ($(e).prop("checked")) {
total++;
id_list += (id_list == "" ? "" : ",") + $(this).val();
} else {
all = false;
}
});
if (all && total > 0) {

$('input[name="check_all"]').prop("checked", true);
} else {
$('input[name="check_all"]').prop("checked", false);
}
$('#id_list').val(id_list);
 }
function clickDelete() {
 if (window.confirm('确定要删除吗?')) {
$.ajax({
type:'POST',
dataType:'json',
url:"{:U('index/plantPlsc')}",
data:"id="+$('#id_list').val(),
success:function(data) {
if (data.error == '') {
alert('删除成功');
window.location.href = "{:U('index/plantLists')}" ;//跳转页面(路径最高级到最低级)
} else {
alert('删除失败 : ' + data.error);
}
},
error:function(data){

alert("error");
}
});
}
 }

</script>


/**
* 电站批量刪除
*
* @author liuz
*/
public function plantPlsc() {
$data ['error'] = "";
$plant = M ( 'plant' );
$id = I ( 'id' );
$condition ['id'] = array (
'in',
$id 
);
$condition ['flag'] = 0;
$data_ ['flag'] = 1;
$plant->where ( $condition )->save ( $data_ );
$this->ajaxReturn ( $data );
}







原创粉丝点击