This commit is contained in:
weiz 2024-05-25 11:38:28 +08:00
parent 76d97aa53a
commit d7c71c15d3
5 changed files with 29 additions and 12 deletions

View File

@ -4,6 +4,7 @@
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\dept\Orgs;
@ -38,13 +39,14 @@
$this->where[] = ['org_id','in',$orgs];
}
return Dept::where($this->searchWhere)->where($this->where)
->field('id,name,org_id,mobile,status,sort,create_time')
->limit($this->limitOffset, $this->limitLength)
->order(['sort' => 'desc', 'id' => 'desc'])
->select()->each(function($item){
$org = Orgs::where('id',$item['org_id'])->findOrEmpty();
$item['org_name'] = $org->isEmpty() ? '' : $org['name'];
$item['status_text'] = $item->status_text;
$admin = Admin::field('name')->where('id',$item['leader_id'])->findOrEmpty();
$item['leader_name'] = !$admin->isEmpty() ? $admin['name'] : '';
return $item;
})
->toArray();

View File

@ -43,7 +43,8 @@ class DeptLogic extends BaseLogic
'name' => $params['name'],
'mobile' => $params['mobile'] ?? '',
'status' => $params['status'],
'sort' => $params['sort'] ?? 0
'sort' => $params['sort'] ?? 0,
'leader_id' => $params['leader_id'] ?? 0,
]);
}
@ -64,7 +65,8 @@ class DeptLogic extends BaseLogic
'name' => $params['name'],
'mobile' => $params['mobile'] ?? '',
'status' => $params['status'],
'sort' => $params['sort'] ?? 0
'sort' => $params['sort'] ?? 0,
'leader_id' => $params['leader_id'] ?? 0,
]);
return true;
} catch (\Exception $e) {
@ -100,13 +102,12 @@ class DeptLogic extends BaseLogic
*/
public static function detail($params): array
{
$data = Dept::field('id,name,org_id,mobile,status,sort,create_time')->where('id',$params['id'])->findOrEmpty();
if($data->isEmpty()){
return [];
}
$data = Dept::where('id',$params['id'])->findOrEmpty();
$org = Orgs::where('id',$data['org_id'])->findOrEmpty();
$data['org_name'] = $org->isEmpty() ? '' : $org['name'];
$data['status_text'] = $data->status_text;
$admin = Admin::field('name')->where('id',$data['leader_id'])->findOrEmpty();
$data['leader_name'] = !$admin->isEmpty() ? $admin['name'] : '';
return $data->toArray();
}

View File

@ -44,13 +44,20 @@ class OaFlowLogic extends BaseLogic
if($params['check_type'] == 3){
$flow_list = $params['flow_list'];
foreach($flow_list as &$v){
$v['flow_type'] = 5;
$v['flow_type'] = 4;
}
$params['flow_list'] = $flow_list;
}
if($params['check_type'] == 2){
$params['flow_list'] = '';
}
if($params['check_type'] == 1){
$flow_list = $params['flow_list'];
foreach($flow_list as &$v){
unset($v['flow_name']);
}
$params['flow_list'] = $flow_list;
}
Db::startTrans();
try {
OaFlow::create([
@ -86,13 +93,20 @@ class OaFlowLogic extends BaseLogic
if($params['check_type'] == 3){
$flow_list = $params['flow_list'];
foreach($flow_list as &$v){
$v['flow_type'] = 5;
$v['flow_type'] = 4;
}
$params['flow_list'] = $flow_list;
}
if($params['check_type'] == 2){
$params['flow_list'] = '';
}
if($params['check_type'] == 1){
$flow_list = $params['flow_list'];
foreach($flow_list as &$v){
unset($v['flow_name']);
}
$params['flow_list'] = $flow_list;
}
Db::startTrans();
try {
OaFlow::where('id', $params['id'])->update([

View File

@ -84,7 +84,7 @@
*/
public function sceneEdit()
{
return $this->only(['id', 'org_id', 'name', 'mobile', 'status'])->append('name', 'checkUniqueByEdit');;
return $this->only(['id', 'org_id', 'name', 'mobile', 'status','leader_id'])->append('name', 'checkUniqueByEdit');
}

View File

@ -175,10 +175,10 @@ class OaFlowValidate extends BaseValidate
if(!isset($v['flow_type']) || !isset($v['flow_uids'])){
return '固定审批流数据参数缺失';
}
if(empty($v['flow_type']) || !in_array($v['flow_type'],[1,2,3,4])){
if(empty($v['flow_type']) || !in_array($v['flow_type'],[1,2,3])){
return '固定审批流第'.($k+1).'行的类型未选择';
}
if($v['flow_type'] > 2 && empty($v['flow_uids'])){
if($v['flow_type'] > 1 && empty($v['flow_uids'])){
return '固定审批流第'.($k+1).'行的指定人未选择';
}
}