no message

This commit is contained in:
kuaifan 2021-06-14 11:55:30 +08:00
parent 804211973f
commit be2f4d65b8
24 changed files with 350 additions and 248 deletions

View File

@ -10,6 +10,7 @@ use App\Models\ProjectTask;
use App\Models\ProjectTaskFile; use App\Models\ProjectTaskFile;
use App\Models\ProjectUser; use App\Models\ProjectUser;
use App\Models\User; use App\Models\User;
use App\Models\WebSocketDialog;
use App\Module\Base; use App\Module\Base;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
@ -973,6 +974,64 @@ class ProjectController extends AbstractController
} }
} }
/**
* 创建/获取聊天室
*
* @apiParam {Number} task_id 任务ID
*/
public function task__dialog()
{
$user = User::authE();
if (Base::isError($user)) {
return $user;
} else {
$user = User::IDE($user['data']);
}
//
$task_id = intval(Request::input('task_id'));
// 任务
$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('项目不存在或不在成员列表内');
}
//
if ($task->parent_id > 0) {
return Base::retError('子任务不支持此功能');
}
//
return AbstractModel::transaction(function() use ($task) {
if (empty($task->dialog_id)) {
$task->lockForUpdate();
$userids = $task->taskUser->pluck('userid')->toArray();
$items = ProjectTask::with(['taskUser'])->where('parent_id', $task->id)->whereNull('archived_at')->get();
foreach ($items as $item) {
$userids = array_merge($userids, $item->taskUser->pluck('userid')->toArray());
}
$userids = array_values(array_filter(array_unique($userids)));
$dialog = WebSocketDialog::createGroup('', $userids, 'task');
if ($dialog) {
$task->dialog_id = $dialog->id;
$task->save();
}
}
if (empty($task->dialog_id)) {
return Base::retError('创建聊天失败');
}
return Base::retSuccess('success', [
'dialog_id' => $task->dialog_id,
]);
});
}
/** /**
* 归档任务 * 归档任务
* *
@ -1003,6 +1062,10 @@ class ProjectController extends AbstractController
return Base::retError('项目不存在或不在成员列表内'); return Base::retError('项目不存在或不在成员列表内');
} }
// //
if ($task->parent_id > 0) {
return Base::retError('子任务不支持此功能');
}
//
return $task->archivedTask(Carbon::now()); return $task->archivedTask(Carbon::now());
} }

View File

@ -15,6 +15,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int|null $parent_id 父级任务ID * @property int|null $parent_id 父级任务ID
* @property int|null $project_id 项目ID * @property int|null $project_id 项目ID
* @property int|null $column_id 列表ID * @property int|null $column_id 列表ID
* @property int|null $dialog_id 聊天会话ID
* @property string|null $name 标题 * @property string|null $name 标题
* @property string|null $color 颜色 * @property string|null $color 颜色
* @property string|null $desc 描述 * @property string|null $desc 描述
@ -31,7 +32,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at * @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \App\Models\ProjectTaskContent|null $content * @property-read \App\Models\ProjectTaskContent|null $content
* @property-read int $dialog_id
* @property-read int $file_num * @property-read int $file_num
* @property-read int $msg_num * @property-read int $msg_num
* @property-read bool $overdue * @property-read bool $overdue
@ -57,6 +57,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereDeletedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereDesc($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereDesc($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereDialogId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereEndAt($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereEndAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereName($value) * @method static \Illuminate\Database\Eloquent\Builder|ProjectTask whereName($value)
@ -85,7 +86,6 @@ class ProjectTask extends AbstractModel
'percent', 'percent',
'today', 'today',
'overdue', 'overdue',
'dialog_id',
]; ];
/** /**
@ -107,7 +107,7 @@ class ProjectTask extends AbstractModel
public function getMsgNumAttribute() public function getMsgNumAttribute()
{ {
if (!isset($this->attributes['msg_num'])) { if (!isset($this->attributes['msg_num'])) {
$this->attributes['msg_num'] = WebSocketDialogMsg::whereDialogId($this->dialog_id)->whereExtraInt($this->id)->count(); $this->attributes['msg_num'] = $this->dialog_id ? WebSocketDialogMsg::whereDialogId($this->dialog_id)->count() : 0;
} }
return $this->attributes['msg_num']; return $this->attributes['msg_num'];
} }
@ -197,18 +197,6 @@ class ProjectTask extends AbstractModel
return false; return false;
} }
/**
* 对话ID
* @return int
*/
public function getDialogIdAttribute()
{
if (!isset($this->attributes['dialog_id'])) {
$this->attributes['dialog_id'] = intval(Project::whereId($this->project_id)->value('dialog_id'));
}
return $this->attributes['dialog_id'];
}
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasOne * @return \Illuminate\Database\Eloquent\Relations\HasOne
*/ */

View File

@ -61,6 +61,8 @@ class WebSocketDialog extends AbstractModel
case "group": case "group":
if ($dialog->group_type === 'project') { if ($dialog->group_type === 'project') {
$dialog->name = Project::whereDialogId($dialog->id)->value('name'); $dialog->name = Project::whereDialogId($dialog->id)->value('name');
} elseif ($dialog->group_type === 'task') {
$dialog->name = ProjectTask::whereDialogId($dialog->id)->value('name');
} }
break; break;
} }

View File

