Merge branch 'master' of github.com:veops/cmdb

This commit is contained in:
pycook 2023-07-31 18:39:46 +08:00
commit 3e67bb94bc
19 changed files with 581 additions and 904 deletions

View File

@ -78,6 +78,7 @@
</template>
<script>
import _ from 'lodash'
import Pager from './pager.vue'
import SearchForm from './searchForm.vue'
import { searchPermissonHistory } from '@/modules/acl/api/history'
@ -251,23 +252,25 @@ export default {
},
//
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let q = ''
for (const key in queryParams) {
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
key !== 'app_id' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
if (q) q += `,${key}:${queryParams[key]}`
else q += `${key}:${queryParams[key]}`
delete queryParams[key]
if (q) q += `,${key}:${_queryParams[key]}`
else q += `${key}:${_queryParams[key]}`
delete _queryParams[key]
}
}
const newQueryParams = { ...queryParams, q }
return q ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return q ? newQueryParams : _queryParams
},
// searchForm
@ -283,7 +286,7 @@ export default {
this.getTable(this.queryParams)
},
handleSearch(queryParams) {
this.queryParams = { ...queryParams, app_id: this.app_id }
this.queryParams = { ...this.queryParams, ...queryParams, app_id: this.app_id }
this.getTable(this.queryParams)
},

View File

