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

批量删除

... ... @@ -372,7 +372,7 @@ class CourseStore extends Backend
public function deleteAll($arr){
foreach ($arr as $k) {
$courseStore = new \app\admin\model\CourseStore;
/* $courseStore = new \app\admin\model\CourseStore;
$courseStore = $courseStore->where(['id'=>$k])->find();
if(empty($courseStore)){
continue;
... ... @@ -380,7 +380,7 @@ class CourseStore extends Backend
$courseStore = $courseStore->toArray();
if($courseStore['status'] != 'new'){
continue;
}
}*/
$courseStore = new \app\admin\model\CourseStore;
$courseStore->where(['id'=>$k])->delete();
}
... ...
... ... @@ -154,4 +154,24 @@ class Store extends Backend
$this->success('ok',null);
}
/**
* 删除
*
* @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) {
$store = new \app\admin\model\Store();
$store->where(['id'=>$k])->delete();
}
$this->success('ok',null);
}
}
... ...
... ... @@ -23,6 +23,7 @@
</div>-->
<a href="javascript:;" class="btn btn-danger btn-publishAll btn-disabled {:$auth->check('course_store/publishAll')?'':'hide'}" title="发布"><i class="fa fa-check"></i> 发布</a>
<a href="javascript:;" class="btn btn-danger btn-cancelAll btn-disabled {:$auth->check('course_store/cancelAll')?'':'hide'}" title="取消"><i class="fa fa-times"></i> 取消</a>
<a href="javascript:;" class="btn btn-danger btn-deleteAll btn-disabled {:$auth->check('course_store/deleteAll')?'':'hide'}" title="批量删除"><i class="fa fa-times"></i> 批量删除</a>
</div>
... ...
... ... @@ -21,6 +21,7 @@
</div>-->
<a href="javascript:;" class="btn btn-danger btn-change1All btn-disabled {:$auth->check('course_store/change1All')?'':'hide'}" title="上架"><i class="fa fa-check"></i> 上架</a>
<a href="javascript:;" class="btn btn-danger btn-changeAll btn-disabled {:$auth->check('course_store/changeAll')?'':'hide'}" title="下架"><i class="fa fa-check"></i> 下架</a>
<a href="javascript:;" class="btn btn-danger btn-deleteAll btn-disabled {:$auth->check('course_store/deleteAll')?'':'hide'}" title="批量删除"><i class="fa fa-check"></i> 批量删除</a>
</div>
... ...
... ... @@ -174,11 +174,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
var arr = [];
var a = true;
$.each(temp, function(key, value){
if(value.status !=='new'){
/* if(value.status !=='new'){
Layer.open({title: '错误', content: '含有已发布或取消的课程', btn: '确定'});
a = false;
return false;
}
}*/
arr.push(value.id);
});
if(a){
... ... @@ -191,11 +191,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
dataType: "json",
success : function (data) {
if (data.code === 1) {
Layer.msg('发布成功');
Layer.msg('删除成功');
Layer.closeAll();
$('.btn-refresh').trigger('click')
} else {
Layer.msg('发布失败');
Layer.msg('删除失败');
}
}
});
... ...
... ... @@ -30,7 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
dblClickToEdit: false,
columns: [
[
//{checkbox: true},
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'name', title: __('Name')},
{field: 'address', title: __('Address')},
... ... @@ -60,7 +60,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
Table.api.bindevent(table);
//上架
$(document).on("click",".btn-btn-change1All",function (e) {
$(document).on("click",".btn-change1All",function (e) {
var temp=table.bootstrapTable('getSelections');
var arr = [];
$.each(temp, function(key, value){
... ... @@ -86,7 +86,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
});
//下架
$(document).on("click",".btn-btn-changeAll",function (e) {
$(document).on("click",".btn-changeAll",function (e) {
var temp=table.bootstrapTable('getSelections');
var arr = [];
$.each(temp, function(key, value){
... ... @@ -110,6 +110,32 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
});
});
//下架
$(document).on("click",".btn-deleteAll",function (e) {
var temp=table.bootstrapTable('getSelections');
var arr = [];
$.each(temp, function(key, value){
arr.push(value.id);
});
$.ajax({
type : "POST",
url : "store/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();
... ...