feat: 一堆功能优化

This commit is contained in:
lbw 2023-03-04 22:49:42 +08:00
parent d058f62588
commit ba619366c4
13 changed files with 116 additions and 89 deletions

View File

@ -34,10 +34,10 @@ export const rule = {
} }
}, },
/** /**
* 线 * 线
* *
*/ */
validatorKey(rule: any, value: any, callback: any) { validatorCapital(rule: any, value: any, callback: any) {
const acount = /^[A-Z_]+$/; const acount = /^[A-Z_]+$/;
if (value && !acount.test(value)) { if (value && !acount.test(value)) {
callback(new Error('请输入大写英文、下划线')); callback(new Error('请输入大写英文、下划线'));
@ -46,6 +46,19 @@ export const rule = {
} }
}, },
/**
* 线
*
*/
validatorLowercase(rule: any, value: any, callback: any) {
const acount = /^[a-z_]+$/;
if (value && !acount.test(value)) {
callback(new Error('请输入小写英文、下划线'));
} else {
callback();
}
},
/** /**
* *
* *

View File

@ -20,39 +20,27 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24" class="mb20"> <el-col :span="12" class="mb20">
<el-form-item :label="t('client.authorizedGrantTypes')" prop="authorizedGrantTypes"> <el-form-item :label="t('client.authorizedGrantTypes')" prop="authorizedGrantTypes">
<el-checkbox-group v-model="form.authorizedGrantTypes"> <el-select v-model="form.authorizedGrantTypes" multiple collapse-tags collapse-tags-tooltip>
<el-checkbox :key="index" :label="item.value" v-for="(item, index) in grant_types">{{ item.label }} </el-checkbox> <el-option :key="index" :label="item.label" v-for="(item, index) in grant_types" :value="item.value"></el-option>
</el-checkbox-group> </el-select>
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="t('client.webServerRedirectUri')" prop="webServerRedirectUri">
<el-input :placeholder="t('client.inputWebServerRedirectUriTip')" v-model="form.webServerRedirectUri" />
</el-form-item>
</el-col>
<el-col :span="12" class="mb20">
<el-form-item :label="t('client.authorities')" prop="authorities">
<el-input :placeholder="t('client.inputAuthoritiesTip')" v-model="form.authorities" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" class="mb20"> <el-col :span="12" class="mb20">
<el-form-item :label="t('client.accessTokenValidity')" prop="accessTokenValidity"> <el-form-item :label="t('client.accessTokenValidity')" prop="accessTokenValidity">
<el-input :placeholder="t('client.inputAccessTokenValidityTip')" v-model="form.accessTokenValidity" /> <el-input-number :placeholder="t('client.inputAccessTokenValidityTip')" v-model="form.accessTokenValidity" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" class="mb20"> <el-col :span="12" class="mb20">
<el-form-item :label="t('client.refreshTokenValidity')" prop="refreshTokenValidity"> <el-form-item :label="t('client.refreshTokenValidity')" prop="refreshTokenValidity">
<el-input :placeholder="t('client.inputRefreshTokenValidityTip')" v-model="form.refreshTokenValidity" /> <el-input-number :placeholder="t('client.inputRefreshTokenValidityTip')" v-model="form.refreshTokenValidity" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" class="mb20"> <el-col :span="12" class="mb20" v-if="form.authorizedGrantTypes.includes('authorization_code')">
<el-form-item :label="t('client.autoapprove')" prop="autoapprove"> <el-form-item :label="t('client.autoapprove')" prop="autoapprove">
<el-radio-group v-model="form.autoapprove"> <el-radio-group v-model="form.autoapprove">
<el-radio :key="index" :label="item.value" border v-for="(item, index) in common_status">{{ item.label }} </el-radio> <el-radio :key="index" :label="item.value" border v-for="(item, index) in common_status">{{ item.label }} </el-radio>
@ -60,9 +48,15 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24" class="mb20"> <el-col :span="12" class="mb20" v-if="form.authorizedGrantTypes.includes('authorization_code')">
<el-form-item :label="t('client.additionalInformation')" prop="additionalInformation"> <el-form-item :label="t('client.authorities')" prop="authorities">
<el-input :placeholder="t('client.inputAdditionalInformationTip')" type="textarea" v-model="form.additionalInformation" /> <el-input :placeholder="t('client.inputAuthoritiesTip')" v-model="form.authorities" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20" v-if="form.authorizedGrantTypes.includes('authorization_code')">
<el-form-item :label="t('client.webServerRedirectUri')" prop="webServerRedirectUri">
<el-input :placeholder="t('client.inputWebServerRedirectUriTip')" v-model="form.webServerRedirectUri" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -118,13 +112,13 @@
</template> </template>
<script lang="ts" name="SysOauthClientDetailsDialog" setup> <script lang="ts" name="SysOauthClientDetailsDialog" setup>
// /
import { useDict } from '/@/hooks/dict'; import { useDict } from '/@/hooks/dict';
import { useMessage } from '/@/hooks/message'; import { useMessage } from '/@/hooks/message';
import { addObj, getObj, putObj } from '/@/api/admin/client'; import { addObj, getObj, putObj } from '/@/api/admin/client';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { rule } from '/@/utils/validate'; import { rule } from '/@/utils/validate';
// /
const emit = defineEmits(['refresh']); const emit = defineEmits(['refresh']);
const { t } = useI18n(); const { t } = useI18n();
@ -145,36 +139,49 @@ const form = reactive({
id: '', id: '',
clientId: '', clientId: '',
clientSecret: '', clientSecret: '',
scope: '', scope: 'server',
authorizedGrantTypes: [], authorizedGrantTypes: [] as string[],
webServerRedirectUri: '', webServerRedirectUri: '',
authorities: '', authorities: '',
accessTokenValidity: '', accessTokenValidity: 43200,
refreshTokenValidity: '', refreshTokenValidity: 2592001,
additionalInformation: '', autoapprove: 'true',
autoapprove: '',
delFlag: '', delFlag: '',
createBy: '', createBy: '',
updateBy: '', updateBy: '',
createTime: '', createTime: '',
updateTime: '', updateTime: '',
tenantId: '', tenantId: '',
onlineQuantity: '1',
captchaFlag: '1',
encFlag: '1',
}); });
const collapseActive = ref('1'); const collapseActive = ref('1');
// //
const dataRules = ref({ const dataRules = ref({
clientId: [{ required: true, message: '编号不能为空', trigger: 'blur' }], clientId: [
clientSecret: [{ required: true, message: '密钥不能为空', trigger: 'blur' }], { required: true, message: '编号不能为空', trigger: 'blur' },
{ validator: rule.validatorLowercase, trigger: 'blur' },
],
clientSecret: [
{ required: true, message: '密钥不能为空', trigger: 'blur' },
{ validator: rule.validatorLowercase, trigger: 'blur' },
],
scope: [{ required: true, message: '域不能为空', trigger: 'blur' }], scope: [{ required: true, message: '域不能为空', trigger: 'blur' }],
authorizedGrantTypes: [{ required: true, message: '授权模式不能为空', trigger: 'blur' }], authorizedGrantTypes: [{ required: true, message: '授权模式不能为空', trigger: 'blur' }],
accessTokenValidity: [{ required: true, message: '令牌时效不能为空', trigger: 'blur' }], accessTokenValidity: [
refreshTokenValidity: [{ required: true, message: '刷新时效不能为空', trigger: 'blur' }], { required: true, message: '令牌时效不能为空', trigger: 'blur' },
{ type: 'number', min: 3600, message: '令牌时效不能小于一小时', trigger: 'blur' },
],
refreshTokenValidity: [
{ required: true, message: '刷新时效不能为空', trigger: 'blur' },
{ type: 'number', min: 7200, message: '刷新时效不能小于两小时', trigger: 'blur' },
],
captchaFlag: [{ required: true, message: '是否开启验证码校验', trigger: 'blur' }], captchaFlag: [{ required: true, message: '是否开启验证码校验', trigger: 'blur' }],
encFlag: [{ required: true, message: '是否开启密码加密传输', trigger: 'blur' }], encFlag: [{ required: true, message: '是否开启密码加密传输', trigger: 'blur' }],
onlineQuantity: [{ required: true, message: '是否允许同时在线', trigger: 'blur' }], onlineQuantity: [{ required: true, message: '是否允许同时在线', trigger: 'blur' }],
authorities: [{ required: true, message: '权限不能为空', trigger: 'blur' }],
autoapprove: [{ required: true, message: '自动放行不能为空', trigger: 'blur' }], autoapprove: [{ required: true, message: '自动放行不能为空', trigger: 'blur' }],
webServerRedirectUri: [ webServerRedirectUri: [
{ required: true, message: '回调地址不能为空', trigger: 'blur' }, { required: true, message: '回调地址不能为空', trigger: 'blur' },

View File

@ -10,8 +10,8 @@ export default {
authorizedGrantTypes: '授权模式', authorizedGrantTypes: '授权模式',
webServerRedirectUri: '回调地址', webServerRedirectUri: '回调地址',
authorities: '权限', authorities: '权限',
accessTokenValidity: '令牌时效', accessTokenValidity: '令牌时效(秒)',
refreshTokenValidity: '刷新时效', refreshTokenValidity: '刷新时效(秒)',
additionalInformation: '扩展信息', additionalInformation: '扩展信息',
autoapprove: '自动放行', autoapprove: '自动放行',
createBy: '创建人', createBy: '创建人',

View File

@ -93,6 +93,7 @@ const multiple = ref(true);
const state: BasicTableProps = reactive<BasicTableProps>({ const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {}, queryForm: {},
pageList: fetchList, pageList: fetchList,
descs: ['id'],
}); });
// table hook // table hook

View File

@ -45,7 +45,7 @@
<el-input-number v-model="state.ruleForm.sortOrder" :min="0" controls-position="right" /> <el-input-number v-model="state.ruleForm.sortOrder" :min="0" controls-position="right" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" class="mb20"> <el-col :span="12" class="mb20" v-if="state.ruleForm.menuType === '0'">
<el-form-item :label="$t('sysmenu.icon')" prop="icon"> <el-form-item :label="$t('sysmenu.icon')" prop="icon">
<IconSelector :placeholder="$t('sysmenu.inputIconTip')" v-model="state.ruleForm.icon" /> <IconSelector :placeholder="$t('sysmenu.inputIconTip')" v-model="state.ruleForm.icon" />
</el-form-item> </el-form-item>

View File

@ -95,7 +95,7 @@ const dataRules = reactive({
publicName: [{ required: true, message: '名称不能为空', trigger: 'blur' }], publicName: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
publicKey: [ publicKey: [
{ required: true, message: '参数键不能为空', trigger: 'blur' }, { required: true, message: '参数键不能为空', trigger: 'blur' },
{ validator: rule.validatorKey, trigger: 'blur' }, { validator: rule.validatorLowercase, trigger: 'blur' },
], ],
publicValue: [{ required: true, message: '参数值不能为空', trigger: 'blur' }], publicValue: [{ required: true, message: '参数值不能为空', trigger: 'blur' }],
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }], status: [{ required: true, message: '状态不能为空', trigger: 'blur' }],

View File

@ -115,7 +115,7 @@ const dataRules = ref({
roleCode: [ roleCode: [
{ required: true, message: '角色标识不能为空', trigger: 'blur' }, { required: true, message: '角色标识不能为空', trigger: 'blur' },
{ min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }, { min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' },
{ validator: rule.validatorKey, trigger: 'blur' }, { validator: rule.validatorCapital, trigger: 'blur' },
{ validator: validateRoleCode, trigger: 'blur' }, { validator: validateRoleCode, trigger: 'blur' },
], ],
roleDesc: [{ max: 128, message: '长度在 128 个字符内', trigger: 'blur' }], roleDesc: [{ max: 128, message: '长度在 128 个字符内', trigger: 'blur' }],

View File

@ -121,8 +121,8 @@ const dataForm = reactive({
nickname: '', nickname: '',
name: '', name: '',
email: '', email: '',
post: [] as String[], post: [] as string[],
role: [] as String[], role: [] as string[],
}); });
const dataRules = ref({ const dataRules = ref({

View File

@ -1,6 +1,6 @@
<template> <template>
<el-dialog :close-on-click-modal="false" :title="state.ruleForm.menuId ? $t('common.editBtn') : $t('common.addBtn')" draggable v-model="visible"> <el-dialog :close-on-click-modal="false" :title="state.ruleForm.menuId ? $t('common.editBtn') : $t('common.addBtn')" draggable v-model="visible">
<el-form :model="state.ruleForm" :rules="dataRules" label-width="90px" ref="menuDialogFormRef" v-loading="loading"> <el-form :model="state.ruleForm" :rules="dataRules" label-width="90px" ref="dataFormRef" v-loading="loading">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12" class="mb20"> <el-col :span="12" class="mb20">
<el-form-item :label="$t('sysmenu.menuType')" prop="menType"> <el-form-item :label="$t('sysmenu.menuType')" prop="menType">
@ -35,9 +35,9 @@
<el-input placeholder="请输入路由地址" v-model="state.ruleForm.path" /> <el-input placeholder="请输入路由地址" v-model="state.ruleForm.path" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" class="mb20"> <el-col :span="12" class="mb20" v-if="state.ruleForm.menuType == '1'">
<el-form-item :label="$t('sysmenu.permission')" prop="permission"> <el-form-item :label="$t('sysmenu.permission')" prop="permission">
<el-input maxlength="50" placeholder="请权限标识" v-model="state.ruleForm.permission" /> <el-input maxlength="50" placeholder="请输入权限标识" v-model="state.ruleForm.permission" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" class="mb20"> <el-col :span="12" class="mb20">
@ -76,7 +76,8 @@ const emit = defineEmits(['refresh']);
const visible = ref(false); const visible = ref(false);
const loading = ref(false); const loading = ref(false);
// //
const menuDialogFormRef = ref(); const dataFormRef = ref();
// //
const state = reactive({ const state = reactive({
ruleForm: { ruleForm: {
@ -88,7 +89,7 @@ const state = reactive({
path: '', path: '',
sortOrder: 0, sortOrder: 0,
menuType: '0', menuType: '0',
visible: '', visible: '1',
id: '', id: '',
}, },
parentData: [] as any[], // parentData: [] as any[], //
@ -142,7 +143,7 @@ const dataRules = reactive({
], ],
permission: [ permission: [
{ required: true, message: '权限标识不能为空', trigger: 'blur' }, { required: true, message: '权限标识不能为空', trigger: 'blur' },
{ validator: rule.validatorKey, trigger: 'blur' }, { validator: rule.validatorLowercase, trigger: 'blur' },
{ min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }, { min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' },
{ {
validator: (rule: any, value: any, callback: any) => { validator: (rule: any, value: any, callback: any) => {
@ -168,7 +169,7 @@ const openDialog = (type: string, row?: any) => {
} else { } else {
// 使 // 使
nextTick(() => { nextTick(() => {
menuDialogFormRef?.value?.resetFields(); dataFormRef?.value?.resetFields();
state.ruleForm.parentId = row?.id || '-1'; state.ruleForm.parentId = row?.id || '-1';
}); });
} }
@ -178,34 +179,39 @@ const openDialog = (type: string, row?: any) => {
// //
const onSubmit = () => { const onSubmit = () => {
// dataFormRef.value.validate((valid: boolean) => {
if (state.ruleForm.id) { if (!valid) {
loading.value = true; return false;
update(state.ruleForm) }
.then(() => { //
visible.value = false; if (state.ruleForm.id) {
emit('refresh'); loading.value = true;
}) update(state.ruleForm)
.catch((err) => { .then(() => {
useMessage().error(err.msg); visible.value = false;
}) emit('refresh');
.finally(() => { })
loading.value = false; .catch((err) => {
}); useMessage().error(err.msg);
} else { })
loading.value = true; .finally(() => {
addObj(state.ruleForm) loading.value = false;
.then(() => { });
visible.value = false; } else {
emit('refresh'); loading.value = true;
}) addObj(state.ruleForm)
.catch((err) => { .then(() => {
useMessage().error(err.msg); visible.value = false;
}) emit('refresh');
.finally(() => { })
loading.value = false; .catch((err) => {
}); useMessage().error(err.msg);
} })
.finally(() => {
loading.value = false;
});
}
});
}; };
// 使 // 使

View File

@ -85,7 +85,7 @@ const dataRules = ref({
roleCode: [ roleCode: [
{ required: true, message: '角色标识不能为空', trigger: 'blur' }, { required: true, message: '角色标识不能为空', trigger: 'blur' },
{ min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }, { min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' },
{ validator: rule.validatorKey, trigger: 'blur' }, { validator: rule.validatorCapital, trigger: 'blur' },
{ {
validator: (rule: any, value: any, callback: any) => { validator: (rule: any, value: any, callback: any) => {
validateAppRoleCode(rule, value, callback, form.roleId !== ''); validateAppRoleCode(rule, value, callback, form.roleId !== '');

View File

@ -95,8 +95,8 @@ const dataForm = reactive({
nickname: '', nickname: '',
name: '', name: '',
email: '', email: '',
post: [] as String[], post: [] as string[],
role: [] as String[], role: [] as string[],
}); });
const dataRules = ref({ const dataRules = ref({

View File

@ -96,17 +96,17 @@
<el-table-column :label="$t('common.action')" width="300" fixed="right"> <el-table-column :label="$t('common.action')" width="300" fixed="right">
<template #default="scope"> <template #default="scope">
<el-button size="small" text type="primary" @click="handleJobLog(scope.row)">日志</el-button> <el-button text type="primary" @click="handleJobLog(scope.row)">日志</el-button>
<el-button size="small" text type="primary" @click="handleStartJob(scope.row)">启动</el-button> <el-button v-if="scope.row.jobStatus !== '2'" text type="primary" @click="handleStartJob(scope.row)">启动</el-button>
<el-button size="small" text type="primary" @click="handleShutDownJob(scope.row)">暂停</el-button> <el-button v-if="scope.row.jobStatus === '2'" text type="primary" @click="handleShutDownJob(scope.row)">暂停</el-button>
<el-button size="small" text type="primary" @click="handleEditJob(scope.row)">{{ $t('common.editBtn') }}</el-button> <el-button text type="primary" @click="handleEditJob(scope.row)">{{ $t('common.editBtn') }}</el-button>
<el-button size="small" text type="primary" @click="handleRunJob(scope.row)">执行</el-button> <el-button text type="primary" @click="handleRunJob(scope.row)">执行</el-button>
<el-button size="small" text type="primary" @click="handleDelete(scope.row)">{{ $t('common.delBtn') }}</el-button> <el-button text type="primary" @click="handleDelete(scope.row)">{{ $t('common.delBtn') }}</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -170,7 +170,7 @@ const handleSelectionChange = (val: any) => {
// excel // excel
const exportExcel = () => { const exportExcel = () => {
downBlobFile('/pigx/job/export', state.queryForm, 'job.xlsx'); downBlobFile('/admin/job/export', state.queryForm, 'job.xlsx');
}; };
const handleJobLog = (row: any) => { const handleJobLog = (row: any) => {

View File

@ -51,7 +51,7 @@ const form = reactive({
id: '', id: '',
groupName: '', groupName: '',
groupDesc: '', groupDesc: '',
templateId: [] as String[], templateId: [] as string[],
putList: [], putList: [],
}); });