作者 王晓刚
1 个管道 的构建 通过 耗费 36 秒

修改问题文档

@@ -111,41 +111,52 @@ class OrderDetail extends Backend @@ -111,41 +111,52 @@ class OrderDetail extends Backend
111 */ 111 */
112 public function send($ids = null) 112 public function send($ids = null)
113 { 113 {
114 - if($ids) {  
115 - $row = $this->model->get($ids);  
116 - if (!$row) {  
117 - $this->error(__('No Results were found')); 114 + $row = $this->model->get($ids);
  115 + if (!$row) {
  116 + $this->error(__('No Results were found'));
  117 + }
  118 + $adminIds = $this->getDataLimitAdminIds();
  119 + if (is_array($adminIds)) {
  120 + if (!in_array($row[$this->dataLimitField], $adminIds)) {
  121 + $this->error(__('You have no permission'));
118 } 122 }
119 - $adminIds = $this->getDataLimitAdminIds();  
120 - if (is_array($adminIds)) {  
121 - if (!in_array($row[$this->dataLimitField], $adminIds)) {  
122 - $this->error(__('You have no permission')); 123 + }
  124 + if ($this->request->isPost()) {
  125 + $params = $this->request->post("row/a");
  126 + if ($params) {
  127 + $params = $this->preExcludeFields($params);
  128 + $result = false;
  129 + Db::startTrans();
  130 + try {
  131 + //是否采用模型验证
  132 + if ($this->modelValidate) {
  133 + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
  134 + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
  135 + $row->validateFailException(true)->validate($validate);
  136 + }
  137 + $params['status'] = '3';
  138 + $result = $row->allowField(true)->save($params);
  139 + Db::commit();
  140 + } catch (ValidateException $e) {
  141 + Db::rollback();
  142 + $this->error($e->getMessage());
  143 + } catch (PDOException $e) {
  144 + Db::rollback();
  145 + $this->error($e->getMessage());
  146 + } catch (Exception $e) {
  147 + Db::rollback();
  148 + $this->error($e->getMessage());
  149 + }
  150 + if ($result !== false) {
  151 + $this->success();
  152 + } else {
  153 + $this->error(__('No rows were updated'));
123 } 154 }
124 } 155 }
125 - $params = $this->request->param();  
126 - if($row->status != 2) {  
127 - $this->error('当前状态无法执行发货操作');  
128 - }  
129 - $row->status = $params['status'];  
130 - Db::startTrans();  
131 - try {  
132 - $result = $row->save();  
133 - Db::commit();  
134 - } catch (ValidateException $e) {  
135 - Db::rollback();  
136 - $this->error($e->getMessage());  
137 - } catch (PDOException $e) {  
138 - Db::rollback();  
139 - $this->error($e->getMessage());  
140 - } catch (\think\Exception $e) {  
141 - Db::rollback();  
142 - $this->error($e->getMessage());  
143 - }  
144 - if(!$result) {  
145 - $this->error('发货失败');  
146 - }  
147 - $this->success('发货成功'); 156 + $this->error(__('Parameter %s can not be empty', ''));
148 } 157 }
  158 + $this->view->assign("row", $row);
  159 + return $this->view->fetch();
149 } 160 }
150 161
151 /** 162 /**
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 <div class="form-group layer-footer"> 34 <div class="form-group layer-footer">
35 <label class="control-label col-xs-12 col-sm-2"></label> 35 <label class="control-label col-xs-12 col-sm-2"></label>
36 <div class="col-xs-12 col-sm-8"> 36 <div class="col-xs-12 col-sm-8">
37 - <input type="text" name="row[order_detail_id]" value="{$order_detail_id}"/> 37 + <input type="hidden" name="row[order_detail_id]" value="{$order_detail_id}"/>
38 <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> 38 <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
39 <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> 39 <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
40 </div> 40 </div>
  1 +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 + <!--<div class="form-group">
  3 + <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
  4 + <div class="col-xs-12 col-sm-8">
  5 + <div class="radio">
  6 + {foreach name="statusList" item="vo"}
  7 + <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>
  8 + {/foreach}
  9 + </div>
  10 + </div>
  11 + </div>-->
  12 + <!--<div class="form-group">
  13 + <label class="control-label col-xs-12 col-sm-2">{:__('快递')}:</label>
  14 + <div class="col-xs-12 col-sm-10">
  15 + <dl class="fieldlist" data-template="kuaiditpl" data-name="row[order_freight]">
  16 + <dd>
  17 + <ins>{:__('快递公司')}</ins>
  18 + <ins>{:__('运单号')}</ins>
  19 + <ins>{:__('订单详情')}</ins>
  20 + </dd>
  21 + <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
  22 + &lt;!&ndash;请注意 dd和textarea间不能存在其它任何元素,实际开发中textarea应该添加个hidden进行隐藏&ndash;&gt;
  23 + <textarea name="row[order_freight]" class="form-control" cols="30" rows="5">{$row.order_freight}</textarea>
  24 + </dl>
  25 + <script id="kuaiditpl" type="text/html">
  26 + <dd class="form-inline">
  27 + <ins>
  28 + <input type="text" name="<%=name%>[<%=index%>][shipper_code]" class="form-control selectpage" data-pagination="true" data-order-by="id asc" data-source="kdniao/index" data-primary-key="code" data-field="company" value="<%if(row.shipper_code){%><%=row.shipper_code%><%}else{%>HTKY<%}%>" size="10"/>
  29 + </ins>
  30 + <ins>
  31 + <ins><input type="text" name="<%=name%>[<%=index%>][logistic_code]" class="form-control" value="<%=row.logistic_code%>" placeholder="请输入运单号"/></ins>
  32 + </ins>
  33 + <ins>
  34 + <input type="text" name="<%=name%>[<%=index%>][order_info_id]" class="form-control selectpage" data-pagination="true" data-order-by="id asc" data-source="order_info/index" data-params='{"custom[order_id]":"{$row.id}"}' data-primary-key="id" data-field="goods_no" value="<%=row.order_info_id%>" size="10"/>
  35 + </ins>
  36 + &lt;!&ndash;下面的两个按钮务必保留&ndash;&gt;
  37 + <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span>
  38 + <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
  39 + </dd>
  40 + </script>
  41 + </div>
  42 + </div>-->
  43 + <!--<div class="form-group">
  44 + <label class="control-label col-xs-12 col-sm-2">{:__('快递公司编码')}:</label>
  45 + <div class="col-xs-12 col-sm-8">
  46 + <input id="c-shipper_code" class="form-control selectpage" data-pagination="true" data-order-by="id asc" data-source="kdniao/index" data-primary-key="code" data-field="company" name="row[shipper_code]" type="text">
  47 + </div>
  48 + </div>-->
  49 + <div class="form-group">
  50 + <label class="control-label col-xs-12 col-sm-2">{:__('物流单号')}:</label>
  51 + <div class="col-xs-12 col-sm-8">
  52 + <input id="c-logistic_code" class="form-control" name="row[logistic_code]" type="text">
  53 + </div>
  54 + </div>
  55 + <div class="form-group layer-footer">
  56 + <label class="control-label col-xs-12 col-sm-2"></label>
  57 + <div class="col-xs-12 col-sm-8">
  58 + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
  59 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  60 + </div>
  61 + </div>
  62 +</form>
@@ -41,6 +41,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -41,6 +41,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
41 {field: 'city_name', title: __('City_name')}, 41 {field: 'city_name', title: __('City_name')},
42 {field: 'county_name', title: __('County_name')}, 42 {field: 'county_name', title: __('County_name')},
43 {field: 'address', title: __('Address')}, 43 {field: 'address', title: __('Address')},
  44 + {field: 'logistic_code', title: __('运单号')},
44 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 45 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
45 {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 46 {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
46 {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"6":__('Status 6'),"7":__('Status 7'),"8":__('Status 8'),"9":__('Status 9'),"10":__('Status 10'),"11":__('Status 11')}, formatter: Table.api.formatter.status}, 47 {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"6":__('Status 6'),"7":__('Status 7'),"8":__('Status 8'),"9":__('Status 9'),"10":__('Status 10'),"11":__('Status 11')}, formatter: Table.api.formatter.status},
@@ -68,9 +69,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -68,9 +69,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
68 name: 'send', 69 name: 'send',
69 text: __('发货'), 70 text: __('发货'),
70 title: __('发货'), 71 title: __('发货'),
71 - classname: 'btn btn-xs btn-info btn-ajax', 72 + classname: 'btn btn-xs btn-info btn-dialog',
72 icon: '', 73 icon: '',
73 - url: $.fn.bootstrapTable.defaults.extend.send_url + '/status/3', 74 + url: $.fn.bootstrapTable.defaults.extend.send_url,
74 confirm: '是否确认通过已发货?', 75 confirm: '是否确认通过已发货?',
75 hidden:function(row){ 76 hidden:function(row){
76 if(row.status != 2){ 77 if(row.status != 2){
@@ -175,6 +176,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -175,6 +176,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
175 init(); 176 init();
176 }) 177 })
177 }, 178 },
  179 + send:function(){
  180 + Controller.api.bindevent();
  181 + },
178 api: { 182 api: {
179 bindevent: function () { 183 bindevent: function () {
180 Form.api.bindevent($("form[role=form]")); 184 Form.api.bindevent($("form[role=form]"));