no message

This commit is contained in:
kuaifan 2021-06-14 00:10:45 +08:00
parent 74fa8ff9a1
commit 76eac54165
7 changed files with 187 additions and 31 deletions

View File

@ -790,16 +790,68 @@ class ProjectController extends AbstractController
return $result;
}
/**
* 添加子任务
*
* @apiParam {Number} task_id 任务ID
* @apiParam {String} name 任务描述
*/
public function task__addsub()
{
$user = User::authE();
if (Base::isError($user)) {
return $user;
} else {
$user = User::IDE($user['data']);
}
//
$task_id = intval(Request::input('task_id'));
$name = Request::input('name');
// 任务
$task = ProjectTask::whereId($task_id)->first();
if (empty($task)) {
return Base::retError('任务不存在');
}
// 项目
$project = Project::select($this->projectSelect)
->join('project_users', 'projects.id', '=', 'project_users.project_id')
->where('projects.id', $task->project_id)
->where('project_users.userid', $user->userid)
->first();
if (empty($project)) {
return Base::retError('项目不存在或不在成员列表内');
}
//
$result = ProjectTask::addTask([
'name' => $name,
'parent_id' => $task->id,
'project_id' => $task->project_id,
'column_id' => $task->column_id,
]);
if (Base::isSuccess($result)) {
$result['data'] = [
'new_column' => null,
'in_top' => 0,
'task' => ProjectTask::with(['taskUser', 'taskTag'])->find($result['data']['id']),
];
}
return $result;
}
/**
* {post} 修改任务、子任务
*
* @apiParam {Number} task_id 任务ID
* @apiParam {String} [name] 任务描述
* @apiParam {String} [color] 任务描述(子任务不支持)
* @apiParam {String} [content] 任务详情(子任务不支持)
* @apiParam {Array} [times] 计划时间(格式:开始时间,结束时间2020-01-01 00:00,2020-01-01 23:59
* @apiParam {Number} [owner] 修改负责人
* @apiParam {Array} [assist] 修改协助人员
* @apiParam {String} [content] 任务详情(子任务不支持)
* @apiParam {String} [color] 背景色(子任务不支持)
* @apiParam {Array} [assist] 修改协助人员(子任务不支持)
*
* @apiParam {Number} [p_level] 优先级相关(子任务不支持)
* @apiParam {String} [p_name] 优先级相关(子任务不支持)
* @apiParam {String} [p_color] 优先级相关(子任务不支持)
*
* @apiParam {String|false} [complete_at] 完成时间2020-01-01 00:00false表示未完成
*/

View File

@ -334,9 +334,6 @@ class ProjectTask extends AbstractModel
$subtask['parent_id'] = $task->id;
$subtask['project_id'] = $task->project_id;
$subtask['column_id'] = $task->column_id;
$subtask['p_level'] = $task->p_level;
$subtask['p_name'] = $task->p_name;
$subtask['p_color'] = $task->p_color;
$result = self::addTask($subtask);
if (Base::isError($result)) {
return $result;
@ -384,26 +381,6 @@ class ProjectTask extends AbstractModel
]);
}
}
// 协助人员
if (Arr::exists($data, 'assist')) {
$array = [];
$assist = is_array($data['assist']) ? $data['assist'] : [$data['assist']];
foreach ($assist as $uid) {
if (intval($uid) == 0) continue;
if (ProjectTaskUser::whereTaskId($this->id)->whereUserid($uid)->whereOwner(1)->exists()) continue;
//
if (!ProjectTaskUser::whereTaskId($this->id)->whereUserid($uid)->where('owner', '!=', 1)->exists()) {
ProjectTaskUser::createInstance([
'project_id' => $this->parent_id,
'task_id' => $this->id,
'userid' => $uid,
'owner' => 0,
])->save();
}
$array[] = $uid;
}
ProjectTaskUser::whereTaskId($this->id)->where('owner', '!=', 1)->whereNotIn('userid', $array)->delete();
}
// 计划时间
if (Arr::exists($data, 'times')) {
$this->start_at = null;
@ -419,6 +396,26 @@ class ProjectTask extends AbstractModel
}
// 以下紧顶级任务可修改
if ($this->parent_id === 0) {
// 协助人员
if (Arr::exists($data, 'assist')) {
$array = [];
$assist = is_array($data['assist']) ? $data['assist'] : [$data['assist']];
foreach ($assist as $uid) {
if (intval($uid) == 0) continue;
if (ProjectTaskUser::whereTaskId($this->id)->whereUserid($uid)->whereOwner(1)->exists()) continue;
//
if (!ProjectTaskUser::whereTaskId($this->id)->whereUserid($uid)->where('owner', '!=', 1)->exists()) {
ProjectTaskUser::createInstance([
'project_id' => $this->parent_id,
'task_id' => $this->id,
'userid' => $uid,
'owner' => 0,
])->save();
}
$array[] = $uid;
}
ProjectTaskUser::whereTaskId($this->id)->where('owner', '!=', 1)->whereNotIn('userid', $array)->delete();
}
// 背景色
if (Arr::exists($data, 'color')) {
$this->color = $data['color'];

View File

@ -122,7 +122,7 @@
v-for="item in panelTask(column.project_task)"
:class="['task-item task-draggable', item.complete_at ? 'complete' : '']"
:style="item.color ? {backgroundColor: item.color} : {}"
@click="$store.dispatch('openTask', item.id)">
@click="openTask(item)">
<div :class="['task-head', item.desc ? 'has-desc' : '']">
<div class="task-title"><pre>{{item.name}}</pre></div>
<div class="task-menu" @click.stop="">
@ -961,6 +961,14 @@ export default {
}
},
openTask(task) {
if (task.parent_id > 0) {
this.$store.dispatch('openTask', task.parent_id)
} else {
this.$store.dispatch('openTask', task.id)
}
},
toggleBoolean(type) {
this.$store.dispatch('toggleBoolean', type);
},

View File

@ -252,7 +252,16 @@
<ul class="item-content subtask">
<TaskDetail v-for="(task, key) in taskDetail.sub_task" :key="key" :open-task="task"/>
<li>
<div class="add-button" @click="">
<Input
v-if="addsubShow"
v-model="addsubName"
ref="addsub"
class="add-input"
:placeholder="$L('+ 输入子任务,回车添加子任务')"
:icon="addsubLoad > 0 ? 'ios-loading' : ''"
@on-blur="addsubChackClose"
@on-keydown="addsubKeydown"/>
<div v-else class="add-button" @click="addsubOpen">
<i class="iconfont">&#xe6f2;</i>{{$L('添加子任务')}}
</div>
</li>
@ -337,6 +346,10 @@ export default {
assistData: {},
assistLoad: 0,
addsubShow: false,
addsubName: "",
addsubLoad: 0,
nowTime: Math.round(new Date().getTime() / 1000),
nowInterval: null,
@ -812,6 +825,49 @@ export default {
});
this.timeOpen = false;
},
addsubOpen() {
this.addsubShow = true;
this.$nextTick(() => {
this.$refs.addsub.focus()
});
},
addsubChackClose() {
if (this.addsubName == '') {
this.addsubShow = false;
}
},
addsubKeydown(e) {
if (e.keyCode === 13) {
if (e.shiftKey) {
return;
}
e.preventDefault();
this.onAddsub();
}
},
onAddsub() {
if (this.addsubName == '') {
$A.messageSuccess('任务描述不能为空');
return;
}
this.addsubLoad++;
this.$store.dispatch("taskAddSub", {
task_id: this.taskDetail.id,
name: this.addsubName,
}).then(({msg}) => {
this.addsubLoad--;
this.addsubName = "";
$A.messageSuccess(msg);
}).catch(({msg}) => {
this.addsubLoad--;
$A.modalError(msg);
});
}
}
}
</script>

