update 文档比对操作栏按钮显隐处理

This commit is contained in:
赵霄
2023-09-18 17:23:27 +08:00
parent ae01a27733
commit dfc32081bf
4 changed files with 91 additions and 70 deletions
+21 -6
View File
@@ -58,14 +58,14 @@
<template v-else>
<!-- 没有特殊判断直接渲染operationList -->
<!-- 需要更多按钮的情况 -->
<template v-if="operationList.length > operateMaxNum + 1">
<a @click="operationClick(operationList[0],record)">{{ operationList[0].text }}</a>
<template v-if="operationList.length > operateMaxNum">
<template v-if="getLineOperationList(record).length > operateMaxNum + 1">
<a @click="operationClick(getLineOperationList(record)[0],record)">{{ getLineOperationList(record)[0].text }}</a>
<template v-if="getLineOperationList(record).length > operateMaxNum">
<a-divider type="vertical" />
<a-dropdown placement="bottomCenter">
<a-icon type="more" class="operate-icon-btn operate-icon-more" />
<a-menu slot="overlay">
<a-menu-item v-for="(operation, index) in operationList.slice(operateMaxNum)" :key="index">
<a-menu-item v-for="(operation, index) in getLineOperationList(record).slice(operateMaxNum)" :key="index">
<a @click="operationClick(operation,record)">
<div class="operate-btn">
{{ operation.text }}
@@ -76,9 +76,10 @@
</a-dropdown>
</template>
</template>
<template v-else-if="operationList.length > 0">
<template v-for="(operation, index) in operationList">
<template v-else-if="getLineOperationList(record).length > 0">
<template v-for="(operation, index) in getLineOperationList(record)">
<a :key="index" @click="operationClick(operation,record)">{{ operation.text }}</a>
<a-divider type="vertical" v-if="index !== getLineOperationList(record).length - 1"/>
</template>
</template>
</template>
@@ -591,6 +592,20 @@ export default {
Vue.ls.remove(J_TABLE_KEYS)
this.resteColumns() // 这里只能刷新当前的表
this.$message.success('成功清除全局JTable的缓存!')
},
getLineOperationList (record) {
const hasPermissionList = this.operationList.filter(tt => !tt.has || isHasPermission(tt.has))
const lineOperateList = []
hasPermissionList.forEach(item => {
if (!item.show) {
lineOperateList.push(item)
} else if (typeof item.show === 'function') {
if (item.show(record)) {
lineOperateList.push(item)
}
}
})
return lineOperateList
}
},
mounted () {
@@ -50,37 +50,11 @@
:can-drag="true"
:loading="loading"
:pagination="ipagination"
:scroll="{x: '100%', y:'calc(100vh - 280px)'}"
:scroll="{x: '100%'}"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
:operation-list="operationList"
@change="handleTableChange"
>
<template v-slot:operation="{text,record}">
<a class="text-operation" @click="comparisonResultsClick(record)">{{ $t('docTool.comparison.comparisonResults') }}</a>
<a-divider type="vertical" v-if="record.createBy === userInfoQuery.username || administrators" />
<a-dropdown v-if="record.createBy === userInfoQuery.username || administrators">
<a class="ant-dropdown-link">
{{ $t('more') }}
<a-icon type="down" />
</a>
<a-menu slot="overlay">
<a-menu-item>
<a v-if="record.createBy === userInfoQuery.username || administrators" @click="subscribe(record)">
{{ !record.releaseState || record.releaseState === 'draft' ? $t('release') : $t('withdraw') }}
</a>
</a-menu-item>
<a-menu-item>
<a v-if="(record.createBy === userInfoQuery.username || administrators) && record.releaseState === 'draft'"
@click="edit(record)">{{ $t('edit') }}</a>
</a-menu-item>
<a-menu-item>
<a v-if="(record.createBy === userInfoQuery.username || administrators) && record.releaseState === 'draft'"
@click="deleteData(record)">{{ $t('delete') }}</a>
</a-menu-item>
</a-menu>
</a-dropdown>
</template>
@operationClick="operationClick">
<template v-slot:serialNumberRight="{text,record}">
<a @click="serialNumberRightClick(record)" :title="text">{{ text }}</a>
</template>
@@ -111,28 +85,9 @@ export default {
deleteBatch: '/compare/sarFileCompareInfo/deleteBatch'
},
loading: false,
dataSource: [
{ id: 1 }
],
selectedRowKeys: [],
selectionRows: [],
downLoadFileUrl: window._CONFIG.domianPreviewURL + '/sys/common/download',
downLoadImgUrl: window._CONFIG.domianWebImgURL + '/sys/common/download',
/* 分页参数 */
ipagination: {
current: 1,
pageSize: 50,
pageSizeOptions: ['10', '50', '100', '150', '200'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + this.$t('total') + ' ' + total + ' ' + this.$t('strip')
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
queryParam: {},
userInfoQuery: {},
administrators: false,
columns: [
{
title: this.$t('number') + ' 1',
@@ -196,29 +151,77 @@ export default {
title: this.$t('operation'),
fixed: 'right',
width: 310,
scopedSlots: { customRender: 'operation' }
scopedSlots: { customRender: 'action' }
}
],
operationList: [
// 对比结果
{
text: this.$t('docTool.comparison.comparisonResults'),
clickEvent: 'comparisonResultsClick',
has: 'domesticStandard:collection'
},
// 发布
{
text: this.$t('release'),
clickEvent: 'subscribe',
has: 'domesticStandard:collection',
show: (record) => {
return (record.createBy === this.userInfo.username || this.administrators) && (!record.releaseState || record.releaseState === 'draft')
}
},
// 撤回
{
text: this.$t('withdraw'),
clickEvent: 'subscribe',
has: 'domesticStandard:collection',
show: (record) => {
return (record.createBy === this.userInfo.username || this.administrators) && !(!record.releaseState || record.releaseState === 'draft')
}
},
// 编辑
{
text: this.$t('edit'),
clickEvent: 'edit',
has: 'domesticStandard:collection',
show: (record) => {
return (record.createBy === this.userInfo.username || this.administrators) && record.releaseState === 'draft'
}
},
// 删除
{
text: this.$t('delete'),
clickEvent: 'comparisonResultsClick',
has: 'domesticStandard:collection',
show: (record) => {
return (record.createBy === this.userInfo.username || this.administrators) && record.releaseState === 'draft'
}
}
]
}
},
mounted () {
computed: {
...mapGetters(['userInfo']),
administrators () {
let flag = false
if (this.userInfo.userRoleList && this.userInfo.userRoleList.length > 0) {
this.userInfo.userRoleList.forEach(res => {
if (res.roleCode === 'admin') {
flag = true
}
})
}
return flag
}
},
created () {
if (this.$route.query.serialNumber) {
this.queryParam.serialNumber = this.$route.query.serialNumber
this.queryParam = { ...this.queryParam }
}
this.userInfoQuery = this.userInfo()
this.administrators = false
if (this.userInfoQuery.userRoleList && this.userInfoQuery.userRoleList.length > 0) {
this.userInfoQuery.userRoleList.forEach(res => {
if (res.roleCode === 'admin') {
this.administrators = true
}
})
}
this.loadData(1)
},
methods: {
...mapGetters(['userInfo']),
getList () {
this.dataSource = [{ id: 1, serialNumberLeft: '11' }]
},
@@ -230,7 +233,7 @@ export default {
const idList = []
const selectionRows = JSON.parse(JSON.stringify(this.selectionRows))
for (let i = 0; i < selectionRows.length; i++) {
if (selectionRows[i].createBy === this.userInfoQuery.username &&
if (selectionRows[i].createBy === this.userInfo.username &&
selectionRows[i].releaseState === 'draft') {
idList.push(selectionRows[i].id)
}
@@ -256,7 +259,7 @@ export default {
},
// 对比结果按钮点击
comparisonResultsClick (item) {
if (item.createBy === this.userInfoQuery.username && item.releaseState === 'draft') {
if (item.createBy === this.userInfo.username && item.releaseState === 'draft') {
item.isDisplay = 2
} else {
item.isDisplay = 1
@@ -1,12 +1,15 @@
<template>
<internal-detail-page :title="$t('docTool.comparison.documentComparison')" :content-padding="0" :loading="loading">
<template v-slot:titleRightCustom>
<!--查看比对结果-->
<a-button class="header-btn" type="primary" icon="eye" ghost @click="viewTheComparisonResultsClick">
{{ $t('docTool.comparison.viewTheComparisonResults') }}
</a-button>
<!--添加全文评论-->
<a-button class="header-btn" type="primary" icon="message" ghost @click="addFullTextCommentClick">
{{ $t('docTool.comparison.addFullTextComment') }}
</a-button>
<!--关闭/打开自动匹配-->
<a-button class="header-btn" type="primary" :icon="isMatching?'close-circle':'check-circle'" ghost @click="turnOffAutomaticMatchingClick">
{{ isMatching ? $t('docTool.comparison.turnOffAutomaticMatching') : $t('docTool.comparison.turnOnAutoMatch') }}
</a-button>
@@ -106,7 +109,7 @@
<script>
import { postAction, getAction } from '../../../api/manage.js'
// 添加全文评论弹框
import ComparisonAddFullComment from '../modules/ComparisonAddFullComment.vue'
import ComparisonAddFullComment from './modules/ComparisonAddFullComment.vue'
import InternalDetailPage from '../../../components/InternalDetailPage.vue'
export default {
@@ -29,7 +29,7 @@
</template>
<script>
import { putAction } from '@/api/manage'
import { putAction } from '../../../../api/manage.js'
export default {
name: 'ComparisonAddFullComment',