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