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);
}
$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;
$task->pushMsg('update', $data);
return Base::retSuccess('修改成功', $data);

View File

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

View File

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

View File

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

View File

@ -140,7 +140,8 @@
</div>
<div class="desc">
<TEditor
v-model="taskDetail.content"
ref="desc"
:value="taskContent"
:plugins="taskPlugins"
:options="taskOptions"
:option-full="taskOptionFull"
@ -262,12 +263,12 @@
</li>
</ul>
</FormItem>
<FormItem v-if="hasFile">
<FormItem v-if="fileList.length > 0">
<div class="item-label" slot="label">
<i class="iconfont">&#xe6e6;</i>{{$L('附件')}}
</div>
<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"/>
<Loading v-else class="file-load"/>
<a class="file-name" :href="file.path||'javascript:;'" target="_blank">{{file.name}}</a>
@ -282,14 +283,14 @@
</li>
</ul>
</FormItem>
<FormItem v-if="hasSubtask || addsubForce">
<FormItem v-if="subList.length > 0 || addsubForce">
<div class="item-label" slot="label">
<i class="iconfont">&#xe6f0;</i>{{$L('子任务')}}
</div>
<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 :class="['item-content', taskDetail.sub_task.length === 0 ? 'nosub' : '']">
<ul :class="['item-content', subList.length === 0 ? 'nosub' : '']">
<li>
<Input
v-if="addsubShow"
@ -465,7 +466,37 @@ export default {
},
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() {
const {innerHeight, taskDetail} = this;
@ -519,16 +550,6 @@ export default {
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() {
const {taskDetail} = this;
if (!$A.isArray(taskDetail.task_user)) {
@ -569,14 +590,14 @@ export default {
name: '截止时间',
});
}
if (!($A.isArray(taskDetail.files) && taskDetail.files.length > 0)) {
if (this.fileList.length == 0) {
list.push({
command: 'file',
icon: '&#xe6e6;',
name: '附件',
});
}
if (!($A.isArray(taskDetail.sub_task) && taskDetail.sub_task.length > 0)) {
if (this.subList.length == 0) {
list.push({
command: 'subtask',
icon: '&#xe6f0;',
@ -756,6 +777,12 @@ export default {
case 'times':
this.$set(this.taskDetail, 'times', [params.start_at, params.end_at])
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};

View File

@ -60,7 +60,7 @@
</div>
</Col>
<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 span="3" class="row-priority">
<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"
@command="dropTask"/>
</div>
<TaskAddSimple v-if="fastAddTask" :parent-id="parentId" row-mode/>
<TaskAddSimple v-if="fastAddTask || parentId > 0" :parent-id="parentId" row-mode/>
</div>
</template>
@ -149,11 +149,15 @@ export default {
},
computed: {
...mapState(['tasks']),
...mapState(['tasks', 'columns']),
subTask() {
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: {
columnName(column_id) {
const column = this.columns.find(({id}) => id == column_id)
return column ? column.name : '';
},
dropTask(task, command) {
this.$emit("command", task, command)
},

View File

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

View File

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

View File

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