no message
This commit is contained in:
parent
c478dbeeaa
commit
b936e61429
@ -643,11 +643,11 @@ class ProjectController extends AbstractController
|
|||||||
* {post} 添加任务
|
* {post} 添加任务
|
||||||
*
|
*
|
||||||
* @apiParam {Number} project_id 项目ID
|
* @apiParam {Number} project_id 项目ID
|
||||||
* @apiParam {Number} [column_id] 列表ID,留空取第一个
|
* @apiParam {mixed} [column_id] 列表ID,任意值自动创建,留空取第一个
|
||||||
* @apiParam {String} name 任务描述
|
* @apiParam {String} name 任务描述
|
||||||
* @apiParam {String} [content] 任务详情
|
* @apiParam {String} [content] 任务详情
|
||||||
* @apiParam {Array} [times] 计划时间(格式:开始时间,结束时间;如:2020-01-01 00:00,2020-01-01 23:59)
|
* @apiParam {Array} [times] 计划时间(格式:开始时间,结束时间;如:2020-01-01 00:00,2020-01-01 23:59)
|
||||||
* @apiParam {Number} [owner] 负责人,留空为自己
|
* @apiParam {mixed} [owner] 负责人,留空为自己
|
||||||
* @apiParam {Array} [subtasks] 子任务(格式:[{name,owner,times}])
|
* @apiParam {Array} [subtasks] 子任务(格式:[{name,owner,times}])
|
||||||
* @apiParam {Number} [top] 添加的任务排到列表最前面
|
* @apiParam {Number} [top] 添加的任务排到列表最前面
|
||||||
*/
|
*/
|
||||||
@ -729,7 +729,9 @@ class ProjectController extends AbstractController
|
|||||||
* @apiParam {String} [color] 任务描述(子任务不支持)
|
* @apiParam {String} [color] 任务描述(子任务不支持)
|
||||||
* @apiParam {String} [content] 任务详情(子任务不支持)
|
* @apiParam {String} [content] 任务详情(子任务不支持)
|
||||||
* @apiParam {Array} [times] 计划时间(格式:开始时间,结束时间;如:2020-01-01 00:00,2020-01-01 23:59)
|
* @apiParam {Array} [times] 计划时间(格式:开始时间,结束时间;如:2020-01-01 00:00,2020-01-01 23:59)
|
||||||
* @apiParam {Number} [owner] 修改负责人
|
* @apiParam {mixed} [owner] 修改负责人
|
||||||
|
*
|
||||||
|
* @apiParam {String|false} [complete_at] 完成时间(如:2020-01-01 00:00,false表示未完成)
|
||||||
*/
|
*/
|
||||||
public function task__update()
|
public function task__update()
|
||||||
{
|
{
|
||||||
@ -746,6 +748,7 @@ class ProjectController extends AbstractController
|
|||||||
$content = Base::getPostValue('content');
|
$content = Base::getPostValue('content');
|
||||||
$times = Base::getPostValue('times');
|
$times = Base::getPostValue('times');
|
||||||
$owner = Base::getPostValue('owner');
|
$owner = Base::getPostValue('owner');
|
||||||
|
$complete_at = Base::getPostValue('complete_at');
|
||||||
// 任务
|
// 任务
|
||||||
$task = ProjectTask::whereId($task_id)->first();
|
$task = ProjectTask::whereId($task_id)->first();
|
||||||
if (empty($task)) {
|
if (empty($task)) {
|
||||||
@ -761,6 +764,20 @@ class ProjectController extends AbstractController
|
|||||||
return Base::retError('项目不存在或不在成员列表内');
|
return Base::retError('项目不存在或不在成员列表内');
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
if ($complete_at === false || $complete_at === "false") {
|
||||||
|
// 标记未完成
|
||||||
|
if (!$task->complete_at) {
|
||||||
|
return Base::retError('未完成任务');
|
||||||
|
}
|
||||||
|
$result = $task->completeTask(null);
|
||||||
|
} elseif (Base::isDate($complete_at)) {
|
||||||
|
// 标记已完成
|
||||||
|
if ($task->complete_at) {
|
||||||
|
return Base::retError('任务已完成');
|
||||||
|
}
|
||||||
|
$result = $task->completeTask(Carbon::now());
|
||||||
|
} else {
|
||||||
|
// 更新任务
|
||||||
$result = $task->updateTask([
|
$result = $task->updateTask([
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'color' => $color,
|
'color' => $color,
|
||||||
@ -768,8 +785,9 @@ class ProjectController extends AbstractController
|
|||||||
'times' => $times,
|
'times' => $times,
|
||||||
'owner' => $owner,
|
'owner' => $owner,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
if (Base::isSuccess($result)) {
|
if (Base::isSuccess($result)) {
|
||||||
$result['data'] = ProjectTask::with(['taskUser', 'taskTag'])->whereId($task->id)->first();
|
$result['data'] = $task->toArray();
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -310,10 +310,35 @@ class ProjectTask extends AbstractModel
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标记已完成、未完成
|
||||||
|
* @param Carbon|null $complete_at 完成时间
|
||||||
|
* @return array|bool
|
||||||
|
*/
|
||||||
|
public function completeTask($complete_at)
|
||||||
|
{
|
||||||
|
return AbstractModel::transaction(function () use ($complete_at) {
|
||||||
|
if ($complete_at === null) {
|
||||||
|
// 标记未完成
|
||||||
|
$this->complete_at = null;
|
||||||
|
} else {
|
||||||
|
// 标记已完成
|
||||||
|
if ($this->parent_id == 0) {
|
||||||
|
if (self::whereParentId($this->id)->whereCompleteAt(null)->exists()) {
|
||||||
|
return Base::retError('子任务未完成');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->complete_at = $complete_at;
|
||||||
|
}
|
||||||
|
$this->save();
|
||||||
|
return Base::retSuccess('修改成功');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改任务
|
* 修改任务
|
||||||
* @param $params
|
* @param $params
|
||||||
* @return array|bool
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function updateTask($params)
|
public function updateTask($params)
|
||||||
{
|
{
|
||||||
|
@ -1947,15 +1947,25 @@ class Base
|
|||||||
return $_A["__static_input_content"][$key] ?? $default;
|
return $_A["__static_input_content"][$key] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $key
|
||||||
|
* @param null $default
|
||||||
|
* @return array|mixed|string|null
|
||||||
|
*/
|
||||||
public static function getPostValue($key, $default = null)
|
public static function getPostValue($key, $default = null)
|
||||||
{
|
{
|
||||||
$value = self::newTrim(self::getContentValue($key, $default));
|
$value = self::getContentValue($key, $default);
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
$value = self::newTrim(Request::post($key, $default));
|
$value = Request::post($key, $default);
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $key
|
||||||
|
* @param null $default
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public static function getPostInt($key, $default = null)
|
public static function getPostInt($key, $default = null)
|
||||||
{
|
{
|
||||||
return intval(self::getPostValue($key, $default));
|
return intval(self::getPostValue($key, $default));
|
||||||
|
@ -133,9 +133,14 @@
|
|||||||
@command="dropTask(item, $event)">
|
@command="dropTask(item, $event)">
|
||||||
<Icon type="ios-more" />
|
<Icon type="ios-more" />
|
||||||
<EDropdownMenu slot="dropdown" class="project-list-more-dropdown-menu">
|
<EDropdownMenu slot="dropdown" class="project-list-more-dropdown-menu">
|
||||||
<EDropdownItem command="complete">
|
<EDropdownItem v-if="item.complete_at" command="uncomplete">
|
||||||
|
<div class="item red">
|
||||||
|
<Icon type="md-checkmark-circle-outline" />{{$L('标记未完成')}}
|
||||||
|
</div>
|
||||||
|
</EDropdownItem>
|
||||||
|
<EDropdownItem v-else command="complete">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<Icon type="md-create" />{{$L('完成')}}
|
<Icon type="md-radio-button-off" />{{$L('完成')}}
|
||||||
</div>
|
</div>
|
||||||
</EDropdownItem>
|
</EDropdownItem>
|
||||||
<EDropdownItem command="delete">
|
<EDropdownItem command="delete">
|
||||||
@ -143,7 +148,7 @@
|
|||||||
<Icon type="md-trash" />{{$L('删除')}}
|
<Icon type="md-trash" />{{$L('删除')}}
|
||||||
</div>
|
</div>
|
||||||
</EDropdownItem>
|
</EDropdownItem>
|
||||||
<EDropdownItem divided disabled>{{$L('颜色')}}</EDropdownItem>
|
<EDropdownItem divided disabled>{{$L('背景色')}}</EDropdownItem>
|
||||||
<EDropdownItem v-for="(c, k) in taskList" :key="k" :command="c">
|
<EDropdownItem v-for="(c, k) in taskList" :key="k" :command="c">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<i class="iconfont" :style="{color:c.color||'#f9f9f9'}" v-html="c.color == column.color ? '' : ''"></i>{{$L(c.name)}}
|
<i class="iconfont" :style="{color:c.color||'#f9f9f9'}" v-html="c.color == column.color ? '' : ''"></i>{{$L(c.name)}}
|
||||||
@ -669,8 +674,8 @@ export default {
|
|||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
$A.messageSuccess(msg);
|
$A.messageSuccess(msg);
|
||||||
} else {
|
} else {
|
||||||
$A.modalError(msg);
|
|
||||||
this.$store.commit('getProjectDetail', this.projectDetail.id);
|
this.$store.commit('getProjectDetail', this.projectDetail.id);
|
||||||
|
$A.modalError(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -828,10 +833,15 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
success: ({ret, data, msg}) => {
|
success: ({ret, data, msg}) => {
|
||||||
if (ret !== 1) {
|
if (ret === 1) {
|
||||||
|
Object.keys(data).forEach(key => {
|
||||||
|
this.$set(column, key, data[key]);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
Object.keys(updata).forEach(key => {
|
Object.keys(updata).forEach(key => {
|
||||||
this.$set(column, key, backup[key]);
|
this.$set(column, key, backup[key]);
|
||||||
});
|
});
|
||||||
|
$A.modalError(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -881,10 +891,19 @@ export default {
|
|||||||
|
|
||||||
dropTask(task, command) {
|
dropTask(task, command) {
|
||||||
if (command === 'complete') {
|
if (command === 'complete') {
|
||||||
// 完成
|
if (task.complete_at) return;
|
||||||
|
this.updateTask(task, {
|
||||||
|
complete_at: $A.formatDate("Y-m-d H:i:s")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if (command === 'uncomplete') {
|
||||||
|
if (!task.complete_at) return;
|
||||||
|
this.updateTask(task, {
|
||||||
|
complete_at: false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
else if (command === 'delete') {
|
else if (command === 'delete') {
|
||||||
// 删除
|
this.removeTask(task);
|
||||||
}
|
}
|
||||||
else if (command.name) {
|
else if (command.name) {
|
||||||
this.updateTask(task, {
|
this.updateTask(task, {
|
||||||
@ -918,15 +937,64 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
success: ({ret, data, msg}) => {
|
success: ({ret, data, msg}) => {
|
||||||
if (ret !== 1) {
|
if (ret === 1) {
|
||||||
|
Object.keys(data).forEach(key => {
|
||||||
|
this.$set(task, key, data[key]);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
Object.keys(updata).forEach(key => {
|
Object.keys(updata).forEach(key => {
|
||||||
this.$set(task, key, backup[key]);
|
this.$set(task, key, backup[key]);
|
||||||
});
|
});
|
||||||
|
$A.modalError(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeTask(task) {
|
||||||
|
$A.modalConfirm({
|
||||||
|
title: '删除任务',
|
||||||
|
content: '你确定要删除任务【' + task.name + '】吗?',
|
||||||
|
loading: true,
|
||||||
|
onOk: () => {
|
||||||
|
if (task.loading === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$set(task, 'loading', true);
|
||||||
|
//
|
||||||
|
$A.apiAjax({
|
||||||
|
url: 'project/task/delete',
|
||||||
|
data: {
|
||||||
|
task_id: task.id,
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
this.$set(task, 'loading', false);
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
this.$Modal.remove();
|
||||||
|
$A.modalAlert('网络繁忙,请稍后再试!');
|
||||||
|
},
|
||||||
|
success: ({ret, data, msg}) => {
|
||||||
|
this.$Modal.remove();
|
||||||
|
if (ret === 1) {
|
||||||
|
$A.messageSuccess(msg);
|
||||||
|
let column = this.projectDetail.project_column.find(({id}) => id === column.id);
|
||||||
|
if (column) {
|
||||||
|
let index = column.project_task.findIndex(({id}) => id === task.id);
|
||||||
|
if (index > -1) {
|
||||||
|
column.project_task.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$store.commit('getProjectDetail', this.projectDetail.id);
|
||||||
|
}else{
|
||||||
|
$A.modalError(msg, 301);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
onSetting() {
|
onSetting() {
|
||||||
this.settingLoad++;
|
this.settingLoad++;
|
||||||
$A.apiAjax({
|
$A.apiAjax({
|
||||||
|
6
resources/assets/sass/project-list.scss
vendored
6
resources/assets/sass/project-list.scss
vendored
@ -599,6 +599,12 @@
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&.red {
|
||||||
|
color: #f00;
|
||||||
|
> i {
|
||||||
|
color: #f00;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&.column-more {
|
&.column-more {
|
||||||
|
1
resources/assets/sass/task-add.scss
vendored
1
resources/assets/sass/task-add.scss
vendored
@ -40,6 +40,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-left: 24px;
|
margin-left: 24px;
|
||||||
|
height: 34px;
|
||||||
> li {
|
> li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin-left: 3px;
|
margin-left: 3px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user