項目:http://m.123.local.qushiyun.com/manager/index.php?app=company
<script type="text/javascript">
$(function(){
//導(dǎo)出數(shù)據(jù)
$('#export_all').click(function(){
window.open('index.php?app=company&act=export', '_blank');
});
//點擊方法例子
//點擊選擇全部
// $(".check-all").click(function () {
// $(".ids").prop("checked", this.checked);
// });
// //選擇多個
// $(".ids").click(function () {
// var option = $(".ids");
// option.each(function (i) {
// if (!this.checked) {
// $(".check-all").prop("checked", false);
// return false;
// } else {
// $(".check-all").prop("checked", true);
// }
// });
// });
//批量刪除
$("#deleteAll").live('click',function(){
var _ = $('form .chooseNow:checked').length;
if (_ < 1) {
$.jBox.tip('請先選擇要操作的數(shù)據(jù)!', 'info');
return false;
}
var submit = function(v, h, f) {
if (v == 'ok') {
_ = $('[name=form2]').serialize();
var action = $('[name=form2]').attr('load');
var _load = $('[name=form2]').attr('action');
$.post(action, _, function(data) {
if (data.status == '1') {
$.jBox.tip(
data.info,
'success',
{closed: function () {
window.location=_load;
}
}
);
} else
$.jBox.tip(data.info, 'error');
}, 'json');
}
return true;
}
$.jBox.confirm('確定要執(zhí)行此操作嗎剥悟?', '提示', submit);
return false;
})
})
function member_delete (id){
var submit = function (v, h, f) {
if (v == 'ok') {
$.ajax({
type: 'POST',
url: 'index.php?app=company&act=drop_company&id='+id,
dataType:'json',
success: function(data){
if(data.status == '1'){
$.jBox.tip(
data.info,
'success',
{closed:
function () {
location.reload();}});
}else{
$.jBox.tip(data.info, 'error');
}
} ,
});
}
return true;
};
top.jBox.confirm("確定要刪除會員嗎滚婉?", "提示", submit);
}
</script>
<form name="form2" class="submitForm" action="index.php?app=company&act=index" load="index.php?app=company&act=drop_company">
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#D6D6D6" style="margin-top:8px">
<tr>
<td height="28" colspan="17" background="{res file=images/tbg.gif}">
<table width='96%' cellpadding='0' cellspacing='0'>
<tr>
<td height="28" background="/manager/templates/images/tbg.gif" style="padding-left:10px;" colspan="2"> ◆客戶公司管理</td>
<td align='right'>
<a href="index.php?app=company&act=addCompany" class='np coolbg'>增加公司</a>
</td>
</tr>
</table>
</td>
</tr>
<tr align="center" bgcolor="#f8f8f8" height="25">
<td width="5%">選擇</td>
<td width="5%">網(wǎng)站ID</td>
<td width="18%">公司名稱</td>
<td width="8%">聯(lián)系人名稱</td>
<td width="8%">聯(lián)系方式</td>
<td width="25%">地址</td>
<td width="8%">公司狀態(tài)</td>
<td width="15%">添加時間</td>
</tr>
<!--{if !empty($companyList)}-->
<!--{foreach from=$companyList item=item name=list}-->
<tr align="center" bgcolor="#FFFFFF" height="26" align="center" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';">
<td class="list-text">
<input name='id[]' type='checkbox' class="chooseNow" value='{$item.id}' />
</td>
<td>
{$item.store_id}
</td>
<td>
{$item.company_name}
</td>
<td>
{$item.linkman_name|default:-}
</td>
<td>
{$item.phone_mob|default:-}
</td>
<td>
{$item.address|default:-}
</td>
<td>
{if $item.status==20}正常
{elseif $item.status==10}<span style="color:red">禁用</span>
{/if}
</td>
<td>
{$item.add_time|date:Y-m-d H:i:g|default:-}
</td>
<td width="" class="list-text">
<div class="lista">
<a href="index.php?app=company&act=addCompany&id={$item.id}"><img src='{res file=images/gtk-edit.png}' title="編輯" alt="編輯" style='cursor:pointer' border='0' width='16' height='16' /></a>
<a onclick="member_delete({$item.id})" href="javascript:;"><img src='{res file=images/gtk-del.png}' title="刪除" alt="刪除" style='cursor:pointer' border='0' width='16' height='16' /></a>
</div>
</td>
</tr>
<!--{/foreach}-->
<tr bgcolor="#ffffff">
<td height="36" colspan="17">
<a class="coolbg" id="checkAll" href="javascript:;">全選</a>
<a class="coolbg" id="unCheck" href="javascript:;">取消</a>
<a class="coolbg" id="deleteAll" href="javascript:;"> 刪除 </a>
<a id="export_all" class="coolbg" href="javascript:;">導(dǎo)出</a>
</td>
</tr>
<!--{else}-->
<tr align="right" bgcolor="#f8f8f8">
<td height="36" colspan="17" align="center"><span>您的數(shù)據(jù)為空</span></td>
</tr>
<!--{/if}-->
<tr bgcolor="#f8f8f8">
<td height="36" colspan="17" align="center">
{include file="./layout/page_bottom.html"}
</td>
</tr>
</table>
</form>
控制器
/*
* 刪除公司
*/
public function drop_company()
{
if($_GET['id']){
$id = $_GET['id'];
}
if($_POST['id']){
$id = $_POST['id'];
}
if ($id <= 0) {
$data = array(
'status' => 'n',
'info' => '請選擇要刪除的數(shù)據(jù)',
);
echo json_encode($data);
} else {
$store_companyModel=m("oa_company");
$store_com=$store_companyModel->delCompany($this->store_id, $id);
$info="刪除成功";
if(!$store_com){
$info="刪除失敗";
}
$data = array(
'status' => '1',
'info' => $info,
);
echo json_encode($data);
}
}
model
public function delCompany($storeId, $id)
{
if(is_array($id))
{
$ids=implode(',',$id); //重要 將數(shù)組變?yōu)樽址? $condition=" store_id='$storeId' and id in($ids)";
}else{
$condition['store_id'] = $storeId;
$condition['id'] = $id;
}
return $this->where($condition)->delete();
}