正在显示
6 个修改的文件
包含
63 行增加
和
3 行删除
@@ -32,4 +32,46 @@ class SellerTalk extends Backend | @@ -32,4 +32,46 @@ class SellerTalk extends Backend | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | 34 | ||
35 | + /** | ||
36 | + * 查看 | ||
37 | + */ | ||
38 | + public function index() | ||
39 | + { | ||
40 | + //当前是否为关联查询 | ||
41 | + $this->relationSearch = true; | ||
42 | + //设置过滤方法 | ||
43 | + $this->request->filter(['strip_tags', 'trim']); | ||
44 | + if ($this->request->isAjax()) | ||
45 | + { | ||
46 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
47 | + if ($this->request->request('keyField')) | ||
48 | + { | ||
49 | + return $this->selectpage(); | ||
50 | + } | ||
51 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
52 | + $total = $this->model | ||
53 | + ->with(['user','seller']) | ||
54 | + ->where($where) | ||
55 | + ->order($sort, $order) | ||
56 | + ->count(); | ||
57 | + | ||
58 | + $list = $this->model | ||
59 | + ->with(['user','seller']) | ||
60 | + ->where($where) | ||
61 | + ->order($sort, $order) | ||
62 | + ->limit($offset, $limit) | ||
63 | + ->select(); | ||
64 | + | ||
65 | + foreach ($list as $row) { | ||
66 | + | ||
67 | + $row->getRelation('user')->visible(['avatar','nickname']); | ||
68 | + $row->getRelation('seller')->visible(['title','avatar']); | ||
69 | + } | ||
70 | + $list = collection($list)->toArray(); | ||
71 | + $result = array("total" => $total, "rows" => $list); | ||
72 | + | ||
73 | + return json($result); | ||
74 | + } | ||
75 | + return $this->view->fetch(); | ||
76 | + } | ||
35 | } | 77 | } |
@@ -7,5 +7,9 @@ return [ | @@ -7,5 +7,9 @@ return [ | ||
7 | 'Num' => '评分', | 7 | 'Num' => '评分', |
8 | 'Title' => '评论内容', | 8 | 'Title' => '评论内容', |
9 | 'Images' => '评论图', | 9 | 'Images' => '评论图', |
10 | - 'Createtime' => '创建时间' | 10 | + 'Createtime' => '创建时间', |
11 | + 'User.avatar' => '头像', | ||
12 | + 'User.nickname' => '微信名', | ||
13 | + 'Seller.title' => '店铺名', | ||
14 | + 'Seller.avatar' => '店铺头图' | ||
11 | ]; | 15 | ]; |
@@ -37,4 +37,14 @@ class SellerTalk extends Model | @@ -37,4 +37,14 @@ class SellerTalk extends Model | ||
37 | 37 | ||
38 | 38 | ||
39 | 39 | ||
40 | + public function user() | ||
41 | + { | ||
42 | + return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); | ||
43 | + } | ||
44 | + | ||
45 | + | ||
46 | + public function seller() | ||
47 | + { | ||
48 | + return $this->belongsTo('Seller', 'seller_id', 'id', [], 'LEFT')->setEagerlyType(0); | ||
49 | + } | ||
40 | } | 50 | } |
@@ -28,7 +28,7 @@ | @@ -28,7 +28,7 @@ | ||
28 | <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label> | 28 | <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label> |
29 | <div class="col-xs-12 col-sm-8"> | 29 | <div class="col-xs-12 col-sm-8"> |
30 | <div class="input-group"> | 30 | <div class="input-group"> |
31 | - <input id="c-images" data-rule="required" class="form-control" size="50" name="row[images]" type="text"> | 31 | + <input id="c-images" class="form-control" size="50" name="row[images]" type="text"> |
32 | <div class="input-group-addon no-border no-padding"> | 32 | <div class="input-group-addon no-border no-padding"> |
33 | <span><button type="button" id="plupload-images" class="btn btn-danger plupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> | 33 | <span><button type="button" id="plupload-images" class="btn btn-danger plupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> |
34 | <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span> | 34 | <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span> |
@@ -28,7 +28,7 @@ | @@ -28,7 +28,7 @@ | ||
28 | <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label> | 28 | <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label> |
29 | <div class="col-xs-12 col-sm-8"> | 29 | <div class="col-xs-12 col-sm-8"> |
30 | <div class="input-group"> | 30 | <div class="input-group"> |
31 | - <input id="c-images" data-rule="required" class="form-control" size="50" name="row[images]" type="text" value="{$row.images|htmlentities}"> | 31 | + <input id="c-images" class="form-control" size="50" name="row[images]" type="text" value="{$row.images|htmlentities}"> |
32 | <div class="input-group-addon no-border no-padding"> | 32 | <div class="input-group-addon no-border no-padding"> |
33 | <span><button type="button" id="plupload-images" class="btn btn-danger plupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> | 33 | <span><button type="button" id="plupload-images" class="btn btn-danger plupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> |
34 | <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span> | 34 | <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span> |
@@ -31,6 +31,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -31,6 +31,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
31 | {field: 'title', title: __('Title')}, | 31 | {field: 'title', title: __('Title')}, |
32 | {field: 'images', title: __('Images'), events: Table.api.events.image, formatter: Table.api.formatter.images}, | 32 | {field: 'images', title: __('Images'), events: Table.api.events.image, formatter: Table.api.formatter.images}, |
33 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, | 33 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, |
34 | + {field: 'user.avatar', title: __('User.avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image}, | ||
35 | + {field: 'user.nickname', title: __('User.nickname')}, | ||
36 | + {field: 'seller.title', title: __('Seller.title')}, | ||
37 | + {field: 'seller.avatar', title: __('Seller.avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image}, | ||
34 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 38 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
35 | ] | 39 | ] |
36 | ] | 40 | ] |
-
请 注册 或 登录 后发表评论