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 () {