feat: 客户端登录,新增工作报告、修改工作报告、查看工作报告,全部直接在新窗口打开

This commit is contained in:
韦荣超 2022-03-11 12:06:36 +08:00
parent e301abe9e3
commit a4b69c3911
7 changed files with 143 additions and 11 deletions

View File

@ -362,6 +362,7 @@ class ReportController extends AbstractController
*/ */
public function detail(): array public function detail(): array
{ {
$user = User::auth();
$id = intval(trim(Request::input("id"))); $id = intval(trim(Request::input("id")));
if (empty($id)) if (empty($id))
return Base::retError("缺少ID参数"); return Base::retError("缺少ID参数");
@ -369,7 +370,6 @@ class ReportController extends AbstractController
$one = Report::getOne($id); $one = Report::getOne($id);
$one->type_val = $one->getRawOriginal("type"); $one->type_val = $one->getRawOriginal("type");
$user = User::auth();
// 标记为已读 // 标记为已读
if (!empty($one->receivesUser)) { if (!empty($one->receivesUser)) {
foreach ($one->receivesUser as $item) { foreach ($one->receivesUser as $item) {

View File

@ -101,15 +101,13 @@ class Report extends AbstractModel
/** /**
* 获取单条记录 * 获取单条记录
* @param $id * @param $id
* @param User|null $user
* @return Report|Builder|Model|object|null * @return Report|Builder|Model|object|null
* @throw ApiException * @throw ApiException
*/ */
public static function getOne($id, User $user = null) public static function getOne($id)
{ {
$user === null && $user = User::auth(); $one = self::whereId($id)->first();
$one = self::whereUserid($user->userid)->whereId($id)->first(); if (empty($one))
if ( empty($one) )
throw new ApiException("记录不存在"); throw new ApiException("记录不存在");
return $one; return $one;
} }

View File

@ -85,14 +85,59 @@ export default {
}, },
onView(row) { onView(row) {
this.showDetailDrawer = true;
this.detailData = row; this.detailData = row;
this.$emit("on-read"); 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.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() { saveSuccess() {

View File

@ -140,7 +140,7 @@ export default {
}, },
on: { on: {
action: (name) => { 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); if (name === 'view') this.$emit("on-view", row);
} }
} }
@ -197,7 +197,7 @@ export default {
}, },
addReport() { addReport() {
this.$emit("on-edit", 0); this.$emit("on-edit", 0, this.$L('新增报告'));
} }
} }
} }

View File

@ -0,0 +1,53 @@
<template>
<div class="electron-report">
<PageTitle :title="$L('报告详情')"/>
<ReportDetail :data="detailData"/>
</div>
</template>
<style lang="scss" scoped>
.electron-report {
height: 100%;
display: flex;
flex-direction: column;
overflow: auto;
}
</style>
<script>
import ReportDetail from "../manage/components/ReportDetail";
export default {
components: {ReportDetail},
name: "reportDetail",
data() {
return {
detailData: {},
};
},
watch: {
'$route': {
handler() {
this.getDetail();
},
immediate: true
},
},
methods: {
getDetail() {
this.$store.dispatch("call", {
url: 'report/detail',
data: {
id: $A.runNum(this.$route.params.id),
},
}).then(({data}) => {
this.detailData = data;
}).catch(({msg}) => {
$A.messageError(msg);
});
},
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,26 @@
<template>
<div class="electron-report">
<PageTitle :title="$L('添加/编辑报告')"/>
<ReportEdit :id="$A.runNum(this.$route.params.id)"/>
</div>
</template>
<style lang="scss" scoped>
.electron-report {
height: 100%;
display: flex;
flex-direction: column;
overflow: auto;
}
</style>
<script>
import ReportEdit from "../manage/components/ReportEdit"
export default {
components: {ReportEdit},
name: "reportEdit"
}
</script>
<style scoped>
</style>

View File

@ -96,6 +96,16 @@ export default [
meta: {title: '验证绑定邮箱'}, meta: {title: '验证绑定邮箱'},
component: () => import('./pages/single/validEmail.vue') 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', name: 'login',
path: '/login', path: '/login',