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

修改问题文档

... ... @@ -111,41 +111,52 @@ class OrderDetail extends Backend
*/
public function send($ids = null)
{
if($ids) {
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException(true)->validate($validate);
}
$params['status'] = '3';
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
}
$params = $this->request->param();
if($row->status != 2) {
$this->error('当前状态无法执行发货操作');
}
$row->status = $params['status'];
Db::startTrans();
try {
$result = $row->save();
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (\think\Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(!$result) {
$this->error('发货失败');
}
$this->success('发货成功');
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("row", $row);
return $this->view->fetch();
}
/**
... ...
... ... @@ -34,7 +34,7 @@
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<input type="text" name="row[order_detail_id]" value="{$order_detail_id}"/>
<input type="hidden" name="row[order_detail_id]" value="{$order_detail_id}"/>
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<!--<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<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>
{/foreach}
</div>
</div>
</div>-->
<!--<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('快递')}:</label>
<div class="col-xs-12 col-sm-10">
<dl class="fieldlist" data-template="kuaiditpl" data-name="row[order_freight]">
<dd>
<ins>{:__('快递公司')}</ins>
<ins>{:__('运单号')}</ins>
<ins>{:__('订单详情')}</ins>
</dd>
<dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
&lt;!&ndash;请注意 dd和textarea间不能存在其它任何元素,实际开发中textarea应该添加个hidden进行隐藏&ndash;&gt;
<textarea name="row[order_freight]" class="form-control" cols="30" rows="5">{$row.order_freight}</textarea>
</dl>
<script id="kuaiditpl" type="text/html">
<dd class="form-inline">
<ins>
<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"/>
</ins>
<ins>
<ins><input type="text" name="<%=name%>[<%=index%>][logistic_code]" class="form-control" value="<%=row.logistic_code%>" placeholder="请输入运单号"/></ins>
</ins>
<ins>
<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"/>
</ins>
&lt;!&ndash;下面的两个按钮务必保留&ndash;&gt;
<span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span>
<span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
</dd>
</script>
</div>
</div>-->
<!--<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('快递公司编码')}:</label>
<div class="col-xs-12 col-sm-8">
<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">
</div>
</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('物流单号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-logistic_code" class="form-control" name="row[logistic_code]" type="text">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
... ... @@ -41,6 +41,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'city_name', title: __('City_name')},
{field: 'county_name', title: __('County_name')},
{field: 'address', title: __('Address')},
{field: 'logistic_code', title: __('运单号')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{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
name: 'send',
text: __('发货'),
title: __('发货'),
classname: 'btn btn-xs btn-info btn-ajax',
classname: 'btn btn-xs btn-info btn-dialog',
icon: '',
url: $.fn.bootstrapTable.defaults.extend.send_url + '/status/3',
url: $.fn.bootstrapTable.defaults.extend.send_url,
confirm: '是否确认通过已发货?',
hidden:function(row){
if(row.status != 2){
... ... @@ -175,6 +176,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
init();
})
},
send:function(){
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
... ...