From 953fcc343715ca7e7c76e9ea7f9e5578440545b4 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Wed, 12 Apr 2023 00:25:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/dvadmin/system/views/user.py | 30 +++++++++++--------- web/src/views/system/dictionary/crud.tsx | 19 ++++++------- web/src/views/system/user/crud.tsx | 36 ++++++++++++------------ 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/backend/dvadmin/system/views/user.py b/backend/dvadmin/system/views/user.py index 01fae1b..7db25e7 100644 --- a/backend/dvadmin/system/views/user.py +++ b/backend/dvadmin/system/views/user.py @@ -41,6 +41,7 @@ class UserSerializer(CustomModelSerializer): exclude = ["password"] extra_kwargs = { "post": {"required": False}, + "mobile": {"required": False}, } def get_dept_name_all(self, instance): @@ -60,9 +61,6 @@ class UserSerializer(CustomModelSerializer): return serializer.data - - - class UserCreateSerializer(CustomModelSerializer): """ 用户新增-序列化器 @@ -82,10 +80,10 @@ class UserCreateSerializer(CustomModelSerializer): """ 对密码进行验证 """ - password = self.initial_data.get("password") - if password: - return make_password(value) - return value + md5 = hashlib.md5() + md5.update(value.encode('utf-8')) + md5_password = md5.hexdigest() + return make_password(md5_password) def save(self, **kwargs): data = super().save(**kwargs) @@ -100,6 +98,7 @@ class UserCreateSerializer(CustomModelSerializer): read_only_fields = ["id"] extra_kwargs = { "post": {"required": False}, + "mobile": {"required": False}, } @@ -114,14 +113,15 @@ class UserUpdateSerializer(CustomModelSerializer): CustomUniqueValidator(queryset=Users.objects.all(), message="账号必须唯一") ], ) + # password = serializers.CharField(required=False, allow_blank=True) - mobile = serializers.CharField( - max_length=50, - validators=[ - CustomUniqueValidator(queryset=Users.objects.all(), message="手机号必须唯一") - ], - allow_blank=True - ) + # mobile = serializers.CharField( + # max_length=50, + # validators=[ + # CustomUniqueValidator(queryset=Users.objects.all(), message="手机号必须唯一") + # ], + # allow_blank=True + # ) def save(self, **kwargs): data = super().save(**kwargs) @@ -136,6 +136,7 @@ class UserUpdateSerializer(CustomModelSerializer): fields = "__all__" extra_kwargs = { "post": {"required": False, "read_only": True}, + "mobile": {"required": False}, } @@ -159,6 +160,7 @@ class UserInfoUpdateSerializer(CustomModelSerializer): fields = ['email', 'mobile', 'avatar', 'name', 'gender'] extra_kwargs = { "post": {"required": False, "read_only": True}, + "mobile": {"required": False}, } diff --git a/web/src/views/system/dictionary/crud.tsx b/web/src/views/system/dictionary/crud.tsx index 6cd9ac6..69b0af0 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 {inject, nextTick, ref} from 'vue'; +import { inject, nextTick, ref } from 'vue'; import { successMessage } from '/@/utils/message'; export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { @@ -20,8 +20,7 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }; //权限判定 - const hasPermissions = inject("$hasPermissions") - + const hasPermissions = inject('$hasPermissions'); return { crudOptions: { @@ -32,7 +31,7 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp delRequest, }, rowHandle: { - fixed:'right', + fixed: 'right', width: 200, buttons: { view: { @@ -41,17 +40,17 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp edit: { iconRight: 'Edit', type: 'text', - show:hasPermissions('dictonary:Update') + show: hasPermissions('dictionary:Update'), }, remove: { iconRight: 'Delete', type: 'text', - show:hasPermissions('dictonary:Delete') + show: hasPermissions('dictionary:Delete'), }, custom: { text: '字典配置', type: 'text', - show:hasPermissions('dictonary:Update'), + show: hasPermissions('dictionary:Update'), tooltip: { placement: 'top', content: '字典配置', @@ -120,7 +119,7 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, }, type: 'input', - column:{ + column: { minWidth: 120, }, form: { @@ -147,7 +146,7 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp }, }, type: 'input', - column:{ + column: { minWidth: 120, }, form: { @@ -197,7 +196,7 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp sort: { title: '排序', type: 'number', - column:{ + column: { minWidth: 80, }, form: { diff --git a/web/src/views/system/user/crud.tsx b/web/src/views/system/user/crud.tsx index 34b4e36..deda080 100644 --- a/web/src/views/system/user/crud.tsx +++ b/web/src/views/system/user/crud.tsx @@ -3,7 +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"; +import { inject } from 'vue'; interface CreateCrudOptionsTypes { crudOptions: CrudOptions; } @@ -24,7 +24,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }; //权限判定 - const hasPermissions = inject("$hasPermissions") + const hasPermissions = inject('$hasPermissions'); return { crudOptions: { @@ -45,12 +45,12 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp edit: { iconRight: 'Edit', type: 'text', - show:hasPermissions('user:Update') + show: hasPermissions('user:Update'), }, remove: { iconRight: 'Delete', type: 'text', - show:hasPermissions('user:Delete') + show: hasPermissions('user:Delete'), }, }, }, @@ -71,8 +71,8 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp show: true, }, type: 'input', - column:{ - minWidth: 100 //最小列宽 + column: { + minWidth: 100, //最小列宽 }, form: { rules: [ @@ -123,8 +123,8 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp show: true, }, type: 'input', - column:{ - minWidth: 100 //最小列宽 + column: { + minWidth: 100, //最小列宽 }, form: { rules: [ @@ -159,8 +159,8 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }); }, }), - column:{ - minWidth: 150 //最小列宽 + column: { + minWidth: 150, //最小列宽 }, form: { rules: [ @@ -205,8 +205,8 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }); }, }), - column:{ - minWidth: 100 //最小列宽 + column: { + minWidth: 100, //最小列宽 }, form: { rules: [ @@ -229,8 +229,8 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp show: true, }, type: 'input', - column:{ - minWidth: 120 //最小列宽 + column: { + minWidth: 120, //最小列宽 }, form: { rules: [ @@ -269,7 +269,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }, gender: { title: '性别', - type: 'dict-radio', + type: 'dict-select', dict: dict({ data: dictionary('gender'), }), @@ -290,8 +290,8 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp dict: dict({ data: dictionary('user_type'), }), - column:{ - minWidth: 100 //最小列宽 + column: { + minWidth: 100, //最小列宽 }, form: { show: false, @@ -302,7 +302,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp }, }, is_active: { - title: '状态', + title: '锁定', search: { show: true, },