系统全局配置,支持在页面可视化配置
continuous-integration/drone/push Build is passing Details

main
wangxiaoshuang 2026-08-10 15:56:52 +08:00
parent 2c9c6d45e5
commit 942529718b
10 changed files with 651 additions and 496 deletions

View File

@ -422,4 +422,19 @@ export function updateSystemEmailConfig(data) {
data data
}) })
} }
// 获取前端配置
export function getWebConfigInfo() {
return request({
url: `/DeployConfig/getWebConfigInfo`,
method: 'get'
})
}
// 更新前端配置
export function updateWebConfigInfo(data) {
return request({
url: `/DeployConfig/updateWebConfigInfo`,
method: 'put',
data
})
}

View File

@ -52,8 +52,8 @@ export default {
data() { data() {
return { return {
currentUser: zzSessionStorage.getItem('userName'), currentUser: zzSessionStorage.getItem('userName'),
COMPANY: process.env.VUE_APP_COMPANY_NAME, COMPANY: window.webConfig.VUE_APP_COMPANY_NAME,
onlyOffice_url: process.env.VUE_APP_ONLYOFFICE_URL, onlyOffice_url: window.webConfig.VUE_APP_ONLYOFFICE_URL,
window, window,
} }
}, },

View File

@ -20,7 +20,7 @@ export default {
title: null, title: null,
documentType: null, documentType: null,
currentUser: zzSessionStorage.getItem('userName'), currentUser: zzSessionStorage.getItem('userName'),
onlyOffice_url: process.env.VUE_APP_ONLYOFFICE_URL onlyOffice_url: window.webConfig.VUE_APP_ONLYOFFICE_URL
}; };
}, },
methods: { methods: {

View File

@ -12,7 +12,7 @@ import './assets/css/iconfont/index.css' // 阿里巴巴图标库
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n // import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import i18n from './lang' import i18n from './lang'
import '@/styles/index.scss' // global css import '@/styles/index.scss' // global css
import { getWebConfigInfo } from '@/api/admin'
import App from './App' import App from './App'
import store from './store' import store from './store'
import router from './router' import router from './router'
@ -98,6 +98,13 @@ import DictData from '@/components/DictData'
import { getBasicDataSelect } from '@/api/dictionary/dictionary' import { getBasicDataSelect } from '@/api/dictionary/dictionary'
import { checkConfig } from '@/const/check/index' import { checkConfig } from '@/const/check/index'
import { getTrialBodyPartList } from "@/api/trials/setting"; import { getTrialBodyPartList } from "@/api/trials/setting";
import global_ from './components/Global'
var _vm
getWebConfigInfo().then(res => {
if (res.IsSuccess) {
window.webConfig = JSON.parse(res.Result)
}
// 全局方法挂载 // 全局方法挂载
var $q = params var $q = params
Vue.prototype.checkConfig = checkConfig Vue.prototype.checkConfig = checkConfig
@ -142,7 +149,7 @@ Vue.prototype.getGuid = (text) => {
Vue.prototype.$validatePassword = (rule, value, callback) => { Vue.prototype.$validatePassword = (rule, value, callback) => {
var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh' var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh'
/* eslint-disable */ /* eslint-disable */
var reg1 = eval(process.env.VUE_APP_PASSWORD_FOR_PERMISSION) ? new RegExp(`${process.env.VUE_APP_PASSWORD_FOR_REGULAR}`) : /.*/g; //密码必须是8位以上、必须含有字母、数字、特殊符号 var reg1 = eval(window.webConfig.VUE_APP_PASSWORD_FOR_PERMISSION) ? new RegExp(`${window.webConfig.VUE_APP_PASSWORD_FOR_REGULAR}`) : /.*/g; //密码必须是8位以上、必须含有字母、数字、特殊符号
if (!reg1.test(value)) { if (!reg1.test(value)) {
callback( callback(
new Error(_vm.$t('env:regExp:formatPassword'))) new Error(_vm.$t('env:regExp:formatPassword')))
@ -153,7 +160,7 @@ Vue.prototype.$validatePassword = (rule, value, callback) => {
DictData.install() DictData.install()
import global_ from './components/Global'
Vue.prototype.GLOBAL = global_ Vue.prototype.GLOBAL = global_
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$upload = () => { Vue.prototype.$upload = () => {
@ -184,7 +191,7 @@ Vue.prototype.fileToBlob = (file) => {
}) })
} }
var _vm
async function VueInit() { async function VueInit() {
var params var params
var res var res
@ -365,7 +372,8 @@ async function VueInit() {
var isLock = zzSessionStorage.getItem('isLock') var isLock = zzSessionStorage.getItem('isLock')
var isOpen = false var isOpen = false
let count = 0; let count = 0;
if (eval(process.env.VUE_APP_LOGIN_FOR_PERMISSION)) { console.log(window.webConfig.VUE_APP_LOGIN_FOR_PERMISSION, 'window.webConfig.VUE_APP_LOGIN_FOR_PERMISSION')
if (eval(window.webConfig.VUE_APP_LOGIN_FOR_PERMISSION)) {
setInterval(() => { setInterval(() => {
var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh' var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh'
if (WHITELIST.includes(_vm.$route.path)) { if (WHITELIST.includes(_vm.$route.path)) {
@ -425,12 +433,12 @@ async function VueInit() {
} }
const h = _vm.$createElement const h = _vm.$createElement
/* eslint-disable */ /* eslint-disable */
// eval(process.env.VUE_APP_LOGOUT_FOR_PERMISSION) // eval(window.webConfig.VUE_APP_LOGOUT_FOR_PERMISSION)
// process.env.VUE_APP_LOGOUT_FOR_TIME // window.webConfig.VUE_APP_LOGOUT_FOR_TIME
// eval(process.env.VUE_APP_LOCK_FOR_PERMISSION) // eval(window.webConfig.VUE_APP_LOCK_FOR_PERMISSION)
// process.env.VUE_APP_LOCK_FOR_TIME // window.webConfig.VUE_APP_LOCK_FOR_TIME
// window.VUE_APP_COMPANY_NAME = process.env.VUE_APP_COMPANY_NAME; // window.VUE_APP_COMPANY_NAME = window.webConfig.VUE_APP_COMPANY_NAME;
waitOperate(eval(process.env.VUE_APP_LOGOUT_FOR_PERMISSION) ? () => { waitOperate(eval(window.webConfig.VUE_APP_LOGOUT_FOR_PERMISSION) ? () => {
var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh' var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh'
if (_vm.$store.state.trials.unlock || WHITELIST.includes(_vm.$route.path)) { if (_vm.$store.state.trials.unlock || WHITELIST.includes(_vm.$route.path)) {
count = 0; count = 0;
@ -463,8 +471,8 @@ async function VueInit() {
}) })
}) })
} : () => { }, process.env.VUE_APP_LOGOUT_FOR_TIME, } : () => { }, window.webConfig.VUE_APP_LOGOUT_FOR_TIME,
eval(process.env.VUE_APP_LOCK_FOR_PERMISSION) eval(window.webConfig.VUE_APP_LOCK_FOR_PERMISSION)
? () => { ? () => {
var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh' var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh'
if (_vm.$store.state.trials.unlock || WHITELIST.includes(_vm.$route.path)) { if (_vm.$store.state.trials.unlock || WHITELIST.includes(_vm.$route.path)) {
@ -524,7 +532,7 @@ async function VueInit() {
done() done()
}, 500) }, 500)
} }
// if (eval(process.env.VUE_APP_LOCK_FOR_PERMISSION_MFA)) { // if (eval(window.webConfig.VUE_APP_LOCK_FOR_PERMISSION_MFA)) {
// sendMFAEmail({ UserId: my_userid, MfaType: 1 }).then((res) => { // sendMFAEmail({ UserId: my_userid, MfaType: 1 }).then((res) => {
// done(); // done();
// Vue.prototype.$MFA({ // Vue.prototype.$MFA({
@ -622,14 +630,16 @@ async function VueInit() {
]) ])
}) })
} : () => { }, } : () => { },
process.env.VUE_APP_LOCK_FOR_TIME window.webConfig.VUE_APP_LOCK_FOR_TIME
) )
} }
VueInit() VueInit()
})
// createVersionPolling({ // createVersionPolling({
// appETagKey: "__APP_ETAG__", // appETagKey: "__APP_ETAG__",
// pollingInterval: 5 * 60 * 1000, // 单位为毫秒 // pollingInterval: 5 * 60 * 1000, // 单位为毫秒
// silent: process.env.NODE_ENV === false, // 开发环境下不检测 // silent: window.webConfig.NODE_ENV === false, // 开发环境下不检测
// onUpdate: (self) => { // onUpdate: (self) => {
// // 当检测到有新版本时,执行的回调函数,可以在这里提示用户刷新页面 // // 当检测到有新版本时,执行的回调函数,可以在这里提示用户刷新页面
// const result = confirm(_vm.$t("versionPolling:tip")); // const result = confirm(_vm.$t("versionPolling:tip"));

