Merge remote-tracking branch 'origin/v2.x' into v2.x
commit
1324924fb2
|
@ -36,7 +36,10 @@ def _get_all_system_config():
|
||||||
system_config_obj = SystemConfig.objects.filter(status=True, parent_id__isnull=False).values(
|
system_config_obj = SystemConfig.objects.filter(status=True, parent_id__isnull=False).values(
|
||||||
'parent__key', 'key', 'value', 'form_item_type').order_by('sort')
|
'parent__key', 'key', 'value', 'form_item_type').order_by('sort')
|
||||||
for system_config in system_config_obj:
|
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
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,6 +89,7 @@ def refresh_dictionary():
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if is_tenants_mode():
|
if is_tenants_mode():
|
||||||
|
from django_tenants.utils import schema_context
|
||||||
with schema_context(connection.tenant.schema_name):
|
with schema_context(connection.tenant.schema_name):
|
||||||
settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary()
|
settings.DICTIONARY_CONFIG[connection.tenant.schema_name] = _get_all_dictionary()
|
||||||
else:
|
else:
|
||||||
|
@ -98,6 +102,7 @@ def refresh_system_config():
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if is_tenants_mode():
|
if is_tenants_mode():
|
||||||
|
from django_tenants.utils import schema_context
|
||||||
with schema_context(connection.tenant.schema_name):
|
with schema_context(connection.tenant.schema_name):
|
||||||
settings.SYSTEM_CONFIG[connection.tenant.schema_name] = _get_all_system_config()
|
settings.SYSTEM_CONFIG[connection.tenant.schema_name] = _get_all_system_config()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -2169,7 +2169,7 @@ system_config_data = [
|
||||||
"create_datetime": datetime.datetime.now(),
|
"create_datetime": datetime.datetime.now(),
|
||||||
"title": "登录网站logo",
|
"title": "登录网站logo",
|
||||||
"key": "site_logo",
|
"key": "site_logo",
|
||||||
"value": "[]",
|
"value": None,
|
||||||
"sort": 2,
|
"sort": 2,
|
||||||
"status": 1,
|
"status": 1,
|
||||||
"data_options": None,
|
"data_options": None,
|
||||||
|
|
|
@ -15,6 +15,8 @@ from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
|
||||||
from rest_framework_simplejwt.views import TokenObtainPairView
|
from rest_framework_simplejwt.views import TokenObtainPairView
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
from application import dispatch
|
||||||
from dvadmin.system.models import Users
|
from dvadmin.system.models import Users
|
||||||
from dvadmin.utils.json_response import ErrorResponse, DetailResponse
|
from dvadmin.utils.json_response import ErrorResponse, DetailResponse
|
||||||
from dvadmin.utils.request_util import save_login_log
|
from dvadmin.utils.request_util import save_login_log
|
||||||
|
@ -34,7 +36,7 @@ class CaptchaView(APIView):
|
||||||
)
|
)
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
data = {}
|
data = {}
|
||||||
if settings.SYSTEM_CONFIG.get("base.captcha_state"):
|
if dispatch.get_system_config_values("base.captcha_state"):
|
||||||
hashkey = CaptchaStore.generate_key()
|
hashkey = CaptchaStore.generate_key()
|
||||||
id = CaptchaStore.objects.filter(hashkey=hashkey).first().id
|
id = CaptchaStore.objects.filter(hashkey=hashkey).first().id
|
||||||
imgage = captcha_image(request, hashkey)
|
imgage = captcha_image(request, hashkey)
|
||||||
|
@ -66,7 +68,7 @@ class LoginSerializer(TokenObtainPairSerializer):
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
captcha = self.initial_data.get("captcha", None)
|
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:
|
if captcha is None:
|
||||||
raise CustomValidationError("验证码不能为空")
|
raise CustomValidationError("验证码不能为空")
|
||||||
self.image_code = CaptchaStore.objects.filter(
|
self.image_code = CaptchaStore.objects.filter(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from application import settings
|
from application import settings, dispatch
|
||||||
from django.contrib.auth.hashers import make_password
|
from django.contrib.auth.hashers import make_password
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
|
@ -252,7 +252,7 @@ class UserViewSet(CustomModelViewSet):
|
||||||
"""恢复默认密码"""
|
"""恢复默认密码"""
|
||||||
instance = Users.objects.filter(id=kwargs.get("pk")).first()
|
instance = Users.objects.filter(id=kwargs.get("pk")).first()
|
||||||
if instance:
|
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()
|
instance.save()
|
||||||
return DetailResponse(data=None, msg="密码重置成功")
|
return DetailResponse(data=None, msg="密码重置成功")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -18,6 +18,7 @@ import XEUtils from 'xe-utils'
|
||||||
import store from '@/store/index'
|
import store from '@/store/index'
|
||||||
import { urlPrefix as deptPrefix } from '@/views/system/dept/api'
|
import { urlPrefix as deptPrefix } from '@/views/system/dept/api'
|
||||||
import types from '@/config/d2p-extends/types'
|
import types from '@/config/d2p-extends/types'
|
||||||
|
import { checkPlugins } from '@/views/plugins'
|
||||||
const uploadUrl = util.baseURL() + 'api/system/file/'
|
const uploadUrl = util.baseURL() + 'api/system/file/'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +35,11 @@ Vue.use(d2CrudX, { name: 'd2-crud-x' })
|
||||||
|
|
||||||
// // 官方版【此处为演示与官方版共存而引入,全新项目中可以用d2-crud-x完全替代官方版】
|
// // 官方版【此处为演示与官方版共存而引入,全新项目中可以用d2-crud-x完全替代官方版】
|
||||||
// Vue.use(d2Crud)
|
// Vue.use(d2Crud)
|
||||||
|
/**
|
||||||
|
* @description 校验插件是否安装
|
||||||
|
* @param {String} pluginName 插件名称
|
||||||
|
*/
|
||||||
|
Vue.prototype.checkPlugins = checkPlugins
|
||||||
// 引入d2CrudPlus
|
// 引入d2CrudPlus
|
||||||
Vue.use(d2CrudPlus, {
|
Vue.use(d2CrudPlus, {
|
||||||
starTip: false,
|
starTip: false,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import cookies from './util.cookies'
|
import cookies from './util.cookies'
|
||||||
import db from './util.db'
|
import db from './util.db'
|
||||||
import log from './util.log'
|
import log from './util.log'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
const util = {
|
const util = {
|
||||||
cookies,
|
cookies,
|
||||||
db,
|
db,
|
||||||
|
@ -34,7 +36,7 @@ util.open = function (url) {
|
||||||
*/
|
*/
|
||||||
util.baseURL = function () {
|
util.baseURL = function () {
|
||||||
var baseURL = process.env.VUE_APP_API
|
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
|
// document.domain
|
||||||
var host = baseURL.split('/')[2]
|
var host = baseURL.split('/')[2]
|
||||||
var prot = host.split(':')[1] || 80
|
var prot = host.split(':')[1] || 80
|
||||||
|
@ -46,5 +48,33 @@ util.baseURL = function () {
|
||||||
}
|
}
|
||||||
return baseURL
|
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
|
export default util
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-form ref="form" :model="form" label-width="140px" label-position="left" style="margin-top: 20px">
|
<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"
|
<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"
|
v-for="(item,index) in formList"
|
||||||
|
|
||||||
>
|
>
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
:on-error="handleError"
|
:on-error="handleError"
|
||||||
:on-exceed="handleExceed"
|
:on-exceed="handleExceed"
|
||||||
:before-remove="(file, fileList)=>{beforeRemove(file, fileList, item.key)}"
|
:before-remove="(file, fileList)=>{beforeRemove(file, fileList, item.key)}"
|
||||||
:limit="item.form_item_type_label==='img'?1:5"
|
:limit="5"
|
||||||
:ref="'fileUpload_'+item.key"
|
:ref="'fileUpload_'+item.key"
|
||||||
:data-keyname="item.key"
|
:data-keyname="item.key"
|
||||||
:file-list="item.value"
|
:file-list="item.value"
|
||||||
|
@ -416,7 +416,7 @@ export default {
|
||||||
this.$message.error('只允许上传图片')
|
this.$message.error('只允许上传图片')
|
||||||
} else {
|
} else {
|
||||||
const uploadImgKey = that.form[imgKey]
|
const uploadImgKey = that.form[imgKey]
|
||||||
if (!uploadImgKey) {
|
if (!uploadImgKey || uploadImgKey === '') {
|
||||||
that.form[imgKey] = []
|
that.form[imgKey] = []
|
||||||
}
|
}
|
||||||
// console.log(len)
|
// console.log(len)
|
||||||
|
|
Loading…
Reference in New Issue