|
@@ -13,6 +13,7 @@ use App\Model\OaOrder;
|
|
|
use App\Model\OaOrderSub;
|
|
|
use App\Model\OaOrderSubEmployee;
|
|
|
use App\Model\OaSub;
|
|
|
+use App\Model\OaSubEmployee;
|
|
|
use App\Model\OaSubRule;
|
|
|
use App\Model\RollFilm;
|
|
|
use App\Model\RollFilmCombine;
|
|
@@ -51,116 +52,45 @@ class OaService extends Service
|
|
|
public function oaDetail($data)
|
|
|
{
|
|
|
|
|
|
-// $id = $data['id'];
|
|
|
-//
|
|
|
-//// if($this->isEmpty($data,'title')) return [201,'名称不存在!'];
|
|
|
-// $detail = OaSub::from('oa_sub as os')
|
|
|
-// ->leftJoin('employee as e', 'e.id', 'os.employee_id')
|
|
|
-// ->leftJoin('area as a', 'a.id', 'os.area_id')
|
|
|
-// ->where('oa_id', $id)
|
|
|
-// ->where('os.del_time', 0)
|
|
|
-// ->select('os.sort', 'os.type', 'os.employee_id', 'os.remark', 'e.emp_name','os.type','os.area_id','a.title as area_name')
|
|
|
-// ->orderBy('os.sort', 'asc')->get()->toArray();
|
|
|
-// $first = Oa::from('oa as o')
|
|
|
-// ->leftjoin('sys_menu as s', 's.id', 'o.menu_id')
|
|
|
-// ->select('o.id', 'o.menu_id', 'o.crt_time', 's.title','o.type')
|
|
|
-// ->where('o.del_time', 0)->where('o.id', $id)->first()->toArray();
|
|
|
-//
|
|
|
-// $first['detail'] = $detail;
|
|
|
-
|
|
|
- $detail = [
|
|
|
- 'id' => 1,
|
|
|
- 'detail' => [
|
|
|
- [
|
|
|
- 'id' => 2,
|
|
|
- 'name' => '张三',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 4,
|
|
|
- 'name' => '张三三',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 5,
|
|
|
- 'name' => '张五',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 6,
|
|
|
- 'name' => '李六',
|
|
|
- 'list' => []
|
|
|
- ]
|
|
|
- ]
|
|
|
- ], [
|
|
|
- 'id' => 7,
|
|
|
- 'name' => '张六',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 6,
|
|
|
- 'name' => '李六',
|
|
|
- 'list' => []
|
|
|
- ]
|
|
|
- ]
|
|
|
- ],
|
|
|
- ],
|
|
|
- ], [
|
|
|
- 'id' => 44,
|
|
|
- 'name' => '张四四',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 55,
|
|
|
- 'name' => '张四四1',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 66,
|
|
|
- 'name' => '李六1',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 77,
|
|
|
- 'name' => 'li7',
|
|
|
- 'list' => []
|
|
|
- ]
|
|
|
- ]
|
|
|
- ]
|
|
|
- ]
|
|
|
- ], [
|
|
|
- 'id' => 77,
|
|
|
- 'name' => '张四四2',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 6,
|
|
|
- 'name' => '李六',
|
|
|
- 'list' => []
|
|
|
- ]
|
|
|
- ]
|
|
|
- ],
|
|
|
- ],
|
|
|
- ],
|
|
|
- ]
|
|
|
- ], [
|
|
|
- 'id' => 3,
|
|
|
- 'name' => '李四',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 8,
|
|
|
- 'name' => '李五',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 9,
|
|
|
- 'name' => '李六',
|
|
|
- 'list' => [
|
|
|
- [
|
|
|
- 'id' => 6,
|
|
|
- 'name' => '李六',
|
|
|
- 'list' => []
|
|
|
- ]
|
|
|
- ]
|
|
|
- ]
|
|
|
- ]
|
|
|
- ]
|
|
|
- ]
|
|
|
- ],
|
|
|
- ],
|
|
|
- ];
|
|
|
-
|
|
|
+ $id = $data['id'];
|
|
|
+ $list = OaSub::where('oa_id',$id)->where('del_time',0)->get()->toArray();
|
|
|
+ $oa_sub_ids = [];
|
|
|
+ foreach ($list as $v){
|
|
|
+ $oa_sub_ids[] = $v['id'];
|
|
|
+ }
|
|
|
+ $oaRule = OaSubRule::wherein('oa_sub_id',$oa_sub_ids)->get()->toArray();
|
|
|
+ $oaEmployee = OaSubEmployee::wherein('oa_sub_id',$oa_sub_ids)->get()->toArray();
|
|
|
+ $oaRuleKey = [];
|
|
|
+ $oaEmployeeKey = [];
|
|
|
+ foreach ($oaRule as $v){
|
|
|
+ $oaRuleKey[$v['oa_sub_id']][] = [
|
|
|
+ 'value' => $v['value'],
|
|
|
+ 'key' => $v['key'],
|
|
|
+ 'formula' => $v['formula'] == '==' ? '=' : $v['formula'] ,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ foreach ($oaEmployee as $v){
|
|
|
+ $oaEmployeeKey[$v['oa_sub_id']][] = $v['employee_id'];
|
|
|
+ }
|
|
|
+ $return = [];
|
|
|
+ foreach ($list as $v){
|
|
|
+ $return[$v['sort']][] = [
|
|
|
+ 'emp_id' => $oaEmployeeKey[$v['id']],
|
|
|
+ 'set' => isset($oaRuleKey[$v['id']])?$oaRuleKey[$v['id']] : [] ,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $detail = [];
|
|
|
+ foreach ($return as $k=>$v){
|
|
|
+ $children = [];
|
|
|
+ foreach ($v as $vv){
|
|
|
+ $children[] = [
|
|
|
+ 'set'=>$vv['set'],
|
|
|
+ 'emp_id'=>$vv['emp_id'],
|
|
|
+ 'index'=>$k,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $detail[] = ['children'=>$children];
|
|
|
+ }
|
|
|
return [true, $detail];
|
|
|
|
|
|
}
|
|
@@ -294,25 +224,10 @@ class OaService extends Service
|
|
|
]);
|
|
|
//处理前端数据
|
|
|
$this->dealOaData($data,$id);
|
|
|
- foreach ($data['detail'] as $v) {
|
|
|
- foreach ($v['employee_list'] as $vv) {
|
|
|
- $insert[] = [
|
|
|
- 'oa_id' => $id,
|
|
|
- 'remark' => $v['remark'],
|
|
|
- 'employee_id' => $vv['employee_id'],
|
|
|
- 'sort' => $v['sort'],
|
|
|
- 'type' => $v['type'],
|
|
|
- 'crt_time' => time(),
|
|
|
- 'upd_time' => time(),
|
|
|
- 'area_id' => $vv['area_id'],
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- OaSub::insert($insert);
|
|
|
DB::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
DB::rollBack();
|
|
|
- return [false, $e->getMessage()];
|
|
|
+ return [false, $e->getLine().$e->getMessage()];
|
|
|
}
|
|
|
|
|
|
return [true, '更新成功'];
|
|
@@ -333,7 +248,67 @@ class OaService extends Service
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
- dd($detail);die;
|
|
|
+ $oa_subs = [];
|
|
|
+ foreach ($detail as $v){
|
|
|
+ $oa_subs[] = [
|
|
|
+ 'crt_time'=>time(),
|
|
|
+ 'upd_time'=>time(),
|
|
|
+ 'sort'=>$v['sort'],
|
|
|
+ 'sub_id'=>-1,
|
|
|
+ 'remark'=>'',
|
|
|
+ 'oa_id'=>$id,
|
|
|
+ 'type'=>1,
|
|
|
+ 'parent_id'=>0,
|
|
|
+ 'h5_key'=>$v['h5_key'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ OaSub::insert($oa_subs);
|
|
|
+ $oa_sub = OaSub::where('oa_id',$id)->get()->toArray();
|
|
|
+ $list_key = [];
|
|
|
+ foreach ($oa_sub as $v){
|
|
|
+ $list_key[$v['h5_key']] = $v;
|
|
|
+ }
|
|
|
+ foreach ($list_key as $k=>$v){
|
|
|
+ if($v['sort'] == 1) continue;
|
|
|
+ $len = strlen($k);
|
|
|
+ foreach ($list_key as $kk=>$vv){
|
|
|
+ if(strlen($kk) == ($len-2) && substr($k,0,$len-2) == $kk){
|
|
|
+ $list_key[$k]['parent_id'] = $vv['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $employee_list = [];
|
|
|
+ $set_list = [];
|
|
|
+ foreach ($detail as $v){
|
|
|
+ foreach ($v['emp_id'] as $vv){
|
|
|
+ $employee_list[] = [
|
|
|
+ 'employee_id' => $vv,
|
|
|
+ 'oa_sub_id' => $list_key[$v['h5_key']]['id'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $n = 1;
|
|
|
+ foreach ($v['set'] as $vv){
|
|
|
+ if($vv['opera'] == '=') $v['opera'] = '==';
|
|
|
+ if($n > 1) $right_formula = '&&';
|
|
|
+ else $right_formula = '';
|
|
|
+ $set_list[] = [
|
|
|
+ 'oa_sub_id'=>$list_key[$v['h5_key']]['id'],
|
|
|
+ 'key'=>$vv['key'],
|
|
|
+ 'value'=>$vv['value'],
|
|
|
+ 'sort'=>$n,
|
|
|
+ 'formula'=>$vv['opera'],
|
|
|
+ 'right_formula'=>$right_formula,
|
|
|
+ ];
|
|
|
+ $n++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ OaSubRule::insert($set_list);
|
|
|
+ OaSubEmployee::insert($employee_list);
|
|
|
+ foreach ($list_key as $v){
|
|
|
+ if($v['parent_id'] > 0 ) OaSub::where('id',$v['id'])->update([
|
|
|
+ 'parent_id' => $v['parent_id']
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public function oaDel($data)
|