style: system views code style
This commit is contained in:
@@ -2,11 +2,11 @@ import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
@@ -45,7 +45,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
label: '模版类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE, 'number'),
|
||||
options: getDictOptions(
|
||||
DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
|
||||
'number',
|
||||
),
|
||||
allowClear: true,
|
||||
placeholder: '请选择模版类型',
|
||||
},
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getNotifyMessagePage } from '#/api/system/notify/message';
|
||||
import Detail from './modules/detail.vue';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Detail from './modules/detail.vue';
|
||||
|
||||
const [DetailModal, detailModalApi] = useVbenModal({
|
||||
connectedComponent: Detail,
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { Descriptions } from 'ant-design-vue';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { Descriptions } from 'ant-design-vue';
|
||||
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { DICT_TYPE } from '#/utils/dict';
|
||||
|
||||
const formData = ref<SystemNotifyMessageApi.SystemNotifyMessage>();
|
||||
@@ -32,7 +34,12 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="站内信详情" class="w-1/2" :show-cancel-button="false" :show-confirm-button="false">
|
||||
<Modal
|
||||
title="站内信详情"
|
||||
class="w-1/2"
|
||||
:show-cancel-button="false"
|
||||
:show-confirm-button="false"
|
||||
>
|
||||
<Descriptions bordered :column="1" size="middle" class="mx-4">
|
||||
<Descriptions.Item label="编号">{{ formData?.id }}</Descriptions.Item>
|
||||
<Descriptions.Item label="用户类型">
|
||||
@@ -57,10 +64,16 @@ const [Modal, modalApi] = useVbenModal({
|
||||
{{ formData?.templateParams }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="模版类型">
|
||||
<DictTag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="formData?.templateType" />
|
||||
<DictTag
|
||||
:type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE"
|
||||
:value="formData?.templateType"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="是否已读">
|
||||
<DictTag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="formData?.readStatus" />
|
||||
<DictTag
|
||||
:type="DICT_TYPE.INFRA_BOOLEAN_STRING"
|
||||
:value="formData?.readStatus"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="阅读时间">
|
||||
{{ formatDateTime(formData?.readTime || '') }}
|
||||
|
||||
@@ -8,9 +8,8 @@ import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { MdiCheckboxMarkedCircleOutline } from '@vben/icons';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
import Detail from './modules/detail.vue';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
@@ -18,8 +17,10 @@ import {
|
||||
updateAllNotifyMessageRead,
|
||||
updateNotifyMessageRead,
|
||||
} from '#/api/system/notify/message';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Detail from './modules/detail.vue';
|
||||
|
||||
const [DetailModal, detailModalApi] = useVbenModal({
|
||||
connectedComponent: Detail,
|
||||
@@ -67,7 +68,9 @@ async function onMarkRead() {
|
||||
return;
|
||||
}
|
||||
|
||||
const ids = rows.map((row: SystemNotifyMessageApi.SystemNotifyMessage) => row.id);
|
||||
const ids = rows.map(
|
||||
(row: SystemNotifyMessageApi.SystemNotifyMessage) => row.id,
|
||||
);
|
||||
message.loading({
|
||||
content: '正在标记已读...',
|
||||
duration: 0,
|
||||
@@ -146,7 +149,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
search: true,
|
||||
},
|
||||
checkboxConfig: {
|
||||
checkMethod: (params: { row: SystemNotifyMessageApi.SystemNotifyMessage }) => !params.row.readStatus,
|
||||
checkMethod: (params: {
|
||||
row: SystemNotifyMessageApi.SystemNotifyMessage;
|
||||
}) => !params.row.readStatus,
|
||||
highlight: true,
|
||||
},
|
||||
} as VxeTableGridOptions<SystemNotifyMessageApi.SystemNotifyMessage>,
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { Descriptions } from 'ant-design-vue';
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { formatDateTime } from '@vben/utils';
|
||||
|
||||
import { Descriptions } from 'ant-design-vue';
|
||||
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { DICT_TYPE } from '#/utils/dict';
|
||||
|
||||
const formData = ref<SystemNotifyMessageApi.SystemNotifyMessage>();
|
||||
@@ -32,7 +34,11 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="消息详情" :show-cancel-button="false" :show-confirm-button="false">
|
||||
<Modal
|
||||
title="消息详情"
|
||||
:show-cancel-button="false"
|
||||
:show-confirm-button="false"
|
||||
>
|
||||
<Descriptions bordered :column="1" size="middle" class="mx-4">
|
||||
<Descriptions.Item label="发送人">
|
||||
{{ formData?.templateNickname }}
|
||||
@@ -41,10 +47,16 @@ const [Modal, modalApi] = useVbenModal({
|
||||
{{ formatDateTime(formData?.createTime) }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="消息类型">
|
||||
<DictTag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="formData?.templateType" />
|
||||
<DictTag
|
||||
:type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE"
|
||||
:value="formData?.templateType"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="是否已读">
|
||||
<DictTag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="formData?.readStatus" />
|
||||
<DictTag
|
||||
:type="DICT_TYPE.INFRA_BOOLEAN_STRING"
|
||||
:value="formData?.readStatus"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="阅读时间">
|
||||
{{ formatDateTime(formData?.readTime || '') }}
|
||||
|
||||
@@ -2,11 +2,12 @@ import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemNotifyTemplateApi } from '#/api/system/notify/template';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { CommonStatusEnum } from '#/utils/constants';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||
import { useAccess } from '@vben/access';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
@@ -191,9 +192,9 @@ export function useSendNotifyFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns<T = SystemNotifyTemplateApi.SystemNotifyTemplate>(
|
||||
onActionClick: OnActionClickFn<T>,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
export function useGridColumns<
|
||||
T = SystemNotifyTemplateApi.SystemNotifyTemplate,
|
||||
>(onActionClick: OnActionClickFn<T>): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
@@ -267,8 +268,8 @@ export function useGridColumns<T = SystemNotifyTemplateApi.SystemNotifyTemplate>
|
||||
code: 'edit',
|
||||
show: hasAccessByCodes(['system:notify-template:update']),
|
||||
},
|
||||
{
|
||||
code: 'send',
|
||||
{
|
||||
code: 'send',
|
||||
text: '测试',
|
||||
show: hasAccessByCodes(['system:notify-template:send-notify']),
|
||||
},
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { SystemNotifyTemplateApi } from '#/api/system/notify/template';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Download, Plus } from '@vben/icons';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
import Form from './modules/form.vue';
|
||||
import SendForm from './modules/send-form.vue';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteNotifyTemplate, exportNotifyTemplate, getNotifyTemplatePage } from '#/api/system/notify/template';
|
||||
import {
|
||||
deleteNotifyTemplate,
|
||||
exportNotifyTemplate,
|
||||
getNotifyTemplatePage,
|
||||
} from '#/api/system/notify/template';
|
||||
import { DocAlert } from '#/components/doc-alert';
|
||||
import { $t } from '#/locales';
|
||||
import { downloadByData } from '#/utils/download';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
import SendForm from './modules/send-form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
@@ -77,14 +85,14 @@ function onActionClick({
|
||||
row,
|
||||
}: OnActionClickParams<SystemNotifyTemplateApi.SystemNotifyTemplate>) {
|
||||
switch (code) {
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
case 'delete': {
|
||||
onDelete(row);
|
||||
break;
|
||||
}
|
||||
case 'edit': {
|
||||
onEdit(row);
|
||||
break;
|
||||
}
|
||||
case 'send': {
|
||||
onSend(row);
|
||||
break;
|
||||
@@ -130,11 +138,20 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<SendModal />
|
||||
<Grid table-title="站内信模板列表">
|
||||
<template #toolbar-tools>
|
||||
<Button type="primary" @click="onCreate" v-access:code="['system:notify-template:create']">
|
||||
<Button
|
||||
type="primary"
|
||||
@click="onCreate"
|
||||
v-access:code="['system:notify-template:create']"
|
||||
>
|
||||
<Plus class="size-5" />
|
||||
{{ $t('ui.actionTitle.create', ['站内信模板']) }}
|
||||
</Button>
|
||||
<Button type="primary" class="ml-2" @click="onExport" v-access:code="['system:notify-template:export']">
|
||||
<Button
|
||||
type="primary"
|
||||
class="ml-2"
|
||||
@click="onExport"
|
||||
v-access:code="['system:notify-template:export']"
|
||||
>
|
||||
<Download class="size-5" />
|
||||
{{ $t('ui.actionTitle.export') }}
|
||||
</Button>
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SystemNotifyTemplateApi } from '#/api/system/notify/template';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createNotifyTemplate, getNotifyTemplate, updateNotifyTemplate } from '#/api/system/notify/template';
|
||||
import {
|
||||
createNotifyTemplate,
|
||||
getNotifyTemplate,
|
||||
updateNotifyTemplate,
|
||||
} from '#/api/system/notify/template';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
@@ -33,9 +39,12 @@ const [Modal, modalApi] = useVbenModal({
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as SystemNotifyTemplateApi.SystemNotifyTemplate;
|
||||
const data =
|
||||
(await formApi.getValues()) as SystemNotifyTemplateApi.SystemNotifyTemplate;
|
||||
try {
|
||||
await (formData.value?.id ? updateNotifyTemplate(data) : createNotifyTemplate(data));
|
||||
await (formData.value?.id
|
||||
? updateNotifyTemplate(data)
|
||||
: createNotifyTemplate(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
@@ -52,7 +61,8 @@ const [Modal, modalApi] = useVbenModal({
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<SystemNotifyTemplateApi.SystemNotifyTemplate>();
|
||||
const data =
|
||||
modalApi.getData<SystemNotifyTemplateApi.SystemNotifyTemplate>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SystemNotifyTemplateApi } from '#/api/system/notify/template';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { sendNotify } from '#/api/system/notify/template';
|
||||
import { $t } from '#/locales';
|
||||
@@ -65,7 +67,8 @@ const [Modal, modalApi] = useVbenModal({
|
||||
return;
|
||||
}
|
||||
// 获取数据
|
||||
const data = modalApi.getData<SystemNotifyTemplateApi.SystemNotifyTemplate>();
|
||||
const data =
|
||||
modalApi.getData<SystemNotifyTemplateApi.SystemNotifyTemplate>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
@@ -93,7 +96,7 @@ const buildFormSchema = () => {
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
placeholder: `请输入参数 ${param}`,
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user