chuweiqiang 1 年之前
父節點
當前提交
75965e45db

+ 38 - 0
application/admin/controller/books/SampleApply.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace app\admin\controller\books;
+
+use app\common\controller\Backend;
+
+/**
+ * 样书申请管理
+ *
+ * @icon fa fa-circle-o
+ */
+class SampleApply extends Backend
+{
+
+    /**
+     * SampleApply模型对象
+     * @var \app\admin\model\books\SampleApply
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\books\SampleApply;
+        $this->view->assign("useToList", $this->model->getUseToList());
+        $this->view->assign("statusList", $this->model->getStatusList());
+    }
+
+
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+
+
+}

+ 18 - 0
application/admin/lang/zh-cn/books/sample_apply.php

@@ -0,0 +1,18 @@
+<?php
+
+return [
+    'Id'              => 'ID',
+    'User_id'         => '用户id',
+    'Name'            => '姓名',
+    'Phone'           => '电话',
+    'Email'           => '邮箱',
+    'School'          => '所在学校',
+    'Use_to'          => '用途 0教材用书 1学习参考 2其他',
+    'Mailing_name'    => '邮寄姓名',
+    'Mailing_area'    => '邮寄地区',
+    'Mailing_address' => '邮寄详细地址',
+    'Mailing_phone'   => '邮寄手机号',
+    'Status'          => '状态 0未审核 1已寄出 2已拒绝',
+    'Createtime'      => '创建时间',
+    'Updatetime'      => '更新时间'
+];

+ 63 - 0
application/admin/model/books/SampleApply.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace app\admin\model\books;
+
+use think\Model;
+
+
+class SampleApply extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'sample_apply';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'integer';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'use_to_text',
+        'status_text'
+    ];
+    
+
+    
+    public function getUseToList()
+    {
+        return ['0' => __('Use_to 0'), '1' => __('Use_to 1'), '2' => __('Use_to 2')];
+    }
+
+    public function getStatusList()
+    {
+        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
+    }
+
+
+    public function getUseToTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['use_to']) ? $data['use_to'] : '');
+        $list = $this->getUseToList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+
+
+}

+ 5 - 5
application/admin/model/order/OrderGoods.php

@@ -8,13 +8,13 @@ use think\Model;
 class OrderGoods extends Model
 {
 
-    
 
-    
+
+
 
     // 表名
     protected $name = 'order_goods';
-    
+
     // 自动写入时间戳字段
     protected $autoWriteTimestamp = 'integer';
 
@@ -27,9 +27,9 @@ class OrderGoods extends Model
     protected $append = [
         'goods_type_text'
     ];
-    
 
-    
+
+
     public function getGoodsTypeList()
     {
         return ['0' => __('Goods_type 0'), '1' => __('Goods_type 1')];

+ 27 - 0
application/admin/validate/books/SampleApply.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate\books;
+
+use think\Validate;
+
+class SampleApply extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 10 - 9
application/admin/view/books/contribute/index.html

@@ -6,19 +6,20 @@
             <div class="tab-pane fade active in" id="one">
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
-                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
-                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('books/contribute/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
-                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('books/contribute/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
-                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('books/contribute/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
-                        
+<!--                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>-->
+<!--                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('books/contribute/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
+<!--                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('books/contribute/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
+<!--                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('books/contribute/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
+
+
+
 
-                        
 
-                        
                     </div>
+<!--                    data-operate-edit="{:$auth->check('books/contribute/edit')}"-->
+<!--                    data-operate-del="{:$auth->check('books/contribute/del')}"-->
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
-                           data-operate-edit="{:$auth->check('books/contribute/edit')}"
-                           data-operate-del="{:$auth->check('books/contribute/del')}"
+
                            width="100%">
                     </table>
                 </div>

+ 87 - 0
application/admin/view/books/sample_apply/add.html

@@ -0,0 +1,87 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-name" class="form-control" name="row[name]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Phone')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-phone" class="form-control" name="row[phone]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-email" class="form-control" name="row[email]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('School')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-school" class="form-control" name="row[school]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Use_to')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-use_to" class="form-control selectpicker" name="row[use_to]">
+                {foreach name="useToList" item="vo"}
+                    <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Mailing_name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-mailing_name" class="form-control" name="row[mailing_name]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Mailing_area')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-mailing_area" class="form-control" name="row[mailing_area]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Mailing_address')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-mailing_address" class="form-control" name="row[mailing_address]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Mailing_phone')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-mailing_phone" class="form-control" name="row[mailing_phone]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+        </div>
+    </div>
+</form>

+ 87 - 0
application/admin/view/books/sample_apply/edit.html

@@ -0,0 +1,87 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Phone')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-phone" class="form-control" name="row[phone]" type="text" value="{$row.phone|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-email" class="form-control" name="row[email]" type="text" value="{$row.email|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('School')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-school" class="form-control" name="row[school]" type="text" value="{$row.school|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Use_to')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-use_to" class="form-control selectpicker" name="row[use_to]">
+                {foreach name="useToList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.use_to"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Mailing_name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-mailing_name" class="form-control" name="row[mailing_name]" type="text" value="{$row.mailing_name|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Mailing_area')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-mailing_area" class="form-control" name="row[mailing_area]" type="text" value="{$row.mailing_area|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Mailing_address')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-mailing_address" class="form-control" name="row[mailing_address]" type="text" value="{$row.mailing_address|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Mailing_phone')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-mailing_phone" class="form-control" name="row[mailing_phone]" type="text" value="{$row.mailing_phone|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <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> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+        </div>
+    </div>
+</form>

+ 46 - 0
application/admin/view/books/sample_apply/index.html

@@ -0,0 +1,46 @@
+<div class="panel panel-default panel-intro">
+    
+    <div class="panel-heading">
+        {:build_heading(null,FALSE)}
+        <ul class="nav nav-tabs" data-field="status">
+            <li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
+            {foreach name="statusList" item="vo"}
+            <li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
+            {/foreach}
+        </ul>
+    </div>
+
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('books/sample_apply/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('books/sample_apply/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('books/sample_apply/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        
+
+                        <div class="dropdown btn-group {:$auth->check('books/sample_apply/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                {foreach name="statusList" item="vo"}
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
+                                {/foreach}
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('books/sample_apply/edit')}"
+                           data-operate-del="{:$auth->check('books/sample_apply/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 153 - 0
application/api/controller/Order.php

@@ -0,0 +1,153 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Gold
+ * Date: 2024/1/16
+ * Time: 9:25
+ */
+
+namespace app\api\controller;
+use app\admin\model\order\Order as OrderModel; //订单
+use app\admin\model\order\OrderGoods; //订单商品
+use app\admin\model\books\Books; //教材
+use app\admin\model\video\Video; //教材
+
+use app\common\controller\Api;
+use think\Db;
+
+class Order extends Api
+{
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 创建订单
+     *
+     */
+    public function createOrder(){
+        $data = input();
+        $uid = $this->auth->id;
+        $OrderModel = new OrderModel();
+        $OrderGoods = new OrderGoods();
+        $Books = new Books();
+        $Video = new Video();
+
+        if(!isset($data['type']) || !$data['goods_id']) $this->error('参数错误');
+
+        if($data['type'] == '0'){
+           $total_price = $Books->where('id','in',$data['goods_id'])->sum('price');
+        }else if($data['type'] == '1'){
+           $total_price =  $Video->where('id','in',$data['goods_id'])->sum('price');
+        }
+
+//        return $total_price;
+
+        $order_arr = [
+            'user_id' => $uid,
+            'order_on' => $this->get_order_sn(),
+            'type' => $data['type'],
+            'total_price' => $total_price
+        ];
+
+        Db::startTrans();
+        try {
+
+        $save = $OrderModel->save($order_arr);
+        $goods_id = explode(',',$data['goods_id']);
+        if(count($goods_id) > 1){
+            foreach ($goods_id as $k => $v){
+                if($data['type'] == 0){
+                    $price = $Books->where('id',$v)->column('price');
+                    $arr = [
+                        'order_id' => $OrderModel->id,
+                        'goods_type' => $data['type'],
+                        'goods_id' => $v,
+                        'price' => (int)$price[0],
+                    ];
+                    $OrderGoods = new OrderGoods();
+                    $OrderGoods->save($arr);
+                }else if($data['type'] == 1){
+                    $price = $Video->where('id',$v)->column('price');
+                    $arr = [
+                        'order_id' => $OrderModel->id,
+                        'goods_type' => $data['type'],
+                        'goods_id' => $v,
+                        'price' => (int)$price[0],
+                    ];
+                    $OrderGoods = new OrderGoods();
+                    $OrderGoods->save($arr);
+                }
+
+            }
+        }
+                 Db::commit();
+        } catch (Exception $e) {
+                $this->setError($e->getMessage());
+                Db::rollback();
+                return false;
+        }
+        $this->success('操作成功',$OrderModel);
+    }
+
+
+    /**
+     * 创建订单
+     *
+     */
+    public function getOrderList(){
+        $data = input();
+        $where = [];
+        $uid = $this->auth->id;
+        $OrderModel = new OrderModel();
+        if(!isset($data['page']) || $data['page'] == '' || $data['page'] == null){
+            $page = 1;
+        }else{
+            $page = $data['page'];
+        }
+        if(!isset($data['limit']) || $data['limit'] == '' || $data['limit'] == null){
+            $limit = 20;
+        }else{
+            $limit = $data['limit'];
+        }
+        if(isset($data['status']) && $data['status'] != '' && $data['status'] != null){
+            $where['status'] = $data['status'];
+        }
+        $where['user_id'] = $uid;
+        $list = $OrderModel->where($where)->with(['goods'])->paginate([
+            'list_rows'=> $limit,
+            'page' => $page,
+        ]);
+        $lists = $list->toArray();
+
+        foreach ($lists['data'] as $key => $item){
+            foreach ($item['goods'] as $k => $v){
+                if($v['goods_type'] == 0){
+                    $Books = new Books();
+                    $lists['data'][$key]['goods'][$k]['good_item'] = $Books->where('id',$v['goods_id'])->field('id,title,image,book_type,is_new_recommend,author,is_awards,price,entity_price,createtime,updatetime,level_id,arrangement_id,speciality_id,series_id,is_series')->find();
+                }else if($v['goods_type'] == 1){
+                    $Video = new Video();
+                    $lists['data'][$key]['good_item'] = $Video->where('id',$v['goods_id'])->find();
+                }
+            }
+        }
+
+
+        $this->success('操作成功',$lists);
+    }
+
+
+    /**
+     * 生成订单号
+     *
+     */
+    public function get_order_sn(){
+        $order_id_main = date('YmdHis') . rand(10000000,99999999);
+        $order_id_len = strlen($order_id_main);
+        $order_id_sum = 0;
+        for($i=0; $i<$order_id_len; $i++){
+            $order_id_sum += (int)(substr($order_id_main,$i,1));
+        }
+        $osn = $order_id_main . str_pad((100 - $order_id_sum % 100) % 100,2,'0',STR_PAD_LEFT);
+        return $osn;
+    }
+
+}

+ 1 - 1
application/api/controller/Video.php

@@ -39,7 +39,7 @@ class Video extends Api
             $where['title'] = ['like','%'.$data['keywords'].'%'];
         }
         $VideoModel = new VideoModel();
