init
This commit is contained in:
251
src/views/admin/client/form.vue
Normal file
251
src/views/admin/client/form.vue
Normal file
@@ -0,0 +1,251 @@
|
||||
<template>
|
||||
<el-dialog :close-on-click-modal="false" :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" draggable v-model="visible">
|
||||
<el-form :model="form" :rules="dataRules" formDialogRef label-width="120px" ref="dataFormRef" v-loading="loading">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('client.clientId')" prop="clientId">
|
||||
<el-input :placeholder="t('client.inputClientIdTip')" v-model="form.clientId" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('client.clientSecret')" prop="clientSecret">
|
||||
<el-input :placeholder="t('client.inputClientSecretTip')" v-model="form.clientSecret" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('client.scope')" prop="scope">
|
||||
<el-input :placeholder="t('client.inputScopeTip')" v-model="form.scope" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('client.authorizedGrantTypes')" prop="authorizedGrantTypes">
|
||||
<el-select collapse-tags collapse-tags-tooltip multiple v-model="form.authorizedGrantTypes">
|
||||
<el-option :key="index" :label="item.label" :value="item.value" v-for="(item, index) in grant_types"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('client.accessTokenValidity')" prop="accessTokenValidity">
|
||||
<el-input-number :placeholder="t('client.inputAccessTokenValidityTip')" v-model="form.accessTokenValidity" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('client.refreshTokenValidity')" prop="refreshTokenValidity">
|
||||
<el-input-number :placeholder="t('client.inputRefreshTokenValidityTip')" v-model="form.refreshTokenValidity" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20" v-if="form.authorizedGrantTypes.includes('authorization_code')">
|
||||
<el-form-item :label="t('client.autoapprove')" prop="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-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20" v-if="form.authorizedGrantTypes.includes('authorization_code')">
|
||||
<el-form-item :label="t('client.authorities')" prop="authorities">
|
||||
<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-col>
|
||||
</el-row>
|
||||
|
||||
<el-collapse v-model="collapseActive">
|
||||
<el-collapse-item name="1" title="安全属性">
|
||||
<template #title>
|
||||
<el-icon class="header-icon">
|
||||
<info-filled />
|
||||
</el-icon>
|
||||
安全属性
|
||||
</template>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('client.captchaFlag')" prop="captchaFlag">
|
||||
<el-radio-group v-model="form.captchaFlag">
|
||||
<el-radio :key="index" :label="item.value" border v-for="(item, index) in captcha_flag_types">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('client.encFlag')" prop="encFlag">
|
||||
<el-radio-group v-model="form.encFlag">
|
||||
<el-radio :key="index" :label="item.value" border v-for="(item, index) in enc_flag_types">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item :label="t('client.onlineQuantity')" prop="onlineQuantity">
|
||||
<el-radio-group v-model="form.onlineQuantity">
|
||||
<el-radio :key="index" :label="item.value" border v-for="(item, index) in enc_flag_types">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
|
||||
<el-button @click="onSubmit" type="primary" :disabled="loading">{{ $t('common.confirmButtonText') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="SysOauthClientDetailsDialog" setup>
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { addObj, getObj, putObj, validateclientId } from '/@/api/admin/client';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { rule } from '/@/utils/validate';
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
|
||||
// 定义字典
|
||||
const { grant_types, common_status, captcha_flag_types, enc_flag_types } = useDict(
|
||||
'grant_types',
|
||||
'common_status',
|
||||
'captcha_flag_types',
|
||||
'enc_flag_types'
|
||||
);
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: '',
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
scope: 'server',
|
||||
authorizedGrantTypes: [] as string[],
|
||||
webServerRedirectUri: '',
|
||||
authorities: '',
|
||||
accessTokenValidity: 43200,
|
||||
refreshTokenValidity: 2592001,
|
||||
autoapprove: 'true',
|
||||
delFlag: '',
|
||||
createBy: '',
|
||||
updateBy: '',
|
||||
createTime: '',
|
||||
updateTime: '',
|
||||
tenantId: '',
|
||||
onlineQuantity: '1',
|
||||
captchaFlag: '1',
|
||||
encFlag: '1',
|
||||
});
|
||||
|
||||
const collapseActive = ref('1');
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
clientId: [
|
||||
{ validator: rule.overLength, trigger: 'blur' },
|
||||
{ required: true, message: '编号不能为空', trigger: 'blur' },
|
||||
{ validator: rule.validatorLowercase, trigger: 'blur' },
|
||||
{
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
validateclientId(rule, value, callback, form.id !== '');
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
clientSecret: [
|
||||
{ validator: rule.overLength, trigger: 'blur' },
|
||||
{ required: true, message: '密钥不能为空', trigger: 'blur' },
|
||||
{ validator: rule.validatorLower, trigger: 'blur' },
|
||||
],
|
||||
scope: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '域不能为空', trigger: 'blur' }],
|
||||
authorizedGrantTypes: [{ required: true, message: '授权模式不能为空', trigger: 'blur' }],
|
||||
accessTokenValidity: [
|
||||
{ required: true, message: '令牌时效不能为空', trigger: 'blur' },
|
||||
{ type: 'number', min: 1, message: '令牌时效不能小于一小时', trigger: 'blur' },
|
||||
],
|
||||
refreshTokenValidity: [
|
||||
{ required: true, message: '刷新时效不能为空', trigger: 'blur' },
|
||||
{ type: 'number', min: 1, message: '刷新时效不能小于两小时', trigger: 'blur' },
|
||||
],
|
||||
captchaFlag: [{ required: true, message: '是否开启验证码校验', trigger: 'blur' }],
|
||||
encFlag: [{ required: true, message: '是否开启密码加密传输', trigger: 'blur' }],
|
||||
onlineQuantity: [{ required: true, message: '是否允许同时在线', trigger: 'blur' }],
|
||||
autoapprove: [{ required: true, message: '自动放行不能为空', trigger: 'blur' }],
|
||||
webServerRedirectUri: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '回调地址不能为空', trigger: 'blur' }],
|
||||
});
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
visible.value = true;
|
||||
form.id = '';
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取sysOauthClientDetails信息
|
||||
if (id) {
|
||||
form.id = id;
|
||||
getsysOauthClientDetailsData(id);
|
||||
}
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
// 立即设置 loading,防止重复点击
|
||||
if (loading.value) return;
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) {
|
||||
loading.value = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化表单数据
|
||||
const getsysOauthClientDetailsData = (id: string) => {
|
||||
// 获取数据
|
||||
getObj(id).then((res: any) => {
|
||||
Object.assign(form, res.data);
|
||||
});
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
||||
45
src/views/admin/client/i18n/en.ts
Normal file
45
src/views/admin/client/i18n/en.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
export default {
|
||||
client: {
|
||||
index: '#',
|
||||
importsysOauthClientDetailsTip: 'import SysOauthClientDetails',
|
||||
id: 'id',
|
||||
clientId: 'client Id',
|
||||
resourceIds: 'resourceIds',
|
||||
clientSecret: 'clientSecret',
|
||||
scope: 'scope',
|
||||
authorizedGrantTypes: 'authorizedGrantTypes',
|
||||
webServerRedirectUri: 'webServerRedirectUri',
|
||||
authorities: 'authorities',
|
||||
accessTokenValidity: 'accessTokenValidity',
|
||||
refreshTokenValidity: 'refreshTokenValidity',
|
||||
additionalInformation: 'additionalInformation',
|
||||
autoapprove: 'autoapprove',
|
||||
delFlag: 'delFlag',
|
||||
createBy: 'createBy',
|
||||
updateBy: 'updateBy',
|
||||
createTime: 'createTime',
|
||||
updateTime: 'updateTime',
|
||||
tenantId: 'tenantId',
|
||||
captchaFlag: 'captchaFlag',
|
||||
encFlag: 'encFlag',
|
||||
onlineQuantity: 'onlineQuantity',
|
||||
inputIdTip: 'input id',
|
||||
inputClientIdTip: 'input clientId',
|
||||
inputResourceIdsTip: 'input resourceIds',
|
||||
inputClientSecretTip: 'input clientSecret',
|
||||
inputScopeTip: 'input scope',
|
||||
inputAuthorizedGrantTypesTip: 'input authorizedGrantTypes',
|
||||
inputWebServerRedirectUriTip: 'input webServerRedirectUri',
|
||||
inputAuthoritiesTip: 'input authorities',
|
||||
inputAccessTokenValidityTip: 'input accessTokenValidity',
|
||||
inputRefreshTokenValidityTip: 'input refreshTokenValidity',
|
||||
inputAdditionalInformationTip: 'input additionalInformation',
|
||||
inputAutoapproveTip: 'input autoapprove',
|
||||
inputDelFlagTip: 'input delFlag',
|
||||
inputCreateByTip: 'input createBy',
|
||||
inputUpdateByTip: 'input updateBy',
|
||||
inputCreateTimeTip: 'input createTime',
|
||||
inputUpdateTimeTip: 'input updateTime',
|
||||
inputTenantIdTip: 'input tenantId',
|
||||
},
|
||||
};
|
||||
43
src/views/admin/client/i18n/zh-cn.ts
Normal file
43
src/views/admin/client/i18n/zh-cn.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
export default {
|
||||
client: {
|
||||
index: '#',
|
||||
importsysOauthClientDetailsTip: '导入终端信息表',
|
||||
id: 'ID',
|
||||
clientId: '客户端id',
|
||||
resourceIds: '',
|
||||
clientSecret: '密钥',
|
||||
scope: '域',
|
||||
authorizedGrantTypes: '授权模式',
|
||||
webServerRedirectUri: '回调地址',
|
||||
authorities: '权限',
|
||||
accessTokenValidity: '令牌时效(秒)',
|
||||
refreshTokenValidity: '刷新时效(秒)',
|
||||
additionalInformation: '扩展信息',
|
||||
autoapprove: '自动放行',
|
||||
createBy: '创建人',
|
||||
updateBy: '修改人',
|
||||
createTime: '上传时间',
|
||||
updateTime: '更新时间',
|
||||
tenantId: '所属租户',
|
||||
captchaFlag: '验证码开关',
|
||||
encFlag: '前端密码加密',
|
||||
onlineQuantity: '允许同时在线',
|
||||
inputIdTip: '请输入ID',
|
||||
inputClientIdTip: '请输入客户端id',
|
||||
inputResourceIdsTip: '请输入',
|
||||
inputClientSecretTip: '请输入密钥',
|
||||
inputScopeTip: '请输入域',
|
||||
inputAuthorizedGrantTypesTip: '请输入授权模式',
|
||||
inputWebServerRedirectUriTip: '请输入回调地址',
|
||||
inputAuthoritiesTip: '请输入权限',
|
||||
inputAccessTokenValidityTip: '请输入令牌时效',
|
||||
inputRefreshTokenValidityTip: '请输入刷新时效',
|
||||
inputAdditionalInformationTip: '请输入扩展信息',
|
||||
inputAutoapproveTip: '请输入自动放行',
|
||||
inputCreateByTip: '请输入创建人',
|
||||
inputUpdateByTip: '请输入修改人',
|
||||
inputCreateTimeTip: '请输入上传时间',
|
||||
inputUpdateTimeTip: '请输入更新时间',
|
||||
inputTenantIdTip: '请输入所属租户',
|
||||
},
|
||||
};
|
||||
155
src/views/admin/client/index.vue
Normal file
155
src/views/admin/client/index.vue
Normal file
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-row class="ml10" v-show="showSearch">
|
||||
<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
|
||||
<el-form-item :label="$t('client.clientId')" prop="clientId">
|
||||
<el-input :placeholder="$t('client.clientId')" style="max-width: 180px" v-model="state.queryForm.clientId" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('client.clientSecret')" prop="clientSecret">
|
||||
<el-input :placeholder="$t('client.clientSecret')" style="max-width: 180px" v-model="state.queryForm.clientSecret" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList" icon="search" type="primary">
|
||||
{{ $t('common.queryBtn') }}
|
||||
</el-button>
|
||||
<el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button v-auth="'sys_client_add'" @click="formDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary">
|
||||
{{ $t('common.addBtn') }}
|
||||
</el-button>
|
||||
<el-button v-auth="'sys_client_del'" plain @click="handleRefreshCache()" class="ml10" icon="refresh-left" type="primary">
|
||||
{{ $t('common.refreshCacheBtn') }}
|
||||
</el-button>
|
||||
|
||||
<el-button plain :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete" type="primary" v-auth="'sys_client_del'">
|
||||
{{ $t('common.delBtn') }}
|
||||
</el-button>
|
||||
|
||||
<right-toolbar
|
||||
:export="'sys_client_del'"
|
||||
@exportExcel="exportExcel"
|
||||
@queryTable="getDataList"
|
||||
class="ml10"
|
||||
style="float: right; margin-right: 20px"
|
||||
v-model:showSearch="showSearch"
|
||||
></right-toolbar>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table
|
||||
:data="state.dataList"
|
||||
@selection-change="handleSelectionChange"
|
||||
style="width: 100%"
|
||||
row-key="id"
|
||||
v-loading="state.loading"
|
||||
border
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
>
|
||||
<el-table-column align="center" type="selection" width="40" />
|
||||
<el-table-column :label="t('client.index')" type="index" width="60" />
|
||||
<el-table-column :label="t('client.clientId')" prop="clientId" show-overflow-tooltip />
|
||||
<el-table-column :label="t('client.clientSecret')" prop="clientSecret" show-overflow-tooltip />
|
||||
<el-table-column :label="t('client.scope')" prop="scope" show-overflow-tooltip />
|
||||
<el-table-column :label="t('client.authorizedGrantTypes')" prop="authorizedGrantTypes" show-overflow-tooltip width="400px">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="grant_types" :value="scope.row.authorizedGrantTypes" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('client.accessTokenValidity')" prop="accessTokenValidity" show-overflow-tooltip />
|
||||
<el-table-column :label="t('client.refreshTokenValidity')" prop="refreshTokenValidity" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('common.action')" width="150">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" @click="formDialogRef.openDialog(scope.row.clientId)" text type="primary" v-auth="'sys_client_add'"
|
||||
>{{ $t('common.editBtn') }}
|
||||
</el-button>
|
||||
<el-button icon="delete" @click="handleDelete([scope.row.id])" text type="primary" v-auth="'sys_client_del'">
|
||||
{{ $t('common.delBtn') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination" />
|
||||
</div>
|
||||
<!-- 编辑、新增 -->
|
||||
<form-dialog @refresh="getDataList()" ref="formDialogRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="systemSysOauthClientDetails" setup>
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { delObj, fetchList, refreshCache } from '/@/api/admin/client';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
const { t } = useI18n();
|
||||
// 定义查询字典
|
||||
|
||||
const { grant_types } = useDict('grant_types');
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref();
|
||||
const queryRef = ref();
|
||||
// 搜索变量
|
||||
const showSearch = ref(true);
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any;
|
||||
const multiple = ref(true);
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: fetchList,
|
||||
descs: ['id'],
|
||||
});
|
||||
|
||||
// table hook
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile, tableStyle } = useTable(state);
|
||||
|
||||
// 删除缓存
|
||||
const handleRefreshCache = () => {
|
||||
refreshCache().then(() => {
|
||||
useMessage().success('同步成功');
|
||||
});
|
||||
};
|
||||
|
||||
const resetQuery = () => {
|
||||
queryRef.value.resetFields();
|
||||
// state.queryForm = {};
|
||||
selectObjs.value = [];
|
||||
getDataList();
|
||||
};
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/admin/client/export', Object.assign(state.queryForm,{ids:selectObjs}), 'client.xlsx');
|
||||
};
|
||||
|
||||
// 多选事件
|
||||
const handleSelectionChange = (objs: { id: string }[]) => {
|
||||
selectObjs.value = objs.map(({ id }) => id);
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm(t('common.delConfirmText'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObj(ids);
|
||||
getDataList();
|
||||
useMessage().success(t('common.delSuccessText'));
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user