perf: sub form perfermence

This commit is contained in:
ibuler 2024-07-03 10:03:14 +08:00 committed by 老广
parent 1e120f6b77
commit d1b343dfd4
3 changed files with 70 additions and 63 deletions

View File

@ -3,12 +3,13 @@
v-if="!loading" v-if="!loading"
:disabled="disabled" :disabled="disabled"
:fields="iFields" :fields="iFields"
:form="value" :form="iValue"
class="sub-form" class="sub-form"
v-bind="kwargs" v-bind="kwargs"
@change="updateValue($event)" @change="updateValue($event)"
@input="updateValue($event)" @input="updateValue($event)"
v-on="$listeners" v-on="$listeners"
@submit.native.prevent
/> />
</template> </template>
@ -42,6 +43,7 @@ export default {
return { return {
loading: false, loading: false,
formJson: JSON.stringify(this.value), formJson: JSON.stringify(this.value),
iValue: this.value,
kwargs: { kwargs: {
hasReset: false, hasReset: false,
hasSaveContinue: false, hasSaveContinue: false,
@ -71,15 +73,22 @@ export default {
} }
}, },
watch: { watch: {
iValue: {
handler(val) {
this.formJson = JSON.stringify(val)
},
deep: true
},
value: { value: {
handler(val) { handler(val) {
const valJson = JSON.stringify(val) const valJson = JSON.stringify(val)
// value // value
if (valJson !== this.formJson) { if (valJson !== this.formJson) {
this.iValue = val
this.loading = true this.loading = true
setTimeout(() => { setTimeout(() => {
this.loading = false this.loading = false
}, 10) }, 100)
} }
}, },
deep: true deep: true
@ -87,8 +96,10 @@ export default {
}, },
methods: { methods: {
updateValue(val) { updateValue(val) {
this.formJson = JSON.stringify(val) this.iValue = val
this.$emit('input', val) setTimeout(() => {
this.$emit('input', val)
}, 100)
}, },
objectToString(obj) { objectToString(obj) {
let data = '' let data = ''
@ -105,7 +116,7 @@ export default {
} }
</script> </script>
<style scoped lang="scss"> <style lang="scss" scoped>
.sub-form { .sub-form {
margin-left: -33%; margin-left: -33%;
margin-right: 10px; margin-right: 10px;

View File

@ -24,7 +24,7 @@
@change="handleChange" @change="handleChange"
@focus="focus = true" @focus="focus = true"
@select="handleSelect" @select="handleSelect"
@keyup.enter.native="handleConfirm" @keyup.enter.prevent.native="handleConfirm"
/> />
<span <span
v-if="replaceShowPassword && filterTags.length > 0" v-if="replaceShowPassword && filterTags.length > 0"
@ -89,7 +89,6 @@ export default {
iPlaceholder() { iPlaceholder() {
return `${this.placeholder} (${this.$t('EnterToContinue')})` return `${this.placeholder} (${this.$t('EnterToContinue')})`
} }
}, },
watch: { watch: {
value(val) { value(val) {
@ -107,7 +106,7 @@ export default {
}, },
handleChange: _.debounce(function(item) { handleChange: _.debounce(function(item) {
this.handleConfirm() this.handleConfirm()
}, 240), }, 200),
handleConfirm() { handleConfirm() {
if (this.filterValue === '') return if (this.filterValue === '') return
@ -116,22 +115,19 @@ export default {
this.filterValue = '' this.filterValue = ''
this.$emit('change', this.filterTags) this.$emit('change', this.filterTags)
} }
this.$refs.SearchInput.focus()
}, },
handleTagClick(v, k) { handleTagClick(v, k) {
if (this.filterValue.length !== 0) {
this.handleConfirm()
}
this.$delete(this.filterTags, k) this.$delete(this.filterTags, k)
this.filterValue = v this.filterValue = v
this.$refs.SearchInput.focus() this.$refs.SearchInput.focus()
}, },
matchRule(value) { matchRule(value) {
const regex = new RegExp(this.replaceRule) const regex = new RegExp(this.replaceRule)
const replacedValue = value.replace(regex, (match, p1, p2, p3) => { return value.replace(regex, (match, p1, p2, p3) => {
const stars = p2.replace(/./g, this.replaceContent) const stars = p2.replace(/./g, this.replaceContent)
return p1 + stars + p3 return p1 + stars + p3
}) })
return replacedValue
}, },
changeTagShowValue(value) { changeTagShowValue(value) {
if (this.replaceShowPassword && this.replaceRule) { if (this.replaceShowPassword && this.replaceRule) {
@ -147,60 +143,60 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.el-tag + .el-tag { .el-tag + .el-tag {
margin-left: 4px; margin-left: 4px;
}
.filter-field {
display: flex;
flex-wrap: wrap;
align-items: center;
padding: 1px 2px 1px;
border: 1px solid #dcdee2;
border-radius: 1px;
background-color: #fff;
line-height: 30px;
&:hover {
border-color: #C0C4CC;
} }
.filter-field { & ::v-deep .el-tag {
display: flex; margin-top: 1px;
flex-wrap: wrap; font-family: sans-serif !important;
align-items: center;
padding: 1px 2px 1px;
border: 1px solid #dcdee2;
border-radius: 1px;
background-color: #fff;
line-height: 30px;
&:hover {
border-color: #C0C4CC;
}
& ::v-deep .el-tag {
margin-top: 1px;
font-family: sans-serif !important;
}
& ::v-deep .el-autocomplete {
height: 28px;
}
} }
.search-input { & ::v-deep .el-autocomplete {
flex: 1;
& ::v-deep .el-input__inner {
max-width: 100%;
border: none;
padding-left: 10px;
}
}
.el-input ::v-deep .el-input__inner {
border: none !important;
font-size: 13px;
}
.filter-field ::v-deep .el-input__inner {
height: 28px; height: 28px;
} }
}
.show-password { .search-input {
display: inherit; flex: 1;
padding-right: 6px;
cursor: pointer;
&:hover { & ::v-deep .el-input__inner {
color: #999999; max-width: 100%;
} border: none;
padding-left: 10px;
} }
}
.el-input ::v-deep .el-input__inner {
border: none !important;
font-size: 13px;
}
.filter-field ::v-deep .el-input__inner {
height: 28px;
}
.show-password {
display: inherit;
padding-right: 6px;
cursor: pointer;
&:hover {
color: #999999;
}
}
</style> </style>

View File

@ -35,7 +35,7 @@ export default {
name: 'Basic' name: 'Basic'
}, },
{ {
title: this.$t('Terminal'), title: this.$t('Components'),
name: 'TerminalList', name: 'TerminalList',
hidden: () => !this.$hasPerm('terminal.view_terminal') hidden: () => !this.$hasPerm('terminal.view_terminal')
}, },
@ -47,14 +47,14 @@ export default {
} }
}, },
{ {
title: this.$t('Endpoint'), title: this.$t('Endpoints'),
name: 'EndpointList', name: 'EndpointList',
hidden: () => { hidden: () => {
return !this.$hasPerm('terminal.view_endpoint') return !this.$hasPerm('terminal.view_endpoint')
} }
}, },
{ {
title: this.$t('EndpointRule'), title: this.$t('EndpointRules'),
name: 'EndpointRuleList', name: 'EndpointRuleList',
hidden: () => { hidden: () => {
return !this.$hasPerm('terminal.view_endpointrule') return !this.$hasPerm('terminal.view_endpointrule')