作者 王智

daima

@@ -39,34 +39,44 @@ class Renwu extends Backend @@ -39,34 +39,44 @@ class Renwu extends Backend
39 */ 39 */
40 public function index() 40 public function index()
41 { 41 {
  42 + $pid = input('pid');
42 //当前是否为关联查询 43 //当前是否为关联查询
43 $this->relationSearch = true; 44 $this->relationSearch = true;
44 //设置过滤方法 45 //设置过滤方法
45 $this->request->filter(['strip_tags', 'trim']); 46 $this->request->filter(['strip_tags', 'trim']);
46 - if ($this->request->isAjax())  
47 - { 47 + if ($this->request->isAjax()) {
  48 + list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  49 + if (empty($pid)) {
48 //如果发送的来源是Selectpage,则转发到Selectpage 50 //如果发送的来源是Selectpage,则转发到Selectpage
49 - if ($this->request->request('keyField'))  
50 - { 51 + if ($this->request->request('keyField')) {
51 return $this->selectpage(); 52 return $this->selectpage();
52 } 53 }
53 - list($where, $sort, $order, $offset, $limit) = $this->buildparams(); 54 + }
  55 + $map = [];
  56 + if ($pid == 1) {
  57 + $map['type'] = ['eq', 3];
  58 + }
  59 + if ($pid == 2) {
  60 + $map['type'] = ['eq', 2];
  61 + }
54 $total = $this->model 62 $total = $this->model
55 - ->with(['user','vip']) 63 + ->with(['user', 'vip'])
56 ->where($where) 64 ->where($where)
57 ->order($sort, $order) 65 ->order($sort, $order)
  66 + ->where($map)
58 ->count(); 67 ->count();
59 68
60 $list = $this->model 69 $list = $this->model
61 - ->with(['user','vip']) 70 + ->with(['user', 'vip'])
62 ->where($where) 71 ->where($where)
63 ->order($sort, $order) 72 ->order($sort, $order)
64 ->limit($offset, $limit) 73 ->limit($offset, $limit)
  74 + ->where($map)
65 ->select(); 75 ->select();
66 76
67 foreach ($list as $row) { 77 foreach ($list as $row) {
68 78
69 - $row->getRelation('user')->visible(['nickname','mobile','address','address_con','car_num','color','car_type','vip']); 79 + $row->getRelation('user')->visible(['nickname', 'mobile', 'address', 'address_con', 'car_num', 'color', 'car_type', 'vip']);
70 $row->getRelation('vip')->visible(['title']); 80 $row->getRelation('vip')->visible(['title']);
71 } 81 }
72 $list = collection($list)->toArray(); 82 $list = collection($list)->toArray();
@@ -3,19 +3,22 @@ @@ -3,19 +3,22 @@
3 <div class="form-group"> 3 <div class="form-group">
4 <label class="control-label col-xs-12 col-sm-2">{:__('Order_sn')}:</label> 4 <label class="control-label col-xs-12 col-sm-2">{:__('Order_sn')}:</label>
5 <div class="col-xs-12 col-sm-8"> 5 <div class="col-xs-12 col-sm-8">
6 - <input id="c-order_sn" data-rule="required" class="form-control" name="row[order_sn]" type="text" value="{$row.order_sn|htmlentities}"> 6 + <input id="c-order_sn" data-rule="required" class="form-control" name="row[order_sn]" type="text"
  7 + value="{$row.order_sn|htmlentities}">
7 </div> 8 </div>
8 </div> 9 </div>
9 <div class="form-group"> 10 <div class="form-group">
10 <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label> 11 <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
11 <div class="col-xs-12 col-sm-8"> 12 <div class="col-xs-12 col-sm-8">
12 - <input id="c-user_id" data-rule="" data-source="user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}"> 13 + <input id="c-user_id" data-rule="" data-source="user/index" data-field="nickname"
  14 + class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
13 </div> 15 </div>
14 </div> 16 </div>
15 <div class="form-group"> 17 <div class="form-group">
16 <label class="control-label col-xs-12 col-sm-2">{:__('Vip_id')}:</label> 18 <label class="control-label col-xs-12 col-sm-2">{:__('Vip_id')}:</label>
17 <div class="col-xs-12 col-sm-8"> 19 <div class="col-xs-12 col-sm-8">
18 - <input id="c-vip_id" data-rule="" data-source="vip/index" data-field="title" class="form-control selectpage" name="row[vip_id]" type="text" value="{$row.vip_id|htmlentities}"> 20 + <input id="c-vip_id" data-rule="" data-source="vip/index" data-field="title" class="form-control selectpage"
  21 + name="row[vip_id]" type="text" value="{$row.vip_id|htmlentities}">
19 </div> 22 </div>
20 </div> 23 </div>
21 <div class="form-group"> 24 <div class="form-group">
@@ -24,7 +27,8 @@ @@ -24,7 +27,8 @@
24 27
25 <select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]"> 28 <select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
26 {foreach name="typeList" item="vo"} 29 {foreach name="typeList" item="vo"}
27 - <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option> 30 + <option value="{$key}" {in name="key" value="$row.type" }selected{
  31 + /in}>{$vo}</option>
28 {/foreach} 32 {/foreach}
29 </select> 33 </select>
30 34
@@ -33,7 +37,9 @@ @@ -33,7 +37,9 @@
33 <div class="form-group"> 37 <div class="form-group">
34 <label class="control-label col-xs-12 col-sm-2">{:__('Xi_id')}:</label> 38 <label class="control-label col-xs-12 col-sm-2">{:__('Xi_id')}:</label>
35 <div class="col-xs-12 col-sm-8"> 39 <div class="col-xs-12 col-sm-8">
36 - <input id="c-xi_id" data-rule="" data-source="user/index" data-field="nickname" class="form-control selectpage" name="row[xi_id]" type="text" value="{$row.xi_id|htmlentities}"> 40 + <input id="c-xi_id" data-rule="" data-source="user/index" data-field="nickname"
  41 + class="form-control selectpage" name="row[xi_id]" type="text" value="{$row.xi_id|htmlentities}"
  42 + onchange="set_next_input(this);">
37 </div> 43 </div>
38 </div> 44 </div>
39 <div class="form-group"> 45 <div class="form-group">
@@ -42,7 +48,8 @@ @@ -42,7 +48,8 @@
42 48
43 <select id="c-xi_type" class="form-control selectpicker" name="row[xi_type]"> 49 <select id="c-xi_type" class="form-control selectpicker" name="row[xi_type]">
44 {foreach name="xiTypeList" item="vo"} 50 {foreach name="xiTypeList" item="vo"}
45 - <option value="{$key}" {in name="key" value="$row.xi_type"}selected{/in}>{$vo}</option> 51 + <option value="{$key}" {in name="key" value="$row.xi_type" }selected{
  52 + /in}>{$vo}</option>
46 {/foreach} 53 {/foreach}
47 </select> 54 </select>
48 55
@@ -52,10 +59,16 @@ @@ -52,10 +59,16 @@
52 <label class="control-label col-xs-12 col-sm-2">{:__('Xi_images')}:</label> 59 <label class="control-label col-xs-12 col-sm-2">{:__('Xi_images')}:</label>
53 <div class="col-xs-12 col-sm-8"> 60 <div class="col-xs-12 col-sm-8">
54 <div class="input-group"> 61 <div class="input-group">
55 - <input id="c-xi_images" class="form-control" size="50" name="row[xi_images]" type="text" value="{$row.xi_images|htmlentities}"> 62 + <input id="c-xi_images" class="form-control" size="50" name="row[xi_images]" type="text"
  63 + value="{$row.xi_images|htmlentities}">
56 <div class="input-group-addon no-border no-padding"> 64 <div class="input-group-addon no-border no-padding">
57 - <span><button type="button" id="plupload-xi_images" class="btn btn-danger plupload" data-input-id="c-xi_images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-xi_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>  
58 - <span><button type="button" id="fachoose-xi_images" class="btn btn-primary fachoose" data-input-id="c-xi_images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span> 65 + <span><button type="button" id="plupload-xi_images" class="btn btn-danger plupload"
  66 + data-input-id="c-xi_images"
  67 + data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp"
  68 + data-multiple="true" data-preview-id="p-xi_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  69 + <span><button type="button" id="fachoose-xi_images" class="btn btn-primary fachoose"
  70 + data-input-id="c-xi_images" data-mimetype="image/*" data-multiple="true"><i
  71 + class="fa fa-list"></i> {:__('Choose')}</button></span>
59 </div> 72 </div>
60 <span class="msg-box n-right" for="c-xi_images"></span> 73 <span class="msg-box n-right" for="c-xi_images"></span>
61 </div> 74 </div>
@@ -65,7 +78,9 @@ @@ -65,7 +78,9 @@
65 <div class="form-group"> 78 <div class="form-group">
66 <label class="control-label col-xs-12 col-sm-2">{:__('Zhao_id')}:</label> 79 <label class="control-label col-xs-12 col-sm-2">{:__('Zhao_id')}:</label>
67 <div class="col-xs-12 col-sm-8"> 80 <div class="col-xs-12 col-sm-8">
68 - <input id="c-zhao_id" data-rule="" data-source="user/index" data-field="nickname" class="form-control selectpage" name="row[zhao_id]" type="text" value="{$row.zhao_id|htmlentities}"> 81 + <input id="c-zhao_id" data-rule="" data-source="user/index" data-field="nickname"
  82 + class="form-control selectpage" name="row[zhao_id]" type="text" value="{$row.zhao_id|htmlentities}"
  83 + onchange="set_next_input2(this);">
69 </div> 84 </div>
70 </div> 85 </div>
71 <div class="form-group"> 86 <div class="form-group">
@@ -74,7 +89,8 @@ @@ -74,7 +89,8 @@
74 89
75 <select id="c-zhao_type" class="form-control selectpicker" name="row[zhao_type]"> 90 <select id="c-zhao_type" class="form-control selectpicker" name="row[zhao_type]">
76 {foreach name="zhaoTypeList" item="vo"} 91 {foreach name="zhaoTypeList" item="vo"}
77 - <option value="{$key}" {in name="key" value="$row.zhao_type"}selected{/in}>{$vo}</option> 92 + <option value="{$key}" {in name="key" value="$row.zhao_type" }selected{
  93 + /in}>{$vo}</option>
78 {/foreach} 94 {/foreach}
79 </select> 95 </select>
80 96
@@ -84,10 +100,16 @@ @@ -84,10 +100,16 @@
84 <label class="control-label col-xs-12 col-sm-2">{:__('Zhao_images')}:</label> 100 <label class="control-label col-xs-12 col-sm-2">{:__('Zhao_images')}:</label>
85 <div class="col-xs-12 col-sm-8"> 101 <div class="col-xs-12 col-sm-8">
86 <div class="input-group"> 102 <div class="input-group">
87 - <input id="c-zhao_images" class="form-control" size="50" name="row[zhao_images]" type="text" value="{$row.zhao_images|htmlentities}"> 103 + <input id="c-zhao_images" class="form-control" size="50" name="row[zhao_images]" type="text"
  104 + value="{$row.zhao_images|htmlentities}">
88 <div class="input-group-addon no-border no-padding"> 105 <div class="input-group-addon no-border no-padding">
89 - <span><button type="button" id="plupload-zhao_images" class="btn btn-danger plupload" data-input-id="c-zhao_images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-zhao_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>  
90 - <span><button type="button" id="fachoose-zhao_images" class="btn btn-primary fachoose" data-input-id="c-zhao_images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span> 106 + <span><button type="button" id="plupload-zhao_images" class="btn btn-danger plupload"
  107 + data-input-id="c-zhao_images"
  108 + data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp"
  109 + data-multiple="true" data-preview-id="p-zhao_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  110 + <span><button type="button" id="fachoose-zhao_images" class="btn btn-primary fachoose"
  111 + data-input-id="c-zhao_images" data-mimetype="image/*" data-multiple="true"><i
  112 + class="fa fa-list"></i> {:__('Choose')}</button></span>
91 </div> 113 </div>
92 <span class="msg-box n-right" for="c-zhao_images"></span> 114 <span class="msg-box n-right" for="c-zhao_images"></span>
93 </div> 115 </div>
@@ -97,7 +119,8 @@ @@ -97,7 +119,8 @@
97 <div class="form-group"> 119 <div class="form-group">
98 <label class="control-label col-xs-12 col-sm-2">{:__('Car_address')}:</label> 120 <label class="control-label col-xs-12 col-sm-2">{:__('Car_address')}:</label>
99 <div class="col-xs-12 col-sm-8"> 121 <div class="col-xs-12 col-sm-8">
100 - <input id="c-car_address" class="form-control" name="row[car_address]" type="text" value="{$row.car_address|htmlentities}"> 122 + <input id="c-car_address" class="form-control" name="row[car_address]" type="text"
  123 + value="{$row.car_address|htmlentities}">
101 </div> 124 </div>
102 </div> 125 </div>
103 <div class="form-group"> 126 <div class="form-group">
@@ -115,13 +138,17 @@ @@ -115,13 +138,17 @@
115 <div class="form-group"> 138 <div class="form-group">
116 <label class="control-label col-xs-12 col-sm-2">{:__('Startime')}:</label> 139 <label class="control-label col-xs-12 col-sm-2">{:__('Startime')}:</label>
117 <div class="col-xs-12 col-sm-8"> 140 <div class="col-xs-12 col-sm-8">
118 - <input id="c-startime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[startime]" type="text" value="{:$row.startime?datetime($row.startime):''}"> 141 + <input id="c-startime" data-rule="required" class="form-control datetimepicker"
  142 + data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[startime]" type="text"
  143 + value="{:$row.startime?datetime($row.startime):''}">
119 </div> 144 </div>
120 </div> 145 </div>
121 <div class="form-group"> 146 <div class="form-group">
122 <label class="control-label col-xs-12 col-sm-2">{:__('Endtime')}:</label> 147 <label class="control-label col-xs-12 col-sm-2">{:__('Endtime')}:</label>
123 <div class="col-xs-12 col-sm-8"> 148 <div class="col-xs-12 col-sm-8">
124 - <input id="c-endtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[endtime]" type="text" value="{:$row.endtime?datetime($row.endtime):''}"> 149 + <input id="c-endtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss"
  150 + data-use-current="true" name="row[endtime]" type="text"
  151 + value="{:$row.endtime?datetime($row.endtime):''}">
125 </div> 152 </div>
126 </div> 153 </div>
127 <div class="form-group layer-footer"> 154 <div class="form-group layer-footer">
@@ -132,3 +159,18 @@ @@ -132,3 +159,18 @@
132 </div> 159 </div>
133 </div> 160 </div>
134 </form> 161 </form>
  162 +<script src="http://code.jquery.com/jquery-latest.js"></script>
  163 +<script>
  164 +
  165 + function set_next_input(obj) {
  166 + //改变下面这个框的数据源
  167 + $("#c-xi_id_text").data("selectPageObject").option.data = 'Renwu/index?pid=1';
  168 + }
  169 +
  170 + function set_next_input2(obj) {
  171 + //改变下面这个框的数据源
  172 + $("#c-zhao_id_id_text").data("selectPageObject").option.data = 'Renwu/index?pid=2';
  173 +
  174 + }
  175 +</script>
  176 +