@ -136,7 +136,7 @@
if (!this.userid) { if (!this.userid) {
return; return;
} }
this.$store.dispatch('userBasic', { this.$store.dispatch("getUserBasic", {
userid: this.userid, userid: this.userid,
success: (user) => { success: (user) => {
this.user = user; this.user = user;

View File

@ -131,7 +131,7 @@
userids.push(value); userids.push(value);
}); });
// //
this.$store.dispatch('userBasic', { this.$store.dispatch("getUserBasic", {
userid: userids, userid: userids,
complete: () => { complete: () => {
this.initialized = true; this.initialized = true;

View File

@ -80,7 +80,7 @@ export default {
}, },
}).then(({data}) => { }).then(({data}) => {
this.loadIng--; this.loadIng--;
this.$store.dispatch('saveUserInfo', data); this.$store.dispatch("saveUserInfo", data);
this.goNext(); this.goNext();
}).catch(({data, msg}) => { }).catch(({data, msg}) => {
this.loadIng--; this.loadIng--;

View File

@ -161,7 +161,7 @@ export default {
}, },
mounted() { mounted() {
this.$store.dispatch('userInfo'); this.$store.dispatch("getUserInfo");
}, },
deactivated() { deactivated() {
@ -274,16 +274,16 @@ export default {
url: 'project/add', url: 'project/add',
data: this.addData, data: this.addData,
}).then(({data, msg}) => { }).then(({data, msg}) => {
this.loadIng--;
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.loadIng--;
this.addShow = false; this.addShow = false;
this.$refs.addProject.resetFields(); this.$refs.addProject.resetFields();
this.$set(this.addData, 'template', 0); this.$set(this.addData, 'template', 0);
this.$store.dispatch('saveProject', data); this.$store.dispatch("saveProject", data);
this.toggleRoute('project/' + data.id) this.toggleRoute('project/' + data.id)
}).catch(({msg}) => { }).catch(({msg}) => {
this.loadIng--;
$A.modalError(msg); $A.modalError(msg);
this.loadIng--;
}); });
} }
}); });

View File

@ -96,7 +96,7 @@ export default {
methods: { methods: {
msgRead() { msgRead() {
this.$store.dispatch('dialogMsgRead', this.msgData); this.$store.dispatch("dialogMsgRead", this.msgData);
}, },
popperShow() { popperShow() {

View File

@ -124,13 +124,13 @@ export default {
text: this.msgText, text: this.msgText,
}, },
}).then(({data}) => { }).then(({data}) => {
this.$store.dispatch('dialogMsgSplice', {id: tempId, data}); this.$store.dispatch("dialogMsgSplice", {id: tempId, data});
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalWarning({ $A.modalWarning({
title: '发送失败', title: '发送失败',
content: msg content: msg
}); });
this.$store.dispatch('dialogMsgSplice', {id: tempId}); this.$store.dispatch("dialogMsgSplice", {id: tempId});
}); });
// //
this.msgText = ''; this.msgText = '';
@ -197,11 +197,11 @@ export default {
break; break;
case 'error': case 'error':
this.$store.dispatch('dialogMsgSplice', {id: file.tempId}); this.$store.dispatch("dialogMsgSplice", {id: file.tempId});
break; break;
case 'success': case 'success':
this.$store.dispatch('dialogMsgSplice', {id: file.tempId, data: file.data}); this.$store.dispatch("dialogMsgSplice", {id: file.tempId, data: file.data});
break; break;
} }
}, },

View File

