$params['org_id'], 'dept_id' => $params['dept_id'], 'project_id' => $params['project_id'], 'name' => $params['name'], 'type' => $params['type'], 'happen_date' => strtotime($params['happen_date']), 'content' => $params['content'], 'remark' => $params['remark'], 'file' => !empty($params['file']) ? $params['file'] : null, 'add_user' => $admin_id, 'update_user' => $admin_id, ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑质量事件 * @param array $params * @return bool * @author likeadmin * @date 2023/12/21 09:42 */ public static function edit(array $params,$admin_id): bool { Db::startTrans(); try { QualityEvent::where('id', $params['id'])->update([ 'org_id' => $params['org_id'], 'dept_id' => $params['dept_id'], 'project_id' => $params['project_id'], 'name' => $params['name'], 'type' => $params['type'], 'happen_date' => strtotime($params['happen_date']), 'content' => $params['content'], 'remark' => $params['remark'], 'file' => !empty($params['file']) ? $params['file'] : null, 'update_user' => $admin_id, 'update_time' => time(), ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除质量事件 * @param array $params * @return bool * @author likeadmin * @date 2023/12/21 09:42 */ public static function delete(array $params): bool { return QualityEvent::destroy($params['id']); } /** * @notes 获取质量事件详情 * @param $params * @return array * @author likeadmin * @date 2023/12/21 09:42 */ public static function detail($params): array { $data = QualityEvent::findOrEmpty($params['id'])->toArray(); $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; $data['org_name'] = $org['name']; $data['dept_name'] = $dept['name']; $data['add_user_name'] = $admin[$data['add_user']]; $data['update_user_name'] = $admin[$data['update_user']]; return $data; } }