update
This commit is contained in:
parent
b8b76ce6d7
commit
60bc509523
@ -1,77 +1,77 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\task;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\task\TaskAllocation;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* TaskAllocation列表
|
||||
* Class TaskAllocationLists
|
||||
* @package app\adminapi\liststask
|
||||
*/
|
||||
class TaskAllocationLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/02/22 10:47
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['project'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/02/22 10:47
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return TaskAllocation::where($this->searchWhere)
|
||||
->field(['id', 'dataid', 'num', 'project', 'project_num', 'head', 'apptime', 'annex'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/02/22 10:47
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return TaskAllocation::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\task;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\task\TaskAllocation;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* TaskAllocation列表
|
||||
* Class TaskAllocationLists
|
||||
* @package app\adminapi\liststask
|
||||
*/
|
||||
class TaskAllocationLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/02/22 10:47
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['project'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/02/22 10:47
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return TaskAllocation::where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/02/22 10:47
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return TaskAllocation::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -38,7 +38,8 @@ class TaskTypeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
|
||||
'=' => ['cost_project_id'],
|
||||
'%like%' => ['superior_sort', 'name'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -54,8 +55,14 @@ class TaskTypeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$startTime = $this->request->param('start_time', '');
|
||||
$endTime = $this->request->param('end_time', '');
|
||||
return TaskType::where($this->searchWhere)
|
||||
->field(['id', 'dataid', 'cost_project_id', 'num', 'name', 'superior_sort', 'level', 'remarks'])
|
||||
->where(function ($query) use($startTime, $endTime) {
|
||||
if ($startTime && $endTime) {
|
||||
$query->whereBetweenTime('create_time', $startTime.' 00:00:00', $endTime.' 23:59:59');
|
||||
}})
|
||||
->field(['id', 'dataid', 'cost_project_id', 'num', 'name', 'superior_sort', 'level', 'remarks','create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
|
@ -41,11 +41,9 @@ class TaskDetailLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
TaskDetail::create([
|
||||
'task_allocation_dataid' => $params['task_allocation_dataid'],
|
||||
'task_name' => $params['task_name'],
|
||||
'task_name_id' => $params['task_name_id'],
|
||||
'process' => $params['process'],
|
||||
'task_allocation_id' => $params['task_allocation_dataid'],
|
||||
'task_type_id' => $params['task_type_id'],
|
||||
'process' => $params['process'],
|
||||
'professional_type' => $params['professional_type'],
|
||||
'engineer' => $params['engineer'],
|
||||
'engineer_id' => $params['engineer_id'],
|
||||
@ -91,11 +89,9 @@ class TaskDetailLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
TaskDetail::where('id', $params['id'])->update([
|
||||
'task_allocation_dataid' => $params['task_allocation_dataid'],
|
||||
'task_name' => $params['task_name'],
|
||||
'task_name_id' => $params['task_name_id'],
|
||||
'process' => $params['process'],
|
||||
'task_allocation_id' => $params['task_allocation_dataid'],
|
||||
'task_type_id' => $params['task_type_id'],
|
||||
'process' => $params['process'],
|
||||
'professional_type' => $params['professional_type'],
|
||||
'engineer' => $params['engineer'],
|
||||
'engineer_id' => $params['engineer_id'],
|
||||
|
@ -41,7 +41,7 @@ class CostProjectLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
CostProject::create([
|
||||
'project_num' => $params['project_num'],
|
||||
'project_num' => generate_sn(CostProject::class, 'project_num'),
|
||||
'project_name' => $params['project_name'],
|
||||
'contract_id' => $params['contract_id'],
|
||||
'types' => $params['types'],
|
||||
@ -176,7 +176,7 @@ class CostProjectLogic extends BaseLogic
|
||||
public static function createProject($data)
|
||||
{
|
||||
return CostProject::create([
|
||||
'project_num' => generate_sn('cost_project'),
|
||||
'project_num' => generate_sn(CostProject::class, 'project_num'),
|
||||
'project_name' => $data['project_name'],
|
||||
'contract_id' => $data['contract_id'],
|
||||
'types' => $data['types'],
|
||||
|
@ -15,8 +15,10 @@
|
||||
namespace app\adminapi\logic\task;
|
||||
|
||||
|
||||
use app\adminapi\logic\TaskDetailLogic;
|
||||
use app\common\model\task\TaskAllocation;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\task\TaskType;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -38,18 +40,31 @@ class TaskAllocationLogic extends BaseLogic
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
// 项目id关联任务类别
|
||||
$projectId = $params['project_id'];
|
||||
// 任务
|
||||
$taskType = TaskType::where('cost_project_id', $projectId)->findOrEmpty();
|
||||
if ($taskType->isEmpty()) {
|
||||
self::setError('项目未配置任务类别');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
TaskAllocation::create([
|
||||
'dataid' => $params['dataid'],
|
||||
'num' => $params['num'],
|
||||
'project' => $params['project'],
|
||||
'project_num' => $params['project_num'],
|
||||
'head' => $params['head'],
|
||||
// 任务分配
|
||||
$taskAllocation = TaskAllocation::create([
|
||||
'dataid' => generate_sn(self::class, 'dataid'),
|
||||
'num' => generate_sn(self::class, 'num'),
|
||||
'task_type_id' => $taskType['id'], // 任务类别id
|
||||
'cost_project_id' => $taskType['cost_project_id'], // 项目id
|
||||
'apptime' => $params['apptime'],
|
||||
'annex' => $params['annex'],
|
||||
]);
|
||||
|
||||
// 任务明细
|
||||
$taskDetail = $params['task_detail'];
|
||||
foreach ($taskDetail as $item) {
|
||||
$item['task_allocation_id'] = $taskAllocation->id;
|
||||
$item['task_type_id'] = $taskType['id'];
|
||||
TaskDetailLogic::add($item);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -69,18 +84,22 @@ class TaskAllocationLogic extends BaseLogic
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
// 项目id关联任务类别
|
||||
$projectId = $params['project_id'];
|
||||
// 任务
|
||||
$taskType = TaskType::where('cost_project_id', $projectId)->findOrEmpty();
|
||||
if ($taskType->isEmpty()) {
|
||||
self::setError('项目未配置任务类别');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
TaskAllocation::where('id', $params['id'])->update([
|
||||
'dataid' => $params['dataid'],
|
||||
'num' => $params['num'],
|
||||
'project' => $params['project'],
|
||||
'project_num' => $params['project_num'],
|
||||
'head' => $params['head'],
|
||||
'apptime' => $params['apptime'],
|
||||
'annex' => $params['annex'],
|
||||
'num' => generate_sn(self::class, 'num'),
|
||||
'task_type_id' => $taskType['id'], // 任务类别id
|
||||
'cost_project_id' => $taskType['cost_project_id'], // 项目id
|
||||
'apptime' => $params['apptime'],
|
||||
'annex' => $params['annex'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user