修改基础管理中的基础内容
This commit is contained in:
@@ -51,14 +51,15 @@ class Firmstoreprojectsone extends Backend
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
$list = $this->model
|
||||
|
||||
->with(['firm'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
foreach ($list as $row) {
|
||||
$row->visible(['id','name']);
|
||||
|
||||
$row->visible(['firm']);
|
||||
$row->getRelation('firm')->visible(['full_name']);
|
||||
}
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 店铺二级项目
|
||||
@@ -51,7 +52,7 @@ class Firmstoreprojectstwo extends Backend
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
$list = $this->model
|
||||
->with(['firmstoreprojectsone'])
|
||||
->with(['firmstoreprojectsone','firm'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
@@ -60,6 +61,8 @@ class Firmstoreprojectstwo extends Backend
|
||||
$row->visible(['id','name']);
|
||||
$row->visible(['firmstoreprojectsone']);
|
||||
$row->getRelation('firmstoreprojectsone')->visible(['name']);
|
||||
$row->visible(['firm']);
|
||||
$row->getRelation('firm')->visible(['full_name']);
|
||||
}
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
@@ -68,5 +71,47 @@ class Firmstoreprojectstwo extends Backend
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function add()
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$ids = input('ids');
|
||||
$oneData['id'] = 0;
|
||||
$oneData['firm_id'] = 0;
|
||||
$oneData['firmstore_id'] = 0;
|
||||
if (!empty($ids)){
|
||||
$oneData = Db::table('fa_firmstoreprojectsone')->where('id',$ids)->find();
|
||||
}
|
||||
$this->view->assign('oneData', $oneData);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
$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 . '.add' : $name) : $this->modelValidate;
|
||||
$this->model->validateFailException()->validate($validate);
|
||||
}
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException|PDOException|Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result === false) {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user