182182 </template >
183183 <template #two >
184184 <div class =" ci-types-right" >
185- <CITypeDetail v-if =" currentCId " :CITypeId =" currentCId " :CITypeName =" currentCName " />
185+ <CITypeDetail
186+ v-if =" currentCId "
187+ :CITypeId =" currentCId "
188+ :CITypeName =" currentCName "
189+ :preferenceData =" preferenceData "
190+ />
186191 <div v-else class =" ci-types-right-empty" >
187192 <a-empty :image =" emptyImage" description =" " ></a-empty >
188193 <a-button icon =" plus" size =" small" type =" primary" @click =" handleCreateCiFromEmpty" >{{
@@ -413,6 +418,7 @@ import {
413418 exportCITypeGroups
414419} from ' @/modules/cmdb/api/ciTypeGroup'
415420import { searchAttributes , getCITypeAttributesById } from ' @/modules/cmdb/api/CITypeAttr'
421+ import { getPreference } from ' @/modules/cmdb/api/preference'
416422import CreateNewAttribute from ' ./ceateNewAttribute.vue'
417423import CITypeDetail from ' ./ciTypedetail.vue'
418424import emptyImage from ' @/assets/data_empty.png'
@@ -489,7 +495,9 @@ export default {
489495
490496 searchValue: ' ' ,
491497 modelExportVisible: false ,
492- pageLoading: false
498+ pageLoading: false ,
499+
500+ preferenceData: {}
493501 }
494502 },
495503 computed: {
@@ -510,23 +518,29 @@ export default {
510518 },
511519 currentGId () {
512520 if (this .currentId ) {
513- return Number (this .currentId .split (' %' )[0 ])
521+ const id = this ? .currentId ? .split ? .(' %' )? .[0 ]
522+ if (id !== ' null' ) {
523+ return Number (id)
524+ }
525+ return null
514526 }
515527 return null
516528 },
517529 currentCId () {
518530 if (this .currentId ) {
519- if (this .currentId .split (' %' )[1 ] !== ' null' ) {
520- return Number (this .currentId .split (' %' )[1 ])
531+ const id = this ? .currentId ? .split ? .(' %' )? .[1 ]
532+ if (id !== ' null' ) {
533+ return Number (id)
521534 }
522535 return null
523536 }
524537 return null
525538 },
526539 currentCName () {
527540 if (this .currentId ) {
528- if (this .currentId .split (' %' )[2 ] !== ' null' ) {
529- return this .currentId .split (' %' )[2 ]
541+ const name = this ? .currentId ? .split ? .(' %' )? .[2 ]
542+ if (name !== ' null' ) {
543+ return name
530544 }
531545 return null
532546 }
@@ -598,6 +612,7 @@ export default {
598612 this .pageLoading = false
599613
600614 this .getAttributes ()
615+ this .getPreference ()
601616 },
602617 methods: {
603618 getAllDepAndEmployee () {
@@ -608,6 +623,13 @@ export default {
608623 handleSearch (e ) {
609624 this .searchValue = e .target .value
610625 },
626+
627+ getPreference () {
628+ getPreference ().then ((res ) => {
629+ this .preferenceData = res || {}
630+ })
631+ },
632+
611633 async loadCITypes (isResetCurrentId = false , isInit = false ) {
612634 const groups = await getCITypeGroupsConfig ({ need_other: true })
613635 let alreadyReset = false
@@ -632,8 +654,10 @@ export default {
632654 if (isInit) {
633655 const isMatch = groups .some ((g ) => {
634656 const matchGroup = ` ${ g? .id }% null % null ` === this.currentId
635- const matchCITypes = g?.ci_types?.some((item) => ` ${g? .id }% ${item? .id }% ${item? .name }` === this.currentId)
636- return matchGroup || matchCITypes
657+ const matchCIType = g?.ci_types?.some((item) => {
658+ return ` ${g? .id }% ${item? .id }% ${item? .name }` === this.currentId || ` null % ${item? .id }% ${item? .name }` === this.currentId
659+ })
660+ return matchGroup || matchCIType
637661 })
638662
639663 if (!isMatch) {
0 commit comments