Skip to content

Commit

Permalink
Merge branch 'master' of github.com:szuprefix/vue-django
Browse files Browse the repository at this point in the history
  • Loading branch information
szuprefix committed Nov 23, 2020
2 parents ee1192b + 6886c23 commit fe9cd4a
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/components/async/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function (task, context) {
return
}
ps = rs.status.split(' ')
progress({status:sm[ps[0]] || ps[0], text: ps[1]})
progress({status:sm[ps[0]] || ps[0], text: rs.status.slice(ps[0].length)})
console.log(rs)
if (['SUCCESS', 'FAILURE'].includes(rs.status)) {
ws.close()
Expand Down
2 changes: 1 addition & 1 deletion src/components/mobile/model/Cells.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
groups () {
if (!this.groupBy) {
return [{cells: this.value}]
return [{cells: this.value, title: this.$attrs.title}]
} else {
let gs = []
let ps = this.groupBy.split(':')
Expand Down
1 change: 1 addition & 0 deletions src/components/mobile/model/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
this.loading = true
return this.model.query(qd, this.url).then(data => {
this.loading = false
this.$emit('loaded', data)
this.count = data.count
let ds = data.results
if (this.prepare) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/mobile/model/Panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
ls.push(d)
})
this.list = ls
// console.log(this.list)
console.log(this.list)
}
},
created () {
Expand Down
2 changes: 1 addition & 1 deletion src/components/model/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default function (appModel, defaults, eventor) {
return import(`@/views${this.getListUrl()}config.js`).then(m => {
return m.default || {}
}).catch((err) => {
console.warn(`找不到视图配置@/views${this.getListUrl()}config.js,将使用默认配置`)
console.warn(`找不到视图配置@/views${this.getListUrl()}config.js,将使用默认配置, err: ${err}`)
return {}
}).then(config => {
this.viewsConfig = config
Expand Down
2 changes: 1 addition & 1 deletion src/components/model/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<el-option :label="getBoolFieldFalseLabel(f.label)" :value="false"></el-option>
</el-select>
<model-select :field="f" v-model="form[f.name]" @input="onSearch"
:showCreate="false" :appModel="f.relateModel || f.model"
:showCreate="false" :appModel="f.relateModel || f.model" :showLink="false"
:title="f.label" :style="`width:${f.label.length+5}rem;min-width:8rem;`"
v-else-if="f.widget === 'modelselect'" :pageSize="100"></model-select>
<el-select v-model="form[f.name]" clearable :placeholder="`请选择${f.label}`"
Expand Down
47 changes: 41 additions & 6 deletions src/components/model/Select.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
<template>
<el-select v-model="selectedValue" :disabled="field.disabled" ref="select" class="model-select"
<el-select v-model="selectedValue" :disabled="field.disabled" ref="select" :class="`related-select ${field.name}`"
:multiple="field.multiple" filterable @change="changed" remote clearable reserve-keyword
:remote-method="onFilter" :class="`related-select ${field.name}`" default-first-option
:remote-method="onFilter" default-first-option
:loading="loading" :loading-text="`${loading}`"
:placeholder="field.placeholder || `请选择${field.label}`">
<el-option :label="c.__str__ || c.name || c.title" :value="c[idField] || c.pk || c.url || c.name"
v-for="c in optionList" :key="c[idField] || c.pk || c.url || c.name">
<span>{{c[selectOptionsFields[0]]}}</span>
<i v-if="showLink" class="fa fa-link" title="跳转到详情页" @click="$router.push(modelDetailPath)"></i>
<span class="label-right" v-if="selectOptionsFields[1]">{{c[selectOptionsFields[1]]}}</span>
</el-option>
<el-alert type="info" v-if="moreThanOnePage" show-icon title="记录太多未展示完全,请输入关键字进行搜索" :closable="false">
</el-alert>

<el-alert v-if="showCreate && canAdd" @click.native="toCreateModel" type="warning" center style="cursor: pointer"
<el-alert v-if="showCreate && canAdd" @click.native="toCreateModel" type="warning" center
style="cursor: pointer"
:closable="false">
<i class="fa fa-plus" style="margin-right: 1rem"></i>新增{{field.label}}
</el-alert>
<template #empty>
<el-alert v-if="showCreate && canAdd" @click.native="toCreateModel" type="warning" center style="cursor: pointer"
:closable="false">
<el-alert v-if="showCreate && canAdd" @click.native="toCreateModel" type="warning" center
style="cursor: pointer" :closable="false">
<i class="fa fa-plus" style="margin-right: 1rem"></i>新增{{field.label}}
</el-alert>
</template>
Expand All @@ -37,7 +39,8 @@
placeholder: String,
field: Object,
showCreate: {type: Boolean, default: true},
value: [String, Number, Array]
value: [String, Number, Array],
showLink: {type: Boolean, default: true}
},
data() {
return {
Expand All @@ -59,7 +62,23 @@
return this.load()
})
},
mounted () {
this.$store.state.bus.$on('model-posted', this.onModelPosted)
this.$store.state.bus.$on('model-deleted', this.onModelPosted)
},
beforeDestroy () {
this.$store.state.bus.$off('model-posted', this.onModelPosted)
this.$store.state.bus.$off('model-deleted', this.onModelPosted)
},
methods: {
onModelPosted ({appModel, id}) {
let dps = this.model.options.dependencies
if (appModel === this.appModel || dps && dps.includes(appModel)) {
this.load()
}
},
loadValueObjects(v){
if (['number', 'string'].includes(typeof v)) {
v = [v]
Expand Down Expand Up @@ -125,6 +144,9 @@
},
idField() {
return this.field.idField || 'id'
},
modelDetailPath () {
return this.model.getDetailUrl(this.selectedValue)
}
},
watch: {
Expand All @@ -143,4 +165,17 @@
color: #8492a6;
font-size: 0.8rem;
}
.el-select-dropdown__item .fa-link {
display: none;
}
.el-select-dropdown__item.selected .fa-link {
display: inline-block;
margin-top: 0.5rem;
margin-left: 0.5rem;
cursor: pointer;
color: gray;
float: right;
}
</style>
20 changes: 10 additions & 10 deletions src/components/table/Table.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template>
<el-table :data="_value" ref="table" v-loading="loading"
<el-table :data="tableData" ref="table" v-loading="loading"
:element-loading-text="loading" v-on="elListeners" v-bind="elAttrs">
<slot name="left"></slot>
<column :field="f" v-for="f in visiableItems" :key="f.name"></column>
<el-table-column label="" align="right" fixed="right" min-width="140"
v-if="rowActions && rowActions.length>0 || topActions && topActions.length>0">
<template slot="header" slot-scope="scope" v-if="topActions">
<actions :items="_topActions" :context="scope" :permissionFunction="$attrs.permissionFunction"
<actions :items="topActionItems" :context="scope" :permissionFunction="$attrs.permissionFunction"
:map="avairableActions"></actions>
</template>
<template slot-scope="scope" v-if="rowActions">
<actions :items="_rowActions" :context="scope" :class="{'hover-show': hoverShow}" trigger="hover"
<actions :items="rowActionItems" :context="scope" :class="{'hover-show': hoverShow}" trigger="hover"
:map="avairableActions"></actions>
</template>
</el-table-column>
Expand Down Expand Up @@ -168,22 +168,22 @@
}
},
computed: {
_topActions () {
topActionItems () {
return this.normalizeActions(this.topActions)
},
_rowActions () {
rowActionItems () {
return this.normalizeActions(this.rowActions)
},
_items(){
tableItems(){
return arrayNormalize(this.items, {}, (i) => {
return this.normalizeItem(i)
})
},
visiableItems () {
return this._items.filter(a => a.hidden !== true)
return this.tableItems.filter(a => a.hidden !== true)
},
fields () {
return flatten(this._items, 'subColumns')
return flatten(this.tableItems, 'subColumns')
},
fieldNames () {
return this.fields.map(a => a.name)
Expand All @@ -198,14 +198,14 @@
})
return rs
},
_value(){
tableData(){
if (this.group > 0) {
return sortBy(this.value, this.fieldNames)
}
return this.value
},
spanMap () {
return genSpanMap(this._value, this.fieldNames, this.group)
return genSpanMap(this.tableData, this.fieldNames, this.group)
},
elListeners () {
Expand Down
24 changes: 24 additions & 0 deletions src/components/table/widgets/Avatar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<el-avatar :src="`${theProxy}${value[field.name]}`" v-if="value[field.name]"></el-avatar>
</template>
<script>
export default{
props: {
value: String,
field: Object,
context: Object,
proxy: {type:String, default: ''}
},
data () {
return {}
},
components: {},
methods: {},
computed: {
theProxy () {
return this.proxy || this.field.proxy || ''
}
}
}
</script>

2 changes: 1 addition & 1 deletion src/components/widgets/ForeignKey.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<a :href="`#/${field.model.replace('.','/')}/${value[field.name]}`" title="点击跳转" class="foreignkey-link" v-if="hasLink">
<a :href="`#/${field.model.replace('.','/')}/${value[field.name]}/`" title="点击跳转" class="foreignkey-link" v-if="hasLink">
{{theValue}}
</a>
<span v-else>
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/party.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ const party = {
getPartyInfo ({commit, rootState}){
return Vue.http.get("/saas/party/current/").then(({data}) => {
commit("setParty", data)
rootState.bus.$emit('party-ready', data)
return data
})
}
}
}

export default party
export default party
8 changes: 6 additions & 2 deletions src/utils/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ export function formatTime(time, option) {
}

/* 数字 格式化 */
export function nFormatter (num, digits) {
const si = [
export function nFormatter (num, digits, inChinese) {
const si = inChinese ? [
{value: 1E12, symbol: '兆'},
{value: 1E8, symbol: '亿'},
{value: 1E4, symbol: '万'}
] : [
{value: 1E18, symbol: 'E'},
{value: 1E15, symbol: 'P'},
{value: 1E12, symbol: 'T'},
Expand Down

0 comments on commit fe9cd4a

Please sign in to comment.