feat:【antd/ele】【mp】freePublish review

This commit is contained in:
YunaiV
2025-11-24 11:47:47 +08:00
parent ffba101d39
commit 2926a8aa36
4 changed files with 31 additions and 23 deletions

View File

@@ -72,12 +72,12 @@ async function handleDelete(row: MpDraftApi.DraftArticle) {
return; return;
} }
const hideLoading = message.loading({ const hideLoading = message.loading({
content: '删除中...', content: $t('ui.actionMessage.deleting'),
duration: 0, duration: 0,
}); });
try { try {
await deleteDraft(accountId, row.mediaId); await deleteDraft(accountId, row.mediaId);
message.success('删除成功'); message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh(); handleRefresh();
} finally { } finally {
hideLoading(); hideLoading();

View File

@@ -1,7 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MpFreePublishApi } from '#/api/mp/freePublish'; import type { MpFreePublishApi } from '#/api/mp/freePublish';
import { confirm, DocAlert, Page } from '@vben/common-ui'; import { DocAlert, Page } from '@vben/common-ui';
import { Image, message, Typography } from 'ant-design-vue'; import { Image, message, Typography } from 'ant-design-vue';
@@ -11,6 +12,7 @@ import { $t } from '#/locales';
import { WxAccountSelect } from '#/views/mp/components'; import { WxAccountSelect } from '#/views/mp/components';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
/** 刷新表格 */ /** 刷新表格 */
function handleRefresh() { function handleRefresh() {
gridApi.query(); gridApi.query();
@@ -21,20 +23,22 @@ function handleAccountChange(accountId: number) {
gridApi.formApi.setValues({ accountId }); gridApi.formApi.setValues({ accountId });
gridApi.formApi.submitForm(); gridApi.formApi.submitForm();
} }
/** 删除文章 */ /** 删除文章 */
async function handleDelete(row: MpFreePublishApi.FreePublish) { async function handleDelete(row: MpFreePublishApi.FreePublish) {
// 二次确认提示 const formValues = await gridApi.formApi.getValues();
await confirm($t('ui.actionMessage.deleteConfirm', ['文章'])); const accountId = formValues.accountId;
if (!accountId) {
message.warning('请先选择公众号');
return;
}
const hideLoading = message.loading({ const hideLoading = message.loading({
content: '删除中...', content: $t('ui.actionMessage.deleting'),
duration: 0, duration: 0,
}); });
try { try {
const formValues = await gridApi.formApi.getValues();
const accountId = formValues.accountId;
await deleteFreePublish(accountId, row.articleId!); await deleteFreePublish(accountId, row.articleId!);
message.success($t('ui.actionMessage.deleteSuccess', ['文章'])); message.success($t('ui.actionMessage.deleteSuccess'));
// 刷新列表
handleRefresh(); handleRefresh();
} finally { } finally {
hideLoading(); hideLoading();
@@ -73,6 +77,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}); });
} }
}); });
// TODO @jaweArticle 类型,报错;
return { return {
list: res.list as unknown as Article[], list: res.list as unknown as Article[],
total: res.total, total: res.total,

View File

@@ -72,11 +72,11 @@ async function handleDelete(row: MpDraftApi.DraftArticle) {
return; return;
} }
const hideLoading = ElLoading.service({ const hideLoading = ElLoading.service({
text: '删除中...', text: $t('ui.actionMessage.deleting'),
}); });
try { try {
await deleteDraft(accountId, row.mediaId); await deleteDraft(accountId, row.mediaId);
ElMessage.success('删除成功'); ElMessage.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh(); handleRefresh();
} finally { } finally {
hideLoading.close(); hideLoading.close();

View File

@@ -1,9 +1,10 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MpFreePublishApi } from '#/api/mp/freePublish'; import type { MpFreePublishApi } from '#/api/mp/freePublish';
import { confirm, DocAlert, Page } from '@vben/common-ui'; import { DocAlert, Page } from '@vben/common-ui';
import { ElImage, ElLink, ElLoading } from 'element-plus'; import { ElImage, ElLink, ElLoading, ElMessage } from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { deleteFreePublish, getFreePublishPage } from '#/api/mp/freePublish'; import { deleteFreePublish, getFreePublishPage } from '#/api/mp/freePublish';
@@ -25,20 +26,21 @@ function handleAccountChange(accountId: number) {
/** 删除文章 */ /** 删除文章 */
async function handleDelete(row: MpFreePublishApi.FreePublish) { async function handleDelete(row: MpFreePublishApi.FreePublish) {
// 二次确认提示 const formValues = await gridApi.formApi.getValues();
await confirm($t('ui.actionMessage.deleteConfirm', ['文章'])); const accountId = formValues.accountId;
const hideLoading = ElLoading.service({ if (!accountId) {
text: '删除中...', ElMessage.warning('请先选择公众号');
return;
}
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting'),
}); });
try { try {
const formValues = await gridApi.formApi.getValues();
const accountId = formValues.accountId;
await deleteFreePublish(accountId, row.articleId!); await deleteFreePublish(accountId, row.articleId!);
message.success($t('ui.actionMessage.deleteSuccess', ['文章'])); ElMessage.success($t('ui.actionMessage.deleteSuccess'));
// 刷新列表
handleRefresh(); handleRefresh();
} finally { } finally {
hideLoading(); loadingInstance.close();
} }
} }
@@ -74,6 +76,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}); });
} }
}); });
// TODO @jaweArticle 类型,报错;
return { return {
list: res.list as unknown as Article[], list: res.list as unknown as Article[],
total: res.total, total: res.total,