projectmanager/app/model/Project.php
2025-06-25 10:53:11 +08:00

51 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\model;
use think\facade\Db;
use think\Model;
class Project extends Model
{
const ZERO = 0;
const ONE = 1;
const TWO = 2;
const THREE = 3;
const FORE = 4;
public static $Status = [
self::ZERO => '未设置',
self::ONE => '未开始',
self::TWO => '进行中',
self::THREE => '已完成',
self::FORE => '已关闭',
];
//详情
public function detail($id)
{
$detail = Db::name('Project')->where(['id' => $id])->find();
if (!empty($detail)) {
$detail['product_name'] = Db::name('Product')->where(['id' => $detail['product_id']])->value('name');
$detail['admin_name'] = Db::name('Admin')->where(['id' => $detail['admin_id']])->value('name');
$detail['director_name'] = Db::name('Admin')->where(['id' => $detail['director_uid']])->value('name');
// 增加筛选条件删除时间为null
$team_admin_ids = Db::name('ProjectUser')
->where(['delete_time' => 0, 'project_id' => $id, 'delete_time' => null]) // 确保delete_time为空
->column('uid');
$team_admin_names = Db::name('Admin')->where('id', 'in', $team_admin_ids)->column('name');
$detail['team_admin_names'] = implode(',', $team_admin_names);
$detail['team_admin_ids'] = implode(',', $team_admin_ids);
$detail['status_name'] = self::$Status[(int) $detail['status']];
$detail['project_type'] = Db::name('Admin')->where(['id' => $detail['project_type']])->value('name');
$detail['times'] = time_trans($detail['create_time']);
$detail['users'] = Db::name('ProjectUser')->where(['delete_time' => 0, 'project_id' => $id])->count();
$detail['comments'] = Db::name('Comment')->where([['module','=','project'],['topic_id','=',$detail['id']],['delete_time','=',0]])->count();
$detail['logs'] = Db::name('Log')->where(['module' => 'project', 'project_id' => $detail['id']])->count();
}
return $detail;
}
}