@ -54,7 +54,7 @@ export default {
methods: { methods: {
getMsg() { getMsg() {
if (this.projectChatShow && this.projectDetail.dialog_id) { if (this.projectChatShow && this.projectDetail.dialog_id) {
this.$store.dispatch('dialogMsgList', this.projectDetail.dialog_id); this.$store.dispatch("getDialogMsgList", this.projectDetail.dialog_id);
} }
} }
} }

View File

@ -576,18 +576,19 @@ export default {
only_column: only_column === true ? 1 : 0 only_column: only_column === true ? 1 : 0
}, },
}).then(({msg}) => { }).then(({msg}) => {
this.sortDisabled = false;
$A.messageSuccess(msg); $A.messageSuccess(msg);
}).catch(({msg}) => {
this.sortDisabled = false; this.sortDisabled = false;
this.$store.dispatch('projectDetail', this.projectDetail.id); }).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.sortDisabled = false;
this.$store.dispatch("getProjectDetail", this.projectDetail.id);
}); });
}, },
onAddTask() { onAddTask() {
this.taskLoad++; this.taskLoad++;
this.$store.dispatch("taskAdd", this.addData).then(({msg}) => { this.$store.dispatch("taskAdd", this.addData).then(({msg}) => {
$A.messageSuccess(msg);
this.taskLoad--; this.taskLoad--;
this.addShow = false; this.addShow = false;
this.addData = { this.addData = {
@ -599,10 +600,9 @@ export default {
p_name: '', p_name: '',
p_color: '', p_color: '',
}; };
$A.messageSuccess(msg);
}).catch(({msg}) => { }).catch(({msg}) => {
this.taskLoad--;
$A.modalError(msg); $A.modalError(msg);
this.taskLoad--;
}); });
}, },
@ -651,7 +651,7 @@ export default {
this.addColumnName = ''; this.addColumnName = '';
this.projectDetail.project_column.push(data) this.projectDetail.project_column.push(data)
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg);
}); });
}, },
@ -726,18 +726,17 @@ export default {
column_id: column.id, column_id: column.id,
}, },
}).then(({msg}) => { }).then(({msg}) => {
$A.messageSuccess(msg);
this.$set(column, 'loading', false); this.$set(column, 'loading', false);
this.$Modal.remove(); this.$Modal.remove();
$A.messageSuccess(msg);
let index = this.projectDetail.project_column.findIndex(({id}) => id === column.id); let index = this.projectDetail.project_column.findIndex(({id}) => id === column.id);
if (index > -1) { if (index > -1) {
this.projectDetail.project_column.splice(index, 1); this.projectDetail.project_column.splice(index, 1);
} }
this.$store.dispatch('projectDetail', this.projectDetail.id);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301);
this.$set(column, 'loading', false); this.$set(column, 'loading', false);
this.$Modal.remove(); this.$Modal.remove();
$A.modalError(msg, 301);
}); });
} }
}); });
@ -809,11 +808,11 @@ export default {
task_id: task.id, task_id: task.id,
type: type, type: type,
}).then(({msg}) => { }).then(({msg}) => {
this.$Modal.remove();
$A.messageSuccess(msg); $A.messageSuccess(msg);
}).catch(({msg}) => {
this.$Modal.remove(); this.$Modal.remove();
}).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg, 301);
this.$Modal.remove();
}); });
}, },
@ -823,13 +822,13 @@ export default {
url: 'project/edit', url: 'project/edit',
data: this.settingData, data: this.settingData,
}).then(({data, msg}) => { }).then(({data, msg}) => {
this.settingLoad--;
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.settingLoad--;
this.settingShow = false; this.settingShow = false;
this.$store.dispatch("saveProject", data) this.$store.dispatch("saveProject", data)
}).catch(({msg}) => { }).catch(({msg}) => {
this.settingLoad--;
$A.modalError(msg); $A.modalError(msg);
this.settingLoad--;
}); });
}, },
@ -842,13 +841,13 @@ export default {
userid: this.userData.userids, userid: this.userData.userids,
}, },
}).then(({msg}) => { }).then(({msg}) => {
this.userLoad--;
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.$store.dispatch('projectDetail', this.userData.project_id);
this.userShow = false;
}).catch(({msg}) => {
this.userLoad--; this.userLoad--;
this.userShow = false;
this.$store.dispatch("getProjectDetail", this.userData.project_id);
}).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.userLoad--;
}); });
}, },
@ -861,13 +860,13 @@ export default {
owner_userid: this.transferData.owner_userid[0], owner_userid: this.transferData.owner_userid[0],
}, },
}).then(({msg}) => { }).then(({msg}) => {
this.transferLoad--;
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.$store.dispatch('projectDetail', this.transferData.project_id);
this.transferShow = false;
}).catch(({msg}) => {
this.transferLoad--; this.transferLoad--;
this.transferShow = false;
this.$store.dispatch("getProjectDetail", this.transferData.project_id);
}).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.transferLoad--;
}); });
}, },
@ -883,9 +882,9 @@ export default {
project_id: this.projectDetail.id, project_id: this.projectDetail.id,
}, },
}).then(({msg}) => { }).then(({msg}) => {
this.$Modal.remove();
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.$store.dispatch('removeProject', this.projectDetail.id); this.$Modal.remove();
this.$store.dispatch("removeProject", this.projectDetail.id);
const project = this.projectList.find(({id}) => id); const project = this.projectList.find(({id}) => id);
if (project) { if (project) {
this.goForward({path: '/manage/project/' + project.id}, true); this.goForward({path: '/manage/project/' + project.id}, true);
@ -893,8 +892,8 @@ export default {
this.goForward({path: '/manage/dashboard'}, true); this.goForward({path: '/manage/dashboard'}, true);
} }
}).catch(({msg}) => { }).catch(({msg}) => {
this.$Modal.remove();
$A.modalError(msg, 301); $A.modalError(msg, 301);
this.$Modal.remove();
}); });
} }
}); });
@ -912,9 +911,9 @@ export default {
project_id: this.projectDetail.id, project_id: this.projectDetail.id,
}, },
}).then(({msg}) => { }).then(({msg}) => {
this.$Modal.remove();
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.$store.dispatch('removeProject', this.projectDetail.id); this.$Modal.remove();
this.$store.dispatch("removeProject", this.projectDetail.id);
const project = this.projectList.find(({id}) => id); const project = this.projectList.find(({id}) => id);
if (project) { if (project) {
this.goForward({path: '/manage/project/' + project.id}, true); this.goForward({path: '/manage/project/' + project.id}, true);
@ -922,8 +921,8 @@ export default {
this.goForward({path: '/manage/dashboard'}, true); this.goForward({path: '/manage/dashboard'}, true);
} }
}).catch(({msg}) => { }).catch(({msg}) => {
this.$Modal.remove();
$A.modalError(msg, 301); $A.modalError(msg, 301);
this.$Modal.remove();
}); });
} }
}); });
@ -963,14 +962,14 @@ export default {
openTask(task) { openTask(task) {
if (task.parent_id > 0) { if (task.parent_id > 0) {
this.$store.dispatch('openTask', task.parent_id) this.$store.dispatch("openTask", task.parent_id)
} else { } else {
this.$store.dispatch('openTask', task.id) this.$store.dispatch("openTask", task.id)
} }
}, },
toggleBoolean(type) { toggleBoolean(type) {
this.$store.dispatch('toggleBoolean', type); this.$store.dispatch("toggleBoolean", type);
}, },
formatTime(date) { formatTime(date) {

View File

@ -160,7 +160,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.$store.dispatch('taskPriority').then(() => { this.$store.dispatch('getTaskPriority').then(() => {
if (!this.value.p_name && this.taskPriority.length > 0) { if (!this.value.p_name && this.taskPriority.length > 0) {
this.choosePriority(this.taskPriority[0]) this.choosePriority(this.taskPriority[0])
} }

View File

@ -107,7 +107,7 @@ export default {
this.active = true; this.active = true;
this.$nextTick(() => { this.$nextTick(() => {
if (this.taskPriority.length === 0) { if (this.taskPriority.length === 0) {
this.$store.dispatch('taskPriority').then(() => { this.$store.dispatch('getTaskPriority').then(() => {
if (!this.addData.p_name && this.taskPriority.length > 0) { if (!this.addData.p_name && this.taskPriority.length > 0) {
this.choosePriority(this.taskPriority[0]) this.choosePriority(this.taskPriority[0])
} }
@ -152,6 +152,7 @@ export default {
} }
this.loadIng++; this.loadIng++;
this.$store.dispatch("taskAdd", this.getData()).then(({msg}) => { this.$store.dispatch("taskAdd", this.getData()).then(({msg}) => {
$A.messageSuccess(msg);
this.loadIng--; this.loadIng--;
this.active = false; this.active = false;
this.addData = { this.addData = {
@ -163,10 +164,9 @@ export default {
p_name: '', p_name: '',
p_color: '', p_color: '',
} }
$A.messageSuccess(msg);
}).catch(({msg}) => { }).catch(({msg}) => {
this.loadIng--;
$A.modalError(msg); $A.modalError(msg);
this.loadIng--;
}); });
}, },

View File

@ -320,6 +320,16 @@
<TaskUpload ref="upload" class="upload"/> <TaskUpload ref="upload" class="upload"/>
</div> </div>
<div class="task-dialog"> <div class="task-dialog">
<DialogWrapper v-if="taskDetail.dialog_id > 0">
<div slot="head" class="head">
<Icon class="icon" type="ios-chatbubbles-outline" />
<div class="nav">
<p class="active">{{$L('聊天')}}</p>
<p>{{$L('动态')}}</p>
</div>
</div>
</DialogWrapper>
<div v-else>
<div class="head"> <div class="head">
<Icon class="icon" type="ios-chatbubbles-outline" /> <Icon class="icon" type="ios-chatbubbles-outline" />
<div class="nav"> <div class="nav">
@ -331,17 +341,19 @@
<div class="no-tip">{{$L('暂无消息')}}</div> <div class="no-tip">{{$L('暂无消息')}}</div>
<div class="no-input"> <div class="no-input">
<Input <Input
ref="input"
class="dialog-input" class="dialog-input"
v-model="taskDetail._msgText" v-model="msgText"
type="textarea" type="textarea"
:rows="1" :rows="1"
:autosize="{ minRows: 1, maxRows: 3 }" :autosize="{ minRows: 1, maxRows: 3 }"
:maxlength="255" :maxlength="255"
:placeholder="$L('输入消息...')"/> :placeholder="$L('输入消息...')"
@on-keydown="msgKeydown"/>
</div> </div>
</div> </div>
</div> </div>
<Input ref="input" v-show="false"/>
</div>
</div> </div>
</template> </template>
@ -351,10 +363,11 @@ import TEditor from "../../../components/TEditor";
import TaskPriority from "./TaskPriority"; import TaskPriority from "./TaskPriority";
import UserInput from "../../../components/UserInput"; import UserInput from "../../../components/UserInput";
import TaskUpload from "./TaskUpload"; import TaskUpload from "./TaskUpload";
import DialogWrapper from "./DialogWrapper";
export default { export default {
name: "TaskDetail", name: "TaskDetail",
components: {TaskUpload, UserInput, TaskPriority, TEditor}, components: {DialogWrapper, TaskUpload, UserInput, TaskPriority, TEditor},
props: { props: {
openTask: { openTask: {
type: Object, type: Object,
@ -393,6 +406,8 @@ export default {
innerHeight: window.innerHeight, innerHeight: window.innerHeight,
msgText: '',
taskPlugins: [ taskPlugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak imagetools', 'advlist autolink lists link image charmap print preview hr anchor pagebreak imagetools',
'searchreplace visualblocks visualchars code', 'searchreplace visualblocks visualchars code',
@ -422,7 +437,7 @@ export default {
}, },
mounted() { mounted() {
this.$store.dispatch('taskPriority'); this.$store.dispatch('getTaskPriority');
this.nowInterval = setInterval(() => { this.nowInterval = setInterval(() => {
this.nowTime = Math.round(new Date().getTime() / 1000); this.nowTime = Math.round(new Date().getTime() / 1000);
}, 1000); }, 1000);
@ -561,6 +576,7 @@ export default {
openTask: { openTask: {
handler(data) { handler(data) {
this.taskDetail = $A.cloneJSON(data); this.taskDetail = $A.cloneJSON(data);
this.$store.dispatch("getDialogMsgList", this.taskDetail.dialog_id);
}, },
immediate: true, immediate: true,
deep: true deep: true
@ -753,11 +769,11 @@ export default {
task_id: this.taskDetail.id, task_id: this.taskDetail.id,
type: type, type: type,
}).then(({msg}) => { }).then(({msg}) => {
this.$Modal.remove();
$A.messageSuccess(msg); $A.messageSuccess(msg);
}).catch(({msg}) => {
this.$Modal.remove(); this.$Modal.remove();
}).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg, 301);
this.$Modal.remove();
}); });
} }
}); });
@ -778,14 +794,14 @@ export default {
task_id: this.taskDetail.id, task_id: this.taskDetail.id,
owner: this.ownerData.owner_userid owner: this.ownerData.owner_userid
}).then(({msg}) => { }).then(({msg}) => {
this.ownerLoad--;
this.ownerShow = false;
this.$store.dispatch("taskOne", this.taskDetail.id);
$A.messageSuccess(msg); $A.messageSuccess(msg);
}).catch(({msg}) => {
this.ownerLoad--; this.ownerLoad--;
this.ownerShow = false; this.ownerShow = false;
this.$store.dispatch("getTaskOne", this.taskDetail.id);
}).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.ownerLoad--;
this.ownerShow = false;
}) })
}, },
@ -808,14 +824,14 @@ export default {
task_id: this.taskDetail.id, task_id: this.taskDetail.id,
assist, assist,
}).then(({msg}) => { }).then(({msg}) => {
this.assistLoad--;
this.assistShow = false;
this.$store.dispatch("taskOne", this.taskDetail.id);
$A.messageSuccess(msg); $A.messageSuccess(msg);
}).catch(({msg}) => {
this.assistLoad--; this.assistLoad--;
this.assistShow = false; this.assistShow = false;
this.$store.dispatch("getTaskOne", this.taskDetail.id);
}).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.assistLoad--;
this.assistShow = false;
}) })
}, },
@ -894,12 +910,12 @@ export default {
task_id: this.taskDetail.id, task_id: this.taskDetail.id,
name: this.addsubName, name: this.addsubName,
}).then(({msg}) => { }).then(({msg}) => {
$A.messageSuccess(msg);
this.addsubLoad--; this.addsubLoad--;
this.addsubName = ""; this.addsubName = "";
$A.messageSuccess(msg);
}).catch(({msg}) => { }).catch(({msg}) => {
this.addsubLoad--;
$A.modalError(msg); $A.modalError(msg);
this.addsubLoad--;
}); });
}, },
@ -939,6 +955,35 @@ export default {
break; break;
} }
}, },
msgKeydown(e) {
if (e.keyCode === 13) {
if (e.shiftKey) {
return;
}
e.preventDefault();
this.msgDialog();
}
},
msgDialog() {
if (!this.msgText) {
return;
}
this.$store.dispatch("call", {
url: 'project/task/dialog',
data: {
task_id: this.taskDetail.id,
},
}).then(({data}) => {
this.$store.dispatch("saveTask", {
id: this.taskDetail.id,
dialog_id: data.dialog_id
});
}).catch(({msg}) => {
$A.modalError(msg);
});
}
} }
} }
</script> </script>

