整理数据结构
This commit is contained in:
parent
a9c763bb77
commit
11b4aea20c
@ -24,6 +24,39 @@ use Request;
|
|||||||
*/
|
*/
|
||||||
class ProjectController extends AbstractController
|
class ProjectController extends AbstractController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 任务统计
|
||||||
|
*/
|
||||||
|
public function statistics()
|
||||||
|
{
|
||||||
|
User::auth();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
// 今日待完成
|
||||||
|
$between = [
|
||||||
|
Carbon::today()->startOfDay(),
|
||||||
|
Carbon::today()->endOfDay()
|
||||||
|
];
|
||||||
|
$data['today'] = ProjectTask::authData()
|
||||||
|
->whereNull('project_tasks.complete_at')
|
||||||
|
->where('project_tasks.parent_id', 0)
|
||||||
|
->where(function ($query) use ($between) {
|
||||||
|
$query->whereBetween('project_tasks.start_at', $between)->orWhereBetween('project_tasks.end_at', $between);
|
||||||
|
})
|
||||||
|
->count();
|
||||||
|
|
||||||
|
// 超期未完成
|
||||||
|
$data['overdue'] = ProjectTask::authData()
|
||||||
|
->whereNull('project_tasks.complete_at')
|
||||||
|
->where('project_tasks.parent_id', 0)
|
||||||
|
->whereNotNull('project_tasks.end_at')
|
||||||
|
->where('project_tasks.end_at', '<', Carbon::now())
|
||||||
|
->count();
|
||||||
|
|
||||||
|
return Base::retSuccess('success', $data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取项目列表
|
* 获取项目列表
|
||||||
*
|
*
|
||||||
@ -43,11 +76,11 @@ class ProjectController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取项目基础信息
|
* 获取一个项目信息
|
||||||
*
|
*
|
||||||
* @apiParam {Number} project_id 项目ID
|
* @apiParam {Number} project_id 项目ID
|
||||||
*/
|
*/
|
||||||
public function basic()
|
public function one()
|
||||||
{
|
{
|
||||||
User::auth();
|
User::auth();
|
||||||
//
|
//
|
||||||
@ -58,41 +91,12 @@ class ProjectController extends AbstractController
|
|||||||
return Base::retSuccess('success', $project);
|
return Base::retSuccess('success', $project);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取项目详细信息
|
|
||||||
*
|
|
||||||
* @apiParam {Number} project_id 项目ID
|
|
||||||
*/
|
|
||||||
public function detail()
|
|
||||||
{
|
|
||||||
User::auth();
|
|
||||||
//
|
|
||||||
$project_id = intval(Request::input('project_id'));
|
|
||||||
//
|
|
||||||
$project = Project::with(['projectColumn' => function($query) {
|
|
||||||
$query->with(['projectTask' => function($taskQuery) {
|
|
||||||
$taskQuery->with(['taskUser', 'taskTag'])->where('parent_id', 0);
|
|
||||||
}]);
|
|
||||||
}, 'projectUser'])
|
|
||||||
->select(project::projectSelect)
|
|
||||||
->authData()
|
|
||||||
->where('projects.id', $project_id)
|
|
||||||
->first();
|
|
||||||
if (empty($project)) {
|
|
||||||
return Base::retError('项目不存在或不在成员列表内');
|
|
||||||
}
|
|
||||||
$owner_user = $project->projectUser->where('owner', 1)->first();
|
|
||||||
$project->owner_userid = $owner_user ? $owner_user->userid : 0;
|
|
||||||
//
|
|
||||||
return Base::retSuccess('success', $project);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加项目
|
* 添加项目
|
||||||
*
|
*
|
||||||
* @apiParam {String} name 项目名称
|
* @apiParam {String} name 项目名称
|
||||||
* @apiParam {String} [desc] 项目介绍
|
* @apiParam {String} [desc] 项目介绍
|
||||||
* @apiParam {Array} [columns] 流程,格式[流程1, 流程2]
|
* @apiParam {Array} [columns] 列表,格式[列表1, 列表2]
|
||||||
*/
|
*/
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
@ -108,7 +112,7 @@ class ProjectController extends AbstractController
|
|||||||
if (mb_strlen($desc) > 255) {
|
if (mb_strlen($desc) > 255) {
|
||||||
return Base::retError('项目介绍最多只能设置255个字');
|
return Base::retError('项目介绍最多只能设置255个字');
|
||||||
}
|
}
|
||||||
//流程
|
// 列表
|
||||||
$columns = Request::input('columns');
|
$columns = Request::input('columns');
|
||||||
if (!is_array($columns)) $columns = [];
|
if (!is_array($columns)) $columns = [];
|
||||||
$insertColumns = [];
|
$insertColumns = [];
|
||||||
@ -129,7 +133,7 @@ class ProjectController extends AbstractController
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (count($insertColumns) > 30) {
|
if (count($insertColumns) > 30) {
|
||||||
return Base::retError('项目流程最多不能超过30个');
|
return Base::retError('项目列表最多不能超过30个');
|
||||||
}
|
}
|
||||||
// 开始创建
|
// 开始创建
|
||||||
$project = Project::createInstance([
|
$project = Project::createInstance([
|
||||||
@ -150,7 +154,7 @@ class ProjectController extends AbstractController
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
$data = $project->find($project->id);
|
$data = Project::find($project->id);
|
||||||
$data->addLog("创建项目");
|
$data->addLog("创建项目");
|
||||||
$data->pushMsg('add', $data->toArray());
|
$data->pushMsg('add', $data->toArray());
|
||||||
return Base::retSuccess('添加成功', $data);
|
return Base::retSuccess('添加成功', $data);
|
||||||
@ -374,6 +378,30 @@ class ProjectController extends AbstractController
|
|||||||
return Base::retSuccess('删除成功', ['id' => $project->id]);
|
return Base::retSuccess('删除成功', ['id' => $project->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务列表
|
||||||
|
*
|
||||||
|
* @apiParam {Number} project_id 项目ID
|
||||||
|
*
|
||||||
|
* @apiParam {Number} [page] 当前页,默认:1
|
||||||
|
* @apiParam {Number} [pagesize] 每页显示数量,默认:100,最大:200
|
||||||
|
*/
|
||||||
|
public function column__lists()
|
||||||
|
{
|
||||||
|
User::auth();
|
||||||
|
//
|
||||||
|
$project_id = intval(Request::input('project_id'));
|
||||||
|
// 项目
|
||||||
|
$project = Project::userProject($project_id);
|
||||||
|
//
|
||||||
|
$list = ProjectColumn::whereProjectId($project->id)
|
||||||
|
->orderBy('sort')
|
||||||
|
->orderBy('id')
|
||||||
|
->paginate(Base::getPaginate(200, 100));
|
||||||
|
//
|
||||||
|
return Base::retSuccess('success', $list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加任务列表
|
* 添加任务列表
|
||||||
*
|
*
|
||||||
@ -400,7 +428,7 @@ class ProjectController extends AbstractController
|
|||||||
$column->save();
|
$column->save();
|
||||||
$column->addLog("创建列表:" . $column->name);
|
$column->addLog("创建列表:" . $column->name);
|
||||||
//
|
//
|
||||||
$data = $column->find($column->id);
|
$data = ProjectColumn::find($column->id);
|
||||||
$data->project_task = [];
|
$data->project_task = [];
|
||||||
$data->pushMsg("add", $data->toArray());
|
$data->pushMsg("add", $data->toArray());
|
||||||
return Base::retSuccess('添加成功', $data);
|
return Base::retSuccess('添加成功', $data);
|
||||||
@ -471,54 +499,46 @@ class ProjectController extends AbstractController
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
$column->deleteColumn();
|
$column->deleteColumn();
|
||||||
return Base::retSuccess('删除成功', $column->toArray());
|
return Base::retSuccess('删除成功', ['id' => $column->id]);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务统计
|
|
||||||
*/
|
|
||||||
public function task__statistics()
|
|
||||||
{
|
|
||||||
User::auth();
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
|
|
||||||
// 今日待完成
|
|
||||||
$between = [
|
|
||||||
Carbon::today()->startOfDay(),
|
|
||||||
Carbon::today()->endOfDay()
|
|
||||||
];
|
|
||||||
$data['today'] = ProjectTask::authData()->where(function($query) use ($between) {
|
|
||||||
$query->whereBetween('project_tasks.start_at', $between)->orWhereBetween('project_tasks.end_at', $between);
|
|
||||||
})->count();
|
|
||||||
|
|
||||||
// 超期未完成
|
|
||||||
$data['overdue'] = ProjectTask::authData()->whereNotNull('project_tasks.end_at')->where('project_tasks.end_at', '<', Carbon::now())->count();
|
|
||||||
|
|
||||||
return Base::retSuccess('success', $data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务列表
|
* 任务列表
|
||||||
*
|
*
|
||||||
* @apiParam {String} name 任务名称(包含)
|
* @apiParam {Number} [project_id] 项目ID
|
||||||
* @apiParam {Array} time 时间范围,如:['2020-12-12', '2020-12-30']
|
* @apiParam {Number} [parent_id] 主任务ID(填写后 project_id 无效)
|
||||||
* @apiParam {String} time_before 指定时间之前,如:2020-12-30 00:00:00(填写此项时time参数无效)
|
* @apiParam {String} [name] 任务描述关键词
|
||||||
|
* @apiParam {Array} [time] 时间范围,如:['2020-12-12', '2020-12-30']
|
||||||
|
* @apiParam {String} [time_before] 指定时间之前,如:2020-12-30 00:00:00(填写此项时time参数无效)
|
||||||
*/
|
*/
|
||||||
public function task__lists()
|
public function task__lists()
|
||||||
{
|
{
|
||||||
User::auth();
|
User::auth();
|
||||||
//
|
//
|
||||||
$builder = ProjectTask::select(ProjectTask::taskSelect)->authData();
|
$builder = ProjectTask::with(['taskUser', 'taskTag']);
|
||||||
//
|
//
|
||||||
|
$parent_id = intval(Request::input('parent_id'));
|
||||||
|
$project_id = intval(Request::input('project_id'));
|
||||||
$name = Request::input('name');
|
$name = Request::input('name');
|
||||||
$time = Request::input('time');
|
$time = Request::input('time');
|
||||||
$time_before = Request::input('time_before');
|
$time_before = Request::input('time_before');
|
||||||
|
//
|
||||||
|
if ($parent_id > 0) {
|
||||||
|
ProjectTask::userTask($parent_id);
|
||||||
|
$builder->where('parent_id', $parent_id)->whereNull('archived_at');
|
||||||
|
} elseif ($project_id > 0) {
|
||||||
|
Project::userProject($project_id);
|
||||||
|
$builder->where('project_id', $project_id)->whereNull('archived_at');
|
||||||
|
} else {
|
||||||
|
$builder->authData();
|
||||||
|
}
|
||||||
|
//
|
||||||
if ($name) {
|
if ($name) {
|
||||||
$builder->where(function($query) use ($name) {
|
$builder->where(function($query) use ($name) {
|
||||||
$query->where('project_tasks.name', 'like', '%,' . $name . ',%');
|
$query->where('project_tasks.name', 'like', '%,' . $name . ',%');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if (Base::isDateOrTime($time_before)) {
|
if (Base::isDateOrTime($time_before)) {
|
||||||
$builder->whereNotNull('project_tasks.end_at')->where('project_tasks.end_at', '<', Carbon::parse($time_before));
|
$builder->whereNotNull('project_tasks.end_at')->where('project_tasks.end_at', '<', Carbon::parse($time_before));
|
||||||
} elseif (is_array($time)) {
|
} elseif (is_array($time)) {
|
||||||
@ -539,11 +559,11 @@ class ProjectController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务基础信息
|
* 获取单个任务信息
|
||||||
*
|
*
|
||||||
* @apiParam {Number} task_id 任务ID
|
* @apiParam {Number} task_id 任务ID
|
||||||
*/
|
*/
|
||||||
public function task__basic()
|
public function task__one()
|
||||||
{
|
{
|
||||||
User::auth();
|
User::auth();
|
||||||
//
|
//
|
||||||
@ -557,23 +577,6 @@ class ProjectController extends AbstractController
|
|||||||
return Base::retSuccess('success', $task);
|
return Base::retSuccess('success', $task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取子任务
|
|
||||||
*
|
|
||||||
* @apiParam {Number} task_id 任务ID
|
|
||||||
*/
|
|
||||||
public function task__sublist()
|
|
||||||
{
|
|
||||||
User::auth();
|
|
||||||
//
|
|
||||||
$task_id = intval(Request::input('task_id'));
|
|
||||||
//
|
|
||||||
$task = ProjectTask::userTask($task_id);
|
|
||||||
//
|
|
||||||
$data = ProjectTask::with(['taskUser', 'taskTag'])->where('parent_id', $task->id)->whereNull('archived_at')->get();
|
|
||||||
return Base::retSuccess('success', $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务详细描述
|
* 获取任务详细描述
|
||||||
*
|
*
|
||||||
@ -661,10 +664,10 @@ class ProjectController extends AbstractController
|
|||||||
]));
|
]));
|
||||||
$data = [
|
$data = [
|
||||||
'new_column' => $newColumn,
|
'new_column' => $newColumn,
|
||||||
'in_top' => intval($data['top']),
|
'task' => ProjectTask::with(['taskUser', 'taskTag'])->find($task->id)->toArray(),
|
||||||
'task' => ProjectTask::with(['taskUser', 'taskTag'])->find($task->id),
|
|
||||||
];
|
];
|
||||||
$task->pushMsg('add', $data);
|
$task->pushMsg('add', $data);
|
||||||
|
$data['task']['owner'] = 1;
|
||||||
return Base::retSuccess('添加成功', $data);
|
return Base::retSuccess('添加成功', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,10 +694,10 @@ class ProjectController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
$data = [
|
$data = [
|
||||||
'new_column' => null,
|
'new_column' => null,
|
||||||
'in_top' => 0,
|
'task' => ProjectTask::with(['taskUser', 'taskTag'])->find($task->id)->toArray(),
|
||||||
'task' => ProjectTask::with(['taskUser', 'taskTag'])->find($task->id),
|
|
||||||
];
|
];
|
||||||
$task->pushMsg('add', $data);
|
$task->pushMsg('add', $data);
|
||||||
|
$data['task']['owner'] = 1;
|
||||||
return Base::retSuccess('添加成功', $data);
|
return Base::retSuccess('添加成功', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,7 +803,8 @@ class ProjectController extends AbstractController
|
|||||||
'userid' => $user->userid,
|
'userid' => $user->userid,
|
||||||
]);
|
]);
|
||||||
$file->save();
|
$file->save();
|
||||||
$file = $file->find($file->id);
|
//
|
||||||
|
$file = ProjectTaskFile::find($file->id);
|
||||||
$task->addLog("上传文件:" . $file->name);
|
$task->addLog("上传文件:" . $file->name);
|
||||||
$task->pushMsg('upload', $file->toArray());
|
$task->pushMsg('upload', $file->toArray());
|
||||||
return Base::retSuccess("上传成功", $file);
|
return Base::retSuccess("上传成功", $file);
|
||||||
@ -863,7 +867,7 @@ class ProjectController extends AbstractController
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
$task->archivedTask(Carbon::now());
|
$task->archivedTask(Carbon::now());
|
||||||
return Base::retSuccess('保存成功', $task);
|
return Base::retSuccess('保存成功', ['id' => $task->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -880,7 +884,7 @@ class ProjectController extends AbstractController
|
|||||||
$task = ProjectTask::userTask($task_id);
|
$task = ProjectTask::userTask($task_id);
|
||||||
//
|
//
|
||||||
$task->deleteTask();
|
$task->deleteTask();
|
||||||
return Base::retSuccess('删除成功', $task);
|
return Base::retSuccess('删除成功', ['id' => $task->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +20,7 @@ use Request;
|
|||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||||
|
* @property-read int $owner_userid
|
||||||
* @property-read int $task_complete
|
* @property-read int $task_complete
|
||||||
* @property-read int $task_my_complete
|
* @property-read int $task_my_complete
|
||||||
* @property-read int $task_my_num
|
* @property-read int $task_my_num
|
||||||
@ -65,6 +66,7 @@ class Project extends AbstractModel
|
|||||||
'task_my_num',
|
'task_my_num',
|
||||||
'task_my_complete',
|
'task_my_complete',
|
||||||
'task_my_percent',
|
'task_my_percent',
|
||||||
|
'owner_userid',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,6 +147,19 @@ class Project extends AbstractModel
|
|||||||
return $this->appendattrs['task_my_percent'];
|
return $this->appendattrs['task_my_percent'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 负责人会员ID
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getOwnerUseridAttribute()
|
||||||
|
{
|
||||||
|
if (!isset($this->appendattrs['owner_userid'])) {
|
||||||
|
$ownerUser = $this->projectUser->where('owner', 1)->first();
|
||||||
|
$this->appendattrs['owner_userid'] = $ownerUser ? $ownerUser->userid : 0;
|
||||||
|
}
|
||||||
|
return $this->appendattrs['owner_userid'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $value
|
* @param $value
|
||||||
* @return int|mixed
|
* @return int|mixed
|
||||||
@ -338,7 +353,7 @@ class Project extends AbstractModel
|
|||||||
*/
|
*/
|
||||||
public static function userProject($project_id)
|
public static function userProject($project_id)
|
||||||
{
|
{
|
||||||
$project = Project::select(self::projectSelect)
|
$project = self::select(self::projectSelect)
|
||||||
->authData()
|
->authData()
|
||||||
->where('projects.id', intval($project_id))
|
->where('projects.id', intval($project_id))
|
||||||
->first();
|
->first();
|
||||||
|
@ -258,15 +258,16 @@ class ProjectTask extends AbstractModel
|
|||||||
{
|
{
|
||||||
$pre = DB::getTablePrefix();
|
$pre = DB::getTablePrefix();
|
||||||
$user = $user ?: User::auth();
|
$user = $user ?: User::auth();
|
||||||
$query->join('project_task_users', 'project_tasks.id', '=', 'project_task_users.task_pid')
|
$query->select(ProjectTask::taskSelect)
|
||||||
|
->join('project_task_users', 'project_tasks.id', '=', 'project_task_users.task_pid')
|
||||||
->whereExists(function ($der) use ($pre) {
|
->whereExists(function ($der) use ($pre) {
|
||||||
$der->select(DB::raw(1))
|
$der->select(DB::raw(1))
|
||||||
->from('project_task_users as B')
|
->from('project_task_users as B')
|
||||||
|
->where('B.owner', 1)
|
||||||
->whereColumn('project_task_users.task_pid', '=', 'B.task_pid')
|
->whereColumn('project_task_users.task_pid', '=', 'B.task_pid')
|
||||||
->havingRaw("max({$pre}B.id) = {$pre}project_task_users.id");
|
->havingRaw("max({$pre}B.id) = {$pre}project_task_users.id");
|
||||||
})
|
})
|
||||||
->whereNull('project_tasks.archived_at')
|
->whereNull('project_tasks.archived_at')
|
||||||
->where('project_tasks.parent_id', 0)
|
|
||||||
->where('project_task_users.userid', $user->userid);
|
->where('project_task_users.userid', $user->userid);
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
@ -688,7 +689,7 @@ class ProjectTask extends AbstractModel
|
|||||||
*/
|
*/
|
||||||
public static function userTask($task_id, $with = [])
|
public static function userTask($task_id, $with = [])
|
||||||
{
|
{
|
||||||
$task = ProjectTask::with($with)->whereId(intval($task_id))->first();
|
$task = self::with($with)->whereId(intval($task_id))->first();
|
||||||
if (empty($task)) {
|
if (empty($task)) {
|
||||||
throw new ApiException('任务不存在');
|
throw new ApiException('任务不存在');
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<li class="menu-project">
|
<li class="menu-project">
|
||||||
<ul>
|
<ul>
|
||||||
<li
|
<li
|
||||||
v-for="(item, key) in projectList"
|
v-for="(item, key) in projects"
|
||||||
:key="key"
|
:key="key"
|
||||||
:class="classNameRoute('project/' + item.id, openMenu[item.id])"
|
:class="classNameRoute('project/' + item.id, openMenu[item.id])"
|
||||||
@click="toggleRoute('project/' + item.id)">
|
@click="toggleRoute('project/' + item.id)">
|
||||||
@ -103,20 +103,21 @@
|
|||||||
|
|
||||||
<!--任务详情-->
|
<!--任务详情-->
|
||||||
<Modal
|
<Modal
|
||||||
v-model="projectOpenTask._show"
|
:value="taskId > 0"
|
||||||
:mask-closable="false"
|
:mask-closable="false"
|
||||||
:styles="{
|
:styles="{
|
||||||
width: '90%',
|
width: '90%',
|
||||||
maxWidth: projectOpenTask.dialog_id ? '1200px' : '640px'
|
maxWidth: taskData.dialog_id ? '1200px' : '640px'
|
||||||
}"
|
}"
|
||||||
|
@on-visible-change="taskVisibleChange"
|
||||||
footer-hide>
|
footer-hide>
|
||||||
<TaskDetail :open-task="projectOpenTask"/>
|
<TaskDetail :open-task="taskData"/>
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState, mapGetters } from 'vuex'
|
||||||
import TaskDetail from "./manage/components/TaskDetail";
|
import TaskDetail from "./manage/components/TaskDetail";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -174,18 +175,19 @@ export default {
|
|||||||
'userId',
|
'userId',
|
||||||
'userInfo',
|
'userInfo',
|
||||||
'dialogMsgUnread',
|
'dialogMsgUnread',
|
||||||
'projectList',
|
'projects',
|
||||||
'projectOpenTask',
|
'projectChatShow',
|
||||||
'projectChatShow'
|
'taskId',
|
||||||
]),
|
]),
|
||||||
|
...mapGetters(['taskData'])
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
'$route' (route) {
|
'$route' (route) {
|
||||||
this.curPath = route.path;
|
this.curPath = route.path;
|
||||||
},
|
},
|
||||||
'projectOpenTask._show' (show) {
|
taskId (id) {
|
||||||
if (show) {
|
if (id > 0) {
|
||||||
if (this.projectChatShow) {
|
if (this.projectChatShow) {
|
||||||
this._projectChatShow = true;
|
this._projectChatShow = true;
|
||||||
this.$store.dispatch("toggleBoolean", "projectChatShow");
|
this.$store.dispatch("toggleBoolean", "projectChatShow");
|
||||||
@ -316,6 +318,12 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
taskVisibleChange(visible) {
|
||||||
|
if (!visible) {
|
||||||
|
this.$store.dispatch('openTask', 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
:theme="calendarTheme"
|
:theme="calendarTheme"
|
||||||
:template="calendarTemplate"
|
:template="calendarTemplate"
|
||||||
:calendars="calendarList"
|
:calendars="calendarList"
|
||||||
:schedules="calendarTasks"
|
:schedules="list"
|
||||||
@beforeCreateSchedule="onBeforeCreateSchedule"
|
@beforeCreateSchedule="onBeforeCreateSchedule"
|
||||||
@beforeClickSchedule="onBeforeClickSchedule"
|
@beforeClickSchedule="onBeforeClickSchedule"
|
||||||
@beforeUpdateSchedule="onBeforeUpdateSchedule"
|
@beforeUpdateSchedule="onBeforeUpdateSchedule"
|
||||||
@ -47,21 +47,6 @@ import {mapState} from "vuex";
|
|||||||
import Calendar from "./components/Calendar";
|
import Calendar from "./components/Calendar";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
|
||||||
const today = new Date();
|
|
||||||
|
|
||||||
const getDate = (type, start, value, operator) => {
|
|
||||||
start = new Date(start);
|
|
||||||
type = type.charAt(0).toUpperCase() + type.slice(1);
|
|
||||||
|
|
||||||
if (operator === '+') {
|
|
||||||
start[`set${type}`](start[`get${type}`]() + value);
|
|
||||||
} else {
|
|
||||||
start[`set${type}`](start[`get${type}`]() - value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return start;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {Calendar},
|
components: {Calendar},
|
||||||
data() {
|
data() {
|
||||||
@ -78,7 +63,7 @@ export default {
|
|||||||
calendarTemplate: {},
|
calendarTemplate: {},
|
||||||
calendarList: [],
|
calendarList: [],
|
||||||
|
|
||||||
scheduleLoad: 0,
|
loadIng: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -91,10 +76,53 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['projectList', 'calendarTask']),
|
...mapState(['projects', 'tasks']),
|
||||||
|
|
||||||
calendarTasks() {
|
list() {
|
||||||
return this.calendarTask.filter(({complete_at}) => !complete_at)
|
let datas = $A.cloneJSON(this.tasks);
|
||||||
|
datas = datas.filter((data) => {
|
||||||
|
if (data.parent_id > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (data.complete_at) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!data.start_at || !data.end_at) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return data.owner;
|
||||||
|
})
|
||||||
|
return datas.map(data => {
|
||||||
|
let task = {
|
||||||
|
id: data.id,
|
||||||
|
calendarId: String(data.project_id),
|
||||||
|
title: data.name,
|
||||||
|
body: data.desc,
|
||||||
|
category: 'allday',
|
||||||
|
start: new Date(data.start_at).toISOString(),
|
||||||
|
end: new Date(data.end_at).toISOString(),
|
||||||
|
color: "#515a6e",
|
||||||
|
bgColor: data.color || '#E3EAFD',
|
||||||
|
borderColor: data.p_color,
|
||||||
|
complete_at: data.complete_at,
|
||||||
|
priority: '',
|
||||||
|
preventClick: true,
|
||||||
|
isChecked: false,
|
||||||
|
};
|
||||||
|
if (data.p_name) {
|
||||||
|
task.priority = '<span class="priority" style="background-color:' + data.p_color + '">' + data.p_name + '</span>';
|
||||||
|
}
|
||||||
|
if (data.overdue) {
|
||||||
|
task.title = '[' + $A.L('超期') + '] ' + task.title
|
||||||
|
task.color = "#f56c6c"
|
||||||
|
task.bgColor = "#fef0f0"
|
||||||
|
task.priority+= '<span class="overdue">' + $A.L('超期未完成') + '</span>';
|
||||||
|
}
|
||||||
|
if (!task.borderColor) {
|
||||||
|
task.borderColor = task.bgColor;
|
||||||
|
}
|
||||||
|
return task;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -103,7 +131,7 @@ export default {
|
|||||||
this.getTask(time);
|
this.getTask(time);
|
||||||
},
|
},
|
||||||
|
|
||||||
projectList: {
|
projects: {
|
||||||
handler(data) {
|
handler(data) {
|
||||||
const list = data.map((project) => {
|
const list = data.map((project) => {
|
||||||
return {
|
return {
|
||||||
@ -155,20 +183,19 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getTask(time) {
|
getTask(time) {
|
||||||
if (this.scheduleLoad > 0) {
|
if (this.loadIng > 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.getTask(time)
|
this.getTask(time)
|
||||||
}, 100)
|
}, 100)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.scheduleLoad++;
|
this.loadIng++;
|
||||||
this.$store.dispatch("getTaskList", {
|
this.$store.dispatch("getTasks", {
|
||||||
time
|
time
|
||||||
}).then(({data}) => {
|
}).then(() => {
|
||||||
this.scheduleLoad--;
|
this.loadIng--;
|
||||||
this.$store.dispatch("saveCalendarTask", data.data)
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.scheduleLoad--;
|
this.loadIng--;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -232,7 +259,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onBeforeClickSchedule({type, schedule}) {
|
onBeforeClickSchedule({type, schedule}) {
|
||||||
let data = this.calendarTask.find(({id}) => id === schedule.id);
|
let data = this.tasks.find(({id}) => id === schedule.id);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -251,17 +278,17 @@ export default {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "edit":
|
case "edit":
|
||||||
this.$store.dispatch("openTask", schedule.id)
|
this.$store.dispatch("openTask", data.id)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "delete":
|
case "delete":
|
||||||
$A.modalConfirm({
|
$A.modalConfirm({
|
||||||
title: '删除任务',
|
title: '删除任务',
|
||||||
content: '你确定要删除任务【' + data.title + '】吗?',
|
content: '你确定要删除任务【' + data.name + '】吗?',
|
||||||
loading: true,
|
loading: true,
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
this.$store.dispatch("taskArchivedOrRemove", {
|
this.$store.dispatch("taskArchivedOrRemove", {
|
||||||
task_id: data.id,
|
id: data.id,
|
||||||
type: 'delete',
|
type: 'delete',
|
||||||
}).then(({msg}) => {
|
}).then(({msg}) => {
|
||||||
$A.messageSuccess(msg);
|
$A.messageSuccess(msg);
|
||||||
@ -279,7 +306,7 @@ export default {
|
|||||||
|
|
||||||
onBeforeUpdateSchedule(res) {
|
onBeforeUpdateSchedule(res) {
|
||||||
const {changes, schedule} = res;
|
const {changes, schedule} = res;
|
||||||
let data = this.calendarTask.find(({id}) => id === schedule.id);
|
let data = this.tasks.find(({id}) => id === schedule.id);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import Calendar from 'tui-calendar-hi';
|
import Calendar from 'tui-calendar-hi';
|
||||||
|
|
||||||
const scheduleNeedProp = [
|
|
||||||
'start',
|
|
||||||
'category'
|
|
||||||
];
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Calendar',
|
name: 'Calendar',
|
||||||
props: {
|
props: {
|
||||||
@ -27,7 +22,7 @@ export default {
|
|||||||
let notHave = false;
|
let notHave = false;
|
||||||
|
|
||||||
value.forEach(schedule => {
|
value.forEach(schedule => {
|
||||||
notHave = scheduleNeedProp.some(prop => !schedule.hasOwnProperty(prop));
|
notHave = [ 'start', 'category' ].some(prop => !schedule.hasOwnProperty(prop));
|
||||||
});
|
});
|
||||||
|
|
||||||
return !notHave;
|
return !notHave;
|
||||||
|
@ -318,10 +318,7 @@ export default {
|
|||||||
if (!this.dialogDetail.group_info) {
|
if (!this.dialogDetail.group_info) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$store.dispatch("openTask", {
|
this.$store.dispatch("openTask", this.dialogDetail.group_info.id);
|
||||||
id: this.dialogDetail.group_info.id,
|
|
||||||
dialog_id: this.dialogDetail.id
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
loadNextPage() {
|
loadNextPage() {
|
||||||
|
@ -821,7 +821,7 @@ export default {
|
|||||||
$A.messageSuccess(msg);
|
$A.messageSuccess(msg);
|
||||||
this.ownerLoad--;
|
this.ownerLoad--;
|
||||||
this.ownerShow = false;
|
this.ownerShow = false;
|
||||||
this.$store.dispatch("getTaskBasic", this.taskDetail.id);
|
this.$store.dispatch("getTaskOne", this.taskDetail.id);
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
this.ownerLoad--;
|
this.ownerLoad--;
|
||||||
@ -851,7 +851,7 @@ export default {
|
|||||||
$A.messageSuccess(msg);
|
$A.messageSuccess(msg);
|
||||||
this.assistLoad--;
|
this.assistLoad--;
|
||||||
this.assistShow = false;
|
this.assistShow = false;
|
||||||
this.$store.dispatch("getTaskBasic", this.taskDetail.id);
|
this.$store.dispatch("getTaskOne", this.taskDetail.id);
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
this.assistLoad--;
|
this.assistLoad--;
|
||||||
|
@ -36,7 +36,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['userToken', 'projectOpenTask']),
|
...mapState(['userToken', 'taskId', 'taskFiles']),
|
||||||
|
|
||||||
headers() {
|
headers() {
|
||||||
return {
|
return {
|
||||||
@ -47,7 +47,7 @@ export default {
|
|||||||
|
|
||||||
params() {
|
params() {
|
||||||
return {
|
return {
|
||||||
task_id: this.projectOpenTask.id,
|
task_id: this.taskId,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -57,18 +57,19 @@ export default {
|
|||||||
//上传时
|
//上传时
|
||||||
if (typeof file.tempId === "undefined") {
|
if (typeof file.tempId === "undefined") {
|
||||||
file.tempId = $A.randomString(8);
|
file.tempId = $A.randomString(8);
|
||||||
this.projectOpenTask.files.push(file);
|
file.task_id = this.taskId;
|
||||||
|
this.taskFiles.push(file);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess({ret, data, msg}, file) {
|
handleSuccess({ret, data, msg}, file) {
|
||||||
//上传完成
|
//上传完成
|
||||||
let index = this.projectOpenTask.files.findIndex(({tempId}) => tempId == file.tempId);
|
let index = this.taskFiles.findIndex(({tempId}) => tempId == file.tempId);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
this.projectOpenTask.files.splice(index, 1);
|
this.taskFiles.splice(index, 1);
|
||||||
}
|
}
|
||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
this.$store.commit("taskUploadSuccess", data)
|
this.taskFiles.push(data);
|
||||||
} else {
|
} else {
|
||||||
this.$refs.upload.fileList.pop();
|
this.$refs.upload.fileList.pop();
|
||||||
$A.modalWarning({
|
$A.modalWarning({
|
||||||
|
@ -5,33 +5,33 @@
|
|||||||
<div class="dashboard-hello">{{$L('欢迎您,' + userInfo.nickname)}}</div>
|
<div class="dashboard-hello">{{$L('欢迎您,' + userInfo.nickname)}}</div>
|
||||||
<div class="dashboard-desc">{{$L('以下是你当前的任务统计数据')}}</div>
|
<div class="dashboard-desc">{{$L('以下是你当前的任务统计数据')}}</div>
|
||||||
<ul class="dashboard-block">
|
<ul class="dashboard-block">
|
||||||
<li @click="active='today'">
|
<li @click="dashboard='today'">
|
||||||
<div class="block-title">{{$L('今日待完成')}}</div>
|
<div class="block-title">{{$L('今日待完成')}}</div>
|
||||||
<div class="block-data">
|
<div class="block-data">
|
||||||
<div class="block-num">{{projectTaskStatistics.today || '...'}}</div>
|
<div class="block-num">{{projectStatistics.today || '...'}}</div>
|
||||||
<i class="iconfont"></i>
|
<i class="iconfont"></i>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li @click="active='overdue'">
|
<li @click="dashboard='overdue'">
|
||||||
<div class="block-title">{{$L('超期未完成')}}</div>
|
<div class="block-title">{{$L('超期未完成')}}</div>
|
||||||
<div class="block-data">
|
<div class="block-data">
|
||||||
<div class="block-num">{{projectTaskStatistics.overdue || '...'}}</div>
|
<div class="block-num">{{projectStatistics.overdue || '...'}}</div>
|
||||||
<i class="iconfont"></i>
|
<i class="iconfont"></i>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="block-title">{{$L('参与的项目')}}</div>
|
<div class="block-title">{{$L('参与的项目')}}</div>
|
||||||
<div class="block-data">
|
<div class="block-data">
|
||||||
<div class="block-num">{{projectList.length}}</div>
|
<div class="block-num">{{projects.length}}</div>
|
||||||
<i class="iconfont"></i>
|
<i class="iconfont"></i>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="dashboard-title">{{getTitle}}</div>
|
<div class="dashboard-title">{{title}}</div>
|
||||||
<ul class="dashboard-list overlay-y">
|
<ul class="dashboard-list overlay-y">
|
||||||
<li v-for="item in taskList">
|
<li v-for="item in list" :key="item.id" @click="$store.dispatch('openTask', item.id)">
|
||||||
<i class="iconfont"></i>
|
<i class="iconfont"></i>
|
||||||
<div class="item-title">{{item.title}}</div>
|
<div class="item-title">{{item.name}}</div>
|
||||||
<div class="item-time"></div>
|
<div class="item-time"></div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -46,22 +46,27 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loadIng: 0,
|
loadIng: 0,
|
||||||
|
active: false,
|
||||||
active: 'today',
|
dashboard: 'today',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
activated() {
|
activated() {
|
||||||
this.$store.dispatch("getTaskStatistics");
|
this.getTask();
|
||||||
this.getDashboardTask();
|
this.active = true;
|
||||||
|
this.$store.dispatch("getProjectStatistics");
|
||||||
|
},
|
||||||
|
|
||||||
|
deactivated() {
|
||||||
|
this.active = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['userInfo', 'projectList', 'projectTaskStatistics', 'calendarTask']),
|
...mapState(['userInfo', 'projects', 'projectStatistics', 'tasks', 'taskId']),
|
||||||
|
|
||||||
getTitle() {
|
title() {
|
||||||
const {active} = this;
|
const {dashboard} = this;
|
||||||
switch (active) {
|
switch (dashboard) {
|
||||||
case 'today':
|
case 'today':
|
||||||
return this.$L('今日任务');
|
return this.$L('今日任务');
|
||||||
case 'overdue':
|
case 'overdue':
|
||||||
@ -71,14 +76,20 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
taskList() {
|
list() {
|
||||||
const {calendarTask, active} = this;
|
const {tasks, dashboard} = this;
|
||||||
const todayStart = new Date($A.formatDate("Y-m-d 00:00:00")),
|
const todayStart = new Date($A.formatDate("Y-m-d 00:00:00")),
|
||||||
todayEnd = new Date($A.formatDate("Y-m-d 23:59:59"));
|
todayEnd = new Date($A.formatDate("Y-m-d 23:59:59"));
|
||||||
return calendarTask.filter((item) => {
|
return tasks.filter((data) => {
|
||||||
const start = new Date(item.start);
|
const start = new Date(data.start_at),
|
||||||
const end = new Date(item.end);
|
end = new Date(data.end_at);
|
||||||
switch (active) {
|
if (data.parent_id > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (data.complete_at) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (dashboard) {
|
||||||
case 'today':
|
case 'today':
|
||||||
return (start >= todayStart && start <= todayEnd) || (end >= todayStart && end <= todayEnd);
|
return (start >= todayStart && start <= todayEnd) || (end >= todayStart && end <= todayEnd);
|
||||||
case 'overdue':
|
case 'overdue':
|
||||||
@ -91,17 +102,23 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
active() {
|
dashboard() {
|
||||||
this.getDashboardTask();
|
this.getTask();
|
||||||
|
},
|
||||||
|
|
||||||
|
taskId(id) {
|
||||||
|
if (id == 0 && this.active) {
|
||||||
|
this.$store.dispatch("getProjectStatistics");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
getDashboardTask() {
|
getTask() {
|
||||||
let payload = {};
|
let data = {};
|
||||||
switch (this.active) {
|
switch (this.dashboard) {
|
||||||
case 'today':
|
case 'today':
|
||||||
payload = {
|
data = {
|
||||||
time: [
|
time: [
|
||||||
$A.formatDate("Y-m-d 00:00:00"),
|
$A.formatDate("Y-m-d 00:00:00"),
|
||||||
$A.formatDate("Y-m-d 23:59:59")
|
$A.formatDate("Y-m-d 23:59:59")
|
||||||
@ -109,7 +126,7 @@ export default {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'overdue':
|
case 'overdue':
|
||||||
payload = {
|
data = {
|
||||||
time_before: $A.formatDate("Y-m-d 00:00:00")
|
time_before: $A.formatDate("Y-m-d 00:00:00")
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -118,9 +135,8 @@ export default {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
this.loadIng++;
|
this.loadIng++;
|
||||||
this.$store.dispatch("getTaskList", payload).then(({data}) => {
|
this.$store.dispatch("getTasks", data).then(() => {
|
||||||
this.loadIng--;
|
this.loadIng--;
|
||||||
this.$store.dispatch("saveCalendarTask", data.data)
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.loadIng--;
|
this.loadIng--;
|
||||||
})
|
})
|
||||||
|
535
resources/assets/js/store/actions.js
vendored
535
resources/assets/js/store/actions.js
vendored
@ -168,7 +168,7 @@ export default {
|
|||||||
state.userToken = userInfo.token;
|
state.userToken = userInfo.token;
|
||||||
state.userIsAdmin = state.method.inArray('admin', userInfo.identity);
|
state.userIsAdmin = state.method.inArray('admin', userInfo.identity);
|
||||||
state.method.setStorage("userInfo", state.userInfo);
|
state.method.setStorage("userInfo", state.userInfo);
|
||||||
dispatch("getProjectList");
|
dispatch("getProjects");
|
||||||
dispatch("getDialogMsgUnread");
|
dispatch("getDialogMsgUnread");
|
||||||
dispatch("websocketConnection");
|
dispatch("websocketConnection");
|
||||||
resolve()
|
resolve()
|
||||||
@ -260,267 +260,304 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** *****************************************************************************************/
|
||||||
|
/** ************************************** 项目 **********************************************/
|
||||||
|
/** *****************************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存项目信息
|
* 保存项目数据
|
||||||
* @param state
|
* @param state
|
||||||
|
* @param dispatch
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveProject({state}, data) {
|
saveProject({state, dispatch}, data) {
|
||||||
if (state.method.isArray(data)) {
|
if (state.method.isArray(data)) {
|
||||||
if (state.projectDetail.id) {
|
data.forEach((project) => {
|
||||||
const project = data.find(({id}) => id == state.projectDetail.id);
|
dispatch("saveProject", project)
|
||||||
if (project) {
|
});
|
||||||
state.projectDetail = Object.assign({}, state.projectDetail, project)
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
state.projectList = data;
|
|
||||||
} else if (state.method.isJson(data)) {
|
} else if (state.method.isJson(data)) {
|
||||||
if (data.id == state.projectDetail.id) {
|
let index = state.projects.findIndex(({id}) => id == data.id);
|
||||||
state.projectDetail = Object.assign({}, state.projectDetail, data)
|
|
||||||
}
|
|
||||||
let index = state.projectList.findIndex(({id}) => id == data.id);
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.projectList.splice(index, 1, Object.assign({}, state.projectList[index], data));
|
state.projects.splice(index, 1, Object.assign(state.projects[index], data));
|
||||||
} else {
|
} else {
|
||||||
state.projectList.unshift(data);
|
state.projects.push(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.method.setStorage("cacheProjectList", state.cacheProjectList = state.projectList);
|
state.method.setStorage("cacheProjects", state.cacheProjects = state.projects);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取项目列表
|
* 获取项目
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
*/
|
*/
|
||||||
getProjectList({state, dispatch}) {
|
getProjects({state, dispatch}) {
|
||||||
if (state.userId === 0) {
|
if (state.userId === 0) {
|
||||||
state.projectList = [];
|
state.projects = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state.cacheProjectList.length > 0) {
|
if (state.cacheProjects.length > 0) {
|
||||||
state.projectList = state.cacheProjectList;
|
state.projects = state.cacheProjects;
|
||||||
}
|
}
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'project/lists',
|
url: 'project/lists',
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
dispatch("saveProject", result.data.data);
|
dispatch("saveProject", result.data.data);
|
||||||
}).catch(result => {
|
}).catch(result => {
|
||||||
$A.modalError(result.msg);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取项目信息
|
|
||||||
* @param state
|
|
||||||
* @param dispatch
|
|
||||||
* @param data {id}
|
|
||||||
*/
|
|
||||||
getProjectBasic({state, dispatch}, data) {
|
|
||||||
if (state.method.runNum(data.id) === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dispatch("call", {
|
|
||||||
url: 'project/basic',
|
|
||||||
data: {
|
|
||||||
project_id: data.id,
|
|
||||||
},
|
|
||||||
}).then(result => {
|
|
||||||
dispatch("saveProject", result.data);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取项目详情
|
|
||||||
* @param state
|
|
||||||
* @param dispatch
|
|
||||||
* @param data {id}
|
|
||||||
*/
|
|
||||||
getProjectDetail({state, dispatch}, data) {
|
|
||||||
if (state.method.runNum(data.id) === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const project = state.cacheProjectList.find(({id}) => id == data.id);
|
|
||||||
if (project) {
|
|
||||||
state.projectDetail = Object.assign({project_column: [], project_user: []}, project);
|
|
||||||
} else {
|
|
||||||
state.projectDetail.id = data.id;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
state.projectLoad++;
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单个项目
|
||||||
|
* @param state
|
||||||
|
* @param dispatch
|
||||||
|
* @param data {id}
|
||||||
|
*/
|
||||||
|
getProjectOne({state, dispatch}, data) {
|
||||||
|
if (state.method.runNum(data.id) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'project/detail',
|
url: 'project/one',
|
||||||
data: {
|
data: {
|
||||||
project_id: data.id,
|
project_id: data.id,
|
||||||
},
|
},
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
state.projectLoad--;
|
|
||||||
dispatch("saveProject", result.data);
|
dispatch("saveProject", result.data);
|
||||||
}).catch(result => {
|
}).catch(result => {
|
||||||
state.projectLoad--;
|
//
|
||||||
$A.modalError(result.msg);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除项目信息
|
* 删除项目
|
||||||
* @param state
|
* @param state
|
||||||
* @param data {id}
|
* @param data {id}
|
||||||
*/
|
*/
|
||||||
removeProject({state}, data) {
|
removeProject({state}, data) {
|
||||||
let index = state.projectList.findIndex(({id}) => id == data.id);
|
if (state.method.runNum(data.id) === 0) {
|
||||||
if (index > -1) {
|
return;
|
||||||
state.projectList.splice(index, 1);
|
|
||||||
state.method.setStorage("cacheProjectList", state.cacheProjectList = state.projectList);
|
|
||||||
}
|
}
|
||||||
if (state.projectDetail.id == data.id) {
|
let index = state.projects.findIndex(({id}) => id == data.id);
|
||||||
const project = state.projectList.find(({id}) => id && id != data.id);
|
if (index > -1) {
|
||||||
|
state.projects.splice(index, 1);
|
||||||
|
}
|
||||||
|
if (state.projectId == data.id) {
|
||||||
|
const project = state.projects.find(({id}) => id && id != data.id);
|
||||||
if (project) {
|
if (project) {
|
||||||
$A.goForward({path: '/manage/project/' + project.id});
|
$A.goForward({path: '/manage/project/' + project.id});
|
||||||
} else {
|
} else {
|
||||||
$A.goForward({path: '/manage/dashboard'});
|
$A.goForward({path: '/manage/dashboard'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
dispatch("call", {
|
||||||
|
url: 'project/delete',
|
||||||
|
data: {
|
||||||
|
project_id: data.id,
|
||||||
|
},
|
||||||
|
}).then(result => {
|
||||||
|
state.method.setStorage("cacheProjects", state.cacheProjects = state.projects);
|
||||||
|
}).catch(result => {
|
||||||
|
//
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存任务信息
|
* 获取项目统计
|
||||||
|
* @param state
|
||||||
|
* @param dispatch
|
||||||
|
*/
|
||||||
|
getProjectStatistics({state, dispatch}) {
|
||||||
|
dispatch("call", {
|
||||||
|
url: 'project/statistics',
|
||||||
|
}).then(({data}) => {
|
||||||
|
state.projectStatistics = data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** *****************************************************************************************/
|
||||||
|
/** ************************************** 列表 **********************************************/
|
||||||
|
/** *****************************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存列表数据
|
||||||
|
* @param state
|
||||||
|
* @param dispatch
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
saveColumn({state, dispatch}, data) {
|
||||||
|
if (state.method.isArray(data)) {
|
||||||
|
data.forEach((column) => {
|
||||||
|
dispatch("saveColumn", column)
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else if (state.method.isJson(data)) {
|
||||||
|
let index = state.columns.findIndex(({id}) => id == data.id);
|
||||||
|
if (index > -1) {
|
||||||
|
state.columns.splice(index, 1, Object.assign(state.columns[index], data));
|
||||||
|
} else {
|
||||||
|
state.columns.push(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state.method.setStorage("cacheColumns", state.cacheColumns = state.columns);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取列表
|
||||||
|
* @param state
|
||||||
|
* @param dispatch
|
||||||
|
* @param data {project_id}
|
||||||
|
*/
|
||||||
|
getColumns({state, dispatch}, data) {
|
||||||
|
if (state.userId === 0) {
|
||||||
|
state.columns = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (state.cacheColumns.length > 0) {
|
||||||
|
state.columns = state.cacheColumns;
|
||||||
|
}
|
||||||
|
dispatch("call", {
|
||||||
|
url: 'project/column/lists',
|
||||||
|
data: {
|
||||||
|
project_id: data.project_id
|
||||||
|
}
|
||||||
|
}).then(result => {
|
||||||
|
dispatch("saveColumn", result.data.data);
|
||||||
|
}).catch(result => {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除列表
|
||||||
|
* @param state
|
||||||
|
* @param data {id}
|
||||||
|
*/
|
||||||
|
removeColumn({state}, data) {
|
||||||
|
if (state.method.runNum(data.id) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let index = state.columns.findIndex(({id}) => id == data.id);
|
||||||
|
if (index > -1) {
|
||||||
|
state.columns.splice(index, 1);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
dispatch("call", {
|
||||||
|
url: 'project/column/delete',
|
||||||
|
data: {
|
||||||
|
column_id: data.id,
|
||||||
|
},
|
||||||
|
}).then(result => {
|
||||||
|
state.method.setStorage("cacheColumns", state.cacheColumns = state.columns);
|
||||||
|
}).catch(result => {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** *****************************************************************************************/
|
||||||
|
/** ************************************** 任务 **********************************************/
|
||||||
|
/** *****************************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存任务数据
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveTask({state, dispatch}, data) {
|
saveTask({state, dispatch}, data) {
|
||||||
state.projectDetail.project_column.some(({project_task}) => {
|
|
||||||
let index = project_task.findIndex(({id}) => id === data.id);
|
|
||||||
if (index > -1) {
|
|
||||||
project_task.splice(index, 1, Object.assign(project_task[index], data))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (data.id == state.projectOpenTask.id) {
|
|
||||||
state.projectOpenTask = Object.assign({}, state.projectOpenTask, data);
|
|
||||||
} else if (data.parent_id == state.projectOpenTask.id && state.projectOpenTask.sub_task) {
|
|
||||||
let index = state.projectOpenTask.sub_task.findIndex(({id}) => id === data.id);
|
|
||||||
if (index > -1) {
|
|
||||||
state.projectOpenTask.sub_task.splice(index, 1, Object.assign(state.projectOpenTask.sub_task[index], data))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dispatch("saveCalendarTask", data)
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存任务信息(日历任务)
|
|
||||||
* @param state
|
|
||||||
* @param dispatch
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
saveCalendarTask({state, dispatch}, data) {
|
|
||||||
if (state.method.isArray(data)) {
|
if (state.method.isArray(data)) {
|
||||||
data.forEach((task) => {
|
data.forEach((task) => {
|
||||||
dispatch("saveCalendarTask", task)
|
dispatch("saveTask", task)
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
} else if (state.method.isJson(data)) {
|
||||||
if (data.parent_id > 0) {
|
let index = state.tasks.findIndex(({id}) => id == data.id);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!data.start_at || !data.end_at) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!data.owner) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let task = {
|
|
||||||
id: data.id,
|
|
||||||
calendarId: String(data.project_id),
|
|
||||||
title: data.name,
|
|
||||||
body: data.desc,
|
|
||||||
category: 'allday',
|
|
||||||
start: new Date(data.start_at).toISOString(),
|
|
||||||
end: new Date(data.end_at).toISOString(),
|
|
||||||
color: "#515a6e",
|
|
||||||
bgColor: data.color || '#E3EAFD',
|
|
||||||
borderColor: data.p_color,
|
|
||||||
complete_at: data.complete_at,
|
|
||||||
priority: '',
|
|
||||||
preventClick: true,
|
|
||||||
isChecked: false,
|
|
||||||
};
|
|
||||||
if (data.p_name) {
|
|
||||||
task.priority = '<span class="priority" style="background-color:' + data.p_color + '">' + data.p_name + '</span>';
|
|
||||||
}
|
|
||||||
if (data.overdue) {
|
|
||||||
task.title = '[' + $A.L('超期') + '] ' + task.title
|
|
||||||
task.color = "#f56c6c"
|
|
||||||
task.bgColor = "#fef0f0"
|
|
||||||
task.priority+= '<span class="overdue">' + $A.L('超期未完成') + '</span>';
|
|
||||||
}
|
|
||||||
if (!task.borderColor) {
|
|
||||||
task.borderColor = task.bgColor;
|
|
||||||
}
|
|
||||||
let index = state.calendarTask.findIndex(({id}) => id === data.id);
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.calendarTask.splice(index, 1, Object.assign(state.calendarTask[index], task))
|
state.tasks.splice(index, 1, Object.assign(state.tasks[index], data));
|
||||||
} else {
|
} else {
|
||||||
state.calendarTask.push(task)
|
state.tasks.push(data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
state.method.setStorage("cacheTasks", state.cacheTasks = state.tasks);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务统计
|
* 获取任务
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
|
* @param data {project_id, parent_id}
|
||||||
*/
|
*/
|
||||||
getTaskStatistics({state, dispatch}) {
|
getTasks({state, dispatch}, data) {
|
||||||
dispatch("call", {
|
|
||||||
url: 'project/task/statistics',
|
|
||||||
}).then(({data}) => {
|
|
||||||
state.projectTaskStatistics = data;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取任务列表
|
|
||||||
* @param state
|
|
||||||
* @param dispatch
|
|
||||||
* @param whereData
|
|
||||||
* @returns {Promise<unknown>}
|
|
||||||
*/
|
|
||||||
getTaskList({state, dispatch}, whereData) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
if (state.userId === 0) {
|
if (state.userId === 0) {
|
||||||
reject()
|
state.tasks = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (state.cacheTasks.length > 0) {
|
||||||
|
state.tasks = state.cacheTasks;
|
||||||
|
}
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'project/task/lists',
|
url: 'project/task/lists',
|
||||||
data: whereData,
|
data: data
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
resolve(result)
|
dispatch("saveTask", result.data.data);
|
||||||
}).catch(result => {
|
}).catch(result => {
|
||||||
reject(result)
|
//
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务信息
|
* 获取单个任务
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param task_id
|
* @param task_id
|
||||||
* @returns {Promise<unknown>}
|
|
||||||
*/
|
*/
|
||||||
getTaskBasic({state, dispatch}, task_id) {
|
getTaskOne({state, dispatch}, task_id) {
|
||||||
return new Promise(function (resolve, reject) {
|
if (state.method.runNum(task_id) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'project/task/basic',
|
url: 'project/task/one',
|
||||||
data: {
|
data: {
|
||||||
task_id,
|
task_id,
|
||||||
},
|
},
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
dispatch("saveTask", result.data);
|
dispatch("saveTask", result.data);
|
||||||
|
}).catch(result => {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除或归档任务
|
||||||
|
* @param state
|
||||||
|
* @param dispatch
|
||||||
|
* @param data {id, type}
|
||||||
|
* @returns {Promise<unknown>}
|
||||||
|
*/
|
||||||
|
taskArchivedOrRemove({state, dispatch}, data) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
if (state.method.runNum(data.id) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let index = state.tasks.findIndex(({id}) => id == data.id);
|
||||||
|
if (index > -1) {
|
||||||
|
state.tasks.splice(index, 1);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
dispatch("call", {
|
||||||
|
url: 'project/task/' + data.type,
|
||||||
|
data: {
|
||||||
|
task_id: data.id,
|
||||||
|
},
|
||||||
|
}).then(result => {
|
||||||
|
state.method.setStorage("cacheTasks", state.cacheTasks = state.tasks);
|
||||||
resolve(result)
|
resolve(result)
|
||||||
}).catch(result => {
|
}).catch(result => {
|
||||||
|
dispatch("getTaskOne", data.id);
|
||||||
reject(result)
|
reject(result)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -541,15 +578,14 @@ export default {
|
|||||||
task_id,
|
task_id,
|
||||||
},
|
},
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
const {content} = result.data;
|
let index = state.taskContents.findIndex(({id}) => id == result.data.id)
|
||||||
state.projectTaskContent[task_id] = content;
|
if (index > -1) {
|
||||||
if (task_id == state.projectOpenTask.id) {
|
state.taskContents.splice(index, 1, result.data)
|
||||||
state.projectOpenTask = Object.assign({}, state.projectOpenTask, {content: content || ''});
|
} else {
|
||||||
|
state.taskContents.push(result.data)
|
||||||
}
|
}
|
||||||
resolve(result)
|
resolve(result)
|
||||||
}).catch(result => {
|
}).catch(reject);
|
||||||
reject(result)
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -568,40 +604,16 @@ export default {
|
|||||||
task_id,
|
task_id,
|
||||||
},
|
},
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
state.projectTaskFiles[task_id] = result.data;
|
result.data.forEach((data) => {
|
||||||
if (task_id == state.projectOpenTask.id) {
|
let index = state.taskFiles.findIndex(({id}) => id == data.id)
|
||||||
state.projectOpenTask = Object.assign({}, state.projectOpenTask, {files: result.data});
|
if (index > -1) {
|
||||||
|
state.taskFiles.splice(index, 1, data)
|
||||||
|
} else {
|
||||||
|
state.taskFiles.push(data)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
resolve(result)
|
resolve(result)
|
||||||
}).catch(result => {
|
}).catch(reject);
|
||||||
reject(result)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取子任务
|
|
||||||
* @param state
|
|
||||||
* @param dispatch
|
|
||||||
* @param task_id
|
|
||||||
* @returns {Promise<unknown>}
|
|
||||||
*/
|
|
||||||
getSubTask({state, dispatch}, task_id) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
dispatch("call", {
|
|
||||||
url: 'project/task/sublist',
|
|
||||||
data: {
|
|
||||||
task_id,
|
|
||||||
},
|
|
||||||
}).then(result => {
|
|
||||||
state.projectSubTask[task_id] = result.data;
|
|
||||||
if (task_id == state.projectOpenTask.id) {
|
|
||||||
state.projectOpenTask = Object.assign({}, state.projectOpenTask, {sub_task: result.data});
|
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}).catch(result => {
|
|
||||||
reject(result)
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -612,35 +624,23 @@ export default {
|
|||||||
* @param task_id
|
* @param task_id
|
||||||
*/
|
*/
|
||||||
openTask({state, dispatch}, task_id) {
|
openTask({state, dispatch}, task_id) {
|
||||||
let data = state.method.isJson(task_id) ? task_id : {id: task_id};
|
state.taskId = task_id;
|
||||||
state.projectDetail.project_column.some(({project_task}) => {
|
if (task_id > 0) {
|
||||||
const task = project_task.find(({id}) => id === data.id);
|
dispatch("getTaskOne", task_id);
|
||||||
if (task) {
|
dispatch("getTaskContent", task_id);
|
||||||
data = Object.assign(data, task);
|
dispatch("getTaskFiles", task_id);
|
||||||
return true
|
dispatch("getTasks", {parent_id: task_id});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
//
|
|
||||||
data.content = state.projectTaskContent[data.id] || ""
|
|
||||||
data.files = state.projectTaskFiles[data.id] || []
|
|
||||||
data.sub_task = state.projectSubTask[data.id] || []
|
|
||||||
//
|
|
||||||
state.projectOpenTask = Object.assign({}, data, {_show: true});
|
|
||||||
dispatch("getTaskBasic", data.id);
|
|
||||||
dispatch("getTaskContent", data.id);
|
|
||||||
dispatch("getTaskFiles", data.id);
|
|
||||||
dispatch("getSubTask", data.id);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加任务
|
* 添加任务
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
|
||||||
* @param commit
|
* @param commit
|
||||||
* @param data
|
* @param data
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
taskAdd({state, dispatch, commit}, data) {
|
taskAdd({state, dispatch}, data) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
const post = state.method.cloneJSON(state.method.date2string(data));
|
const post = state.method.cloneJSON(state.method.date2string(data));
|
||||||
if (state.method.isArray(post.column_id)) post.column_id = post.column_id.find((val) => val)
|
if (state.method.isArray(post.column_id)) post.column_id = post.column_id.find((val) => val)
|
||||||
@ -651,32 +651,31 @@ export default {
|
|||||||
data: post,
|
data: post,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
commit("taskAddSuccess", result.data)
|
const {new_column, task} = result.data;
|
||||||
|
dispatch("saveColumn", new_column)
|
||||||
|
dispatch("saveTask", task)
|
||||||
resolve(result)
|
resolve(result)
|
||||||
}).catch(result => {
|
}).catch(reject);
|
||||||
reject(result)
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加子任务
|
* 添加子任务
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param commit
|
|
||||||
* @param data {task_id, name}
|
* @param data {task_id, name}
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
taskAddSub({dispatch, commit}, data) {
|
taskAddSub({dispatch}, data) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'project/task/addsub',
|
url: 'project/task/addsub',
|
||||||
data: data,
|
data: data,
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
commit("taskAddSuccess", result.data)
|
const {new_column, task} = result.data;
|
||||||
|
dispatch("saveColumn", new_column)
|
||||||
|
dispatch("saveTask", task)
|
||||||
resolve(result)
|
resolve(result)
|
||||||
}).catch(result => {
|
}).catch(reject);
|
||||||
reject(result)
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -684,11 +683,10 @@ export default {
|
|||||||
* 更新任务
|
* 更新任务
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param commit
|
|
||||||
* @param data
|
* @param data
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
taskUpdate({state, dispatch, commit}, data) {
|
taskUpdate({state, dispatch}, data) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
const post = state.method.cloneJSON(state.method.date2string(data));
|
const post = state.method.cloneJSON(state.method.date2string(data));
|
||||||
if (state.method.isArray(post.owner)) post.owner = post.owner.find((id) => id)
|
if (state.method.isArray(post.owner)) post.owner = post.owner.find((id) => id)
|
||||||
@ -698,42 +696,10 @@ export default {
|
|||||||
data: post,
|
data: post,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
const {data} = result;
|
dispatch("saveTask", result.data)
|
||||||
if (data.is_update_content === true) {
|
|
||||||
state.projectTaskContent[data.id] = post['content'];
|
|
||||||
if (data.id == state.projectOpenTask.id) {
|
|
||||||
state.projectOpenTask = Object.assign({}, state.projectOpenTask, {content: post['content']});
|
|
||||||
}
|
|
||||||
data.is_update_content = false;
|
|
||||||
}
|
|
||||||
commit("taskUpdateSuccess", data)
|
|
||||||
resolve(result)
|
resolve(result)
|
||||||
}).catch(result => {
|
}).catch(result => {
|
||||||
dispatch("getTaskBasic", post.task_id);
|
dispatch("getTaskOne", post.task_id);
|
||||||
reject(result)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除或归档任务
|
|
||||||
* @param dispatch
|
|
||||||
* @param commit
|
|
||||||
* @param data {task_id, type}
|
|
||||||
* @returns {Promise<unknown>}
|
|
||||||
*/
|
|
||||||
taskArchivedOrRemove({dispatch, commit}, data) {
|
|
||||||
let {task_id, type} = data;
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
dispatch("call", {
|
|
||||||
url: 'project/task/' + type,
|
|
||||||
data: {
|
|
||||||
task_id,
|
|
||||||
},
|
|
||||||
}).then(result => {
|
|
||||||
commit("taskDeleteSuccess", result.data);
|
|
||||||
resolve(result);
|
|
||||||
}).catch(result => {
|
|
||||||
reject(result)
|
reject(result)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -752,12 +718,15 @@ export default {
|
|||||||
}).then(result => {
|
}).then(result => {
|
||||||
state.taskPriority = result.data;
|
state.taskPriority = result.data;
|
||||||
resolve(result)
|
resolve(result)
|
||||||
}).catch(result => {
|
}).catch(reject);
|
||||||
reject(result)
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** *****************************************************************************************/
|
||||||
|
/** ************************************** 会话 **********************************************/
|
||||||
|
/** *****************************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新会话数据
|
* 更新会话数据
|
||||||
* @param state
|
* @param state
|
||||||
@ -980,10 +949,10 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state.method.isJson(data)) {
|
if (state.method.isJson(data)) {
|
||||||
state.projectDetail.project_column.some(({project_task}) => {
|
const task = state.tasks.find(({dialog_id}) => dialog_id === data.dialog_id);
|
||||||
const task = project_task.find(({dialog_id}) => dialog_id === data.dialog_id);
|
if (task) {
|
||||||
if (task) task.msg_num++;
|
task.msg_num++;
|
||||||
});
|
}
|
||||||
if (data.id && state.dialogMsgList.find(m => m.id == data.id)) {
|
if (data.id && state.dialogMsgList.find(m => m.id == data.id)) {
|
||||||
data = null;
|
data = null;
|
||||||
}
|
}
|
||||||
@ -1152,10 +1121,8 @@ export default {
|
|||||||
commit("dialogMoveToTop", dialog_id);
|
commit("dialogMoveToTop", dialog_id);
|
||||||
}
|
}
|
||||||
// 新增任务消息数量
|
// 新增任务消息数量
|
||||||
state.projectDetail.project_column.some(({project_task}) => {
|
const task = state.tasks.find(({dialog_id}) => dialog_id === data.dialog_id);
|
||||||
const task = project_task.find(({dialog_id}) => dialog_id === data.dialog_id);
|
|
||||||
if (task) task.msg_num++;
|
if (task) task.msg_num++;
|
||||||
});
|
|
||||||
// 新增总未读数
|
// 新增总未读数
|
||||||
if (data.userid !== state.userId) state.dialogMsgUnread++;
|
if (data.userid !== state.userId) state.dialogMsgUnread++;
|
||||||
}
|
}
|
||||||
|
19
resources/assets/js/store/getters.js
vendored
19
resources/assets/js/store/getters.js
vendored
@ -1,3 +1,20 @@
|
|||||||
export default {
|
export default {
|
||||||
|
taskData(state) {
|
||||||
|
let taskId = state.taskId;
|
||||||
|
if (taskId == 0) {
|
||||||
|
taskId = state.method.runNum(window.__taskId);
|
||||||
|
}
|
||||||
|
if (taskId > 0) {
|
||||||
|
window.__taskId = taskId;
|
||||||
|
const task = state.tasks.find(({id}) => id == taskId);
|
||||||
|
if (task) {
|
||||||
|
const content = state.taskContents.find(({task_id}) => task_id == taskId);
|
||||||
|
task.content = content ? content.content : '';
|
||||||
|
task.files = state.taskFiles.filter(({task_id}) => task_id == taskId);
|
||||||
|
task.sub_task = state.tasks.filter(({parent_id}) => parent_id == taskId);
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
170
resources/assets/js/store/mutations.js
vendored
170
resources/assets/js/store/mutations.js
vendored
@ -1,174 +1,4 @@
|
|||||||
export default {
|
export default {
|
||||||
/**
|
|
||||||
* 添加列表
|
|
||||||
* @param state
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
columnAddSuccess(state, data) {
|
|
||||||
if (state.projectDetail.id == data.project_id) {
|
|
||||||
let index = state.projectDetail.project_column.findIndex(({id}) => id === data.id);
|
|
||||||
if (index === -1) {
|
|
||||||
state.projectDetail.project_column.push(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新列表
|
|
||||||
* @param state
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
columnUpdateSuccess(state, data) {
|
|
||||||
if (state.projectDetail.id == data.project_id) {
|
|
||||||
let index = state.projectDetail.project_column.findIndex(({id}) => id === data.id);
|
|
||||||
if (index > -1) {
|
|
||||||
state.projectDetail.project_column.splice(index, 1, Object.assign({}, state.projectDetail.project_column[index], data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除列表
|
|
||||||
* @param state
|
|
||||||
* @param data {id, project_id}
|
|
||||||
*/
|
|
||||||
columnDeleteSuccess(state, data) {
|
|
||||||
if (state.projectDetail.id == data.project_id) {
|
|
||||||
let index = state.projectDetail.project_column.findIndex(({id}) => id === data.id);
|
|
||||||
if (index > -1) {
|
|
||||||
state.projectDetail.project_column.splice(index, 1);
|
|
||||||
}
|
|
||||||
this.dispatch("getProjectBasic", {id: data.project_id});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加任务
|
|
||||||
* @param state
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
taskAddSuccess(state, data) {
|
|
||||||
const {task, in_top, new_column} = data;
|
|
||||||
if (task.parent_id == 0) {
|
|
||||||
// 添加任务
|
|
||||||
if (state.projectDetail.id == task.project_id) {
|
|
||||||
if (new_column) {
|
|
||||||
state.projectDetail.project_column.push(new_column);
|
|
||||||
}
|
|
||||||
const column = state.projectDetail.project_column.find(({id}) => id === task.column_id);
|
|
||||||
if (column) {
|
|
||||||
let index = column.project_task.findIndex(({id}) => id === task.id)
|
|
||||||
if (index === -1) {
|
|
||||||
if (in_top) {
|
|
||||||
column.project_task.unshift(task);
|
|
||||||
} else {
|
|
||||||
column.project_task.push(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.dispatch("getProjectBasic", {id: task.project_id});
|
|
||||||
} else {
|
|
||||||
// 添加子任务
|
|
||||||
if (state.projectDetail.id == task.project_id) {
|
|
||||||
const column = state.projectDetail.project_column.find(({id}) => id === task.column_id);
|
|
||||||
if (column) {
|
|
||||||
const project_task = column.project_task.find(({id}) => id === task.parent_id)
|
|
||||||
if (project_task && project_task.sub_task) {
|
|
||||||
let index = project_task.sub_task.findIndex(({id}) => id === task.id)
|
|
||||||
if (index === -1) {
|
|
||||||
project_task.sub_task.push(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (task.parent_id == state.projectOpenTask.id) {
|
|
||||||
let index = state.projectOpenTask.sub_task.findIndex(({id}) => id === task.id)
|
|
||||||
if (index === -1) {
|
|
||||||
state.projectOpenTask.sub_task.push(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.dispatch("getTaskBasic", task.parent_id);
|
|
||||||
}
|
|
||||||
this.dispatch("saveTask", task);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新任务
|
|
||||||
* @param state
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
taskUpdateSuccess(state, data) {
|
|
||||||
if (data.parent_id) {
|
|
||||||
this.dispatch("getTaskBasic", data.parent_id);
|
|
||||||
}
|
|
||||||
if (data.is_update_complete === true) {
|
|
||||||
this.dispatch("getProjectBasic", {id: data.project_id});
|
|
||||||
}
|
|
||||||
if (data.is_update_content === true) {
|
|
||||||
this.dispatch("getTaskContent", data.id);
|
|
||||||
}
|
|
||||||
this.dispatch("saveTask", data);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务上传附件
|
|
||||||
* @param state
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
taskUploadSuccess(state, data) {
|
|
||||||
if (state.projectOpenTask.id == data.task_id) {
|
|
||||||
let index = state.projectOpenTask.files.findIndex(({id}) => id == data.id);
|
|
||||||
if (index > -1) {
|
|
||||||
state.projectOpenTask.files.splice(index, 1, data);
|
|
||||||
} else {
|
|
||||||
state.projectOpenTask.files.push(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state.projectDetail.project_column.some(({project_task}) => {
|
|
||||||
let task = project_task.find(({id}) => id === data.task_id);
|
|
||||||
if (task) {
|
|
||||||
if (!state.method.isJson(task._file_tmp)) task._file_tmp = {}
|
|
||||||
if (task._file_tmp[data.id] !== true) {
|
|
||||||
task._file_tmp[data.id] = true;
|
|
||||||
this.dispatch("saveTask", {
|
|
||||||
id: task.id,
|
|
||||||
file_num: task.file_num + 1,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除任务
|
|
||||||
* @param state
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
taskDeleteSuccess(state, data) {
|
|
||||||
const column = state.projectDetail.project_column.find(({id}) => id === data.column_id);
|
|
||||||
if (column) {
|
|
||||||
let index = column.project_task.findIndex(({id}) => id === data.id);
|
|
||||||
if (index > -1) {
|
|
||||||
column.project_task.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (data.id == state.projectOpenTask.id) {
|
|
||||||
state.projectOpenTask = Object.assign({}, state.projectOpenTask, {_show: false});
|
|
||||||
} else if (data.parent_id == state.projectOpenTask.id && state.projectOpenTask.sub_task) {
|
|
||||||
let index = state.projectOpenTask.sub_task.findIndex(({id}) => id === data.id);
|
|
||||||
if (index > -1) {
|
|
||||||
state.projectOpenTask.sub_task.splice(index, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let index = state.calendarTask.findIndex(({id}) => id === data.id);
|
|
||||||
if (index > -1) {
|
|
||||||
state.calendarTask.splice(index, 1)
|
|
||||||
}
|
|
||||||
this.dispatch("getProjectBasic", {id: data.project_id});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会话消息列表
|
* 会话消息列表
|
||||||
* @param state
|
* @param state
|
||||||
|
22
resources/assets/js/store/state.js
vendored
22
resources/assets/js/store/state.js
vendored
@ -249,7 +249,9 @@ state.ajaxWsListener = [];
|
|||||||
// 数据缓存
|
// 数据缓存
|
||||||
state.cacheUserBasic = state.method.getStorageJson("cacheUserBasic");
|
state.cacheUserBasic = state.method.getStorageJson("cacheUserBasic");
|
||||||
state.cacheDialogMsg = state.method.getStorageJson("cacheDialogMsg");
|
state.cacheDialogMsg = state.method.getStorageJson("cacheDialogMsg");
|
||||||
state.cacheProjectList = state.method.getStorageArray("cacheProjectList");
|
state.cacheProjects = state.method.getStorageArray("cacheProjects");
|
||||||
|
state.cacheColumns = state.method.getStorageArray("cacheColumns");
|
||||||
|
state.cacheTasks = state.method.getStorageArray("cacheTasks");
|
||||||
|
|
||||||
// 会员信息
|
// 会员信息
|
||||||
state.userInfo = state.method.getStorageJson("userInfo");
|
state.userInfo = state.method.getStorageJson("userInfo");
|
||||||
@ -268,15 +270,15 @@ state.wsReadTimeout = null;
|
|||||||
state.wsReadWaitList = [];
|
state.wsReadWaitList = [];
|
||||||
|
|
||||||
// 项目任务
|
// 项目任务
|
||||||
state.projectLoad = 0;
|
state.projects = [];
|
||||||
state.projectList = state.cacheProjectList;
|
state.projectStatistics = {};
|
||||||
state.projectDetail = {id: 0, project_column: [], project_user: []};
|
state.columns = [];
|
||||||
state.projectOpenTask = {_show: false, id: 0, task_user: [], task_tag: []};
|
state.tasks = [];
|
||||||
state.projectTaskStatistics = {};
|
state.taskContents = [];
|
||||||
state.projectTaskContent = {};
|
state.taskFiles = [];
|
||||||
state.projectTaskFiles = {};
|
state.taskLogs = [];
|
||||||
state.projectSubTask = {};
|
state.projectId = 0;
|
||||||
state.calendarTask = [];
|
state.taskId = 0;
|
||||||
|
|
||||||
// 会话聊天
|
// 会话聊天
|
||||||
state.dialogId = 0;
|
state.dialogId = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user