From b03037b8669e50bf4acdf262e83388cad538a12f Mon Sep 17 00:00:00 2001 From: victory Date: Wed, 22 Mar 2023 22:39:08 +0800 Subject: [PATCH 01/43] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=E5=92=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=99=BD=E5=90=8D=E5=8D=95=E7=9A=84=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/role/curd.tsx | 52 ++++++++++--------------- web/src/views/system/user/crud.tsx | 23 ----------- web/src/views/system/whiteList/crud.tsx | 23 +++++++++-- 3 files changed, 40 insertions(+), 58 deletions(-) diff --git a/web/src/views/system/role/curd.tsx b/web/src/views/system/role/curd.tsx index 330b5f726..2655d6557 100644 --- a/web/src/views/system/role/curd.tsx +++ b/web/src/views/system/role/curd.tsx @@ -78,18 +78,6 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp }, }, }, - search: { - title: '关键词', - column: {show: false}, - type: 'text', - search: {show: true}, - form: { - show: false, - component: { - placeholder: '输入关键词搜索', - }, - }, - }, id: { title: 'ID', type: 'text', @@ -103,7 +91,7 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp search: {show: true}, column: { minWidth: 120, - sortable: true, + sortable: "custom", }, form: { rules: [{required: true, message: '角色名称必填'}], @@ -118,7 +106,7 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp search: {show: false}, column: { width: 120, - sortable: true, + sortable: "custom", }, form: { rules: [{required: true, message: '权限标识必填'}], @@ -131,9 +119,10 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp type: 'number', column: { width: 90, - sortable: true, + sortable: "custom", }, form: { + rules: [{required: true, message: '排序必填'}], value: 1, }, }, @@ -157,9 +146,10 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp }), column: { width: 130, - sortable: true, + sortable: "custom", }, form: { + rules: [{required: true, message: '是否管理员必填'}], value: false, }, }, @@ -183,9 +173,10 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp }), column: { width: 90, - sortable: true, + sortable: "custom", }, form: { + rules: [{required: true, message: '状态必填'}], value: true, }, }, @@ -195,7 +186,7 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp search: {show: false}, column: { width: 170, - sortable: true, + sortable: "custom", }, form: { show: false, @@ -209,7 +200,7 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp type: 'text', search: {show: false}, column: { - sortable: true, + sortable: "custom", width: 170, }, form: { @@ -219,18 +210,17 @@ export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExp }, }, }, - - description: { - title: '备注', - type: 'textarea', - search: {show: false}, - form: { - component: { - maxlength: 200, - placeholder: '输入备注', - }, - }, - }, + // description: { + // title: '备注', + // type: 'textarea', + // search: {show: false}, + // form: { + // component: { + // maxlength: 200, + // placeholder: '输入备注', + // }, + // }, + // }, }, }, }; diff --git a/web/src/views/system/user/crud.tsx b/web/src/views/system/user/crud.tsx index c5aac2979..3b7cd32cf 100644 --- a/web/src/views/system/user/crud.tsx +++ b/web/src/views/system/user/crud.tsx @@ -54,29 +54,6 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp columnSetDisabled: true, //禁止在列设置中选择 }, }, - search: { - title: '关键词', - column: { - show: false - }, - search: { - show: true, - component: { - props: { - clearable: true - }, - placeholder: '请输入关键词' - } - }, - form: { - show: false, - component: { - props: { - clearable: true - } - } - }, - }, username: { title: '账号', search: { diff --git a/web/src/views/system/whiteList/crud.tsx b/web/src/views/system/whiteList/crud.tsx index decf73bbe..a9d0545a6 100644 --- a/web/src/views/system/whiteList/crud.tsx +++ b/web/src/views/system/whiteList/crud.tsx @@ -28,6 +28,14 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp editRequest, delRequest, }, + form: { + col: {span: 24}, + labelWidth: '110px', + wrapper: { + is: 'el-dialog', + width: '600px', + }, + }, columns: { _index: { title: '序号', @@ -70,7 +78,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }, method: { title: '请求方式', - sortable: true, + sortable: "custom", search: { disabled: false, }, @@ -93,6 +101,10 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp label: 'DELETE', value: 3, }, + { + label: 'PATCH', + value: 4, + } ], }), form: { @@ -113,7 +125,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }, url: { title: '接口地址', - sortable: true, + sortable: "custom", search: { disabled: true, }, @@ -155,9 +167,11 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp class: { yxtInput: true }, }, helper: { - render(h) { - return ; + position: "label", + tooltip: { + placement: "top-start" }, + text: "请正确填写,以免请求时被拦截。匹配单例使用正则,例如:/api/xx/.*?/" }, }, }, @@ -173,6 +187,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }), form: { value: true, + rules: [{ required: true, message: '必填项' }], component: { span: 12, }, -- Gitee From af5f3b71371d947860a365cb076dc8e7508e93dc Mon Sep 17 00:00:00 2001 From: victory Date: Wed, 22 Mar 2023 22:39:19 +0800 Subject: [PATCH 02/43] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E5=AF=B9url?= =?UTF-8?q?=E4=B8=AD=E6=8E=92=E5=BA=8F=E5=8F=82=E6=95=B0=E7=9A=84=E8=A7=A3?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/settings.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/src/settings.ts b/web/src/settings.ts index cbe2219c5..9cd264cf3 100644 --- a/web/src/settings.ts +++ b/web/src/settings.ts @@ -28,6 +28,9 @@ export default { //你项目后台接口大概率与fast-crud所需要的返回结构不一致,所以需要配置此项 //请参考文档http://fast-crud.docmirror.cn/api/crud-options/request.html transformQuery: ({ page, form, sort }: any) => { + if (sort.asc !== undefined){ + form["ordering"] = `${sort.asc ? "" : "-"}${sort.prop}` + } //转换为你pageRequest所需要的请求参数结构 return { page: page.currentPage, limit: page.pageSize, ...form }; }, -- Gitee From 581e4cd92f41ac9614f0a189dd67db193aeee91b Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Thu, 23 Mar 2023 21:10:07 +0800 Subject: [PATCH 03/43] =?UTF-8?q?feat:=20=F0=9F=94=A7=20tailwind=20css=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/tailwind.config.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 32e3abdef..8d5245a95 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -1,8 +1,8 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: [], - theme: { - extend: {}, - }, - plugins: [], -} + content: ['./index.html', './src/**/*.{vue,js}'], + theme: { + extend: {}, + }, + plugins: [], +}; -- Gitee From b6b3b4a39ad113b704892f501b9fe75fd28ce7ad Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Fri, 24 Mar 2023 15:17:43 +0800 Subject: [PATCH 04/43] =?UTF-8?q?feat:=20=F0=9F=9A=80=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?nginx=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker_env/nginx/my.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_env/nginx/my.conf b/docker_env/nginx/my.conf index 30fa2108d..94fe805e7 100644 --- a/docker_env/nginx/my.conf +++ b/docker_env/nginx/my.conf @@ -28,6 +28,6 @@ server { proxy_send_timeout 600s; real_ip_header X-Forwarded-For; rewrite ^/api/(.*)$ /$1 break; #重写 - proxy_pass http://177.8.0.12:8000/; # 设置代理服务器的协议和地址 + proxy_pass http://178.10.0.12:8000/; # 设置代理服务器的协议和地址 } } -- Gitee From ab1d1c87e2131e311fc5f01421e979835721d551 Mon Sep 17 00:00:00 2001 From: raymond Date: Fri, 24 Mar 2023 16:41:22 +0800 Subject: [PATCH 05/43] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E9=80=9A?= =?UTF-8?q?=E8=BF=87python=20manage.py=20createsuperuser=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/dvadmin/system/models.py | 47 ++++++++++++++++++---------- backend/dvadmin/system/views/user.py | 5 +++ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/backend/dvadmin/system/models.py b/backend/dvadmin/system/models.py index a33814fdd..4376afbc9 100644 --- a/backend/dvadmin/system/models.py +++ b/backend/dvadmin/system/models.py @@ -1,9 +1,9 @@ import hashlib import os -from django.contrib.auth.models import AbstractUser +from django.contrib.auth.models import AbstractUser, UserManager from django.db import models - +from django.core.exceptions import ObjectDoesNotExist, ValidationError from application import dispatch from dvadmin.utils.models import CoreModel, table_prefix @@ -13,6 +13,34 @@ STATUS_CHOICES = ( ) +class Role(CoreModel): + name = models.CharField(max_length=64, verbose_name="角色名称", help_text="角色名称") + key = models.CharField(max_length=64, unique=True, verbose_name="权限字符", help_text="权限字符") + sort = models.IntegerField(default=1, verbose_name="角色顺序", help_text="角色顺序") + status = models.BooleanField(default=True, verbose_name="角色状态", help_text="角色状态") + admin = models.BooleanField(default=False, verbose_name="是否为admin", help_text="是否为admin") + + class Meta: + db_table = table_prefix + "system_role" + verbose_name = "角色表" + verbose_name_plural = verbose_name + ordering = ("sort",) + + +class CustomUserManager(UserManager): + + def create_superuser(self, username, email=None, password=None, **extra_fields): + user = super(CustomUserManager, self).create_superuser(username, email, password, **extra_fields) + user.set_password(password) + try: + user.role.add(Role.objects.get(name="管理员")) + user.save(using=self._db) + return user + except ObjectDoesNotExist: + user.delete() + raise ValidationError("角色`管理员`不存在, 创建失败, 请先执行python manage.py init") + + class Users(CoreModel, AbstractUser): username = models.CharField(max_length=150, unique=True, db_index=True, verbose_name="用户账号", help_text="用户账号") @@ -48,6 +76,7 @@ class Users(CoreModel, AbstractUser): blank=True, help_text="关联部门", ) + objects = CustomUserManager() def set_password(self, raw_password): super().set_password(hashlib.md5(raw_password.encode(encoding="UTF-8")).hexdigest()) @@ -76,20 +105,6 @@ class Post(CoreModel): ordering = ("sort",) -class Role(CoreModel): - name = models.CharField(max_length=64, verbose_name="角色名称", help_text="角色名称") - key = models.CharField(max_length=64, unique=True, verbose_name="权限字符", help_text="权限字符") - sort = models.IntegerField(default=1, verbose_name="角色顺序", help_text="角色顺序") - status = models.BooleanField(default=True, verbose_name="角色状态", help_text="角色状态") - admin = models.BooleanField(default=False, verbose_name="是否为admin", help_text="是否为admin") - - class Meta: - db_table = table_prefix + "system_role" - verbose_name = "角色表" - verbose_name_plural = verbose_name - ordering = ("sort",) - - class Dept(CoreModel): name = models.CharField(max_length=64, verbose_name="部门名称", help_text="部门名称") key = models.CharField(max_length=64, unique=True, null=True, blank=True, verbose_name="关联字符", diff --git a/backend/dvadmin/system/views/user.py b/backend/dvadmin/system/views/user.py index 4355f34f9..01fae1b02 100644 --- a/backend/dvadmin/system/views/user.py +++ b/backend/dvadmin/system/views/user.py @@ -293,6 +293,11 @@ class UserViewSet(CustomModelViewSet): 'dept_id': dept.id, 'dept_name': dept.name } + else: + result['dept_info'] = { + 'dept_id': None, + 'dept_name': "暂无部门" + } role = getattr(user, 'role', None) if role: result['role_info'] = role.values('id', 'name', 'key') -- Gitee From df74c792f6cb9cf54d649f12e88fd8de04017d1b Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Fri, 24 Mar 2023 18:45:58 +0800 Subject: [PATCH 06/43] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/user/crud.tsx | 586 ++++++++++++++-------------- web/src/views/system/user/index.vue | 83 +++- 2 files changed, 377 insertions(+), 292 deletions(-) diff --git a/web/src/views/system/user/crud.tsx b/web/src/views/system/user/crud.tsx index 3b7cd32cf..a563180e9 100644 --- a/web/src/views/system/user/crud.tsx +++ b/web/src/views/system/user/crud.tsx @@ -1,297 +1,305 @@ -import * as api from "./api"; -import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, } from "@fast-crud/fast-crud"; -import { request } from "/@/utils/service"; -import { dictionary } from "/@/utils/dictionary"; +import * as api from './api'; +import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud'; +import { request } from '/@/utils/service'; +import { dictionary } from '/@/utils/dictionary'; interface CreateCrudOptionsTypes { - crudOptions: CrudOptions; + crudOptions: CrudOptions; } export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExpose }): CreateCrudOptionsTypes { - const pageRequest = async (query: PageQuery) => { - return await api.GetList(query); - }; - const editRequest = async ({ form, row }: EditReq) => { - form.id = row.id; - return await api.UpdateObj(form); - }; - const delRequest = async ({ row }: DelReq) => { - return await api.DelObj(row.id); - }; - const addRequest = async ({ form }: AddReq) => { - return await api.AddObj(form); - }; - return { - crudOptions: { - request: { - pageRequest, - addRequest, - editRequest, - delRequest - }, - rowHandle: { - //固定右侧 - fixed: "right", - width: 310, - buttons: { - orderExample: { - show:false, - text: "重置密码", - click: () => { - //console.log("reset password") - } - } - }, - - }, - columns: { - _index: { - title: '序号', - form: { show: false }, - column: { - type: 'index', - align: 'center', - width: '70px', - columnSetDisabled: true, //禁止在列设置中选择 - }, - }, - username: { - title: '账号', - search: { - show: true, - }, - minWidth: 100, - type: 'input', - form: { - rules: [ // 表单校验规则 - { - required: true, - message: '账号必填项' - } - ], - component: { - placeholder: '请输入账号' - }, - } - }, - password: { - title: '密码', - type: 'input', - column: { - show: false - }, - editForm: { - show: false - }, - form: { - rules: [ // 表单校验规则 - { - required: true, - message: '密码必填项' - } - ], - component: { - span: 12, - showPassword: true, - placeholder: '请输入密码' - }, - // value: vm.systemConfig('base.default_password'), - }, - /* valueResolve(row, key) { + const pageRequest = async (query: PageQuery) => { + return await api.GetList(query); + }; + const editRequest = async ({ form, row }: EditReq) => { + form.id = row.id; + return await api.UpdateObj(form); + }; + const delRequest = async ({ row }: DelReq) => { + return await api.DelObj(row.id); + }; + const addRequest = async ({ form }: AddReq) => { + return await api.AddObj(form); + }; + return { + crudOptions: { + request: { + pageRequest, + addRequest, + editRequest, + delRequest, + }, + rowHandle: { + //固定右侧 + fixed: 'right', + width: 300, + buttons: { + view: { + show: false, + }, + edit: { + iconRight: 'Edit', + type: 'text', + }, + remove: { + iconRight: 'Delete', + type: 'text', + }, + }, + }, + columns: { + _index: { + title: '序号', + form: { show: false }, + column: { + type: 'index', + align: 'center', + width: '70px', + columnSetDisabled: true, //禁止在列设置中选择 + }, + }, + username: { + title: '账号', + search: { + show: true, + }, + minWidth: 100, + type: 'input', + form: { + rules: [ + // 表单校验规则 + { + required: true, + message: '账号必填项', + }, + ], + component: { + placeholder: '请输入账号', + }, + }, + }, + password: { + title: '密码', + type: 'input', + column: { + show: false, + }, + editForm: { + show: false, + }, + form: { + rules: [ + // 表单校验规则 + { + required: true, + message: '密码必填项', + }, + ], + component: { + span: 12, + showPassword: true, + placeholder: '请输入密码', + }, + // value: vm.systemConfig('base.default_password'), + }, + /* valueResolve(row, key) { if (row.password) { row.password = vm.$md5(row.password) } } */ - }, - name: { - title: '姓名', - search: { - show: true, - }, - type: 'input', - form: { - rules: [ // 表单校验规则 - { - required: true, - message: '姓名必填项' - } - ], - component: { - span: 12, - placeholder: '请输入姓名' - }, - } - }, - dept: { - title: '部门', - search: { - disabled: true - }, - type: 'dict-tree', - dict: dict({ - isTree: true, - url: '/api/system/dept/all_dept/', - value: 'id', - label: 'name', - getData: async ({ url }: { url: string }) => { - return request({ - url: url, - }).then((ret: any) => { - return ret.data - }) - } - }), - form: { - rules: [ // 表单校验规则 - { - required: true, - message: '必填项' - } - ], - component: { - filterable: true, - placeholder: '请选择', - props: { - props: { - value: "id", - label: "name", - } - } - }, - }, - }, - role: { - title: '角色', - search: { - disabled: true - }, - type: 'dict-select', - dict: dict({ - url: '/api/system/role/', - value: 'id', - label: 'name', - isTree: true, - getData: async ({ url }: { url: string }) => { - return request({ - url: url, - params: { - page: 1, - limit: 10 - } - }).then((ret: any) => { - return ret.data - }) - } - }), - form: { - rules: [ // 表单校验规则 - { - required: true, - message: '必填项' - } - ], - component: { - multiple: true, - filterable: true, - placeholder: '请选择角色' - }, - } - }, - mobile: { - title: '手机号码', - search: { - show: true, - }, - type: 'input', - form: { - rules: [ - { - max: 20, - message: '请输入正确的手机号码', - trigger: 'blur' - }, - { - pattern: /^1[3-9]\d{9}$/, - message: '请输入正确的手机号码' - } - ], - component: { - placeholder: '请输入手机号码' - } - } - }, - email: { - title: '邮箱', - column:{ - width:260 - }, - form: { - rules: [ - { - type: 'email', - message: '请输入正确的邮箱地址', - trigger: ['blur', 'change'] - } - ], - component: { - placeholder: '请输入邮箱' - } - } - }, - gender: { - title: '性别', - type: 'dict-radio', - dict: dict({ - data: dictionary('gender') - }), - form: { - value: 1, - component: { - span: 12 - } - }, - component: { props: { color: 'auto' } } // 自动染色 - }, - user_type: { - title: '用户类型', - search: { - show: true, - }, - type: 'dict-select', - dict: dict({ - data: dictionary('user_type') - }), - form: { - show: false, - value: 0, - component: { - span: 12 - } - } - }, - is_active: { - title: '状态', - search: { - show: true, - }, - type: 'dict-radio', - dict: dict({ - data: dictionary('button_status_bool') - }), - form: { - value: true, - component: { - span: 12 - } - } - }, - avatar: { - title: '头像', - type: 'avatar-cropper', - form:{ - show:false - } - } - } - } - }; -} + }, + name: { + title: '姓名', + search: { + show: true, + }, + type: 'input', + form: { + rules: [ + // 表单校验规则 + { + required: true, + message: '姓名必填项', + }, + ], + component: { + span: 12, + placeholder: '请输入姓名', + }, + }, + }, + dept: { + title: '部门', + search: { + disabled: true, + }, + type: 'dict-tree', + dict: dict({ + isTree: true, + url: '/api/system/dept/all_dept/', + value: 'id', + label: 'name', + getData: async ({ url }: { url: string }) => { + return request({ + url: url, + }).then((ret: any) => { + return ret.data; + }); + }, + }), + form: { + rules: [ + // 表单校验规则 + { + required: true, + message: '必填项', + }, + ], + component: { + filterable: true, + placeholder: '请选择', + props: { + props: { + value: 'id', + label: 'name', + }, + }, + }, + }, + }, + role: { + title: '角色', + search: { + disabled: true, + }, + type: 'dict-select', + dict: dict({ + url: '/api/system/role/', + value: 'id', + label: 'name', + isTree: true, + getData: async ({ url }: { url: string }) => { + return request({ + url: url, + params: { + page: 1, + limit: 10, + }, + }).then((ret: any) => { + return ret.data; + }); + }, + }), + form: { + rules: [ + // 表单校验规则 + { + required: true, + message: '必填项', + }, + ], + component: { + multiple: true, + filterable: true, + placeholder: '请选择角色', + }, + }, + }, + mobile: { + title: '手机号码', + search: { + show: true, + }, + type: 'input', + form: { + rules: [ + { + max: 20, + message: '请输入正确的手机号码', + trigger: 'blur', + }, + { + pattern: /^1[3-9]\d{9}$/, + message: '请输入正确的手机号码', + }, + ], + component: { + placeholder: '请输入手机号码', + }, + }, + }, + email: { + title: '邮箱', + column: { + width: 260, + }, + form: { + rules: [ + { + type: 'email', + message: '请输入正确的邮箱地址', + trigger: ['blur', 'change'], + }, + ], + component: { + placeholder: '请输入邮箱', + }, + }, + }, + gender: { + title: '性别', + type: 'dict-radio', + dict: dict({ + data: dictionary('gender'), + }), + form: { + value: 1, + component: { + span: 12, + }, + }, + component: { props: { color: 'auto' } }, // 自动染色 + }, + user_type: { + title: '用户类型', + search: { + show: true, + }, + type: 'dict-select', + dict: dict({ + data: dictionary('user_type'), + }), + form: { + show: false, + value: 0, + component: { + span: 12, + }, + }, + }, + is_active: { + title: '状态', + search: { + show: true, + }, + type: 'dict-radio', + dict: dict({ + data: dictionary('button_status_bool'), + }), + form: { + value: true, + component: { + span: 12, + }, + }, + }, + avatar: { + title: '头像', + type: 'avatar-cropper', + form: { + show: false, + }, + }, + }, + }, + }; +}; diff --git a/web/src/views/system/user/index.vue b/web/src/views/system/user/index.vue index 1fa86341b..dd2126516 100644 --- a/web/src/views/system/user/index.vue +++ b/web/src/views/system/user/index.vue @@ -1,13 +1,32 @@ + + -- Gitee From 7c78c7e53fda6a3a0c2ae5415b7d40e493c3d2b3 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Tue, 28 Mar 2023 20:09:49 +0800 Subject: [PATCH 07/43] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86=E9=87=8D=E6=9E=84=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/dvadmin/system/views/menu.py | 27 ++- web/src/views/system/menu/api.ts | 17 +- web/src/views/system/menu/crud.tsx | 35 +-- web/src/views/system/menu/index.vue | 309 +++++++++++++++++++++++++-- 4 files changed, 345 insertions(+), 43 deletions(-) diff --git a/backend/dvadmin/system/views/menu.py b/backend/dvadmin/system/views/menu.py index ae74af894..3566dde78 100644 --- a/backend/dvadmin/system/views/menu.py +++ b/backend/dvadmin/system/views/menu.py @@ -53,9 +53,6 @@ class MenuCreateSerializer(CustomModelSerializer): read_only_fields = ["id"] - - - class WebRouterSerializer(CustomModelSerializer): """ 前端菜单路由的简单序列化器 @@ -63,11 +60,11 @@ class WebRouterSerializer(CustomModelSerializer): path = serializers.CharField(source="web_path") title = serializers.CharField(source="name") - class Meta: model = Menu - fields = ('id', 'parent', 'icon', 'sort', 'path', 'name', 'title', 'is_link', 'is_catalog', 'web_path', 'component', - 'component_name', 'cache', 'visible') + fields = ( + 'id', 'parent', 'icon', 'sort', 'path', 'name', 'title', 'is_link', 'is_catalog', 'web_path', 'component', + 'component_name', 'cache', 'visible', 'status') read_only_fields = ["id"] @@ -86,6 +83,7 @@ class MenuViewSet(CustomModelViewSet): update_serializer_class = MenuCreateSerializer search_fields = ['name', 'status'] filter_fields = ['parent', 'name', 'status', 'is_link', 'visible', 'cache', 'is_catalog'] + # extra_filter_class = [] @action(methods=['GET'], detail=False, permission_classes=[]) @@ -101,12 +99,25 @@ class MenuViewSet(CustomModelViewSet): data = serializer.data return SuccessResponse(data=data, total=len(data), msg="获取成功") - def list(self,request): + @action(methods=['GET'], detail=False, permission_classes=[]) + def get_all_menu(self, request): + """用于菜单管理获取所有的菜单""" + user = request.user + queryset = self.queryset.all() + if not user.is_superuser: + role_list = user.role.values_list('id', flat=True) + menu_list = RoleMenuPermission.objects.filter(role__in=role_list).values_list('menu_id') + queryset = Menu.objects.filter(id__in=menu_list) + serializer = WebRouterSerializer(queryset, many=True, request=request) + data = serializer.data + return SuccessResponse(data=data, total=len(data), msg="获取成功") + + def list(self, request): """懒加载""" request.query_params._mutable = True params = request.query_params parent = params.get('parent', None) - page = params.get('page',None) + page = params.get('page', None) limit = params.get('limit', None) if page: del params['page'] diff --git a/web/src/views/system/menu/api.ts b/web/src/views/system/menu/api.ts index 1df5890aa..8dbaf69a5 100644 --- a/web/src/views/system/menu/api.ts +++ b/web/src/views/system/menu/api.ts @@ -6,12 +6,20 @@ export function GetList(query: PageQuery) { return request({ url: apiPrefix, method: 'get', - params: query + params: query, }); } +export function GetAllMenu(query: PageQuery) { + return request({ + url: apiPrefix + 'get_all_menu/', + method: 'get', + params: query, + }); +} + export function GetObj(id: InfoReq) { return request({ - url: apiPrefix + id+'/', + url: apiPrefix + id + '/', method: 'get', }); } @@ -32,10 +40,9 @@ export function UpdateObj(obj: EditReq) { }); } -export function DelObj(id: DelReq) { +export function DelObj(obj: DelReq) { return request({ - url: apiPrefix + id + '/', + url: apiPrefix + obj.id + '/', method: 'delete', - data: { id }, }); } diff --git a/web/src/views/system/menu/crud.tsx b/web/src/views/system/menu/crud.tsx index 9727a3d31..659698de3 100644 --- a/web/src/views/system/menu/crud.tsx +++ b/web/src/views/system/menu/crud.tsx @@ -3,7 +3,7 @@ import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } fro import { dictionary } from '/@/utils/dictionary'; import { eIconPicker, eIcon } from 'e-icon-picker'; import { useCompute } from '@fast-crud/fast-crud'; -import { inject,computed } from 'vue'; +import { inject, computed } from 'vue'; import { apiPrefix as menuPrefix } from './api'; import XEUtils from 'xe-utils'; import { request } from '/@/utils/service'; @@ -81,9 +81,20 @@ export const createCrudOptions = function ({ crudExpose, menuButtonRef }: { crud }, }, rowHandle: { - fixed: "right", - width: 310, + fixed: 'right', + width: 200, buttons: { + view: { + show: false, + }, + edit: { + iconRight: 'Edit', + type: 'text', + }, + remove: { + iconRight: 'Delete', + type: 'text', + }, custom: { text: '按钮配置', type: 'warning', @@ -104,15 +115,15 @@ export const createCrudOptions = function ({ crudExpose, menuButtonRef }: { crud menuButtonRef.value.initGet(); }, }, - addChildren:{ - text: "添加子级", - type:"warning", - click(context){ - const rowId =context.row.id - crudExpose.openAdd({ row: { parent: rowId } }) - } - } - } + addChildren: { + text: '添加子级', + type: 'text', + click(context) { + const rowId = context.row.id; + crudExpose.openAdd({ row: { parent: rowId } }); + }, + }, + }, }, columns: { _index: { diff --git a/web/src/views/system/menu/index.vue b/web/src/views/system/menu/index.vue index 1680ba097..88769b5be 100644 --- a/web/src/views/system/menu/index.vue +++ b/web/src/views/system/menu/index.vue @@ -1,30 +1,303 @@ + + -- Gitee From 1407a25b6a805d88e7e09197402e71af80f19c14 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Tue, 28 Mar 2023 20:35:35 +0800 Subject: [PATCH 08/43] =?UTF-8?q?feat:=20=E2=9C=A8=20=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=9B=9E=E8=BD=A6=E7=99=BB=E5=BD=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/login/component/account.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web/src/views/system/login/component/account.vue b/web/src/views/system/login/component/account.vue index 88a539da6..165e4e8ff 100644 --- a/web/src/views/system/login/component/account.vue +++ b/web/src/views/system/login/component/account.vue @@ -58,7 +58,7 @@ diff --git a/web/src/views/system/menu/index.vue b/web/src/views/system/menu/index.vue index 88769b5be..10e45959d 100644 --- a/web/src/views/system/menu/index.vue +++ b/web/src/views/system/menu/index.vue @@ -16,11 +16,19 @@ :data="data" :props="treeProps" :filter-node-method="filterNode" + :load="loadNode" + :allow-drag="allowDrag" + :allow-drop="allowDrop" + @node-drop="nodeDrop" + lazy + icon="ArrowRightBold" + :indent="12" + draggable @node-click="handleNodeClick" > @@ -28,6 +36,7 @@ + 菜单配置 @@ -36,7 +45,7 @@ - + @@ -71,16 +80,13 @@ - - + + 全选 - - - - - - + + + 其他权限 @@ -102,16 +108,15 @@ + + + diff --git a/web/src/views/system/dictionary/crud.tsx b/web/src/views/system/dictionary/crud.tsx index e994f0638..646073816 100644 --- a/web/src/views/system/dictionary/crud.tsx +++ b/web/src/views/system/dictionary/crud.tsx @@ -1,7 +1,7 @@ import * as api from './api'; import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud'; import { dictionary } from '/@/utils/dictionary'; -import {nextTick, ref} from 'vue'; +import { nextTick, ref } from 'vue'; interface CreateCrudOptionsTypes { crudOptions: CrudOptions; @@ -30,25 +30,34 @@ export const createCrudOptions = function ({ crudExpose, subDictRef }: { crudExp delRequest, }, rowHandle: { - width: 360, + width: 200, buttons: { + view: { + show: false, + }, + edit: { + iconRight: 'Edit', + type: 'text', + }, + remove: { + iconRight: 'Delete', + type: 'text', + }, custom: { text: '字典配置', - type: 'success', + type: 'text', tooltip: { placement: 'top', content: '字典配置', }, //@ts-ignore click: (context: any) => { - const {row} = context + const { row } = context; subDictRef.value.drawer = true; - nextTick(()=>{ + nextTick(() => { subDictRef.value.setSearchFormData({ form: { parent: row.id } }); subDictRef.value.doRefresh(); - }) - - + }); }, }, }, diff --git a/web/src/views/system/dictionary/subDict/crud.tsx b/web/src/views/system/dictionary/subDict/crud.tsx index 27828abad..7626d896a 100644 --- a/web/src/views/system/dictionary/subDict/crud.tsx +++ b/web/src/views/system/dictionary/subDict/crud.tsx @@ -2,7 +2,7 @@ import * as api from './api'; import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud'; import { request } from '/@/utils/service'; import { dictionary } from '/@/utils/dictionary'; -import {watch} from "vue"; +import { watch } from 'vue'; interface CreateCrudOptionsTypes { crudOptions: CrudOptions; } @@ -30,6 +30,24 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp editRequest, delRequest, }, + rowHandle: { + //固定右侧 + fixed: 'right', + width: 200, + buttons: { + view: { + show: false, + }, + edit: { + iconRight: 'Edit', + type: 'text', + }, + remove: { + iconRight: 'Delete', + type: 'text', + }, + }, + }, columns: { _index: { title: '序号', diff --git a/web/src/views/system/fileList/crud.tsx b/web/src/views/system/fileList/crud.tsx index e0d9d65cd..60ef81b8f 100644 --- a/web/src/views/system/fileList/crud.tsx +++ b/web/src/views/system/fileList/crud.tsx @@ -35,6 +35,24 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp editRequest, delRequest, }, + rowHandle: { + //固定右侧 + fixed: 'right', + width: 200, + buttons: { + view: { + show: false, + }, + edit: { + iconRight: 'Edit', + type: 'text', + }, + remove: { + iconRight: 'Delete', + type: 'text', + }, + }, + }, columns: { _index: { title: '序号', diff --git a/web/src/views/system/log/loginLog/crud.tsx b/web/src/views/system/log/loginLog/crud.tsx index 259243b00..5e1190393 100644 --- a/web/src/views/system/log/loginLog/crud.tsx +++ b/web/src/views/system/log/loginLog/crud.tsx @@ -36,7 +36,11 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }, }, rowHandle: { + width: 100, buttons: { + view: { + type: 'text', + }, edit: { show: false, }, diff --git a/web/src/views/system/log/operationLog/crud.tsx b/web/src/views/system/log/operationLog/crud.tsx index 53c127666..11daf677f 100644 --- a/web/src/views/system/log/operationLog/crud.tsx +++ b/web/src/views/system/log/operationLog/crud.tsx @@ -36,7 +36,11 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }, }, rowHandle: { + width: 100, buttons: { + view: { + type: 'text', + }, edit: { show: false, }, diff --git a/web/src/views/system/role/curd.tsx b/web/src/views/system/role/curd.tsx index 2655d6557..c7562ee93 100644 --- a/web/src/views/system/role/curd.tsx +++ b/web/src/views/system/role/curd.tsx @@ -1,227 +1,237 @@ -import {CrudOptions, AddReq, DelReq, EditReq, dict, CrudExpose} from '@fast-crud/fast-crud'; +import { CrudOptions, AddReq, DelReq, EditReq, dict, CrudExpose } from '@fast-crud/fast-crud'; import _ from 'lodash-es'; -import * as api from "./api"; +import * as api from './api'; interface CreateCrudOptionsTypes { - crudOptions: CrudOptions; + crudOptions: CrudOptions; } //此处为crudOptions配置 -export const createCrudOptions = function ({crudExpose,rolePermission}: {crudExpose: CrudExpose,rolePermission:any}): CreateCrudOptionsTypes { +export const createCrudOptions = function ({ crudExpose, rolePermission }: { crudExpose: CrudExpose; rolePermission: any }): CreateCrudOptionsTypes { + const pageRequest = async (query: any) => { + return await api.GetList(query); + }; + const editRequest = async ({ form, row }: EditReq) => { + form.id = row.id; + return await api.UpdateObj(form); + }; + const delRequest = async ({ row }: DelReq) => { + return await api.DelObj(row.id); + }; + const addRequest = async ({ form }: AddReq) => { + return await api.AddObj(form); + }; - const pageRequest = async (query: any) => { - return await api.GetList(query); - }; - const editRequest = async ({ form, row }: EditReq) => { - form.id = row.id; - return await api.UpdateObj(form); - }; - const delRequest = async ({ row }: DelReq) => { - return await api.DelObj(row.id); - }; - const addRequest = async ({ form }: AddReq) => { - return await api.AddObj(form); - }; - - return { - crudOptions: { - request: { - pageRequest, - addRequest, - editRequest, - delRequest, - }, - rowHandle: { - //固定右侧 - fixed: "right", - width:310, - buttons: { - custom: { - text: "权限配置", - type:'warning', - tooltip: { - placement: "top", - content: "删除" - }, - click: (context:any):void => { - const {row} = context - // eslint-disable-next-line no-mixed-spaces-and-tabs - rolePermission.value.drawer=true - rolePermission.value.editedRoleInfo = row - rolePermission.value.initGet() - } - } - }, - }, - form: { - col: {span: 24}, - labelWidth: '100px', - wrapper: { - is: 'el-dialog', - width: '600px', - }, - }, - columns: { - _index: { - title: '序号', - form: {show: false}, - column: { - //type: 'index', - align: 'center', - width: '70px', - columnSetDisabled: true, //禁止在列设置中选择 - formatter: (context) => { - //计算序号,你可以自定义计算规则,此处为翻页累加 - let index = context.index ?? 1; - let pagination = crudExpose.crudBinding.value.pagination; - // @ts-ignore - return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1; - }, - }, - }, - id: { - title: 'ID', - type: 'text', - column: {show: false}, - search: {show: false}, - form: {show: false}, - }, - name: { - title: '角色名称', - type: 'text', - search: {show: true}, - column: { - minWidth: 120, - sortable: "custom", - }, - form: { - rules: [{required: true, message: '角色名称必填'}], - component: { - placeholder: '输入角色名称搜索', - }, - }, - }, - key: { - title: '权限标识', - type: 'text', - search: {show: false}, - column: { - width: 120, - sortable: "custom", - }, - form: { - rules: [{required: true, message: '权限标识必填'}], - placeholder: '输入权限标识', - }, - }, - sort: { - title: '排序', - search: {show: false}, - type: 'number', - column: { - width: 90, - sortable: "custom", - }, - form: { - rules: [{required: true, message: '排序必填'}], - value: 1, - }, - }, - admin: { - title: '是否管理员', - search: {show: false}, - type: 'dict-radio', - dict: dict({ - data: [ - { - label: '是', - value: true, - color: 'success', - }, - { - label: '否', - value: false, - color: 'danger', - }, - ], - }), - column: { - width: 130, - sortable: "custom", - }, - form: { - rules: [{required: true, message: '是否管理员必填'}], - value: false, - }, - }, - status: { - title: '状态', - search: {show: true}, - type: 'dict-radio', - dict: dict({ - data: [ - { - label: '启用', - value: true, - color: 'success', - }, - { - label: '禁用', - value: false, - color: 'danger', - }, - ], - }), - column: { - width: 90, - sortable: "custom", - }, - form: { - rules: [{required: true, message: '状态必填'}], - value: true, - }, - }, - update_datetime: { - title: '更新时间', - type: 'text', - search: {show: false}, - column: { - width: 170, - sortable: "custom", - }, - form: { - show: false, - component: { - placeholder: '输入关键词搜索', - }, - }, - }, - create_datetime: { - title: '创建时间', - type: 'text', - search: {show: false}, - column: { - sortable: "custom", - width: 170, - }, - form: { - show: false, - component: { - placeholder: '输入关键词搜索', - }, - }, - }, - // description: { - // title: '备注', - // type: 'textarea', - // search: {show: false}, - // form: { - // component: { - // maxlength: 200, - // placeholder: '输入备注', - // }, - // }, - // }, - }, - }, - }; + return { + crudOptions: { + request: { + pageRequest, + addRequest, + editRequest, + delRequest, + }, + rowHandle: { + //固定右侧 + fixed: 'right', + width: 200, + buttons: { + view: { + show: false, + }, + edit: { + iconRight: 'Edit', + type: 'text', + }, + remove: { + iconRight: 'Delete', + type: 'text', + }, + custom: { + text: '权限配置', + type: 'text', + tooltip: { + placement: 'top', + content: '删除', + }, + click: (context: any): void => { + const { row } = context; + // eslint-disable-next-line no-mixed-spaces-and-tabs + rolePermission.value.drawer = true; + rolePermission.value.editedRoleInfo = row; + rolePermission.value.initGet(); + }, + }, + }, + }, + form: { + col: { span: 24 }, + labelWidth: '100px', + wrapper: { + is: 'el-dialog', + width: '600px', + }, + }, + columns: { + _index: { + title: '序号', + form: { show: false }, + column: { + //type: 'index', + align: 'center', + width: '70px', + columnSetDisabled: true, //禁止在列设置中选择 + formatter: (context) => { + //计算序号,你可以自定义计算规则,此处为翻页累加 + let index = context.index ?? 1; + let pagination = crudExpose.crudBinding.value.pagination; + // @ts-ignore + return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1; + }, + }, + }, + id: { + title: 'ID', + type: 'text', + column: { show: false }, + search: { show: false }, + form: { show: false }, + }, + name: { + title: '角色名称', + type: 'text', + search: { show: true }, + column: { + minWidth: 120, + sortable: 'custom', + }, + form: { + rules: [{ required: true, message: '角色名称必填' }], + component: { + placeholder: '输入角色名称搜索', + }, + }, + }, + key: { + title: '权限标识', + type: 'text', + search: { show: false }, + column: { + width: 120, + sortable: 'custom', + }, + form: { + rules: [{ required: true, message: '权限标识必填' }], + placeholder: '输入权限标识', + }, + }, + sort: { + title: '排序', + search: { show: false }, + type: 'number', + column: { + width: 90, + sortable: 'custom', + }, + form: { + rules: [{ required: true, message: '排序必填' }], + value: 1, + }, + }, + admin: { + title: '是否管理员', + search: { show: false }, + type: 'dict-radio', + dict: dict({ + data: [ + { + label: '是', + value: true, + color: 'success', + }, + { + label: '否', + value: false, + color: 'danger', + }, + ], + }), + column: { + width: 130, + sortable: 'custom', + }, + form: { + rules: [{ required: true, message: '是否管理员必填' }], + value: false, + }, + }, + status: { + title: '状态', + search: { show: true }, + type: 'dict-radio', + dict: dict({ + data: [ + { + label: '启用', + value: true, + color: 'success', + }, + { + label: '禁用', + value: false, + color: 'danger', + }, + ], + }), + column: { + width: 90, + sortable: 'custom', + }, + form: { + rules: [{ required: true, message: '状态必填' }], + value: true, + }, + }, + update_datetime: { + title: '更新时间', + type: 'text', + search: { show: false }, + column: { + width: 170, + sortable: 'custom', + }, + form: { + show: false, + component: { + placeholder: '输入关键词搜索', + }, + }, + }, + create_datetime: { + title: '创建时间', + type: 'text', + search: { show: false }, + column: { + sortable: 'custom', + width: 170, + }, + form: { + show: false, + component: { + placeholder: '输入关键词搜索', + }, + }, + }, + // description: { + // title: '备注', + // type: 'textarea', + // search: {show: false}, + // form: { + // component: { + // maxlength: 200, + // placeholder: '输入备注', + // }, + // }, + // }, + }, + }, + }; }; diff --git a/web/src/views/system/user/crud.tsx b/web/src/views/system/user/crud.tsx index 06c32c3f8..84180e933 100644 --- a/web/src/views/system/user/crud.tsx +++ b/web/src/views/system/user/crud.tsx @@ -31,7 +31,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp rowHandle: { //固定右侧 fixed: 'right', - width: 200, + width: 140, buttons: { view: { show: false, diff --git a/web/src/views/system/user/index.vue b/web/src/views/system/user/index.vue index 841763d1c..7d130b649 100644 --- a/web/src/views/system/user/index.vue +++ b/web/src/views/system/user/index.vue @@ -3,14 +3,33 @@ +

+ 用户列表 + + + +

- - + + +
- + - +
@@ -18,38 +37,44 @@ -- Gitee From b96c220f1d3763ee004d5a30933bad61c6ef126f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Sun, 9 Apr 2023 23:08:30 +0800 Subject: [PATCH 18/43] =?UTF-8?q?refactor(=E7=99=BB=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2):=20=E2=99=BB=EF=B8=8F=20=E7=99=BB=E5=BD=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/i18n/pages/login/en.ts | 4 ++-- web/src/i18n/pages/login/zh-cn.ts | 4 ++-- web/src/i18n/pages/login/zh-tw.ts | 4 ++-- web/src/utils/service.ts | 12 ++++++++++-- web/src/utils/websocket.ts | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/web/src/i18n/pages/login/en.ts b/web/src/i18n/pages/login/en.ts index 2654a188c..28c6983ba 100644 --- a/web/src/i18n/pages/login/en.ts +++ b/web/src/i18n/pages/login/en.ts @@ -9,8 +9,8 @@ export default { two4: 'Links', }, account: { - accountPlaceholder1: 'The user name admin or not is common', - accountPlaceholder2: 'Password: 123456', + accountPlaceholder1: 'Please enter your login account', + accountPlaceholder2: 'Please enter your login password', accountPlaceholder3: 'Please enter the verification code', accountBtnText: 'Sign in', }, diff --git a/web/src/i18n/pages/login/zh-cn.ts b/web/src/i18n/pages/login/zh-cn.ts index 3367b539f..61f994d2d 100644 --- a/web/src/i18n/pages/login/zh-cn.ts +++ b/web/src/i18n/pages/login/zh-cn.ts @@ -9,8 +9,8 @@ export default { two4: '友情链接', }, account: { - accountPlaceholder1: '用户名 admin 或不输均为 common', - accountPlaceholder2: '密码:123456', + accountPlaceholder1: '请输入登录账号', + accountPlaceholder2: '请输入登录密码', accountPlaceholder3: '请输入验证码', accountBtnText: '登 录', }, diff --git a/web/src/i18n/pages/login/zh-tw.ts b/web/src/i18n/pages/login/zh-tw.ts index 138e8c826..13ad01336 100644 --- a/web/src/i18n/pages/login/zh-tw.ts +++ b/web/src/i18n/pages/login/zh-tw.ts @@ -9,8 +9,8 @@ export default { two4: '友情連結', }, account: { - accountPlaceholder1: '用戶名admin或不輸均為common', - accountPlaceholder2: '密碼:123456', + accountPlaceholder1: '請輸入登入賬號', + accountPlaceholder2: '請輸入登入密碼', accountPlaceholder3: '請輸入驗證碼', accountBtnText: '登入', }, diff --git a/web/src/utils/service.ts b/web/src/utils/service.ts index 87988983e..2385c4825 100644 --- a/web/src/utils/service.ts +++ b/web/src/utils/service.ts @@ -70,7 +70,7 @@ function createService() { case 401: Local.clear(); Session.clear(); - dataAxios.msg = '登录授权过期,请重新登录'; + dataAxios.msg = '登录认证失败,请重新登录'; ElMessageBox.alert(dataAxios.msg, '提示', { confirmButtonText: 'OK', callback: (action: Action) => { @@ -100,7 +100,15 @@ function createService() { error.message = '请求错误'; break; case 401: - error.message = '未授权,请登录'; + Local.clear(); + Session.clear(); + error.message = '登录授权过期,请重新登录'; + ElMessageBox.alert(error.message, '提示', { + confirmButtonText: 'OK', + callback: (action: Action) => { + window.location.reload(); + }, + }) break; case 403: error.message = '拒绝访问'; diff --git a/web/src/utils/websocket.ts b/web/src/utils/websocket.ts index 72fe41091..987273e88 100644 --- a/web/src/utils/websocket.ts +++ b/web/src/utils/websocket.ts @@ -30,7 +30,7 @@ const websocket: socket = { } const token = Session.get('token') if(!token){ - message.warning('websocket认证失败') + // message.warning('websocket认证失败') return null } const wsUrl = `${getWsBaseURL()}ws/${token}/` -- Gitee From 160c376f81e27084c039a558727ded5be76d27b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Sun, 9 Apr 2023 23:09:35 +0800 Subject: [PATCH 19/43] =?UTF-8?q?fix(=E7=99=BB=E5=BD=95):=20=20=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/dvadmin/utils/exception.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/dvadmin/utils/exception.py b/backend/dvadmin/utils/exception.py index 849844174..d1dbedc4d 100644 --- a/backend/dvadmin/utils/exception.py +++ b/backend/dvadmin/utils/exception.py @@ -38,12 +38,16 @@ def CustomExceptionHandler(ex, context): # 调用默认的异常处理函数 response = exception_handler(ex, context) if isinstance(ex, AuthenticationFailed): - code = 401 - code_type = response.data.get('detail').code - if code_type == 'no_active_account': - code=400 + # 如果是身份验证错误 + if response and response.data.get('detail') == "Given token not valid for any token type": + code = 401 + msg = ex.detail + elif response and response.data.get('detail') == "Token is blacklisted": + # token在黑名单 return ErrorResponse(status=HTTP_401_UNAUTHORIZED) - msg = ex.detail + else: + code = 401 + msg = ex.detail elif isinstance(ex,Http404): code = 400 msg = "接口地址不正确" -- Gitee From 61066b8caad62acd7173acb2dabf582e01e616da Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Mon, 10 Apr 2023 00:03:17 +0800 Subject: [PATCH 20/43] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86=E5=89=8D?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menuButton/{curd.tsx => crud.tsx} | 24 +++--- .../menu/components/menuButton/index.vue | 79 +++---------------- web/src/views/system/menu/index.vue | 17 ++-- web/tailwind.config.js | 6 +- 4 files changed, 38 insertions(+), 88 deletions(-) rename web/src/views/system/menu/components/menuButton/{curd.tsx => crud.tsx} (90%) diff --git a/web/src/views/system/menu/components/menuButton/curd.tsx b/web/src/views/system/menu/components/menuButton/crud.tsx similarity index 90% rename from web/src/views/system/menu/components/menuButton/curd.tsx rename to web/src/views/system/menu/components/menuButton/crud.tsx index 7e42c5d9e..50c79df5a 100644 --- a/web/src/views/system/menu/components/menuButton/curd.tsx +++ b/web/src/views/system/menu/components/menuButton/crud.tsx @@ -1,17 +1,23 @@ -import { CrudOptions, AddReq, DelReq, EditReq, dict, CrudExpose } from '@fast-crud/fast-crud'; +import { + CrudOptions, + AddReq, + DelReq, + EditReq, + dict, + CrudExpose, + CreateCrudOptionsRet, + CreateCrudOptionsProps, + UserPageQuery, +} from '@fast-crud/fast-crud'; import _ from 'lodash-es'; import * as api from './api'; -import { dictionary } from '/@/utils/dictionary'; - -interface CreateCrudOptionsTypes { - crudOptions: CrudOptions; -} import { request } from '/@/utils/service'; //此处为crudOptions配置 -export const createCrudOptions = function ({ crudExpose, selectOptions }: { crudExpose: CrudExpose; selectOptions: any }): CreateCrudOptionsTypes { - const pageRequest = async (query: any) => { - return await api.GetList({ menu: selectOptions.value.id } as any); +export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { + const pageRequest = async (query: UserPageQuery) => { + console.log(context!.selectOptions); + return await api.GetList({ menu: context!.selectOptions.value.id } as any); }; const editRequest = async ({ form, row }: EditReq) => { form.id = row.id; diff --git a/web/src/views/system/menu/components/menuButton/index.vue b/web/src/views/system/menu/components/menuButton/index.vue index b65410beb..2d00e306b 100644 --- a/web/src/views/system/menu/components/menuButton/index.vue +++ b/web/src/views/system/menu/components/menuButton/index.vue @@ -1,83 +1,28 @@ diff --git a/web/src/views/system/menu/index.vue b/web/src/views/system/menu/index.vue index 10e45959d..aa4c376f7 100644 --- a/web/src/views/system/menu/index.vue +++ b/web/src/views/system/menu/index.vue @@ -79,16 +79,7 @@ - - - - 全选 - - - - 其他权限 - - + @@ -104,11 +95,15 @@ + + + + + - diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 8d5245a95..48cde8a40 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -2,7 +2,11 @@ module.exports = { content: ['./index.html', './src/**/*.{vue,js}'], theme: { - extend: {}, + extend: { + height: { + 'screen/2': '50vh', + }, + }, }, plugins: [], }; -- Gitee From 82d7193dcb8e43ddb7c7bf19a54963de79e9fb99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Mon, 10 Apr 2023 09:45:25 +0800 Subject: [PATCH 21/43] =?UTF-8?q?refactor(=E6=89=80=E6=9C=89=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2):=20=E2=99=BB=EF=B8=8F=20=E6=89=80=E6=9C=89=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E8=A1=A8=E6=A0=BC=E5=88=97=E5=AE=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/utils/service.ts | 6 +- web/src/views/system/areas/crud.tsx | 18 +++- web/src/views/system/dictionary/crud.tsx | 12 ++- web/src/views/system/fileList/crud.tsx | 10 +- web/src/views/system/log/loginLog/crud.tsx | 61 +++++++++-- .../views/system/log/operationLog/crud.tsx | 28 +++++ web/src/views/system/messageCenter/crud.tsx | 8 +- web/src/views/system/role/crud.tsx | 10 +- web/src/views/system/rolePermission/index.vue | 101 ++++++++++-------- web/src/views/system/whiteList/crud.tsx | 7 ++ 10 files changed, 190 insertions(+), 71 deletions(-) diff --git a/web/src/utils/service.ts b/web/src/utils/service.ts index 2385c4825..c3b46446f 100644 --- a/web/src/utils/service.ts +++ b/web/src/utils/service.ts @@ -62,10 +62,10 @@ function createService() { // 有 code 代表这是一个后端接口 可以进行进一步的判断 switch (code) { case 400: - Local.clear(); - Session.clear(); + // Local.clear(); + // Session.clear(); errorCreate(`${dataAxios.msg}: ${response.config.url}`); - window.location.reload(); + // window.location.reload(); break; case 401: Local.clear(); diff --git a/web/src/views/system/areas/crud.tsx b/web/src/views/system/areas/crud.tsx index 286eea51d..73af3ea88 100644 --- a/web/src/views/system/areas/crud.tsx +++ b/web/src/views/system/areas/crud.tsx @@ -105,8 +105,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp show: true, }, treeNode: true, - width: 160, type: 'input', + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -123,6 +125,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp show: true, }, type: 'input', + column:{ + minWidth: 90, + }, form: { rules: [ // 表单校验规则 @@ -139,6 +144,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -155,6 +163,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 100, + }, form: { disabled: false, rules: [ @@ -168,6 +179,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, initials: { title: '首字母', + column:{ + minWidth: 100, + }, form: { rules: [ // 表单校验规则 @@ -184,9 +198,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { show: true, }, - width: 90, type: 'dict-radio', column: { + minWidth:90, component: { name: 'fs-dict-switch', activeText: '', diff --git a/web/src/views/system/dictionary/crud.tsx b/web/src/views/system/dictionary/crud.tsx index 4ec048b08..53ec8b75d 100644 --- a/web/src/views/system/dictionary/crud.tsx +++ b/web/src/views/system/dictionary/crud.tsx @@ -111,6 +111,9 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, }, type: 'input', + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -135,6 +138,9 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, }, type: 'input', + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -155,12 +161,12 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, status: { title: '状态', - width: 90, search: { show: true, }, type: 'dict-radio', column: { + minWidth: 90, component: { name: 'fs-dict-switch', activeText: '', @@ -181,8 +187,10 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, sort: { title: '排序', - width: 90, type: 'number', + column:{ + minWidth: 80, + }, form: { value: 1, }, diff --git a/web/src/views/system/fileList/crud.tsx b/web/src/views/system/fileList/crud.tsx index 448d32260..31a7ec2af 100644 --- a/web/src/views/system/fileList/crud.tsx +++ b/web/src/views/system/fileList/crud.tsx @@ -94,6 +94,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp show: true, }, type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入文件名称', @@ -106,13 +109,18 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { disabled: true, }, + column:{ + minWidth: 200, + }, }, md5sum: { title: '文件MD5', - width: 200, search: { disabled: true, }, + column:{ + minWidth: 120, + }, form: { disabled: false, }, diff --git a/web/src/views/system/log/loginLog/crud.tsx b/web/src/views/system/log/loginLog/crud.tsx index 4de311a9c..e8a50be70 100644 --- a/web/src/views/system/log/loginLog/crud.tsx +++ b/web/src/views/system/log/loginLog/crud.tsx @@ -31,6 +31,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, }, rowHandle: { + fixed:'right', width: 100, buttons: { view: { @@ -89,8 +90,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { disabled: false, }, - width: 140, type: 'input', + column:{ + minWidth: 120, + }, form: { disabled: true, component: { @@ -103,8 +106,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { disabled: false, }, - width: 130, type: 'input', + column:{ + minWidth: 120, + }, form: { disabled: true, component: { @@ -118,8 +123,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, disabled: true, - width: 180, type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入运营商', @@ -128,8 +135,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, continent: { title: '大州', - width: 80, type: 'input', + column:{ + minWidth: 90, + }, form: { disabled: true, component: { @@ -140,8 +149,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, country: { title: '国家', - width: 80, type: 'input', + column:{ + minWidth: 90, + }, form: { component: { placeholder: '请输入国家', @@ -151,8 +162,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, province: { title: '省份', - width: 80, type: 'input', + column:{ + minWidth: 80, + }, form: { component: { placeholder: '请输入省份', @@ -162,8 +175,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, city: { title: '城市', - width: 80, type: 'input', + column:{ + minWidth: 80, + }, form: { component: { placeholder: '请输入城市', @@ -174,8 +189,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp district: { title: '县区', key: '', - width: 80, type: 'input', + column:{ + minWidth: 80, + }, form: { component: { placeholder: '请输入县区', @@ -186,6 +203,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp area_code: { title: '区域代码', type: 'input', + column:{ + minWidth: 90, + }, form: { component: { placeholder: '请输入区域代码', @@ -195,8 +215,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, country_english: { title: '英文全称', - width: 120, type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入英文全称', @@ -207,6 +229,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp country_code: { title: '简称', type: 'input', + column:{ + minWidth: 100, + }, form: { component: { placeholder: '请输入简称', @@ -218,6 +243,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp title: '经度', type: 'input', disabled: true, + column:{ + minWidth: 100, + }, form: { component: { placeholder: '请输入经度', @@ -229,6 +257,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp title: '纬度', type: 'input', disabled: true, + column:{ + minWidth: 100, + }, form: { component: { placeholder: '请输入纬度', @@ -248,6 +279,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp { label: '微信扫码登录', value: 2 }, ], }), + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请选择登录类型', @@ -257,6 +291,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp os: { title: '操作系统', type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入操作系统', @@ -266,6 +303,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp browser: { title: '浏览器名', type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入浏览器名', @@ -276,6 +316,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp title: 'agent信息', disabled: true, type: 'input', + column:{ + minWidth: 120, + }, form: { component: { placeholder: '请输入agent信息', diff --git a/web/src/views/system/log/operationLog/crud.tsx b/web/src/views/system/log/operationLog/crud.tsx index 4d1ace96a..cef5ebb90 100644 --- a/web/src/views/system/log/operationLog/crud.tsx +++ b/web/src/views/system/log/operationLog/crud.tsx @@ -31,6 +31,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, }, rowHandle: { + fixed:'right', width: 100, buttons: { view: { @@ -90,6 +91,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: false, }, type: 'input', + column:{ + minWidth: 100, + }, form: { disabled: true, component: { @@ -103,6 +107,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: false, }, type: 'input', + column:{ + minWidth: 200, + }, form: { disabled: true, component: { @@ -141,6 +148,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp search: { disabled: false, }, + column:{ + minWidth: 100, + }, form: { disabled: true, component: { @@ -164,6 +174,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: false, }, type: 'input', + column:{ + minWidth: 100, + }, form: { disabled: true, component: { @@ -175,6 +188,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp request_browser: { title: '请求浏览器', type: 'input', + column:{ + minWidth: 120, + }, form: { disabled: true, }, @@ -186,6 +202,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 100, + }, form: { disabled: true, }, @@ -198,6 +217,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 120, + }, form: { disabled: true, }, @@ -209,6 +231,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp disabled: true, }, type: 'input', + column:{ + minWidth: 150, + }, form: { disabled: true, }, @@ -216,6 +241,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, creator_name: { title: '操作人', + column:{ + minWidth: 100, + }, form: { disabled: true, }, diff --git a/web/src/views/system/messageCenter/crud.tsx b/web/src/views/system/messageCenter/crud.tsx index 0ddd72794..69d3d182d 100644 --- a/web/src/views/system/messageCenter/crud.tsx +++ b/web/src/views/system/messageCenter/crud.tsx @@ -73,6 +73,9 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx show: true, }, type: ['text', 'colspan'], + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -103,7 +106,9 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx target_type: { title: '目标类型', type: ['dict-radio', 'colspan'], - width: 120, + column:{ + minWidth: 120, + }, dict: dict({ data: [ { value: 0, label: '按用户' }, @@ -134,7 +139,6 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx search: { disabled: true, }, - width: 130, form: { component: { name: shallowRef(tableSelector), diff --git a/web/src/views/system/role/crud.tsx b/web/src/views/system/role/crud.tsx index c2f90727f..0fad942db 100644 --- a/web/src/views/system/role/crud.tsx +++ b/web/src/views/system/role/crud.tsx @@ -81,13 +81,6 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru align: 'center', width: '70px', columnSetDisabled: true, //禁止在列设置中选择 - formatter: (context) => { - //计算序号,你可以自定义计算规则,此处为翻页累加 - let index = context.index ?? 1; - let pagination = crudExpose.crudBinding.value.pagination; - // @ts-ignore - return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1; - }, }, }, id: { @@ -108,7 +101,7 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru form: { rules: [{ required: true, message: '角色名称必填' }], component: { - placeholder: '输入角色名称搜索', + placeholder: '请输入角色名称', }, }, }, @@ -170,6 +163,7 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru search: { show: true }, type: 'dict-radio', column: { + width:100, component: { name: 'fs-dict-switch', activeText: '', diff --git a/web/src/views/system/rolePermission/index.vue b/web/src/views/system/rolePermission/index.vue index c217360d8..fe5e9ba6e 100644 --- a/web/src/views/system/rolePermission/index.vue +++ b/web/src/views/system/rolePermission/index.vue @@ -7,18 +7,24 @@ :before-close="handleClose" > +
- @@ -35,11 +41,18 @@ - +
@@ -49,12 +62,12 @@ @@ -139,8 +152,8 @@ import {ref, defineExpose, reactive, toRefs} from 'vue' import {ElMessageBox} from 'element-plus' import * as api from './api' -import type {FormRules,FormInstance} from 'element-plus' -import { ElMessage } from 'element-plus' +import type {FormRules, FormInstance} from 'element-plus' +import {ElMessage} from 'element-plus' import XEUtils from 'xe-utils' //抽屉是否显示 const drawer = ref(false) @@ -190,7 +203,7 @@ let buttonOptions = ref<[]>() let editedMenuInfo = ref() //菜单节点点击事件 const menuNodeClick = (node: any, obj: any) => { - isBtnPermissionShow.value = !node.is_catalog + isBtnPermissionShow.value = !node.is_catalog if (!node.is_catalog) { buttonOptions.value = [] editedMenuInfo.value = node @@ -198,7 +211,7 @@ const menuNodeClick = (node: any, obj: any) => { const {data} = res buttonOptions.value = data }) - api.getObj({menu: node.id,role:editedRoleInfo.value.id}).then((res:any)=>{ + api.getObj({menu: node.id, role: editedRoleInfo.value.id}).then((res: any) => { const {data} = res buttonPermissionData.value = data }) @@ -211,7 +224,7 @@ const menuTree = ref() //是否显示新增表单 const dialogFormVisible = ref(false) //部门树 -const deptTree=ref() +const deptTree = ref() //自定义部门数据 const deptOptions = ref() //选中的部门数据 @@ -220,7 +233,7 @@ const deptCheckedKeys = [] const buttonForm = reactive({ menu_button: null, role: null, - menu:null, + menu: null, data_range: null, dept: [] }) @@ -256,20 +269,20 @@ const onChangeButton = (val: any) => { }) //获取权限部门值 api.GetDataScopeDept({menu_button: val}).then((res: any) => { - deptOptions.value = XEUtils.toArrayTree(res.data,{ parentKey: 'parent', strict: false }) + deptOptions.value = XEUtils.toArrayTree(res.data, {parentKey: 'parent', strict: false}) }) } //过滤按钮名称 -const formatMenuBtn = (val:any)=>{ - let obj:any = buttonOptions.value?.find((item:any)=>{ - return item.id===val +const formatMenuBtn = (val: any) => { + let obj: any = buttonOptions.value?.find((item: any) => { + return item.id === val }) - return obj?obj.name:null + return obj ? obj.name : null } //过滤权限范围 -const formatDataRange = (val:any)=>{ - let obj:any = [ +const formatDataRange = (val: any) => { + let obj: any = [ { "value": 0, "label": '仅本人数据权限' @@ -290,17 +303,17 @@ const formatDataRange = (val:any)=>{ "value": 4, "label": '自定义数据权限' } - ].find((item:any)=>{ - return item.value===val + ].find((item: any) => { + return item.value === val }) - return obj?obj.label:null + return obj ? obj.label : null } //保存按钮表单 const onSaveButtonForm = async () => { - const {id:roleId} = editedRoleInfo.value - const {id:menuId} = editedMenuInfo.value - const form:any = Object.assign({},buttonForm) + const {id: roleId} = editedRoleInfo.value + const {id: menuId} = editedMenuInfo.value + const form: any = Object.assign({}, buttonForm) form.role = roleId form.menu = menuId //选中的部门 @@ -309,7 +322,7 @@ const onSaveButtonForm = async () => { if (!buttonFormRef.value) return await buttonFormRef.value.validate((valid, fields) => { if (valid) { - api.CreatePermission(form).then((res:any)=>{ + api.CreatePermission(form).then((res: any) => { buttonPermissionData.value.push(form) dialogFormVisible.value = false ElMessage({ @@ -320,7 +333,7 @@ const onSaveButtonForm = async () => { } else { ElMessage({ type: 'error', - title:'提交错误', + title: '提交错误', message: 'F12控制台看详情', }) console.log('提交错误', fields) @@ -329,8 +342,8 @@ const onSaveButtonForm = async () => { } //删除按钮权限 -const onDeleteBtn = (scope:any)=>{ - const {row,$index} = scope +const onDeleteBtn = (scope: any) => { + const {row, $index} = scope ElMessageBox.confirm( '您是否要删除数据?', '温馨提示', @@ -339,15 +352,15 @@ const onDeleteBtn = (scope:any)=>{ cancelButtonText: '取消', type: 'warning', } - ).then(() => { - api.DeletePermission({id:row.id}).then(res=>{ - buttonPermissionData.value.splice($index,1) - ElMessage({ - type: 'success', - message: res.msg, - }) - }) + ).then(() => { + api.DeletePermission({id: row.id}).then(res => { + buttonPermissionData.value.splice($index, 1) + ElMessage({ + type: 'success', + message: res.msg, }) + }) + }) .catch(() => { ElMessage({ type: 'info', @@ -373,12 +386,12 @@ const onSaveAuth = () => { //合并的菜单数据 const menuIdList = [...checkedList, ...halfCheckedList] // console.log(menuIdList) - const { id:roleId } = editedRoleInfo.value + const {id: roleId} = editedRoleInfo.value const data = { - role:roleId, - menu:menuIdList + role: roleId, + menu: menuIdList } - api.SaveMenuPermission(data).then((res:any)=>{ + api.SaveMenuPermission(data).then((res: any) => { ElMessage({ message: res.msg, type: 'success', diff --git a/web/src/views/system/whiteList/crud.tsx b/web/src/views/system/whiteList/crud.tsx index 41b2d3f64..0b3fd67b5 100644 --- a/web/src/views/system/whiteList/crud.tsx +++ b/web/src/views/system/whiteList/crud.tsx @@ -124,6 +124,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, ], }), + column:{ + minWidth: 120, + }, form: { rules: [ // 表单校验规则 @@ -162,6 +165,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }); }, }), + column:{ + minWidth: 200, + }, form: { rules: [ // 表单校验规则 @@ -199,6 +205,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, type: 'dict-radio', column: { + minWidth:120, component: { name: 'fs-dict-switch', activeText: '', -- Gitee From 08b56ee663c399aa26aa03e3d039258453eb5edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Mon, 10 Apr 2023 16:45:49 +0800 Subject: [PATCH 22/43] =?UTF-8?q?refactor(=E6=89=80=E6=9C=89=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2):=20=E2=99=BB=EF=B8=8F=20=E6=89=80=E6=9C=89=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E6=8C=89=E9=92=AE=E6=9D=83=E9=99=90=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/dictionary/crud.tsx | 11 ++++++++++- web/src/views/system/messageCenter/crud.tsx | 16 +++++++++++++++- web/src/views/system/role/crud.tsx | 9 ++++++++- web/src/views/system/user/crud.tsx | 7 +++++++ web/src/views/system/whiteList/crud.tsx | 9 ++++++++- 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/web/src/views/system/dictionary/crud.tsx b/web/src/views/system/dictionary/crud.tsx index 53ec8b75d..6cd9ac62e 100644 --- a/web/src/views/system/dictionary/crud.tsx +++ b/web/src/views/system/dictionary/crud.tsx @@ -1,7 +1,7 @@ import * as api from './api'; import { dict, UserPageQuery, AddReq, DelReq, EditReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud'; import { dictionary } from '/@/utils/dictionary'; -import { nextTick, ref } from 'vue'; +import {inject, nextTick, ref} from 'vue'; import { successMessage } from '/@/utils/message'; export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { @@ -18,6 +18,11 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp const addRequest = async ({ form }: AddReq) => { return await api.AddObj(form); }; + + //权限判定 + const hasPermissions = inject("$hasPermissions") + + return { crudOptions: { request: { @@ -27,6 +32,7 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp delRequest, }, rowHandle: { + fixed:'right', width: 200, buttons: { view: { @@ -35,14 +41,17 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp edit: { iconRight: 'Edit', type: 'text', + show:hasPermissions('dictonary:Update') }, remove: { iconRight: 'Delete', type: 'text', + show:hasPermissions('dictonary:Delete') }, custom: { text: '字典配置', type: 'text', + show:hasPermissions('dictonary:Update'), tooltip: { placement: 'top', content: '字典配置', diff --git a/web/src/views/system/messageCenter/crud.tsx b/web/src/views/system/messageCenter/crud.tsx index 69d3d182d..aebef1e8f 100644 --- a/web/src/views/system/messageCenter/crud.tsx +++ b/web/src/views/system/messageCenter/crud.tsx @@ -1,7 +1,7 @@ import * as api from './api'; import { dict, useCompute, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud'; import tableSelector from '/@/components/tableSelector/index.vue'; -import { shallowRef, computed, ref } from 'vue'; +import {shallowRef, computed, ref, inject} from 'vue'; import manyToMany from '/@/components/manyToMany/index.vue'; const { compute } = useCompute(); @@ -36,6 +36,9 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx return tabActivted.value === 'receive'; }); + //权限判定 + const hasPermissions = inject("$hasPermissions") + return { crudOptions: { request: { @@ -45,11 +48,17 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx delRequest, }, rowHandle: { + fixed:'right', + width:150, buttons: { edit: { show: false, }, view: { + text:"查看", + type:'text', + iconRight:'View', + show:hasPermissions("messageCenter:Search"), click({ index, row }) { crudExpose.openView({ index, row }); if (tabActivted.value === 'receive') { @@ -58,6 +67,11 @@ export const createCrudOptions = function ({ crudExpose, tabActivted }: { crudEx } }, }, + remove: { + iconRight: 'Delete', + type: 'text', + show:hasPermissions('messageCenter:Delete') + }, }, }, columns: { diff --git a/web/src/views/system/role/crud.tsx b/web/src/views/system/role/crud.tsx index 0fad942db..eda0af320 100644 --- a/web/src/views/system/role/crud.tsx +++ b/web/src/views/system/role/crud.tsx @@ -3,6 +3,7 @@ import _ from 'lodash-es'; import * as api from './api'; import { dictionary } from '/@/utils/dictionary'; import { successMessage } from '../../../utils/message'; +import {inject} from "vue"; interface CreateCrudOptionsTypes { crudOptions: CrudOptions; } @@ -23,6 +24,9 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru return await api.AddObj(form); }; + //权限判定 + const hasPermissions = inject("$hasPermissions") + return { crudOptions: { request: { @@ -42,17 +46,20 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru edit: { iconRight: 'Edit', type: 'text', + show:hasPermissions('role:Update') }, remove: { iconRight: 'Delete', type: 'text', + show:hasPermissions('role:Delete') }, custom: { text: '权限配置', type: 'text', + show:hasPermissions('role:Update'), tooltip: { placement: 'top', - content: '删除', + content: '权限配置', }, click: (context: any): void => { const { row } = context; diff --git a/web/src/views/system/user/crud.tsx b/web/src/views/system/user/crud.tsx index f86143fa2..34b4e362a 100644 --- a/web/src/views/system/user/crud.tsx +++ b/web/src/views/system/user/crud.tsx @@ -3,6 +3,7 @@ import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, comp import { request } from '/@/utils/service'; import { dictionary } from '/@/utils/dictionary'; import { successMessage } from '/@/utils/message'; +import {inject} from "vue"; interface CreateCrudOptionsTypes { crudOptions: CrudOptions; } @@ -21,6 +22,10 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp const addRequest = async ({ form }: AddReq) => { return await api.AddObj(form); }; + + //权限判定 + const hasPermissions = inject("$hasPermissions") + return { crudOptions: { request: { @@ -40,10 +45,12 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp edit: { iconRight: 'Edit', type: 'text', + show:hasPermissions('user:Update') }, remove: { iconRight: 'Delete', type: 'text', + show:hasPermissions('user:Delete') }, }, }, diff --git a/web/src/views/system/whiteList/crud.tsx b/web/src/views/system/whiteList/crud.tsx index 0b3fd67b5..e47280f11 100644 --- a/web/src/views/system/whiteList/crud.tsx +++ b/web/src/views/system/whiteList/crud.tsx @@ -3,6 +3,7 @@ import { dict, UserPageQuery, AddReq, DelReq, EditReq, compute, CreateCrudOption import { request } from '/@/utils/service'; import { dictionary } from '/@/utils/dictionary'; import { successMessage } from '/@/utils/message'; +import {inject} from "vue"; export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet { const pageRequest = async (query: UserPageQuery) => { @@ -18,6 +19,10 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp const addRequest = async ({ form }: AddReq) => { return await api.AddObj(form); }; + + //权限判定 + const hasPermissions = inject("$hasPermissions") + return { crudOptions: { request: { @@ -29,7 +34,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp rowHandle: { //固定右侧 fixed: 'right', - width: 200, + width: 150, buttons: { view: { show: false, @@ -37,10 +42,12 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp edit: { iconRight: 'Edit', type: 'text', + show:hasPermissions("api_white_list:Update") }, remove: { iconRight: 'Delete', type: 'text', + show:hasPermissions("api_white_list:Delete") }, }, }, -- Gitee From dc6ddda4ab54ff9d7f5cb26cccef7f34bd4f4212 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Mon, 10 Apr 2023 17:59:30 +0800 Subject: [PATCH 23/43] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E9=83=A8=E9=97=A8=E7=AE=A1=E7=90=86=E5=89=8D?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/dept/api.ts | 8 + web/src/views/system/dept/index.vue | 191 +++++++++++++++--- .../menu/components/menuButton/index.vue | 4 +- web/src/views/system/menu/index.vue | 4 +- 4 files changed, 173 insertions(+), 34 deletions(-) diff --git a/web/src/views/system/dept/api.ts b/web/src/views/system/dept/api.ts index b60b1077b..c9796d763 100644 --- a/web/src/views/system/dept/api.ts +++ b/web/src/views/system/dept/api.ts @@ -39,3 +39,11 @@ export function DelObj(id: DelReq) { data: { id }, }); } + +export function lazyLoadDept(query: UserPageQuery) { + return request({ + url: apiPrefix, + method: 'get', + params: query, + }); +} diff --git a/web/src/views/system/dept/index.vue b/web/src/views/system/dept/index.vue index 0f80d1be4..561258524 100644 --- a/web/src/views/system/dept/index.vue +++ b/web/src/views/system/dept/index.vue @@ -3,12 +3,7 @@ -

- 部门列表 - - - -

+

部门列表

- + + + 部门配置 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 保存 + 新建 + 添加子级 + 添加同级 + 删除部门 + + + +
@@ -37,12 +78,11 @@ diff --git a/web/src/views/system/menu/components/menuButton/index.vue b/web/src/views/system/menu/components/menuButton/index.vue index 2d00e306b..a6a4f7b5f 100644 --- a/web/src/views/system/menu/components/menuButton/index.vue +++ b/web/src/views/system/menu/components/menuButton/index.vue @@ -1,7 +1,5 @@ + + diff --git a/web/src/stores/interface/index.ts b/web/src/stores/interface/index.ts index 794b6031e..e60a85f01 100644 --- a/web/src/stores/interface/index.ts +++ b/web/src/stores/interface/index.ts @@ -5,11 +5,17 @@ // 用户信息 export interface UserInfosState { - authBtnList: string[]; - photo: string; - roles: string[]; - time: number; + avatar: string; userName: string; + name: string; + email: string; + mobile: string; + gender: string; + dept_info: { + dept_id: number; + dept_name: string; + }; + role_info: any[]; } export interface UserInfosStates { userInfos: UserInfosState; diff --git a/web/src/stores/userInfo.ts b/web/src/stores/userInfo.ts index 88ab8a551..1bfd30710 100644 --- a/web/src/stores/userInfo.ts +++ b/web/src/stores/userInfo.ts @@ -11,11 +11,22 @@ import { request } from '../utils/service'; export const useUserInfo = defineStore('userInfo', { state: (): UserInfosStates => ({ userInfos: { + avatar: '', userName: '', - photo: '', - time: 0, - roles: [], - authBtnList: [], + name: '', + email: '', + mobile: '', + gender: '', + dept_info: { + dept_id: 0, + dept_name: '', + }, + role_info: [ + { + id: 0, + name: '', + }, + ], }, }), actions: { @@ -26,17 +37,22 @@ export const useUserInfo = defineStore('userInfo', { } else { let userInfos: any = await this.getApiUserInfo(); this.userInfos.userName = userInfos.data.name; - this.userInfos.photo = userInfos.data.avatar || 'https://img2.baidu.com/it/u=1978192862,2048448374&fm=253&fmt=auto&app=138&f=JPEG?w=504&h=500' - this.userInfos.time = new Date().getTime() - this.userInfos.roles = ['admin'] - Session.set('userInfo', this.userInfos) + this.userInfos.avatar = + userInfos.data.avatar || 'https://img2.baidu.com/it/u=1978192862,2048448374&fm=253&fmt=auto&app=138&f=JPEG?w=504&h=500'; + this.userInfos.name = userInfos.data.name; + this.userInfos.email = userInfos.data.email; + this.userInfos.mobile = userInfos.data.mobile; + this.userInfos.gender = userInfos.data.gender; + this.userInfos.dept_info = userInfos.data.dept_info; + this.userInfos.role_info = userInfos.data.role_info; + Session.set('userInfo', this.userInfos); } }, async getApiUserInfo() { return request({ url: '/api/system/user/user_info/', method: 'get', - }) - } + }); + }, }, }); diff --git a/web/src/utils/tools.ts b/web/src/utils/tools.ts index 439b927b6..15645ae3a 100644 --- a/web/src/utils/tools.ts +++ b/web/src/utils/tools.ts @@ -3,16 +3,16 @@ * @param {String} jsonString 需要解析的 json 字符串 * @param {String} defaultValue 默认值 */ -import { uiContext } from "@fast-crud/fast-crud"; +import { uiContext } from '@fast-crud/fast-crud'; -export function parse(jsonString = "{}", defaultValue = {}) { - let result = defaultValue; - try { - result = JSON.parse(jsonString); - } catch (error) { - console.log(error); - } - return result; +export function parse(jsonString = '{}', defaultValue = {}) { + let result = defaultValue; + try { + result = JSON.parse(jsonString); + } catch (error) { + console.log(error); + } + return result; } /** @@ -21,8 +21,8 @@ export function parse(jsonString = "{}", defaultValue = {}) { * @param {String} msg 状态信息 * @param {Number} code 状态码 */ -export function response(data = {}, msg = "", code = 0) { - return [200, { code, msg, data }]; +export function response(data = {}, msg = '', code = 0) { + return [200, { code, msg, data }]; } /** @@ -30,8 +30,8 @@ export function response(data = {}, msg = "", code = 0) { * @param {Any} data 返回值 * @param {String} msg 状态信息 */ -export function responseSuccess(data = {}, msg = "成功") { - return response(data, msg); +export function responseSuccess(data = {}, msg = '成功') { + return response(data, msg); } /** @@ -40,30 +40,57 @@ export function responseSuccess(data = {}, msg = "成功") { * @param {String} msg 状态信息 * @param {Number} code 状态码 */ -export function responseError(data = {}, msg = "请求失败", code = 500) { - return response(data, msg, code); +export function responseError(data = {}, msg = '请求失败', code = 500) { + return response(data, msg, code); } /** * @description 记录和显示错误 * @param {Error} error 错误对象 */ -export function errorLog(error:any,notification=true) { - // 打印到控制台 - console.error(error); - // 显示提示 - if(notification){ - uiContext.get().notification.error({ message: error.message }); - } - +export function errorLog(error: any, notification = true) { + // 打印到控制台 + console.error(error); + // 显示提示 + if (notification) { + uiContext.get().notification.error({ message: error.message }); + } } /** * @description 创建一个错误 * @param {String} msg 错误信息 */ -export function errorCreate(msg:any,notification=true) { - const error = new Error(msg); - errorLog(error,notification); - // throw error; +export function errorCreate(msg: any, notification = true) { + const error = new Error(msg); + errorLog(error, notification); + // throw error; +} + +export function base64ToFile(base64: any, fileName: string) { + // 将base64按照 , 进行分割 将前缀 与后续内容分隔开 + let data = base64.split(','); + // 利用正则表达式 从前缀中获取图片的类型信息(image/png、image/jpeg、image/webp等) + let type = data[0].match(/:(.*?);/)[1]; + // 从图片的类型信息中 获取具体的文件格式后缀(png、jpeg、webp) + let suffix = type.split('/')[1]; + // 使用atob()对base64数据进行解码 结果是一个文件数据流 以字符串的格式输出 + const bstr = window.atob(data[1]); + // 获取解码结果字符串的长度 + let n = bstr.length; + // 根据解码结果字符串的长度创建一个等长的整形数字数组 + // 但在创建时 所有元素初始值都为 0 + const u8arr = new Uint8Array(n); + // 将整形数组的每个元素填充为解码结果字符串对应位置字符的UTF-16 编码单元 + while (n--) { + // charCodeAt():获取给定索引处字符对应的 UTF-16 代码单元 + u8arr[n] = bstr.charCodeAt(n); + } + // 利用构造函数创建File文件对象 + // new File(bits, name, options) + const file = new File([u8arr], `${fileName}.${suffix}`, { + type: type, + }); + // 将File文件对象返回给方法的调用者 + return file; } diff --git a/web/src/views/system/login/component/account.vue b/web/src/views/system/login/component/account.vue index 6b92ffb8c..585cf4c11 100644 --- a/web/src/views/system/login/component/account.vue +++ b/web/src/views/system/login/component/account.vue @@ -89,8 +89,8 @@ export default defineComponent({ const state = reactive({ isShowPassword: false, ruleForm: { - username: 'superadmin', - password: 'admin123456', + username: '', + password: '', captcha: '', captchaKey: '', captchaImgBase: '', diff --git a/web/src/views/system/personal/api.ts b/web/src/views/system/personal/api.ts index c68e5f210..f5243d85f 100644 --- a/web/src/views/system/personal/api.ts +++ b/web/src/views/system/personal/api.ts @@ -1,40 +1,38 @@ import { request } from '/@/utils/service'; import { PageQuery, AddReq, DelReq, EditReq, InfoReq } from '@fast-crud/fast-crud'; -import {apiPrefix} from "/@/views/system/messageCenter/api"; +import { apiPrefix } from '/@/views/system/messageCenter/api'; export function GetUserInfo(query: PageQuery) { - return request({ - url: '/api/system/user/user_info/', - method: 'get', - params: query - }); + return request({ + url: '/api/system/user/user_info/', + method: 'get', + params: query, + }); } - /** * 更新用户信息 * @param data */ export function updateUserInfo(data: AddReq) { - return request({ - url: '/api/system/user/update_user_info/', - method: 'put', - data: data - }) + return request({ + url: '/api/system/user/update_user_info/', + method: 'put', + data: data, + }); } - /** * 获取自己接收的消息 * @param query * @returns {*} * @constructor */ -export function GetSelfReceive (query:PageQuery) { - return request({ - url: '/api/system/message_center/get_self_receive/', - method: 'get', - params: query - }) +export function GetSelfReceive(query: PageQuery) { + return request({ + url: '/api/system/message_center/get_self_receive/', + method: 'get', + params: query, + }); } /*** @@ -42,9 +40,24 @@ export function GetSelfReceive (query:PageQuery) { * @param data */ export function UpdatePassword(data: EditReq) { - return request({ - url: '/api/system/user/change_password/', - method: 'put', - data: data - }) + return request({ + url: '/api/system/user/change_password/', + method: 'put', + data: data, + }); +} + +/*** + * 上传头像 + * @param data + */ +export function uploadAvatar(data: AddReq) { + return request({ + url: 'api/system/file/', + method: 'post', + data: data, + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); } diff --git a/web/src/views/system/personal/index.vue b/web/src/views/system/personal/index.vue index 14f53e559..d6d295eac 100644 --- a/web/src/views/system/personal/index.vue +++ b/web/src/views/system/personal/index.vue @@ -6,10 +6,9 @@
- - - - + + +
@@ -174,13 +173,18 @@ -- Gitee From d1223dddd34474ceee43794345b8530788d7bf1b Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Wed, 12 Apr 2023 02:13:57 +0800 Subject: [PATCH 29/43] =?UTF-8?q?feat:=20=E2=9A=A1=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/user/crud.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/src/views/system/user/crud.tsx b/web/src/views/system/user/crud.tsx index c09ab5290..b5be3cbf4 100644 --- a/web/src/views/system/user/crud.tsx +++ b/web/src/views/system/user/crud.tsx @@ -25,6 +25,11 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp return { crudOptions: { + table: { + remove: { + confirmMessage: '是否删除该用户?', + }, + }, request: { pageRequest, addRequest, -- Gitee From c4c9a81ac882dea1471ab64eb4e4ef0c9a1ac325 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Thu, 13 Apr 2023 02:24:31 +0800 Subject: [PATCH 30/43] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E5=88=A0=E9=99=A4bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/dept/api.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/views/system/dept/api.ts b/web/src/views/system/dept/api.ts index c9796d763..29254ea1f 100644 --- a/web/src/views/system/dept/api.ts +++ b/web/src/views/system/dept/api.ts @@ -32,11 +32,11 @@ export function UpdateObj(obj: EditReq) { }); } -export function DelObj(id: DelReq) { +export function DelObj(obj: DelReq) { return request({ - url: apiPrefix + id + '/', + url: apiPrefix + obj.id + '/', method: 'delete', - data: { id }, + data: obj, }); } -- Gitee From 5ab3ad4ed92a8e0ce2a85c57623767daa858d944 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Fri, 21 Apr 2023 14:27:03 +0800 Subject: [PATCH 31/43] =?UTF-8?q?fix:=20=F0=9F=90=9B=20get=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2params=E5=8F=82=E6=95=B0=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=88=86=E9=A1=B5=E4=B8=8D=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/fileList/api.ts | 2 +- web/src/views/system/log/loginLog/api.ts | 2 +- web/src/views/system/whiteList/api.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/views/system/fileList/api.ts b/web/src/views/system/fileList/api.ts index 06c649957..7c5708b1b 100644 --- a/web/src/views/system/fileList/api.ts +++ b/web/src/views/system/fileList/api.ts @@ -6,7 +6,7 @@ export function GetList(query: UserPageQuery) { return request({ url: apiPrefix, method: 'get', - data: query, + params: query, }); } export function GetObj(id: InfoReq) { diff --git a/web/src/views/system/log/loginLog/api.ts b/web/src/views/system/log/loginLog/api.ts index 71575dd2c..defefc494 100644 --- a/web/src/views/system/log/loginLog/api.ts +++ b/web/src/views/system/log/loginLog/api.ts @@ -6,7 +6,7 @@ export function GetList(query: UserPageQuery) { return request({ url: apiPrefix, method: 'get', - data: query, + params: query, }); } export function GetObj(id: InfoReq) { diff --git a/web/src/views/system/whiteList/api.ts b/web/src/views/system/whiteList/api.ts index 3be27dbbe..9b7e7f1f5 100644 --- a/web/src/views/system/whiteList/api.ts +++ b/web/src/views/system/whiteList/api.ts @@ -6,7 +6,7 @@ export function GetList(query: UserPageQuery) { return request({ url: apiPrefix, method: 'get', - data: query, + params: query, }); } export function GetObj(id: InfoReq) { -- Gitee From 9c24e6112342854e758f9d5eb1916ab5b0bf855e Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Fri, 21 Apr 2023 14:37:02 +0800 Subject: [PATCH 32/43] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86=E7=9A=84=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8C=89=E9=92=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menu/components/menuButton/crud.tsx | 3 +- web/src/views/system/menu/index.vue | 66 ++++++++++--------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/web/src/views/system/menu/components/menuButton/crud.tsx b/web/src/views/system/menu/components/menuButton/crud.tsx index 50c79df5a..0ab209558 100644 --- a/web/src/views/system/menu/components/menuButton/crud.tsx +++ b/web/src/views/system/menu/components/menuButton/crud.tsx @@ -16,7 +16,6 @@ import { request } from '/@/utils/service'; //此处为crudOptions配置 export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const pageRequest = async (query: UserPageQuery) => { - console.log(context!.selectOptions); return await api.GetList({ menu: context!.selectOptions.value.id } as any); }; const editRequest = async ({ form, row }: EditReq) => { @@ -27,7 +26,7 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp return await api.DelObj(row.id); }; const addRequest = async ({ form }: AddReq) => { - return await api.AddObj(form); + return await api.AddObj({ ...form, ...{ menu: context!.selectOptions.value.id } }); }; return { crudOptions: { diff --git a/web/src/views/system/menu/index.vue b/web/src/views/system/menu/index.vue index 0eadbe7f1..30849c0ab 100644 --- a/web/src/views/system/menu/index.vue +++ b/web/src/views/system/menu/index.vue @@ -6,29 +6,23 @@

菜单列表 - + + +

- + @@ -42,29 +36,26 @@ - + + - + + - + - + + @@ -79,6 +70,14 @@ + + + + 启用 + 禁用 + + + @@ -97,7 +96,9 @@ - + + + @@ -240,6 +241,7 @@ let form: Form = reactive({ is_catalog: false, permission: '', icon: '', + visible: '' }); let menuPermissonList = ref([]); -- Gitee From 054bcf3eeac3dcc74fb1c39498a46485259d71ad Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Fri, 21 Apr 2023 15:07:52 +0800 Subject: [PATCH 33/43] =?UTF-8?q?build:=20=E2=AC=86=EF=B8=8F=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BE=9D=E8=B5=96=EF=BC=9Afast-crud=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/package.json | 8 ++++---- web/yarn.lock | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/web/package.json b/web/package.json index 4349cde86..345af77ca 100644 --- a/web/package.json +++ b/web/package.json @@ -10,10 +10,10 @@ }, "dependencies": { "@element-plus/icons-vue": "^2.0.10", - "@fast-crud/fast-crud": "^1.11.10", - "@fast-crud/fast-extends": "^1.11.10", - "@fast-crud/ui-element": "^1.11.10", - "@fast-crud/ui-interface": "^1.11.9", + "@fast-crud/fast-crud": "^1.13.2", + "@fast-crud/fast-extends": "^1.13.2", + "@fast-crud/ui-element": "^1.13.2", + "@fast-crud/ui-interface": "^1.13.2", "@vitejs/plugin-vue-jsx": "^3.0.0", "@wangeditor/editor": "^5.1.23", "@wangeditor/editor-for-vue": "^5.1.12", diff --git a/web/yarn.lock b/web/yarn.lock index 71ad5c135..53c5d0b3f 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -1433,18 +1433,18 @@ resolved "https://registry.npmjs.org/@eslint/js/-/js-8.36.0.tgz#9837f768c03a1e4a30bd304a64fb8844f0e72efe" integrity sha512-lxJ9R5ygVm8ZWgYdUweoq5ownDlJ4upvoWmO4eLxBYHdMo+vZ/Rx0EN6MbKWDJOSUGrqJy2Gt+Dyv/VKml0fjg== -"@fast-crud/fast-crud@^1.11.10": - version "1.11.10" - resolved "https://registry.npmjs.org/@fast-crud/fast-crud/-/fast-crud-1.11.10.tgz#9316346c424275e0706c801de90c091c17091577" - integrity sha512-TIfetITnXRsIh5ETDmlvzjK5Rjhgoizf5lYBO2HdUV7JxqQiULKh0TpYebFbgYABfcFjNz2XbgEmngFWZ+Qc3w== +"@fast-crud/fast-crud@^1.13.2": + version "1.13.2" + resolved "https://registry.npmjs.org/@fast-crud/fast-crud/-/fast-crud-1.13.2.tgz#8e7e83c05f2d78a7053a029350dc808d21dcece9" + integrity sha512-ANvAeBtxGctdKXkyVRAxXq886BJriTODaSUONPJsc5e3RcSXK99MBeiwImBwiyq0kg5JT+AlN6DuV1In7vsuYQ== dependencies: lru-cache "^8.0.3" vuedraggable-es "^4.1.1" -"@fast-crud/fast-extends@^1.11.10": - version "1.11.10" - resolved "https://registry.npmjs.org/@fast-crud/fast-extends/-/fast-extends-1.11.10.tgz#1f0342e677bccc86245d0e40b531d16cbaed7364" - integrity sha512-aYaMshrUwE9yuAzwwaXA94r7gGFd385/sSE3Q6M7OLnW0uysjMt9WkdvwKtEPh14hpVdvKyYRo0G5DvLz383xg== +"@fast-crud/fast-extends@^1.13.2": + version "1.13.2" + resolved "https://registry.npmjs.org/@fast-crud/fast-extends/-/fast-extends-1.13.2.tgz#7e0e044dd7f2a25eff4d2a6c88966071d7282719" + integrity sha512-VgVkU4lta52h/Cv1eIIICz0pNs5nHACHVtQr07PYwcxZDkgLFbjf9j0gdegSYq22MpJ1kp9hZ35WDXvVRzrx+Q== dependencies: "@aws-sdk/client-s3" "^3.292.0" "@aws-sdk/s3-request-presigner" "^3.292.0" @@ -1464,15 +1464,15 @@ quill "^1.3.7" vue-cropperjs "^5.0.0" -"@fast-crud/ui-element@^1.11.10": - version "1.11.10" - resolved "https://registry.npmjs.org/@fast-crud/ui-element/-/ui-element-1.11.10.tgz#25ce805ced2020d54a7b2c19f1df73fd39227a1f" - integrity sha512-lZNhIx7E6jkGrjEz3+ChJc8z53f1GFxmYWBoKDkJilfE6HhF+gmuV3nZiuRixjbSqWhVRHStMd+/7kDys7htZg== +"@fast-crud/ui-element@^1.13.2": + version "1.13.2" + resolved "https://registry.npmjs.org/@fast-crud/ui-element/-/ui-element-1.13.2.tgz#d012b4a382a241dbec4354963661f085575a772e" + integrity sha512-11aQ+EQRr/w3VdCmZCn8nZC9+aqGE2goYH9jsy1DoDLNKL5MMAyxfalTxkWGsgVTyJPjq1OgITCa1D4WoyVQQw== -"@fast-crud/ui-interface@^1.11.9": - version "1.11.9" - resolved "https://registry.npmjs.org/@fast-crud/ui-interface/-/ui-interface-1.11.9.tgz#df6d4732a020e7df06daf0b3763adb91a5e70f25" - integrity sha512-WFGWWleM7Uy2eWcbFxiKK1FZ/mtEoKVImfbxCPvNFkGgZS2NGA5zPXkJNY5/PntwCcgAvxvSYzLrtKfOlOHnpQ== +"@fast-crud/ui-interface@^1.13.2": + version "1.13.2" + resolved "https://registry.npmjs.org/@fast-crud/ui-interface/-/ui-interface-1.13.2.tgz#263f26e21d1014623f7dbfd36628aaf5bb5bab17" + integrity sha512-lNsJSyPK+ssugsVGJDCV0xjrQ08d0BfPgwSN5z7DNrfOHJILrYDebyKq8WnUFLnDIPtXBwlP83s93is/EIsofw== dependencies: lodash-es "^4.17.21" -- Gitee From 25cc2c83c1fbe8abf6e60b0b13c1d010f59919b5 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Fri, 21 Apr 2023 20:49:48 +0800 Subject: [PATCH 34/43] =?UTF-8?q?feat:=20=E2=9C=A8=20=E5=85=A8=E5=B1=80cru?= =?UTF-8?q?d=E7=9A=84ElNotification=E6=8F=90=E7=A4=BA=EF=BC=8CElNotificati?= =?UTF-8?q?on=E7=9A=84=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/settings.ts | 9 +++++++++ web/src/utils/message.ts | 20 ++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/web/src/settings.ts b/web/src/settings.ts index 588a6a058..ed41401ed 100644 --- a/web/src/settings.ts +++ b/web/src/settings.ts @@ -9,6 +9,7 @@ import { request } from '/@/utils/service'; //扩展包 import { FsExtendsEditor } from '@fast-crud/fast-extends'; import '@fast-crud/fast-extends/dist/style.css'; +import { successMessage, successNotification } from '/@/utils/message'; export default { async install(app: any, options: any) { // 先安装ui @@ -40,6 +41,14 @@ export default { return { records: res.data, currentPage: res.page, pageSize: res.limit, total: res.total }; }, }, + form: { + afterSubmit(ctx: any) { + // 增加crud提示 + if (ctx.res.code == 2000) { + successNotification(ctx.res.msg); + } + }, + }, /* search: { layout: 'multi-line', collapse: true, diff --git a/web/src/utils/message.ts b/web/src/utils/message.ts index 0e3bc4b13..a022c0ba5 100644 --- a/web/src/utils/message.ts +++ b/web/src/utils/message.ts @@ -1,10 +1,10 @@ -import { ElMessage, MessageOptions } from 'element-plus'; +import { ElMessage, ElNotification, MessageOptions } from 'element-plus'; export function message(message: string, option?: MessageOptions) { ElMessage({ message, ...option }); } export function successMessage(message: string, option?: MessageOptions) { - ElMessage({ message, ...option, type: 'success' }); + ElMessage({ message, type: 'success' }); } export function warningMessage(message: string, option?: MessageOptions) { ElMessage({ message, ...option, type: 'warning' }); @@ -15,3 +15,19 @@ export function errorMessage(message: string, option?: MessageOptions) { export function infoMessage(message: string, option?: MessageOptions) { ElMessage({ message, ...option, type: 'info' }); } + +export function notification(message: string) { + ElNotification({ message }); +} +export function successNotification(message: string) { + ElNotification({ message, type: 'success' }); +} +export function warningNotification(message: string) { + ElNotification({ message, type: 'warning' }); +} +export function errorNotification(message: string) { + ElNotification({ message, type: 'error' }); +} +export function infoNotification(message: string) { + ElNotification({ message, type: 'info' }); +} -- Gitee From 096f5919af7b3c880d7dd7bf4aea0c3868f8f0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Fri, 28 Apr 2023 11:05:56 +0800 Subject: [PATCH 35/43] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=ADswitch=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/config/components/formContent.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/src/views/system/config/components/formContent.vue b/web/src/views/system/config/components/formContent.vue index d00c3f66d..2524b8aa0 100644 --- a/web/src/views/system/config/components/formContent.vue +++ b/web/src/views/system/config/components/formContent.vue @@ -85,6 +85,7 @@ :key="index + 6" v-else-if="item.form_item_type_label === 'switch'" v-model="formData[item.key]" + :inactive-value="false" active-color="#13ce66" inactive-color="#ff4949" > @@ -296,7 +297,7 @@ const getInit = () => { if ([5, 12, 14].indexOf(item.form_item_type) !== -1) { _formData[key] = []; } else { - _formData[key] = undefined; + _formData[key] = item.value; } } if (item.form_item_type_label === 'array') { -- Gitee From d3b057f75a4f388fe5a0e8b7481abbb6781d8158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Fri, 28 Apr 2023 11:54:50 +0800 Subject: [PATCH 36/43] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE)?= =?UTF-8?q?:=20=F0=9F=90=9B=20=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0,=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=B7=BB=E5=8A=A0,=E5=88=86=E7=BB=84=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.文件上传; 2.内容添加; 3.添加完成后刷新 --- .../views/system/config/components/addContent.vue | 11 ++++++++--- web/src/views/system/config/components/addTabs.vue | 12 ++++++++++-- .../views/system/config/components/formContent.vue | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/web/src/views/system/config/components/addContent.vue b/web/src/views/system/config/components/addContent.vue index 6284a181f..e7e9e4d05 100644 --- a/web/src/views/system/config/components/addContent.vue +++ b/web/src/views/system/config/components/addContent.vue @@ -40,7 +40,7 @@ - 立即创建 + 立即创建
@@ -49,7 +49,7 @@