no message

This commit is contained in:
kuaifan 2021-06-21 13:15:41 +08:00
parent c294807b28
commit 301e532cf9
9 changed files with 107 additions and 49 deletions

View File

@ -747,7 +747,8 @@ class ProjectController extends AbstractController
$task->updateTask($data, $updateContent); $task->updateTask($data, $updateContent);
} }
$data = $task->toArray(); $data = $task->toArray();
$data['is_update_complete'] = $updateComplete; $data['is_subtask'] = $task->parent_id > 0;
$data['is_update_complete'] = $task->parent_id == 0 && $updateComplete;
$data['is_update_content'] = $updateContent; $data['is_update_content'] = $updateContent;
$task->pushMsg('update', $data); $task->pushMsg('update', $data);
return Base::retSuccess('修改成功', $data); return Base::retSuccess('修改成功', $data);

View File

@ -381,24 +381,26 @@ class ProjectTask extends AbstractModel
} }
// 负责人 // 负责人
if (Arr::exists($data, 'owner')) { if (Arr::exists($data, 'owner')) {
$row = ProjectTaskUser::whereTaskId($this->id)->whereOwner(1)->first();
$owner = intval($data['owner']); $owner = intval($data['owner']);
if ($row->userid != $owner) { $row = ProjectTaskUser::whereTaskId($this->id)->whereUserid($owner)->first();
if (empty($this->useridInTheProject($owner))) { if (empty($row)) {
throw new ApiException('请选择正确的负责人'); $row = ProjectTaskUser::createInstance([
}
$row->owner = 0;
$row->save();
ProjectTaskUser::updateInsert([
'project_id' => $this->project_id, 'project_id' => $this->project_id,
'task_id' => $this->id, 'task_id' => $this->id,
'userid' => $owner, 'userid' => $owner,
], [
'owner' => 1, 'owner' => 1,
]); ]);
$this->syncDialogUser(); } else {
$this->addLog("修改{任务}负责人为会员ID" . $owner); $row->owner = 1;
} }
$row->save();
if ($this->parent_id) {
ProjectTaskUser::whereTaskId($this->id)->where('id', '!=', $row->id)->delete();
} else {
ProjectTaskUser::whereTaskId($this->id)->where('id', '!=', $row->id)->update([ 'owner' => 0 ]);
}
$this->syncDialogUser();
$this->addLog("修改{任务}负责人为会员ID" . $row->userid);
} }
// 计划时间 // 计划时间
if (Arr::exists($data, 'times')) { if (Arr::exists($data, 'times')) {

View File

@ -86,7 +86,7 @@
return {} return {}
} }
return { return {
'transform': 'scale(' + (size / 32) + ')', 'transform': 'scale(' + Math.min(1, size / 32) + ')',
} }
}, },

View File

@ -627,7 +627,6 @@ export default {
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.sortDisabled = false; this.sortDisabled = false;
this.$store.state.tasks = this.tasks.filter(({project_id}) => project_id != this.projectId);
this.$store.dispatch("getTasks", {project_id: this.projectId}) this.$store.dispatch("getTasks", {project_id: this.projectId})
}); });
}, },

View File