View File

@ -158,7 +158,7 @@ export default {
return; return;
} }
this.$set(task, 'loading', true); this.$set(task, 'loading', true);
this.$store.dispatch("subTask", task.id).then(({data}) => { this.$store.dispatch("getSubTask", task.id).then(({data}) => {
this.$set(task, 'loading', false); this.$set(task, 'loading', false);
this.$set(task, 'sub_list', data); this.$set(task, 'sub_list', data);
this.$set(task, 'sub_open', true); this.$set(task, 'sub_open', true);
@ -170,9 +170,9 @@ export default {
openTask(task) { openTask(task) {
if (task.parent_id > 0) { if (task.parent_id > 0) {
this.$store.dispatch('openTask', task.parent_id) this.$store.dispatch("openTask", task.parent_id)
} else { } else {
this.$store.dispatch('openTask', task.id) this.$store.dispatch("openTask", task.id)
} }
}, },

View File

@ -60,7 +60,7 @@ export default {
if (res.ret === 1) { if (res.ret === 1) {
if (index > -1) { if (index > -1) {
this.projectOpenTask.files.splice(index, 1, res.data); this.projectOpenTask.files.splice(index, 1, res.data);
this.$store.dispatch("taskData", { this.$store.dispatch("saveTask", {
id: this.projectOpenTask.id, id: this.projectOpenTask.id,
file_num: this.projectOpenTask.files.length, file_num: this.projectOpenTask.files.length,
}); });

View File

@ -81,7 +81,7 @@ export default {
mounted() { mounted() {
this.dialogLoad++; this.dialogLoad++;
this.$store.dispatch("dialogList").then(() => { this.$store.dispatch("getDialogList").then(() => {
this.dialogLoad--; this.dialogLoad--;
this.openDialogStorage(); this.openDialogStorage();
}).catch(() => { }).catch(() => {
@ -125,7 +125,7 @@ export default {
methods: { methods: {
openDialog(dialog) { openDialog(dialog) {
this.$store.state.method.setStorage('messengerDialogId', dialog.id) this.$store.state.method.setStorage('messengerDialogId', dialog.id)
this.$store.dispatch('dialogMsgList', dialog.id); this.$store.dispatch("getDialogMsgList", dialog.id);
}, },
openDialogStorage() { openDialogStorage() {

View File

@ -24,7 +24,7 @@ export default {
this.project_id = route.params.id; this.project_id = route.params.id;
}, },
project_id(id) { project_id(id) {
this.$store.dispatch('projectDetail', id); this.$store.dispatch("getProjectDetail", id);
} }
}, },
} }

View File

@ -83,13 +83,13 @@ export default {
url: 'users/editpass', url: 'users/editpass',
data: this.formDatum, data: this.formDatum,
}).then(({data}) => { }).then(({data}) => {
this.loadIng--;
$A.messageSuccess('修改成功'); $A.messageSuccess('修改成功');
this.$store.dispatch('saveUserInfo', data); this.loadIng--;
this.$store.dispatch("saveUserInfo", data);
this.$refs.formDatum.resetFields(); this.$refs.formDatum.resetFields();
}).catch(({msg}) => { }).catch(({msg}) => {
this.loadIng--;
$A.modalError(msg); $A.modalError(msg);
this.loadIng--;
}); });
} }
}) })

View File

@ -76,12 +76,12 @@ export default {
url: 'users/editdata', url: 'users/editdata',
data: this.formDatum, data: this.formDatum,
}).then(() => { }).then(() => {
this.loadIng--;
$A.messageSuccess('修改成功'); $A.messageSuccess('修改成功');
this.$store.dispatch('userInfo');
}).catch(({msg}) => {
this.loadIng--; this.loadIng--;
this.$store.dispatch('getUserInfo');
}).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.loadIng--;
}); });
} }
}) })

