[update] 修改bug87487,企标详情页的关联文件增加权限限制

This commit is contained in:
lideqin
2024-07-29 14:46:36 +08:00
parent 82c54a69bd
commit 673f189bfc
2 changed files with 86 additions and 43 deletions
@@ -7,49 +7,52 @@
</div>
<div class="detail-page-part-form" v-if="part !== DisplayAreaManagement.PROCESS_DOCUMENTATION.text && part !== DisplayAreaManagement.PROCESS_DOCUMENTATION.textEn">
<div class="detail-page-part-form-item" v-for="formItem in form[part]" :key="formItem.id">
<label>{{ formItem.dbFieldTxt }}</label>
<!--标准需要跳转是标准字段且有内容的情况下在这处理-->
<template v-if="standardFields.includes(formItem.dbFieldName) && !!detailData[formItem.dbFieldName]">
<div class="div-form-content">
<template v-for="(standard, standardIndex) in detailData[formItem.dbFieldName].split(',')">
<div class="can-click" :key="'standardKey' + standardIndex" @click="toStandardDetailPage(standard.split('|')[0])">{{ standard }}</div>
<div v-if="standardIndex!==detailData[formItem.dbFieldName].split(',').length - 1">,</div>
</template>
</div>
</template>
<div v-else-if="fileField.includes(formItem.dbFieldName)" class="file-box">
<template v-if="detailData[formItem.dbFieldName]">
<div class="detail-page-process-manuscript-file" v-for="file in detailData[formItem.dbFieldName + 'List']" :key="file.id">
<div class="detail-page-process-manuscript-file-info">
<a-icon type="link" />
<div class="detail-page-process-manuscript-file-name" @click="handlePreview(file)">{{ file.fileName }}</div>
</div>
<!-- 下载-->
<a-button type="link" icon="download" class="file-btn" @click="handleDownload(file)">
{{ $t('download') }}
</a-button>
<!-- 无水印下载-->
<!--<a-button type="link" v-has="btnPermission.unwatermarkedDownload" class="file-btn">-->
<!-- <i class="iconfont icon-water-drop-slash"></i>-->
<!-- {{ $t('unwatermarkedDownload') }}-->
<!--</a-button>-->
<!-- 查看文件有的有权限控制企标的关联文件 -->
<template v-if="fileField.includes(formItem.dbFieldName) ? fileVisibility(formItem.dbFieldName) : true">
<label>{{ formItem.dbFieldTxt }}</label>
<!--标准需要跳转是标准字段且有内容的情况下在这处理-->
<template v-if="standardFields.includes(formItem.dbFieldName) && !!detailData[formItem.dbFieldName]">
<div class="div-form-content">
<template v-for="(standard, standardIndex) in detailData[formItem.dbFieldName].split(',')">
<div class="can-click" :key="'standardKey' + standardIndex" @click="toStandardDetailPage(standard.split('|')[0])">{{ standard }}</div>
<div v-if="standardIndex!==detailData[formItem.dbFieldName].split(',').length - 1">,</div>
</template>
</div>
</template>
<template v-else>
<span></span>
</template>
</div>
<!-- 需要显示查看全部按钮 -->
<a-button v-else-if="showViewAllField.includes(formItem.dbFieldName) &&
<div v-else-if="fileField.includes(formItem.dbFieldName)" class="file-box">
<template v-if="detailData[formItem.dbFieldName]">
<div class="detail-page-process-manuscript-file" v-for="file in detailData[formItem.dbFieldName + 'List']" :key="file.id">
<div class="detail-page-process-manuscript-file-info">
<a-icon type="link" />
<div class="detail-page-process-manuscript-file-name" @click="handlePreview(file)">{{ file.fileName }}</div>
</div>
<!-- 下载-->
<a-button v-if="fileIsDownload(formItem.dbFieldName)" type="link" icon="download" class="file-btn" @click="handleDownload(file)">
{{ $t('download') }}
</a-button>
<!-- 无水印下载-->
<!--<a-button type="link" v-has="btnPermission.unwatermarkedDownload" class="file-btn">-->
<!-- <i class="iconfont icon-water-drop-slash"></i>-->
<!-- {{ $t('unwatermarkedDownload') }}-->
<!--</a-button>-->
</div>
</template>
<template v-else>
<span></span>
</template>
</div>
<!-- 需要显示查看全部按钮 -->
<a-button v-else-if="showViewAllField.includes(formItem.dbFieldName) &&
(detailData[formItem.dbFieldName + '_dictText'] || detailData[formItem.dbFieldName])"
type="primary" ghost @click="viewAll(formItem.dbFieldName)">
{{ $t('enterpriseStandardLibrary.standard.viewAll')}}
</a-button>
<span v-else-if="detailData[formItem.dbFieldName + '_dictText']">{{ detailData[formItem.dbFieldName + '_dictText'] }}</span>
<!-- 标准适用范围,有标签需要编译 -->
<span v-else-if="detailData[formItem.dbFieldName] && formItem.dbFieldName === 'standard_scope'" v-html="detailData[formItem.dbFieldName]"></span>
<span v-else-if="detailData[formItem.dbFieldName]">{{ detailData[formItem.dbFieldName] }}</span>
<span v-else>—</span>
type="primary" ghost @click="viewAll(formItem.dbFieldName)">
{{ $t('enterpriseStandardLibrary.standard.viewAll')}}
</a-button>
<span v-else-if="detailData[formItem.dbFieldName + '_dictText']">{{ detailData[formItem.dbFieldName + '_dictText'] }}</span>
<!-- 标准适用范围,有标签需要编译 -->
<span v-else-if="detailData[formItem.dbFieldName] && formItem.dbFieldName === 'standard_scope'" v-html="detailData[formItem.dbFieldName]"></span>
<span v-else-if="detailData[formItem.dbFieldName]">{{ detailData[formItem.dbFieldName] }}</span>
<span v-else>—</span>
</template>
</div>
</div>
<!-- 过程稿件特殊处理-->
@@ -129,6 +132,8 @@ import { getFileInfo } from '../../../../api/api'
import { kkFilePreview } from '@/utils/kkFilePreview'
import TextContentModal from './module/TextContentModal'
import { queryStandardInfoByStandardNumber } from '@/utils/util'
import { mapGetters } from 'vuex'
import { isHasPermission } from '../../../../utils/hasPermission'
// 支持预览的文件后缀
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
@@ -191,7 +196,19 @@ export default {
// 参与只允许查看最新稿件排序的字段顺序(发布稿>征求意见稿)
newestManuScriptField: ['publish_of_original', 'draft_for_comment'],
// 过程稿件中可以查看的最新文件id
manuScriptNewestFileId: ''
manuScriptNewestFileId: '',
filePerm: { // 上传文件根据权限控制只能查看,没有权限的除了系统管理员外不可见不可下载
associated_file: 'enterpriseStandard:associatedFile:look' // 关联文件
}
}
},
computed: {
...mapGetters(['userInfo']),
// 是否是系统管理员
isSystemAdmin () {
const roleList = window._CONFIG.systemAdminRoleCode.split(',')
const userRoleList = this.userInfo.roleCode.split(',')
return userRoleList.some(tt => roleList.includes(tt))
}
},
created () {
@@ -199,6 +216,32 @@ export default {
this.initData()
},
methods: {
fileIsDownload (fieldName) { // 文件是否可下载
if (Object.keys(this.filePerm).includes(fieldName)) {
// 系统管理员可下载
if (this.isSystemAdmin) {
return true
} else {
return false
}
} else {
// 不是需要特殊判断的字段正常可下载
return true
}
},
fileVisibility (fieldName) { // 文件是否可见,有授权的和系统管理员可下载
if (Object.keys(this.filePerm).includes(fieldName)) {
// 系统管理员和有权限的角色可见
if (this.isSystemAdmin || isHasPermission(this.filePerm[fieldName])) {
return true
} else {
return false
}
} else {
// 不是需要特殊判断的字段正常可见
return true
}
},
initForm () {
const params = {}
params.type = 1
@@ -269,7 +312,7 @@ export default {
if (!file || !file.url) {
return
}
if (this.newestManuScriptField.includes(formItem.dbFieldName) && file.id !== this.manuScriptNewestFileId) {
if (formItem && this.newestManuScriptField.includes(formItem.dbFieldName) && file.id !== this.manuScriptNewestFileId) {
// 参与最新稿件不预览的不是最新的稿件不能预览
return
}
@@ -313,7 +313,7 @@ export default {
if (!file || !file.url) {
return
}
if (this.newestManuScriptField.includes(formItem.dbFieldName) && file.id !== this.manuScriptNewestFileId) {
if (formItem && this.newestManuScriptField.includes(formItem.dbFieldName) && file.id !== this.manuScriptNewestFileId) {
// 参与最新稿件不预览的不是最新的稿件不能预览
return
}