diff --git a/cmdb-ui/src/components/CMDBFilterComp/index.vue b/cmdb-ui/src/components/CMDBFilterComp/index.vue index 6c347a6..07c0456 100644 --- a/cmdb-ui/src/components/CMDBFilterComp/index.vue +++ b/cmdb-ui/src/components/CMDBFilterComp/index.vue @@ -68,7 +68,8 @@ export default { }, methods: { - visibleChange(open) { + visibleChange(open, isInitOne = true) { + // isInitOne 初始化exp为空时,ruleList是否默认给一条 // const regQ = /(?<=q=).+(?=&)|(?<=q=).+$/g const exp = this.expression.match(new RegExp(this.regQ, 'g')) ? this.expression.match(new RegExp(this.regQ, 'g'))[0] @@ -151,15 +152,20 @@ export default { }) this.ruleList = [...expArray] } else if (open) { - this.ruleList = [ - { - id: uuidv4(), - type: 'and', - property: this.canSearchPreferenceAttrList[0].name, - exp: 'is', - value: null, - }, - ] + this.ruleList = isInitOne + ? [ + { + id: uuidv4(), + type: 'and', + property: + this.canSearchPreferenceAttrList && this.canSearchPreferenceAttrList.length + ? this.canSearchPreferenceAttrList[0].name + : undefined, + exp: 'is', + value: null, + }, + ] + : [] } }, handleClear() { diff --git a/cmdb-ui/src/modules/cmdb/api/CITypeAttr.js b/cmdb-ui/src/modules/cmdb/api/CITypeAttr.js index 3720c52..1a963b1 100644 --- a/cmdb-ui/src/modules/cmdb/api/CITypeAttr.js +++ b/cmdb-ui/src/modules/cmdb/api/CITypeAttr.js @@ -77,6 +77,14 @@ export function getCITypeAttributesByTypeIds(params) { }) } +export function getCITypeCommonAttributesByTypeIds(params) { + return axios({ + url: `/v0.1/ci_types/common_attributes`, + method: 'get', + params: params + }) +} + /** * 删除属性 * @param attrId diff --git a/cmdb-ui/src/modules/cmdb/api/CITypeRelation.js b/cmdb-ui/src/modules/cmdb/api/CITypeRelation.js index 20d4f5e..3aaf654 100644 --- a/cmdb-ui/src/modules/cmdb/api/CITypeRelation.js +++ b/cmdb-ui/src/modules/cmdb/api/CITypeRelation.js @@ -61,3 +61,10 @@ export function revokeTypeRelation(first_type_id, second_type_id, rid, data) { data }) } + +export function getRecursive_level2children(type_id) { + return axios({ + url: `/v0.1/ci_type_relations/${type_id}/recursive_level2children`, + method: 'GET' + }) +} diff --git a/cmdb-ui/src/modules/cmdb/api/customDashboard.js b/cmdb-ui/src/modules/cmdb/api/customDashboard.js index dcdd1f6..863609c 100644 --- a/cmdb-ui/src/modules/cmdb/api/customDashboard.js +++ b/cmdb-ui/src/modules/cmdb/api/customDashboard.js @@ -37,3 +37,11 @@ export function batchUpdateCustomDashboard(data) { data }) } + +export function postCustomDashboardPreview(data) { + return axios({ + url: '/v0.1/custom_dashboard/preview', + method: 'post', + data + }) +} diff --git a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chart.vue b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chart.vue index 0b896c2..8808e6d 100644 --- a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chart.vue +++ b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chart.vue @@ -1,11 +1,55 @@ @@ -127,12 +168,14 @@ export default { }, } }, - mounted() { - this.getLayout() + created() { getCITypes().then((res) => { this.ci_types = res.ci_types }) }, + mounted() { + this.getLayout() + }, methods: { async getLayout() { const res = await getCustomDashboard() @@ -196,6 +239,13 @@ export default { }) } }, + getCiType(item) { + if (item.type_id || item.options?.type_ids) { + const _find = this.ci_types.find((type) => type.id === item.type_id || type.id === item.options?.type_ids[0]) + return _find || null + } + return null + }, }, } @@ -206,15 +256,18 @@ export default { text-align: center; } .cmdb-dashboard-grid-item { - border-radius: 15px; + border-radius: 8px; + padding: 6px 12px; .cmdb-dashboard-grid-item-title { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; font-weight: 700; - padding-left: 6px; - color: #000000bd; + color: #000000; } .cmdb-dashboard-grid-item-operation { position: absolute; - right: 6px; + right: 12px; top: 6px; } .cmdb-dashboard-grid-item-chart-type { @@ -224,3 +277,26 @@ export default { } } + +