mirror of
https://gitee.com/yudaocode/yudao-ui-admin-vben.git
synced 2025-12-30 10:32:25 +00:00
Merge remote-tracking branch 'yudao/dev' into dev
This commit is contained in:
@@ -3,6 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/** 素材类型枚举 */
|
||||
// TODO @xingyu:芋艿,可能要整理下枚举;
|
||||
export enum MaterialType {
|
||||
IMAGE = 1, // 图片
|
||||
THUMB = 4, // 缩略图
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/** 菜单类型枚举 */
|
||||
// TODO @xingyu:芋艿,可能要整理下枚举;
|
||||
export enum MenuType {
|
||||
CLICK = 'click', // 点击推事件
|
||||
LOCATION_SELECT = 'location_select', // 发送位置
|
||||
@@ -11,7 +12,7 @@ export enum MenuType {
|
||||
PIC_WEIXIN = 'pic_weixin', // 微信相册发图
|
||||
SCANCODE_PUSH = 'scancode_push', // 扫码推事件
|
||||
SCANCODE_WAITMSG = 'scancode_waitmsg', // 扫码带提示
|
||||
VIEW = 'view', // 跳转URL
|
||||
VIEW = 'view', // 跳转 URL
|
||||
VIEW_LIMITED = 'view_limited', // 跳转图文消息URL
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/** 消息类型枚举 */
|
||||
// TODO @xingyu:芋艿,可能要整理下枚举;
|
||||
export enum MessageType {
|
||||
IMAGE = 'image', // 图片消息
|
||||
MPNEWS = 'mpnews', // 公众号图文消息
|
||||
@@ -29,7 +30,7 @@ export namespace MpMessageApi {
|
||||
}
|
||||
|
||||
/** 发送消息请求 */
|
||||
export interface SendMessageRequest {
|
||||
export interface MessageSendRequestVO {
|
||||
accountId: number;
|
||||
openid: string;
|
||||
type: MessageType;
|
||||
@@ -49,6 +50,6 @@ export function getMessagePage(params: PageParam) {
|
||||
}
|
||||
|
||||
/** 发送消息 */
|
||||
export function sendMessage(data: MpMessageApi.SendMessageRequest) {
|
||||
export function sendMessage(data: MpMessageApi.MessageSendRequestVO) {
|
||||
return requestClient.post('/mp/message/send', data);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MpStatisticsApi {
|
||||
/** 统计查询参数 */
|
||||
export interface StatisticsQuery {
|
||||
export interface StatisticsGetReqVO {
|
||||
accountId: number;
|
||||
date: Date[];
|
||||
}
|
||||
|
||||
/** 消息发送概况数据 */
|
||||
export interface UpstreamMessage {
|
||||
export interface StatisticsUpstreamMessageRespVO {
|
||||
refDate: string;
|
||||
msgType: string;
|
||||
msgUser: number;
|
||||
@@ -16,7 +16,7 @@ export namespace MpStatisticsApi {
|
||||
}
|
||||
|
||||
/** 用户增减数据 */
|
||||
export interface UserSummary {
|
||||
export interface StatisticsUserSummaryRespVO {
|
||||
refDate: string;
|
||||
userSource: number;
|
||||
newUser: number;
|
||||
@@ -25,13 +25,13 @@ export namespace MpStatisticsApi {
|
||||
}
|
||||
|
||||
/** 用户累计数据 */
|
||||
export interface UserCumulate {
|
||||
export interface StatisticsUserCumulateRespVO {
|
||||
refDate: string;
|
||||
cumulateUser: number;
|
||||
}
|
||||
|
||||
/** 接口分析数据 */
|
||||
export interface InterfaceSummary {
|
||||
export interface StatisticsInterfaceSummaryRespVO {
|
||||
refDate: string;
|
||||
callbackCount: number;
|
||||
failCount: number;
|
||||
@@ -41,8 +41,8 @@ export namespace MpStatisticsApi {
|
||||
}
|
||||
|
||||
/** 获取消息发送概况数据 */
|
||||
export function getUpstreamMessage(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.UpstreamMessage[]>(
|
||||
export function getUpstreamMessage(params: MpStatisticsApi.StatisticsGetReqVO) {
|
||||
return requestClient.get<MpStatisticsApi.StatisticsUpstreamMessageRespVO[]>(
|
||||
'/mp/statistics/upstream-message',
|
||||
{
|
||||
params,
|
||||
@@ -51,8 +51,8 @@ export function getUpstreamMessage(params: MpStatisticsApi.StatisticsQuery) {
|
||||
}
|
||||
|
||||
/** 获取用户增减数据 */
|
||||
export function getUserSummary(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.UserSummary[]>(
|
||||
export function getUserSummary(params: MpStatisticsApi.StatisticsGetReqVO) {
|
||||
return requestClient.get<MpStatisticsApi.StatisticsUserSummaryRespVO[]>(
|
||||
'/mp/statistics/user-summary',
|
||||
{
|
||||
params,
|
||||
@@ -61,8 +61,8 @@ export function getUserSummary(params: MpStatisticsApi.StatisticsQuery) {
|
||||
}
|
||||
|
||||
/** 获取用户累计数据 */
|
||||
export function getUserCumulate(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.UserCumulate[]>(
|
||||
export function getUserCumulate(params: MpStatisticsApi.StatisticsGetReqVO) {
|
||||
return requestClient.get<MpStatisticsApi.StatisticsUserCumulateRespVO[]>(
|
||||
'/mp/statistics/user-cumulate',
|
||||
{
|
||||
params,
|
||||
@@ -71,8 +71,10 @@ export function getUserCumulate(params: MpStatisticsApi.StatisticsQuery) {
|
||||
}
|
||||
|
||||
/** 获取接口分析数据 */
|
||||
export function getInterfaceSummary(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.InterfaceSummary[]>(
|
||||
export function getInterfaceSummary(
|
||||
params: MpStatisticsApi.StatisticsGetReqVO,
|
||||
) {
|
||||
return requestClient.get<MpStatisticsApi.StatisticsInterfaceSummaryRespVO[]>(
|
||||
'/mp/statistics/interface-summary',
|
||||
{
|
||||
params,
|
||||
|
||||
@@ -11,12 +11,6 @@ export namespace MpTagApi {
|
||||
count?: number;
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 标签分页查询参数 */
|
||||
export interface TagPageQuery extends PageParam {
|
||||
accountId?: number;
|
||||
name?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/** 创建公众号标签 */
|
||||
@@ -44,7 +38,7 @@ export function getTag(id: number) {
|
||||
}
|
||||
|
||||
/** 获取公众号标签分页 */
|
||||
export function getTagPage(params: MpTagApi.TagPageQuery) {
|
||||
export function getTagPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MpTagApi.Tag>>('/mp/tag/page', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -21,13 +21,6 @@ export namespace MpUserApi {
|
||||
tagIds?: number[];
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 用户分页查询参数 */
|
||||
export interface UserPageQuery extends PageParam {
|
||||
accountId?: number;
|
||||
nickname?: string;
|
||||
tagId?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 更新公众号粉丝 */
|
||||
@@ -43,7 +36,7 @@ export function getUser(id: number) {
|
||||
}
|
||||
|
||||
/** 获取公众号粉丝分页 */
|
||||
export function getUserPage(params: MpUserApi.UserPageQuery) {
|
||||
export function getUserPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MpUserApi.User>>('/mp/user/page', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -5,8 +5,8 @@ import { computed, onBeforeUnmount, ref, shallowRef } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
// @ts-ignore - tinymce vue 声明文件按项目依赖提供
|
||||
import Editor from '@tinymce/tinymce-vue';
|
||||
import { Alert, Button } from 'ant-design-vue';
|
||||
|
||||
import { setupTinyPlugins } from './tinymce-plugin';
|
||||
|
||||
@@ -23,9 +23,7 @@ const props = withDefaults(
|
||||
const tinymceScriptSrc = `${import.meta.env.VITE_BASE}tinymce/tinymce.min.js`;
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
closable: true,
|
||||
footer: false,
|
||||
title: '自定义模板',
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
return;
|
||||
@@ -51,7 +49,6 @@ const handleConfirm = () => {
|
||||
modalApi.close();
|
||||
};
|
||||
|
||||
// 提供给 @ 自动补全的字段(默认 + 表单字段)
|
||||
const mentionList = computed<MentionItem[]>(() => {
|
||||
const base: MentionItem[] = [
|
||||
{ id: 'startUser', name: '发起人' },
|
||||
@@ -70,11 +67,10 @@ const mentionList = computed<MentionItem[]>(() => {
|
||||
name: `[表单]${it.title}`,
|
||||
}));
|
||||
return [...base, ...extras];
|
||||
});
|
||||
}); // 提供给 @ 自动补全的字段(默认 + 表单字段)
|
||||
|
||||
// 编辑器
|
||||
const valueHtml = ref<string>('');
|
||||
const editorRef = shallowRef<any>();
|
||||
const editorRef = shallowRef<any>(); // 编辑器
|
||||
|
||||
const tinyInit = {
|
||||
height: 400,
|
||||
@@ -103,9 +99,10 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-3/4">
|
||||
<!-- TODO @jason:a-button 改成 Modal 自带的 onConfirm 替代;= = 我貌似试着改了下,有点问题,略奇怪 -->
|
||||
<Modal class="w-3/4" title="自定义模板">
|
||||
<div class="mb-3">
|
||||
<a-alert
|
||||
<Alert
|
||||
message="输入 @ 可选择插入流程选项和表单选项"
|
||||
type="info"
|
||||
show-icon
|
||||
@@ -119,8 +116,8 @@ onBeforeUnmount(() => {
|
||||
/>
|
||||
<template #footer>
|
||||
<div class="flex justify-end gap-2">
|
||||
<a-button @click="modalApi.onCancel()">取 消</a-button>
|
||||
<a-button type="primary" @click="handleConfirm">确 定</a-button>
|
||||
<Button @click="modalApi.onCancel()">取 消</Button>
|
||||
<Button type="primary" @click="handleConfirm">确 定</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
|
||||
@@ -319,14 +319,6 @@ const defaultTemplate = `<p style="text-align: center;font-size: 1.25rem;"><stro
|
||||
</div>
|
||||
<p> </p>`;
|
||||
|
||||
const handlePrintTemplateEnableChange = (checked: any) => {
|
||||
const val = !!checked;
|
||||
if (val && !modelData.value.printTemplateSetting.template) {
|
||||
modelData.value.printTemplateSetting.template = defaultTemplate;
|
||||
}
|
||||
};
|
||||
|
||||
// 自定义打印模板开关
|
||||
const printTemplateEnable = computed<boolean>({
|
||||
get() {
|
||||
return !!modelData.value?.printTemplateSetting?.enable;
|
||||
@@ -338,9 +330,16 @@ const printTemplateEnable = computed<boolean>({
|
||||
template: '',
|
||||
};
|
||||
}
|
||||
modelData.value.printTemplateSetting.enable = !!val;
|
||||
modelData.value.printTemplateSetting.enable = val;
|
||||
},
|
||||
});
|
||||
}); // 自定义打印模板开关
|
||||
|
||||
function handlePrintTemplateEnableChange(checked: any) {
|
||||
const val = !!checked;
|
||||
if (val && !modelData.value.printTemplateSetting.template) {
|
||||
modelData.value.printTemplateSetting.template = defaultTemplate;
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ initData, validate });
|
||||
</script>
|
||||
|
||||
@@ -16,6 +16,7 @@ import { MsgType } from './types';
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
// TODO @芋艿:要不要使用统一枚举?
|
||||
const RequestMessageTypes = new Set([
|
||||
'image',
|
||||
'link',
|
||||
@@ -148,6 +149,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
|
||||
fieldName: 'reply',
|
||||
label: '回复消息',
|
||||
component: markRaw(WxReply),
|
||||
// TODO @hw:这里注释,要不要删除掉?
|
||||
// componentProps: {
|
||||
// modelValue: { type: 'video', content: '12456' },
|
||||
// },
|
||||
@@ -157,6 +159,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
// TODO @芋艿:貌似可能微信号拿不到。
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MpAutoReplyApi } from '#/api/mp/autoReply';
|
||||
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
|
||||
@@ -25,6 +26,23 @@ defineOptions({ name: 'MpAutoReply' });
|
||||
|
||||
const msgType = ref<string>(String(MsgType.Keyword)); // 消息类型
|
||||
|
||||
const showCreateButton = computed(() => {
|
||||
if (Number(msgType.value) !== MsgType.Follow) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const tableData = gridApi.grid?.getTableData();
|
||||
return (tableData?.tableData?.length || 0) <= 0;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}); // 计算是否显示新增按钮:关注时回复类型只有在没有数据时才显示
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 切换回复类型 */
|
||||
async function onTabChange(tabName: any) {
|
||||
msgType.value = tabName;
|
||||
@@ -41,7 +59,7 @@ async function onTabChange(tabName: any) {
|
||||
await gridApi.query();
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
/** 新增自动回复 */
|
||||
async function handleCreate() {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
formModalApi
|
||||
@@ -52,7 +70,7 @@ async function handleCreate() {
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
/** 修改自动回复 */
|
||||
async function handleEdit(row: any) {
|
||||
const data = (await getAutoReply(row.id)) as any;
|
||||
formModalApi
|
||||
@@ -64,7 +82,7 @@ async function handleEdit(row: any) {
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
/** 删除自动回复 */
|
||||
async function handleDelete(row: any) {
|
||||
await confirm('是否确认删除此数据?');
|
||||
const hideLoading = message.loading({
|
||||
@@ -114,28 +132,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<any>,
|
||||
} as VxeTableGridOptions<MpAutoReplyApi.AutoReply>,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
// 计算是否显示新增按钮:关注时回复类型只有在没有数据时才显示
|
||||
const showCreateButton = computed(() => {
|
||||
if (Number(msgType.value) !== MsgType.Follow) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const tableData = gridApi.grid?.getTableData();
|
||||
return (tableData?.tableData?.length || 0) <= 0;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// DONE @hw:看看能不能参考 tag/index.vue 简化下
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -145,9 +143,7 @@ const showCreateButton = computed(() => {
|
||||
</template>
|
||||
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="自动回复列表">
|
||||
<!-- 第一层:公众号选择(在表单中) -->
|
||||
<!-- 第二层:tab 切换 -->
|
||||
<Grid>
|
||||
<template #toolbar-actions>
|
||||
<Tabs
|
||||
v-model:active-key="msgType"
|
||||
|
||||
@@ -41,8 +41,6 @@ const [Form, formApi] = useVbenForm({
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
// 注意:schema 的更新现在在 onOpenChange 中手动处理,避免时序问题
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
@@ -115,6 +113,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
// 编辑:加载数据
|
||||
const rowData = data.row;
|
||||
const formValues: any = { ...rowData };
|
||||
// TODO @hw:下面要删除掉么,注释。
|
||||
// delete formValues.responseMessageType;
|
||||
// delete formValues.responseContent;
|
||||
// delete formValues.responseMediaId;
|
||||
|
||||
@@ -27,7 +27,6 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
// DONE @hw:这里的公众号选择,要改参考 /apps/web-antd/src/views/mp/tag/data.ts;相关联的代码还简单点~
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
|
||||
@@ -10,7 +10,6 @@ import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteDraft, getDraftPage } from '#/api/mp/draft';
|
||||
// DONE @hw:MpFreePublishApi 去掉,直接 import;参考别的模块哈;
|
||||
import { submitFreePublish } from '#/api/mp/freePublish';
|
||||
import { createEmptyNewsItem } from '#/views/mp/draft/modules/types';
|
||||
|
||||
@@ -18,8 +17,6 @@ import { useGridColumns, useGridFormSchema } from './data';
|
||||
import DraftTableCell from './modules/draft-table.vue';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
// DONE @hw:参考 tag/index.vue 放到 formValues.accountId;
|
||||
// DONE @hw:看看这个 watch、provide 能不能简化掉;
|
||||
defineOptions({ name: 'MpDraft' });
|
||||
|
||||
/** 刷新表格 */
|
||||
@@ -27,12 +24,7 @@ function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 新增按钮操作 */
|
||||
/** 新增草稿 */
|
||||
async function handleCreate() {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
@@ -49,7 +41,7 @@ async function handleCreate() {
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
/** 修改草稿 */
|
||||
async function handleEdit(row: Article) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
@@ -67,11 +59,32 @@ async function handleEdit(row: Article) {
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 发布按钮操作 */
|
||||
/** 删除草稿 */
|
||||
async function handleDelete(row: Article) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
if (!accountId) {
|
||||
message.warning('请先选择公众号');
|
||||
return;
|
||||
}
|
||||
await confirm('此操作将永久删除该草稿, 是否继续?');
|
||||
const hideLoading = message.loading({
|
||||
content: '删除中...',
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteDraft(accountId, row.mediaId);
|
||||
message.success('删除成功');
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 发布草稿 */
|
||||
async function handlePublish(row: Article) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
// DONE @hw:看看能不能去掉 -1 的判断哈?
|
||||
if (!accountId) {
|
||||
message.warning('请先选择公众号');
|
||||
return;
|
||||
@@ -94,27 +107,10 @@ async function handlePublish(row: Article) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
async function handleDelete(row: Article) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
if (!accountId) {
|
||||
message.warning('请先选择公众号');
|
||||
return;
|
||||
}
|
||||
await confirm('此操作将永久删除该草稿, 是否继续?');
|
||||
const hideLoading = message.loading({
|
||||
content: '删除中...',
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteDraft(accountId, row.mediaId);
|
||||
message.success('删除成功');
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
@@ -157,10 +153,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
// TODO @hw:这里有点纠结,一般是 MpDraftApi.Article,但是一改貌似就 linter 告警了。
|
||||
} as VxeTableGridOptions<Article>,
|
||||
});
|
||||
|
||||
// DONE @hw:看看能不能参考 tag/index.vue 简化下
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -56,12 +56,11 @@ function onMaterialSelected(item: any) {
|
||||
newsItem.value.thumbMediaId = item.mediaId;
|
||||
newsItem.value.thumbUrl = item.url;
|
||||
}
|
||||
// DONE @hw:注释都补充下哈;
|
||||
|
||||
/** 上传前校验 */
|
||||
const onBeforeUpload = (file: UploadFile) =>
|
||||
useBeforeUpload(UploadType.Image, 2)(file as any);
|
||||
|
||||
// DONE @hw:注释都补充下哈;
|
||||
/** 上传错误处理 */
|
||||
function onUploadChange(info: any) {
|
||||
if (info.file.status === 'error') {
|
||||
@@ -69,7 +68,6 @@ function onUploadChange(info: any) {
|
||||
}
|
||||
}
|
||||
|
||||
// DONE @hw:注释都补充下哈;
|
||||
/** 上传成功处理 */
|
||||
function onUploadSuccess(res: any) {
|
||||
if (res.code !== 0) {
|
||||
@@ -84,7 +82,6 @@ function onUploadSuccess(res: any) {
|
||||
newsItem.value.thumbUrl = res.data.url;
|
||||
}
|
||||
|
||||
// DONE @hw:注释都补充下哈;
|
||||
/** 上传失败处理 */
|
||||
function onUploadError(err: Error) {
|
||||
message.error(`上传失败: ${err.message}`);
|
||||
@@ -94,8 +91,6 @@ function onUploadError(err: Error) {
|
||||
<template>
|
||||
<div>
|
||||
<p>封面:</p>
|
||||
<!-- DONE @hw:我貌似上传不成功。不确定是不是我这边的问题;;;可以微信沟通下哈。 -->
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div class="flex w-full flex-col items-center justify-center text-center">
|
||||
<Image
|
||||
v-if="newsItem.thumbUrl"
|
||||
@@ -138,7 +133,6 @@ function onUploadError(err: Error) {
|
||||
支持 bmp/png/jpeg/jpg/gif 格式,大小不超过 2M
|
||||
</div>
|
||||
</div>
|
||||
<!-- DONE @hw:是不是使用 vben 自带的 Modal 哈;这样 ele 通用性更好点。其它模块,涉及到 Modal 也按照这个调整噢 -->
|
||||
<Modal
|
||||
v-model:open="dialogVisible"
|
||||
title="图片选择"
|
||||
|
||||
@@ -13,25 +13,22 @@ import NewsForm from './news-form.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
// DONE @hw:是不是通过 id 字段判断是否为新增?类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/system/user/modules/form.vue
|
||||
const formData = ref<{
|
||||
accountId: number;
|
||||
mediaId?: string;
|
||||
newsList?: NewsItem[];
|
||||
}>();
|
||||
const newsList = ref<NewsItem[]>([]);
|
||||
// DONE @hw:不需要 isSave,通过 modal 去 lock 就好啦。
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.mediaId ? '修改图文' : '新建图文';
|
||||
});
|
||||
|
||||
// 提供 accountId 给子组件
|
||||
provide(
|
||||
'accountId',
|
||||
computed(() => formData.value?.accountId),
|
||||
);
|
||||
); // 提供 accountId 给子组件
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
@@ -39,6 +36,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO @hw:是不是 isSubmitting 非必须哈?因为 modal 已经去 lock 啦。
|
||||
isSubmitting.value = true;
|
||||
modalApi.lock();
|
||||
try {
|
||||
|
||||
@@ -44,7 +44,6 @@ const activeNewsItem = computed(() => {
|
||||
return item;
|
||||
});
|
||||
|
||||
// DONE @hw:注释使用 /** */
|
||||
/** 将图文向下移动 */
|
||||
function moveDownNews(index: number) {
|
||||
const current = newsList.value[index];
|
||||
@@ -86,7 +85,6 @@ function plusNews() {
|
||||
<template>
|
||||
<Layout>
|
||||
<Layout.Sider width="40%" theme="light">
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div class="mx-auto mb-[10px] w-[60%] border border-[#eaeaea] p-[10px]">
|
||||
<div v-for="(news, index) in newsList" :key="index">
|
||||
<div
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// DONE @hw:要不把 components 里的部分,拿到 modules 里。
|
||||
// TODO @hw:这个要融合到 draftApi 里么?类似其他模块的。
|
||||
interface NewsItem {
|
||||
title: string;
|
||||
thumbMediaId: string;
|
||||
|
||||
@@ -25,12 +25,12 @@ import menuHeadImg from './modules/assets/menu_head.png';
|
||||
defineOptions({ name: 'MpMenu' });
|
||||
|
||||
// ======================== 列表查询 ========================
|
||||
|
||||
const loading = ref(false); // 遮罩层
|
||||
const accountId = ref(-1);
|
||||
const accountName = ref<string>('');
|
||||
const menuList = ref<Menu[]>([]);
|
||||
|
||||
// 创建表单
|
||||
const [AccountForm, accountFormApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
@@ -50,6 +50,7 @@ const [AccountForm, accountFormApi] = useVbenForm({
|
||||
});
|
||||
|
||||
// ======================== 菜单操作 ========================
|
||||
|
||||
// 当前选中菜单编码:
|
||||
// * 一级('x')
|
||||
// * 二级('x-y')
|
||||
@@ -61,6 +62,7 @@ const activeIndex = ref<string>(MENU_NOT_SELECTED);
|
||||
const parentIndex = ref(-1);
|
||||
|
||||
// ======================== 菜单编辑 ========================
|
||||
|
||||
const showRightPanel = ref(false); // 右边配置显示默认详情还是配置详情
|
||||
const isParent = ref<boolean>(true); // 是否一级菜单,控制MenuEditor中name字段长度
|
||||
const activeMenu = ref<Menu>({}); // 选中菜单,MenuEditor的modelValue
|
||||
@@ -84,25 +86,20 @@ async function onAccountChanged(values: Record<string, any>) {
|
||||
const accountList = await getSimpleAccountList();
|
||||
const account = accountList.find((item) => item.id === values.accountId);
|
||||
accountName.value = account?.name || '';
|
||||
getList();
|
||||
await getList();
|
||||
}
|
||||
|
||||
/** 初始化账号ID - 作为备用方案,防止 handleValuesChange 未触发 */
|
||||
async function initAccountId() {
|
||||
// 等待表单初始化完成
|
||||
await nextTick();
|
||||
try {
|
||||
const values = await accountFormApi.getValues();
|
||||
if (values?.accountId && accountId.value === -1) {
|
||||
// 如果表单有值但 accountId 还是初始值,则手动触发一次
|
||||
await onAccountChanged(values);
|
||||
}
|
||||
} catch {
|
||||
// 忽略错误
|
||||
await nextTick(); // 等待表单初始化完成
|
||||
const values = await accountFormApi.getValues();
|
||||
if (values?.accountId && accountId.value === -1) {
|
||||
// 如果表单有值但 accountId 还是初始值,则手动触发一次
|
||||
await onAccountChanged(values);
|
||||
}
|
||||
}
|
||||
|
||||
// 组件挂载时初始化账号ID
|
||||
/** 组件挂载时初始化账号 ID */
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
await initAccountId();
|
||||
@@ -170,6 +167,7 @@ function resetForm() {
|
||||
}
|
||||
|
||||
// ======================== 菜单操作 ========================
|
||||
|
||||
/** 一级菜单点击事件 */
|
||||
function menuClicked(parent: Menu, x: number) {
|
||||
// 右侧的表单相关
|
||||
@@ -221,6 +219,7 @@ async function onDeleteMenu() {
|
||||
}
|
||||
|
||||
// ======================== 菜单编辑 ========================
|
||||
|
||||
/** 保存菜单 */
|
||||
async function onSave() {
|
||||
await confirm('确定要保存吗?');
|
||||
@@ -302,13 +301,9 @@ function menuToBackend(menu: any) {
|
||||
</template>
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<!-- <ContentWrap> -->
|
||||
<AccountForm class="-mb-15px w-240px" @values-change="onAccountChanged" />
|
||||
<!-- </ContentWrap> -->
|
||||
|
||||
<!-- DONE @hw:貌似高度高了点。就是手机下面部分,空了一大块。 -->
|
||||
<ContentWrap>
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div
|
||||
class="mx-auto w-[1200px] after:clear-both after:table after:content-['']"
|
||||
v-loading="loading"
|
||||
@@ -341,7 +336,6 @@ function menuToBackend(menu: any) {
|
||||
@submenu-clicked="(child, x, y) => subMenuClicked(child, x, y)"
|
||||
/>
|
||||
</div>
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div class="mt-[15px] flex items-center justify-center gap-[10px]">
|
||||
<Button
|
||||
type="primary"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script lang="ts" setup>
|
||||
// DONE @hw:名字可以缩写成 editor.vue,文件名
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
|
||||
import { IconifyIcon } from '@vben/icons';
|
||||
@@ -49,6 +48,7 @@ watch(menu, () => {
|
||||
});
|
||||
|
||||
// ======================== 菜单编辑(素材选择) ========================
|
||||
|
||||
/** 选择素材 */
|
||||
function selectMaterial(item: any) {
|
||||
const articleId = item.articleId;
|
||||
@@ -81,7 +81,6 @@ function deleteMaterial() {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div>
|
||||
<div class="mb-[15px] text-right">
|
||||
<Button type="primary" danger @click="emit('delete')">
|
||||
@@ -139,7 +138,6 @@ function deleteMaterial() {
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<!-- DONE @hw:1)左侧 filed 宽度,看看要不要统一;2)右侧的 input 宽度也处理下; -->
|
||||
<div
|
||||
class="mt-5 rounded-[5px] bg-white p-[20px_10px]"
|
||||
v-if="menu.type === 'miniprogram'"
|
||||
@@ -202,7 +200,6 @@ function deleteMaterial() {
|
||||
</div>
|
||||
<div v-else>
|
||||
<Row justify="center">
|
||||
<!-- DONE @hw:html 标签里的 style 要用 tindwind 替代下; -->
|
||||
<Col :span="24" class="text-center">
|
||||
<Button type="primary" @click="showNewsDialog = true">
|
||||
素材库选择
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// DONE @hw:如果只有自己组件里用,一般是 modules,所以这个目录要改成 modules 哈(自己模块的一部分);如果要给外部的组件用,可以叫 components;
|
||||
export { default as MenuEditor } from './editor.vue';
|
||||
export { default as MenuPreviewer } from './previewer.vue';
|
||||
export type * from './types';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script lang="ts" setup>
|
||||
// DONE @hw:名字可以缩写成 previewer.vue,文件名
|
||||
import type { Menu } from './types';
|
||||
|
||||
import { computed } from 'vue';
|
||||
@@ -44,7 +43,6 @@ function addMenu() {
|
||||
|
||||
/** 添加横向二级菜单;parent 表示要操作的父菜单 */
|
||||
function addSubMenu(i: number, parent: any) {
|
||||
// DONE @hw:可以 inline 掉。idea 或者 vscode 的一些告警,处理掉会更干净一些。
|
||||
parent.children[parent.children.length] = {
|
||||
name: '子菜单名称',
|
||||
reply: {
|
||||
|
||||
@@ -72,7 +72,6 @@ interface _Menu extends RawMenu {
|
||||
|
||||
export type Menu = Partial<_Menu>;
|
||||
|
||||
// DONE @hw:这个要不合并到 types 里;
|
||||
export const menuOptions = [
|
||||
{
|
||||
value: 'view',
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { MpStatisticsApi } from '#/api/mp/statistics';
|
||||
|
||||
/** 用户增减数据图表配置项 */
|
||||
export function userSummaryOption(
|
||||
data: MpStatisticsApi.UserSummary[],
|
||||
data: MpStatisticsApi.StatisticsUserSummaryRespVO[],
|
||||
dates: string[],
|
||||
): any {
|
||||
return {
|
||||
@@ -41,7 +41,7 @@ export function userSummaryOption(
|
||||
|
||||
/** 累计用户数据图表配置项 */
|
||||
export function userCumulateOption(
|
||||
data: MpStatisticsApi.UserCumulate[],
|
||||
data: MpStatisticsApi.StatisticsUserCumulateRespVO[],
|
||||
dates: string[],
|
||||
): any {
|
||||
return {
|
||||
@@ -71,7 +71,7 @@ export function userCumulateOption(
|
||||
|
||||
/** 消息发送概况数据图表配置项 */
|
||||
export function upstreamMessageOption(
|
||||
data: MpStatisticsApi.UpstreamMessage[],
|
||||
data: MpStatisticsApi.StatisticsUpstreamMessageRespVO[],
|
||||
dates: string[],
|
||||
): any {
|
||||
return {
|
||||
@@ -111,7 +111,7 @@ export function upstreamMessageOption(
|
||||
|
||||
/** 接口分析况数据图表配置项 */
|
||||
export function interfaceSummaryOption(
|
||||
data: MpStatisticsApi.InterfaceSummary[],
|
||||
data: MpStatisticsApi.StatisticsInterfaceSummaryRespVO[],
|
||||
dates: string[],
|
||||
): any {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user