From a4b69c3911335cb554919072023f9307e0dc15c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E8=8D=A3=E8=B6=85?= <302645122@qq.com> Date: Fri, 11 Mar 2022 12:06:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=99=BB?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=B7=A5=E4=BD=9C=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E3=80=81=E4=BF=AE=E6=94=B9=E5=B7=A5=E4=BD=9C=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E3=80=81=E6=9F=A5=E7=9C=8B=E5=B7=A5=E4=BD=9C=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=EF=BC=8C=E5=85=A8=E9=83=A8=E7=9B=B4=E6=8E=A5=E5=9C=A8?= =?UTF-8?q?=E6=96=B0=E7=AA=97=E5=8F=A3=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/ReportController.php | 2 +- app/Models/Report.php | 8 ++- .../js/pages/manage/components/Report.vue | 51 ++++++++++++++++-- .../js/pages/manage/components/ReportMy.vue | 4 +- .../assets/js/pages/single/reportDetail.vue | 53 +++++++++++++++++++ .../assets/js/pages/single/reportEdit.vue | 26 +++++++++ resources/assets/js/routes.js | 10 ++++ 7 files changed, 143 insertions(+), 11 deletions(-) create mode 100644 resources/assets/js/pages/single/reportDetail.vue create mode 100644 resources/assets/js/pages/single/reportEdit.vue diff --git a/app/Http/Controllers/Api/ReportController.php b/app/Http/Controllers/Api/ReportController.php index 9424f84f7..e8299c54d 100755 --- a/app/Http/Controllers/Api/ReportController.php +++ b/app/Http/Controllers/Api/ReportController.php @@ -362,6 +362,7 @@ class ReportController extends AbstractController */ public function detail(): array { + $user = User::auth(); $id = intval(trim(Request::input("id"))); if (empty($id)) return Base::retError("缺少ID参数"); @@ -369,7 +370,6 @@ class ReportController extends AbstractController $one = Report::getOne($id); $one->type_val = $one->getRawOriginal("type"); - $user = User::auth(); // 标记为已读 if (!empty($one->receivesUser)) { foreach ($one->receivesUser as $item) { diff --git a/app/Models/Report.php b/app/Models/Report.php index 1b5dca7f6..24df1078a 100644 --- a/app/Models/Report.php +++ b/app/Models/Report.php @@ -101,15 +101,13 @@ class Report extends AbstractModel /** * 获取单条记录 * @param $id - * @param User|null $user * @return Report|Builder|Model|object|null * @throw ApiException */ - public static function getOne($id, User $user = null) + public static function getOne($id) { - $user === null && $user = User::auth(); - $one = self::whereUserid($user->userid)->whereId($id)->first(); - if ( empty($one) ) + $one = self::whereId($id)->first(); + if (empty($one)) throw new ApiException("记录不存在"); return $one; } diff --git a/resources/assets/js/pages/manage/components/Report.vue b/resources/assets/js/pages/manage/components/Report.vue index 1650f8671..9199632f6 100644 --- a/resources/assets/js/pages/manage/components/Report.vue +++ b/resources/assets/js/pages/manage/components/Report.vue @@ -85,14 +85,59 @@ export default { }, onView(row) { - this.showDetailDrawer = true; this.detailData = row; this.$emit("on-read"); + if (this.$Electron) { + let config = { + title: row.title, + titleFixed: true, + parent: null, + width: Math.min(window.screen.availWidth, this.$el.clientWidth + 72), + height: Math.min(window.screen.availHeight, this.$el.clientHeight + 72), + minWidth: 600, + minHeight: 450, + }; + if (this.hasOpenDialog) { + config.minWidth = 800; + config.minHeight = 600; + } + this.$Electron.sendMessage('windowRouter', { + name: 'report-' + row.id, + path: "/single/report/detail/" + row.id, + force: false, + config + }); + }else{ + this.showDetailDrawer = true; + } }, - onEditReport(id) { + onEditReport(id,title) { this.reportId = id; - this.showEditDrawer = true; + if (this.$Electron) { + let config = { + title: title, + titleFixed: true, + parent: null, + width: Math.min(window.screen.availWidth, this.$el.clientWidth + 72), + height: Math.min(window.screen.availHeight, this.$el.clientHeight + 72), + minWidth: 600, + minHeight: 450, + }; + if (this.hasOpenDialog) { + config.minWidth = 800; + config.minHeight = 600; + } + this.$Electron.sendMessage('windowRouter', { + name: 'report-' + id, + path: "/single/report/edit/" + id, + force: false, + config + }); + } else { + this.showEditDrawer = true; + } + }, saveSuccess() { diff --git a/resources/assets/js/pages/manage/components/ReportMy.vue b/resources/assets/js/pages/manage/components/ReportMy.vue index cbf52643d..2d73d9311 100644 --- a/resources/assets/js/pages/manage/components/ReportMy.vue +++ b/resources/assets/js/pages/manage/components/ReportMy.vue @@ -140,7 +140,7 @@ export default { }, on: { action: (name) => { - if (name === 'edit') this.$emit("on-edit", row.id); + if (name === 'edit') this.$emit("on-edit", row.id, row.title); if (name === 'view') this.$emit("on-view", row); } } @@ -197,7 +197,7 @@ export default { }, addReport() { - this.$emit("on-edit", 0); + this.$emit("on-edit", 0, this.$L('新增报告')); } } } diff --git a/resources/assets/js/pages/single/reportDetail.vue b/resources/assets/js/pages/single/reportDetail.vue new file mode 100644 index 000000000..ec56fa9ee --- /dev/null +++ b/resources/assets/js/pages/single/reportDetail.vue @@ -0,0 +1,53 @@ + + + + + diff --git a/resources/assets/js/pages/single/reportEdit.vue b/resources/assets/js/pages/single/reportEdit.vue new file mode 100644 index 000000000..422bed0fd --- /dev/null +++ b/resources/assets/js/pages/single/reportEdit.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/resources/assets/js/routes.js b/resources/assets/js/routes.js index 5b237de7d..937f293f7 100755 --- a/resources/assets/js/routes.js +++ b/resources/assets/js/routes.js @@ -96,6 +96,16 @@ export default [ meta: {title: '验证绑定邮箱'}, component: () => import('./pages/single/validEmail.vue') }, + { + name: 'report-edit', + path: '/single/report/edit/:id', + component: () => import('./pages/single/reportEdit.vue') + }, + { + name: 'report-detail', + path: '/single/report/detail/:id', + component: () => import('./pages/single/reportDetail.vue') + }, { name: 'login', path: '/login',