Skip to content

Commit

Permalink
relations getSyncInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
szuprefix committed May 31, 2020
1 parent 44ebe37 commit fafbc0e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-django",
"version": "0.7.11",
"version": "0.7.12",
"description": "个人实验项目, 本框架的目标是借鉴并超越django admin的自动化思想, 实现UI前端的极简快速定制开发",
"main": "index.js",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions src/components/generic/ContentType.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
loadIdMap () {
if (this.idMap === undefined && this.loading === false) {
this.loading = true
axios.get(`${this.model.getListUrl()}?page_size=1000`).then(({data}) => {
axios.get(`${this.model.getListUrl()}all/?page_size=1000`).then(({data}) => {
return data.results
}).then(ls => {
let idm = {}
Expand All @@ -39,4 +39,4 @@ export default {
})
}
}
}
}
15 changes: 14 additions & 1 deletion src/components/mobile/model/Relations.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<tab v-model="tab" :animate="false">
<tab-item :active-class="`active-${i%3+1}`" v-for="a, i in items" :key="a.name">{{a.label}}</tab-item>
<tab-item :active-class="`active-${i%3+1}`" :badge-label="a.badge" v-for="a, i in tabItems" :key="a.name">{{a.label}}</tab-item>
</tab>
<component :is="tabItems[tab].component" :owner="owner" v-bind="[tabItems[tab]]"
v-if="loaded"></component>
Expand All @@ -11,6 +11,9 @@
import {Tab, TabItem} from 'vux'
import arrayNormalize from 'vue-django/src/utils/array_normalize'
export default{
model: {
prop: 'current'
},
props: {
current: Number,
items: Array,
Expand All @@ -34,6 +37,12 @@
normalizeItems () {
this.tabItems = arrayNormalize(this.items, {}, (a, i) => {
a.component = a.component || `${a.name.replace('.', '/')}/components/List`
if (a.getAsyncInfo) {
a.getAsyncInfo().then(info => {
this.tabItems[i] = {...this.tabItems[i], ...info}
this.$emit('syncinfo', info)
})
}
return a
})
},
Expand All @@ -54,6 +63,10 @@
if (typeof this.tabItems[v].component === 'string') {
this.load(v)
}
this.$emit('input', v)
},
current (v) {
this.tab = v
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/model/Relations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
export default{
props: {
parent: Object,
items: Array,
items: Array
},
data () {
return {
Expand Down

0 comments on commit fafbc0e

Please sign in to comment.