Skip to content

Commit 7715d52

Browse files
authored
Merge pull request #129 from veops/dev_ui
前端更新
2 parents 5d299bd + bd72abb commit 7715d52

File tree

6 files changed

+189
-120
lines changed

6 files changed

+189
-120
lines changed

cmdb-ui/src/modules/cmdb/components/cmdbGrant/ciTypeGrant.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template>
22
<div class="ci-type-grant">
3-
<vxe-table size="mini" stripe class="ops-stripe-table" :data="filterTableData" :max-height="`${tableHeight}px`">
3+
<vxe-table
4+
ref="xTable"
5+
size="mini"
6+
stripe
7+
class="ops-stripe-table"
8+
:data="filterTableData"
9+
:max-height="`${tableHeight}px`"
10+
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
11+
>
412
<vxe-column field="name"></vxe-column>
513
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
614
<template #default="{row}">
@@ -37,6 +45,7 @@ import _ from 'lodash'
3745
import { permMap } from './constants.js'
3846
import { grantCiType, revokeCiType } from '../../api/CIType'
3947
import ReadCheckbox from './readCheckbox.vue'
48+
import { getCurrentRowStyle } from './utils'
4049
4150
export default {
4251
name: 'CiTypeGrant',
@@ -55,10 +64,13 @@ export default {
5564
type: String,
5665
default: 'ci_type',
5766
},
67+
addedRids: {
68+
type: Array,
69+
default: () => [],
70+
},
5871
},
5972
computed: {
6073
filterTableData() {
61-
console.log(_.cloneDeep(this.tableData))
6274
const _tableData = this.tableData.filter((data) => {
6375
const _intersection = _.intersection(
6476
Object.keys(data),
@@ -90,6 +102,7 @@ export default {
90102
}
91103
},
92104
methods: {
105+
getCurrentRowStyle,
93106
async handleChange(e, col, row) {
94107
if (e.target.checked) {
95108
await grantCiType(this.CITypeId, row.rid, { perms: [col] }).catch(() => {

cmdb-ui/src/modules/cmdb/components/cmdbGrant/grantComp.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
@grantDepart="grantDepart"
1010
@grantRole="grantRole"
1111
@getTableData="getTableData"
12+
ref="grant_ci_type"
13+
:addedRids="addedRids"
1214
/>
1315
</template>
1416
<template
@@ -25,6 +27,8 @@
2527
@grantRole="grantRole"
2628
@getTableData="getTableData"
2729
@openReadGrantModal="openReadGrantModal"
30+
ref="grant_ci"
31+
:addedRids="addedRids"
2832
/>
2933
</template>
3034
<template v-if="cmdbGrantType.includes('type_relation')">
@@ -36,6 +40,8 @@
3640
@grantDepart="grantDepart"
3741
@grantRole="grantRole"
3842
@getTableData="getTableData"
43+
ref="grant_type_relation"
44+
:addedRids="addedRids"
3945
/>
4046
</template>
4147
<template v-if="cmdbGrantType.includes('relation_view')">
@@ -47,6 +53,8 @@
4753
@grantDepart="grantDepart"
4854
@grantRole="grantRole"
4955
@getTableData="getTableData"
56+
ref="grant_relation_view"
57+
:addedRids="addedRids"
5058
/>
5159
</template>
5260

@@ -108,6 +116,7 @@ export default {
108116
attrGroup: [],
109117
filerPerimissions: {},
110118
loading: false,
119+
addedRids: [], // 本次新增的rid
111120
}
112121
},
113122
computed: {
@@ -282,6 +291,12 @@ export default {
282291
})
283292
)
284293
}
294+
this.addedRids = rids
295+
this.$nextTick(() => {
296+
setTimeout(() => {
297+
this.$refs[`grant_${grantType}`].$refs.xTable.elemStore['main-body-wrapper'].scrollTo(0, 0)
298+
}, 300)
299+
})
285300
},
286301
openReadGrantModal(col, row) {
287302
this.$refs.readGrantModal.open(col, row)

cmdb-ui/src/modules/cmdb/components/cmdbGrant/relationViewGrant.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template>
22
<div class="ci-relation-grant">
3-
<vxe-table size="mini" stripe class="ops-stripe-table" :data="tableData" :max-height="`${tableHeight}px`">
3+
<vxe-table
4+
ref="xTable"
5+
size="mini"
6+
stripe
7+
class="ops-stripe-table"
8+
:data="tableData"
9+
:max-height="`${tableHeight}px`"
10+
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
11+
>
412
<vxe-column field="name"></vxe-column>
513
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
614
<template #default="{row}">
@@ -18,6 +26,8 @@
1826
<script>
1927
import { permMap } from './constants.js'
2028
import { grantRelationView, revokeRelationView } from '../../api/preference.js'
29+
import { getCurrentRowStyle } from './utils'
30+
2131
export default {
2232
name: 'RelationViewGrant',
2333
inject: ['loading', 'isModal'],
@@ -34,6 +44,10 @@ export default {
3444
type: String,
3545
default: 'relation_view',
3646
},
47+
addedRids: {
48+
type: Array,
49+
default: () => [],
50+
},
3751
},
3852
data() {
3953
return {
@@ -53,6 +67,7 @@ export default {
5367
},
5468
},
5569
methods: {
70+
getCurrentRowStyle,
5671
grantDepart() {
5772
this.$emit('grantDepart', this.grantType)
5873
},

cmdb-ui/src/modules/cmdb/components/cmdbGrant/typeRelationGrant.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template>
22
<div class="ci-relation-grant">
3-
<vxe-table size="mini" stripe class="ops-stripe-table" :data="tableData" :max-height="`${tableHeight}px`">
3+
<vxe-table
4+
ref="xTable"
5+
size="mini"
6+
stripe
7+
class="ops-stripe-table"
8+
:data="tableData"
9+
:max-height="`${tableHeight}px`"
10+
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
11+
>
412
<vxe-column field="name"></vxe-column>
513
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
614
<template #default="{row}">
@@ -18,6 +26,8 @@
1826
<script>
1927
import { permMap } from './constants.js'
2028
import { grantTypeRelation, revokeTypeRelation } from '../../api/CITypeRelation.js'
29+
import { getCurrentRowStyle } from './utils'
30+
2131
export default {
2232
name: 'TypeRelationGrant',
2333
inject: ['loading', 'isModal'],
@@ -34,6 +44,10 @@ export default {
3444
type: Array,
3545
default: null,
3646
},
47+
addedRids: {
48+
type: Array,
49+
default: () => [],
50+
},
3751
},
3852
data() {
3953
return {
@@ -53,6 +67,7 @@ export default {
5367
},
5468
},
5569
methods: {
70+
getCurrentRowStyle,
5671
grantDepart() {
5772
this.$emit('grantDepart', this.grantType)
5873
},
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const getCurrentRowStyle = ({ row }, addedRids) => {
2+
const idx = addedRids.findIndex(item => item.rid === row.rid)
3+
return idx > -1 ? 'background-color:#E0E7FF!important' : ''
4+
}

0 commit comments

Comments
 (0)