mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-18 13:28:12 +00:00
fix: 添加任务时不设置时间无须提示任务冲突
This commit is contained in:
parent
d54c86cec9
commit
81957c9396
@ -1111,7 +1111,7 @@ class ProjectController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* @api {get} api/project/task/easylists 20. 任务列表-简单的
|
* @api {get} api/project/task/easylists 20. 任务列表-简单的
|
||||||
*
|
*
|
||||||
* @apiDescription 需要token身份
|
* @apiDescription 需要token身份,主要用于判断是否有时间冲突的任务
|
||||||
* @apiVersion 1.0.0
|
* @apiVersion 1.0.0
|
||||||
* @apiGroup project
|
* @apiGroup project
|
||||||
* @apiName task__easylists
|
* @apiName task__easylists
|
||||||
@ -1130,23 +1130,24 @@ class ProjectController extends AbstractController
|
|||||||
//
|
//
|
||||||
$taskid = trim(Request::input('taskid'));
|
$taskid = trim(Request::input('taskid'));
|
||||||
$userid = Request::input('userid');
|
$userid = Request::input('userid');
|
||||||
$timerange = Request::input('timerange');
|
$timerange = TimeRange::parse(Request::input('timerange'));
|
||||||
//
|
//
|
||||||
$list = ProjectTask::with(['taskUser'])
|
$list = ProjectTask::with(['taskUser'])
|
||||||
->select('projects.name as project_name', 'project_tasks.id', 'project_tasks.name', 'project_tasks.start_at', 'project_tasks.end_at')
|
->select([
|
||||||
|
'projects.name as project_name',
|
||||||
|
'project_tasks.id',
|
||||||
|
'project_tasks.name',
|
||||||
|
'project_tasks.start_at',
|
||||||
|
'project_tasks.end_at'
|
||||||
|
])
|
||||||
->join('projects','project_tasks.project_id','=','projects.id')
|
->join('projects','project_tasks.project_id','=','projects.id')
|
||||||
->leftJoin('project_task_users', function ($query) {
|
->leftJoin('project_task_users', function ($query) {
|
||||||
$query->on('project_tasks.id', '=', 'project_task_users.task_id')->where('project_task_users.owner', '=', 1);
|
$query->on('project_tasks.id', '=', 'project_task_users.task_id')->where('project_task_users.owner', '=', 1);
|
||||||
})
|
})
|
||||||
->whereIn('project_task_users.userid', is_array($userid) ? $userid : explode(',', $userid) )
|
->whereIn('project_task_users.userid', is_array($userid) ? $userid : explode(',', $userid) )
|
||||||
->when(!empty($timerange), function ($query) use ($timerange) {
|
->when($timerange->isExist(), function ($query) use ($timerange) {
|
||||||
if (!is_array($timerange)) {
|
$query->where('project_tasks.start_at', '<=', $timerange->lastTime()->endOfDay());
|
||||||
$timerange = explode(',', $timerange);
|
$query->where('project_tasks.end_at', '>=', $timerange->firstTime()->startOfDay());
|
||||||
}
|
|
||||||
if (Base::isDateOrTime($timerange[0]) && Base::isDateOrTime($timerange[1])) {
|
|
||||||
$query->where('project_tasks.start_at', '<=', Carbon::parse($timerange[1])->endOfDay());
|
|
||||||
$query->where('project_tasks.end_at', '>=', Carbon::parse($timerange[0])->startOfDay());
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
->when(!empty($taskid), function ($query) use ($taskid) {
|
->when(!empty($taskid), function ($query) use ($taskid) {
|
||||||
$query->where('project_tasks.id', "!=", $taskid);
|
$query->where('project_tasks.id', "!=", $taskid);
|
||||||
|
|||||||
@ -15,12 +15,17 @@ class TimeRange
|
|||||||
public function __construct($data)
|
public function __construct($data)
|
||||||
{
|
{
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
$range = $this->format($data['timerange']);
|
$keys = array_keys($data);
|
||||||
if ($data['updated_at'] || $data['at_after']) {
|
if (count($keys) === 2 && $keys[0] === 0 && $keys[1] === 1) {
|
||||||
$range[0] = $data['updated_at'] ?: $data['at_after'];
|
$range = $data;
|
||||||
}
|
} else {
|
||||||
if ($data['deleted_at']) {
|
$range = $this->format($data['timerange']);
|
||||||
$range[1] = $data['deleted_at'];
|
if ($data['updated_at'] || $data['at_after']) {
|
||||||
|
$range[0] = $data['updated_at'] ?: $data['at_after'];
|
||||||
|
}
|
||||||
|
if ($data['deleted_at']) {
|
||||||
|
$range[1] = $data['deleted_at'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$range = $this->format($data);
|
$range = $this->format($data);
|
||||||
@ -34,6 +39,30 @@ class TimeRange
|
|||||||
$this->deleted = $deleted ? Carbon::parse($deleted)->setTimezone($timezone) : null;
|
$this->deleted = $deleted ? Carbon::parse($deleted)->setTimezone($timezone) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Carbon|null
|
||||||
|
*/
|
||||||
|
public function firstTime(): ?Carbon
|
||||||
|
{
|
||||||
|
return $this->updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Carbon|null
|
||||||
|
*/
|
||||||
|
public function lastTime(): ?Carbon
|
||||||
|
{
|
||||||
|
return $this->deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isExist(): bool
|
||||||
|
{
|
||||||
|
return $this->updated && $this->deleted;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $timerange
|
* @param $timerange
|
||||||
* - 格式1:2021-01-01 00:00:00,2021-01-01 23:59:59
|
* - 格式1:2021-01-01 00:00:00,2021-01-01 23:59:59
|
||||||
|
|||||||
@ -502,7 +502,7 @@ export default {
|
|||||||
this.addData = Object.assign({}, this.addData, data);
|
this.addData = Object.assign({}, this.addData, data);
|
||||||
},
|
},
|
||||||
|
|
||||||
async onAdd(again,affirm=false) {
|
async onAdd(again, affirm = false) {
|
||||||
if (!this.addData.name) {
|
if (!this.addData.name) {
|
||||||
$A.messageError("任务描述不能为空");
|
$A.messageError("任务描述不能为空");
|
||||||
return;
|
return;
|
||||||
@ -512,7 +512,7 @@ export default {
|
|||||||
|
|
||||||
// 存在任务提示
|
// 存在任务提示
|
||||||
if (!affirm && this.addData.owner.length > 0) {
|
if (!affirm && this.addData.owner.length > 0) {
|
||||||
this.$refs['taskExistTipsRef'].isExistTask({
|
this.$refs.taskExistTipsRef.isExistTask({
|
||||||
userids: this.addData.owner,
|
userids: this.addData.owner,
|
||||||
timerange: this.addData.times
|
timerange: this.addData.times
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
|||||||
@ -1048,7 +1048,7 @@ export default {
|
|||||||
if (!desc) {
|
if (!desc) {
|
||||||
return `请输入修改备注`
|
return `请输入修改备注`
|
||||||
}
|
}
|
||||||
this.updateParams = Object.assign(params, { desc })
|
this.updateParams = Object.assign(params, {desc})
|
||||||
if (params.start_at && params.end_at && this.$refs.taskExistTipsRef) {
|
if (params.start_at && params.end_at && this.$refs.taskExistTipsRef) {
|
||||||
this.$refs.taskExistTipsRef.isExistTask({
|
this.$refs.taskExistTipsRef.isExistTask({
|
||||||
taskid: this.taskDetail.id,
|
taskid: this.taskDetail.id,
|
||||||
|
|||||||
@ -69,9 +69,13 @@ export default {
|
|||||||
return string
|
return string
|
||||||
},
|
},
|
||||||
|
|
||||||
isExistTask({ userids, timerange, taskid }) {
|
isExistTask({userids, timerange, taskid}) {
|
||||||
this.isExist = false;
|
this.isExist = false;
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
|
if ($A.isArray(timerange) && (!timerange[0] || !timerange[1])) {
|
||||||
|
resolve(this.isExist)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'project/task/easylists',
|
url: 'project/task/easylists',
|
||||||
data: {
|
data: {
|
||||||
@ -80,7 +84,7 @@ export default {
|
|||||||
taskid: taskid
|
taskid: taskid
|
||||||
},
|
},
|
||||||
method: 'get',
|
method: 'get',
|
||||||
}).then(({ data }) => {
|
}).then(({data}) => {
|
||||||
if (data.data.length > 0) {
|
if (data.data.length > 0) {
|
||||||
this.show = true;
|
this.show = true;
|
||||||
let taskObj = {}
|
let taskObj = {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user