feat: 支持使用%发送工作报告

This commit is contained in:
kuaifan 2025-03-15 17:53:21 +08:00
parent 021c09e426
commit 7ca0bc5960
4 changed files with 106 additions and 82 deletions

View File

@ -6,6 +6,7 @@ use App\Exceptions\ApiException;
use App\Models\AbstractModel; use App\Models\AbstractModel;
use App\Models\ProjectTask; use App\Models\ProjectTask;
use App\Models\Report; use App\Models\Report;
use App\Models\ReportLink;
use App\Models\ReportReceive; use App\Models\ReportReceive;
use App\Models\User; use App\Models\User;
use App\Module\Base; use App\Module\Base;
@ -441,7 +442,8 @@ class ReportController extends AbstractController
* @apiGroup report * @apiGroup report
* @apiName detail * @apiName detail
* *
* @apiParam {Number} [id] 报告id * @apiParam {Number} [id] 报告ID
* @apiParam {String} [code] 报告分享代码与ID二选一优先ID
* *
* @apiSuccess {Number} ret 返回状态码1正确、0错误 * @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述) * @apiSuccess {String} msg 返回信息(错误描述)
@ -450,13 +452,17 @@ class ReportController extends AbstractController
public function detail(): array public function detail(): array
{ {
$user = User::auth(); $user = User::auth();
//
$id = intval(trim(Request::input("id"))); $id = intval(trim(Request::input("id")));
if (empty($id)) $code = trim(Request::input("code"));
//
if (empty($id) && empty($code)) {
return Base::retError("缺少ID参数"); return Base::retError("缺少ID参数");
}
//
if (!empty($id)) {
$one = Report::getOne($id); $one = Report::getOne($id);
$one->type_val = $one->getRawOriginal("type"); $one->type_val = $one->getRawOriginal("type");
// 标记为已读 // 标记为已读
if (!empty($one->receivesUser)) { if (!empty($one->receivesUser)) {
foreach ($one->receivesUser as $item) { foreach ($one->receivesUser as $item) {
@ -467,7 +473,14 @@ class ReportController extends AbstractController
} }
} }
} }
} else {
$link = ReportLink::whereCode($code)->first();
if (empty($link)) {
return Base::retError("报告不存在或已被删除");
}
$one = Report::getOne($link->rid);
$one->report_link = $link;
}
return Base::retSuccess("success", $one); return Base::retSuccess("success", $one);
} }

View File

