Skip to content

Commit

Permalink
Merge pull request #370 from TencentBlueKing/develop
Browse files Browse the repository at this point in the history
v1.5.12
  • Loading branch information
zhu327 authored Nov 11, 2021
2 parents ecc5de7 + 230ee95 commit 87c4636
Show file tree
Hide file tree
Showing 21 changed files with 413 additions and 39 deletions.
2 changes: 0 additions & 2 deletions frontend/src/views/grading-admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@
this.isFilter = true
}
}
this.pagination.current = 1
this.searchValue = ''
},
methods: {
showImgDialog () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<bk-table-column type="selection" align="center" :selectable="getIsSelect"></bk-table-column>
<bk-table-column :label="$t(`m.permTemplate['模板名']`)">
<template slot-scope="{ row }">
<Icon v-if="!getIsSelect(row)" type="error-fill" class="error-icon" />
<span class="perm-template-name" :title="row.name" @click="handleViewTemplateDetail(row)">{{ row.name }}</span>
</template>
</bk-table-column>
Expand Down Expand Up @@ -291,7 +292,7 @@
},
getIsSelect (row, index) {
return row.tag === 'unchecked'
return row.tag === 'unchecked' && !row.need_to_update
},
handleRefresh () {
Expand Down Expand Up @@ -580,5 +581,11 @@
color: #3a84ff;
}
}
.error-icon {
font-size: 14px;
color: #ffb400;
position: absolute;
left: -5px;
}
}
</style>
59 changes: 52 additions & 7 deletions frontend/src/views/perm-template/components/render-action.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<section :class="['action-group-name', { 'set-cursor': originalCustomTmplList.length > 1 }]">
<Icon :type="item.expanded ? 'down-angle' : 'right-angle'" v-if="originalCustomTmplList.length > 1" />
<span>{{ item.name }}</span>
<span v-if="isShowCount" class="count">{{$t(`m.common['已选']`)}} {{ item.count }} / {{ item.allCount }} {{ $t(`m.common['个']`) }}</span>
<span v-if="isShowCount" class="count">{{$t(`m.common['已选']`)}} {{ item.count }} / {{ item.allCount }} {{ $t(`m.common['个']`) }} <span v-if="item.deleteCount" class="delete-count"> 包含{{item.deleteCount}}个需要被删除的操作</span></span>
</section>
<span
v-if="!isDisabled"
Expand All @@ -35,10 +35,12 @@
@change="handleActionChecked(...arguments, act, item)">
<bk-popover placement="top" :delay="[300, 0]" ext-cls="iam-tooltips-cls">
<template v-if="act.disabled">
<span class="text">{{ act.name }}</span>
<span class="text" :class="{ 'text-through': act.tag === 'delete' && mode === 'detail' }">{{ act.name }}</span>
<Icon v-if="act.tag === 'delete'" type="error-fill" class="error-icon" />
</template>
<template v-else>
<span class="text">{{ act.name }}</span>
<span class="text" :class="{ 'text-through': act.tag === 'delete' && mode === 'detail' }">{{ act.name }}</span>
<Icon v-if="act.tag === 'delete'" type="error-fill" class="error-icon" />
</template>
<div slot="content" class="iam-perm-apply-action-popover-content">
<div>
Expand Down Expand Up @@ -89,10 +91,12 @@
@change="handleSubActionChecked(...arguments, act, subAct, item)">
<bk-popover placement="top" :delay="[300, 0]" ext-cls="iam-tooltips-cls">
<template v-if="act.disabled">
<span class="text">{{ act.name }}</span>
<span class="text" :class="{ 'text-through': act.tag === 'delete' && mode === 'detail' }">{{ act.name }}</span>
<Icon v-if="act.tag === 'delete'" type="error-fill" class="error-icon" />
</template>
<template v-else>
<span class="text">{{ act.name }}</span>
<span class="text" :class="{ 'text-through': act.tag === 'delete' && mode === 'detail' }">{{ act.name }}</span>
<Icon v-if="act.tag === 'delete'" type="error-fill" class="error-icon" />
</template>
<div slot="content" class="iam-perm-apply-action-popover-content">
<div>
Expand Down Expand Up @@ -173,17 +177,24 @@
curSelectActions () {
const allActionIds = []
this.originalCustomTmplList.forEach(payload => {
payload.deleteCount = 0
if (!payload.actionsAllDisabled) {
payload.actions.forEach(item => {
if (!item.disabled && item.checked) {
allActionIds.push(item.id)
}
if (!item.disabled && item.checked && item.tag === 'delete') {
payload.deleteCount++
}
})
;(payload.sub_groups || []).forEach(subItem => {
(subItem.actions || []).forEach(act => {
if (!act.disabled && act.checked) {
allActionIds.push(act.id)
}
if (!act.disabled && act.checked && act.tag === 'delete') {
payload.deleteCount++
}
})
})
}
Expand Down Expand Up @@ -239,15 +250,38 @@
}
})
const isSubAllChecked = sub.actions.every(v => v.checked)
const subActions = sub.actions.filter(e => !e.disabled)
let isSubAllCheckedData = true
if (subActions.length) {
isSubAllCheckedData = subActions.every(v => v.checked)
}
sub.allChecked = isSubAllChecked
sub.allCheckedData = isSubAllCheckedData
})
const isAllChecked = item.actions.every(v => v.checked)
const actions = item.actions.filter(e => !e.disabled)
let isAllCheckedData = true
if (actions.length) {
isAllCheckedData = actions.every(v => v.checked)
}
console.log('isAllChecked', isAllChecked)
item.allChecked = isAllChecked
item.allCheckedData = isAllCheckedData
if (item.sub_groups && item.sub_groups.length > 0) {
item.actionsAllChecked = isAllChecked && item.sub_groups.every(v => v.allChecked)
console.log('isAllChecked && item.sub_groups.every(v => v.allCheckedData)', item.sub_groups.every(v => v.allCheckedData))
this.$nextTick(() => {
item.actionsAllChecked = isAllCheckedData && item.sub_groups.every(v => v.allCheckedData)
console.log('item.actionsAllChecked', item.actionsAllChecked)
})
} else {
item.actionsAllChecked = isAllChecked
this.$nextTick(() => {
item.actionsAllChecked = isAllCheckedData
})
}
console.log('this.originalCustomTmplList', this.originalCustomTmplList)
})
},
Expand Down Expand Up @@ -562,6 +596,9 @@
font-weight: normal;
color: #979ba5;
}
.delete-count{
color: #ec4545;
}
}
.check-all {
position: relative;
Expand Down Expand Up @@ -615,6 +652,14 @@
.iam-action-cls {
width: 175px;
line-height: 36px;
.error-icon {
font-size: 14px;
color: #ffb400;
}
.text-through{
text-decoration: line-through;
text-decoration-color: #ffb400;
}
}
.iam-action-all-cls {
position: absolute;
Expand Down
39 changes: 37 additions & 2 deletions frontend/src/views/perm-template/components/render-content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
let allCheckedLen = 0
let count = 0
let delCount = 0
let deleteCount = 0
item.actions.forEach(item => {
if (!item.disabled) {
if (payload.includes(item.id)) {
Expand All @@ -383,6 +384,9 @@
this.$refs.actionsRef.handleRelatedActions(item, flag)
}
}
if (item.tag === 'delete') {
++deleteCount
}
if (item.disabled || item.checked) {
allCheckedLen++
}
Expand All @@ -404,6 +408,10 @@
this.$refs.actionsRef.handleRelatedActions(act, flag)
}
}
if (item.tag === 'delete') {
++deleteCount
}
if (act.disabled || act.checked) {
allSubCheckedLen++
}
Expand All @@ -422,6 +430,7 @@
} else {
item.count = item.count - delCount
}
this.$set(item, 'deleteCount', deleteCount)
})
},
Expand Down Expand Up @@ -453,18 +462,22 @@
this.$set(item, 'expanded', index === 0)
let allCount = 0
let count = 0
let deleteCount = 0
this.$set(item, 'count', 0)
if (!item.actions) {
this.$set(item, 'actions', [])
}
item.actions.forEach(act => {
this.$set(act, 'checked', ['checked', 'readonly'].includes(act.tag))
this.$set(act, 'checked', ['checked', 'readonly', 'delete'].includes(act.tag))
this.$set(act, 'disabled', act.tag === 'readonly')
linearActions.push(act)
if (act.checked) {
this.curSelectActions.push(act.id)
this.$set(act, 'flag', 'selected')
++count
if (act.tag === 'delete') {
++deleteCount
}
}
})
allCount = allCount + item.actions.length
Expand All @@ -475,13 +488,16 @@
this.$set(sub, 'actions', [])
}
sub.actions.forEach(act => {
this.$set(act, 'checked', ['checked', 'readonly'].includes(act.tag))
this.$set(act, 'checked', ['checked', 'readonly', 'delete'].includes(act.tag))
this.$set(act, 'disabled', act.tag === 'readonly')
linearActions.push(act)
if (act.checked) {
this.curSelectActions.push(act.id)
this.$set(act, 'flag', 'selected')
++count
if (act.tag === 'delete') {
++deleteCount
}
}
})
Expand All @@ -493,6 +509,7 @@
this.$set(item, 'allCount', allCount)
this.$set(item, 'count', count)
this.$set(item, 'deleteCount', deleteCount)
const isAllChecked = item.actions.every(v => v.checked)
const isAllDisabled = item.actions.every(v => v.disabled)
this.$set(item, 'allChecked', isAllChecked)
Expand Down Expand Up @@ -602,19 +619,27 @@
const temps = _.cloneDeep(payload)
temps.forEach(item => {
let count = 0
let deleteCount = 0
item.actions.forEach(act => {
if (act.checked) {
++count
if (act.tag === 'delete') {
++deleteCount
}
}
})
;(item.sub_groups || []).forEach(sub => {
sub.actions.forEach(act => {
if (act.checked) {
++count
if (act.tag === 'delete') {
++deleteCount
}
}
})
})
this.$set(item, 'count', count)
this.$set(item, 'deleteCount', deleteCount)
})
return temps
Expand Down Expand Up @@ -671,6 +696,16 @@
},
async handleNextStep () {
if (!this.hasGroupPreview && this.originalCustomTmplList.some(e => e.deleteCount)) {
this.bkMessageInstance = this.$bkMessage({
limit: 1,
theme: 'error',
message: '由于分级管理员的授权范围没有包含此操作,如需使用该模板进行新的授权必须先删除该操作。',
ellipsisLine: 2,
ellipsisCopy: true
})
return
}
this.handleNameBlur(this.tempName)
this.isShowActionError = this.curSelectActions.length < 1
if (this.isShowNameError || this.isShowActionError) {
Expand Down
24 changes: 20 additions & 4 deletions frontend/src/views/perm-template/detail/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,20 @@
this.$set(item, 'expanded', false)
let count = 0
let allCount = 0
let deleteCount = 0
if (!item.actions) {
this.$set(item, 'actions', [])
}
item.actions.forEach(act => {
this.$set(act, 'checked', ['checked', 'readonly'].includes(act.tag))
this.$set(act, 'checked', ['checked', 'readonly', 'delete'].includes(act.tag))
this.$set(act, 'disabled', act.tag === 'readonly')
if (act.checked) {
++count
this.defaultCheckedActions.push(act.id)
}
if (act.tag === 'delete') {
++deleteCount
}
++allCount
})
;(item.sub_groups || []).forEach(sub => {
Expand All @@ -188,19 +192,23 @@
this.$set(sub, 'actions', [])
}
sub.actions.forEach(act => {
this.$set(act, 'checked', ['checked', 'readonly'].includes(act.tag))
this.$set(act, 'checked', ['checked', 'readonly', 'delete'].includes(act.tag))
this.$set(act, 'disabled', act.tag === 'readonly')
if (act.checked) {
++count
this.defaultCheckedActions.push(act.id)
}
if (act.tag === 'delete') {
++deleteCount
}
++allCount
})
const isSubAllChecked = sub.actions.every(v => v.checked)
this.$set(sub, 'allChecked', isSubAllChecked)
})
this.$set(item, 'deleteCount', deleteCount)
this.$set(item, 'count', count)
this.$set(item, 'allCount', allCount)
Expand Down Expand Up @@ -233,11 +241,12 @@
temps.forEach((item, index) => {
this.$set(item, 'expanded', index === 0)
let count = 0
let deleteCount = 0
if (!item.actions) {
this.$set(item, 'actions', [])
}
item.actions.forEach(act => {
this.$set(act, 'checked', ['checked', 'readonly'].includes(act.tag))
this.$set(act, 'checked', ['checked', 'readonly', 'delete'].includes(act.tag))
this.$set(act, 'disabled', act.tag === 'readonly')
if (hasAddActions.includes(act.id)) {
this.$set(act, 'checked', true)
Expand All @@ -250,6 +259,9 @@
if (act.checked) {
++count
}
if (act.tag === 'delete') {
++deleteCount
}
})
;(item.sub_groups || []).forEach(sub => {
this.$set(sub, 'expanded', false)
Expand All @@ -258,7 +270,7 @@
this.$set(sub, 'actions', [])
}
sub.actions.forEach(act => {
this.$set(act, 'checked', ['checked', 'readonly'].includes(act.tag))
this.$set(act, 'checked', ['checked', 'readonly', 'delete'].includes(act.tag))
this.$set(act, 'disabled', act.tag === 'readonly')
if (hasAddActions.includes(act.id)) {
this.$set(act, 'checked', true)
Expand All @@ -271,12 +283,16 @@
if (act.checked) {
++count
}
if (act.tag === 'delete') {
++deleteCount
}
})
const isSubAllChecked = sub.actions.every(v => v.checked)
this.$set(sub, 'allChecked', isSubAllChecked)
})
this.$set(item, 'deleteCount', deleteCount)
this.$set(item, 'count', count)
const isAllChecked = item.actions.every(v => v.checked)
Expand Down
2 changes: 1 addition & 1 deletion saas/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.11
1.5.12
Loading

0 comments on commit 87c4636

Please sign in to comment.