|
@@ -223,12 +223,18 @@ class OaService extends Service
|
|
|
|
|
|
public function oaEdit($data, $user)
|
|
public function oaEdit($data, $user)
|
|
{
|
|
{
|
|
- $first = Oa::where('del_time', 0)->where('channel',$this->user['depart_top'][0]['depart_id'])->where('menu_id', $data['menu_id']);
|
|
|
|
- if (isset($data['id'])) $first = $first->where('id', '<>', $data['id']);
|
|
|
|
- if (isset($data['type'])) $first = $first->where('type', $data['type']);
|
|
|
|
- $first = $first->first();
|
|
|
|
-
|
|
|
|
- if ($first) return [false, '该菜单oa已存在!'];
|
|
|
|
|
|
+ $id = $data['id'] ?? 0;
|
|
|
|
+ $type = $data['type'] ?? 0;
|
|
|
|
+ $first = Oa::where('del_time', 0)
|
|
|
|
+ ->where('menu_id', $data['menu_id'])
|
|
|
|
+ ->when(! empty($id), function ($query) use ($id) {
|
|
|
|
+ return $query->where('id', '<>', $id);
|
|
|
|
+ })
|
|
|
|
+ ->when(! empty($type), function ($query) use ($type) {
|
|
|
|
+ return $query->where('$type', $type);
|
|
|
|
+ })
|
|
|
|
+ ->first();
|
|
|
|
+ if ($first) return [false, '菜单工作流已存在'];
|
|
|
|
|
|
try {
|
|
try {
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
@@ -238,24 +244,24 @@ class OaService extends Service
|
|
$oa->crt_employee_id = $user['id'];
|
|
$oa->crt_employee_id = $user['id'];
|
|
$oa->type = $data['type'] ?? 0;
|
|
$oa->type = $data['type'] ?? 0;
|
|
$oa->title = $data['title'] ?? '';
|
|
$oa->title = $data['title'] ?? '';
|
|
- $oa->channel = $this->user['depart_top'][0]['depart_id'];
|
|
|
|
$oa->save();
|
|
$oa->save();
|
|
$id = $oa->id;
|
|
$id = $oa->id;
|
|
- $insert = [];
|
|
|
|
|
|
|
|
$oa_sub_id = OaSub::where('oa_id', $id)->where('del_time',0)->pluck('id')->toArray();
|
|
$oa_sub_id = OaSub::where('oa_id', $id)->where('del_time',0)->pluck('id')->toArray();
|
|
OaSub::where('oa_id', $id)->update([
|
|
OaSub::where('oa_id', $id)->update([
|
|
'del_time' => time()
|
|
'del_time' => time()
|
|
]);
|
|
]);
|
|
|
|
+
|
|
//处理前端数据
|
|
//处理前端数据
|
|
$this->dealOaData($data, $id, $oa_sub_id);
|
|
$this->dealOaData($data, $id, $oa_sub_id);
|
|
|
|
+
|
|
DB::commit();
|
|
DB::commit();
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
return [false, $e->getLine() . $e->getMessage()];
|
|
return [false, $e->getLine() . $e->getMessage()];
|
|
}
|
|
}
|
|
|
|
|
|
- return [true, '更新成功'];
|
|
|
|
|
|
+ return [true, ''];
|
|
}
|
|
}
|
|
|
|
|
|
public function dealOaData($data, $id, $oa_sub_id)
|
|
public function dealOaData($data, $id, $oa_sub_id)
|