Commit 153248f9 by 杨树贤

添加日期范围选择presenter和添加时间筛选

parent 40026aed
...@@ -31,16 +31,17 @@ class IntegralsApiController extends Controller ...@@ -31,16 +31,17 @@ class IntegralsApiController extends Controller
private function transformer($data) private function transformer($data)
{ {
if (isset($data['data']) && $data['data']) {
foreach ($data['data'] as &$item) { foreach ($data['data'] as &$item) {
$item['status'] = $item['status'] ? '使用中' : '已停用'; $item['status'] = $item['status'] ? '使用中' : '已停用';
$item['add_time'] = date('Y-m-d H:i:s', $item['add_time']); $item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
$item['update_time'] = $item['update_time'] ? date('Y-m-d H:i:s', $item['update_time']) : '暂无更新'; $item['update_time'] = $item['update_time'] ? date('Y-m-d H:i:s', $item['update_time']) : '暂无更新';
$item['daily_limit'] = "每日{$item['daily_limit']}次"; $item['daily_limit'] = "每日{$item['daily_limit']}次";
} }
}
unset($item); unset($item);
return $data; return $data;
} }
public function storeIntegralApi(IntegralApiRequest $request, IntegralService $service) public function storeIntegralApi(IntegralApiRequest $request, IntegralService $service)
......
<?php
namespace App\Presenters;
class TimeIntervalPresenter
{
public function render($name, $text)
{
$time = request()->get($name);
$html = <<<EOF
<label class="layui-form-label">$text</label>
<div class="layui-input-inline" style="min-width: 300px">
<input type="text" name="{$name}" autocomplete="off" class="layui-input">
</div>
<script>
$(window).load(function(){
var laydate = layui.laydate;
laydate.render({
elem: 'input[name=$name]'
,type: 'datetime'
,trigger:'click'
,range: '~' //或 range: '~' 来自定义分割字符
,value: '$time'
});
});
</script>
EOF;
return $html;
}
}
\ No newline at end of file
...@@ -46,6 +46,7 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () { ...@@ -46,6 +46,7 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
var table = layui.table; var table = layui.table;
var form = layui.form; var form = layui.form;
table.render({ table.render({
elem: '#list' elem: '#list'
, url: '/integrals/api/integralList' , url: '/integrals/api/integralList'
...@@ -59,8 +60,8 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () { ...@@ -59,8 +60,8 @@ layui.use(['table', 'form', 'laydate', 'layer'], function () {
, defaultToolbar: ['filter'] , defaultToolbar: ['filter']
, loading: true , loading: true
, cols: [[ , cols: [[
{type:'checkbox'} {type: 'checkbox'}
,{field: 'id', title: '序号'} , {field: 'id', title: '序号'}
, {field: 'name', title: '红包名称'} , {field: 'name', title: '红包名称'}
, {field: 'amount', title: '奖励金额'} , {field: 'amount', title: '奖励金额'}
, {field: 'daily_limit', title: '每个用户日限', templet: '#title'} , {field: 'daily_limit', title: '每个用户日限', templet: '#title'}
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
{!! $statusPresenter->render('status','配置状态',request()->get('status'),[0=>'已停用',1=>'使用中']) !!} {!! $statusPresenter->render('status','配置状态',request()->get('status'),[0=>'已停用',1=>'使用中']) !!}
</div> </div>
<div class="layui-inline"> <div class="layui-inline">
@inject('timeInterval','App\Presenters\TimeIntervalPresenter')
{!! $timeInterval->render('add_time','添加时间') !!}
</div>
<div class="layui-inline">
<button type="submit" class="layui-btn"> <button type="submit" class="layui-btn">
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
</button> </button>
......
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