功能变化: 优化dept-format

v2.x
李强 2023-03-18 23:30:14 +08:00
parent b54017889e
commit 4c75f010f8
1 changed files with 8 additions and 9 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
{{$store.state.d2admin.dept.data[currentValue] || ''}} {{currentValue}}
</div> </div>
</template> </template>
<script> <script>
@ -24,21 +24,20 @@ export default {
} }
}, },
watch: { watch: {
value (value) { value () {
// this.$emit('change', value) this.setValue()
if (this.currentValue === value) {
return
}
this.setValue(value)
} }
}, },
created () { created () {
this.setValue(this.value) this.setValue(this.value)
}, },
methods: { methods: {
setValue (value) { async setValue () {
// value // value
this.currentValue = String(this.value) if (!this.$store.state.d2admin.dept.data) {
await this.$store.dispatch('d2admin/dept/load')
}
this.currentValue = this.$store.state.d2admin.dept.data[String(this.value)]
// key // key
} }
} }