作者 xwp
1 个管道 的构建 通过 耗费 1 秒

登录注册调试

... ... @@ -78,4 +78,33 @@ class User extends Backend
public function import(){
parent::import();
}
/**
* 发布
*
* @param $arr
*
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function deleteAll($arr){
foreach ($arr as $k) {
/* $courseStore = new \app\admin\model\CourseStore;
$courseStore = $courseStore->where(['id'=>$k])->find();
if(empty($courseStore)){
continue;
}
$courseStore = $courseStore->toArray();
if($courseStore['status'] != 'new'){
continue;
}*/
$courseStore = new \app\admin\model\User();
$courseStore->where(['id'=>$k])->delete();
}
$this->success('ok',null);
}
}
... ...
... ... @@ -14,6 +14,8 @@
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>-->
<a href="javascript:;" class="btn btn-danger btn-deleteAll btn-disabled {:$auth->check('user/user/deleteAll')?'':'hide'}" title="批量删除"><i class="fa fa-times"></i> 批量删除</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover" width="100%"
data-operate-edit="{:$auth->check('user/user/edit')}"
... ...
... ... @@ -28,7 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
dblClickToEdit: false,
columns: [
[
//{checkbox: true},
{checkbox: true},
{field: 'id', title: __('Id'), sortable: true},
{field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
{field: 'username', title: __('Username'), operate: 'LIKE'},
... ... @@ -61,6 +61,42 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 为表格绑定事件
Table.api.bindevent(table);
//发布
$(document).on("click",".btn-deleteAll",function (e) {
var temp=table.bootstrapTable('getSelections');
var arr = [];
var a = true;
$.each(temp, function(key, value){
/* if(value.status !=='new'){
Layer.open({title: '错误', content: '含有已发布或取消的课程', btn: '确定'});
a = false;
return false;
}*/
arr.push(value.id);
});
if(a){
$.ajax({
type : "POST",
url : "user/user/deleteAll",
data : {
arr : arr,
},
dataType: "json",
success : function (data) {
if (data.code === 1) {
Layer.msg('删除成功');
Layer.closeAll();
$('.btn-refresh').trigger('click')
} else {
Layer.msg('删除失败');
}
}
});
}
});
},
add: function () {
Controller.api.bindevent();
... ...