no message

This commit is contained in:
kuaifan 2021-06-24 15:53:20 +08:00
parent 8847d1d10a
commit 6db6528be1
6 changed files with 84 additions and 19 deletions

View File

@ -656,6 +656,33 @@ class ProjectController extends AbstractController
return Base::retSuccess('success', $task->taskFile);
}
/**
* 删除任务文件(限:项目、任务负责人)
*
* @apiParam {Number} file_id 文件ID
*/
public function task__filedelete()
{
User::auth();
//
$file_id = intval(Request::input('file_id'));
//
$file = ProjectTaskFile::find($file_id);
if (empty($file)) {
return Base::retError('文件不存在或已被删除');
}
//
$task = ProjectTask::userTask($file->task_id, [], true, $project);
if (!$task->owner && !$project->owner) {
return Base::retError('仅限项目或任务负责人操作');
}
//
$task->pushMsg('filedelete', $file);
$file->delete();
//
return Base::retSuccess('success', $file);
}
/**
* {post} 添加任务
*

View File

@ -106,7 +106,6 @@ export default {
autoInterval: null,
dialogDrag: false,
dialogReady: false,
msgText: '',
msgNew: 0,
@ -164,20 +163,12 @@ export default {
dialogId: {
handler() {
this.dialogReady = false;
this.autoBottom = true;
this.msgNew = 0;
this.topId = -1;
this.getMsg();
},
immediate: true
},
dialogs: {
handler() {
this.getMsg();
},
deep: true
}
},
@ -186,13 +177,6 @@ export default {
if (!this.dialogId) {
return;
}
if (this.dialogs.findIndex(({id}) => id == this.dialogId) === -1) {
return;
}
if (this.dialogReady) {
return;
}
this.dialogReady = true;
this.$store.dispatch("getDialogMsgs", this.dialogId);
},

View File

@ -285,6 +285,7 @@
<Loading v-else class="file-load"/>
<a class="file-name" :href="file.path||'javascript:;'" target="_blank">{{file.name}}</a>
<div class="file-size">{{$A.bytesToSize(file.size)}}</div>
<i class="iconfont file-delete" @click="deleteFile(file.id)">&#xe6ea;</i>
</li>
</ul>
<ul class="item-content">
@ -1089,6 +1090,20 @@ export default {
}).catch(({msg}) => {
$A.modalError(msg);
});
},
deleteFile(file_id) {
this.$store.dispatch("forgetTaskFile", file_id)
//
this.$store.dispatch("call", {
url: 'project/task/filedelete',
data: {
file_id,
},
}).catch(({msg}) => {
$A.modalError(msg);
this.$store.dispatch("getTaskFiles", this.taskDetail.id)
});
}
}
}

View File

@ -105,9 +105,12 @@ export default {
dialogList() {
const {dialogActive, dialogKey} = this;
if (dialogActive == '' && dialogKey == '') {
return this.dialogs;
return this.dialogs.filter(({name}) => name !== undefined);
}
return this.dialogs.filter(({name, type, group_type, last_msg}) => {
if (name === undefined) {
return false;
}
if (dialogActive) {
switch (dialogActive) {
case 'project':

View File

@ -874,6 +874,19 @@ export default {
});
},
/**
* 忘记任务文件
* @param state
* @param dispatch
* @param file_id
*/
forgetTaskFile({state, dispatch}, file_id) {
let index = state.taskFiles.findIndex(({id}) => id == file_id)
if (index > -1) {
state.taskFiles.splice(index, 1)
}
},
/**
* 打开任务详情页
* @param state
@ -1169,9 +1182,12 @@ export default {
* @param dialog_id
*/
getDialogMsgs({state, dispatch}, dialog_id) {
const dialog = state.dialogs.find(({id}) => id == dialog_id);
let dialog = state.dialogs.find(({id}) => id == dialog_id);
if (!dialog) {
return;
dialog = {
id: dialog_id,
};
state.dialogs.push(dialog);
}
if (dialog.loading) {
return;
@ -1369,6 +1385,7 @@ export default {
// 更新最后消息
dispatch("updateDialogLastMsg", data);
if (mode === "add") {
let dialog = state.dialogs.find(({id}) => id == data.dialog_id);
// 更新对话列表
if (dialog) {
// 新增未读数
@ -1443,6 +1460,9 @@ export default {
case 'upload':
dispatch("getTaskFiles", data.task_id)
break;
case 'filedelete':
dispatch("forgetTaskFile", data.id)
break;
case 'archived':
case 'delete':
dispatch("forgetTask", data.id)

View File

@ -180,6 +180,22 @@
font-size: 12px;
color: #bbbbbb;
}
.file-delete {
display: none;
padding-left: 12px;
font-size: 14px;
cursor: pointer;
color: #aaaaaa;
transition: color 0.3s;
&:hover {
color: #ff0000;
}
}
&:hover {
.file-delete {
display: inline-block;
}
}
}
}
&.subtask {