@ -140,7 +140,8 @@
</div> </div>
<div class="desc"> <div class="desc">
<TEditor <TEditor
v-model="taskDetail.content" ref="desc"
:value="taskContent"
:plugins="taskPlugins" :plugins="taskPlugins"
:options="taskOptions" :options="taskOptions"
:option-full="taskOptionFull" :option-full="taskOptionFull"
@ -262,12 +263,12 @@
</li> </li>
</ul> </ul>
</FormItem> </FormItem>
<FormItem v-if="hasFile"> <FormItem v-if="fileList.length > 0">
<div class="item-label" slot="label"> <div class="item-label" slot="label">
<i class="iconfont">&#xe6e6;</i>{{$L('附件')}} <i class="iconfont">&#xe6e6;</i>{{$L('附件')}}
</div> </div>
<ul class="item-content file"> <ul class="item-content file">
<li v-for="file in taskDetail.files"> <li v-for="file in fileList">
<img v-if="file.id" class="file-ext" :src="file.thumb"/> <img v-if="file.id" class="file-ext" :src="file.thumb"/>
<Loading v-else class="file-load"/> <Loading v-else class="file-load"/>
<a class="file-name" :href="file.path||'javascript:;'" target="_blank">{{file.name}}</a> <a class="file-name" :href="file.path||'javascript:;'" target="_blank">{{file.name}}</a>
@ -282,14 +283,14 @@
</li> </li>
</ul> </ul>
</FormItem> </FormItem>
<FormItem v-if="hasSubtask || addsubForce"> <FormItem v-if="subList.length > 0 || addsubForce">
<div class="item-label" slot="label"> <div class="item-label" slot="label">
<i class="iconfont">&#xe6f0;</i>{{$L('子任务')}} <i class="iconfont">&#xe6f0;</i>{{$L('子任务')}}
</div> </div>
<ul class="item-content subtask"> <ul class="item-content subtask">
<TaskDetail v-for="(task, key) in taskDetail.sub_task" :key="key" :open-task="task"/> <TaskDetail v-for="(task, key) in subList" :key="key" :open-task="task"/>
</ul> </ul>
<ul :class="['item-content', taskDetail.sub_task.length === 0 ? 'nosub' : '']"> <ul :class="['item-content', subList.length === 0 ? 'nosub' : '']">
<li> <li>
<Input <Input
v-if="addsubShow" v-if="addsubShow"
@ -465,7 +466,37 @@ export default {
}, },
computed: { computed: {
...mapState(['userId', 'taskPriority']), ...mapState(['userId', 'taskId', 'tasks', 'taskContents', 'taskFiles', 'taskPriority']),
taskContent() {
if (!this.taskId) {
return "";
}
let content = this.taskContents.find(({task_id}) => task_id == this.taskId)
return content ? content.content : ''
},
fileList() {
if (!this.taskId) {
return [];
}
return this.taskFiles.filter(({task_id}) => {
return task_id == this.taskId
}).sort((a, b) => {
return a.id - b.id;
});
},
subList() {
if (!this.taskId) {
return [];
}
return this.tasks.filter(({parent_id}) => {
return parent_id == this.taskId
}).sort((a, b) => {
return a.id - b.id;
});
},
scrollerStyle() { scrollerStyle() {
const {innerHeight, taskDetail} = this; const {innerHeight, taskDetail} = this;
@ -519,16 +550,6 @@ export default {
return string; return string;
}, },
hasFile() {
const {taskDetail} = this;
return $A.isArray(taskDetail.files) && taskDetail.files.length > 0;
},
hasSubtask() {
const {taskDetail} = this;
return $A.isArray(taskDetail.sub_task) && taskDetail.sub_task.length > 0;
},
getOwner() { getOwner() {
const {taskDetail} = this; const {taskDetail} = this;
if (!$A.isArray(taskDetail.task_user)) { if (!$A.isArray(taskDetail.task_user)) {
@ -569,14 +590,14 @@ export default {
name: '截止时间', name: '截止时间',
}); });
} }
if (!($A.isArray(taskDetail.files) && taskDetail.files.length > 0)) { if (this.fileList.length == 0) {
list.push({ list.push({
command: 'file', command: 'file',
icon: '&#xe6e6;', icon: '&#xe6e6;',
name: '附件', name: '附件',
}); });
} }
if (!($A.isArray(taskDetail.sub_task) && taskDetail.sub_task.length > 0)) { if (this.subList.length == 0) {
list.push({ list.push({
command: 'subtask', command: 'subtask',
icon: '&#xe6f0;', icon: '&#xe6f0;',
@ -756,6 +777,12 @@ export default {
case 'times': case 'times':
this.$set(this.taskDetail, 'times', [params.start_at, params.end_at]) this.$set(this.taskDetail, 'times', [params.start_at, params.end_at])
break; break;
case 'content':
if (this.$refs.desc.getContent() == this.taskContent) {
return;
}
this.$set(this.taskDetail, 'content', this.$refs.desc.getContent())
break;
} }
// //
let dataJson = {task_id: this.taskDetail.id}; let dataJson = {task_id: this.taskDetail.id};

View File

@ -60,7 +60,7 @@
</div> </div>
</Col> </Col>
<Col span="3" class="row-column"> <Col span="3" class="row-column">
<div v-if="item.parent_id === 0" class="task-column">{{item.column_name}}</div> <div v-if="item.parent_id === 0" class="task-column">{{columnName(item.column_id)}}</div>
</Col> </Col>
<Col span="3" class="row-priority"> <Col span="3" class="row-priority">
<TaskPriority v-if="item.p_name && item.parent_id === 0" :backgroundColor="item.p_color">{{item.p_name}}</TaskPriority> <TaskPriority v-if="item.p_name && item.parent_id === 0" :backgroundColor="item.p_color">{{item.p_name}}</TaskPriority>
@ -91,7 +91,7 @@
:open-key="openKey" :open-key="openKey"
@command="dropTask"/> @command="dropTask"/>
</div> </div>
<TaskAddSimple v-if="fastAddTask" :parent-id="parentId" row-mode/> <TaskAddSimple v-if="fastAddTask || parentId > 0" :parent-id="parentId" row-mode/>
</div> </div>
</template> </template>
@ -149,11 +149,15 @@ export default {
}, },
computed: { computed: {
...mapState(['tasks']), ...mapState(['tasks', 'columns']),
subTask() { subTask() {
return function(task_id) { return function(task_id) {
return this.tasks.filter(({parent_id}) => parent_id == task_id); return this.tasks.filter(({parent_id}) => {
return parent_id == task_id
}).sort((a, b) => {
return a.id - b.id;
});
} }
}, },
@ -171,6 +175,11 @@ export default {
}, },
}, },
methods: { methods: {
columnName(column_id) {
const column = this.columns.find(({id}) => id == column_id)
return column ? column.name : '';
},
dropTask(task, command) { dropTask(task, command) {
this.$emit("command", task, command) this.$emit("command", task, command)
}, },

View File

@ -24,11 +24,13 @@ export default {
this.project_id = route.params.id; this.project_id = route.params.id;
}, },
project_id(id) { project_id(id) {
if (id > 0) {
this.$store.state.projectId = $A.runNum(id); this.$store.state.projectId = $A.runNum(id);
this.$store.dispatch("getProjectOne", id); this.$store.dispatch("getProjectOne", id);
this.$store.dispatch("getColumns", id); this.$store.dispatch("getColumns", id);
this.$store.dispatch("getTasks", {project_id: id}); this.$store.dispatch("getTasks", {project_id: id});
} }
}
}, },
} }
</script> </script>

View File

@ -439,11 +439,13 @@ export default {
/** /**
* 忘记列表数据 * 忘记列表数据
* @param state * @param state
* @param dispatch
* @param column_id * @param column_id
*/ */
forgetColumn({state}, column_id) { forgetColumn({state, dispatch}, column_id) {
let index = state.columns.findIndex(({id}) => id == column_id); let index = state.columns.findIndex(({id}) => id == column_id);
if (index > -1) { if (index > -1) {
dispatch('getProjectOne', state.columns[index].project_id)
state.columns.splice(index, 1); state.columns.splice(index, 1);
} }
state.method.setStorage("cacheColumns", state.cacheColumns = state.columns); state.method.setStorage("cacheColumns", state.cacheColumns = state.columns);
@ -493,6 +495,7 @@ export default {
resolve(result) resolve(result)
}).catch(e => { }).catch(e => {
!e.ret && console.error(e); !e.ret && console.error(e);
reject(e);
}); });
}); });
}, },
@ -521,6 +524,16 @@ export default {
} else { } else {
state.tasks.push(data); state.tasks.push(data);
} }
//
if (data.is_subtask) {
dispatch("getTaskOne", data.parent_id);
}
if (data.is_update_complete) {
dispatch("getProjectOne", data.project_id);
}
if (data.is_update_content) {
dispatch("getTaskContent", data.id);
}
} }
state.method.setStorage("cacheTasks", state.cacheTasks = state.tasks); state.method.setStorage("cacheTasks", state.cacheTasks = state.tasks);
}, },
@ -528,11 +541,14 @@ export default {
/** /**
* 忘记任务数据 * 忘记任务数据
* @param state * @param state
* @param dispatch
* @param task_id * @param task_id
*/ */
forgetTask({state}, task_id) { forgetTask({state, dispatch}, task_id) {
let index = state.tasks.findIndex(({id}) => id == task_id); let index = state.tasks.findIndex(({id}) => id == task_id);
if (index > -1) { if (index > -1) {
dispatch("getTaskOne", state.tasks[index].parent_id)
dispatch('getProjectOne', state.tasks[index].project_id)
state.tasks.splice(index, 1); state.tasks.splice(index, 1);
} }
if (state.taskId == task_id) { if (state.taskId == task_id) {
@ -665,6 +681,7 @@ export default {
resolve(result) resolve(result)
}).catch(e => { }).catch(e => {
!e.ret && console.error(e); !e.ret && console.error(e);
reject(e);
}); });
}); });
}, },
@ -695,6 +712,7 @@ export default {
resolve(result) resolve(result)
}).catch(e => { }).catch(e => {
!e.ret && console.error(e); !e.ret && console.error(e);
reject(e);
}); });
}); });
}, },
@ -736,9 +754,11 @@ export default {
const {new_column, task} = result.data; const {new_column, task} = result.data;
dispatch("saveColumn", new_column) dispatch("saveColumn", new_column)
dispatch("saveTask", task) dispatch("saveTask", task)
dispatch("getProjectOne", task.project_id);
resolve(result) resolve(result)
}).catch(e => { }).catch(e => {
!e.ret && console.error(e); !e.ret && console.error(e);
reject(e);
}); });
}); });
}, },
@ -755,12 +775,13 @@ export default {
url: 'project/task/addsub', url: 'project/task/addsub',
data: data, data: data,
}).then(result => { }).then(result => {
const {new_column, task} = result.data; const {task} = result.data;
dispatch("saveColumn", new_column)
dispatch("saveTask", task) dispatch("saveTask", task)
dispatch("getTaskOne", task.parent_id);
resolve(result) resolve(result)
}).catch(e => { }).catch(e => {
!e.ret && console.error(e); !e.ret && console.error(e);
reject(e);
}); });
}); });
}, },
@ -807,6 +828,7 @@ export default {
resolve(result) resolve(result)
}).catch(e => { }).catch(e => {
!e.ret && console.error(e); !e.ret && console.error(e);
reject(e);
}); });
}); });
}, },

View File

@ -46,10 +46,6 @@ export default {
window.__taskId = taskId; window.__taskId = taskId;
const task = state.tasks.find(({id}) => id == taskId); const task = state.tasks.find(({id}) => id == taskId);
if (task) { 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 task;
} }
} }