$params['project_num'], 'project_name' => $params['project_name'], 'contract_id' => $params['contract_id'], 'types' => $params['types'], 'industry' => $params['industry'], 'province' => $params['province'], 'city' => $params['city'], 'address' => $params['address'], 'starting' => $params['starting'], 'endtime' => $params['endtime'], 'jhgq' => $params['jhgq'], 'org_id' => $params['org_id'], 'depar' => $params['depar'], 'principal' => $params['principal'], 'person' => $params['person'], 'invest' => $params['invest'], 'budget' => $params['budget'], 'cost' => $params['cost'], 'approval' => $params['approval'], 'aunit' => $params['aunit'], 'Acontact' => $params['Acontact'], 'acontactnum' => $params['acontactnum'], 'date' => $params['date'], 'generalize' => $params['generalize'], 'note' => $params['note'], 'remark' => $params['remark'], 'annex' => $params['annex'] ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑造价项目台账 * @param array $params * @return bool * @author likeadmin * @date 2024/02/21 09:23 */ public static function edit(array $params): bool { Db::startTrans(); try { CostProject::where('id', $params['id'])->update([ 'project_num' => $params['project_num'], 'project_name' => $params['project_name'], 'contract_id' => $params['contract_id'], 'types' => $params['types'], 'industry' => $params['industry'], 'province' => $params['province'], 'city' => $params['city'], 'address' => $params['address'], 'starting' => $params['starting'], 'endtime' => $params['endtime'], 'jhgq' => $params['jhgq'], 'org_id' => $params['org_id'], 'depar' => $params['depar'], 'principal' => $params['principal'], 'person' => $params['person'], 'invest' => $params['invest'], 'budget' => $params['budget'], 'cost' => $params['cost'], 'approval' => $params['approval'], 'aunit' => $params['aunit'], 'Acontact' => $params['Acontact'], 'acontactnum' => $params['acontactnum'], 'date' => $params['date'], 'generalize' => $params['generalize'], 'note' => $params['note'], 'remark' => $params['remark'], 'annex' => $params['annex'] ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除造价项目台账 * @param array $params * @return bool * @author likeadmin * @date 2024/02/21 09:23 */ public static function delete(array $params): bool { return CostProject::destroy($params['id']); } /** * @notes 获取造价项目台账详情 * @param $params * @return array * @author likeadmin * @date 2024/02/21 09:23 */ public static function detail($params): array { return CostProject::with(['contract'])->findOrEmpty($params['id'])->toArray(); } public static function datas($name) { $datas = CostProject::where(function ($query) use ($name) { if ($name) { $query->where('project_name', 'like', '%' . $name . '%'); } }) ->field(['id', 'project_num', 'project_name']) ->order(['id' => 'desc']) ->select() ->toArray(); foreach ($datas as &$item) { $item['projectinfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['project_name']; } return $datas; } public static function createProject($data) { return CostProject::create([ 'project_num' => generate_sn('cost_project'), 'project_name' => $data['project_name'], 'contract_id' => $data['contract_id'], 'types' => $data['types'], 'industry' => $data['industry'], 'province' => $data['province'], 'city' => $data['city'], 'address' => $data['address'], 'starting' => $data['starting'], 'endtime' => $data['endtime'], 'jhgq' => $data['jhgq'], 'depar' => $data['depar'], 'principal' => $data['principal'], 'person' => $data['person'], 'invest' => $data['invest'], 'budget' => $data['budget'], 'cost' => $data['cost'], 'approval' => $data['approval'], 'aunit' => $data['aunit'], 'Acontact' => $data['Acontact'], 'acontactnum' => $data['acontactnum'], 'date' => $data['date'], 'generalize' => $data['generalize'], 'note' => $data['note'], 'remark' => $data['remark'], 'annex' => $data['annex'] ]); } }