xieruidong 2 years ago
parent
commit
fdc1d49dea

+ 37 - 0
application/admin/controller/GoodsSku.php

@@ -12,12 +12,49 @@ use app\common\controller\Backend;
 class GoodsSku extends Backend
 {
     protected $noNeedRight=['bindList'];
+    protected $relationSearch=true;
     public function _initialize()
     {
         parent::_initialize(); // TODO: Change the autogenerated stub
         $this->model=new \app\admin\model\GoodsSku;
     }
 
+    public function index()
+    {
+        $pid=$this->request->get('pid');
+        //当前是否为关联查询
+        $this->relationSearch = false;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $map=[];
+            if($pid){
+                $map['programme_id']=$pid;
+            }
+
+            $list = $this->model
+                ->with(['goods'])
+                ->where($where)
+                ->where($map)
+                ->order($sort, $order)
+                ->paginate($limit);
+
+            foreach ($list as $row) {
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
     public function bind_list(){
         $name=input('name');
         $page=input('pageNumber')?:1;

+ 23 - 0
application/admin/view/goods_sku/index.html

@@ -0,0 +1,23 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <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>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('programme_goods/edit')}" 
+                           data-operate-del="{:$auth->check('programme_goods/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 1 - 0
application/api/controller/UserTax.php

@@ -47,6 +47,7 @@ class UserTax extends Api
                 'id'=>$item['id'],
                 'tax_link'=>$item['orders']['tax_link']??null,
                 'status'=>empty($item['orders']['tax_link'])?1:2,
+                'is_default'=>$item['is_default'],
             ];
             $newList['data'][]=$order;
         }

+ 52 - 0
public/assets/js/backend/goods_sku.js

@@ -0,0 +1,52 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'goods_sku/index' + location.search,
+                    add_url: 'goods_sku/add',
+                    edit_url: 'goods_sku/edit',
+                    del_url: 'goods_sku/del',
+                    multi_url: 'goods_sku/multi',
+                    import_url: 'goods_sku/import',
+                    table: 'goods_sku',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                searchFormVisible:false,
+                columns: [
+                    [
+                        {field: 'goods.name', title: __('商品'),operate: false,},
+                        {field: 'name', title: __('规格'),operate: false,},
+                        {field: 'fx_per', title: __('分销比例'),operate: false,},
+                        {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;
+});