Merge remote-tracking branch 'origin/v2.x' into v2.x

pull/57/MERGE
猿小天 2022-05-16 20:29:10 +08:00
commit 1324924fb2
7 changed files with 53 additions and 11 deletions

View File

@ -36,7 +36,10 @@ def _get_all_system_config():
system_config_obj = SystemConfig.objects.filter(status=True, parent_id__isnull=False).values(
'parent__key', 'key', 'value', 'form_item_type').order_by('sort')
for system_config in system_config_obj:
data[f"{system_config.get('parent__key')}.{system_config.get('key')}"] = system_config.get('value') or ''
value = system_config.get('value') or ''
if value and system_config.get('form_item_type') == 7:
value = value[0].get('url')
data[f"{system_config.get('parent__key')}.{system_config.get('key')}"] = value
return data
@ -86,6 +89,7 @@ def refresh_dictionary():
:return:
"""
if is_tenants_mode():
from django_tenants.utils import schema_context
with schema_context(connection.tenant.schema_name):
settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary()
else:
@ -98,6 +102,7 @@ def refresh_system_config():
:return:
"""
if is_tenants_mode():
from django_tenants.utils import schema_context
with schema_context(connection.tenant.schema_name):
settings.SYSTEM_CONFIG[connection.tenant.schema_name] = _get_all_system_config()
else:

View File

@ -2169,7 +2169,7 @@ system_config_data = [
"create_datetime": datetime.datetime.now(),
"title": "登录网站logo",
"key": "site_logo",
"value": "[]",
"value": None,
"sort": 2,
"status": 1,
"data_options": None,

View File

@ -15,6 +15,8 @@ from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
from rest_framework_simplejwt.views import TokenObtainPairView
from django.conf import settings
from application import dispatch
from dvadmin.system.models import Users
from dvadmin.utils.json_response import ErrorResponse, DetailResponse
from dvadmin.utils.request_util import save_login_log
@ -34,7 +36,7 @@ class CaptchaView(APIView):
)
def get(self, request):
data = {}
if settings.SYSTEM_CONFIG.get("base.captcha_state"):
if dispatch.get_system_config_values("base.captcha_state"):
hashkey = CaptchaStore.generate_key()
id = CaptchaStore.objects.filter(hashkey=hashkey).first().id
imgage = captcha_image(request, hashkey)
@ -66,7 +68,7 @@ class LoginSerializer(TokenObtainPairSerializer):
def validate(self, attrs):
captcha = self.initial_data.get("captcha", None)
if settings.SYSTEM_CONFIG.get("base.captcha_state"):
if dispatch.get_system_config_values("base.captcha_state"):
if captcha is None:
raise CustomValidationError("验证码不能为空")
self.image_code = CaptchaStore.objects.filter(

View File

@ -1,6 +1,6 @@
import hashlib
from application import settings
from application import settings, dispatch
from django.contrib.auth.hashers import make_password
from rest_framework import serializers
from rest_framework.decorators import action
@ -252,7 +252,7 @@ class UserViewSet(CustomModelViewSet):
"""恢复默认密码"""
instance = Users.objects.filter(id=kwargs.get("pk")).first()
if instance:
instance.set_password(settings.SYSTEM_CONFIG.get("base.default_password"))
instance.set_password(dispatch.get_system_config_values("base.default_password"))
instance.save()
return DetailResponse(data=None, msg="密码重置成功")
else:

View File

@ -18,6 +18,7 @@ import XEUtils from 'xe-utils'
import store from '@/store/index'
import { urlPrefix as deptPrefix } from '@/views/system/dept/api'
import types from '@/config/d2p-extends/types'
import { checkPlugins } from '@/views/plugins'
const uploadUrl = util.baseURL() + 'api/system/file/'
/**
@ -34,7 +35,11 @@ Vue.use(d2CrudX, { name: 'd2-crud-x' })
// // 官方版此处为演示与官方版共存而引入全新项目中可以用d2-crud-x完全替代官方版
// Vue.use(d2Crud)
/**
* @description 校验插件是否安装
* @param {String} pluginName 插件名称
*/
Vue.prototype.checkPlugins = checkPlugins
// 引入d2CrudPlus
Vue.use(d2CrudPlus, {
starTip: false,

View File

@ -1,6 +1,8 @@
import cookies from './util.cookies'
import db from './util.db'
import log from './util.log'
import dayjs from 'dayjs'
const util = {
cookies,
db,
@ -34,7 +36,7 @@ util.open = function (url) {
*/
util.baseURL = function () {
var baseURL = process.env.VUE_APP_API
if (window.pluginsAll && window.pluginsAll.indexOf('dvadmin-tenant') !== -1) {
if (window.pluginsAll && window.pluginsAll.indexOf('dvadmin-tenant-web') !== -1) {
// document.domain
var host = baseURL.split('/')[2]
var prot = host.split(':')[1] || 80
@ -46,5 +48,33 @@ util.baseURL = function () {
}
return baseURL
}
/**
* 自动生成ID
*/
util.autoCreateCode = function () {
return dayjs().format('YYYYMMDDHHmmssms') + Math.round(Math.random() * 80 + 20)
}
/**
* 自动生成短 ID
*/
util.autoShortCreateCode = function () {
var Num = ''
for (var i = 0; i < 4; i++) {
Num += Math.floor(Math.random() * 10)
}
return dayjs().format('YYMMDD') + Num
}
/**
* 生产随机字符串
*/
util.randomString = function (e) {
e = e || 32
var t = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'
var a = t.length
var n = ''
for (let i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a))
return n
}
export default util

View File

@ -7,7 +7,7 @@
</el-row>
<el-form ref="form" :model="form" label-width="140px" label-position="left" style="margin-top: 20px">
<el-form-item :label="item.title" :prop="['array'].indexOf(item.form_item_type_label) >-1?'':item.key"
:key="index" :rules="item.rule"
:key="index" :rules="item.rule || []"
v-for="(item,index) in formList"
>
@ -118,7 +118,7 @@
:on-error="handleError"
:on-exceed="handleExceed"
:before-remove="(file, fileList)=>{beforeRemove(file, fileList, item.key)}"
:limit="item.form_item_type_label==='img'?1:5"
:limit="5"
:ref="'fileUpload_'+item.key"
:data-keyname="item.key"
:file-list="item.value"
@ -416,7 +416,7 @@ export default {
this.$message.error('只允许上传图片')
} else {
const uploadImgKey = that.form[imgKey]
if (!uploadImgKey) {
if (!uploadImgKey || uploadImgKey === '') {
that.form[imgKey] = []
}
// console.log(len)