作者 何书鹏
1 个管道 的构建 通过 耗费 4 秒

api更新

... ... @@ -3,6 +3,10 @@
namespace app\admin\controller;
use app\common\controller\Backend;
use Exception;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 医生管理
... ... @@ -72,4 +76,66 @@ class Doctor extends Backend
return $this->view->fetch();
}
/**
* 审核
*/
public function examine($ids = null)
{
$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'));
}
}
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
if($params['status'] == 1) {
if($row->status == 1) {
$this->error('该售后申请已通过审核');
}
}
if($params['status'] == 2) {
if($row->status == 2) {
$this->error('该售后申请已驳回审核');
}
}
$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);
}
$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'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("row", $row);
return $this->view->fetch();
}
}
... ...
<form id="add-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"}
{neq name="key" value="0"}
<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>
{/neq}
{/foreach}
</div>
</div>
</div>
<div class="form-group reject_reason hide">
<label class="control-label col-xs-12 col-sm-2">{:__('拒绝原因')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-reject_reason" class="form-control" rows="5" name="row[reject_reason]" cols="50">{$row.reject_reason|htmlentities}</textarea>
</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>
... ...
... ... @@ -121,7 +121,7 @@ class User extends Api
* @ApiParams (name=iv, type=string, required=true, description="iv")
* @ApiParams (name=encryptedData, type=string, required=true, description="encryptedData")
* @ApiParams (name=openid, type=string, required=true, description="openid")
* @ApiParams (name=unionid, type=string, required=true, description="unionid")
* @ApiParams (name=unionid, type=string, required=false, description="unionid")
* @ApiReturn({
"code": 1,
"msg": "Logged in successful",
... ...
此 diff 太大无法显示。
... ... @@ -46,7 +46,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
Controller.api.bindevent();
setTimeout(function(){
$("select[name='row[type]']").trigger("change");
},100)
},100);
},
api: {
bindevent: function () {
... ...
... ... @@ -11,6 +11,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
del_url: 'doctor/del',
multi_url: 'doctor/multi',
import_url: 'doctor/import',
examine_url: 'doctor/examine',
table: 'doctor',
}
});
... ... @@ -39,7 +40,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'total_receive_num', title: __('Total_receive_num')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'doctorlevel.level', title: __('Doctorlevel.level')},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [
{
name: 'examine',
text: '审核',
title: '审核',
classname: 'btn btn-xs btn-primary btn-dialog',
icon: '',
url: $.fn.bootstrapTable.defaults.extend.examine_url,
// visible:function (row) {
// if(row.status == 0){
// return true;
// }
// },
},
], formatter: Table.api.formatter.operate
}
]
]
});
... ... @@ -53,6 +70,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
edit: function () {
Controller.api.bindevent();
},
examine: function () {
Controller.api.bindevent();
setTimeout(function(){
$("input[name='row[status]']").trigger("change");
},100);
$(document).on("change","input[name='row[status]']",function(){
var status = $(this).val();
if(status == '1'){
$('.reject_reason').addClass('hide');
}else{
$('.reject_reason').removeClass('hide');
}
})
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
... ...