Skip to content

Commit f8ab88f

Browse files
committed
fix(ui): attr editor control type display
1 parent 011284d commit f8ab88f

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

cmdb-ui/src/modules/cmdb/components/ciTable/index.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<vxe-input v-else-if="col.is_password" v-model="passwordValue[col.field]" />
7474

7575
<a-textarea
76-
v-else-if="col.value_type === '2' && !col.is_index"
76+
v-else-if="isLongText(col)"
7777
:value="col.is_list && Array.isArray(row[col.field]) ? row[col.field].join(',') : row[col.field]"
7878
:style="{ resize: 'none' }"
7979
:rows="1"
@@ -226,6 +226,8 @@
226226
import _ from 'lodash'
227227
import { getCITypes } from '@/modules/cmdb/api/CIType'
228228
import { searchCI } from '@/modules/cmdb/api/ci'
229+
import { isLongText } from '@/modules/cmdb/utils/helper.js'
230+
229231
import JsonEditor from '../JsonEditor/jsonEditor.vue'
230232
import PasswordField from '../passwordField/index.vue'
231233
import { ops_move_icon as OpsMoveIcon } from '@/core/icons'
@@ -353,6 +355,7 @@ export default {
353355
},
354356
355357
methods: {
358+
isLongText,
356359
getVxetableRef() {
357360
return this?.$refs?.['xTable']?.getVxetableRef?.() || null
358361
},
@@ -541,7 +544,7 @@ export default {
541544
},
542545
543546
showCustomEditComponent(col) {
544-
if (col.value_type === '2' && !col.is_index) {
547+
if (isLongText(col)) {
545548
return true
546549
}
547550

cmdb-ui/src/modules/cmdb/utils/helper.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export function getCITableColumns(data, attrList, width = 1600, height) {
128128
is_fixed: attr.is_fixed,
129129
is_bool: attr.is_bool,
130130
is_reference: attr.is_reference,
131+
is_index: attr.is_index,
131132
reference_type_id: attr.reference_type_id
132133
})
133134
}
@@ -295,4 +296,8 @@ export const getAllParentNodesLabel = (node, label) => {
295296
}
296297
export const getTreeSelectLabel = (node) => {
297298
return `${getAllParentNodesLabel(node, node.label)}`
298-
}
299+
}
300+
301+
export const isLongText = (attr) => {
302+
return attr.value_type === '2' && attr.is_index === false && !attr.is_link && !attr.is_attachment && !attr.is_password
303+
}

cmdb-ui/src/modules/cmdb/views/ci/modules/CreateInstanceForm.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,13 @@ import moment from 'moment'
181181
import { Select, Option } from 'element-ui'
182182
import { getCIType, getCITypeGroupById } from '@/modules/cmdb/api/CIType'
183183
import { addCI } from '@/modules/cmdb/api/ci'
184-
import JsonEditor from '../../../components/JsonEditor/jsonEditor.vue'
184+
import { getCITypeParent, getCanEditByParentIdChildId } from '@/modules/cmdb/api/CITypeRelation'
185185
import { valueTypeMap } from '../../../utils/const'
186+
import { isLongText } from '@/modules/cmdb/utils/helper'
187+
186188
import CreateInstanceFormByGroup from './createInstanceFormByGroup.vue'
187-
import { getCITypeParent, getCanEditByParentIdChildId } from '@/modules/cmdb/api/CITypeRelation'
188189
import CIReferenceAttr from '@/components/ciReferenceAttr/index.vue'
190+
import JsonEditor from '../../../components/JsonEditor/jsonEditor.vue'
189191
190192
export default {
191193
name: 'CreateInstanceForm',
@@ -465,7 +467,7 @@ export default {
465467
return 'input_number'
466468
} else if (_find.value_type === '4' || _find.value_type === '3') {
467469
return _find.value_type
468-
} else if (_find.value_type === '2' && !_find.is_index) {
470+
} else if (isLongText(_find)) {
469471
return 'textarea'
470472
} else {
471473
return 'input'

cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailAttrContent.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
/>
111111

112112
<a-textarea
113-
v-else-if="attr.value_type === '2' && !attr.is_index"
113+
v-else-if="isLongText(attr)"
114114
size="small"
115115
v-decorator="[
116116
attr.name,
@@ -209,9 +209,11 @@
209209
import _ from 'lodash'
210210
import moment from 'moment'
211211
import { updateCI } from '@/modules/cmdb/api/ci'
212+
import { getAttrPassword } from '../../../api/CITypeAttr'
213+
import { isLongText } from '@/modules/cmdb/utils/helper'
214+
212215
import JsonEditor from '../../../components/JsonEditor/jsonEditor.vue'
213216
import PasswordField from '../../../components/passwordField/index.vue'
214-
import { getAttrPassword } from '../../../api/CITypeAttr'
215217
import CIReferenceAttr from '@/components/ciReferenceAttr/index.vue'
216218
217219
export default {
@@ -245,6 +247,7 @@ export default {
245247
},
246248
methods: {
247249
moment,
250+
isLongText,
248251
eventListener(e) {
249252
const datePickerContainer = document.getElementsByClassName('ant-calendar-picker-container')
250253
if (this.isEdit && !datePickerContainer.length) {

cmdb-ui/src/modules/cmdb/views/ci/modules/createInstanceFormByGroup.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
]"
4141
/>
4242
<a-textarea
43-
v-else-if="attr.value_type === '2' && !attr.is_index"
43+
v-else-if="isLongText(attr)"
4444
v-decorator="[
4545
attr.name,
4646
{
@@ -164,6 +164,8 @@
164164
<script>
165165
import _ from 'lodash'
166166
import moment from 'moment'
167+
import { isLongText } from '@/modules/cmdb/utils/helper'
168+
167169
import JsonEditor from '../../../components/JsonEditor/jsonEditor.vue'
168170
import CIReferenceAttr from '@/components/ciReferenceAttr/index.vue'
169171
@@ -196,6 +198,7 @@ export default {
196198
},
197199
methods: {
198200
moment,
201+
isLongText,
199202
handleFocusInput(e, attr) {
200203
console.log(attr)
201204
const _tempFind = this.attributeList.find((item) => item.name === attr.name)

0 commit comments

Comments
 (0)