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\ProjectTask;
use App\Models\Report;
use App\Models\ReportLink;
use App\Models\ReportReceive;
use App\Models\User;
use App\Module\Base;
@ -441,7 +442,8 @@ class ReportController extends AbstractController
* @apiGroup report
* @apiName detail
*
* @apiParam {Number} [id] 报告id
* @apiParam {Number} [id] 报告ID
* @apiParam {String} [code] 报告分享代码与ID二选一优先ID
*
* @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述)
@ -450,24 +452,35 @@ class ReportController extends AbstractController
public function detail(): array
{
$user = User::auth();
//
$id = intval(trim(Request::input("id")));
if (empty($id))
$code = trim(Request::input("code"));
//
if (empty($id) && empty($code)) {
return Base::retError("缺少ID参数");
$one = Report::getOne($id);
$one->type_val = $one->getRawOriginal("type");
// 标记为已读
if (!empty($one->receivesUser)) {
foreach ($one->receivesUser as $item) {
if ($item->userid === $user->userid && $item->pivot->read === 0) {
$one->receivesUser()->updateExistingPivot($user->userid, [
"read" => 1,
]);
}
//
if (!empty($id)) {
$one = Report::getOne($id);
$one->type_val = $one->getRawOriginal("type");
// 标记为已读
if (!empty($one->receivesUser)) {
foreach ($one->receivesUser as $item) {
if ($item->userid === $user->userid && $item->pivot->read === 0) {
$one->receivesUser()->updateExistingPivot($user->userid, [
"read" => 1,
]);
}
}
}
} 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);
}

View File

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

View File

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

View File

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