人员支持按公司检索,添加查看公司所有下属公司
This commit is contained in:
parent
520f4a5b34
commit
9fe14c3414
@ -16,7 +16,6 @@
|
|||||||
namespace app\adminapi\controller;
|
namespace app\adminapi\controller;
|
||||||
|
|
||||||
|
|
||||||
use app\adminapi\controller\BaseAdminController;
|
|
||||||
use app\adminapi\lists\CompanyLists;
|
use app\adminapi\lists\CompanyLists;
|
||||||
use app\adminapi\logic\CompanyLogic;
|
use app\adminapi\logic\CompanyLogic;
|
||||||
use app\adminapi\validate\CompanyValidate;
|
use app\adminapi\validate\CompanyValidate;
|
||||||
@ -25,7 +24,6 @@ use app\api\logic\SmsLogic;
|
|||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
use app\common\model\Company;
|
use app\common\model\Company;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use think\view\driver\Think;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Company控制器
|
* Company控制器
|
||||||
@ -256,4 +254,19 @@ class CompanyController extends BaseAdminController
|
|||||||
return $this->success('success', $users, 1, 1);
|
return $this->success('success', $users, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有成员公司
|
||||||
|
* @param $id
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function subordinate($id)
|
||||||
|
{
|
||||||
|
$company = Company::findOrEmpty($id);
|
||||||
|
$result = loopGetChild(Company::class, $company->id, 'level_one');
|
||||||
|
return $this->success('success', $result, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'%like%' => ['name', 'account'],
|
'%like%' => ['name', 'account'],
|
||||||
|
'=' => ['company_id']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,3 +444,24 @@ function get_config($key)
|
|||||||
{
|
{
|
||||||
return \think\facade\Config::get($key);
|
return \think\facade\Config::get($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 循环获取子级
|
||||||
|
* @param $model
|
||||||
|
* @param $id
|
||||||
|
* @param $parentKey
|
||||||
|
* @param $field
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function loopGetChild($model, $id, $parentKey = 'pid', $field = '*')
|
||||||
|
{
|
||||||
|
static $result = [];
|
||||||
|
$list = $model::where($parentKey, $id)->field($field)->select()->toArray();
|
||||||
|
if ($list) {
|
||||||
|
foreach ($list as $v) {
|
||||||
|
$result[] = $v;
|
||||||
|
loopGetChild($model, $v['id'], $parentKey, $field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user