mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-14 13:03:07 +00:00
perf: sub form perfermence
This commit is contained in:
parent
1e120f6b77
commit
d1b343dfd4
@ -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
|
||||||
|
setTimeout(() => {
|
||||||
this.$emit('input', val)
|
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;
|
||||||
|
@ -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) {
|
||||||
|
@ -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')
|
||||||
|
Loading…
Reference in New Issue
Block a user