Merge branch 'dev' of https://gitee.com/yudaocode/yudao-ui-admin-vben into dev
This commit is contained in:
@@ -366,8 +366,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
label: '表名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入表名称',
|
||||
allowClear: true,
|
||||
placeholder: '请输入表名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -375,8 +375,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
label: '表描述',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入表描述',
|
||||
allowClear: true,
|
||||
placeholder: '请输入表描述',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -154,8 +154,8 @@ getDetail();
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex justify-end space-x-2">
|
||||
<Button v-show="currentStep > 0" @click="prevStep">上一步</Button>
|
||||
<Button v-show="currentStep < steps.length - 1" @click="nextStep">
|
||||
<Button :disabled="currentStep === 0" @click="prevStep">上一步</Button>
|
||||
<Button :disabled="currentStep === steps.length - 1" @click="nextStep">
|
||||
下一步
|
||||
</Button>
|
||||
<Button type="primary" :loading="loading" @click="submitForm">
|
||||
|
||||
@@ -27,7 +27,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ async function handleDelete(row: InfraConfigApi.Config) {
|
||||
try {
|
||||
await deleteConfig(row.id as number);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
@@ -73,7 +73,7 @@ async function handleDeleteBatch() {
|
||||
await deleteConfigList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
onRefresh();
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
@@ -125,7 +125,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="onRefresh" />
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="参数列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
|
||||
@@ -55,26 +55,31 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 50 },
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
field: 'id',
|
||||
title: '主键编号',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '数据源名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'url',
|
||||
title: '数据源连接',
|
||||
minWidth: 300,
|
||||
},
|
||||
{
|
||||
field: 'username',
|
||||
title: '用户名',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { InfraDataSourceConfigApi } from '#/api/infra/data-source-config';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
@@ -25,6 +25,11 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建数据源 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
@@ -43,10 +48,8 @@ async function handleDelete(row: InfraDataSourceConfigApi.DataSourceConfig) {
|
||||
});
|
||||
try {
|
||||
await deleteDataSourceConfig(row.id as number);
|
||||
message.success({
|
||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||
});
|
||||
await handleLoadData();
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
@@ -63,7 +66,7 @@ async function handleDeleteBatch() {
|
||||
await deleteDataSourceConfigList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
await handleLoadData();
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
@@ -101,21 +104,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
|
||||
/** 加载数据 */
|
||||
async function handleLoadData() {
|
||||
await gridApi.query();
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
handleLoadData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="handleLoadData" />
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="数据源列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
|
||||
@@ -83,7 +83,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-2/5" :title="getTitle">
|
||||
<Modal :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -159,7 +159,7 @@ onMounted(async () => {
|
||||
onClick: handleExpand,
|
||||
},
|
||||
{
|
||||
label: '批量删除',
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
|
||||
@@ -292,9 +292,7 @@ export function useDataGridFormSchema(): VbenFormSchema[] {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典数据表格列
|
||||
*/
|
||||
/** 字典数据表格列 */
|
||||
export function useDataGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type {
|
||||
VxeGridListeners,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemDictTypeApi } from '#/api/system/dict/type';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
@@ -44,6 +44,7 @@ function handleEdit(row: SystemMailAccountApi.MailAccount) {
|
||||
async function handleDelete(row: SystemMailAccountApi.MailAccount) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.mail]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteMailAccount(row.id as number);
|
||||
|
||||
@@ -119,28 +119,31 @@ export function useSendMailFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'toMails',
|
||||
label: '收件邮箱',
|
||||
component: 'Textarea',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请输入收件邮箱,每行一个邮箱地址',
|
||||
rows: 3,
|
||||
mode: 'tags',
|
||||
allowClear: true,
|
||||
placeholder: '请输入收件邮箱,按 Enter 添加',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'ccMails',
|
||||
label: '抄送邮箱',
|
||||
component: 'Textarea',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请输入抄送邮箱,每行一个邮箱地址',
|
||||
rows: 2,
|
||||
mode: 'tags',
|
||||
allowClear: true,
|
||||
placeholder: '请输入抄送邮箱,按 Enter 添加',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'bccMails',
|
||||
label: '密送邮箱',
|
||||
component: 'Textarea',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请输入密送邮箱,每行一个邮箱地址',
|
||||
rows: 2,
|
||||
mode: 'tags',
|
||||
allowClear: true,
|
||||
placeholder: '请输入密送邮箱,按 Enter 添加',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -42,17 +42,10 @@ const [Modal, modalApi] = useVbenModal({
|
||||
paramsObj[param] = values[`param_${param}`];
|
||||
});
|
||||
}
|
||||
const parseEmails = (text: string): string[] => {
|
||||
if (!text) return [];
|
||||
return text
|
||||
.split('\n')
|
||||
.map((email) => email.trim())
|
||||
.filter((email) => email.length > 0);
|
||||
};
|
||||
const data: SystemMailTemplateApi.MailSendReqVO = {
|
||||
toMails: parseEmails(values.toMails || ''),
|
||||
ccMails: parseEmails(values.ccMails || ''),
|
||||
bccMails: parseEmails(values.bccMails || ''),
|
||||
toMails: values.toMails,
|
||||
ccMails: values.ccMails,
|
||||
bccMails: values.bccMails,
|
||||
templateCode: formData.value?.code || '',
|
||||
templateParams: paramsObj,
|
||||
};
|
||||
@@ -64,8 +57,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success('邮件发送成功');
|
||||
} catch (error) {
|
||||
console.error('发送邮件失败', error);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
||||
placeholder: '请选择是否已读',
|
||||
allowClear: true,
|
||||
placeholder: '请选择是否已读',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -185,7 +185,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: '测试',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.ADD,
|
||||
icon: ACTION_ICON.VIEW,
|
||||
auth: ['system:sms-template:send-sms'],
|
||||
onClick: handleSend.bind(null, row),
|
||||
},
|
||||
|
||||
@@ -47,7 +47,7 @@ async function handleDelete(row: SystemSocialClientApi.SocialClient) {
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteSocialClient(row.id as number);
|
||||
await deleteSocialClient(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
|
||||
@@ -8,9 +8,8 @@ import { h } from 'vue';
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
@@ -126,9 +125,9 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'avatar',
|
||||
label: '用户头像',
|
||||
// TODO @芋艿:使用 antd 的 Image 组件
|
||||
content: (data: SystemSocialUserApi.SocialUser) => {
|
||||
if (data?.avatar) {
|
||||
// TODO @芋艿:使用 antd 的 Image 组件
|
||||
return h('img', {
|
||||
src: data.avatar,
|
||||
style: 'width: 30px; height: 30px; cursor: pointer;',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { InfraApiAccessLogApi } from '#/api/infra/api-access-log';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -16,9 +16,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 110,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 110,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { InfraApiErrorLogApi } from '#/api/infra/api-error-log';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -16,9 +16,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 110,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 110,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -87,6 +87,7 @@ function showTemplate() {
|
||||
formData.value = makeTemplate();
|
||||
}
|
||||
|
||||
/** 生成组件 */
|
||||
function makeTemplate() {
|
||||
const rule = designer.value.getRule();
|
||||
const opt = designer.value.getOption();
|
||||
|
||||
@@ -42,8 +42,8 @@ export function useImportTableFormSchema(): VbenFormSchema[] {
|
||||
label: '表名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入表名称',
|
||||
clearable: true,
|
||||
placeholder: '请输入表名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -51,8 +51,8 @@ export function useImportTableFormSchema(): VbenFormSchema[] {
|
||||
label: '表描述',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入表描述',
|
||||
clearable: true,
|
||||
placeholder: '请输入表描述',
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -366,8 +366,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
label: '表名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入表名称',
|
||||
clearable: true,
|
||||
placeholder: '请输入表名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -375,8 +375,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
label: '表描述',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入表描述',
|
||||
clearable: true,
|
||||
placeholder: '请输入表描述',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -151,8 +151,13 @@ getDetail();
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex justify-end space-x-2">
|
||||
<ElButton v-show="currentStep > 0" @click="prevStep">上一步</ElButton>
|
||||
<ElButton v-show="currentStep < steps.length - 1" @click="nextStep">
|
||||
<ElButton :disabled="currentStep === 0" @click="prevStep">
|
||||
上一步
|
||||
</ElButton>
|
||||
<ElButton
|
||||
:disabled="currentStep === steps.length - 1"
|
||||
@click="nextStep"
|
||||
>
|
||||
下一步
|
||||
</ElButton>
|
||||
<ElButton type="primary" :loading="loading" @click="submitForm">
|
||||
|
||||
@@ -176,6 +176,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
|
||||
/** 获取数据源配置列表 */
|
||||
// TODO @芋艿:这种场景的最佳实践;
|
||||
async function initDataSourceConfig() {
|
||||
try {
|
||||
dataSourceConfigList.value = await getDataSourceConfigList();
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { InfraDataSourceConfigApi } from '#/api/infra/data-source-config';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
@@ -58,9 +53,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns<T = InfraDataSourceConfigApi.DataSourceConfig>(
|
||||
onActionClick: OnActionClickFn<T>,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
@@ -90,31 +83,10 @@ export function useGridColumns<T = InfraDataSourceConfigApi.DataSourceConfig>(
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'operation',
|
||||
title: '操作',
|
||||
minWidth: 130,
|
||||
align: 'center',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
cellRender: {
|
||||
attrs: {
|
||||
nameField: 'name',
|
||||
nameTitle: '数据源',
|
||||
onClick: onActionClick,
|
||||
},
|
||||
name: 'CellOperation',
|
||||
options: [
|
||||
{
|
||||
code: 'edit',
|
||||
show: hasAccessByCodes(['infra:data-source-config:update']),
|
||||
disabled: (row: any) => row.id === 0,
|
||||
},
|
||||
{
|
||||
code: 'delete',
|
||||
show: hasAccessByCodes(['infra:data-source-config:delete']),
|
||||
disabled: (row: any) => row.id === 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { InfraDataSourceConfigApi } from '#/api/infra/data-source-config';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { isEmpty } from '@vben/utils';
|
||||
@@ -28,37 +25,49 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建数据源 */
|
||||
function onCreate() {
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑数据源 */
|
||||
function onEdit(row: InfraDataSourceConfigApi.DataSourceConfig) {
|
||||
function handleEdit(row: InfraDataSourceConfigApi.DataSourceConfig) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除数据源 */
|
||||
async function onDelete(row: InfraDataSourceConfigApi.DataSourceConfig) {
|
||||
async function handleDelete(row: InfraDataSourceConfigApi.DataSourceConfig) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||
});
|
||||
try {
|
||||
await deleteDataSourceConfig(row.id as number);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
onRefresh();
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除数据源 */
|
||||
async function onDeleteBatch() {
|
||||
await confirm('确定要批量删除该数据源吗?');
|
||||
await deleteDataSourceConfigList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||
await onRefresh();
|
||||
async function handleDeleteBatch() {
|
||||
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deletingBatch'),
|
||||
});
|
||||
try {
|
||||
await deleteDataSourceConfigList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
@@ -70,30 +79,14 @@ function handleRowCheckboxChange({
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({
|
||||
code,
|
||||
row,
|
||||
}: OnActionClickParams<InfraDataSourceConfigApi.DataSourceConfig>) {
|
||||
switch (code) {
|
||||
case 'delete': {
|
||||
onDelete(row);
|
||||
break;
|
||||
}
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useGridColumns(onActionClick),
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
@@ -109,26 +102,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
|
||||
/** 加载数据 */
|
||||
async function handleLoadData() {
|
||||
await gridApi.query();
|
||||
}
|
||||
|
||||
/** 刷新表格 */
|
||||
async function onRefresh() {
|
||||
await handleLoadData();
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
handleLoadData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="onRefresh" />
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="数据源列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
@@ -138,7 +116,7 @@ onMounted(() => {
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['infra:data-source-config:create'],
|
||||
onClick: onCreate,
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
@@ -146,7 +124,32 @@ onMounted(() => {
|
||||
icon: ACTION_ICON.DELETE,
|
||||
disabled: isEmpty(checkedIds),
|
||||
auth: ['infra:data-source-config:delete'],
|
||||
onClick: onDeleteBatch,
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['infra:data-source-config:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['infra:data-source-config:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
|
||||
@@ -150,21 +150,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
</template>
|
||||
<template #file-content="{ row }">
|
||||
<ElImage v-if="row.type && row.type.includes('image')" :src="row.url" />
|
||||
<ElButton
|
||||
v-else-if="row.type && row.type.includes('pdf')"
|
||||
type="primary"
|
||||
link
|
||||
@click="() => openWindow(row.url!)"
|
||||
>
|
||||
预览
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-else
|
||||
type="primary"
|
||||
link
|
||||
@click="() => openWindow(row.url!)"
|
||||
>
|
||||
下载
|
||||
<ElButton type="primary" link @click="() => openWindow(row.url!)">
|
||||
{{ row.type && row.type.includes('pdf') ? '预览' : '下载' }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { InfraJobLogApi } from '#/api/infra/job-log';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -17,9 +17,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 140,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 140,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { InfraJobApi } from '#/api/infra/job';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -18,9 +18,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 140,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 140,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -76,7 +76,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-[40%]">
|
||||
<Modal :title="getTitle" class="w-2/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -157,7 +157,7 @@ onMounted(async () => {
|
||||
onClick: handleExpand,
|
||||
},
|
||||
{
|
||||
label: '批量删除',
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'danger',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['system:dept:delete'],
|
||||
|
||||
@@ -151,9 +151,7 @@ export function useTypeGridColumns(): VxeTableGridOptions['columns'] {
|
||||
// ============================== 字典数据 ==============================
|
||||
|
||||
// TODO @芋艿:后续针对 antd,增加
|
||||
/**
|
||||
* 颜色选项
|
||||
*/
|
||||
/** 颜色选项 */
|
||||
const colorOptions = [
|
||||
{ value: '', label: '无' },
|
||||
{ value: 'processing', label: '主要' },
|
||||
|
||||
@@ -55,7 +55,7 @@ async function handleDelete(row: SystemDictTypeApi.DictType) {
|
||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||
});
|
||||
try {
|
||||
await deleteDictType(row.id as number);
|
||||
await deleteDictType(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
|
||||
@@ -3,11 +3,11 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemLoginLogApi } from '#/api/system/login-log';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { exportLoginLog, getLoginLogPage } from '#/api/system/login-log';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Detail from './modules/detail.vue';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { SystemLoginLogApi } from '#/api/system/login-log';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -16,9 +16,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 110,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 110,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -135,8 +135,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'danger',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
disabled: isEmpty(checkedIds),
|
||||
auth: ['system:mail-account:delete'],
|
||||
disabled: isEmpty(checkedIds),
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { SystemMailLogApi } from '#/api/system/mail/log';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -16,9 +16,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 2,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 140,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 140,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -119,28 +119,25 @@ export function useSendMailFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'toMails',
|
||||
label: '收件邮箱',
|
||||
component: 'Textarea',
|
||||
component: 'InputTag',
|
||||
componentProps: {
|
||||
placeholder: '请输入收件邮箱,每行一个邮箱地址',
|
||||
rows: 3,
|
||||
placeholder: '请输入收件邮箱,按 Enter 添加',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'ccMails',
|
||||
label: '抄送邮箱',
|
||||
component: 'Textarea',
|
||||
component: 'InputTag',
|
||||
componentProps: {
|
||||
placeholder: '请输入抄送邮箱,每行一个邮箱地址',
|
||||
rows: 2,
|
||||
placeholder: '请输入抄送邮箱,按 Enter 添加',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'bccMails',
|
||||
label: '密送邮箱',
|
||||
component: 'Textarea',
|
||||
component: 'InputTag',
|
||||
componentProps: {
|
||||
placeholder: '请输入密送邮箱,每行一个邮箱地址',
|
||||
rows: 2,
|
||||
placeholder: '请输入密送邮箱,按 Enter 添加',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -160,8 +160,8 @@ onMounted(async () => {
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'danger',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
disabled: isEmpty(checkedIds),
|
||||
auth: ['system:mail-template:delete'],
|
||||
disabled: isEmpty(checkedIds),
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
|
||||
@@ -42,17 +42,10 @@ const [Modal, modalApi] = useVbenModal({
|
||||
paramsObj[param] = values[`param_${param}`];
|
||||
});
|
||||
}
|
||||
const parseEmails = (text: string): string[] => {
|
||||
if (!text) return [];
|
||||
return text
|
||||
.split('\n')
|
||||
.map((email) => email.trim())
|
||||
.filter((email) => email.length > 0);
|
||||
};
|
||||
const data: SystemMailTemplateApi.MailSendReqVO = {
|
||||
toMails: parseEmails(values.toMails || ''),
|
||||
ccMails: parseEmails(values.ccMails || ''),
|
||||
bccMails: parseEmails(values.bccMails || ''),
|
||||
toMails: values.toMails,
|
||||
ccMails: values.ccMails,
|
||||
bccMails: values.bccMails,
|
||||
templateCode: formData.value?.code || '',
|
||||
templateParams: paramsObj,
|
||||
};
|
||||
@@ -64,8 +57,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
ElMessage.success('邮件发送成功');
|
||||
} catch (error) {
|
||||
console.error('发送邮件失败', error);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
},
|
||||
showSearch: true,
|
||||
treeDefaultExpandedKeys: [0],
|
||||
allowClear: true,
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
renderComponentContent() {
|
||||
@@ -168,7 +167,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
component: 'AutoComplete',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
allowClear: true,
|
||||
filterOption(input: string, option: { value: string }) {
|
||||
return option.value.toLowerCase().includes(input.toLowerCase());
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -16,9 +16,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 140,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 140,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -30,8 +30,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
label: '发送时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
...getRangePickerDefaultProps(),
|
||||
clearable: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -16,9 +16,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 140,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 140,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { SystemOperateLogApi } from '#/api/system/operate-log';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -16,9 +16,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 1,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 110,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 110,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -164,6 +164,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
props: { type: DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import type { SystemSmsLogApi } from '#/api/system/sms/log';
|
||||
|
||||
import { ref } from 'vue';
|
||||
@@ -16,9 +16,9 @@ const [Descriptions] = useDescription({
|
||||
border: true,
|
||||
column: 2,
|
||||
direction: 'horizontal',
|
||||
labelWidth: 140,
|
||||
title: '',
|
||||
extra: '',
|
||||
labelWidth: 140,
|
||||
},
|
||||
schema: useDetailSchema(),
|
||||
});
|
||||
|
||||
@@ -75,10 +75,17 @@ async function handleDelete(row: SystemSmsTemplateApi.SmsTemplate) {
|
||||
/** 批量删除短信模板 */
|
||||
async function handleDeleteBatch() {
|
||||
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||
await deleteSmsTemplateList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deletingBatch'),
|
||||
});
|
||||
try {
|
||||
await deleteSmsTemplateList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
|
||||
@@ -42,22 +42,22 @@ function handleEdit(row: SystemSocialClientApi.SocialClient) {
|
||||
|
||||
/** 删除社交客户端 */
|
||||
async function handleDelete(row: SystemSocialClientApi.SocialClient) {
|
||||
const hideLoading = ElLoading.service({
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||
});
|
||||
try {
|
||||
await deleteSocialClient(row.id as number);
|
||||
await deleteSocialClient(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading.close();
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除社交客户端 */
|
||||
async function handleDeleteBatch() {
|
||||
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||
const hideLoading = ElLoading.service({
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deletingBatch'),
|
||||
});
|
||||
try {
|
||||
@@ -66,7 +66,7 @@ async function handleDeleteBatch() {
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading.close();
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,8 @@ import { h } from 'vue';
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
@@ -126,6 +125,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
||||
{
|
||||
field: 'avatar',
|
||||
label: '用户头像',
|
||||
// TODO @芋艿:使用 antd 的 Image 组件
|
||||
content: (data: SystemSocialUserApi.SocialUser) => {
|
||||
if (data?.avatar) {
|
||||
return h('img', {
|
||||
|
||||
@@ -76,7 +76,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Modal :title="getTitle" class="w-1/3">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -59,7 +59,7 @@ async function handleDownload() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="导入用户">
|
||||
<Modal title="导入用户" class="w-1/3">
|
||||
<Form class="mx-4">
|
||||
<template #file>
|
||||
<div class="w-full">
|
||||
|
||||
Reference in New Issue
Block a user