perf: 优化表单

This commit is contained in:
ibuler 2024-03-15 10:45:02 +08:00
parent dc94ff58c3
commit 06cfed009a
7 changed files with 23 additions and 14 deletions

View File

@ -158,7 +158,7 @@ export default {
margin: 5px 0;
}
h3 {
margin-bottom: 5px;
margin-bottom: 10px;
}
}
}

View File

@ -27,7 +27,7 @@
:account="account"
:add-template="true"
:asset="iAsset"
:title="accountCreateUpdateTitle"
:title="accountCreateByTemplateTitle"
:visible.sync="showAddTemplateDialog"
@add="addAccountSuccess"
@bulk-create-done="showBulkCreateResult($event)"
@ -140,6 +140,7 @@ export default {
showAddTemplateDialog: false,
createAccountResults: [],
accountCreateUpdateTitle: this.$t('AddAccount'),
accountCreateByTemplateTitle: this.$t('AddAccountByTemplate'),
iAsset: this.asset,
account: {},
secretUrl: '',
@ -325,7 +326,6 @@ export default {
setTimeout(() => {
vm.iAsset = this.asset
vm.account = {}
vm.accountCreateUpdateTitle = this.$t('Create')
vm.showAddDialog = true
})
}
@ -342,7 +342,6 @@ export default {
setTimeout(() => {
vm.iAsset = this.asset
vm.account = {}
vm.accountCreateUpdateTitle = this.$t('Create')
vm.showAddTemplateDialog = true
})
}

View File

@ -13,9 +13,9 @@
<el-button :size="size" class="more-action" v-bind="cleanButtonAction(action)">
<span v-if="action.icon" class="pre-icon">
<i v-if="action.icon.startsWith('fa')" :class="'fa fa-fw ' + action.icon" />
<svg-icon v-else :icon-class="action.icon" style="" />
<svg-icon v-else :icon-class="action.icon" />
</span>
{{ toSentenceCase(action.title) }}<i class="el-icon-arrow-down el-icon--right" />
{{ action.title }}<i class="el-icon-arrow-down el-icon--right" />
</el-button>
<el-dropdown-menu slot="dropdown" style="overflow: auto;max-height: 60vh">
<template v-for="option in action.dropdown">
@ -35,9 +35,9 @@
>
<span v-if="option.icon" class="pre-icon">
<i v-if="option.icon.startsWith('fa')" :class="'fa fa-fw ' + option.icon" />
<svg-icon v-else :icon-class="option.icon" style="" />
<svg-icon v-else :icon-class="option.icon" />
</span>
{{ toSentenceCase(option.title) }}
{{ option.title }}
</el-dropdown-item>
</template>
</el-dropdown-menu>
@ -57,7 +57,7 @@
<i v-if="action.icon.startsWith('fa')" :class="'fa ' + action.icon" />
<svg-icon v-else :icon-class="action.icon" />
</span>
{{ toSentenceCase(action.title) }}
{{ action.title }}
</span>
</el-tooltip>
</el-button>
@ -154,7 +154,7 @@ export default {
if (!v) {
continue
}
const action = Object.assign({}, v)
const action = { ...v }
// action
const has = this.checkItem(action, 'has')
delete action['has']
@ -169,7 +169,6 @@ export default {
action.disabled = !can
if (action.dropdown) {
// const dropdown = this.cleanActions(action.dropdown)
action.dropdown = this.cleanActions(action.dropdown)
}
cleanedActions.push(action)

View File

@ -151,7 +151,7 @@ export default {
.el-cascader {
.el-input.el-input--suffix {
.el-input__inner {
height: calc(#{$innerHeight} - 1px);
height: calc(#{$headerHeight} - 1px);
}
}
}

View File

@ -430,14 +430,23 @@ export function toTitleCase(string) {
export function toSentenceCase(string) {
if (!string) return string
if (string.indexOf('/') > 0) return string
const s = string.trim().split(' ').map(item => {
const s = string.trim().split(' ').map((item, index) => {
if (item.length === 0) return ''
if (item.length === 1) return item.toLowerCase()
// 如果首字母大写,且第二个字母也大写,不处理
if (item[0] === item[0].toUpperCase() && item[1] === item[1].toUpperCase()) {
return item
}
return item.toLowerCase()
if (index === 0) {
return item[0].toUpperCase() + item.slice(1)
}
// 仅处理首字母大写,别的是小写的情况
if (item[0] !== item[0].toLowerCase() && item.slice(1) === item.slice(1).toLowerCase()) {
return item[0].toLowerCase() + item.slice(1)
}
return item
}).join(' ')
return s[0].toUpperCase() + s.slice(1)
}

View File

@ -38,6 +38,7 @@ export default {
},
columnsMeta: {
privileged: {
width: '120px',
formatterArgs: {
showText: false,
showFalse: false

View File

@ -142,6 +142,7 @@ export default {
this.headerActions.moreCreates.dropdown = this.$store.state.assets.assetCategoriesDropdown.filter(item => {
return item.category === this.tab.activeMenu
})
console.log('Category: ', this.headerActions.moreCreates.dropdown)
},
async setCategoriesTab() {
const categoryIcon = {