View File

@ -3,6 +3,59 @@
<div ref="leftContainer" class="left" style="padding: 20px;"> <div ref="leftContainer" class="left" style="padding: 20px;">
<el-form :inline="true" :model="form" :rules="rules" ref="systemConfigForm" <el-form :inline="true" :model="form" :rules="rules" ref="systemConfigForm"
style="display: flex;align-items: center;justify-content: space-between;flex-wrap: wrap;"> style="display: flex;align-items: center;justify-content: space-between;flex-wrap: wrap;">
<h3>{{ $t("system:config:WebConfig") }}</h3>
<el-form-item :label="$t('system:config:VUE_APP_ONLYOFFICE_URL')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_ONLYOFFICE_URL">
<el-input v-model="form.WebConfigInfo.VUE_APP_ONLYOFFICE_URL" clearable />
</el-form-item>
<el-form-item :label="$t('system:config:VUE_APP_LOGIN_FOR_PERMISSION')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_LOGIN_FOR_PERMISSION">
<el-select v-model="form.WebConfigInfo.VUE_APP_LOGIN_FOR_PERMISSION" placeholder="">
<el-option v-for="item in $d.YesOrNo" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('system:config:VUE_APP_LOCK_FOR_PERMISSION_MFA')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_LOCK_FOR_PERMISSION_MFA">
<el-select v-model="form.WebConfigInfo.VUE_APP_LOCK_FOR_PERMISSION_MFA" placeholder="">
<el-option v-for="item in $d.YesOrNo" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('system:config:VUE_APP_LOCK_FOR_PERMISSION')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_LOCK_FOR_PERMISSION">
<el-select v-model="form.WebConfigInfo.VUE_APP_LOCK_FOR_PERMISSION" placeholder="">
<el-option v-for="item in $d.YesOrNo" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('system:config:VUE_APP_LOCK_FOR_TIME')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_LOCK_FOR_TIME">
<el-input-number v-model="form.WebConfigInfo.VUE_APP_LOCK_FOR_TIME" clearable type="number" />
</el-form-item>
<el-form-item :label="$t('system:config:VUE_APP_LOGOUT_FOR_PERMISSION')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_LOGOUT_FOR_PERMISSION">
<el-select v-model="form.WebConfigInfo.VUE_APP_LOGOUT_FOR_PERMISSION" placeholder="">
<el-option v-for="item in $d.YesOrNo" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('system:config:VUE_APP_LOGOUT_FOR_TIME')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_LOGOUT_FOR_TIME">
<el-input-number v-model="form.WebConfigInfo.VUE_APP_LOGOUT_FOR_TIME" clearable type="number" />
</el-form-item>
<el-form-item :label="$t('system:config:VUE_APP_PASSWORD_FOR_PERMISSION')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_PASSWORD_FOR_PERMISSION">
<el-select v-model="form.WebConfigInfo.VUE_APP_PASSWORD_FOR_PERMISSION" placeholder="">
<el-option v-for="item in $d.YesOrNo" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<!-- <el-form-item :label="$t('system:config:VUE_APP_WORD_FOR_PERMISSION')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_WORD_FOR_PERMISSION">
<el-select v-model="form.WebConfigInfo.VUE_APP_WORD_FOR_PERMISSION" placeholder="">
<el-option v-for="item in $d.YesOrNo" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item> -->
<el-form-item :label="$t('system:config:VUE_APP_COMPANY_NAME')" style="width: 45%;"
prop="WebConfigInfo.VUE_APP_COMPANY_NAME">
<el-input v-model="form.WebConfigInfo.VUE_APP_COMPANY_NAME" clearable />
</el-form-item>
<h3>{{ $t("system:config:BasicSystemConfig") }}</h3> <h3>{{ $t("system:config:BasicSystemConfig") }}</h3>
<el-form-item :label="$t('system:config:QcRiskControl')" style="width: 45%;"> <el-form-item :label="$t('system:config:QcRiskControl')" style="width: 45%;">
<el-select v-model="form.BasicSystemConfig.QCRiskControl" placeholder=""> <el-select v-model="form.BasicSystemConfig.QCRiskControl" placeholder="">
@ -84,7 +137,7 @@
<el-input v-model="form.SystemEmailSendConfig.Port" clearable type="number" /> <el-input v-model="form.SystemEmailSendConfig.Port" clearable type="number" />
</el-form-item> </el-form-item>
<el-form-item :label="$t('system:config:Imap')" style="width: 45%;" prop="SystemEmailSendConfig.Imap"> <el-form-item :label="$t('system:config:Imap')" style="width: 45%;" prop="SystemEmailSendConfig.Imap">
<el-input v-model="form.SystemEmailSendConfig.Imap" clearable /> <el-input v-model="form.SystemEmailSendConfig.Imap" clearable />http://localhost:8080/trials/trials-list
</el-form-item> </el-form-item>
<el-form-item :label="$t('system:config:ImapPort')" style="width: 45%;" prop="SystemEmailSendConfig.ImapPort"> <el-form-item :label="$t('system:config:ImapPort')" style="width: 45%;" prop="SystemEmailSendConfig.ImapPort">
<el-input v-model="form.SystemEmailSendConfig.ImapPort" clearable type="number" /> <el-input v-model="form.SystemEmailSendConfig.ImapPort" clearable type="number" />
@ -157,7 +210,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getSystemBasicConfigInfo, getEmailConfigInfo, updateSystemBasicConfig, updateSystemEmailConfig } from '@/api/admin' import { getSystemBasicConfigInfo, getEmailConfigInfo, updateSystemBasicConfig, updateSystemEmailConfig, getWebConfigInfo, updateWebConfigInfo } from '@/api/admin'
export default { export default {
name: "systemConfig", name: "systemConfig",
data() { data() {
@ -255,8 +308,53 @@ export default {
'SystemEmailSendConfig.EmailRegexStr': [ 'SystemEmailSendConfig.EmailRegexStr': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' } { required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
], ],
'WebConfigInfo.VUE_APP_ONLYOFFICE_URL': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
],
'WebConfigInfo.VUE_APP_LOGIN_FOR_PERMISSION': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
],
'WebConfigInfo.VUE_APP_LOCK_FOR_PERMISSION_MFA': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
],
'WebConfigInfo.VUE_APP_LOCK_FOR_PERMISSION': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
],
'WebConfigInfo.VUE_APP_LOCK_FOR_TIME': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' },
{ type: 'number', message: this.$t('systemConfig:ruleMessage:mustNumber'), trigger: 'blur' },
],
'WebConfigInfo.VUE_APP_LOGOUT_FOR_PERMISSION': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
],
'WebConfigInfo.VUE_APP_LOGOUT_FOR_TIME': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' },
{ type: 'number', message: this.$t('systemConfig:ruleMessage:mustNumber'), trigger: 'blur' },
],
'WebConfigInfo.VUE_APP_PASSWORD_FOR_PERMISSION': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
],
// 'WebConfigInfo.VUE_APP_WORD_FOR_PERMISSION': [
// { required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
// ],
'WebConfigInfo.VUE_APP_COMPANY_NAME': [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
],
}, },
form: { form: {
WebConfigInfo: {
VUE_APP_ONLYOFFICE_URL: '', // onlyoffice
VUE_APP_LOGIN_FOR_PERMISSION: false, //
VUE_APP_LOCK_FOR_PERMISSION_MFA: false,// MFA
VUE_APP_LOCK_FOR_PERMISSION: false, //
VUE_APP_LOCK_FOR_TIME: 900, //
VUE_APP_LOGOUT_FOR_PERMISSION: false,//
VUE_APP_LOGOUT_FOR_TIME: 1800, //
VUE_APP_PASSWORD_FOR_PERMISSION: false, //
// VUE_APP_WORD_FOR_PERMISSION: false, // ,
VUE_APP_COMPANY_NAME: '', //
},
"BasicSystemConfig": { "BasicSystemConfig": {
// //
"QCRiskControl": true, "QCRiskControl": true,
@ -340,14 +438,14 @@ export default {
methods: { methods: {
handleSave() { handleSave() {
this.loading = true this.loading = true
Promise.all([this.updateSystemBasicConfig(), this.updateSystemEmailConfig()]).then(res => { Promise.all([this.updateSystemBasicConfig(), this.updateSystemEmailConfig(), this.updateWebConfigInfo()]).then(res => {
this.loading = false this.loading = false
this.getInfo() // this.getInfo()
}) })
}, },
getInfo() { getInfo() {
this.loading = true this.loading = true
Promise.all([this.getSystemBasicConfigInfo(), this.getEmailConfigInfo()]).then(res => { Promise.all([this.getSystemBasicConfigInfo(), this.getEmailConfigInfo(), this.getWebConfigInfo()]).then(res => {
this.loading = false this.loading = false
}) })
}, },
@ -383,6 +481,38 @@ export default {
console.log(err) console.log(err)
} }
}, },
async updateWebConfigInfo() {
try {
let validate = await this.$refs.systemConfigForm.validate()
if (!validate) return false
let data = {}
Object.keys(this.form.WebConfigInfo).forEach(key => {
data[key] = this.form.WebConfigInfo[key]
})
let res = await updateWebConfigInfo({
configStr: JSON.stringify(data)
})
if (res.IsSuccess) {
}
} catch (err) {
console.log(err)
}
},
async getWebConfigInfo() {
try {
let res = await getWebConfigInfo()
if (res.IsSuccess) {
let data = res.Result ? JSON.parse(res.Result) : {}
Object.keys(this.form.WebConfigInfo).forEach(key => {
this.form.WebConfigInfo[key] = data[key] ? data[key] : this.form.WebConfigInfo[key]
})
}
} catch (err) {
this.loading = false
console.log(err)
}
},
async getSystemBasicConfigInfo() { async getSystemBasicConfigInfo() {
try { try {
let res = await getSystemBasicConfigInfo() let res = await getSystemBasicConfigInfo()

View File

@ -217,7 +217,7 @@ export default {
moment, moment,
loading: false, loading: false,
currentUser: zzSessionStorage.getItem('userName'), currentUser: zzSessionStorage.getItem('userName'),
COMPANY:process.env.VUE_APP_COMPANY_NAME COMPANY:window.webConfig.VUE_APP_COMPANY_NAME
} }
}, },
mounted() { mounted() {

View File

@ -46,7 +46,7 @@ export default {
fileList: [], fileList: [],
loading: false, loading: false,
currentUser: zzSessionStorage.getItem('userName'), currentUser: zzSessionStorage.getItem('userName'),
COMPANY: process.env.VUE_APP_COMPANY_NAME COMPANY: window.webConfig.VUE_APP_COMPANY_NAME
} }
}, },
mounted() { mounted() {

View File

@ -46,7 +46,7 @@ export default {
fileList: [], fileList: [],
loading: false, loading: false,
currentUser: zzSessionStorage.getItem('userName'), currentUser: zzSessionStorage.getItem('userName'),
COMPANY: process.env.VUE_APP_COMPANY_NAME COMPANY: window.webConfig.VUE_APP_COMPANY_NAME
} }
}, },
mounted() { mounted() {

View File

@ -33,7 +33,7 @@ export default {
data() { data() {
return { return {
currentUser: zzSessionStorage.getItem('userName'), currentUser: zzSessionStorage.getItem('userName'),
COMPANY:process.env.VUE_APP_COMPANY_NAME COMPANY:window.webConfig.VUE_APP_COMPANY_NAME
} }
}, },
methods: { methods: {

View File

@ -46,7 +46,7 @@ export default {
fileList: [], fileList: [],
loading: false, loading: false,
currentUser: zzSessionStorage.getItem('userName'), currentUser: zzSessionStorage.getItem('userName'),
COMPANY: process.env.VUE_APP_COMPANY_NAME COMPANY: window.webConfig.VUE_APP_COMPANY_NAME
} }
}, },
mounted() { mounted() {