Commit a33b0058 by 杨树贤

添加批量删除,修改页面等

parent 359b8ae2
......@@ -11,6 +11,13 @@ use Illuminate\Http\Request;
class IntegralsApiController extends Controller
{
protected $service;
public function __construct(IntegralService $service)
{
$this->service = $service;
}
public function integralListApi(Request $request, IntegralService $service)
{
$data = $service->getIntegralList('/integrals?' . urldecode(http_build_query($request->all())));
......@@ -56,4 +63,22 @@ class IntegralsApiController extends Controller
return $result;
}
public function changeIntegralStatusApi(Request $request)
{
$id = $request->id;
$status = $request->status;
$path = 'integrals/' . $id;
$result = $this->service->changeIntegralStatus($path, ['status' => $status]);
return $result;
}
public function batchUpdateStatusApi(Request $request)
{
$path = 'integrals/batchUpdateStatus';
$result = $this->service->batchUpdateStatus($path, $request->all());
return $result;
}
}
\ No newline at end of file
......@@ -31,4 +31,14 @@ class IntegralService extends BaseService
return $this->apiPatch($path, $data);
}
public function changeIntegralStatus($path, $data = [])
{
return $this->apiPatch($path, $data);
}
public function batchUpdateStatus($path, $data = [])
{
return $this->apiPost($path, $data);
}
}
\ No newline at end of file
......@@ -11,6 +11,36 @@ function getRequestParams() {
return theRequest;
}
function changeStatus(checkStatus, status, table) {
var data = checkStatus.data;
var ids = [];
for (var key in data) {
ids.push(data[key].id);
}
var operateText = status ? '恢复' : '禁用';
layer.confirm('确定要批量' + operateText + '?', function (index) {
$.ajax({
url: '/integrals/api/batchUpdateStatusApi',
type: 'post',
data: {ids: ids, status: status},
dataType: 'json',
timeout: 10000,
success: function (res) {
if (!res) return layer.msg('网络错误,请重试', {icon: 5});
if (res.errcode === 0) {
var msg = status ? '批量恢复成功' : '批量禁用成功';
layer.msg('批量' + operateText + '成功');
table.reload('Integral');
}
},
error: function () {
return layer.msg('网络错误,请重试', {icon: 5});
}
})
})
}
layui.use(['table', 'form', 'laydate', 'layer'], function () {
var table = layui.table;
......@@ -30,7 +60,8 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
, defaultToolbar: ['filter']
, loading: true
, cols: [[
{field: 'id', title: '序号'}
{type:'checkbox'}
,{field: 'id', title: '序号'}
, {field: 'name', title: '红包名称'}
, {field: 'amount', title: '奖励金额'}
, {field: 'daily_limit', title: '每个用户日限', templet: '#title'}
......@@ -38,7 +69,7 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
, {field: 'update_time', title: '配置更新时间', templet: '#update_time'}
, {field: 'experience', title: '操作', templet: '#operate', fixed: 'right'}
]]
, id: 'Reload'
, id: 'Integral'
, page: {
// layout: ['prev', 'page', 'next', 'count', 'skip'] //自定义分页布局
}
......@@ -46,34 +77,42 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
//监听行工具事件
table.on('tool(Integral)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
table.on('tool(Integral)', function (obj) {
var data = obj.data //获得当前行数据
, layEvent = obj.event; //获得 lay-event 对应的值
if (layEvent === 'detail') {
layer.msg('查看操作');
} else if (layEvent === 'del') {
layer.confirm('真的删除积分项吗', function (index) {
//向服务端发送删除指令
console.log(obj.data.id);
$.get('/integrals/api/deleteIntegral', {id: obj.data.id}, function (result) {
if (result.errcode === 0) {
layer.msg('删除成功!');
layer.close(index);
table.reload('Reload');
}
switch (layEvent) {
case 'disable':
layer.confirm('确定要禁用该项红包?', function (index) {
//向服务端发送禁用指令
$.get('/integrals/api/changeIntegralStatusApi', {
id: obj.data.id,
status: 0
}, function (result) {
if (result.errcode === 0) {
layer.msg('禁用成功!');
layer.close(index);
table.reload('Integral');
}
});
});
break;
case 'recover':
layer.confirm('确定要恢复该项红包?', function (index) {
$.get('/integrals/api/changeIntegralStatusApi', {
id: obj.data.id,
status: 1
}, function (result) {
if (result.errcode === 0) {
layer.msg('恢复成功!');
layer.close(index);
table.reload('Integral');
}
});
});
});
} else if (layEvent === 'edit') {
window.location = '/integrals/updateIntegral?id=' + obj.data.id;
} else if (layEvent === 'setting') {
//iframe层-父子操作
layer.open({
type: 2,
area: ['500px', '350px'],
fixed: false, //不固定
maxmin: true,
content: '/integrals/settingIntegral'
});
break;
case 'edit':
window.location = '/integrals/updateIntegral?id=' + obj.data.id;
break;
}
});
......@@ -88,71 +127,18 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
return false;
});
//实现额外的全选 --start
form.on('checkbox(qx)', function (data) {
var checkStatus = table.checkStatus('Reload');
if (data.elem.checked) {//选中
if (checkStatus.isAll == true) {//已经全选
return false;
}
} else {
if (checkStatus.isAll == false) {//已经全选
return false;
}
}
$('.layui-table-header thead tr th .laytable-cell-checkbox .layui-form-checkbox').trigger('click');
});
table.on('checkbox(Reload)', function (obj) {
var checkStatus = table.checkStatus('Reload');
if (checkStatus.isAll == true) {
$('input[name=qx]').prop("checked", true);
} else {
$('input[name=qx]').removeAttr("checked");
//头工具栏事件
table.on('toolbar(Integral)', function (obj) {
var checkStatus = table.checkStatus(obj.config.id);
switch (obj.event) {
case 'batchDisableStatus':
changeStatus(checkStatus, 0, table);
break;
case 'batchRecoverStatus':
changeStatus(checkStatus, 1, table);
break;
}
form.render(); //更新渲染
});
// 实现额外的全选 --end
$('#down').click(function () {
var checkStatus = table.checkStatus('Reload')
, data = checkStatus.data;
ids = [];
for (var i in data) {
if (data[i].audit_status == 1 && data[i].goods_id > 0) {
ids[i] = data[i].goods_id;
}
}
if (!ids || ids.length < 1) return layer.msg('没有可以操作的数据', {offset: 200, icon: 6});
layer.prompt(function (val, index) {
if (!val) return layer.msg('请输入禁用原因', {icon: 6});
layer.msg('处理中', {icon: 16, time: 10000});
var data = {
goods_id: ids,
prohibit_remark: val
};
$.ajax({
url: '/goods/api/ApiProhibitGoods',
type: 'post',
data: data,
dataType: 'json',
timeout: 10000,
success: function (res) {
if (!res) return layer.msg('网络错误,请重试', {icon: 5});
layer.msg(res.errmsg, {icon: 6});
if (res.errcode == 0) {
window.location.reload();
}
},
error: function () {
return layer.msg('网络错误,请重试', {icon: 5});
}
})
});
})
});
\ No newline at end of file
......@@ -20,24 +20,18 @@
<div class="layui-inline">
<label class="layui-form-label">每个用户日限</label>
<div class="layui-input-inline">
<input type="text" name="daily_limit" lay-verify="required|number" autocomplete="off" class="layui-input">
<input type="text" name="daily_limit" lay-verify="required|number" autocomplete="off"
class="layui-input">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">配置状态</label>
<div class="layui-input-block">
<input type="checkbox" checked="" value="1" name="status" lay-skin="switch" lay-filter="switchStatus"
lay-text="使用中|已停用">
<div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch">
<em>使用中</em><i></i>
</div>
</div>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status','配置状态',1,[0=>'已停用',1=>'使用中']) !!}
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit="" lay-filter="creat_integral">立即提交</button>
{{-- <button type="reset" class="layui-btn layui-btn-primary">重置</button>--}}
</div>
</div>
</div>
......
<div class="layui-card">
<div class="layui-card-body" style="padding-top: 20px">
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
<form class="layui-form" action="">
<div class="layui-form-item">
<div class="layui-inline">
......@@ -12,35 +12,51 @@
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status','配置状态',request()->get('status'),[0=>'已用',1=>'使用中']) !!}
{!! $statusPresenter->render('status','配置状态',request()->get('status'),[0=>'已用',1=>'使用中']) !!}
</div>
<div class="layui-inline">
<button type="submit" class="layui-btn layui-btn-sm">
<button type="submit" class="layui-btn">
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
</button>
<a type="button" href="/integrals/integralList"
class="layui-btn layui-btn-primary layui-btn-sm">
<i class="layui-icon layui-icon-refresh-3" title="重置搜索"></i>
<a type="button" class="layui-btn" href="/integrals/integralList">
<i class="layui-icon layui-icon-refresh-3 layuiadmin-button-btn" title="重置搜索"></i>
</a>
</div>
</div>
</form>
</div>
<div class="layui-card-body" style="padding-top: 20px">
<div style="padding-bottom: 10px;">
{{-- <button class="layui-btn layui-btn-danger layuiadmin-btn-list" data-type="batchdel">禁用</button>--}}
<a href="/integrals/createIntegral" class="layui-btn layuiadmin-btn-list"
data-type="add">添加</a>
</div>
<table class="layui-table" id="list" lay-filter="Integral"></table>
</div>
</div>
<script type="text/html" id="operate">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
{{-- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>--}}
{{-- <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="setting">设置</a>--}}
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">编辑</a>
@{{# if(d.status == '使用中'){ }}
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="disable">禁用</a>
@{{# } else { }}
<a class="layui-btn layui-btn-green layui-btn-xs" lay-event="recover">恢复</a>
@{{# } }}
</script>
<script type="text/html" id="status">
@{{# if(d.status == '使用中'){ }}
<span class="layui-badge-dot layui-bg-blue"></span>
@{{# } else { }}
<span class="layui-badge-dot layui-bg-gray"></span>
@{{# } }}
@{{d.status}}
</script>
<script type="text/html" id="toolbarLeft">
<div class="layui-btn-container">
<a href="/integrals/createIntegral" class="layui-btn layui-btn-sm" lay-event="getCheckData">新增红包</a>
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="batchDisableStatus">禁用所选中行</button>
<button class="layui-btn layui-btn-green layui-btn-sm" lay-event="batchRecoverStatus">恢复所选中行</button>
</div>
</script>
<script>
</script>
\ No newline at end of file
......@@ -29,18 +29,8 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">配置状态</label>
<div class="layui-input-block">
@php
$check = $integral['status']?'checked':'';
@endphp
<input type="checkbox" {{$check}} value="{{$integral['status']}}" name="status" lay-skin="switch"
lay-filter="switchStatus"
lay-text="使用中|已停用">
<div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch">
<em>使用中</em><i></i>
</div>
</div>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status','配置状态',$integral['status'],[0=>'已停用',1=>'使用中']) !!}
</div>
<div class="layui-form-item">
<div class="layui-input-block">
......
......@@ -34,10 +34,14 @@ Route::get('/time', function () {
});
Route::namespace('Api')->group(function () {
//基础积分信息
Route::match(['get', 'post'], '/integrals/api/integralList', 'IntegralsApiController@integralListApi');
Route::match(['get', 'post'], '/integrals/api/deleteIntegral', 'IntegralsApiController@deleteIntegralApi');
Route::match(['get', 'post'], '/integrals/api/storeIntegralApi', 'IntegralsApiController@storeIntegralApi');
Route::match(['get', 'post'], '/integrals/api/updateIntegralApi', 'IntegralsApiController@updateIntegralApi');
Route::match(['get', 'post'], '/integrals/api/changeIntegralStatusApi', 'IntegralsApiController@changeIntegralStatusApi');
Route::match(['get', 'post'], '/integrals/api/batchUpdateStatusApi', 'IntegralsApiController@batchUpdateStatusApi');
//用户积分
Route::match(['get', 'post'], '/user_integrals/api/userIntegralList',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment