From be7ec8a803940582b93c4b10ea735c8395a6de59 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 25 Sep 2020 14:46:01 +0800 Subject: [PATCH] part sort --- client/src/views/ability/cma2.vue | 25 +++++++++++++------ client/src/views/system/organization.vue | 25 ++++++------------- client/src/views/system/perm.vue | 19 +++----------- client/src/views/system/role.vue | 15 ++--------- client/src/views/system/user.vue | 19 +++----------- .../migrations/0005_organization_sort.py | 18 +++++++++++++ server/apps/system/models.py | 2 +- server/apps/system/views.py | 8 +++--- 8 files changed, 56 insertions(+), 75 deletions(-) create mode 100644 server/apps/system/migrations/0005_organization_sort.py diff --git a/client/src/views/ability/cma2.vue b/client/src/views/ability/cma2.vue index 930445e..529aa47 100644 --- a/client/src/views/ability/cma2.vue +++ b/client/src/views/ability/cma2.vue @@ -73,28 +73,37 @@ @filter-change="filterChange" > - + - + - + - + - + - + - + - + + + + + + + + + diff --git a/client/src/views/system/organization.vue b/client/src/views/system/organization.vue index ccbb524..ffd03ef 100644 --- a/client/src/views/system/organization.vue +++ b/client/src/views/system/organization.vue @@ -62,6 +62,9 @@ + + +
取消 @@ -81,7 +84,8 @@ import '@riophae/vue-treeselect/dist/vue-treeselect.css' const defaultOrg = { id: null, name: '', - pid: null + pid: null, + sort:1 } export default { components: { Treeselect }, @@ -155,10 +159,7 @@ export default { .then(async() => { await deleteOrg(scope.row.id) this.getList() - this.$message({ - type: 'success', - message: '成功删除!' - }) + this.$message.success('成功') }) .catch(err => { console.error(err) @@ -172,12 +173,7 @@ export default { updateOrg(this.org.id, this.org).then(() => { this.getList() this.dialogVisible = false - this.$notify({ - title: '成功', - message: '编辑成功', - type: 'success', - duration: 2000 - }) + this.$message.success('成功') }) } else { createOrg(this.org).then(res => { @@ -185,12 +181,7 @@ export default { // this.tableData.unshift(this.org) this.getList() this.dialogVisible = false - this.$notify({ - title: '成功', - message: '新增成功', - type: 'success', - duration: 2000 - }) + this.$message.success('成功') }) } } else { diff --git a/client/src/views/system/perm.vue b/client/src/views/system/perm.vue index ce17537..450c1aa 100644 --- a/client/src/views/system/perm.vue +++ b/client/src/views/system/perm.vue @@ -167,10 +167,7 @@ export default { .then(async() => { await deletePerm(scope.row.id) this.getList() - this.$message({ - type: 'success', - message: '成功删除!' - }) + this.$message.success('成功') }) .catch(err => { console.error(err) @@ -184,12 +181,7 @@ export default { updatePerm(this.perm.id, this.perm).then(() => { this.getList() this.dialogVisible = false - this.$notify({ - title: '成功', - message: '编辑成功', - type: 'success', - duration: 2000 - }) + this.$message.success('成功') }) } else { createPerm(this.perm).then(res => { @@ -197,12 +189,7 @@ export default { // this.tableData.unshift(this.perm) this.getList() this.dialogVisible = false - this.$notify({ - title: '成功', - message: '新增成功', - type: 'success', - duration: 2000 - }) + this.$message.success('成功') }) } } else { diff --git a/client/src/views/system/role.vue b/client/src/views/system/role.vue index 016bf24..edc23fe 100644 --- a/client/src/views/system/role.vue +++ b/client/src/views/system/role.vue @@ -218,10 +218,7 @@ export default { .then(async() => { await deleteRole(row.id) this.tableData.splice($index, 1) - this.$message({ - type: 'success', - message: '成功删除!' - }) + this.$message.success('成功') }) .catch(err => { console.error(err) @@ -254,15 +251,7 @@ export default { const { desc, name } = this.role this.dialogVisible = false - this.$notify({ - title: '成功', - dangerouslyUseHTMLString: true, - message: ` -
角色名: ${name}
-
角色描述: ${desc}
- `, - type: 'success' - }) + this.$message.success('成功') } } } diff --git a/client/src/views/system/user.vue b/client/src/views/system/user.vue index c690684..dbbdc44 100644 --- a/client/src/views/system/user.vue +++ b/client/src/views/system/user.vue @@ -329,10 +329,7 @@ export default { .then(async () => { await deleteUser(scope.row.id); this.userList.splice(scope.row.index, 1); - this.$message({ - type: "success", - message: "成功删除!" - }); + this.$message.success('成功') }) .catch(err => { console.error(err); @@ -347,12 +344,7 @@ export default { if (res.code >= 200) { this.getList(); this.dialogVisible = false; - this.$notify({ - title: "成功", - message: "编辑成功", - type: "success", - duration: 2000 - }); + this.$message.success('成功') } }); } else { @@ -360,12 +352,7 @@ export default { if (res.code >= 200) { this.getList(); this.dialogVisible = false; - this.$notify({ - title: "成功", - message: "新增成功", - type: "success", - duration: 2000 - }); + this.$message.success('成功') } }); } diff --git a/server/apps/system/migrations/0005_organization_sort.py b/server/apps/system/migrations/0005_organization_sort.py new file mode 100644 index 0000000..c8d37f5 --- /dev/null +++ b/server/apps/system/migrations/0005_organization_sort.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-09-25 06:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('system', '0004_message'), + ] + + operations = [ + migrations.AddField( + model_name='organization', + name='sort', + field=models.IntegerField(default=1, verbose_name='排序'), + ), + ] diff --git a/server/apps/system/models.py b/server/apps/system/models.py index accc014..8f7ab35 100644 --- a/server/apps/system/models.py +++ b/server/apps/system/models.py @@ -64,7 +64,7 @@ class Organization(SoftModel): choices=organization_type_choices, default='部门') pid = models.ForeignKey('self', null=True, blank=True, on_delete=models.SET_NULL, verbose_name='父') - + sort = models.IntegerField('排序', default=1) class Meta: verbose_name = '组织架构' verbose_name_plural = verbose_name diff --git a/server/apps/system/views.py b/server/apps/system/views.py index 0be077b..8b33a33 100644 --- a/server/apps/system/views.py +++ b/server/apps/system/views.py @@ -166,7 +166,7 @@ class PermissionViewSet(ModelViewSet): pagination_class = None search_fields = ['name'] ordering_fields = ['sort'] - ordering = 'id' + ordering = 'sort' class OrganizationViewSet(ModelViewSet): @@ -178,9 +178,9 @@ class OrganizationViewSet(ModelViewSet): queryset = Organization.objects.all() serializer_class = OrganizationSerializer pagination_class = None - search_fields = ['^name', '^method'] - ordering_fields = ['id'] - ordering = 'id' + search_fields = ['name'] + ordering_fields = ['sort'] + ordering = ['sort', 'pk'] class RoleViewSet(ModelViewSet):