@ -212,7 +212,12 @@ export default {
// searchForm
handleSearch(queryParams) {
this.queryParams = { ...queryParams, app_id: this.app_id, scope: this.checked ? 'resource_group' : 'resource' }
this.queryParams = {
...this.queryParams,
...queryParams,
app_id: this.app_id,
scope: this.checked ? 'resource_group' : 'resource',
}
this.getTable(this.queryParams)
},
searchFormReset() {
@ -245,9 +250,11 @@ export default {
},
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let flag = false
let q = queryParams.q ? queryParams.q : ''
for (const key in queryParams) {
let q = _queryParams.q ? _queryParams.q : ''
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
@ -255,16 +262,16 @@ export default {
key !== 'q' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
flag = true
if (q) q += `,${key}:${queryParams[key]}`
else q += `${key}:${queryParams[key]}`
delete queryParams[key]
if (q) q += `,${key}:${_queryParams[key]}`
else q += `${key}:${_queryParams[key]}`
delete _queryParams[key]
}
}
const newQueryParams = { ...queryParams, q }
return flag ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return flag ? newQueryParams : _queryParams
},
handleTagColor(operateType) {
return this.colorMap.get(operateType)

View File

@ -179,7 +179,7 @@ export default {
// searchForm
handleSearch(queryParams) {
this.queryParams = { ...queryParams, app_id: this.app_id, scope: 'resource_type' }
this.queryParams = { ...this.queryParams, ...queryParams, app_id: this.app_id, scope: 'resource_type' }
this.getTable(this.queryParams)
},
searchFormReset() {
@ -206,9 +206,11 @@ export default {
},
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let flag = false
let q = queryParams.q ? queryParams.q : ''
for (const key in queryParams) {
let q = _queryParams.q ? _queryParams.q : ''
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
@ -216,16 +218,16 @@ export default {
key !== 'q' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
flag = true
if (q) q += `,${key}:${queryParams[key]}`
else q += `${key}:${queryParams[key]}`
delete queryParams[key]
if (q) q += `,${key}:${_queryParams[key]}`
else q += `${key}:${_queryParams[key]}`
delete _queryParams[key]
}
}
const newQueryParams = { ...queryParams, q }
return flag ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return flag ? newQueryParams : _queryParams
},
handleTagColor(operateType) {
return this.colorMap.get(operateType)

View File

@ -220,7 +220,12 @@ export default {
this.getTable(this.queryParams)
},
handleSearch(queryParams) {
this.queryParams = { ...queryParams, app_id: this.app_id, scope: this.checked ? 'role_relation' : 'role' }
this.queryParams = {
...this.queryParams,
...queryParams,
app_id: this.app_id,
scope: this.checked ? 'role_relation' : 'role',
}
this.getTable(this.queryParams)
},
searchFormReset() {
@ -237,9 +242,11 @@ export default {
//
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let flag = false
let q = queryParams.q ? queryParams.q : ''
for (const key in queryParams) {
let q = _queryParams.q ? _queryParams.q : ''
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
@ -247,16 +254,16 @@ export default {
key !== 'q' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
flag = true
if (q) q += `,${key}:${queryParams[key]}`
else q += `${key}:${queryParams[key]}`
delete queryParams[key]
if (q) q += `,${key}:${_queryParams[key]}`
else q += `${key}:${_queryParams[key]}`
delete _queryParams[key]
}
}
const newQueryParams = { ...queryParams, q }
return flag ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return flag ? newQueryParams : _queryParams
},
// tag
handleTagColor(operateType) {

View File

@ -147,7 +147,6 @@ export default {
expand: false,
queryParams: {
page: 1,
page_size: 50,
},
date: undefined,
checked: false,
@ -188,7 +187,6 @@ export default {
handleReset() {
this.queryParams = {
page: 1,
page_size: 50,
}
this.date = undefined
this.$emit('searchFormReset')

View File

@ -200,7 +200,7 @@ export default {
// searchForm
handleSearch(queryParams) {
this.queryParams = queryParams
this.queryParams = { ...this.queryParams, ...queryParams }
this.queryParams.app_id = this.app_id
this.getTable(this.queryParams)
},
@ -281,25 +281,27 @@ export default {
}
},
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let q = ''
for (const key in queryParams) {
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
key !== 'app_id' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
if (q) {
q += `,${key}:${queryParams[key]}`
q += `,${key}:${_queryParams[key]}`
} else {
q += `${key}:${queryParams[key]}`
q += `${key}:${_queryParams[key]}`
}
}
}
const newQueryParams = { ...queryParams, q }
return q ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return q ? newQueryParams : _queryParams
},
handleTagColor(operateType) {
return this.colorMap.get(operateType)

View File

@ -79,6 +79,7 @@
</template>
<script>
import _ from 'lodash'
import debounce from 'lodash/debounce'
import Pager from '../../module/pager.vue'
import SearchForm from '../../module/searchForm.vue'
@ -347,7 +348,7 @@ export default {
this.getTable(this.queryParams)
},
handleSearch(queryParams) {
this.queryParams = queryParams
this.queryParams = { ...this.queryParams, ...queryParams }
this.getTable(this.queryParams)
},
handleExpandChange(expand) {
@ -387,23 +388,24 @@ export default {
},
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let q = ''
for (const key in queryParams) {
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
key !== 'app_id' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
if (q) q += `,${key}:${queryParams[key]}`
else q += `${key}:${queryParams[key]}`
delete queryParams[key]
if (q) q += `,${key}:${_queryParams[key]}`
else q += `${key}:${_queryParams[key]}`
delete _queryParams[key]
}
}
const newQueryParams = { ...queryParams, q }
return q ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return q ? newQueryParams : _queryParams
},
},
}

View File

@ -267,7 +267,7 @@ export default {
this.isExpand = expand
},
handleSearch(queryParams) {
this.queryParams = { ...queryParams, scope: this.checked ? 'resource_group' : 'resource' }
this.queryParams = { ...this.queryParams, ...queryParams, scope: this.checked ? 'resource_group' : 'resource' }
this.getTable(this.queryParams)
},
searchFormReset() {
@ -317,9 +317,11 @@ export default {
},
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let flag = false
let q = queryParams.q ? queryParams.q : ''
for (const key in queryParams) {
let q = _queryParams.q ? _queryParams.q : ''
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
@ -327,16 +329,16 @@ export default {
key !== 'q' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
flag = true
if (q) q += `,${key}:${queryParams[key]}`
else q += `${key}:${queryParams[key]}`
delete queryParams[key]
if (q) q += `,${key}:${_queryParams[key]}`
else q += `${key}:${_queryParams[key]}`
delete _queryParams[key]
}
}
const newQueryParams = { ...queryParams, q }
return flag ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return flag ? newQueryParams : _queryParams
},
handleTagColor(operateType) {
return this.colorMap.get(operateType)

View File

@ -217,7 +217,7 @@ export default {
this.isExpand = expand
},
handleSearch(queryParams) {
this.queryParams = { ...queryParams, scope: 'resource_type' }
this.queryParams = { ...this.queryParams, ...queryParams, scope: 'resource_type' }
this.getTable(this.queryParams)
},
searchFormReset() {
@ -253,9 +253,11 @@ export default {
},
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let flag = false
let q = queryParams.q ? queryParams.q : ''
for (const key in queryParams) {
let q = _queryParams.q ? _queryParams.q : ''
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
@ -263,16 +265,16 @@ export default {
key !== 'q' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
flag = true
if (q) q += `,${key}:${queryParams[key]}`
else q += `${key}:${queryParams[key]}`
delete queryParams[key]
if (q) q += `,${key}:${_queryParams[key]}`
else q += `${key}:${_queryParams[key]}`
delete _queryParams[key]
}
}
const newQueryParams = { ...queryParams, q }
return flag ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return flag ? newQueryParams : _queryParams
},
handleTagColor(operateType) {
return this.colorMap.get(operateType)

View File

@ -231,7 +231,7 @@ export default {
this.getTable(this.queryParams)
},
handleSearch(queryParams) {
this.queryParams = { ...queryParams, scope: this.checked ? 'role_relation' : 'role' }
this.queryParams = { ...this.queryParams, ...queryParams, scope: this.checked ? 'role_relation' : 'role' }
this.getTable(this.queryParams)
},
searchFormReset() {
@ -247,9 +247,10 @@ export default {
//
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let flag = false
let q = queryParams.q ? queryParams.q : ''
for (const key in queryParams) {
let q = _queryParams.q ? _queryParams.q : ''
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
@ -257,16 +258,16 @@ export default {
key !== 'q' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
flag = true
if (q) q += `,${key}:${queryParams[key]}`
else q += `${key}:${queryParams[key]}`
delete queryParams[key]
if (q) q += `,${key}:${_queryParams[key]}`
else q += `${key}:${_queryParams[key]}`
delete _queryParams[key]
}
}
const newQueryParams = { ...queryParams, q }
return flag ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return flag ? newQueryParams : _queryParams
},
// tag
handleTagColor(operateType) {

View File

@ -241,7 +241,7 @@ export default {
this.isExpand = expand
},
handleSearch(queryParams) {
this.queryParams = queryParams
this.queryParams = { ...this.queryParams, ...queryParams }
this.getTable(this.queryParams)
},
searchFormReset() {
@ -326,25 +326,27 @@ export default {
}
},
handleQueryParams(queryParams) {
const _queryParams = _.cloneDeep(queryParams)
let q = ''
for (const key in queryParams) {
for (const key in _queryParams) {
if (
key !== 'page' &&
key !== 'page_size' &&
key !== 'app_id' &&
key !== 'start' &&
key !== 'end' &&
queryParams[key] !== undefined
_queryParams[key] !== undefined
) {
if (q) {
q += `,${key}:${queryParams[key]}`
q += `,${key}:${_queryParams[key]}`
} else {
q += `${key}:${queryParams[key]}`
q += `${key}:${_queryParams[key]}`
}
}
}
const newQueryParams = { ...queryParams, q }
return q ? newQueryParams : queryParams
const newQueryParams = { ..._queryParams, q }
return q ? newQueryParams : _queryParams
},
handleTagColor(operateType) {
return this.colorMap.get(operateType)

View File

@ -1,6 +1,14 @@
<template>
<div class="ci-type-grant">
<vxe-table size="mini" stripe class="ops-stripe-table" :data="filterTableData" :max-height="`${tableHeight}px`">
<vxe-table
ref="xTable"
size="mini"
stripe
class="ops-stripe-table"
:data="filterTableData"
:max-height="`${tableHeight}px`"
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
>
<vxe-column field="name"></vxe-column>
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
<template #default="{row}">
@ -37,6 +45,7 @@ import _ from 'lodash'
import { permMap } from './constants.js'
import { grantCiType, revokeCiType } from '../../api/CIType'
import ReadCheckbox from './readCheckbox.vue'
import { getCurrentRowStyle } from './utils'
export default {
name: 'CiTypeGrant',
@ -55,10 +64,13 @@ export default {
type: String,
default: 'ci_type',
},
addedRids: {
type: Array,
default: () => [],
},
},
computed: {
filterTableData() {
console.log(_.cloneDeep(this.tableData))
const _tableData = this.tableData.filter((data) => {
const _intersection = _.intersection(
Object.keys(data),
@ -90,6 +102,7 @@ export default {
}
},
methods: {
getCurrentRowStyle,
async handleChange(e, col, row) {
if (e.target.checked) {
await grantCiType(this.CITypeId, row.rid, { perms: [col] }).catch(() => {

View File

@ -9,6 +9,8 @@
@grantDepart="grantDepart"
@grantRole="grantRole"
@getTableData="getTableData"
ref="grant_ci_type"
:addedRids="addedRids"
/>
</template>
<template
@ -25,6 +27,8 @@
@grantRole="grantRole"
@getTableData="getTableData"
@openReadGrantModal="openReadGrantModal"
ref="grant_ci"
:addedRids="addedRids"
/>
</template>
<template v-if="cmdbGrantType.includes('type_relation')">
@ -36,6 +40,8 @@
@grantDepart="grantDepart"
@grantRole="grantRole"
@getTableData="getTableData"
ref="grant_type_relation"
:addedRids="addedRids"
/>
</template>
<template v-if="cmdbGrantType.includes('relation_view')">
@ -47,6 +53,8 @@
@grantDepart="grantDepart"
@grantRole="grantRole"
@getTableData="getTableData"
ref="grant_relation_view"
:addedRids="addedRids"
/>
</template>
@ -108,6 +116,7 @@ export default {
attrGroup: [],
filerPerimissions: {},
loading: false,
addedRids: [], // rid
}
},
computed: {
@ -282,6 +291,12 @@ export default {
})
)
}
this.addedRids = rids
this.$nextTick(() => {
setTimeout(() => {
this.$refs[`grant_${grantType}`].$refs.xTable.elemStore['main-body-wrapper'].scrollTo(0, 0)
}, 300)
})
},
openReadGrantModal(col, row) {
this.$refs.readGrantModal.open(col, row)

View File

@ -1,6 +1,14 @@
<template>
<div class="ci-relation-grant">
<vxe-table size="mini" stripe class="ops-stripe-table" :data="tableData" :max-height="`${tableHeight}px`">
<vxe-table
ref="xTable"
size="mini"
stripe
class="ops-stripe-table"
:data="tableData"
:max-height="`${tableHeight}px`"
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
>
<vxe-column field="name"></vxe-column>
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
<template #default="{row}">
@ -18,6 +26,8 @@
<script>
import { permMap } from './constants.js'
import { grantRelationView, revokeRelationView } from '../../api/preference.js'
import { getCurrentRowStyle } from './utils'
export default {
name: 'RelationViewGrant',
inject: ['loading', 'isModal'],
@ -34,6 +44,10 @@ export default {
type: String,
default: 'relation_view',
},
addedRids: {
type: Array,
default: () => [],
},
},
data() {
return {
@ -53,6 +67,7 @@ export default {
},
},
methods: {
getCurrentRowStyle,
grantDepart() {
this.$emit('grantDepart', this.grantType)
},

View File

@ -1,6 +1,14 @@
<template>
<div class="ci-relation-grant">
<vxe-table size="mini" stripe class="ops-stripe-table" :data="tableData" :max-height="`${tableHeight}px`">
<vxe-table
ref="xTable"
size="mini"
stripe
class="ops-stripe-table"
:data="tableData"
:max-height="`${tableHeight}px`"
:row-style="(params) => getCurrentRowStyle(params, addedRids)"
>
<vxe-column field="name"></vxe-column>
<vxe-column v-for="col in columns" :key="col" :field="col" :title="permMap[col]">
<template #default="{row}">
@ -18,6 +26,8 @@
<script>
import { permMap } from './constants.js'
import { grantTypeRelation, revokeTypeRelation } from '../../api/CITypeRelation.js'
import { getCurrentRowStyle } from './utils'
export default {
name: 'TypeRelationGrant',
inject: ['loading', 'isModal'],
@ -34,6 +44,10 @@ export default {
type: Array,
default: null,
},
addedRids: {
type: Array,
default: () => [],
},
},
data() {
return {
@ -53,6 +67,7 @@ export default {
},
},
methods: {
getCurrentRowStyle,
grantDepart() {
this.$emit('grantDepart', this.grantType)
},

View File

@ -0,0 +1,4 @@
export const getCurrentRowStyle = ({ row }, addedRids) => {
const idx = addedRids.findIndex(item => item.rid === row.rid)
return idx > -1 ? 'background-color:#E0E7FF!important' : ''
}

View File

@ -1,6 +1,7 @@
<template>
<a-form :form="form" class="create-new-attribute">
<a-divider style="font-size:14px;margin-top:6px;">基础设置</a-divider>
<a-row>
<a-col :span="12">
<a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="属性名(英文)">
<a-input
@ -11,7 +12,10 @@
{
rules: [
{ required: true, message: '请输入属性名' },
{ message: '不能以数字开头,可以是英文 数字以及下划线 (_)', pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$') },
{
message: '不能以数字开头,可以是英文 数字以及下划线 (_)',
pattern: RegExp('^(?!\\d)[a-zA-Z_0-9]+$'),
},
{ message: '内置字段', pattern: RegExp('^(?!(id|_id|ci_id|type|_type|ci_type)$).*$') },
],
},
@ -24,6 +28,8 @@
<a-input name="alias" v-decorator="['alias', { rules: [] }]" />
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="12">
<a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="数据类型">
<a-select
@ -125,6 +131,7 @@
</template>
</a-form-item>
</a-col>
</a-row>
<a-col :span="6">
<a-form-item

View File

@ -534,7 +534,7 @@ export default {
})
},
getAllFlatEmployees() {
getEmployeeList({ block_status: 0, page_size: 99999 }).then((res) => {
getEmployeeList({ block_status: -1, page_size: 99999 }).then((res) => {
this.allFlatEmployees = res.data_list
})
},
@ -721,7 +721,7 @@ export default {
this.loading = false
},
updateAll() {
this.expression = []
// this.expression = []
this.updateCount()
this.updateTableDataByFilter()
},
@ -774,7 +774,7 @@ export default {
},
reset() {
this.filterName = ''
this.$refs.filterComp.expression = ''
this.$refs.filterComp.expression = []
this.updateTableDataByFilter()
},
handleSearch(expression) {

File diff suppressed because it is too large Load Diff