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 Jul 24, 2020
2 parents d108bd0 + 1401413 commit d8d44a7
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 17 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.12",
"version": "0.7.14",
"description": "个人实验项目, 本框架的目标是借鉴并超越django admin的自动化思想, 实现UI前端的极简快速定制开发",
"main": "index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<el-menu class="el-menu-demo" mode="horizontal" router>
<el-menu-item index="/" class="brand">
<img :src="party.logo" height="32">
<b v-if="user.as_saas_worker">{{party.name}}</b>
<b>{{party.name}}</b>
{{system_name}}
</el-menu-item>
<el-submenu index="2" style="float:right">
Expand Down
8 changes: 6 additions & 2 deletions src/components/model/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<actions :items="_topActions"></actions>
</el-col>
</el-row>
<x-form :url="url" :items="formItems" v-model="formValue" ref="form" :options="options.form"
<x-form :url="url" :items="formItems" v-model="formValue" ref="form" :options="options.form" :disabled="disabled"
:successInfo="successInfo"
:method="method" @form-posted="onPosted" :submit="submit">
<span slot="submit" v-if="!options.inline"></span>
Expand Down Expand Up @@ -184,7 +184,8 @@
},
checkPermission(p, m){
m = m || this
return this.$store.state.user.model_permissions[m.appModel].includes(p)
let ps = this.$store.state.user.model_permissions[m.appModel]
return ps && ps.includes(p)
}
},
computed: {
Expand All @@ -197,6 +198,9 @@
_topActions(){
return arrayNormalize(this.topActions, this.avairableActions)
},
disabled () {
return !(this.checkPermission('update', this.model) || this.checkPermission('create', this.model))
}
},
watch: {
value(val){
Expand Down
18 changes: 11 additions & 7 deletions src/components/model/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
icon: 'plus',
title: '创建',
do: this.toCreateModel,
show: () => this.checkPermission('create')
show: () => this.parentMultipleRelationField && this.checkPermission('partial_update', this.parent) || this.checkPermission('create')
},
'add': {
icon: 'plus-square',
Expand All @@ -95,7 +95,7 @@
icon: 'pencil',
title: '编辑',
do: this.toEditModel,
show: () => this.checkPermission('update')
show: () => this.checkPermission('update') || this.checkPermission('partial_update')
},
'delete': {
icon: 'trash',
Expand All @@ -108,7 +108,7 @@
icon: 'trash',
title: '移除',
do: this.removeFromParent,
show: () => this.checkPermission('update', this.parent)
show: () => this.checkPermission('partial_update', this.parent)
},
'batch': {
icon: 'archive',
Expand Down Expand Up @@ -222,7 +222,7 @@
return ({selection, scope}) => {
let ids = selection.map((a) => a.id)
let qd = {...this._baseQueries, ...this.search}
return this.$http.post(`${this.model.getListUrl()}${action.api || action.name}/?${Qs.stringify(qd, {arrayFormat: 'comma'})}`, {batch_action_ids: ids, ...action.context, scope})
return this.$http.post(`${this.model.getListUrl()}${action.api || action.name}/?${Qs.stringify(qd, {arrayFormat: 'comma'})}`, {batch_action_ids: ids, ...action.context, scope}).catch(this.onServerResponseError)
}
},
addToParent ({selection}) {
Expand All @@ -238,7 +238,7 @@
rows: data[fn].length - oids.length
}
}
})
}).catch(this.onServerResponseError)
},
removeFromParent({row}) {
let fn = this.parentMultipleRelationField.name
Expand All @@ -247,7 +247,7 @@
return this.$http.patch(this.parent.getDetailUrl(), d).then(({data}) => {
this.parent.data[fn] = data[fn]
this.parentQueries = Object.assign({}, this.getParentQueries())
})
}).catch(this.onServerResponseError)
},
getConfig () {
let config = this.model.viewsConfig.list || {}
Expand Down Expand Up @@ -357,13 +357,17 @@
let avairableActions = {...this.avairableActions, ...bactions, ...ractions}
let topActions = ['refresh', 'create', ['download'].concat(Object.keys(bactions))]
let rowActions = ['edit'].concat(Object.keys(ractions)).concat([[this.parentMultipleRelationField ? 'removeFromParent' : 'delete']])
let title = this.model.config.verbose_name
if (this.parent) {
title = `${this.parent.title()}${title}`
}
return {
topActions,
rowActions,
// excelFormat: this.excelFormat,
permissionFunction: this.checkPermission,
dblClickAction: 'edit',
title: this.model.config.verbose_name,
title,
...this.$attrs,
baseQueries: this._baseQueries,
avairableActions,
Expand Down
16 changes: 11 additions & 5 deletions src/components/queue/Task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<el-button type="primary" size="small" @click="sumbit">开始</el-button>
</div>

<x-table v-model="queue" :items="items" :cellWidget="TableCell"></x-table>
<x-table v-model="queue" :items="items" :cellWidget="TableCell" row-key="keyField"></x-table>
</div>
</el-tab-pane>
<el-tab-pane :label="`${success.length}`">
<span slot="label"><i class="fa fa-check"></i> 成功记录<el-badge type="success" :value="success.length"
v-if="success.length>0"/></span>

<x-table v-model="success" :items="items"></x-table>
<x-table v-model="success" :items="items" row-key="keyField"></x-table>
</el-tab-pane>
<el-tab-pane :label="`${fail.length}`">
<span slot="label"><i class="fa fa-close"></i> 失败记录<el-badge :value="fail.length"
Expand All @@ -29,7 +29,7 @@
<div class="flex-right">
<el-button type="primary" size="small" @click="retry">再试一次</el-button>
</div>
<x-table v-model="fail" :items="items"></x-table>
<x-table v-model="fail" :items="items" row-key="keyField"></x-table>
</el-tab-pane>
</el-tabs>
</div>
Expand All @@ -43,7 +43,7 @@
props: {
items: Array,
concurrence: {type: Number, default: 1},
keyField: String,
keyField: {type: String, default: 'id'},
action: Function,
onSuccess: Function,
value: Array
Expand Down Expand Up @@ -73,7 +73,13 @@
this.fail.push(d)
}
}).then(() => {
this.queue = this.queue.filter(a => !(a[this.keyField] in this.ids))
for (var i in this.queue) {
if (this.queue[i][this.keyField] === id) {
this.queue.splice(i,1)
console.log('delete', id)
return
}
}
})
},
sumbit () {
Expand Down
3 changes: 2 additions & 1 deletion src/components/sheets/ExcelReader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
components: {},
methods: {
onChange(file, fileList) {
console.log(file)
// console.log(file)
},
readFile(req) {
this.$emit('start', req)
let file = req.file
import('xlsx').then(XLSX => {
Expand Down

0 comments on commit d8d44a7

Please sign in to comment.