View File

@ -97,6 +97,9 @@ export default {
list: this.formDatum list: this.formDatum
}, },
}).then(({data}) => { }).then(({data}) => {
if (save) {
$A.messageSuccess('修改成功');
}
this.loadIng--; this.loadIng--;
this.$store.state.taskPriority = $A.cloneJSON(data); this.$store.state.taskPriority = $A.cloneJSON(data);
this.formDatum = data; this.formDatum = data;
@ -104,14 +107,11 @@ export default {
this.addDatum(); this.addDatum();
} }
this.formDatum_bak = $A.cloneJSON(this.formDatum); this.formDatum_bak = $A.cloneJSON(this.formDatum);
if (save) {
$A.messageSuccess('修改成功');
}
}).catch(({msg}) => { }).catch(({msg}) => {
this.loadIng--;
if (save) { if (save) {
$A.modalError(msg); $A.modalError(msg);
} }
this.loadIng--;
}); });
} }
} }

View File

@ -55,17 +55,17 @@ export default {
url: 'system/setting?type=' + (save ? 'save' : 'get'), url: 'system/setting?type=' + (save ? 'save' : 'get'),
data: this.formDatum, data: this.formDatum,
}).then(({data}) => { }).then(({data}) => {
this.loadIng--;
this.formDatum = data;
this.formDatum_bak = $A.cloneJSON(this.formDatum);
if (save) { if (save) {
$A.messageSuccess('修改成功'); $A.messageSuccess('修改成功');
} }
}).catch(({msg}) => {
this.loadIng--; this.loadIng--;
this.formDatum = data;
this.formDatum_bak = $A.cloneJSON(this.formDatum);
}).catch(({msg}) => {
if (save) { if (save) {
$A.modalError(msg); $A.modalError(msg);
} }
this.loadIng--;
}); });
} }
} }

