更新细节

This commit is contained in:
yaooo 2023-12-23 14:52:47 +08:00
parent 490bde6bb4
commit 4d825b1d64
3 changed files with 47 additions and 7 deletions

View File

@ -18,7 +18,7 @@ namespace app\adminapi\lists\custom_service;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\custom_service\CustomService;
use app\common\lists\ListsSearchInterface;
use think\facade\Db;
/**
* CustomService列表
@ -38,7 +38,7 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
public function setSearch(): array
{
return [
'=' => ['project_id', 'custom_id', 'approve_id', 'contacts', 'phone', 'date', 'classification', 'urgency', 'receiver', 'processed_admin_id', 'name', 'description', 'notes', 'annex'],
'=' => ['cs.project_id', 'cs.custom_id', 'cs.approve_id', 'cs.contacts', 'cs.phone', 'cs.date', 'cs.classification', 'cs.urgency', 'cs.receiver', 'cs.processed_admin_id', 'cs.name'],
];
}
@ -54,10 +54,18 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
*/
public function lists(): array
{
return CustomService::where($this->searchWhere)
->field(['*'])->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
return Db::name('CustomService')->alias('cs')
->where($this->searchWhere)
->whereNull('cs.delete_time')
->leftJoin('orgs o','o.id = cs.org_id')
->leftJoin('dept d','d.id = cs.dept_id')
->field('cs.*, d.name as dept_name, o.name as org_name')
->limit($this->limitOffset, $this->limitLength)
->order(['cs.id' => 'desc'])
->select()->each(function($item, $key){
//关联数据后续添加
return $item;
})
->toArray();
}
@ -70,7 +78,11 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
*/
public function count(): int
{
return CustomService::where($this->searchWhere)->count();
return Db::name('CustomService')->alias('cs')
->where($this->searchWhere)
->whereNull('cs.delete_time')
->leftJoin('orgs o','o.id = cs.org_id')
->leftJoin('dept d','d.id = cs.dept_id')->count();
}
}

View File

@ -41,6 +41,8 @@ class CustomServiceLogic extends BaseLogic
Db::startTrans();
try {
CustomService::create([
'org_id' => $params['org_id'] ?? 0,
'dept_id' => $params['dept_id'] ?? 0,
'project_id' => $params['project_id'] ?? 0,
'custom_id' => $params['custom_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
@ -79,6 +81,8 @@ class CustomServiceLogic extends BaseLogic
Db::startTrans();
try {
CustomService::where('id', $params['id'])->update([
'org_id' => $params['org_id'] ?? 0,
'dept_id' => $params['dept_id'] ?? 0,
'project_id' => $params['project_id'] ?? 0,
'custom_id' => $params['custom_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
@ -130,6 +134,8 @@ class CustomServiceLogic extends BaseLogic
$customService = CustomService::findOrEmpty($params['id']);
$customService->project;
$customService->custom;
$customService->org;
$customService->dept;
$customService->annex = json_decode($customService->annex, true);
return $customService->toArray();
}

View File

@ -45,4 +45,26 @@ class CustomService extends BaseModel
return $this->belongsTo(\app\common\model\project\Project::class, 'project_id');
}
/**
* @notes 关联org
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/12/20 11:01
*/
public function org()
{
return $this->hasOne(\app\common\model\dept\Orgs::class, 'id', 'org_id');
}
/**
* @notes 关联dept
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/12/20 11:01
*/
public function dept()
{
return $this->hasOne(\app\common\model\dept\Dept::class, 'id', 'dept_id');
}
}