@ -4,43 +4,43 @@
{{ data.title }} {{ data.title }}
<Icon v-if="loadIng > 0" type="ios-loading" class="icon-loading"></Icon> <Icon v-if="loadIng > 0" type="ios-loading" class="icon-loading"></Icon>
</div> </div>
<div v-if="formOptions.labelWidth === 'auto'" class="report-detail-context"> <div class="report-detail-context">
<Form class="report-form auto-form" label-width="auto" inline> <ul>
<FormItem :label="$L('汇报人')"> <li>
<UserAvatar :userid="data.userid" :size="28"/> <div class="report-label">
</FormItem> {{ $L("汇报人") }}
<FormItem :label="$L('提交时间')">
{{ data.created_at }}
</FormItem>
<FormItem :label="$L('汇报对象')">
<template v-if="data.receives_user.length === 0">-</template>
<UserAvatar v-else v-for="(item, key) in data.receives_user" :key="key" :userid="item.userid" :size="28"/>
</FormItem>
</Form>
<Form class="report-form auto-form" label-width="auto">
<FormItem :label="$L('汇报内容')">
<div class="report-content" v-html="data.content"></div>
</FormItem>
</Form>
</div> </div>
<div v-else class="report-detail-context"> <div class="report-value">
<Form class="report-form" v-bind="formOptions">
<template v-if="formOptions.labelWidth !== 'auto'">
<FormItem :label="$L('汇报人')">
<UserAvatar :userid="data.userid" :size="28"/> <UserAvatar :userid="data.userid" :size="28"/>
</FormItem> </div>
<FormItem :label="$L('提交时间')"> </li>
<li>
<div class="report-label">
{{ $L("提交时间") }}
</div>
<div class="report-value">
{{ data.created_at }} {{ data.created_at }}
</FormItem> </div>
<FormItem :label="$L('汇报对象')"> </li>
<li>
<div class="report-label">
{{ $L("汇报对象") }}
</div>
<div class="report-value">
<template v-if="data.receives_user.length === 0">-</template> <template v-if="data.receives_user.length === 0">-</template>
<UserAvatar v-else v-for="(item, key) in data.receives_user" :key="key" :userid="item.userid" :size="28"/> <UserAvatar v-else v-for="(item, key) in data.receives_user" :key="key" :userid="item.userid" :size="28"/>
</FormItem> </div>
</template> </li>
<FormItem :label="$L('汇报内容')"> <li v-if="data.report_link" :title="$L('分享时间') + '' + data.report_link.created_at">
<div class="report-label">
{{ $L("分享人") }}
</div>
<div class="report-value">
<UserAvatar :userid="data.report_link.userid" :size="28"/>
</div>
</li>
</ul>
<div class="report-content" v-html="data.content"></div> <div class="report-content" v-html="data.content"></div>
</FormItem>
</Form>
</div> </div>
</div> </div>
</template> </template>
@ -53,7 +53,10 @@ export default {
props: { props: {
data: { data: {
default: {}, default: {},
} },
type: {
default: 'view',
},
}, },
data() { data() {
return { return {
@ -66,7 +69,9 @@ export default {
watch: { watch: {
'data.id': { 'data.id': {
handler(id) { handler(id) {
if (id > 0) this.sendRead(); if (id > 0 && this.type === 'view') {
this.sendRead();
}
}, },
immediate: true immediate: true
}, },

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="electron-report"> <div class="electron-report">
<PageTitle :title="$L('报告详情')"/> <PageTitle :title="$L('报告详情')"/>
<ReportDetail :data="detailData"/> <ReportDetail :data="detailData" :type="type"/>
</div> </div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -19,17 +19,18 @@ export default {
components: {ReportDetail}, components: {ReportDetail},
data() { data() {
return { return {
type: 'view',
detailData: {}, detailData: {},
}; };
}, },
computed: { computed: {
reportDetailId() { reportId() {
const {reportDetailId} = this.$route.params; const {reportDetailId} = this.$route.params;
return parseInt(/^\d+$/.test(reportDetailId) ? reportDetailId : 0); return reportDetailId;
}, },
}, },
watch: { watch: {
reportDetailId: { reportId: {
handler() { handler() {
this.getDetail(); this.getDetail();
}, },
@ -38,14 +39,20 @@ export default {
}, },
methods: { methods: {
getDetail() { getDetail() {
if (this.reportDetailId <= 0) { if (!this.reportId) {
return; return;
} }
const data = {}
if (/^\d+$/.test(this.reportId)) {
data.id = this.reportId;
this.type = 'view';
} else {
data.code = this.reportId;
this.type = 'share';
}
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'report/detail', url: 'report/detail',
data: { data,
id: this.reportDetailId,
},
}).then(({data}) => { }).then(({data}) => {
this.detailData = data; this.detailData = data;
}).catch(({msg}) => { }).catch(({msg}) => {

View File

@ -80,41 +80,40 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow: auto; overflow: auto;
} > ul {
.report-form {
&.auto-form {
display: flex; display: flex;
margin-bottom: 12px; flex-wrap: wrap;
justify-content: space-between;
.ivu-form-item { row-gap: 12px;
column-gap: 48px;
@media (max-width: 768px) {
flex-direction: column;
column-gap: 0;
}
> li {
flex: 1; flex: 1;
flex-shrink: 0;
.ivu-form-item-label {
padding-top: 8px;
}
}
}
.ivu-form-item {
.ivu-form-item-label {
opacity: 0.8;
}
.ivu-form-item-content {
line-height: 30px;
display: flex; display: flex;
align-items: center; align-items: center;
white-space: nowrap;
.common-avatar { .report-label {
margin-right: 6px; flex-shrink: 0;
padding-right: 12px;
opacity: .8;
}
.report-value {
flex: 1;
display: flex;
align-items: center;
column-gap: 6px;
} }
} }
} }
} }
.report-content { .report-content {
border-top: 1px solid #eeeeee;
padding-top: 24px;
margin-top: 24px;
width: 100%; width: 100%;
h2 { h2 {