作者 杨育虎

优惠券

@@ -22,7 +22,7 @@ class Tick extends Backend @@ -22,7 +22,7 @@ class Tick extends Backend
22 { 22 {
23 parent::_initialize(); 23 parent::_initialize();
24 $this->model = new \app\admin\model\Tick; 24 $this->model = new \app\admin\model\Tick;
25 - 25 + $this->view->assign("statusList", $this->model->getStatusList());
26 } 26 }
27 27
28 public function import() 28 public function import()
@@ -5,5 +5,8 @@ return [ @@ -5,5 +5,8 @@ return [
5 'Title' => '优惠券名称', 5 'Title' => '优惠券名称',
6 'You_time' => '有效期(天)', 6 'You_time' => '有效期(天)',
7 'Door' => '使用门槛(元)', 7 'Door' => '使用门槛(元)',
8 - 'Del_price' => '优惠金额(元)' 8 + 'Del_price' => '优惠金额(元)',
  9 + 'Status' => '类型',
  10 + 'Status 1' => '新人券',
  11 + 'Status 2' => '拉新券'
9 ]; 12 ];
@@ -25,12 +25,16 @@ class Tick extends Model @@ -25,12 +25,16 @@ class Tick extends Model
25 25
26 // 追加属性 26 // 追加属性
27 protected $append = [ 27 protected $append = [
28 - 'you_time_text' 28 + 'you_time_text',
  29 + 'status_text'
29 ]; 30 ];
30 31
31 32
32 33
33 - 34 + public function getStatusList()
  35 + {
  36 + return ['1' => __('Status 1'), '2' => __('Status 2')];
  37 + }
34 38
35 39
36 public function getYouTimeTextAttr($value, $data) 40 public function getYouTimeTextAttr($value, $data)
@@ -39,6 +43,14 @@ class Tick extends Model @@ -39,6 +43,14 @@ class Tick extends Model
39 return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; 43 return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
40 } 44 }
41 45
  46 +
  47 + public function getStatusTextAttr($value, $data)
  48 + {
  49 + $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  50 + $list = $this->getStatusList();
  51 + return isset($list[$value]) ? $list[$value] : '';
  52 + }
  53 +