View File

@ -50,7 +50,7 @@
</template>
</EDropdownMenu>
</EDropdown>
<div class="item-title" @click="$store.dispatch('openTask', item.id)">{{item.name}}</div>
<div class="item-title" @click="openTask(item)">{{item.name}}</div>
<div v-if="item.sub_num > 0" class="item-sub-num" @click="getSublist(item)">
<Icon type="md-git-merge" />
{{item.sub_complete}}/{{item.sub_num}}
@ -168,6 +168,14 @@ export default {
});
},
openTask(task) {
if (task.parent_id > 0) {
this.$store.dispatch('openTask', task.parent_id)
} else {
this.$store.dispatch('openTask', task.id)
}
},
formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000),
string = '';
@ -202,7 +210,7 @@ export default {
else if (minutes > 0) duration = this.formatBit(minutes) + ":" + this.formatBit(seconds);
else if (seconds > 0) duration = this.formatBit(seconds) + "s";
return duration;
},
}
}
}
</script>

View File

@ -570,6 +570,30 @@ export default {
});
},
/**
* 添加子任务
* @param state
* @param dispatch
* @param data {task_id, name}
* @returns {Promise<unknown>}
*/
taskAddSub({state, dispatch}, data) {
return new Promise(function (resolve, reject) {
dispatch("call", {
url: 'project/task/addsub',
data: data,
}).then(result => {
if (data.task_id == state.projectOpenTask.id) {
state.projectOpenTask.sub_task.push(result.data.task);
}
dispatch('taskOne', data.task_id);
resolve(result)
}).catch(result => {
reject(result)
});
});
},
/**
* 更新任务
* @param state

View File

@ -170,6 +170,9 @@
> li {
align-items: flex-start;
margin-bottom: 4px;
&:last-child {
margin-bottom: -6px;
}
.subtask-icon {
width: 16px;
height: 26px;
@ -241,12 +244,19 @@
height: 26px;
cursor: pointer;
}
.ivu-icon-ios-loading {
animation: icon-loading-load 0.6s infinite linear;
}
}
}
}
}
.add {
margin-top: 12px;
margin-bottom: 10px;
}
.add-input {
margin-top: 6px;
}
.add-button {
cursor: pointer;
@ -254,6 +264,7 @@
display: flex;
align-items: center;
margin-top: 6px;
height: 32px;
> i {
font-size: 14px;
padding-right: 8px;
@ -284,7 +295,7 @@
flex: 1;
display: flex;
flex-direction: column;
margin-top: 32px;
margin-top: 22px;
position: relative;
.head {
display: flex;