perf: 修改 auto form check box

This commit is contained in:
ibuler
2024-05-22 16:46:51 +08:00
parent fd9d08eb0c
commit 035597d330
4 changed files with 33 additions and 3 deletions

View File

@@ -173,7 +173,13 @@ export class FormFieldGenerator {
let helpTextAsPlaceholder = field.helpTextAsPlaceholder
const helpTextWordLength = helpText.split(' ').length
if ((helpTextWordLength <= 5 || helpText.length <= 10) && helpTextAsPlaceholder === undefined) {
const placeholderType = ['input', 'select', 'm2m_related_field']
const placeholderComponent = [ObjectSelect2]
if (helpTextAsPlaceholder !== undefined) {
helpTextAsPlaceholder = !!helpTextAsPlaceholder
} else if (placeholderType.indexOf(field.type) === -1 && placeholderComponent.indexOf(field.component) === -1) {
helpTextAsPlaceholder = false
} else if (helpTextWordLength <= 5 || helpText.length <= 10) {
helpTextAsPlaceholder = true
}
@@ -193,6 +199,16 @@ export class FormFieldGenerator {
if (field.placeholder) {
field.el.placeholder = field.placeholder
}
// 设置 checkbox 的 tips
if (field.tips && ['checkbox-group', 'radio-group'].indexOf(field.type) !== -1) {
field.options.map(option => {
if (!option.tip && field.tips[option.value]) {
option.tip = field.tips[option.value]
}
})
}
return field
}

View File

@@ -61,6 +61,9 @@
v-bind="opt"
>
{{ opt.label }}
<el-tooltip v-if="opt.tip" :content="opt.tip" :open-delay="500" placement="top">
<i class="fa fa-question-circle-o" />
</el-tooltip>
</el-checkbox>
<!-- WARNING: radio label 属性来表示 value 的含义 -->
<!-- FYI: radio value 属性可以在没有 radio-group 时用来关联到同一个 v-model -->
@@ -69,7 +72,11 @@
:key="opt.label"
:label="'value' in opt ? opt.value : opt.label"
v-bind="opt"
>{{ opt.label }}
>
{{ opt.label }}
<el-tooltip v-if="opt.tip" :content="opt.tip" :open-delay="500" placement="top">
<i class="fa fa-question-circle-o" />
</el-tooltip>
</el-radio>
</template>
</custom-component>

View File

@@ -82,6 +82,10 @@ export default {
}
}
>>> .el-table td, .el-table th {
padding: 5px 0;
}
>>> .el-table th, .el-table tr {
background-color: #F5F6F7!important;

View File

@@ -46,7 +46,10 @@ export default {
}
},
mfa_level: {
disabled: false
disabled: false,
tips: {
2: this.$t('If force enable, user can not disable by themselves')
}
},
email: {
rules: [