42 protected function setYouTimeAttr($value) 54 protected function setYouTimeAttr($value)
43 { 55 {
44 return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); 56 return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
@@ -24,6 +24,18 @@ @@ -24,6 +24,18 @@
24 <input id="c-del_price" data-rule="required" class="form-control" step="0.01" name="row[del_price]" type="number"> 24 <input id="c-del_price" data-rule="required" class="form-control" step="0.01" name="row[del_price]" type="number">
25 </div> 25 </div>
26 </div> 26 </div>
  27 + <div class="form-group">
  28 + <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
  29 + <div class="col-xs-12 col-sm-8">
  30 +
  31 + <div class="radio">
  32 + {foreach name="statusList" item="vo"}
  33 + <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label>
  34 + {/foreach}
  35 + </div>
  36 +
  37 + </div>
  38 + </div>
27 <div class="form-group layer-footer"> 39 <div class="form-group layer-footer">
28 <label class="control-label col-xs-12 col-sm-2"></label> 40 <label class="control-label col-xs-12 col-sm-2"></label>
29 <div class="col-xs-12 col-sm-8"> 41 <div class="col-xs-12 col-sm-8">
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 <div class="form-group"> 9 <div class="form-group">
10 <label class="control-label col-xs-12 col-sm-2">{:__('You_time')}:</label> 10 <label class="control-label col-xs-12 col-sm-2">{:__('You_time')}:</label>
11 <div class="col-xs-12 col-sm-8"> 11 <div class="col-xs-12 col-sm-8">
12 - <input id="c-you_time" data-rule="required" class="form-control" data-use-current="true" name="row[you_time]" type="number" value="{:$row.you_time}"> 12 + <input id="c-you_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[you_time]" type="text" value="{:$row.you_time?datetime($row.you_time):''}">
13 </div> 13 </div>
14 </div> 14 </div>
15 <div class="form-group"> 15 <div class="form-group">
@@ -24,6 +24,18 @@ @@ -24,6 +24,18 @@
24 <input id="c-del_price" data-rule="required" class="form-control" step="0.01" name="row[del_price]" type="number" value="{$row.del_price|htmlentities}"> 24 <input id="c-del_price" data-rule="required" class="form-control" step="0.01" name="row[del_price]" type="number" value="{$row.del_price|htmlentities}">
25 </div> 25 </div>
26 </div> 26 </div>
  27 + <div class="form-group">
  28 + <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
  29 + <div class="col-xs-12 col-sm-8">
  30 +
  31 + <div class="radio">
  32 + {foreach name="statusList" item="vo"}
  33 + <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
  34 + {/foreach}
  35 + </div>
  36 +
  37 + </div>
  38 + </div>
27 <div class="form-group layer-footer"> 39 <div class="form-group layer-footer">
28 <label class="control-label col-xs-12 col-sm-2"></label> 40 <label class="control-label col-xs-12 col-sm-2"></label>
29 <div class="col-xs-12 col-sm-8"> 41 <div class="col-xs-12 col-sm-8">
1 <div class="panel panel-default panel-intro"> 1 <div class="panel panel-default panel-intro">
2 - {:build_heading()} 2 +
  3 + <div class="panel-heading">
  4 + {:build_heading(null,FALSE)}
  5 + <ul class="nav nav-tabs" data-field="status">
  6 + <li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
  7 + {foreach name="statusList" item="vo"}
  8 + <li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
  9 + {/foreach}
  10 + </ul>
  11 + </div>
  12 +
3 13
4 <div class="panel-body"> 14 <div class="panel-body">
5 <div id="myTabContent" class="tab-content"> 15 <div id="myTabContent" class="tab-content">
@@ -7,18 +17,18 @@ @@ -7,18 +17,18 @@
7 <div class="widget-body no-padding"> 17 <div class="widget-body no-padding">
8 <div id="toolbar" class="toolbar"> 18 <div id="toolbar" class="toolbar">
9 <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> 19 <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
10 -<!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('tick/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>--> 20 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('tick/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
11 <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('tick/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> 21 <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('tick/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
12 -<!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('tick/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->  
13 -<!-- <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('tick/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->  
14 -<!---->  
15 -<!-- <div class="dropdown btn-group {:$auth->check('tick/multi')?'':'hide'}">-->  
16 -<!-- <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->  
17 -<!-- <ul class="dropdown-menu text-left" role="menu">-->  
18 -<!-- <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>-->  
19 -<!-- <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>-->  
20 -<!-- </ul>-->  
21 -<!-- </div>--> 22 + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('tick/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
  23 + <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('tick/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
  24 +
  25 + <div class="dropdown btn-group {:$auth->check('tick/multi')?'':'hide'}">
  26 + <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
  27 + <ul class="dropdown-menu text-left" role="menu">
  28 + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
  29 + <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>
  30 + </ul>
  31 + </div>
22 32
23 33
24 </div> 34 </div>
此 diff 太大无法显示。
@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
8 index_url: 'tick/index' + location.search, 8 index_url: 'tick/index' + location.search,
9 add_url: 'tick/add', 9 add_url: 'tick/add',
10 edit_url: 'tick/edit', 10 edit_url: 'tick/edit',
11 - // del_url: 'tick/del', 11 + del_url: 'tick/del',
12 multi_url: 'tick/multi', 12 multi_url: 'tick/multi',
13 import_url: 'tick/import', 13 import_url: 'tick/import',
14 table: 'tick', 14 table: 'tick',
@@ -30,6 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -30,6 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
30 {field: 'you_time', title: __('You_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, 30 {field: 'you_time', title: __('You_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
31 {field: 'door', title: __('Door')}, 31 {field: 'door', title: __('Door')},
32 {field: 'del_price', title: __('Del_price'), operate:'BETWEEN'}, 32 {field: 'del_price', title: __('Del_price'), operate:'BETWEEN'},
  33 + {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
33 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} 34 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
34 ] 35 ]
35 ] 36 ]