更新细节
This commit is contained in:
parent
490bde6bb4
commit
4d825b1d64
@ -18,7 +18,7 @@ namespace app\adminapi\lists\custom_service;
|
|||||||
use app\adminapi\lists\BaseAdminDataLists;
|
use app\adminapi\lists\BaseAdminDataLists;
|
||||||
use app\common\model\custom_service\CustomService;
|
use app\common\model\custom_service\CustomService;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CustomService列表
|
* CustomService列表
|
||||||
@ -38,7 +38,7 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
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
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return CustomService::where($this->searchWhere)
|
return Db::name('CustomService')->alias('cs')
|
||||||
->field(['*'])->limit($this->limitOffset, $this->limitLength)
|
->where($this->searchWhere)
|
||||||
->order(['id' => 'desc'])
|
->whereNull('cs.delete_time')
|
||||||
->select()
|
->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();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +78,11 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
|
|||||||
*/
|
*/
|
||||||
public function count(): int
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -41,6 +41,8 @@ class CustomServiceLogic extends BaseLogic
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
CustomService::create([
|
CustomService::create([
|
||||||
|
'org_id' => $params['org_id'] ?? 0,
|
||||||
|
'dept_id' => $params['dept_id'] ?? 0,
|
||||||
'project_id' => $params['project_id'] ?? 0,
|
'project_id' => $params['project_id'] ?? 0,
|
||||||
'custom_id' => $params['custom_id'] ?? 0,
|
'custom_id' => $params['custom_id'] ?? 0,
|
||||||
'approve_id' => $params['approve_id'] ?? 0,
|
'approve_id' => $params['approve_id'] ?? 0,
|
||||||
@ -79,6 +81,8 @@ class CustomServiceLogic extends BaseLogic
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
CustomService::where('id', $params['id'])->update([
|
CustomService::where('id', $params['id'])->update([
|
||||||
|
'org_id' => $params['org_id'] ?? 0,
|
||||||
|
'dept_id' => $params['dept_id'] ?? 0,
|
||||||
'project_id' => $params['project_id'] ?? 0,
|
'project_id' => $params['project_id'] ?? 0,
|
||||||
'custom_id' => $params['custom_id'] ?? 0,
|
'custom_id' => $params['custom_id'] ?? 0,
|
||||||
'approve_id' => $params['approve_id'] ?? 0,
|
'approve_id' => $params['approve_id'] ?? 0,
|
||||||
@ -130,6 +134,8 @@ class CustomServiceLogic extends BaseLogic
|
|||||||
$customService = CustomService::findOrEmpty($params['id']);
|
$customService = CustomService::findOrEmpty($params['id']);
|
||||||
$customService->project;
|
$customService->project;
|
||||||
$customService->custom;
|
$customService->custom;
|
||||||
|
$customService->org;
|
||||||
|
$customService->dept;
|
||||||
$customService->annex = json_decode($customService->annex, true);
|
$customService->annex = json_decode($customService->annex, true);
|
||||||
return $customService->toArray();
|
return $customService->toArray();
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,26 @@ class CustomService extends BaseModel
|
|||||||
return $this->belongsTo(\app\common\model\project\Project::class, 'project_id');
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user