<div class="col-md-12">
<a auth_is="1" data-href="<?=$baseUrl?>/delItemBatch" class="btn btn-danger delBatch" href="javascript:void(0)">批量删除</a>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th><input type="checkbox" class="checkAll" name="allChecked" value="" ></th>
<th>ID</th>
<th>拍品名称</th>
<th>描述</th>
<th>分类名称(外部)</th>
<th>国家</th>
<th>京东起拍价</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php if(!empty($result['items']['itemInfos'])):?>
<?php foreach ($result['items']['itemInfos'] as $key=>$val):?>
<tr>
<td><input type="checkbox" class="item" name="item[]" value="<?=!empty($val['itemId'])?$val['itemId']:0?>"/></td>
<td><?=!empty($val['itemId'])?$val['itemId']:'--'?></td>
<td><?=!empty($val['itemName'])?$val['itemName']:'--'?></td>
<td><?=!empty($val['desInfo'])?$val['desInfo']:'--'?></td>
<td><?=!empty($val['itemCate2Name'])?$val['itemCate2Name']:'--'?>-><?=!empty($val['itemCate3Name'])?$val['itemCate3Name']:'--'?></td>
<td><?=!empty($val['countryName'])?$val['countryName']:'--'?></td>
<td>¥<input type="text" name="pfStartPrice" class="pfStartPrice" data-id="<?=$val['itemId']?>" value="<?=$val['pfStartPrice']?>"></td>
<td>
<a auth_is="1" href="/goods/goods/show?id=<?=!empty($val['itemId'])?$val['itemId']:0?>" class="btn btn-sm btn-default"><i class="fa fa-search">查看</i></a>
<a auth_is="1" href="/goods/goods/edit?id=<?=!empty($val['itemId'])?$val['itemId']:0?>" class="btn btn-sm btn-info"><i class="fa fa-search">编辑</i></a>
<a auth_is="1" data-href="<?=$baseUrl?>/delItem" href="javascript:void(0)" data-id="<?=!empty($val['itemId'])?$val['itemId']:0?>" class="btn btn-sm btn-danger btn-del"><i class="fa fa-search">删除</i></a>
</td>
</tr>
<?php endforeach;?>
<?php else:?>
<tr>
<td colspan="8">暂无数据</td>
</tr>
<?php endif;?>
</tbody>
</table>
<script src="jquery-1.8.3.min.js"></script>
<script>
/**
* 获取批量选中的ID
*/
function getIds() {
var _ids = '';
$('.item:checked').each(function () {
if (!isNaN($(this).val())) {
_ids += $(this).val() + ',';
}
});
return _ids;
}
/**
* 实现删除操作
*/
$('.delBatch').click(function () {
var _itemIdJson = getIds();
if(_itemIdJson==''){
toastr.warning('请选择要删除的拍品');
return false;
}
if(!confirm('确定要删除吗?')) return false;
formAjax(_baseUrl + '/delItemBatch', 'get', {'itemIdJson': _itemIdJson}, '',0)
})
/**
* 表单提交
* @param url
* @param method
* @param data
* @param modalName
* @param num
*/
function formAjax(url, method, data, modalName, num) {
$.ajax({
url: url,
method: method,
data: data,
async: false,
dataType: "json",
timeout : 1000,
headers: {'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')},
success: function (data) {
formRemoveClass();
if (data.status == 200) {
if (modalName != '') {
$('#' + modalName + ' .num').text(num);
$('#' + modalName).modal();
} else {
toastr.success(data.message);
$.pjax.reload('#pjax-container');
}
} else if (data.status == 201) {
console.log(typeof data.message)
if (typeof data.message == 'string') {
toastr.warning(data.message);
} else {
for (k in data.message) {
formAddClass(k);
if (data.message[k].length > 1) {
for (kk in data.message[k]) {
toastr.warning(data.message[k][kk]);
}
} else {
toastr.warning(data.message[k][0]);
}
}
}
} else {
toastr.error(data.message);
}
},
complete : function(XMLHttpRequest,status){ //请求完成后最终执行参数
if(status=='timeout'){//超时,status还有success,error等值的情况
ajaxTimeoutTest.abort();
toastr.error('接口超时');
}
},
error: function () {
toastr.error('error');
}
});
}
</script>