perf: 归档任务可以搜索
This commit is contained in:
parent
0236897d1f
commit
72b732a55d
@ -662,14 +662,14 @@ class ProjectController extends AbstractController
|
||||
$project_id = intval(Request::input('project_id'));
|
||||
$type = Request::input('type', 'add');
|
||||
//
|
||||
$project = Project::userProject($project_id, false, true);
|
||||
$project = Project::userProject($project_id, $type == 'add', true);
|
||||
//
|
||||
if ($type == 'recovery') {
|
||||
$project->archivedProject(null);
|
||||
} elseif ($type == 'add') {
|
||||
$project->archivedProject(Carbon::now());
|
||||
}
|
||||
return Base::retSuccess('设置成功', ['id' => $project->id]);
|
||||
return Base::retSuccess('操作成功', ['id' => $project->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -692,7 +692,7 @@ class ProjectController extends AbstractController
|
||||
//
|
||||
$project_id = intval(Request::input('project_id'));
|
||||
//
|
||||
$project = Project::userProject($project_id, true, true);
|
||||
$project = Project::userProject($project_id, null, true);
|
||||
//
|
||||
$project->deleteProject();
|
||||
return Base::retSuccess('删除成功', ['id' => $project->id]);
|
||||
@ -854,8 +854,12 @@ class ProjectController extends AbstractController
|
||||
* @apiGroup project
|
||||
* @apiName task__lists
|
||||
*
|
||||
* @apiParam {Object} [keys] 搜索条件
|
||||
* - keys.name: 任务名称
|
||||
* @apiParam {Number} [project_id] 项目ID
|
||||
* @apiParam {Number} [parent_id] 主任务ID(填写此项时 project_id 参数无效)
|
||||
* @apiParam {Number} [parent_id] 主任务ID(project_id && parent_id ≤ 0 时 仅查询自己参与的任务)
|
||||
* - 大于0:指定主任务下的子任务
|
||||
* - 等于-1:表示仅主任务
|
||||
* @apiParam {String} [name] 任务描述关键词
|
||||
* @apiParam {Array} [time] 指定时间范围,如:['2020-12-12', '2020-12-30']
|
||||
* @apiParam {String} [time_before] 指定时间之前,如:2020-12-30 00:00:00(填写此项时 time 参数无效)
|
||||
@ -888,15 +892,30 @@ class ProjectController extends AbstractController
|
||||
$time_before = Request::input('time_before');
|
||||
$complete = Request::input('complete', 'all');
|
||||
$archived = Request::input('archived', 'no');
|
||||
$keys = Request::input('keys');
|
||||
$sorts = Request::input('sorts');
|
||||
$keys = is_array($keys) ? $keys : [];
|
||||
$sorts = is_array($sorts) ? $sorts : [];
|
||||
//
|
||||
if ($keys['name']) {
|
||||
$builder->where("project_tasks.name", "like", "%{$keys['name']}%");
|
||||
}
|
||||
//
|
||||
$scopeAll = false;
|
||||
if ($parent_id > 0) {
|
||||
ProjectTask::userTask($parent_id);
|
||||
$builder->allData()->where('project_tasks.parent_id', $parent_id);
|
||||
} elseif ($project_id > 0) {
|
||||
$scopeAll = true;
|
||||
$builder->where('project_tasks.parent_id', $parent_id);
|
||||
} elseif ($parent_id === -1) {
|
||||
$builder->where('project_tasks.parent_id', 0);
|
||||
}
|
||||
if ($project_id > 0) {
|
||||
Project::userProject($project_id);
|
||||
$builder->allData()->where('project_tasks.project_id', $project_id);
|
||||
$scopeAll = true;
|
||||
$builder->where('project_tasks.project_id', $project_id);
|
||||
}
|
||||
if ($scopeAll) {
|
||||
$builder->allData();
|
||||
} else {
|
||||
$builder->authData();
|
||||
}
|
||||
@ -1345,7 +1364,7 @@ class ProjectController extends AbstractController
|
||||
$task_id = intval(Request::input('task_id'));
|
||||
$type = Request::input('type', 'add');
|
||||
//
|
||||
$task = ProjectTask::userTask($task_id, false, true);
|
||||
$task = ProjectTask::userTask($task_id, $type == 'add', true);
|
||||
//
|
||||
if ($task->parent_id > 0) {
|
||||
return Base::retError('子任务不支持此功能');
|
||||
@ -1356,7 +1375,7 @@ class ProjectController extends AbstractController
|
||||
} elseif ($type == 'add') {
|
||||
$task->archivedTask(Carbon::now());
|
||||
}
|
||||
return Base::retSuccess('设置成功', ['id' => $task->id]);
|
||||
return Base::retSuccess('操作成功', ['id' => $task->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1379,7 +1398,7 @@ class ProjectController extends AbstractController
|
||||
//
|
||||
$task_id = intval(Request::input('task_id'));
|
||||
//
|
||||
$task = ProjectTask::userTask($task_id, true, true);
|
||||
$task = ProjectTask::userTask($task_id, null, true);
|
||||
//
|
||||
$task->deleteTask();
|
||||
return Base::retSuccess('删除成功', ['id' => $task->id]);
|
||||
|
@ -900,7 +900,7 @@ class ProjectTask extends AbstractModel
|
||||
/**
|
||||
* 获取任务(会员有任务权限 或 会员存在项目内)
|
||||
* @param int $task_id
|
||||
* @param bool $archived true:仅限未归档, false:不限制
|
||||
* @param bool $archived true:仅限未归档, false:不限制, null:不限制
|
||||
* @param int|bool $mustOwner 0|false:不限制, 1|true:限制任务或项目负责人, 2:已有负责人才限制任务或项目负责人
|
||||
* @param array $with
|
||||
* @return self
|
||||
@ -915,6 +915,9 @@ class ProjectTask extends AbstractModel
|
||||
if ($archived === true && $task->archived_at != null) {
|
||||
throw new ApiException('任务已归档', [ 'task_id' => $task_id ], -4002);
|
||||
}
|
||||
if ($archived === false && $task->archived_at == null) {
|
||||
throw new ApiException('任务未归档', [ 'task_id' => $task_id ]);
|
||||
}
|
||||
//
|
||||
try {
|
||||
$project = Project::userProject($task->project_id, $archived);
|
||||
|
@ -1,6 +1,12 @@
|
||||
<template>
|
||||
<div class="project-archived">
|
||||
<div class="archived-title">{{$L('归档的项目')}}</div>
|
||||
<div class="archived-title">
|
||||
{{$L('归档的项目')}}
|
||||
<div class="title-icon">
|
||||
<Loading v-if="loadIng > 0"/>
|
||||
<Icon v-else type="ios-refresh" @click="refresh"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-container auto">
|
||||
<ul>
|
||||
<li>
|
||||
@ -113,7 +119,7 @@ export default {
|
||||
align: 'center',
|
||||
width: 100,
|
||||
render: (h, params) => {
|
||||
let show = h('Poptip', {
|
||||
const recoveryNode = h('Poptip', {
|
||||
props: {
|
||||
title: this.$L('你确定要还原归档吗?'),
|
||||
confirm: true,
|
||||
@ -130,33 +136,50 @@ export default {
|
||||
this.recovery(params.row);
|
||||
}
|
||||
},
|
||||
}, [
|
||||
h('Button', {
|
||||
}, this.$L('还原'));
|
||||
const deleteNode = h('Poptip', {
|
||||
props: {
|
||||
type: 'primary',
|
||||
size: 'small'
|
||||
title: this.$L('你确定要删除项目吗?'),
|
||||
confirm: true,
|
||||
transfer: true,
|
||||
placement: 'left',
|
||||
},
|
||||
style: {
|
||||
fontSize: '12px',
|
||||
marginLeft: '6px',
|
||||
fontSize: '13px',
|
||||
cursor: 'pointer',
|
||||
color: '#f00',
|
||||
},
|
||||
}, this.$L('还原')),
|
||||
]);
|
||||
on: {
|
||||
'on-ok': () => {
|
||||
this.delete(params.row);
|
||||
}
|
||||
},
|
||||
}, this.$L('删除'));
|
||||
return h('TableAction', {
|
||||
props: {
|
||||
column: params.column
|
||||
}
|
||||
}, [
|
||||
show,
|
||||
recoveryNode,
|
||||
deleteNode,
|
||||
]);
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
refresh() {
|
||||
this.keys = [];
|
||||
this.getLists();
|
||||
},
|
||||
|
||||
getLists() {
|
||||
this.loadIng++;
|
||||
this.$store.dispatch("call", {
|
||||
url: 'project/lists',
|
||||
data: {
|
||||
keys: this.keys,
|
||||
archived: 'yes',
|
||||
page: Math.max(this.page, 1),
|
||||
pagesize: Math.max($A.runNum(this.pageSize), 20),
|
||||
@ -202,6 +225,20 @@ export default {
|
||||
this.loadIng--;
|
||||
this.getLists();
|
||||
})
|
||||
},
|
||||
|
||||
delete(row) {
|
||||
this.list = this.list.filter(({id}) => id != row.id);
|
||||
this.loadIng++;
|
||||
this.$store.dispatch("removeProject", row.id).then(({msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.loadIng--;
|
||||
this.getLists();
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg);
|
||||
this.loadIng--;
|
||||
this.getLists();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,11 @@
|
||||
<Timeline>
|
||||
<TimelineItem v-for="(item, index) in items.lists" :key="index">
|
||||
<div slot="dot" class="logs-dot">
|
||||
<UserAvatar :userid="item.userid" :size="18"/>
|
||||
<UserAvatar v-if="item.userid" :userid="item.userid" :size="18"/>
|
||||
<EAvatar v-else :size="18">A</EAvatar>
|
||||
</div>
|
||||
<div class="log-summary">
|
||||
<span class="log-creator">{{item.user.nickname}}</span>
|
||||
<span class="log-creator">{{item.user ? item.user.nickname : $L('系统')}}</span>
|
||||
<span class="log-text">{{$L(item.detail)}}</span>
|
||||
<span class="log-time">{{item.time.ymd}} {{item.time.segment}} {{item.time.hi}}</span></div>
|
||||
</TimelineItem>
|
||||
|
@ -1,7 +1,28 @@
|
||||
<template>
|
||||
<div class="task-archived">
|
||||
<div class="archived-title">{{$L('归档的任务')}}</div>
|
||||
<Table :columns="columns" :data="list" :no-data-text="$L(noText)"></Table>
|
||||
<div class="archived-title">
|
||||
{{$L('归档的任务')}}
|
||||
<div class="title-icon">
|
||||
<Loading v-if="loadIng > 0"/>
|
||||
<Icon v-else type="ios-refresh" @click="refresh"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-container auto">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="search-label">
|
||||
{{$L("任务名")}}
|
||||
</div>
|
||||
<div class="search-content">
|
||||
<Input v-model="keys.name" clearable/>
|
||||
</div>
|
||||
</li>
|
||||
<li class="search-button">
|
||||
<Button :loading="loadIng > 0" type="primary" icon="ios-search" @click="getLists">{{$L('搜索')}}</Button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<Table :columns="columns" :data="list" :loading="loadIng > 0" :no-data-text="$L(noText)"></Table>
|
||||
<Page
|
||||
class="page-container"
|
||||
:total="total"
|
||||
@ -30,6 +51,8 @@ export default {
|
||||
return {
|
||||
loadIng: 0,
|
||||
|
||||
keys: {},
|
||||
|
||||
columns: [],
|
||||
list: [],
|
||||
|
||||
@ -56,6 +79,12 @@ export default {
|
||||
methods: {
|
||||
initLanguage() {
|
||||
this.columns = [
|
||||
{
|
||||
title: this.$L('ID'),
|
||||
minWidth: 50,
|
||||
maxWidth: 70,
|
||||
key: 'id',
|
||||
},
|
||||
{
|
||||
title: this.$L('任务名称'),
|
||||
key: 'name',
|
||||
@ -96,7 +125,7 @@ export default {
|
||||
align: 'center',
|
||||
width: 100,
|
||||
render: (h, params) => {
|
||||
let show = h('Poptip', {
|
||||
const recoveryNode = h('Poptip', {
|
||||
props: {
|
||||
title: this.$L('你确定要还原归档吗?'),
|
||||
confirm: true,
|
||||
@ -114,17 +143,43 @@ export default {
|
||||
}
|
||||
},
|
||||
}, this.$L('还原'));
|
||||
const deleteNode = h('Poptip', {
|
||||
props: {
|
||||
title: this.$L('你确定要删除任务吗?'),
|
||||
confirm: true,
|
||||
transfer: true,
|
||||
placement: 'left',
|
||||
},
|
||||
style: {
|
||||
marginLeft: '6px',
|
||||
fontSize: '13px',
|
||||
cursor: 'pointer',
|
||||
color: '#f00',
|
||||
},
|
||||
on: {
|
||||
'on-ok': () => {
|
||||
this.delete(params.row);
|
||||
}
|
||||
},
|
||||
}, this.$L('删除'));
|
||||
return h('TableAction', {
|
||||
props: {
|
||||
column: params.column
|
||||
}
|
||||
}, [
|
||||
show,
|
||||
recoveryNode,
|
||||
deleteNode,
|
||||
]);
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
refresh() {
|
||||
this.keys = {};
|
||||
this.getLists()
|
||||
},
|
||||
|
||||
getLists() {
|
||||
if (!this.projectId) {
|
||||
return;
|
||||
@ -133,7 +188,9 @@ export default {
|
||||
this.$store.dispatch("call", {
|
||||
url: 'project/task/lists',
|
||||
data: {
|
||||
keys: this.keys,
|
||||
project_id: this.projectId,
|
||||
parent_id: -1,
|
||||
archived: 'yes',
|
||||
sorts: {
|
||||
archived_at: 'desc'
|
||||
@ -173,15 +230,30 @@ export default {
|
||||
task_id: row.id,
|
||||
type: 'recovery'
|
||||
},
|
||||
}).then(() => {
|
||||
}).then(({msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.loadIng--;
|
||||
this.getLists();
|
||||
this.$store.dispatch("getTaskOne", row.id);
|
||||
this.$store.dispatch("openTask", row);
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg);
|
||||
this.loadIng--;
|
||||
this.getLists();
|
||||
})
|
||||
},
|
||||
|
||||
delete(row) {
|
||||
this.list = this.list.filter(({id}) => id != row.id);
|
||||
this.loadIng++;
|
||||
this.$store.dispatch("removeTask", row.id).then(({msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.loadIng--;
|
||||
this.getLists();
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg);
|
||||
this.loadIng--;
|
||||
this.getLists();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,15 @@
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
margin-bottom: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.title-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
margin-left: 4px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@
|
||||
font-size: 17px;
|
||||
width: 30px;
|
||||
height: 32px;
|
||||
color: #888888;
|
||||
color: #aaaaaa;
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
transform: scale(1) !important;
|
||||
|
@ -12,5 +12,15 @@
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
margin-bottom: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.title-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
margin-left: 4px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user