no message

This commit is contained in:
kuaifan 2022-01-05 22:46:22 +08:00
parent 90336e1edf
commit aba1628d36
22 changed files with 80 additions and 147 deletions

View File

@ -946,12 +946,11 @@ class ProjectController extends AbstractController
// //
$task_id = intval(Request::input('task_id')); $task_id = intval(Request::input('task_id'));
// //
$task = ProjectTask::userTask($task_id, ['taskUser', 'taskTag'], true, $project); $task = ProjectTask::userTask($task_id, true, false, ['taskUser', 'taskTag']);
// //
$data = $task->toArray(); $data = $task->toArray();
$data['project_name'] = $project?->name; $data['project_name'] = $task->project?->name;
$data['column_name'] = ProjectColumn::whereId($task->column_id)->value('name'); $data['column_name'] = $task->projectColumn?->name;
//
return Base::retSuccess('success', $data); return Base::retSuccess('success', $data);
} }
@ -1030,10 +1029,7 @@ class ProjectController extends AbstractController
return Base::retError('文件不存在或已被删除'); return Base::retError('文件不存在或已被删除');
} }
// //
$task = ProjectTask::userTask($file->task_id, [], true, $project); $task = ProjectTask::userTask($file->task_id, true, true);
if (!$task->isOwner() && !$project->owner) {
return Base::retError('仅限项目或任务负责人操作');
}
// //
$task->pushMsg('filedelete', $file); $task->pushMsg('filedelete', $file);
$file->delete(); $file->delete();
@ -1133,10 +1129,7 @@ class ProjectController extends AbstractController
$task_id = intval(Request::input('task_id')); $task_id = intval(Request::input('task_id'));
$name = Request::input('name'); $name = Request::input('name');
// //
$task = ProjectTask::userTask($task_id, [], true, $project); $task = ProjectTask::userTask($task_id, true, true);
if (!$task->isOwner() && !$project->owner) {
return Base::retError('仅限项目或任务负责人添加');
}
// //
$task = ProjectTask::addTask([ $task = ProjectTask::addTask([
'name' => $name, 'name' => $name,
@ -1187,14 +1180,7 @@ class ProjectController extends AbstractController
parse_str(Request::getContent(), $data); parse_str(Request::getContent(), $data);
$task_id = intval($data['task_id']); $task_id = intval($data['task_id']);
// //
$task = ProjectTask::userTask($task_id, [], true, $project); $task = ProjectTask::userTask($task_id, true, 2);
//
if ($task->hasOwner()) {
// 任务有负责人后仅限项目或任务负责人修改
if (!$task->isOwner() && !$project->owner) {
return Base::retError('仅限项目或任务负责人修改');
}
}
// 更新任务 // 更新任务
$updateProject = false; $updateProject = false;
$updateContent = false; $updateContent = false;
@ -1233,10 +1219,7 @@ class ProjectController extends AbstractController
// //
$task_id = Base::getPostInt('task_id'); $task_id = Base::getPostInt('task_id');
// //
$task = ProjectTask::userTask($task_id, [], true, $project); $task = ProjectTask::userTask($task_id, true, true);
if (!$task->isOwner() && !$project->owner) {
return Base::retError('仅限项目或任务负责人上传');
}
// //
$path = "uploads/task/" . $task->id . "/"; $path = "uploads/task/" . $task->id . "/";
$image64 = Base::getPostValue('image64'); $image64 = Base::getPostValue('image64');
@ -1350,10 +1333,7 @@ class ProjectController extends AbstractController
$task_id = intval(Request::input('task_id')); $task_id = intval(Request::input('task_id'));
$type = Request::input('type', 'add'); $type = Request::input('type', 'add');
// //
$task = ProjectTask::userTask($task_id, [], false, $project); $task = ProjectTask::userTask($task_id, false, true);
if (!$task->isOwner() && !$project->owner) {
return Base::retError('仅限项目或任务负责人操作');
}
// //
if ($task->parent_id > 0) { if ($task->parent_id > 0) {
return Base::retError('子任务不支持此功能'); return Base::retError('子任务不支持此功能');
@ -1387,10 +1367,7 @@ class ProjectController extends AbstractController
// //
$task_id = intval(Request::input('task_id')); $task_id = intval(Request::input('task_id'));
// //
$task = ProjectTask::userTask($task_id, [], true, $project); $task = ProjectTask::userTask($task_id, true, true);
if (!$task->isOwner() && !$project->owner) {
return Base::retError('仅限项目或任务负责人删除');
}
// //
$task->deleteTask(); $task->deleteTask();
return Base::retSuccess('删除成功', ['id' => $task->id]); return Base::retSuccess('删除成功', ['id' => $task->id]);

View File

@ -8,9 +8,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Response; use Response;
/** /**
* Class FileContent * App\Models\FileContent
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $fid 文件ID * @property int|null $fid 文件ID
* @property string|null $content 内容 * @property string|null $content 内容

View File

@ -11,26 +11,19 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Request; use Request;
/** /**
* Class Project * App\Models\Project
* *
* @package App\Models
* @property int $id * @property int $id
* @property string|null $name 名称 * @property string|null $name 名称
* @property string|null $desc 描述、备注 * @property string|null $desc 描述、备注
* @property int|null $userid 创建人 * @property int|null $userid 创建人
* @property int|mixed $dialog_id 聊天会话ID * @property int|null $dialog_id 聊天会话ID
* @property string|null $archived_at 归档时间 * @property string|null $archived_at 归档时间
* @property int|null $archived_userid 归档会员 * @property int|null $archived_userid 归档会员
* @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $created_at
* @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 int $owner_userid * @property-read int $owner_userid
* @property-read int $task_complete
* @property-read int $task_my_complete
* @property-read int $task_my_num
* @property-read int $task_my_percent
* @property-read int $task_num
* @property-read int $task_percent
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectColumn[] $projectColumn * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectColumn[] $projectColumn
* @property-read int|null $project_column_count * @property-read int|null $project_column_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectLog[] $projectLog * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectLog[] $projectLog
@ -337,20 +330,20 @@ class Project extends AbstractModel
/** /**
* 根据用户获取项目信息(用于判断会员是否存在项目内) * 根据用户获取项目信息(用于判断会员是否存在项目内)
* @param int $project_id * @param int $project_id
* @param null|bool $ignoreArchived 排除已归档 * @param null|bool $archived true:仅限未归档, false:仅限已归档, null:不限制
* @param null|bool $mustOwner 是否仅限项目负责人 * @param null|bool $mustOwner true:仅限项目负责人, false:仅限非项目负责人, null:不限制
* @return self * @return self
*/ */
public static function userProject($project_id, $ignoreArchived = true, $mustOwner = null) public static function userProject($project_id, $archived = true, $mustOwner = null)
{ {
$project = self::authData()->where('projects.id', intval($project_id))->first(); $project = self::authData()->where('projects.id', intval($project_id))->first();
if (empty($project)) { if (empty($project)) {
throw new ApiException('项目不存在或不在成员列表内', [ 'project_id' => $project_id ], -4001); throw new ApiException('项目不存在或不在成员列表内', [ 'project_id' => $project_id ], -4001);
} }
if ($ignoreArchived === true && $project->archived_at != null) { if ($archived === true && $project->archived_at != null) {
throw new ApiException('项目已归档', [ 'project_id' => $project_id ], -4001); throw new ApiException('项目已归档', [ 'project_id' => $project_id ], -4001);
} }
if ($ignoreArchived === false && $project->archived_at == null) { if ($archived === false && $project->archived_at == null) {
throw new ApiException('项目未归档', [ 'project_id' => $project_id ]); throw new ApiException('项目未归档', [ 'project_id' => $project_id ]);
} }
if ($mustOwner === true && !$project->owner) { if ($mustOwner === true && !$project->owner) {

View File

@ -9,9 +9,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Request; use Request;
/** /**
* Class ProjectColumn * App\Models\ProjectColumn
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $project_id 项目ID * @property int|null $project_id 项目ID
* @property string|null $name 列表名称 * @property string|null $name 列表名称

View File

@ -3,9 +3,8 @@
namespace App\Models; namespace App\Models;
/** /**
* Class ProjectLog * App\Models\ProjectLog
* *
* @package App\Models
* @property int $id * @property int $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

View File

@ -42,12 +42,12 @@ use Request;
* @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
* @property-read bool $owner
* @property-read int $percent * @property-read int $percent
* @property-read int $sub_complete * @property-read int $sub_complete
* @property-read int $sub_num * @property-read int $sub_num
* @property-read bool $today * @property-read bool $today
* @property-read \App\Models\Project|null $project * @property-read \App\Models\Project|null $project
* @property-read \App\Models\ProjectColumn|null $projectColumn
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectTaskFile[] $taskFile * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectTaskFile[] $taskFile
* @property-read int|null $task_file_count * @property-read int|null $task_file_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectTaskTag[] $taskTag * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectTaskTag[] $taskTag
@ -91,11 +91,6 @@ class ProjectTask extends AbstractModel
{ {
use SoftDeletes; use SoftDeletes;
const taskSelect = [
'project_tasks.*',
'project_task_users.owner',
];
protected $appends = [ protected $appends = [
'file_num', 'file_num',
'msg_num', 'msg_num',
@ -223,6 +218,14 @@ class ProjectTask extends AbstractModel
return $this->hasOne(Project::class, 'id', 'project_id'); return $this->hasOne(Project::class, 'id', 'project_id');
} }
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function projectColumn(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(ProjectColumn::class, 'id', 'column_id');
}
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasOne * @return \Illuminate\Database\Eloquent\Relations\HasOne
*/ */
@ -869,32 +872,39 @@ class ProjectTask extends AbstractModel
/** /**
* 根据会员ID获取任务、项目信息会员有任务权限 会员存在项目内) * 根据会员ID获取任务、项目信息会员有任务权限 会员存在项目内)
* @param int $task_id * @param int $task_id
* @param bool $archived true:仅限未归档, false:不限制
* @param int|bool $mustOwner 0|false:不限制, 1|true:限制任务或项目负责人, 2:已有负责人才限制任务或项目负责人
* @param array $with * @param array $with
* @param bool $ignoreArchived 排除已归档
* @param null $project
* @return self * @return self
*/ */
public static function userTask($task_id, $with = [], $ignoreArchived = true, &$project = null) public static function userTask($task_id, $archived = true, $mustOwner = 0, $with = [])
{ {
$task = self::with($with)->whereId(intval($task_id))->first(); $task = self::with($with)->allData()->where("project_tasks.id", intval($task_id))->first();
//
if (empty($task)) { if (empty($task)) {
throw new ApiException('任务不存在', [ 'task_id' => $task_id ], -4002); throw new ApiException('任务不存在', [ 'task_id' => $task_id ], -4002);
} }
if ($ignoreArchived && $task->archived_at != null) { if ($archived === true && $task->archived_at != null) {
throw new ApiException('任务已归档', [ 'task_id' => $task_id ], -4002); throw new ApiException('任务已归档', [ 'task_id' => $task_id ], -4002);
} }
// //
try { try {
$project = Project::userProject($task->project_id, $ignoreArchived); $project = Project::userProject($task->project_id, $archived);
} catch (Exception $e) { } catch (Exception $e) {
if (ProjectTaskUser::whereUserid(User::userid())->whereTaskPid($task->id)->exists()) { if ($task->owner === null) {
$project = Project::find($task->project_id);
if (empty($project)) {
throw new ApiException('项目不存在或已被删除', [ 'task_id' => $task_id ], -4002);
}
} else {
throw new ApiException($e->getMessage(), [ 'task_id' => $task_id ], -4002); throw new ApiException($e->getMessage(), [ 'task_id' => $task_id ], -4002);
} }
$project = Project::find($task->project_id);
if (empty($project)) {
throw new ApiException('项目不存在或已被删除', [ 'task_id' => $task_id ], -4002);
}
}
//
if ($mustOwner === 2) {
$mustOwner = $task->hasOwner() ? 1 : 0;
}
if (($mustOwner === 1 || $mustOwner === true) && !$task->owner && !$project->owner) {
throw new ApiException('仅限项目或任务负责人操作');
} }
// //
return $task; return $task;

View File

@ -3,9 +3,8 @@
namespace App\Models; namespace App\Models;
/** /**
* Class ProjectTaskContent * App\Models\ProjectTaskContent
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $project_id 项目ID * @property int|null $project_id 项目ID
* @property int|null $task_id 任务ID * @property int|null $task_id 任务ID

View File

@ -5,17 +5,16 @@ namespace App\Models;
use App\Module\Base; use App\Module\Base;
/** /**
* Class ProjectTaskFile * App\Models\ProjectTaskFile
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $project_id 项目ID * @property int|null $project_id 项目ID
* @property int|null $task_id 任务ID * @property int|null $task_id 任务ID
* @property string|null $name 文件名称 * @property string|null $name 文件名称
* @property int|null $size 文件大小(B) * @property int|null $size 文件大小(B)
* @property string|null $ext 文件格式 * @property string|null $ext 文件格式
* @property string|null $path 文件地址 * @property string $path 文件地址
* @property string|null $thumb 缩略图 * @property string $thumb 缩略图
* @property int|null $userid 上传用户ID * @property int|null $userid 上传用户ID
* @property int|null $download 下载次数 * @property int|null $download 下载次数
* @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $created_at

View File

@ -3,9 +3,8 @@
namespace App\Models; namespace App\Models;
/** /**
* Class ProjectTaskTag * App\Models\ProjectTaskTag
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $project_id 项目ID * @property int|null $project_id 项目ID
* @property int|null $task_id 任务ID * @property int|null $task_id 任务ID

View File

@ -3,9 +3,8 @@
namespace App\Models; namespace App\Models;
/** /**
* Class ProjectTaskUser * App\Models\ProjectTaskUser
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $project_id 项目ID * @property int|null $project_id 项目ID
* @property int|null $task_id 任务ID * @property int|null $task_id 任务ID

View File

@ -5,9 +5,8 @@ namespace App\Models;
use App\Module\Base; use App\Module\Base;
/** /**
* Class ProjectUser * App\Models\ProjectUser
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $project_id 项目ID * @property int|null $project_id 项目ID
* @property int|null $userid 成员ID * @property int|null $userid 成员ID

View File

@ -3,9 +3,8 @@
namespace App\Models; namespace App\Models;
/** /**
* Class Setting * App\Models\Setting
* *
* @package App\Models
* @property int $id * @property int $id
* @property string|null $name * @property string|null $name
* @property string|null $desc 参数描述、备注 * @property string|null $desc 参数描述、备注

View File

@ -3,9 +3,8 @@
namespace App\Models; namespace App\Models;
/** /**
* Class Tmp * App\Models\Tmp
* *
* @package App\Models
* @property int $id * @property int $id
* @property string|null $name * @property string|null $name
* @property string|null $value * @property string|null $value

View File

@ -9,9 +9,8 @@ use Cache;
use Carbon\Carbon; use Carbon\Carbon;
/** /**
* Class User * App\Models\User
* *
* @package App\Models
* @property int $userid * @property int $userid
* @property array $identity 身份 * @property array $identity 身份
* @property string|null $az A-Z * @property string|null $az A-Z

View File

@ -4,14 +4,13 @@ namespace App\Models;
/** /**
* Class WebSocket * App\Models\WebSocket
* *
* @package App\Models
* @property int $id * @property int $id
* @property string $key * @property string $key
* @property string|null $fd * @property string|null $fd
* @property int|null $userid
* @property string|null $path * @property string|null $path
* @property int|null $userid
* @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|WebSocket newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|WebSocket newModelQuery()

View File

@ -7,9 +7,8 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
/** /**
* Class WebSocketDialog * App\Models\WebSocketDialog
* *
* @package App\Models
* @property int $id * @property int $id
* @property string|null $type 对话类型 * @property string|null $type 对话类型
* @property string|null $group_type 聊天室类型 * @property string|null $group_type 聊天室类型

View File

@ -10,9 +10,8 @@ use Carbon\Carbon;
use Hhxsv5\LaravelS\Swoole\Task\Task; use Hhxsv5\LaravelS\Swoole\Task\Task;
/** /**
* Class WebSocketDialogMsg * App\Models\WebSocketDialogMsg
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $dialog_id 对话ID * @property int|null $dialog_id 对话ID
* @property int|null $userid 发送会员ID * @property int|null $userid 发送会员ID

View File

@ -3,9 +3,8 @@
namespace App\Models; namespace App\Models;
/** /**
* Class WebSocketDialogMsgRead * App\Models\WebSocketDialogMsgRead
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $dialog_id 对话ID * @property int|null $dialog_id 对话ID
* @property int|null $msg_id 消息ID * @property int|null $msg_id 消息ID

View File

@ -3,9 +3,8 @@
namespace App\Models; namespace App\Models;
/** /**
* Class WebSocketDialogUser * App\Models\WebSocketDialogUser
* *
* @package App\Models
* @property int $id * @property int $id
* @property int|null $dialog_id 对话ID * @property int|null $dialog_id 对话ID
* @property int|null $userid 会员ID * @property int|null $userid 会员ID

View File

@ -3,9 +3,8 @@
namespace App\Models; namespace App\Models;
/** /**
* Class WebSocketTmpMsg * App\Models\WebSocketTmpMsg
* *
* @package App\Models
* @property int $id * @property int $id
* @property string|null $md5 MD5(会员ID-消息) * @property string|null $md5 MD5(会员ID-消息)
* @property string|null $msg 详细消息 * @property string|null $msg 详细消息

View File

@ -142,10 +142,10 @@
*/ */
getMiddle(string, start, end) { getMiddle(string, start, end) {
string = string.toString(); string = string.toString();
if (this.ishave(start) && this.strExists(string, start)) { if (this.isHave(start) && this.strExists(string, start)) {
string = string.substring(string.indexOf(start) + start.length); string = string.substring(string.indexOf(start) + start.length);
} }
if (this.ishave(end) && this.strExists(string, end)) { if (this.isHave(end) && this.strExists(string, end)) {
string = string.substring(0, string.indexOf(end)); string = string.substring(0, string.indexOf(end));
} }
return string; return string;
@ -160,7 +160,7 @@
*/ */
subString(string, start, end) { subString(string, start, end) {
string += ""; string += "";
if (!this.ishave(end)) { if (!this.isHave(end)) {
end = string.length; end = string.length;
} }
return string.substring(start, end); return string.substring(start, end);
@ -187,7 +187,7 @@
* @param set * @param set
* @returns {boolean} * @returns {boolean}
*/ */
ishave(set) { isHave(set) {
return !!(set !== null && set !== "null" && set !== undefined && set !== "undefined" && set); return !!(set !== null && set !== "null" && set !== undefined && set !== "undefined" && set);
}, },
@ -197,12 +197,12 @@
* @param fixed * @param fixed
* @returns {number} * @returns {number}
*/ */
runNum(str, fixed) { runNum(str, fixed = null) {
let _s = Number(str); let _s = Number(str);
if (_s + "" === "NaN") { if (_s + "" === "NaN") {
_s = 0; _s = 0;
} }
if (/^[0-9]*[1-9][0-9]*$/.test(fixed)) { if (fixed && /^[0-9]*[1-9][0-9]*$/.test(fixed)) {
_s = _s.toFixed(fixed); _s = _s.toFixed(fixed);
let rs = _s.indexOf('.'); let rs = _s.indexOf('.');
if (rs < 0) { if (rs < 0) {
@ -349,15 +349,6 @@
return /^1([3456789])\d{9}$/.test(str); return /^1([3456789])\d{9}$/.test(str);
}, },
/**
* 是否手机号码
* @param phone
* @returns {boolean}
*/
isPhone(phone) {
return this.isMobile(phone);
},
/** /**
* 根据两点间的经纬度计算距离 * 根据两点间的经纬度计算距离
* @param lng1 * @param lng1
@ -416,24 +407,6 @@
} }
}, },
/**
* 克隆对象
* @param myObj
* @returns {*}
*/
cloneData(myObj) {
if(typeof(myObj) !== 'object') return myObj;
if(myObj === null) return myObj;
//
if (typeof myObj.length === 'number') {
let [ ...myNewObj ] = myObj;
return myNewObj;
}else{
let { ...myNewObj } = myObj;
return myNewObj;
}
},
/** /**
* 克隆对象 * 克隆对象
* @param myObj * @param myObj
@ -452,7 +425,7 @@
* @param defaultVal * @param defaultVal
* @returns {*} * @returns {*}
*/ */
jsonParse(str, defaultVal) { jsonParse(str, defaultVal = undefined) {
if (str === null) { if (str === null) {
return defaultVal ? defaultVal : {}; return defaultVal ? defaultVal : {};
} }
@ -472,7 +445,7 @@
* @param defaultVal * @param defaultVal
* @returns {string} * @returns {string}
*/ */
jsonStringify(json, defaultVal) { jsonStringify(json, defaultVal = undefined) {
if (typeof json !== 'object') { if (typeof json !== 'object') {
return json; return json;
} }
@ -544,10 +517,10 @@
if (this.count(obj) === 0 || this.count(keys) === 0) { if (this.count(obj) === 0 || this.count(keys) === 0) {
return ""; return "";
} }
let arr = keys.replace(/,/g, "|").replace(/\./g, "|").split("|"); let array = keys.replace(/,/g, "|").replace(/\./g, "|").split("|");
$A.each(arr, (index, key) => { array.some(key => {
object = typeof object[key] === "undefined" ? "" : object[key]; object = typeof object[key] === "undefined" ? "" : object[key];
}); })
return object; return object;
}, },
@ -736,7 +709,7 @@
* @param object * @param object
* @param content * @param content
*/ */
insert2Input (object, content) { insert2Input(object, content) {
if (object === null || typeof object !== "object") return; if (object === null || typeof object !== "object") return;
if (typeof object.length === 'number' && object.length > 0) object = object[0]; if (typeof object.length === 'number' && object.length > 0) object = object[0];
@ -1045,7 +1018,7 @@
* ============================================================================= * =============================================================================
*/ */
$.extend({ $.extend({
serializeObject (obj, parents) { serializeObject(obj, parents) {
if (typeof obj === 'string') return obj; if (typeof obj === 'string') return obj;
let resultArray = []; let resultArray = [];
let separator = '&'; let separator = '&';

View File

@ -119,21 +119,21 @@ export default {
}, },
theme: { theme: {
handler(newValue) { handler(newValue) {
this.calendarInstance.setTheme(this.cloneData(newValue)); this.calendarInstance.setTheme($A.cloneJSON(newValue));
}, },
deep: true deep: true
}, },
week: { week: {
handler(newValue) { handler(newValue) {
const silent = this.view !== 'week' && this.view !== 'day'; const silent = this.view !== 'week' && this.view !== 'day';
this.calendarInstance.setOptions({week: this.cloneData(newValue)}, silent); this.calendarInstance.setOptions({week: $A.cloneJSON(newValue)}, silent);
}, },
deep: true deep: true
}, },
month: { month: {
handler(newValue) { handler(newValue) {
const silent = this.view !== 'month'; const silent = this.view !== 'month';
this.calendarInstance.setOptions({month: this.cloneData(newValue)}, silent); this.calendarInstance.setOptions({month: $A.cloneJSON(newValue)}, silent);
}, },
deep: true deep: true
}, },
@ -176,9 +176,6 @@ export default {
this.calendarInstance.destroy(); this.calendarInstance.destroy();
}, },
methods: { methods: {
cloneData(data) {
return JSON.parse(JSON.stringify(data));
},
addEventListeners() { addEventListeners() {
for (const eventName of Object.keys(this.$listeners)) { for (const eventName of Object.keys(this.$listeners)) {
this.calendarInstance.on(eventName, (...args) => this.$emit(eventName, ...args)); this.calendarInstance.on(eventName, (...args) => this.$emit(eventName, ...args));