diff --git a/cmdb-ui/public/iconfont/demo_index.html b/cmdb-ui/public/iconfont/demo_index.html
index 6fe2c09..0f9fea8 100644
--- a/cmdb-ui/public/iconfont/demo_index.html
+++ b/cmdb-ui/public/iconfont/demo_index.html
@@ -54,6 +54,12 @@
@@ -101,6 +101,8 @@ import ValueTypeIcon from '@/components/CMDBValueTypeMapIcon'
import { valueTypeMap } from '../../utils/const'
import TriggerForm from './triggerForm.vue'
import { updateCIType } from '@/modules/cmdb/api/CIType'
+import { getPropertyType } from '../../utils/helper'
+
export default {
name: 'AttributeCard',
inject: {
@@ -191,6 +193,7 @@ export default {
},
},
methods: {
+ getPropertyType,
handleEdit() {
this.$emit('edit')
},
diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEdit/referenceModelSelect.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEdit/referenceModelSelect.vue
new file mode 100644
index 0000000..b9bcb75
--- /dev/null
+++ b/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEdit/referenceModelSelect.vue
@@ -0,0 +1,78 @@
+
+
+
+
+ {{ item.label }}
+
+
+
+
+
+
diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue
index de5065c..caa0caf 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue
@@ -60,11 +60,17 @@
v-decorator="['value_type', { rules: [{ required: true }] }]"
@change="handleChangeValueType"
>
-
{{ value }}
+
+
+ {{ value }}
+
-
+
+
@@ -157,7 +162,18 @@
-
+
+
+
+
+
@@ -206,7 +222,7 @@
@@ -219,7 +235,7 @@
@@ -228,8 +244,8 @@
>{{ $t('cmdb.ciType.defaultShow') }}
{
@@ -250,7 +266,7 @@
@@ -263,7 +279,7 @@
-
+
{{ $t('cmdb.ciType.list') }}
{
@@ -297,7 +313,7 @@
@@ -306,8 +322,8 @@
>{{ $t('cmdb.ciType.isDynamic') }}
{
@@ -328,17 +344,22 @@
{{ $t('cmdb.ciType.advancedSettings') }}
-
+
-
+
-
+
-
+
-
+
{{ $t('cmdb.ciType.computedAttribute') }}
{
@@ -415,14 +436,16 @@ import {
calcComputedAttribute,
} from '@/modules/cmdb/api/CITypeAttr'
import { valueTypeMap } from '../../utils/const'
+import { getPropertyType, getPropertyIcon } from '../../utils/helper'
import ComputedArea from './computedArea.vue'
import PreValueArea from './preValueArea.vue'
import FontArea from './fontArea.vue'
import RegSelect from '@/components/RegexSelect'
+import ReferenceModelSelect from './attributeEdit/referenceModelSelect.vue'
export default {
name: 'AttributeEditForm',
- components: { ComputedArea, PreValueArea, vueJsonEditor, FontArea, RegSelect },
+ components: { ComputedArea, PreValueArea, vueJsonEditor, FontArea, RegSelect, ReferenceModelSelect },
props: {
CITypeId: {
type: Number,
@@ -467,7 +490,7 @@ export default {
return formLayout === 'horizontal'
? {
labelCol: { span: 8 },
- wrapperCol: { span: 12 },
+ wrapperCol: { span: 15 },
}
: {}
},
@@ -484,6 +507,7 @@ export default {
},
mounted() {},
methods: {
+ getPropertyIcon,
async handleCreate() {
try {
await canDefineComputed()
@@ -516,9 +540,7 @@ export default {
}
}
if (property === 'is_list') {
- this.form.setFieldsValue({
- default_value: checked ? [] : '',
- })
+ this.handleSwitchIsList(checked)
}
if (checked && property === 'is_sortable') {
this.$message.warning(this.$t('cmdb.ciType.addAttributeTips1'))
@@ -536,6 +558,26 @@ export default {
}
},
+ handleSwitchIsList(checked) {
+ let defaultValue = checked ? [] : ''
+
+ switch (this.currentValueType) {
+ case '2':
+ case '9':
+ defaultValue = ''
+ break
+ case '10':
+ defaultValue = checked ? '' : false
+ break
+ default:
+ break
+ }
+
+ this.form.setFieldsValue({
+ default_value: defaultValue,
+ })
+ },
+
async handleEdit(record, attributes) {
try {
await canDefineComputed()
@@ -544,12 +586,7 @@ export default {
this.canDefineComputed = false
}
const _record = _.cloneDeep(record)
- if (_record.is_password) {
- _record.value_type = '7'
- }
- if (_record.is_link) {
- _record.value_type = '8'
- }
+ _record.value_type = getPropertyType(_record)
this.drawerTitle = this.$t('cmdb.ciType.editAttribute')
this.drawerVisible = true
this.record = _record
@@ -573,8 +610,13 @@ export default {
is_dynamic: _record.is_dynamic,
})
}
+ if (_record.value_type === '11') {
+ this.form.setFieldsValue({
+ reference_type_id: _record.reference_type_id
+ })
+ }
console.log(_record)
- if (!['6'].includes(_record.value_type) && _record.re_check) {
+ if (!['6', '10', '11'].includes(_record.value_type) && _record.re_check) {
this.re_check = {
value: _record.re_check,
}
@@ -583,7 +625,11 @@ export default {
}
if (_record.default) {
this.$nextTick(() => {
- if (_record.value_type === '0') {
+ if (_record.value_type === '10') {
+ this.form.setFieldsValue({
+ default_value: Boolean(_record.default.default),
+ })
+ } else if (_record.value_type === '0') {
if (_record.is_list) {
this.$nextTick(() => {
this.form.setFieldsValue({
@@ -639,7 +685,7 @@ export default {
})
}
const _find = attributes.find((item) => item.id === _record.id)
- if (!['6', '7'].includes(_record.value_type)) {
+ if (!['6', '7', '10', '11'].includes(_record.value_type)) {
this.$refs.preValueArea.setData({
choice_value: (_find || {}).choice_value || [],
choice_web_hook: _record.choice_web_hook,
@@ -672,7 +718,9 @@ export default {
delete values['default_show']
delete values['is_required']
const { default_value } = values
- if (values.value_type === '0' && default_value) {
+ if (values.value_type === '10') {
+ values.default = { default: values.is_list ? default_value : Boolean(default_value) }
+ } else if (values.value_type === '0' && default_value) {
if (values.is_list) {
values.default = { default: default_value || null }
} else {
@@ -706,23 +754,42 @@ export default {
values = { ...values, ...computedAreaData }
} else {
// If it is a non-computed attribute, check to see if there is a predefined value
- if (!['6', '7'].includes(values.value_type)) {
+ if (!['6', '7', '10', '11'].includes(values.value_type)) {
const preValueAreaData = this.$refs.preValueArea.getData()
values = { ...values, ...preValueAreaData }
}
}
const fontOptions = this.$refs.fontArea.getData()
- if (values.value_type === '7') {
- values.value_type = '2'
- values.is_password = true
- }
- if (values.value_type === '8') {
- values.value_type = '2'
- values.is_link = true
- }
- if (values.value_type !== '6') {
+
+ if (!['6', '10', '11'].includes(values.value_type)) {
values.re_check = this.re_check?.value ?? null
}
+
+ // 重置数据类型
+ switch (values.value_type) {
+ case '7':
+ values.value_type = '2'
+ values.is_password = true
+ break
+ case '8':
+ values.value_type = '2'
+ values.is_link = true
+ break
+ case '9':
+ values.value_type = '2'
+ break
+ case '10':
+ values.value_type = '7'
+ values.is_bool = true
+ break
+ case '11':
+ values.value_type = '0'
+ values.is_reference = true
+ break
+ default:
+ break
+ }
+
if (values.id) {
await this.updateAttribute(values.id, { ...values, option: { fontOptions } }, isCalcComputed)
} else {
@@ -806,6 +873,9 @@ export default {
line-height: 22px;
color: #a5a9bc;
}
+.value-type-text {
+ margin-left: 4px;
+}
diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/relationAD.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/relationAD.vue
index 2383f40..0353046 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci_types/relationAD.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci_types/relationAD.vue
@@ -137,6 +137,7 @@ import {
getCITypeChildren,
getCITypeParent
} from '../../api/CITypeRelation.js'
+import { getCITypeAttributesById } from '../../api/CITypeAttr'
export default {
name: 'RelationAutoDiscovery',
@@ -169,7 +170,18 @@ export default {
methods: {
async getCITypeAttributes() {
const res = await getCITypeAttributes(this.CITypeId)
- this.ciTypeADTAttributes = res.map((item) => {
+ const attr = await getCITypeAttributesById(this.CITypeId)
+
+ const filterAttr = res.filter((name) => {
+ const currentAttr = attr?.attributes?.find((item) => item?.name === name)
+ if (!currentAttr) {
+ return true
+ }
+
+ return this.filterAttributes(name)
+ })
+
+ this.ciTypeADTAttributes = filterAttr.map((item) => {
return {
id: item,
value: item,
@@ -239,7 +251,7 @@ export default {
const peer_type_id = item.peer_type_id
const attributes = this?.relationOptions?.find((option) => option?.value === peer_type_id)?.attributes
- item.attributes = attributes
+ item.attributes = attributes.filter((attr) => this.filterAttributes(attr))
item.peer_attr_id = undefined
})
},
@@ -288,6 +300,15 @@ export default {
this.getCITypeRelations()
}
},
+
+ filterAttributes(attr) {
+ // filter password/json/is_list/longText/bool/reference
+ if (attr?.value_type === '2' && !attr?.is_index) {
+ return false
+ }
+
+ return !attr?.is_password && !attr?.is_list && attr?.value_type !== '6' && !attr?.is_bool && !attr?.is_reference
+ },
},
}
diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/relationTable.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/relationTable.vue
index 8346a22..2a19985 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci_types/relationTable.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci_types/relationTable.vue
@@ -598,8 +598,14 @@ export default {
})
},
filterAttributes(attributes) {
- // filter password/json/is_list
- return attributes.filter((attr) => !attr.is_password && !attr.is_list && attr.value_type !== '6')
+ // filter password/json/is_list/longText/bool/reference
+ return attributes.filter((attr) => {
+ if (attr.value_type === '2' && !attr.is_index) {
+ return false
+ }
+
+ return !attr.is_password && !attr.is_list && attr.value_type !== '6' && !attr.is_bool && !attr.is_reference
+ })
},
addTableAttr() {
this.tableAttrList.push({
diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/triggerForm.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/triggerForm.vue
index db6abf4..ad871e6 100644
--- a/cmdb-ui/src/modules/cmdb/views/ci_types/triggerForm.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ci_types/triggerForm.vue
@@ -471,10 +471,15 @@ export default {
this.dateForm = _.cloneDeep(this.defaultDateForm)
this.notifies = _.cloneDeep(this.defaultNotify)
this.category = 1
- this.triggerAction = '1'
this.filterExp = ''
this.selectedBot = undefined
- this.visible = false
+ if (this.$refs.noticeContent) {
+ this.$refs.noticeContent.destroy()
+ }
+
+ this.$nextTick(() => {
+ this.visible = false
+ })
},
filterChange(value) {
this.filterValue = value
diff --git a/cmdb-ui/src/modules/cmdb/views/model_relation/index.vue b/cmdb-ui/src/modules/cmdb/views/model_relation/index.vue
index d5a1d25..442da89 100644
--- a/cmdb-ui/src/modules/cmdb/views/model_relation/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/model_relation/index.vue
@@ -364,8 +364,14 @@ export default {
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
filterAttributes(attributes) {
- // filter password/json/is_list
- return attributes.filter((attr) => !attr.is_password && !attr.is_list && attr.value_type !== '6')
+ // filter password/json/is_list/longText/bool/reference
+ return attributes.filter((attr) => {
+ if (attr.value_type === '2' && !attr.is_index) {
+ return false
+ }
+
+ return !attr.is_password && !attr.is_list && attr.value_type !== '6' && !attr.is_bool && !attr.is_reference
+ })
},
addModalAttr() {
diff --git a/cmdb-ui/src/modules/cmdb/views/model_relation/modules/modelRelationTable.vue b/cmdb-ui/src/modules/cmdb/views/model_relation/modules/modelRelationTable.vue
index 31134a7..40484b4 100644
--- a/cmdb-ui/src/modules/cmdb/views/model_relation/modules/modelRelationTable.vue
+++ b/cmdb-ui/src/modules/cmdb/views/model_relation/modules/modelRelationTable.vue
@@ -306,8 +306,14 @@ export default {
return _find?.alias ?? _find?.name ?? id
},
filterAttributes(attributes) {
- // filter password/json/is_list
- return attributes.filter((attr) => !attr.is_password && !attr.is_list && attr.value_type !== '6')
+ // filter password/json/is_list/longText/bool/reference
+ return attributes.filter((attr) => {
+ if (attr.value_type === '2' && !attr.is_index) {
+ return false
+ }
+
+ return !attr.is_password && !attr.is_list && attr.value_type !== '6' && !attr.is_bool && !attr.is_reference
+ })
},
addTableAttr() {
diff --git a/cmdb-ui/src/modules/cmdb/views/relation_views/modules/AddTableModal.vue b/cmdb-ui/src/modules/cmdb/views/relation_views/modules/AddTableModal.vue
index e1238b1..5f2236f 100644
--- a/cmdb-ui/src/modules/cmdb/views/relation_views/modules/AddTableModal.vue
+++ b/cmdb-ui/src/modules/cmdb/views/relation_views/modules/AddTableModal.vue
@@ -1,250 +1,260 @@
-
-
-
-
-
- {
- $refs.createInstanceForm.handleOpen(true, 'create')
- }
- "
- slot="extraContent"
- type="primary"
- size="small"
- >新增
-
-
-
-
-
- {{ JSON.stringify(row[col.field]) }}
-
-
-
-
-
-
- {
- currentPage = 1
- getTableData(true)
- }
- "
- />
-
-
-
-
-
-
+
+
+
+
+
+ {
+ $refs.createInstanceForm.handleOpen(true, 'create')
+ }
+ "
+ slot="extraContent"
+ type="primary"
+ size="small"
+ >新增
+
+
+
+
+
+
+ {{ id }}
+
+
+
+ {{ JSON.stringify(row[col.field]) }}
+
+
+
+
+
+
+ {
+ currentPage = 1
+ getTableData(true)
+ }
+ "
+ />
+
+
+
+
+
+
diff --git a/cmdb-ui/src/modules/cmdb/views/resource_search/index.vue b/cmdb-ui/src/modules/cmdb/views/resource_search/index.vue
index 1808ad5..2835288 100644
--- a/cmdb-ui/src/modules/cmdb/views/resource_search/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/resource_search/index.vue
@@ -101,8 +101,18 @@
:minWidth="100"
:cell-type="col.value_type === '2' ? 'string' : 'auto'"
>
-
- {{ JSON.stringify(row[col.field]) }}
+
+
+
+ {{ getReferenceAttrValue(ciId, col) }}
+
+
+ {{ JSON.stringify(row[col.field]) }}
{
this.columnsGroup = [..._commonColumnsGroup, ..._columnsGroup]
this.instanceList = res['result']
+ this.handlePerference()
})
})
.finally(() => {
this.loading = false
})
},
+
+ handlePerference() {
+ let needRequiredCIType = []
+ this.columnsGroup.forEach((group) => {
+ group.children.forEach((col) => {
+ if (col?.is_reference && col?.reference_type_id) {
+ needRequiredCIType.push(col)
+ }
+ })
+ })
+ needRequiredCIType = _.uniq(needRequiredCIType)
+
+ if (!needRequiredCIType.length) {
+ this.referenceShowAttrNameMap = {}
+ this.referenceCIIdMap = {}
+ return
+ }
+
+ this.handleReferenceShowAttrName(needRequiredCIType)
+ this.handleReferenceCIIdMap(needRequiredCIType)
+ },
+
+ async handleReferenceShowAttrName(needRequiredCIType) {
+ const res = await getCITypes({
+ type_ids: needRequiredCIType.map((col) => col.reference_type_id).join(',')
+ })
+
+ const map = {}
+ res.ci_types.forEach((ciType) => {
+ map[ciType.id] = ciType?.show_name || ciType?.unique_name || ''
+ })
+
+ this.referenceShowAttrNameMap = map
+ },
+
+ async handleReferenceCIIdMap(needRequiredCIType) {
+ const map = {}
+ this.instanceList.forEach((row) => {
+ needRequiredCIType.forEach((col) => {
+ const ids = Array.isArray(row[col.field]) ? row[col.field] : row[col.field] ? [row[col.field]] : []
+ if (ids.length) {
+ if (!map?.[col.reference_type_id]) {
+ map[col.reference_type_id] = {}
+ }
+ ids.forEach((id) => {
+ map[col.reference_type_id][id] = {}
+ })
+ }
+ })
+ })
+
+ if (!Object.keys(map).length) {
+ this.referenceCIIdMap = {}
+ return
+ }
+
+ const allRes = await Promise.all(
+ Object.keys(map).map((key) => {
+ return searchCI({
+ q: `_type:${key},_id:(${Object.keys(map[key]).join(';')})`,
+ count: 9999
+ })
+ })
+ )
+
+ allRes.forEach((res) => {
+ res.result.forEach((item) => {
+ if (map?.[item._type]?.[item._id]) {
+ map[item._type][item._id] = item
+ }
+ })
+ })
+
+ this.referenceCIIdMap = map
+ },
+
+ getReferenceAttrValue(id, col) {
+ const ci = this?.referenceCIIdMap?.[col?.reference_type_id]?.[id]
+ if (!ci) {
+ return id
+ }
+
+ const attrName = this.referenceShowAttrNameMap?.[col.reference_type_id]
+ return ci?.[attrName] || id
+ },
+
getColumns(data, attrList) {
const width = document.getElementById('resource_search').clientWidth - 50
return getCITableColumns(data, attrList, width).map((item) => {
diff --git a/cmdb-ui/src/modules/cmdb/views/tree_views/modules/treeViewsNode.vue b/cmdb-ui/src/modules/cmdb/views/tree_views/modules/treeViewsNode.vue
index 8e8b96e..97898fc 100644
--- a/cmdb-ui/src/modules/cmdb/views/tree_views/modules/treeViewsNode.vue
+++ b/cmdb-ui/src/modules/cmdb/views/tree_views/modules/treeViewsNode.vue
@@ -14,7 +14,7 @@ export default {
name: 'TreeViewsNode',
props: {
title: {
- type: [String, Number],
+ type: [String, Number, Boolean],
default: '',
},
treeKey: {