View File

@ -137,12 +137,12 @@ export default {
* @param dispatch * @param dispatch
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
userInfo({dispatch}) { getUserInfo({dispatch}) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
dispatch("call", { dispatch("call", {
url: 'users/info', url: 'users/info',
}).then(result => { }).then(result => {
dispatch('saveUserInfo', result.data); dispatch("saveUserInfo", result.data);
resolve(result) resolve(result)
}).catch(result => { }).catch(result => {
dispatch("logout"); dispatch("logout");
@ -168,8 +168,8 @@ export default {
state.userToken = userInfo.token; state.userToken = userInfo.token;
state.userIsAdmin = state.method.inArray('admin', userInfo.identity); state.userIsAdmin = state.method.inArray('admin', userInfo.identity);
state.method.setStorage('userInfo', state.userInfo); state.method.setStorage('userInfo', state.userInfo);
dispatch('projectList'); dispatch('getProjectList');
dispatch('dialogMsgUnread'); dispatch('getDialogMsgUnread');
dispatch('websocketConnection'); dispatch('websocketConnection');
resolve() resolve()
}); });
@ -193,7 +193,7 @@ export default {
* @param dispatch * @param dispatch
* @param params {userid, success, complete} * @param params {userid, success, complete}
*/ */
userBasic({state, dispatch}, params) { getUserBasic({state, dispatch}, params) {
if (!state.method.isJson(params)) { if (!state.method.isJson(params)) {
return; return;
} }
@ -220,7 +220,7 @@ export default {
// //
if (state.cacheUserBasic["::load"] === true) { if (state.cacheUserBasic["::load"] === true) {
setTimeout(() => { setTimeout(() => {
dispatch('userBasic', params); dispatch("getUserBasic", params);
}, 20); }, 20);
return; return;
} }
@ -239,7 +239,7 @@ export default {
data: item data: item
}; };
state.method.setStorage("cacheUserBasic", state.cacheUserBasic); state.method.setStorage("cacheUserBasic", state.cacheUserBasic);
dispatch('saveUserOnlineStatus', item); dispatch("saveUserOnlineStatus", item);
typeof success === "function" && success(item, true) typeof success === "function" && success(item, true)
}); });
}).catch(result => { }).catch(result => {
@ -254,85 +254,12 @@ export default {
* @param dispatch * @param dispatch
*/ */
logout({dispatch}) { logout({dispatch}) {
dispatch('saveUserInfo', {}).then(() => { dispatch("saveUserInfo", {}).then(() => {
const from = window.location.pathname == '/' ? '' : encodeURIComponent(window.location.href); const from = window.location.pathname == '/' ? '' : encodeURIComponent(window.location.href);
$A.goForward({path: '/login', query: from ? {from: from} : {}}, true); $A.goForward({path: '/login', query: from ? {from: from} : {}}, true);
}); });
}, },
/**
* 获取项目列表
* @param state
* @param dispatch
*/
projectList({state, dispatch}) {
if (state.userId === 0) {
state.projectList = [];
return;
}
if (state.cacheProjectList.length > 0) {
state.projectList = state.cacheProjectList;
}
dispatch("call", {
url: 'project/lists',
}).then(result => {
dispatch('saveProject', result.data.data);
}).catch(result => {
$A.modalError(result.msg);
});
},
/**
* 获取项目信息
* @param state
* @param dispatch
* @param project_id
*/
projectOne({state, dispatch}, project_id) {
if (state.method.runNum(project_id) === 0) {
return;
}
dispatch("call", {
url: 'project/one',
data: {
project_id: project_id,
},
}).then(result => {
dispatch('saveProject', result.data);
});
},
/**
* 获取项目详情
* @param state
* @param dispatch
* @param project_id
*/
projectDetail({state, dispatch}, project_id) {
if (state.method.runNum(project_id) === 0) {
return;
}
const project = state.cacheProjectList.find(({id}) => id == project_id);
if (project) {
state.projectDetail = Object.assign({project_column: [], project_user: []}, project);
}
state.projectDetail.id = project_id;
//
state.projectLoad++;
dispatch("call", {
url: 'project/detail',
data: {
project_id: project_id,
},
}).then(result => {
state.projectLoad--;
dispatch('saveProject', result.data);
}).catch(result => {
state.projectLoad--;
$A.modalError(result.msg);
});
},
/** /**
* 保存项目信息 * 保存项目信息
* @param state * @param state
@ -361,6 +288,79 @@ export default {
state.method.setStorage("cacheProjectList", state.projectList); state.method.setStorage("cacheProjectList", state.projectList);
}, },
/**
* 获取项目列表
* @param state
* @param dispatch
*/
getProjectList({state, dispatch}) {
if (state.userId === 0) {
state.projectList = [];
return;
}
if (state.cacheProjectList.length > 0) {
state.projectList = state.cacheProjectList;
}
dispatch("call", {
url: 'project/lists',
}).then(result => {
dispatch("saveProject", result.data.data);
}).catch(result => {
$A.modalError(result.msg);
});
},
/**
* 获取项目信息
* @param state
* @param dispatch
* @param project_id
*/
getProjectOne({state, dispatch}, project_id) {
if (state.method.runNum(project_id) === 0) {
return;
}
dispatch("call", {
url: 'project/one',
data: {
project_id: project_id,
},
}).then(result => {
dispatch("saveProject", result.data);
});
},
/**
* 获取项目详情
* @param state
* @param dispatch
* @param project_id
*/
getProjectDetail({state, dispatch}, project_id) {
if (state.method.runNum(project_id) === 0) {
return;
}
const project = state.cacheProjectList.find(({id}) => id == project_id);
if (project) {
state.projectDetail = Object.assign({project_column: [], project_user: []}, project);
}
state.projectDetail.id = project_id;
//
state.projectLoad++;
dispatch("call", {
url: 'project/detail',
data: {
project_id: project_id,
},
}).then(result => {
state.projectLoad--;
dispatch("saveProject", result.data);
}).catch(result => {
state.projectLoad--;
$A.modalError(result.msg);
});
},
/** /**
* 删除项目信息 * 删除项目信息
* @param state * @param state
@ -375,11 +375,11 @@ export default {
}, },
/** /**
* 更新任务信息 * 保存任务信息
* @param state * @param state
* @param data * @param data
*/ */
taskData({state}, data) { saveTask({state}, data) {
state.projectDetail.project_column.some(({project_task}) => { state.projectDetail.project_column.some(({project_task}) => {
let index = project_task.findIndex(({id}) => id === data.id); let index = project_task.findIndex(({id}) => id === data.id);
if (index > -1) { if (index > -1) {
@ -404,7 +404,7 @@ export default {
* @param task_id * @param task_id
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
taskOne({state, dispatch}, task_id) { getTaskOne({state, dispatch}, task_id) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
dispatch("call", { dispatch("call", {
url: 'project/task/one', url: 'project/task/one',
@ -412,7 +412,7 @@ export default {
task_id, task_id,
}, },
}).then(result => { }).then(result => {
dispatch("taskData", result.data); dispatch("saveTask", result.data);
resolve(result) resolve(result)
}).catch(result => { }).catch(result => {
reject(result) reject(result)
@ -427,7 +427,7 @@ export default {
* @param task_id * @param task_id
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
taskContent({state, dispatch}, task_id) { getTaskContent({state, dispatch}, task_id) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
dispatch("call", { dispatch("call", {
url: 'project/task/content', url: 'project/task/content',
@ -454,7 +454,7 @@ export default {
* @param task_id * @param task_id
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
taskFiles({state, dispatch}, task_id) { getTaskFiles({state, dispatch}, task_id) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
dispatch("call", { dispatch("call", {
url: 'project/task/files', url: 'project/task/files',
@ -480,7 +480,7 @@ export default {
* @param task_id * @param task_id
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
subTask({state, dispatch}, task_id) { getSubTask({state, dispatch}, task_id) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
dispatch("call", { dispatch("call", {
url: 'project/task/sublist', url: 'project/task/sublist',
@ -520,10 +520,10 @@ export default {
data.sub_task = state.projectSubTask[task_id] || [] data.sub_task = state.projectSubTask[task_id] || []
// //
state.projectOpenTask = Object.assign({}, data, {_show: true}); state.projectOpenTask = Object.assign({}, data, {_show: true});
dispatch("taskOne", task_id); dispatch("getTaskOne", task_id);
dispatch("taskContent", task_id); dispatch("getTaskContent", task_id);
dispatch("taskFiles", task_id); dispatch("getTaskFiles", task_id);
dispatch("subTask", task_id); dispatch("getSubTask", task_id);
}, },
/** /**
@ -562,7 +562,7 @@ export default {
} }
} }
} }
dispatch('projectOne', task.project_id); dispatch("getProjectOne", task.project_id);
resolve(result) resolve(result)
}).catch(result => { }).catch(result => {
reject(result) reject(result)
@ -586,7 +586,7 @@ export default {
if (data.task_id == state.projectOpenTask.id) { if (data.task_id == state.projectOpenTask.id) {
state.projectOpenTask.sub_task.push(result.data.task); state.projectOpenTask.sub_task.push(result.data.task);
} }
dispatch('taskOne', data.task_id); dispatch("getTaskOne", data.task_id);
resolve(result) resolve(result)
}).catch(result => { }).catch(result => {
reject(result) reject(result)
@ -613,15 +613,15 @@ export default {
method: 'post', method: 'post',
}).then(result => { }).then(result => {
if (result.data.parent_id) { if (result.data.parent_id) {
dispatch('taskOne', result.data.parent_id); dispatch("getTaskOne", result.data.parent_id);
} }
if (typeof post.complete_at !== "undefined") { if (typeof post.complete_at !== "undefined") {
dispatch('projectOne', result.data.project_id); dispatch("getProjectOne", result.data.project_id);
} }
dispatch("taskData", result.data); dispatch("saveTask", result.data);
resolve(result) resolve(result)
}).catch(result => { }).catch(result => {
dispatch('taskOne', post.task_id); dispatch("getTaskOne", post.task_id);
reject(result) reject(result)
}); });
}); });
@ -659,7 +659,6 @@ export default {
state.projectOpenTask.sub_task.splice(index, 1) state.projectOpenTask.sub_task.splice(index, 1)
} }
} }
dispatch('projectDetail', data.project_id);
resolve(result); resolve(result);
}).catch(result => { }).catch(result => {
reject(result) reject(result)
@ -673,7 +672,7 @@ export default {
* @param dispatch * @param dispatch
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
taskPriority({state, dispatch}) { getTaskPriority({state, dispatch}) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
dispatch("call", { dispatch("call", {
url: 'system/priority', url: 'system/priority',
@ -686,12 +685,30 @@ export default {
}); });
}, },
/**
* 更新会话数据
* @param state
* @param dispatch
* @param data
*/
saveDialog({state, dispatch}, data) {
let splice = false;
state.dialogList.some(({id, unread}, index) => {
if (id == data.id) {
unread !== data.unread && dispatch('getDialogMsgUnread');
state.dialogList.splice(index, 1, data);
return splice = true;
}
});
!splice && state.dialogList.unshift(data)
},
/** /**
* 获取会话列表 * 获取会话列表
* @param state * @param state
* @param dispatch * @param dispatch
*/ */
dialogList({state, dispatch}) { getDialogList({state, dispatch}) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
dispatch("call", { dispatch("call", {
url: 'dialog/lists', url: 'dialog/lists',
@ -704,38 +721,20 @@ export default {
}); });
}, },
/**
* 更新会话数据
* @param state
* @param dispatch
* @param data
*/
dialogUpdate({state, dispatch}, data) {
let splice = false;
state.dialogList.some(({id, unread}, index) => {
if (id == data.id) {
unread !== data.unread && dispatch('dialogMsgUnread');
state.dialogList.splice(index, 1, data);
return splice = true;
}
});
!splice && state.dialogList.unshift(data)
},
/** /**
* 获取单个会话 * 获取单个会话
* @param state * @param state
* @param dispatch * @param dispatch
* @param dialog_id * @param dialog_id
*/ */
dialogOne({state, dispatch}, dialog_id) { getDialogOne({state, dispatch}, dialog_id) {
dispatch("call", { dispatch("call", {
url: 'dialog/one', url: 'dialog/one',
data: { data: {
dialog_id, dialog_id,
}, },
}).then(result => { }).then(result => {
dispatch('dialogUpdate', result.data); dispatch("dialogUpdate", result.data);
}); });
}, },
@ -756,8 +755,8 @@ export default {
}, },
}).then(result => { }).then(result => {
state.method.setStorage('messengerDialogId', result.data.id) state.method.setStorage('messengerDialogId', result.data.id)
dispatch('dialogMsgList', result.data.id); dispatch("getDialogMsgList", result.data.id);
dispatch('dialogUpdate', result.data); dispatch("saveDialog", result.data);
}).catch(result => { }).catch(result => {
$A.modalError(result.msg); $A.modalError(result.msg);
}); });
@ -769,7 +768,7 @@ export default {
* @param dispatch * @param dispatch
* @param dialog_id * @param dialog_id
*/ */
dialogMsgList({state, dispatch}, dialog_id) { getDialogMsgList({state, dispatch}, dialog_id) {
if (state.method.runNum(dialog_id) === 0) { if (state.method.runNum(dialog_id) === 0) {
return; return;
} }
@ -823,7 +822,7 @@ export default {
}) })
} }
// 更新会话数据 // 更新会话数据
dispatch('dialogUpdate', dialog); dispatch("saveDialog", dialog);
}).catch(() => { }).catch(() => {
state.dialogMsgLoad--; state.dialogMsgLoad--;
state.cacheDialogList[dialog_id + "::load"] = false; state.cacheDialogList[dialog_id + "::load"] = false;
@ -835,7 +834,7 @@ export default {
* @param state * @param state
* @param dispatch * @param dispatch
*/ */
dialogMsgUnread({state, dispatch}) { getDialogMsgUnread({state, dispatch}) {
if (state.userId === 0) { if (state.userId === 0) {
state.dialogMsgUnread = 0; state.dialogMsgUnread = 0;
return; return;
@ -848,7 +847,7 @@ export default {
state.dialogMsgUnread = result.data.unread; state.dialogMsgUnread = result.data.unread;
} else { } else {
setTimeout(() => { setTimeout(() => {
dispatch('dialogMsgUnread'); dispatch('getDialogMsgUnread');
}, 200); }, 200);
} }
}); });
@ -907,7 +906,7 @@ export default {
state.wsReadWaitList.push(id); state.wsReadWaitList.push(id);
clearTimeout(state.wsReadTimeout); clearTimeout(state.wsReadTimeout);
state.wsReadTimeout = setTimeout(() => { state.wsReadTimeout = setTimeout(() => {
dispatch('websocketSend', { dispatch("websocketSend", {
type: 'readMsg', type: 'readMsg',
data: { data: {
id: state.method.cloneJSON(state.wsReadWaitList) id: state.method.cloneJSON(state.wsReadWaitList)
@ -977,11 +976,11 @@ export default {
break break
case "line": case "line":
dispatch('saveUserOnlineStatus', msgDetail.data); dispatch("saveUserOnlineStatus", msgDetail.data);
break break
default: default:
msgId && dispatch('websocketSend', {type: 'receipt', msgId}); msgId && dispatch("websocketSend", {type: 'receipt', msgId});
state.wsMsg = msgDetail; state.wsMsg = msgDetail;
Object.values(state.wsListener).forEach((call) => { Object.values(state.wsListener).forEach((call) => {
if (typeof call === "function") { if (typeof call === "function") {
@ -1015,7 +1014,7 @@ export default {
if (dialog) { if (dialog) {
dialog.last_msg = data; dialog.last_msg = data;
} else { } else {
dispatch('dialogOne', dialog_id); dispatch("getDialogOne", dialog_id);
} }
if (mode === "add") { if (mode === "add") {
if (dialog) { if (dialog) {

View File

@ -430,6 +430,12 @@
margin: 0 0 0 18px; margin: 0 0 0 18px;
} }
} }
.dialog-wrapper {
z-index: 0;
.dialog-footer {
margin-bottom: 0;
}
}
} }
} }