forked from github/dataease
Merge pull request #6821 from dataease/pr@dev-v2@feat_basic_setting
feat: 系统参数-基础设置
This commit is contained in:
commit
a73848f3d8
@ -1,15 +1,17 @@
|
||||
package io.dataease.system.manage;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.dataease.api.system.vo.SettingItemVO;
|
||||
import io.dataease.system.dao.auto.entity.CoreSysSetting;
|
||||
import io.dataease.system.dao.auto.mapper.CoreSysSettingMapper;
|
||||
import io.dataease.system.dao.ext.mapper.ExtCoreSysSettingMapper;
|
||||
import io.dataease.utils.BeanUtils;
|
||||
import io.dataease.utils.IDUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@ -22,6 +24,9 @@ public class SysParameterManage {
|
||||
@Resource
|
||||
private CoreSysSettingMapper coreSysSettingMapper;
|
||||
|
||||
@Resource
|
||||
private ExtCoreSysSettingMapper extCoreSysSettingMapper;
|
||||
|
||||
public String singleVal(String key) {
|
||||
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("pkey", key);
|
||||
@ -53,22 +58,39 @@ public class SysParameterManage {
|
||||
sysSetting.setPval(val);
|
||||
coreSysSettingMapper.updateById(sysSetting);
|
||||
}
|
||||
void save(List<CoreSysSetting> boList) {
|
||||
List<CoreSysSetting> all = all();
|
||||
}
|
||||
|
||||
private List<CoreSysSetting> all() {
|
||||
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
|
||||
return coreSysSettingMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
public Map<String,String> groupVal(String groupKey) {
|
||||
public Map<String, String> groupVal(String groupKey) {
|
||||
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like("pkey", groupKey);
|
||||
queryWrapper.likeRight("pkey", groupKey);
|
||||
queryWrapper.orderByAsc("sort");
|
||||
List<CoreSysSetting> sysSettings = coreSysSettingMapper.selectList(queryWrapper);
|
||||
if (!CollectionUtils.isEmpty(sysSettings)) {
|
||||
return sysSettings.stream().collect(Collectors.toMap(CoreSysSetting::getPkey, CoreSysSetting::getPval));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<SettingItemVO> groupList(String groupKey) {
|
||||
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.likeRight("pkey", groupKey);
|
||||
queryWrapper.orderByAsc("sort");
|
||||
List<CoreSysSetting> sysSettings = coreSysSettingMapper.selectList(queryWrapper);
|
||||
if (!CollectionUtils.isEmpty(sysSettings)) {
|
||||
return sysSettings.stream().map(item -> BeanUtils.copyBean(new SettingItemVO(), item)).toList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveGroup(List<SettingItemVO> vos, String groupKey) {
|
||||
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.likeRight("pkey", groupKey);
|
||||
coreSysSettingMapper.delete(queryWrapper);
|
||||
List<CoreSysSetting> sysSettings = vos.stream().map(item -> {
|
||||
CoreSysSetting sysSetting = BeanUtils.copyBean(new CoreSysSetting(), item);
|
||||
sysSetting.setId(IDUtils.snowID());
|
||||
return sysSetting;
|
||||
}).collect(Collectors.toList());
|
||||
extCoreSysSettingMapper.saveBatch(sysSettings);
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,15 @@ package io.dataease.system.server;
|
||||
|
||||
import io.dataease.api.system.SysParameterApi;
|
||||
import io.dataease.api.system.request.OnlineMapEditor;
|
||||
import io.dataease.api.system.vo.SettingItemVO;
|
||||
import io.dataease.system.manage.SysParameterManage;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sysParameter")
|
||||
public class SysParameterServer implements SysParameterApi {
|
||||
@ -29,4 +32,15 @@ public class SysParameterServer implements SysParameterApi {
|
||||
String key = sysParameterManage.queryOnlineMap();
|
||||
return StringUtils.isNotBlank(key) ? key : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SettingItemVO> queryBasicSetting() {
|
||||
String key = "basic.";
|
||||
return sysParameterManage.groupList(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveBasicSetting(List<SettingItemVO> settingItemVOS) {
|
||||
sysParameterManage.saveGroup(settingItemVOS, "basic.");
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,9 @@
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<span v-else-if="item.pkey === '数据源检测时间间隔'">
|
||||
<span>{{ item.pval + ' ' + executeTime + '执行一次' }}</span>
|
||||
</span>
|
||||
<span v-else>{{ item.pval }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -62,22 +65,35 @@ const props = defineProps({
|
||||
default: '基础设置'
|
||||
}
|
||||
})
|
||||
|
||||
const executeTime = ref('0分0秒')
|
||||
const curTitle = computed(() => {
|
||||
return props.settingTitle
|
||||
})
|
||||
|
||||
const loadList = () => {
|
||||
settingList.value = []
|
||||
if (props.settingData?.length) {
|
||||
props.settingData.forEach(item => {
|
||||
settingList.value.push(item)
|
||||
if (item.pkey === '数据源检测频率') {
|
||||
executeTime.value = getExecuteTime(item.pval)
|
||||
} else {
|
||||
settingList.value.push(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const getExecuteTime = val => {
|
||||
const options = [
|
||||
{ value: 'minute', label: '分钟(执行时间:0秒)' },
|
||||
{ value: 'hour', label: '小时(执行时间:0分0秒)' }
|
||||
]
|
||||
return options.filter(item => item.value === val)[0].label
|
||||
}
|
||||
|
||||
const settingList = ref([] as SettingRecord[])
|
||||
|
||||
const loadBasic = () => {
|
||||
/* const loadBasic = () => {
|
||||
settingList.value.push({
|
||||
pkey: '请求超时时间',
|
||||
pval: '100',
|
||||
@ -147,15 +163,9 @@ const loadEmail = () => {
|
||||
type: 'text',
|
||||
sort: 7
|
||||
})
|
||||
}
|
||||
} */
|
||||
|
||||
const init = () => {
|
||||
if (props.settingKey === 'basic') {
|
||||
loadBasic()
|
||||
}
|
||||
if (props.settingKey === 'email') {
|
||||
loadEmail()
|
||||
}
|
||||
if (props.settingData?.length) {
|
||||
loadList()
|
||||
}
|
||||
@ -186,6 +196,9 @@ const emits = defineEmits(['edit'])
|
||||
const edit = () => {
|
||||
emits('edit')
|
||||
}
|
||||
defineExpose({
|
||||
init
|
||||
})
|
||||
init()
|
||||
formatPwd()
|
||||
formatLabel()
|
||||
|
@ -3,51 +3,82 @@ import { ref, reactive } from 'vue'
|
||||
import { ElMessage, ElLoading } from 'element-plus-secondary'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import type { FormInstance, FormRules } from 'element-plus-secondary'
|
||||
|
||||
import request from '@/config/axios'
|
||||
const { t } = useI18n()
|
||||
const dialogVisible = ref(false)
|
||||
const loadingInstance = ref(null)
|
||||
const createUserForm = ref<FormInstance>()
|
||||
const basicForm = ref<FormInstance>()
|
||||
const options = [
|
||||
{ value: 'minute', label: '分钟(执行时间:0秒)' },
|
||||
{ value: 'hour', label: '小时(执行时间:0分0秒)' }
|
||||
]
|
||||
interface BasicFrom {
|
||||
autoCreateUser?: boolean
|
||||
dsIntervalTime?: string
|
||||
dsExecuteTime?: string
|
||||
}
|
||||
const state = reactive({
|
||||
roleList: [],
|
||||
form: reactive<UserForm>({
|
||||
id: null,
|
||||
account: null,
|
||||
name: null,
|
||||
email: null,
|
||||
enable: true,
|
||||
phone: null,
|
||||
phonePrefix: '+86',
|
||||
roleIds: []
|
||||
form: reactive<BasicFrom>({
|
||||
autoCreateUser: false,
|
||||
dsIntervalTime: '30',
|
||||
dsExecuteTime: 'minute'
|
||||
})
|
||||
})
|
||||
|
||||
const rule = reactive<FormRules>({})
|
||||
const rule = reactive<FormRules>({
|
||||
dsIntervalTime: [
|
||||
{
|
||||
required: true,
|
||||
message: t('common.require'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const edit = () => {
|
||||
const edit = row => {
|
||||
state.form = {
|
||||
autoCreateUser: row.autoCreateUser === 'true',
|
||||
dsIntervalTime: row.dsIntervalTime,
|
||||
dsExecuteTime: row.dsExecuteTime
|
||||
}
|
||||
dialogVisible.value = true
|
||||
// queryForm()
|
||||
}
|
||||
/* const queryForm = () => {
|
||||
showLoading()
|
||||
personInfoApi().then(res => {
|
||||
state.form = reactive<UserForm>(res.data)
|
||||
closeLoading()
|
||||
})
|
||||
} */
|
||||
|
||||
const emits = defineEmits(['saved'])
|
||||
|
||||
const buildSettingList = () => {
|
||||
const param = { ...state.form }
|
||||
const item0 = {
|
||||
pkey: 'basic.autoCreateUser',
|
||||
pval: param.autoCreateUser.toString(),
|
||||
type: 'text',
|
||||
sort: 1
|
||||
}
|
||||
const item1 = {
|
||||
pkey: 'basic.dsIntervalTime',
|
||||
pval: param.dsIntervalTime,
|
||||
type: 'text',
|
||||
sort: 2
|
||||
}
|
||||
const item2 = {
|
||||
pkey: 'basic.dsExecuteTime',
|
||||
pval: param.dsExecuteTime,
|
||||
type: 'text',
|
||||
sort: 3
|
||||
}
|
||||
return [item0, item1, item2]
|
||||
}
|
||||
const submitForm = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return
|
||||
await formEl.validate((valid, fields) => {
|
||||
if (valid) {
|
||||
const param = { ...state.form }
|
||||
const method = null
|
||||
const param = buildSettingList()
|
||||
showLoading()
|
||||
method(param)
|
||||
request
|
||||
.post({ url: '/sysParameter/basic/save', data: param })
|
||||
.then(res => {
|
||||
if (!res.msg) {
|
||||
ElMessage.success(t('common.save_success'))
|
||||
|
||||
emits('saved')
|
||||
reset()
|
||||
}
|
||||
@ -69,7 +100,7 @@ const resetForm = (formEl: FormInstance | undefined) => {
|
||||
}
|
||||
|
||||
const reset = () => {
|
||||
resetForm(createUserForm.value)
|
||||
resetForm(basicForm.value)
|
||||
}
|
||||
|
||||
const showLoading = () => {
|
||||
@ -92,32 +123,46 @@ defineExpose({
|
||||
direction="rtl"
|
||||
>
|
||||
<el-form
|
||||
ref="createUserForm"
|
||||
ref="basicForm"
|
||||
require-asterisk-position="right"
|
||||
:model="state.form"
|
||||
:rules="rule"
|
||||
label-width="80px"
|
||||
label-position="top"
|
||||
>
|
||||
<el-form-item label="请求超时时间" prop="name">
|
||||
<el-input
|
||||
v-model="state.form.name"
|
||||
:placeholder="t('common.please_input') + t('user.name')"
|
||||
/>
|
||||
<el-form-item label="禁止扫码创建用户" prop="autoCreateUser">
|
||||
<el-switch v-model="state.form.autoCreateUser" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="数据源检测时间间隔" prop="account">
|
||||
<el-input
|
||||
v-model="state.form.account"
|
||||
:placeholder="t('common.please_input') + t('common.account')"
|
||||
disabled
|
||||
/>
|
||||
<el-form-item label="数据源检测时间间隔" prop="dsIntervalTime">
|
||||
<div class="ds-task-form-inline">
|
||||
<span>每</span>
|
||||
<el-input-number
|
||||
v-model="state.form.dsIntervalTime"
|
||||
autocomplete="off"
|
||||
step-strictly
|
||||
class="text-left"
|
||||
:min="1"
|
||||
:placeholder="t('common.inputText')"
|
||||
controls-position="right"
|
||||
type="number"
|
||||
/>
|
||||
<el-select v-model="state.form.dsExecuteTime">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<span class="ds-span">执行一次</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="resetForm(createUserForm)">{{ t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="submitForm(createUserForm)">
|
||||
<el-button @click="resetForm(basicForm)">{{ t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="submitForm(basicForm)">
|
||||
{{ t('commons.save') }}
|
||||
</el-button>
|
||||
</span>
|
||||
@ -125,47 +170,22 @@ defineExpose({
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<style lang="less">
|
||||
.basic-info-drawer {
|
||||
.editer-form-title {
|
||||
width: 100%;
|
||||
border-radius: 4px;
|
||||
background: #e1eaff;
|
||||
margin: -8px 0 16px 0;
|
||||
height: 40px;
|
||||
padding-left: 16px;
|
||||
|
||||
i {
|
||||
color: #3370ff;
|
||||
font-size: 14.666666030883789px;
|
||||
}
|
||||
|
||||
.pwd {
|
||||
font-family: PingFang SC;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.pwd {
|
||||
margin: 0 8px;
|
||||
color: #1f2329;
|
||||
<style scoped lang="less">
|
||||
.ds-task-form-inline {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
.ed-input-number {
|
||||
width: 140px;
|
||||
margin: 0 6px;
|
||||
}
|
||||
.ed-select {
|
||||
width: 240px;
|
||||
:deep(.ed-input) {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
.input-with-select {
|
||||
.ed-input-group__prepend {
|
||||
width: 72px;
|
||||
background-color: #fff;
|
||||
padding: 0 20px;
|
||||
color: #1f2329;
|
||||
text-align: center;
|
||||
font-family: PingFang SC;
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
}
|
||||
span.ds-span {
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -1,27 +1,81 @@
|
||||
<template>
|
||||
<InfoTemplate
|
||||
ref="infoTemplate"
|
||||
:label-tooltips="tooltips"
|
||||
setting-key="basic"
|
||||
setting-title="基础设置"
|
||||
:setting-data="state.templateList"
|
||||
@edit="edit"
|
||||
/>
|
||||
<basic-edit ref="editor" />
|
||||
<basic-edit ref="editor" @saved="refresh" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import InfoTemplate from '../../common/InfoTemplate.vue'
|
||||
import BasicEdit from './BasicEdit.vue'
|
||||
|
||||
import request from '@/config/axios'
|
||||
import { SettingRecord } from '@/views/system/common/SettingTemplate'
|
||||
import { reactive } from 'vue'
|
||||
const editor = ref()
|
||||
const infoTemplate = ref()
|
||||
const tooltips = [
|
||||
{
|
||||
key: '请求超时时间',
|
||||
val: '请求超时时间(单位:秒,注意:保存后刷新浏览器生效)'
|
||||
}
|
||||
]
|
||||
const state = reactive({
|
||||
templateList: [
|
||||
{
|
||||
pkey: '禁止扫码创建用户',
|
||||
pval: '未开启',
|
||||
type: 'text',
|
||||
sort: 1
|
||||
},
|
||||
{
|
||||
pkey: '数据源检测时间间隔',
|
||||
pval: '100',
|
||||
type: 'text',
|
||||
sort: 2
|
||||
},
|
||||
{
|
||||
pkey: '数据源检测频率',
|
||||
pval: 'minute',
|
||||
type: 'text',
|
||||
sort: 3
|
||||
}
|
||||
] as SettingRecord[]
|
||||
})
|
||||
|
||||
const search = cb => {
|
||||
const url = '/sysParameter/basic/query'
|
||||
request.get({ url }).then(res => {
|
||||
const data = res.data
|
||||
for (let index = 0; index < data.length; index++) {
|
||||
const item = data[index]
|
||||
if (index === 0) {
|
||||
state.templateList[index].pval = item.pval === 'true' ? '开启' : '未开启'
|
||||
} else {
|
||||
state.templateList[index].pval = item.pval
|
||||
}
|
||||
}
|
||||
cb && cb()
|
||||
})
|
||||
}
|
||||
const refresh = () => {
|
||||
search(() => {
|
||||
infoTemplate?.value.init()
|
||||
})
|
||||
}
|
||||
search(null)
|
||||
|
||||
const edit = () => {
|
||||
editor?.value.edit()
|
||||
const param = {
|
||||
autoCreateUser: state.templateList[0].pval === '开启' ? 'true' : 'false',
|
||||
dsIntervalTime: state.templateList[1].pval,
|
||||
dsExecuteTime: state.templateList[2].pval
|
||||
}
|
||||
editor?.value.edit(param)
|
||||
}
|
||||
</script>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<div class="container-sys-param">
|
||||
<map-setting v-if="activeName === 'map'" />
|
||||
<basic-info v-if="activeName === 'basic'" />
|
||||
<email-info v-if="activeName === 'email'" />
|
||||
<!-- <email-info v-if="activeName === 'email'" /> -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -17,12 +17,12 @@ import { ref } from 'vue'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import MapSetting from './map/MapSetting.vue'
|
||||
import BasicInfo from './basic/BasicInfo.vue'
|
||||
import EmailInfo from './email/EmailInfo.vue'
|
||||
/* import EmailInfo from './email/EmailInfo.vue' */
|
||||
const { t } = useI18n()
|
||||
|
||||
const tabArray = [
|
||||
{ label: '基础设置', name: 'basic' },
|
||||
{ label: '邮件设置', name: 'email' },
|
||||
/* { label: '邮件设置', name: 'email' }, */
|
||||
{ label: '地图设置', name: 'map' }
|
||||
/* {label: '引擎设置', name: 'engine'}, */
|
||||
]
|
||||
|
@ -1,11 +1,14 @@
|
||||
package io.dataease.api.system;
|
||||
|
||||
import io.dataease.api.system.request.OnlineMapEditor;
|
||||
import io.dataease.api.system.vo.SettingItemVO;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysParameterApi {
|
||||
|
||||
@GetMapping("/singleVal/{key}")
|
||||
@ -17,4 +20,10 @@ public interface SysParameterApi {
|
||||
@GetMapping("/queryOnlineMap")
|
||||
String queryOnlineMap();
|
||||
|
||||
@GetMapping("basic/query")
|
||||
List<SettingItemVO> queryBasicSetting();
|
||||
|
||||
@PostMapping("/basic/save")
|
||||
void saveBasicSetting(@RequestBody List<SettingItemVO> settingItemVOS);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package io.dataease.api.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SettingItemVO implements Serializable {
|
||||
|
||||
private String pkey;
|
||||
|
||||
private String pval;
|
||||
|
||||
private String type;
|
||||
|
||||
private Integer sort;
|
||||
}
|
Loading…
Reference in New Issue
Block a user