-        $list = $VideoModel->where('is_deleted',1)->where($where)->paginate([
+        $list = $VideoModel->where('is_deleted',1)->where($where)->order('sort desc,id desc')->paginate([
             'list_rows'=> $limit,
             'page' => $page,
         ]);

+ 1 - 1
public/assets/js/backend/books/contribute.js

@@ -38,7 +38,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'funds_status', title: __('经费情况'), searchList: {"0":__('无经费'),"1":__('三万以内'),"2":__('五万以内'),"3":__('五万以上')}, formatter: Table.api.formatter.status},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]
             });

+ 65 - 0
public/assets/js/backend/books/sample_apply.js

@@ -0,0 +1,65 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'books/sample_apply/index' + location.search,
+                    add_url: 'books/sample_apply/add',
+                    edit_url: 'books/sample_apply/edit',
+                    del_url: 'books/sample_apply/del',
+                    multi_url: 'books/sample_apply/multi',
+                    import_url: 'books/sample_apply/import',
+                    table: 'sample_apply',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                fixedColumns: true,
+                fixedRightNumber: 1,
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'user_id', title: __('User_id')},
+                        {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'phone', title: __('Phone'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'email', title: __('Email'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'school', title: __('School'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'use_to', title: __('Use_to'), searchList: {"0":__('Use_to 0'),"1":__('Use_to 1'),"2":__('Use_to 2')}, formatter: Table.api.formatter.normal},
+                        {field: 'mailing_name', title: __('Mailing_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'mailing_area', title: __('Mailing_area'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'mailing_address', title: __('Mailing_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'mailing_phone', title: __('Mailing_phone'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
+                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});