From a3890a120f4e730a9d8f5a222d6a860a967bfdf3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 25 Oct 2025 15:01:31 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90ele=E3=80=91mp/tag=20?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/views/mp/account/index.vue | 6 +- apps/web-antd/src/views/mp/statistics/data.ts | 1 - apps/web-antd/src/views/mp/tag/data.ts | 8 +- apps/web-antd/src/views/mp/tag/index.vue | 20 ++- .../src/views/mp/tag/modules/form.vue | 4 +- apps/web-ele/src/views/mp/account/index.vue | 6 +- apps/web-ele/src/views/mp/statistics/data.ts | 1 - apps/web-ele/src/views/mp/tag/data.ts | 93 ++++++++++ apps/web-ele/src/views/mp/tag/index.vue | 166 ++++++++++++++++++ .../web-ele/src/views/mp/tag/modules/form.vue | 83 +++++++++ 10 files changed, 369 insertions(+), 19 deletions(-) create mode 100644 apps/web-ele/src/views/mp/tag/data.ts create mode 100644 apps/web-ele/src/views/mp/tag/index.vue create mode 100644 apps/web-ele/src/views/mp/tag/modules/form.vue diff --git a/apps/web-antd/src/views/mp/account/index.vue b/apps/web-antd/src/views/mp/account/index.vue index 4fd7ab516..cd3434189 100644 --- a/apps/web-antd/src/views/mp/account/index.vue +++ b/apps/web-antd/src/views/mp/account/index.vue @@ -45,7 +45,7 @@ async function handleDelete(row: MpAccountApi.Account) { duration: 0, }); try { - await deleteAccount(row.id as number); + await deleteAccount(row.id!); message.success($t('ui.actionMessage.deleteSuccess', [row.name])); handleRefresh(); } finally { @@ -60,7 +60,7 @@ async function handleGenerateQrCode(row: MpAccountApi.Account) { duration: 0, }); try { - await generateAccountQrCode(row.id as number); + await generateAccountQrCode(row.id!); message.success($t('ui.actionMessage.operationSuccess')); handleRefresh(); } finally { @@ -75,7 +75,7 @@ async function handleCleanQuota(row: MpAccountApi.Account) { duration: 0, }); try { - await clearAccountQuota(row.id as number); + await clearAccountQuota(row.id!); message.success($t('ui.actionMessage.operationSuccess')); } finally { hideLoading(); diff --git a/apps/web-antd/src/views/mp/statistics/data.ts b/apps/web-antd/src/views/mp/statistics/data.ts index 769b4c9e7..2572aed30 100644 --- a/apps/web-antd/src/views/mp/statistics/data.ts +++ b/apps/web-antd/src/views/mp/statistics/data.ts @@ -22,7 +22,6 @@ export function useGridFormSchema(): VbenFormSchema[] { value: item.id, })), placeholder: '请选择公众号', - allowClear: true, }, defaultValue: accountList[0]?.id, }, diff --git a/apps/web-antd/src/views/mp/tag/data.ts b/apps/web-antd/src/views/mp/tag/data.ts index 30f9a3b1f..e8efd6fba 100644 --- a/apps/web-antd/src/views/mp/tag/data.ts +++ b/apps/web-antd/src/views/mp/tag/data.ts @@ -4,6 +4,7 @@ import type { MpAccountApi } from '#/api/mp/account'; import { getSimpleAccountList } from '#/api/mp/account'; +/** 关联数据 */ let accountList: MpAccountApi.AccountSimple[] = []; getSimpleAccountList().then((data) => (accountList = data)); @@ -45,14 +46,13 @@ export function useGridFormSchema(): VbenFormSchema[] { { fieldName: 'accountId', label: '公众号', - component: 'Select', + component: 'ApiSelect', componentProps: { options: accountList.map((item) => ({ label: item.name, value: item.id, })), placeholder: '请选择公众号', - allowClear: true, }, defaultValue: accountList[0]?.id, }, @@ -65,19 +65,23 @@ export function useGridColumns(): VxeGridPropTypes.Columns { { title: '编号', field: 'id', + minWidth: 80, }, { title: '标签名称', field: 'name', + minWidth: 150, }, { title: '粉丝数', field: 'count', + minWidth: 100, }, { title: '创建时间', field: 'createTime', formatter: 'formatDateTime', + minWidth: 180, }, { title: '操作', diff --git a/apps/web-antd/src/views/mp/tag/index.vue b/apps/web-antd/src/views/mp/tag/index.vue index 8545bd182..a9a8b2c31 100644 --- a/apps/web-antd/src/views/mp/tag/index.vue +++ b/apps/web-antd/src/views/mp/tag/index.vue @@ -27,6 +27,10 @@ function handleRefresh() { async function handleCreate() { const formValues = await gridApi.formApi.getValues(); const accountId = formValues.accountId; + if (!accountId) { + message.warning('请先选择公众号'); + return; + } formModalApi.setData({ accountId }).open(); } @@ -34,6 +38,10 @@ async function handleCreate() { async function handleEdit(row: MpTagApi.Tag) { const formValues = await gridApi.formApi.getValues(); const accountId = formValues.accountId; + if (!accountId) { + message.warning('请先选择公众号'); + return; + } formModalApi.setData({ row, accountId }).open(); } @@ -44,15 +52,14 @@ async function handleDelete(row: MpTagApi.Tag) { duration: 0, }); try { - await deleteTag(row.id as number); - message.success({ - content: $t('ui.actionMessage.deleteSuccess', [row.name]), - }); + await deleteTag(row.id!); + message.success($t('ui.actionMessage.deleteSuccess', [row.name])); handleRefresh(); } finally { hideLoading(); } } + /** 同步标签 */ async function handleSync() { const formValues = await gridApi.formApi.getValues(); @@ -69,9 +76,7 @@ async function handleSync() { }); try { await syncTag(accountId); - message.success({ - content: '同步标签成功', - }); + message.success('同步标签成功'); handleRefresh(); } finally { hideLoading(); @@ -99,6 +104,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, rowConfig: { keyField: 'id', + isHover: true, }, toolbarConfig: { refresh: true, diff --git a/apps/web-antd/src/views/mp/tag/modules/form.vue b/apps/web-antd/src/views/mp/tag/modules/form.vue index 66295e075..bd19e7d3d 100644 --- a/apps/web-antd/src/views/mp/tag/modules/form.vue +++ b/apps/web-antd/src/views/mp/tag/modules/form.vue @@ -66,7 +66,7 @@ const [Modal, modalApi] = useVbenModal({ } modalApi.lock(); try { - formData.value = await getTag(data.row.id as number); + formData.value = await getTag(data.row.id!); // 设置到 values await formApi.setValues(formData.value); } finally { @@ -77,7 +77,7 @@ const [Modal, modalApi] = useVbenModal({ diff --git a/apps/web-ele/src/views/mp/account/index.vue b/apps/web-ele/src/views/mp/account/index.vue index 3127f9eab..dd3f4785e 100644 --- a/apps/web-ele/src/views/mp/account/index.vue +++ b/apps/web-ele/src/views/mp/account/index.vue @@ -44,7 +44,7 @@ async function handleDelete(row: MpAccountApi.Account) { text: $t('ui.actionMessage.deleting', [row.name]), }); try { - await deleteAccount(row.id as number); + await deleteAccount(row.id!); ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name])); handleRefresh(); } finally { @@ -58,7 +58,7 @@ async function handleGenerateQrCode(row: MpAccountApi.Account) { text: '正在生成二维码中...', }); try { - await generateAccountQrCode(row.id as number); + await generateAccountQrCode(row.id!); ElMessage.success($t('ui.actionMessage.operationSuccess')); handleRefresh(); } finally { @@ -72,7 +72,7 @@ async function handleCleanQuota(row: MpAccountApi.Account) { text: $t('ui.actionMessage.processing', ['清空 API 配额']), }); try { - await clearAccountQuota(row.id as number); + await clearAccountQuota(row.id!); ElMessage.success($t('ui.actionMessage.operationSuccess')); } finally { loadingInstance.close(); diff --git a/apps/web-ele/src/views/mp/statistics/data.ts b/apps/web-ele/src/views/mp/statistics/data.ts index 7ec41d0d0..2572aed30 100644 --- a/apps/web-ele/src/views/mp/statistics/data.ts +++ b/apps/web-ele/src/views/mp/statistics/data.ts @@ -22,7 +22,6 @@ export function useGridFormSchema(): VbenFormSchema[] { value: item.id, })), placeholder: '请选择公众号', - clearable: true, }, defaultValue: accountList[0]?.id, }, diff --git a/apps/web-ele/src/views/mp/tag/data.ts b/apps/web-ele/src/views/mp/tag/data.ts new file mode 100644 index 000000000..e8efd6fba --- /dev/null +++ b/apps/web-ele/src/views/mp/tag/data.ts @@ -0,0 +1,93 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeGridPropTypes } from '#/adapter/vxe-table'; +import type { MpAccountApi } from '#/api/mp/account'; + +import { getSimpleAccountList } from '#/api/mp/account'; + +/** 关联数据 */ +let accountList: MpAccountApi.AccountSimple[] = []; +getSimpleAccountList().then((data) => (accountList = data)); + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'accountId', + label: '公众号', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '标签名称', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入名称', + }, + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'accountId', + label: '公众号', + component: 'ApiSelect', + componentProps: { + options: accountList.map((item) => ({ + label: item.name, + value: item.id, + })), + placeholder: '请选择公众号', + }, + defaultValue: accountList[0]?.id, + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeGridPropTypes.Columns { + return [ + { + title: '编号', + field: 'id', + minWidth: 80, + }, + { + title: '标签名称', + field: 'name', + minWidth: 150, + }, + { + title: '粉丝数', + field: 'count', + minWidth: 100, + }, + { + title: '创建时间', + field: 'createTime', + formatter: 'formatDateTime', + minWidth: 180, + }, + { + title: '操作', + width: 140, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-ele/src/views/mp/tag/index.vue b/apps/web-ele/src/views/mp/tag/index.vue new file mode 100644 index 000000000..ad1490bb8 --- /dev/null +++ b/apps/web-ele/src/views/mp/tag/index.vue @@ -0,0 +1,166 @@ + + + diff --git a/apps/web-ele/src/views/mp/tag/modules/form.vue b/apps/web-ele/src/views/mp/tag/modules/form.vue new file mode 100644 index 000000000..ca1bf4a02 --- /dev/null +++ b/apps/web-ele/src/views/mp/tag/modules/form.vue @@ -0,0 +1,83 @@ + + +