作者 王智

daima

@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 namespace app\admin\controller; 3 namespace app\admin\controller;
4 4
5 -use think\Db;  
6 use app\common\controller\Backend; 5 use app\common\controller\Backend;
7 6
8 /** 7 /**
@@ -44,20 +43,22 @@ class Renwu extends Backend @@ -44,20 +43,22 @@ class Renwu extends Backend
44 $this->relationSearch = true; 43 $this->relationSearch = true;
45 //设置过滤方法 44 //设置过滤方法
46 $this->request->filter(['strip_tags', 'trim']); 45 $this->request->filter(['strip_tags', 'trim']);
47 - if ($this->request->isAjax()) { 46 + if ($this->request->isAjax())
  47 + {
48 //如果发送的来源是Selectpage,则转发到Selectpage 48 //如果发送的来源是Selectpage,则转发到Selectpage
49 - if ($this->request->request('keyField')) { 49 + if ($this->request->request('keyField'))
  50 + {
50 return $this->selectpage(); 51 return $this->selectpage();
51 } 52 }
52 list($where, $sort, $order, $offset, $limit) = $this->buildparams(); 53 list($where, $sort, $order, $offset, $limit) = $this->buildparams();
53 $total = $this->model 54 $total = $this->model
54 - ->with(['user', 'vip']) 55 + ->with(['user','vip'])
55 ->where($where) 56 ->where($where)
56 ->order($sort, $order) 57 ->order($sort, $order)
57 ->count(); 58 ->count();
58 59
59 $list = $this->model 60 $list = $this->model
60 - ->with(['user', 'vip']) 61 + ->with(['user','vip'])
61 ->where($where) 62 ->where($where)
62 ->order($sort, $order) 63 ->order($sort, $order)
63 ->limit($offset, $limit) 64 ->limit($offset, $limit)
@@ -65,7 +66,7 @@ class Renwu extends Backend @@ -65,7 +66,7 @@ class Renwu extends Backend
65 66
66 foreach ($list as $row) { 67 foreach ($list as $row) {
67 68
68 - $row->getRelation('user')->visible(['nickname', 'mobile', 'address', 'address_con', 'car_num', 'color', 'car_type', 'vip']); 69 + $row->getRelation('user')->visible(['nickname','mobile','address','address_con','car_num','color','car_type','vip']);
69 $row->getRelation('vip')->visible(['title']); 70 $row->getRelation('vip')->visible(['title']);
70 } 71 }
71 $list = collection($list)->toArray(); 72 $list = collection($list)->toArray();
@@ -75,59 +76,4 @@ class Renwu extends Backend @@ -75,59 +76,4 @@ class Renwu extends Backend
75 } 76 }
76 return $this->view->fetch(); 77 return $this->view->fetch();
77 } 78 }
78 -  
79 -  
80 - /**  
81 - * 编辑  
82 - */  
83 - public function edit($ids = null)  
84 - {  
85 - $row = $this->model->get($ids);  
86 -// dump($row);  
87 -// die;  
88 - if (!$row) {  
89 - $this->error(__('No Results were found'));  
90 - }  
91 - $adminIds = $this->getDataLimitAdminIds();  
92 - if (is_array($adminIds)) {  
93 - if (!in_array($row[$this->dataLimitField], $adminIds)) {  
94 - $this->error(__('You have no permission'));  
95 - }  
96 - }  
97 - if ($this->request->isPost()) {  
98 - $params = $this->request->post("row/a");  
99 - if ($params) {  
100 - $params = $this->preExcludeFields($params);  
101 - $result = false;  
102 - Db::startTrans();  
103 - try {  
104 - //是否采用模型验证  
105 - if ($this->modelValidate) {  
106 - $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));  
107 - $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;  
108 - $row->validateFailException(true)->validate($validate);  
109 - }  
110 - $result = $row->allowField(true)->save($params);  
111 - Db::commit();  
112 - } catch (ValidateException $e) {  
113 - Db::rollback();  
114 - $this->error($e->getMessage());  
115 - } catch (PDOException $e) {  
116 - Db::rollback();  
117 - $this->error($e->getMessage());  
118 - } catch (Exception $e) {  
119 - Db::rollback();  
120 - $this->error($e->getMessage());  
121 - }  
122 - if ($result !== false) {  
123 - $this->success();  
124 - } else {  
125 - $this->error(__('No rows were updated'));  
126 - }  
127 - }  
128 - $this->error(__('Parameter %s can not be empty', ''));  
129 - }  
130 - $this->view->assign("row", $row);  
131 - return $this->view->fetch();  
132 - }  
133 } 79 }
@@ -27,8 +27,7 @@ @@ -27,8 +27,7 @@
27 27
28 <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]">
29 {foreach name="typeList" item="vo"} 29 {foreach name="typeList" item="vo"}
30 - <option value="{$key}" {in name="key" value="$row.type" }selected{  
31 - /in}>{$vo}</option> 30 + <option value="{$key}" {in name="key" value="$row.type" }selected{/in}>{$vo}</option>
32 {/foreach} 31 {/foreach}
33 </select> 32 </select>
34 33
@@ -48,8 +47,7 @@ @@ -48,8 +47,7 @@
48 47
49 <select id="c-xi_type" class="form-control selectpicker" name="row[xi_type]"> 48 <select id="c-xi_type" class="form-control selectpicker" name="row[xi_type]">
50 {foreach name="xiTypeList" item="vo"} 49 {foreach name="xiTypeList" item="vo"}
51 - <option value="{$key}" {in name="key" value="$row.xi_type" }selected{  
52 - /in}>{$vo}</option> 50 + <option value="{$key}" {in name="key" value="$row.xi_type" }selected{/in}>{$vo}</option>
53 {/foreach} 51 {/foreach}
54 </select> 52 </select>
55 53
@@ -89,8 +87,7 @@ @@ -89,8 +87,7 @@
89 87
90 <select id="c-zhao_type" class="form-control selectpicker" name="row[zhao_type]"> 88 <select id="c-zhao_type" class="form-control selectpicker" name="row[zhao_type]">
91 {foreach name="zhaoTypeList" item="vo"} 89 {foreach name="zhaoTypeList" item="vo"}
92 - <option value="{$key}" {in name="key" value="$row.zhao_type" }selected{  
93 - /in}>{$vo}</option> 90 + <option value="{$key}" {in name="key" value="$row.zhao_type" }selected{/in}>{$vo}</option>
94 {/foreach} 91 {/foreach}
95 </select> 92 </select>
96 93