2021-09-17 15:36:54 +08:00
|
|
|
import Dict from './Dict'
|
|
|
|
import { mergeOptions } from './DictOptions'
|
|
|
|
|
|
|
|
export default function(Vue, options) {
|
|
|
|
mergeOptions(options)
|
|
|
|
Vue.mixin({
|
|
|
|
data() {
|
2021-11-24 15:00:51 +08:00
|
|
|
if (this.$options === undefined || this.$options.dicts === undefined || this.$options.dicts === null) {
|
2021-09-17 15:36:54 +08:00
|
|
|
return {}
|
|
|
|
}
|
|
|
|
const dict = new Dict()
|
|
|
|
dict.owner = this
|
|
|
|
return {
|
|
|
|
dict
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
if (!(this.dict instanceof Dict)) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
options.onCreated && options.onCreated(this.dict)
|
|
|
|
this.dict.init(this.$options.dicts).then(() => {
|
|
|
|
options.onReady && options.onReady(this.dict)
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$emit('dictReady', this.dict)
|
|
|
|
if (this.$options.methods && this.$options.methods.onDictReady instanceof Function) {
|
|
|
|
this.$options.methods.onDictReady.call(this, this.dict)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|