182
182
</template >
183
183
<template #two >
184
184
<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
+ />
186
191
<div v-else class =" ci-types-right-empty" >
187
192
<a-empty :image =" emptyImage" description =" " ></a-empty >
188
193
<a-button icon =" plus" size =" small" type =" primary" @click =" handleCreateCiFromEmpty" >{{
@@ -413,6 +418,7 @@ import {
413
418
exportCITypeGroups
414
419
} from ' @/modules/cmdb/api/ciTypeGroup'
415
420
import { searchAttributes , getCITypeAttributesById } from ' @/modules/cmdb/api/CITypeAttr'
421
+ import { getPreference } from ' @/modules/cmdb/api/preference'
416
422
import CreateNewAttribute from ' ./ceateNewAttribute.vue'
417
423
import CITypeDetail from ' ./ciTypedetail.vue'
418
424
import emptyImage from ' @/assets/data_empty.png'
@@ -489,7 +495,9 @@ export default {
489
495
490
496
searchValue: ' ' ,
491
497
modelExportVisible: false ,
492
- pageLoading: false
498
+ pageLoading: false ,
499
+
500
+ preferenceData: {}
493
501
}
494
502
},
495
503
computed: {
@@ -510,23 +518,29 @@ export default {
510
518
},
511
519
currentGId () {
512
520
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
514
526
}
515
527
return null
516
528
},
517
529
currentCId () {
518
530
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)
521
534
}
522
535
return null
523
536
}
524
537
return null
525
538
},
526
539
currentCName () {
527
540
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
530
544
}
531
545
return null
532
546
}
@@ -598,6 +612,7 @@ export default {
598
612
this .pageLoading = false
599
613
600
614
this .getAttributes ()
615
+ this .getPreference ()
601
616
},
602
617
methods: {
603
618
getAllDepAndEmployee () {
@@ -608,6 +623,13 @@ export default {
608
623
handleSearch (e ) {
609
624
this .searchValue = e .target .value
610
625
},
626
+
627
+ getPreference () {
628
+ getPreference ().then ((res ) => {
629
+ this .preferenceData = res || {}
630
+ })
631
+ },
632
+
611
633
async loadCITypes (isResetCurrentId = false , isInit = false ) {
612
634
const groups = await getCITypeGroupsConfig ({ need_other: true })
613
635
let alreadyReset = false
@@ -632,8 +654,10 @@ export default {
632
654
if (isInit) {
633
655
const isMatch = groups .some ((g ) => {
634
656
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
637
661
})
638
662
639
663
if (!isMatch) {
0 commit comments