mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 11:13:26 +00:00
feat: 支持编辑已发送的消息
This commit is contained in:
parent
6b9c20bf93
commit
9c861ec58c
@ -442,6 +442,7 @@ class DialogController extends AbstractController
|
|||||||
* @apiName msg__sendtext
|
* @apiName msg__sendtext
|
||||||
*
|
*
|
||||||
* @apiParam {Number} dialog_id 对话ID
|
* @apiParam {Number} dialog_id 对话ID
|
||||||
|
* @apiParam {Number} [update_id] 更新消息ID(优先大于reply_id)
|
||||||
* @apiParam {Number} [reply_id] 回复ID
|
* @apiParam {Number} [reply_id] 回复ID
|
||||||
* @apiParam {String} text 消息内容
|
* @apiParam {String} text 消息内容
|
||||||
*
|
*
|
||||||
@ -463,14 +464,20 @@ class DialogController extends AbstractController
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
$dialog_id = Base::getPostInt('dialog_id');
|
$dialog_id = Base::getPostInt('dialog_id');
|
||||||
|
$update_id = Base::getPostInt('update_id');
|
||||||
$reply_id = Base::getPostInt('reply_id');
|
$reply_id = Base::getPostInt('reply_id');
|
||||||
$text = trim(Base::getPostValue('text'));
|
$text = trim(Base::getPostValue('text'));
|
||||||
//
|
//
|
||||||
WebSocketDialog::checkDialog($dialog_id);
|
WebSocketDialog::checkDialog($dialog_id);
|
||||||
//
|
//
|
||||||
if ($reply_id > 0 && !WebSocketDialogMsg::whereId($reply_id)->whereDialogId($dialog_id)->exists()) {
|
if ($update_id > 0) {
|
||||||
return Base::retError('回复的消息不存在');
|
$action = "update-$update_id";
|
||||||
|
} elseif ($reply_id > 0) {
|
||||||
|
$action = "reply-$reply_id";
|
||||||
|
} else {
|
||||||
|
$action = "";
|
||||||
}
|
}
|
||||||
|
//
|
||||||
$text = WebSocketDialogMsg::formatMsg($text, $dialog_id);
|
$text = WebSocketDialogMsg::formatMsg($text, $dialog_id);
|
||||||
$strlen = mb_strlen($text);
|
$strlen = mb_strlen($text);
|
||||||
if ($strlen < 1) {
|
if ($strlen < 1) {
|
||||||
@ -500,10 +507,10 @@ class DialogController extends AbstractController
|
|||||||
'height' => -1,
|
'height' => -1,
|
||||||
'ext' => 'htm',
|
'ext' => 'htm',
|
||||||
];
|
];
|
||||||
return WebSocketDialogMsg::sendMsg($dialog_id, $reply_id, 'file', $fileData, $user->userid);
|
return WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
return WebSocketDialogMsg::sendMsg($dialog_id, $reply_id, 'text', ['text' => $text], $user->userid);
|
return WebSocketDialogMsg::sendMsg($action, $dialog_id, 'text', ['text' => $text], $user->userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -532,9 +539,7 @@ class DialogController extends AbstractController
|
|||||||
//
|
//
|
||||||
WebSocketDialog::checkDialog($dialog_id);
|
WebSocketDialog::checkDialog($dialog_id);
|
||||||
//
|
//
|
||||||
if ($reply_id > 0 && !WebSocketDialogMsg::whereId($reply_id)->whereDialogId($dialog_id)->exists()) {
|
$action = $reply_id > 0 ? "reply-$reply_id" : "";
|
||||||
return Base::retError('回复的消息不存在');
|
|
||||||
}
|
|
||||||
$path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
|
$path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
|
||||||
$base64 = Base::getPostValue('base64');
|
$base64 = Base::getPostValue('base64');
|
||||||
$duration = Base::getPostInt('duration');
|
$duration = Base::getPostInt('duration');
|
||||||
@ -551,7 +556,7 @@ class DialogController extends AbstractController
|
|||||||
$recordData = $data['data'];
|
$recordData = $data['data'];
|
||||||
$recordData['size'] *= 1024;
|
$recordData['size'] *= 1024;
|
||||||
$recordData['duration'] = $duration;
|
$recordData['duration'] = $duration;
|
||||||
return WebSocketDialogMsg::sendMsg($dialog_id, $reply_id, 'record', $recordData, $user->userid);
|
return WebSocketDialogMsg::sendMsg($action, $dialog_id, 'record', $recordData, $user->userid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,9 +589,7 @@ class DialogController extends AbstractController
|
|||||||
//
|
//
|
||||||
$dialog = WebSocketDialog::checkDialog($dialog_id);
|
$dialog = WebSocketDialog::checkDialog($dialog_id);
|
||||||
//
|
//
|
||||||
if ($reply_id > 0 && !WebSocketDialogMsg::whereId($reply_id)->whereDialogId($dialog_id)->exists()) {
|
$action = $reply_id > 0 ? "reply-$reply_id" : "";
|
||||||
return Base::retError('回复的消息不存在');
|
|
||||||
}
|
|
||||||
$path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
|
$path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
|
||||||
$image64 = Base::getPostValue('image64');
|
$image64 = Base::getPostValue('image64');
|
||||||
$fileName = Base::getPostValue('filename');
|
$fileName = Base::getPostValue('filename');
|
||||||
@ -631,7 +634,7 @@ class DialogController extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
$result = WebSocketDialogMsg::sendMsg($dialog_id, $reply_id, 'file', $fileData, $user->userid);
|
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid);
|
||||||
if (Base::isSuccess($result)) {
|
if (Base::isSuccess($result)) {
|
||||||
if (isset($task)) {
|
if (isset($task)) {
|
||||||
$result['data']['task_id'] = $task->id;
|
$result['data']['task_id'] = $task->id;
|
||||||
|
|||||||
@ -882,7 +882,7 @@ class UsersController extends AbstractController
|
|||||||
}
|
}
|
||||||
$dialog = WebSocketDialog::checkUserDialog($user->userid, $userid);
|
$dialog = WebSocketDialog::checkUserDialog($user->userid, $userid);
|
||||||
if ($dialog) {
|
if ($dialog) {
|
||||||
$res = WebSocketDialogMsg::sendMsg($dialog->id, 0, 'meeting', $data, $user->userid);
|
$res = WebSocketDialogMsg::sendMsg(null, $dialog->id, 'meeting', $data, $user->userid);
|
||||||
if (Base::isSuccess($res)) {
|
if (Base::isSuccess($res)) {
|
||||||
$msgs[] = $res['data'];
|
$msgs[] = $res['data'];
|
||||||
}
|
}
|
||||||
@ -932,7 +932,7 @@ class UsersController extends AbstractController
|
|||||||
}
|
}
|
||||||
$dialog = WebSocketDialog::checkUserDialog($user->userid, $userid);
|
$dialog = WebSocketDialog::checkUserDialog($user->userid, $userid);
|
||||||
if ($dialog) {
|
if ($dialog) {
|
||||||
$res = WebSocketDialogMsg::sendMsg($dialog->id, 0, 'meeting', $data, $user->userid);
|
$res = WebSocketDialogMsg::sendMsg(null, $dialog->id, 'meeting', $data, $user->userid);
|
||||||
if (Base::isSuccess($res)) {
|
if (Base::isSuccess($res)) {
|
||||||
$msgs[] = $res['data'];
|
$msgs[] = $res['data'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1188,7 +1188,7 @@ class ProjectTask extends AbstractModel
|
|||||||
$this->complete_at = null;
|
$this->complete_at = null;
|
||||||
$this->addLog("标记{任务}未完成");
|
$this->addLog("标记{任务}未完成");
|
||||||
if ($addMsg) {
|
if ($addMsg) {
|
||||||
WebSocketDialogMsg::sendMsg($this->dialog_id, 0, 'notice', [
|
WebSocketDialogMsg::sendMsg(null, $this->dialog_id, 'notice', [
|
||||||
'notice' => '标记任务未完成'
|
'notice' => '标记任务未完成'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -1205,7 +1205,7 @@ class ProjectTask extends AbstractModel
|
|||||||
$this->complete_at = $complete_at;
|
$this->complete_at = $complete_at;
|
||||||
$this->addLog("标记{任务}已完成");
|
$this->addLog("标记{任务}已完成");
|
||||||
if ($addMsg) {
|
if ($addMsg) {
|
||||||
WebSocketDialogMsg::sendMsg($this->dialog_id, 0, 'notice', [
|
WebSocketDialogMsg::sendMsg(null, $this->dialog_id, 'notice', [
|
||||||
'notice' => '标记任务已完成'
|
'notice' => '标记任务已完成'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -146,7 +146,7 @@ class WebSocketDialog extends AbstractModel
|
|||||||
], [
|
], [
|
||||||
'inviter' => $inviter,
|
'inviter' => $inviter,
|
||||||
]);
|
]);
|
||||||
WebSocketDialogMsg::sendMsg($this->id, 0, 'notice', [
|
WebSocketDialogMsg::sendMsg(null, $this->id, 'notice', [
|
||||||
'notice' => User::userid2nickname($value) . " 已加入群组"
|
'notice' => User::userid2nickname($value) . " 已加入群组"
|
||||||
], $inviter, true);
|
], $inviter, true);
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ class WebSocketDialog extends AbstractModel
|
|||||||
} else {
|
} else {
|
||||||
$notice = User::userid2nickname($item->userid) . " 退出群组";
|
$notice = User::userid2nickname($item->userid) . " 退出群组";
|
||||||
}
|
}
|
||||||
WebSocketDialogMsg::sendMsg($this->id, 0, 'notice', ['notice' => $notice], User::userid(), true);
|
WebSocketDialogMsg::sendMsg(null, $this->id, 'notice', ['notice' => $notice], User::userid(), true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -26,6 +26,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property int|null $send 发送数量
|
* @property int|null $send 发送数量
|
||||||
* @property int|null $tag 标注会员ID
|
* @property int|null $tag 标注会员ID
|
||||||
* @property int|null $link 是否存在链接
|
* @property int|null $link 是否存在链接
|
||||||
|
* @property int|null $modify 是否编辑
|
||||||
* @property int|null $reply_num 有多少条回复
|
* @property int|null $reply_num 有多少条回复
|
||||||
* @property int|null $reply_id 回复ID
|
* @property int|null $reply_id 回复ID
|
||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
@ -46,6 +47,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereId($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereId($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereKey($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereKey($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereLink($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereLink($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereModify($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereMsg($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereMsg($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereMtype($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereMtype($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereRead($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereRead($value)
|
||||||
@ -276,7 +278,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
$data = [
|
$data = [
|
||||||
'update' => $resData
|
'update' => $resData
|
||||||
];
|
];
|
||||||
$res = self::sendMsg($this->dialog_id, 0, 'tag', [
|
$res = self::sendMsg(null, $this->dialog_id, 'tag', [
|
||||||
'action' => $this->tag ? 'add' : 'remove',
|
'action' => $this->tag ? 'add' : 'remove',
|
||||||
'data' => [
|
'data' => [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
@ -307,7 +309,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
}
|
}
|
||||||
$dialog = WebSocketDialog::checkUserDialog($sender, $userid);
|
$dialog = WebSocketDialog::checkUserDialog($sender, $userid);
|
||||||
if ($dialog) {
|
if ($dialog) {
|
||||||
$res = self::sendMsg($dialog->id, 0, $this->type, $this->getOriginal('msg'), $sender);
|
$res = self::sendMsg(null, $dialog->id, $this->type, $this->getOriginal('msg'), $sender);
|
||||||
if (Base::isSuccess($res)) {
|
if (Base::isSuccess($res)) {
|
||||||
$msgs[] = $res['data'];
|
$msgs[] = $res['data'];
|
||||||
}
|
}
|
||||||
@ -515,16 +517,18 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送消息
|
* 发送消息、修改消息
|
||||||
|
* @param string $action 动作
|
||||||
|
* - reply-98:回复消息ID-98
|
||||||
|
* - update-99:更新消息ID-99
|
||||||
* @param int $dialog_id 会话ID(即 聊天室ID)
|
* @param int $dialog_id 会话ID(即 聊天室ID)
|
||||||
* @param int $reply_id 回复ID
|
|
||||||
* @param string $type 消息类型
|
* @param string $type 消息类型
|
||||||
* @param array $msg 发送的消息
|
* @param array $msg 发送的消息
|
||||||
* @param int $sender 发送的会员ID(默认自己,0为系统)
|
* @param int $sender 发送的会员ID(默认自己,0为系统)
|
||||||
* @param bool $push_self 是否推送给自己
|
* @param bool $push_self 是否推送给自己
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function sendMsg($dialog_id, $reply_id, $type, $msg, $sender = 0, $push_self = false)
|
public static function sendMsg($action, $dialog_id, $type, $msg, $sender = 0, $push_self = false)
|
||||||
{
|
{
|
||||||
$link = 0;
|
$link = 0;
|
||||||
$mtype = $type;
|
$mtype = $type;
|
||||||
@ -541,28 +545,64 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
$update_id = preg_match("/^update-(\d+)$/", $action, $match) ? $match[1] : 0;
|
||||||
|
$reply_id = preg_match("/^reply-(\d+)$/", $action, $match) ? $match[1] : 0;
|
||||||
|
$sender = $sender ?: User::userid();
|
||||||
|
//
|
||||||
|
$dialog = WebSocketDialog::find($dialog_id);
|
||||||
|
if (empty($dialog)) {
|
||||||
|
throw new ApiException('获取会话失败');
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if ($update_id) {
|
||||||
|
// 修改
|
||||||
|
$dialogMsg = self::whereId($update_id)->whereDialogId($dialog_id)->first();
|
||||||
|
if (empty($dialogMsg)) {
|
||||||
|
throw new ApiException('消息不存在');
|
||||||
|
}
|
||||||
|
if ($dialogMsg->type !== 'text') {
|
||||||
|
throw new ApiException('此消息不支持此操作');
|
||||||
|
}
|
||||||
|
if ($dialogMsg->userid != $sender) {
|
||||||
|
throw new ApiException('仅支持修改自己的消息');
|
||||||
|
}
|
||||||
|
//
|
||||||
|
$updateData = [
|
||||||
|
'mtype' => $mtype,
|
||||||
|
'link' => $link,
|
||||||
|
'msg' => $msg,
|
||||||
|
'modify' => 1,
|
||||||
|
];
|
||||||
|
$dialogMsg->updateInstance($updateData);
|
||||||
|
$dialogMsg->key = $dialogMsg->generateMsgKey();
|
||||||
|
$dialogMsg->save();
|
||||||
|
//
|
||||||
|
$dialog->pushMsg('update', array_merge($updateData, [
|
||||||
|
'id' => $dialogMsg->id
|
||||||
|
]));
|
||||||
|
//
|
||||||
|
return Base::retSuccess('修改成功', $dialogMsg);
|
||||||
|
} else {
|
||||||
|
// 发送
|
||||||
|
if ($reply_id && !self::whereId($reply_id)->increment('reply_num')) {
|
||||||
|
throw new ApiException('回复的消息不存在');
|
||||||
|
}
|
||||||
|
//
|
||||||
$dialogMsg = self::createInstance([
|
$dialogMsg = self::createInstance([
|
||||||
'dialog_id' => $dialog_id,
|
'dialog_id' => $dialog_id,
|
||||||
|
'dialog_type' => $dialog->type,
|
||||||
'reply_id' => $reply_id,
|
'reply_id' => $reply_id,
|
||||||
'userid' => $sender ?: User::userid(),
|
'userid' => $sender,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'mtype' => $mtype,
|
'mtype' => $mtype,
|
||||||
'link' => $link,
|
'link' => $link,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
'read' => 0,
|
'read' => 0,
|
||||||
]);
|
]);
|
||||||
if ($reply_id > 0) {
|
AbstractModel::transaction(function () use ($dialog, $dialogMsg) {
|
||||||
self::whereId($reply_id)->increment('reply_num');
|
|
||||||
}
|
|
||||||
AbstractModel::transaction(function () use ($dialogMsg) {
|
|
||||||
$dialog = WebSocketDialog::find($dialogMsg->dialog_id);
|
|
||||||
if (empty($dialog)) {
|
|
||||||
throw new ApiException('获取会话失败');
|
|
||||||
}
|
|
||||||
$dialog->last_at = Carbon::now();
|
$dialog->last_at = Carbon::now();
|
||||||
$dialog->save();
|
$dialog->save();
|
||||||
$dialogMsg->send = 1;
|
$dialogMsg->send = 1;
|
||||||
$dialogMsg->dialog_type = $dialog->type;
|
|
||||||
$dialogMsg->key = $dialogMsg->generateMsgKey();
|
$dialogMsg->key = $dialogMsg->generateMsgKey();
|
||||||
$dialogMsg->save();
|
$dialogMsg->save();
|
||||||
});
|
});
|
||||||
@ -576,3 +616,4 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
return Base::retSuccess('发送成功', $dialogMsg);
|
return Base::retSuccess('发送成功', $dialogMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddWebSocketDialogMsgsModify extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('web_socket_dialog_msgs', function (Blueprint $table) {
|
||||||
|
if (!Schema::hasColumn('web_socket_dialog_msgs', 'modify')) {
|
||||||
|
$table->boolean('modify')->default(0)->after('link')->nullable()->comment('是否编辑');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('web_socket_dialog_msgs', function (Blueprint $table) {
|
||||||
|
$table->dropColumn("modify");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -91,6 +91,10 @@
|
|||||||
<div v-if="msgData.tag" class="tag">
|
<div v-if="msgData.tag" class="tag">
|
||||||
<i class="taskfont"></i>
|
<i class="taskfont"></i>
|
||||||
</div>
|
</div>
|
||||||
|
<!--编辑-->
|
||||||
|
<div v-if="msgData.modify" class="modify">
|
||||||
|
<i class="taskfont"></i>
|
||||||
|
</div>
|
||||||
<!--等待/时间/阅读-->
|
<!--等待/时间/阅读-->
|
||||||
<Loading v-if="isLoading"/>
|
<Loading v-if="isLoading"/>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
|||||||
@ -164,26 +164,22 @@
|
|||||||
<i class="taskfont"></i>
|
<i class="taskfont"></i>
|
||||||
<span>{{ $L('回复') }}</span>
|
<span>{{ $L('回复') }}</span>
|
||||||
</li>
|
</li>
|
||||||
|
<li v-if="operateItem.userid == userId && operateItem.type === 'text'" @click="onOperate('update')">
|
||||||
|
<i class="taskfont"></i>
|
||||||
|
<span>{{ $L('编辑') }}</span>
|
||||||
|
</li>
|
||||||
|
<li v-if="operateHasText" @click="onOperate('copy')">
|
||||||
|
<i class="taskfont"></i>
|
||||||
|
<span>{{ $L('复制') }}</span>
|
||||||
|
</li>
|
||||||
<li @click="onOperate('forward')">
|
<li @click="onOperate('forward')">
|
||||||
<i class="taskfont"></i>
|
<i class="taskfont"></i>
|
||||||
<span>{{ $L('转发') }}</span>
|
<span>{{ $L('转发') }}</span>
|
||||||
</li>
|
</li>
|
||||||
<template v-if="operateHasText">
|
<li v-if="operateItem.userid == userId" @click="onOperate('withdraw')">
|
||||||
<li @click="onOperate('copy')">
|
|
||||||
<i class="taskfont"></i>
|
|
||||||
<span>{{ $L('复制') }}</span>
|
|
||||||
</li>
|
|
||||||
<li @click="onOperate('newTask')">
|
|
||||||
<i class="taskfont"></i>
|
|
||||||
<span>{{ $L('新任务') }}</span>
|
|
||||||
</li>
|
|
||||||
</template>
|
|
||||||
<template v-if="operateItem.userid == userId">
|
|
||||||
<li @click="onOperate('withdraw')">
|
|
||||||
<i class="taskfont"></i>
|
<i class="taskfont"></i>
|
||||||
<span>{{ $L('撤回') }}</span>
|
<span>{{ $L('撤回') }}</span>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
|
||||||
<template v-if="operateItem.type === 'file'">
|
<template v-if="operateItem.type === 'file'">
|
||||||
<li @click="onOperate('view')">
|
<li @click="onOperate('view')">
|
||||||
<i class="taskfont"></i>
|
<i class="taskfont"></i>
|
||||||
@ -198,6 +194,10 @@
|
|||||||
<i class="taskfont"></i>
|
<i class="taskfont"></i>
|
||||||
<span>{{ $L(operateItem.tag ? '取消标注' : '标注') }}</span>
|
<span>{{ $L(operateItem.tag ? '取消标注' : '标注') }}</span>
|
||||||
</li>
|
</li>
|
||||||
|
<li v-if="operateItem.type === 'text'" @click="onOperate('newTask')">
|
||||||
|
<i class="taskfont"></i>
|
||||||
|
<span>{{ $L('新任务') }}</span>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem name="emoji" class="dropdown-emoji">
|
<DropdownItem name="emoji" class="dropdown-emoji">
|
||||||
@ -389,6 +389,7 @@ export default {
|
|||||||
|
|
||||||
replyActiveId: 0,
|
replyActiveId: 0,
|
||||||
replyActiveIndex: -1,
|
replyActiveIndex: -1,
|
||||||
|
replyActiveUpdate: false,
|
||||||
|
|
||||||
replyListShow: false,
|
replyListShow: false,
|
||||||
replyListId: 0,
|
replyListId: 0,
|
||||||
@ -717,12 +718,36 @@ export default {
|
|||||||
}
|
}
|
||||||
msgText = msgText.replace(/<\/span> <\/p>$/, "</span></p>")
|
msgText = msgText.replace(/<\/span> <\/p>$/, "</span></p>")
|
||||||
//
|
//
|
||||||
|
if (this.replyActiveUpdate) {
|
||||||
|
// 修改
|
||||||
|
const update_id = this.replyId
|
||||||
|
this.$store.dispatch("setLoad", {
|
||||||
|
key: `msg-${update_id}`,
|
||||||
|
delay: 600
|
||||||
|
})
|
||||||
|
this.$store.dispatch("call", {
|
||||||
|
url: 'dialog/msg/sendtext',
|
||||||
|
data: {
|
||||||
|
dialog_id: this.dialogId,
|
||||||
|
update_id,
|
||||||
|
text: msgText,
|
||||||
|
},
|
||||||
|
method: 'post',
|
||||||
|
complete: _ => this.$store.dispatch("cancelLoad", `msg-${update_id}`)
|
||||||
|
}).then(({data}) => {
|
||||||
|
this.sendSuccess(data)
|
||||||
|
this.onPositionId(update_id)
|
||||||
|
}).catch(({msg}) => {
|
||||||
|
$A.modalError(msg)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 发送
|
||||||
this.msgType = '';
|
this.msgType = '';
|
||||||
this.onToBottom();
|
|
||||||
this.onActive();
|
this.onActive();
|
||||||
|
this.onToBottom();
|
||||||
//
|
//
|
||||||
let tempId = $A.randomString(16);
|
const tempId = $A.randNum(1000000000, 9999999999);
|
||||||
let tempMsg = {
|
const tempMsg = {
|
||||||
id: tempId,
|
id: tempId,
|
||||||
dialog_id: this.dialogData.id,
|
dialog_id: this.dialogData.id,
|
||||||
reply_id: this.replyId,
|
reply_id: this.replyId,
|
||||||
@ -746,14 +771,14 @@ export default {
|
|||||||
reply_id: this.replyId,
|
reply_id: this.replyId,
|
||||||
text: msgText,
|
text: msgText,
|
||||||
},
|
},
|
||||||
method: 'post'
|
method: 'post',
|
||||||
|
complete: _ => this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId)
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId)
|
this.sendSuccess(data)
|
||||||
this.sendSuccess(data);
|
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg)
|
||||||
this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId)
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -762,11 +787,11 @@ export default {
|
|||||||
*/
|
*/
|
||||||
sendRecord(msg) {
|
sendRecord(msg) {
|
||||||
this.msgType = '';
|
this.msgType = '';
|
||||||
this.onToBottom();
|
|
||||||
this.onActive();
|
this.onActive();
|
||||||
|
this.onToBottom();
|
||||||
//
|
//
|
||||||
let tempId = $A.randomString(16);
|
const tempId = $A.randNum(1000000000, 9999999999);
|
||||||
this.tempMsgs.push({
|
const tempMsg = {
|
||||||
id: tempId,
|
id: tempId,
|
||||||
dialog_id: this.dialogData.id,
|
dialog_id: this.dialogData.id,
|
||||||
reply_id: this.replyId,
|
reply_id: this.replyId,
|
||||||
@ -774,7 +799,8 @@ export default {
|
|||||||
type: 'loading',
|
type: 'loading',
|
||||||
userid: this.userId,
|
userid: this.userId,
|
||||||
msg,
|
msg,
|
||||||
});
|
}
|
||||||
|
this.tempMsgs.push(tempMsg);
|
||||||
//
|
//
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'dialog/msg/sendrecord',
|
url: 'dialog/msg/sendrecord',
|
||||||
@ -782,13 +808,12 @@ export default {
|
|||||||
dialog_id: this.dialogId,
|
dialog_id: this.dialogId,
|
||||||
reply_id: this.replyId,
|
reply_id: this.replyId,
|
||||||
}),
|
}),
|
||||||
method: 'post'
|
method: 'post',
|
||||||
|
complete: _ => this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId)
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId)
|
|
||||||
this.sendSuccess(data);
|
this.sendSuccess(data);
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId)
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -965,8 +990,8 @@ export default {
|
|||||||
chatFile(type, file) {
|
chatFile(type, file) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'progress':
|
case 'progress':
|
||||||
this.onToBottom();
|
|
||||||
this.onActive();
|
this.onActive();
|
||||||
|
this.onToBottom();
|
||||||
//
|
//
|
||||||
this.tempMsgs.push({
|
this.tempMsgs.push({
|
||||||
id: file.tempId,
|
id: file.tempId,
|
||||||
@ -991,15 +1016,15 @@ export default {
|
|||||||
|
|
||||||
sendSuccess(data) {
|
sendSuccess(data) {
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.some(item => {
|
data.some(this.sendSuccess)
|
||||||
this.sendSuccess(item)
|
|
||||||
})
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$store.dispatch("saveDialogMsg", data);
|
this.$store.dispatch("saveDialogMsg", data);
|
||||||
|
if (!this.replyActiveUpdate) {
|
||||||
this.$store.dispatch("increaseTaskMsgNum", this.dialogId);
|
this.$store.dispatch("increaseTaskMsgNum", this.dialogId);
|
||||||
this.$store.dispatch("increaseMsgReplyNum", data.reply_id);
|
this.$store.dispatch("increaseMsgReplyNum", data.reply_id);
|
||||||
this.$store.dispatch("updateDialogLastMsg", data);
|
this.$store.dispatch("updateDialogLastMsg", data);
|
||||||
|
}
|
||||||
this.onCancelReply();
|
this.onCancelReply();
|
||||||
this.onActive();
|
this.onActive();
|
||||||
},
|
},
|
||||||
@ -1264,31 +1289,23 @@ export default {
|
|||||||
this.operateVisible = false;
|
this.operateVisible = false;
|
||||||
this.$nextTick(_ => {
|
this.$nextTick(_ => {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
case "reply":
|
||||||
|
this.onReply()
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "update":
|
||||||
|
this.onUpdate()
|
||||||
|
break;
|
||||||
|
|
||||||
case "copy":
|
case "copy":
|
||||||
if (this.operateHasText) {
|
if (this.operateHasText) {
|
||||||
this.$copyText(this.operateItem.msg.text.replace(/<[^>]+>/g, "")).then(_ => {
|
const text = this.operateItem.msg.text.replace(/<[^>]+>/g, "")
|
||||||
$A.messageSuccess('复制成功');
|
this.$copyText(text).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败'));
|
||||||
}).catch(_ => {
|
|
||||||
$A.messageError('复制失败');
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
$A.messageWarning('不可复制的内容');
|
$A.messageWarning('不可复制的内容');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "newTask":
|
|
||||||
if (this.operateHasText) {
|
|
||||||
Store.set('addTask', {
|
|
||||||
owner: [this.userId],
|
|
||||||
name: this.operateItem.msg.text.replace(/<[^>]+>/g, "")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "reply":
|
|
||||||
this.onReply()
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "forward":
|
case "forward":
|
||||||
this.onForward('open')
|
this.onForward('open')
|
||||||
break;
|
break;
|
||||||
@ -1305,13 +1322,20 @@ export default {
|
|||||||
this.onDownFile()
|
this.onDownFile()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "emoji":
|
|
||||||
this.onEmoji(value)
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "tag":
|
case "tag":
|
||||||
this.onTag()
|
this.onTag()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "newTask":
|
||||||
|
Store.set('addTask', {
|
||||||
|
owner: [this.userId],
|
||||||
|
content: $A.formatMsgBasic(this.operateItem.msg.text)
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "emoji":
|
||||||
|
this.onEmoji(value)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -1325,7 +1349,19 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onUpdate() {
|
||||||
|
this.onReply()
|
||||||
|
if (this.operateItem.type === 'text') {
|
||||||
|
this.replyActiveUpdate = true
|
||||||
|
this.msgText = $A.formatMsgBasic(this.operateItem.msg.text)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onCancelReply() {
|
onCancelReply() {
|
||||||
|
if (this.replyActiveUpdate) {
|
||||||
|
this.replyActiveUpdate = false
|
||||||
|
this.msgText = ''
|
||||||
|
}
|
||||||
this.replyActiveId = 0;
|
this.replyActiveId = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -792,25 +792,23 @@
|
|||||||
height: 10px;
|
height: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reply {
|
.tag,
|
||||||
|
.reply,
|
||||||
|
.modify {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 12px;
|
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
color: $primary-color;
|
|
||||||
cursor: pointer;
|
|
||||||
> i {
|
> i {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
padding-right: 2px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag {
|
.reply {
|
||||||
display: flex;
|
font-size: 12px;
|
||||||
align-items: center;
|
color: $primary-color;
|
||||||
margin-right: 6px;
|
cursor: pointer;
|
||||||
> i {
|
> i {
|
||||||
font-size: 13px;
|
padding-right: 2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user