Skip to content

Commit b614808

Browse files
committed
feat(ui): change the long text editing control to a textarea #738
1 parent a5721c2 commit b614808

File tree

5 files changed

+63
-3
lines changed

5 files changed

+63
-3
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<span>{{ col.title }}</span>
5858
</span>
5959
</template>
60-
<template v-if="col.is_choice || col.is_password || col.is_bool || col.is_reference" #edit="{ row }">
60+
<template v-if="showCustomEditComponent(col)" #edit="{ row }">
6161
<CIReferenceAttr
6262
v-if="col.is_reference"
6363
:referenceTypeId="col.reference_type_id"
@@ -71,6 +71,17 @@
7171
v-model="row[col.field]"
7272
/>
7373
<vxe-input v-else-if="col.is_password" v-model="passwordValue[col.field]" />
74+
75+
<a-textarea
76+
v-else-if="col.value_type === '2' && !col.is_index"
77+
:value="col.is_list && Array.isArray(row[col.field]) ? row[col.field].join(',') : row[col.field]"
78+
:style="{ resize: 'none' }"
79+
:rows="1"
80+
@input="(e) => {
81+
row[col.field] = e.target.value
82+
}"
83+
/>
84+
7485
<a-select
7586
v-if="col.is_choice"
7687
v-model="row[col.field]"
@@ -527,7 +538,15 @@ export default {
527538
})
528539
529540
return option
530-
}
541+
},
542+
543+
showCustomEditComponent(col) {
544+
if (col.value_type === '2' && !col.is_index) {
545+
return true
546+
}
547+
548+
return col.is_choice || col.is_password || col.is_bool || col.is_reference
549+
},
531550
}
532551
}
533552
</script>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@
108108
}
109109
]"
110110
/>
111+
<a-textarea
112+
v-else-if="getFieldType(list.name) === 'textarea'"
113+
v-decorator="[list.name, { rules: getDecoratorRules(list) }]"
114+
@focus="(e) => handleFocusInput(e, list)"
115+
@blur="handleCascadeAttrByUpdate(list)"
116+
/>
111117
<a-select
112118
:style="{ width: '100%' }"
113119
v-decorator="[list.name, { rules: getDecoratorRules(list) }]"
@@ -459,6 +465,8 @@ export default {
459465
return 'input_number'
460466
} else if (_find.value_type === '4' || _find.value_type === '3') {
461467
return _find.value_type
468+
} else if (_find.value_type === '2' && !_find.is_index) {
469+
return 'textarea'
462470
} else {
463471
return 'input'
464472
}

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<span :id="`ci-detail-attr-${attr.name}`">
3-
<span v-if="!isEdit || attr.value_type === '6'">
3+
<span class="ci-detail-attr-preview" v-if="!isEdit || attr.value_type === '6'">
44
<template v-if="attr.is_reference" >
55
<a
66
v-for="(ciId) in (attr.is_list ? ci[attr.name] : [ci[attr.name]])"
@@ -108,6 +108,20 @@
108108
}
109109
]"
110110
/>
111+
112+
<a-textarea
113+
v-else-if="attr.value_type === '2' && !attr.is_index"
114+
size="small"
115+
v-decorator="[
116+
attr.name,
117+
{
118+
validateTrigger: ['submit'],
119+
rules: [{ required: attr.is_required }],
120+
},
121+
]"
122+
style="width: 100%"
123+
/>
124+
111125
<a-select
112126
:style="{ width: '200px' }"
113127
v-decorator="[
@@ -357,6 +371,10 @@ export default {
357371
</script>
358372
359373
<style lang="less" scoped>
374+
.ci-detail-attr-preview {
375+
white-space: pre-wrap;
376+
}
377+
360378
.ci-detail-attr-json {
361379
overflow: hidden;
362380
text-overflow: ellipsis;

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@
3939
}
4040
]"
4141
/>
42+
<a-textarea
43+
v-else-if="attr.value_type === '2' && !attr.is_index"
44+
v-decorator="[
45+
attr.name,
46+
{
47+
validateTrigger: ['submit'],
48+
rules: [{ required: attr.is_required, message: $t('placeholder1') + `${attr.alias || attr.name}` }],
49+
initialValue: attr.default && attr.default.default ? attr.default.default : null,
50+
},
51+
]"
52+
style="width: 100%"
53+
@focus="(e) => handleFocusInput(e, attr)"
54+
@blur="handleChange(attr)"
55+
/>
4256
<a-select
4357
:style="{ width: '100%' }"
4458
v-decorator="[

cmdb-ui/src/modules/cmdb/views/resource_search_2/resourceSearch/components/attrDisplay.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</template>
5353
<span
5454
v-else
55+
:style="{ whiteSpace: isEllipsis ? 'nowrap' : 'pre-wrap' }"
5556
v-html="markSearchValue((attr.is_list && Array.isArray(ci[attr.name])) ? ci[attr.name].join(',') : ci[attr.name])"
5657
></span>
5758
</div>

0 commit comments

Comments
 (0)