Commit 0a549ae7 authored by hujun's avatar hujun

部门名编辑

parent 12b3e817
...@@ -53,12 +53,19 @@ class District extends Basic ...@@ -53,12 +53,19 @@ class District extends Basic
* 添加部门,绑定总监关系 * 添加部门,绑定总监关系
* *
* @return \think\Response * @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function addDistrict () { public function addDistrict () {
if ($this->params['department_name'] || $this->params['agents_id']) { if ($this->params['department_name'] || $this->params['agents_id']) {
$district = new ADistrict(); $district = new ADistrict();
$this->data = $district->addDepartmentAgents($this->params, $this->params['agents_id']); if ($this->request->isPost()) {
$this->data = $district->addDepartmentAgents($this->params, $this->params['agents_id']);
} else {
$this->data = $district->getDistrictById($this->params['id']);
}
} else { } else {
$this->code = 101; $this->code = 101;
$this->msg = 'department or district is null'; $this->msg = 'department or district is null';
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
namespace app\model; namespace app\model;
use think\Db;
class ADistrict extends BaseModel class ADistrict extends BaseModel
{ {
/** /**
...@@ -56,4 +58,26 @@ class ADistrict extends BaseModel ...@@ -56,4 +58,26 @@ class ADistrict extends BaseModel
return $resutlt; return $resutlt;
} }
/**
* 获取部门名和总监
*
* @param $id
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDistrictById($id) {
if ($id) {
$data['district_name'] = $this->where('id',$id)->value('district_name');
$agents = Db::table('a_agents')->field('name,phone')
->where(['status'=>0,'level'=>['in',['30,40']]])->find();
$data['name'] = $agents['name'].'-'.$agents['phone'];
} else {
$data = false;
}
return $data;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment