fix: ele统一风格
This commit is contained in:
@@ -8,7 +8,7 @@ import { DICT_TYPE } from '@vben/constants';
|
|||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { getSimpleAccountList } from '#/api/mp/account';
|
import { getSimpleAccountList } from '#/api/mp/account';
|
||||||
import { ReplySelect } from '#/views/mp/modules';
|
import { ReplySelect } from '#/views/mp/components';
|
||||||
|
|
||||||
import { MsgType } from './types';
|
import { MsgType } from './types';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Music, News, VideoPlayer, VoicePlayer } from '#/views/mp/modules';
|
import { Music, News, VideoPlayer, VoicePlayer } from '#/views/mp/components';
|
||||||
// DONE @hw:迁移到 /apps/web-antd/src/views/mp/autoReply/modules 里;组件名可能要换一个,= = 之前写的不太好;类似 content.vue ?本质是内容~
|
// DONE @hw:迁移到 /apps/web-antd/src/views/mp/autoReply/modules 里;组件名可能要换一个,= = 之前写的不太好;类似 content.vue ?本质是内容~
|
||||||
defineOptions({ name: 'ReplyContentCell' });
|
defineOptions({ name: 'ReplyContentCell' });
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Reply } from '#/views/mp/modules/reply/types';
|
import type { Reply } from '#/views/mp/components/reply/types';
|
||||||
|
|
||||||
import { computed, nextTick, ref } from 'vue';
|
import { computed, nextTick, ref } from 'vue';
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ import { message } from 'ant-design-vue';
|
|||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { createAutoReply, updateAutoReply } from '#/api/mp/autoReply';
|
import { createAutoReply, updateAutoReply } from '#/api/mp/autoReply';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { ReplyType } from '#/views/mp/modules/reply/types';
|
import { ReplyType } from '#/views/mp/components/reply/types';
|
||||||
|
|
||||||
import { useFormSchema } from '../data';
|
import { useFormSchema } from '../data';
|
||||||
import { MsgType } from '../types';
|
import { MsgType } from '../types';
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|||||||
import { getDraftPage } from '#/api/mp/draft';
|
import { getDraftPage } from '#/api/mp/draft';
|
||||||
import { getFreePublishPage } from '#/api/mp/freePublish';
|
import { getFreePublishPage } from '#/api/mp/freePublish';
|
||||||
import { getMaterialPage } from '#/api/mp/material';
|
import { getMaterialPage } from '#/api/mp/material';
|
||||||
import { News, VideoPlayer, VoicePlayer } from '#/views/mp/modules/index';
|
import { News, VideoPlayer, VoicePlayer } from '#/views/mp/components/index';
|
||||||
|
|
||||||
import { NewsType } from './types';
|
import { NewsType } from './types';
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
News,
|
News,
|
||||||
VideoPlayer,
|
VideoPlayer,
|
||||||
VoicePlayer,
|
VoicePlayer,
|
||||||
} from '#/views/mp/modules';
|
} from '#/views/mp/components';
|
||||||
|
|
||||||
import MsgEvent from './msg-event.vue';
|
import MsgEvent from './msg-event.vue';
|
||||||
import { MsgType } from './types';
|
import { MsgType } from './types';
|
||||||
@@ -38,7 +38,7 @@ defineExpose({
|
|||||||
:preview="false"
|
:preview="false"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="absolute bottom-0 left-0 inline-block w-[98%] whitespace-normal bg-black p-[1%] text-xs text-white opacity-65"
|
class="absolute bottom-0 left-0 inline-block w-[100%] whitespace-normal bg-black p-[1%] text-xs text-white opacity-65"
|
||||||
>
|
>
|
||||||
<span>{{ article.title }}</span>
|
<span>{{ article.title }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -29,7 +29,7 @@ defineOptions({ name: 'ReplySelect' });
|
|||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
modelValue: Reply;
|
modelValue: Reply | undefined;
|
||||||
newsType?: NewsType;
|
newsType?: NewsType;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
@@ -11,7 +11,7 @@ import { useAccessStore } from '@vben/stores';
|
|||||||
import { Button, Col, message, Modal, Row, Upload } from 'ant-design-vue';
|
import { Button, Col, message, Modal, Row, Upload } from 'ant-design-vue';
|
||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
import { MaterialSelect } from '#/views/mp/modules';
|
import { MaterialSelect } from '#/views/mp/components';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: Reply;
|
modelValue: Reply;
|
||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
import { MaterialSelect } from '#/views/mp/modules';
|
import { MaterialSelect } from '#/views/mp/components';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: Reply;
|
modelValue: Reply;
|
||||||
@@ -7,7 +7,7 @@ import { IconifyIcon } from '@vben/icons';
|
|||||||
|
|
||||||
import { Button, Col, Modal, Row } from 'ant-design-vue';
|
import { Button, Col, Modal, Row } from 'ant-design-vue';
|
||||||
|
|
||||||
import { MaterialSelect, News } from '#/views/mp/modules';
|
import { MaterialSelect, News } from '#/views/mp/components';
|
||||||
|
|
||||||
import { NewsType } from '../material-select/types';
|
import { NewsType } from '../material-select/types';
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
import { MaterialSelect, VideoPlayer } from '#/views/mp/modules';
|
import { MaterialSelect, VideoPlayer } from '#/views/mp/components';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: Reply;
|
modelValue: Reply;
|
||||||
@@ -11,7 +11,7 @@ import { useAccessStore } from '@vben/stores';
|
|||||||
import { Button, Col, message, Modal, Row, Upload } from 'ant-design-vue';
|
import { Button, Col, message, Modal, Row, Upload } from 'ant-design-vue';
|
||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
import { MaterialSelect, VoicePlayer } from '#/views/mp/modules';
|
import { MaterialSelect, VoicePlayer } from '#/views/mp/components';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: Reply;
|
modelValue: Reply;
|
||||||
@@ -17,12 +17,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
minWidth: 300,
|
minWidth: 300,
|
||||||
slots: { default: 'content' },
|
slots: { default: 'content' },
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
field: 'updateTime',
|
// field: 'updateTime',
|
||||||
title: '更新时间',
|
// title: '更新时间',
|
||||||
minWidth: 180,
|
// minWidth: 180,
|
||||||
formatter: 'formatDateTime', // TODO @YunaiV 接口返回数据不对,需要乘1000
|
// formatter: 'formatDateTime', // TODO @YunaiV 接口返回数据不对,需要乘1000
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 200,
|
width: 200,
|
||||||
|
|||||||
@@ -230,6 +230,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
.vxe-body--column {
|
.vxe-body--column {
|
||||||
.vxe-cell {
|
.vxe-cell {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
height: auto !important;
|
||||||
|
img {
|
||||||
|
width: 300px !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { useAccessStore } from '@vben/stores';
|
|||||||
import { Button, Image, message, Modal, Upload } from 'ant-design-vue';
|
import { Button, Image, message, Modal, Upload } from 'ant-design-vue';
|
||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
import { MaterialSelect } from '#/views/mp/modules';
|
import { MaterialSelect } from '#/views/mp/components';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
isFirst: boolean;
|
isFirst: boolean;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Article } from './types';
|
import type { Article } from './types';
|
||||||
|
|
||||||
import { News } from '#/views/mp/modules';
|
import { News } from '#/views/mp/components';
|
||||||
|
|
||||||
defineOptions({ name: 'DraftTableCell' });
|
defineOptions({ name: 'DraftTableCell' });
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
import { MaterialSelect, News, ReplySelect } from '#/views/mp/modules';
|
import { MaterialSelect, News, ReplySelect } from '#/views/mp/components';
|
||||||
|
|
||||||
import { menuOptions } from './types';
|
import { menuOptions } from './types';
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ VITE_PORT=5777
|
|||||||
VITE_BASE=/
|
VITE_BASE=/
|
||||||
|
|
||||||
# 请求路径
|
# 请求路径
|
||||||
VITE_BASE_URL=http://127.0.0.1:48080
|
VITE_BASE_URL=http://47.103.66.220:48080
|
||||||
|
# VITE_BASE_URL=http://192.168.1.49:48080
|
||||||
# 接口地址
|
# 接口地址
|
||||||
VITE_GLOB_API_URL=/admin-api
|
VITE_GLOB_API_URL=http://47.103.66.220:48080/admin-api
|
||||||
|
# VITE_GLOB_API_URL=http://192.168.1.49:48080/admin-api
|
||||||
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务
|
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务
|
||||||
VITE_UPLOAD_TYPE=server
|
VITE_UPLOAD_TYPE=server
|
||||||
# 是否打开 devtools,true 为打开,false 为关闭
|
# 是否打开 devtools,true 为打开,false 为关闭
|
||||||
|
|||||||
@@ -1,19 +1,33 @@
|
|||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeGridPropTypes } from '#/adapter/vxe-table';
|
||||||
|
import type { MpAccountApi } from '#/api/mp/account';
|
||||||
|
|
||||||
import { markRaw } from 'vue';
|
import { markRaw } from 'vue';
|
||||||
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictObj, getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import WxAccountSelect from '#/views/mp/modules/wx-account-select/main.vue';
|
import { getSimpleAccountList } from '#/api/mp/account';
|
||||||
|
import { ReplySelect } from '#/views/mp/components';
|
||||||
|
|
||||||
import { MsgType } from './modules/types';
|
import { MsgType } from './modules/types';
|
||||||
|
|
||||||
|
/** 关联数据 */
|
||||||
|
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||||
|
getSimpleAccountList().then((data) => (accountList = data));
|
||||||
|
|
||||||
|
const RequestMessageTypes = new Set([
|
||||||
|
'image',
|
||||||
|
'link',
|
||||||
|
'location',
|
||||||
|
'shortvideo',
|
||||||
|
'text',
|
||||||
|
'video',
|
||||||
|
'voice',
|
||||||
|
]); // 允许选择的请求消息类型
|
||||||
/** 获取表格列配置 */
|
/** 获取表格列配置 */
|
||||||
export function useGridColumns(
|
export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns {
|
||||||
msgType: MsgType,
|
const columns: VxeGridPropTypes.Columns = [];
|
||||||
): VxeTableGridOptions['columns'] {
|
|
||||||
const columns: VxeTableGridOptions['columns'] = [];
|
|
||||||
// 请求消息类型列(仅消息回复显示)
|
// 请求消息类型列(仅消息回复显示)
|
||||||
if (msgType === MsgType.Message) {
|
if (msgType === MsgType.Message) {
|
||||||
columns.push({
|
columns.push({
|
||||||
@@ -51,10 +65,8 @@ export function useGridColumns(
|
|||||||
field: 'responseMessageType',
|
field: 'responseMessageType',
|
||||||
title: '回复消息类型',
|
title: '回复消息类型',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
cellRender: {
|
formatter: ({ cellValue }) =>
|
||||||
name: 'CellDict',
|
getDictObj(DICT_TYPE.MP_MESSAGE_TYPE, String(cellValue))?.label ?? '',
|
||||||
props: { type: DICT_TYPE.MP_MESSAGE_TYPE },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'responseContent',
|
field: 'responseContent',
|
||||||
@@ -78,13 +90,79 @@ export function useGridColumns(
|
|||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
|
||||||
|
const schema: VbenFormSchema[] = [];
|
||||||
|
// 消息类型(仅消息回复显示)
|
||||||
|
if (Number(msgType) === MsgType.Message) {
|
||||||
|
schema.push({
|
||||||
|
fieldName: 'requestMessageType',
|
||||||
|
label: '消息类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择',
|
||||||
|
options: getDictOptions(DICT_TYPE.MP_MESSAGE_TYPE).filter((d) =>
|
||||||
|
RequestMessageTypes.has(d.value as string),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 匹配类型(仅关键词回复显示)
|
||||||
|
if (Number(msgType) === MsgType.Keyword) {
|
||||||
|
schema.push({
|
||||||
|
fieldName: 'requestMatch',
|
||||||
|
label: '匹配类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择匹配类型',
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(
|
||||||
|
DICT_TYPE.MP_AUTO_REPLY_REQUEST_MATCH,
|
||||||
|
'number',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关键词(仅关键词回复显示)
|
||||||
|
if (Number(msgType) === MsgType.Keyword) {
|
||||||
|
schema.push({
|
||||||
|
fieldName: 'requestKeyword',
|
||||||
|
label: '关键词',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入内容',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 回复消息
|
||||||
|
schema.push({
|
||||||
|
fieldName: 'reply',
|
||||||
|
label: '回复消息',
|
||||||
|
component: markRaw(ReplySelect),
|
||||||
|
});
|
||||||
|
return schema;
|
||||||
|
}
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
fieldName: 'accountId',
|
fieldName: 'accountId',
|
||||||
label: '公众号',
|
label: '公众号',
|
||||||
component: markRaw(WxAccountSelect),
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
options: accountList.map((item) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.id,
|
||||||
|
})),
|
||||||
|
placeholder: '请选择公众号',
|
||||||
|
},
|
||||||
|
defaultValue: accountList[0]?.id,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { TabPaneName } from 'element-plus';
|
|
||||||
|
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { computed, nextTick, onMounted, ref } from 'vue';
|
import { computed, nextTick, ref } from 'vue';
|
||||||
|
|
||||||
import { ContentWrap, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ElLoading,
|
ElLoading,
|
||||||
@@ -21,26 +20,27 @@ import * as MpAutoReplyApi from '#/api/mp/autoReply';
|
|||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Content from './modules/content.vue';
|
||||||
import Form from './modules/form.vue';
|
import Form from './modules/form.vue';
|
||||||
import ReplyContentCell from './modules/ReplyTable.vue';
|
|
||||||
import { MsgType } from './modules/types';
|
import { MsgType } from './modules/types';
|
||||||
|
|
||||||
defineOptions({ name: 'MpAutoReply' });
|
defineOptions({ name: 'MpAutoReply' });
|
||||||
|
|
||||||
const msgType = ref<MsgType>(MsgType.Keyword); // 消息类型
|
const msgType = ref<string>(String(MsgType.Keyword)); // 消息类型
|
||||||
async function onTabChange(_tabName: TabPaneName) {
|
/** 切换回复类型 */
|
||||||
// 等待 msgType 更新完成
|
async function onTabChange(tabName: string) {
|
||||||
|
msgType.value = tabName;
|
||||||
await nextTick();
|
await nextTick();
|
||||||
const columns = useGridColumns(msgType.value);
|
// 更新 columns
|
||||||
|
const columns = useGridColumns(Number(msgType.value) as MsgType);
|
||||||
if (columns) {
|
if (columns) {
|
||||||
// 使用 setGridOptions 更新列配置
|
// 使用 setGridOptions 更新列配置
|
||||||
gridApi.setGridOptions({ columns });
|
gridApi.setGridOptions({ columns });
|
||||||
// 等待列配置更新完成
|
// 等待列配置更新完成
|
||||||
await nextTick();
|
await nextTick();
|
||||||
}
|
}
|
||||||
|
// 查询数据
|
||||||
await gridApi.query();
|
await gridApi.query();
|
||||||
// 查询完成后更新数据长度
|
|
||||||
updateTableDataLength();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
@@ -49,7 +49,6 @@ async function handleCreate() {
|
|||||||
|
|
||||||
formModalApi
|
formModalApi
|
||||||
.setData({
|
.setData({
|
||||||
isCreating: true,
|
|
||||||
msgType: msgType.value,
|
msgType: msgType.value,
|
||||||
accountId: formValues.accountId,
|
accountId: formValues.accountId,
|
||||||
})
|
})
|
||||||
@@ -59,8 +58,13 @@ async function handleCreate() {
|
|||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
async function handleEdit(row: any) {
|
async function handleEdit(row: any) {
|
||||||
const data = (await MpAutoReplyApi.getAutoReply(row.id)) as any;
|
const data = (await MpAutoReplyApi.getAutoReply(row.id)) as any;
|
||||||
|
const formValues = await gridApi.formApi.getValues();
|
||||||
formModalApi
|
formModalApi
|
||||||
.setData({ isCreating: false, msgType: msgType.value, row: data })
|
.setData({
|
||||||
|
msgType: msgType.value,
|
||||||
|
row: data,
|
||||||
|
accountId: formValues.accountId,
|
||||||
|
})
|
||||||
.open();
|
.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,9 +77,7 @@ async function handleDelete(row: any) {
|
|||||||
try {
|
try {
|
||||||
await MpAutoReplyApi.deleteAutoReply(row.id);
|
await MpAutoReplyApi.deleteAutoReply(row.id);
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
await gridApi.query();
|
handleRefresh();
|
||||||
// 查询完成后更新数据长度
|
|
||||||
updateTableDataLength();
|
|
||||||
} finally {
|
} finally {
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
}
|
}
|
||||||
@@ -93,9 +95,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
submitOnChange: true,
|
submitOnChange: true,
|
||||||
},
|
},
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(msgType.value),
|
columns: useGridColumns(Number(msgType.value) as MsgType),
|
||||||
height: 'calc(100vh - 300px)',
|
height: 'auto',
|
||||||
// height: '600px',
|
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
@@ -103,13 +104,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
return await MpAutoReplyApi.getAutoReplyPage({
|
return await MpAutoReplyApi.getAutoReplyPage({
|
||||||
pageNo: page.currentPage,
|
pageNo: page.currentPage,
|
||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
type: msgType.value,
|
type: Number(msgType.value) as MsgType,
|
||||||
...formValues,
|
...formValues,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// 禁用自动加载,等表单初始化完成后再加载
|
|
||||||
autoLoad: false,
|
|
||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
@@ -122,132 +121,108 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
} as VxeTableGridOptions<any>,
|
} as VxeTableGridOptions<any>,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 表格数据长度,用于判断是否显示新增按钮
|
/** 刷新表格 */
|
||||||
const tableDataLength = ref(0);
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
// 更新表格数据长度(避免在模板中直接调用 getTableData 导致响应式循环)
|
|
||||||
function updateTableDataLength() {
|
|
||||||
try {
|
|
||||||
if (!gridApi.grid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const tableData = gridApi.grid.getTableData();
|
|
||||||
tableDataLength.value = tableData?.tableData?.length || 0;
|
|
||||||
} catch {
|
|
||||||
tableDataLength.value = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算是否显示新增按钮:关注时回复类型只有在没有数据时才显示
|
// 计算是否显示新增按钮:关注时回复类型只有在没有数据时才显示
|
||||||
const showCreateButton = computed(() => {
|
const showCreateButton = computed(() => {
|
||||||
if (msgType.value !== MsgType.Follow) {
|
if (Number(msgType.value) !== MsgType.Follow) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return tableDataLength.value <= 0;
|
try {
|
||||||
});
|
const tableData = gridApi.grid?.getTableData();
|
||||||
|
return (tableData?.tableData?.length || 0) <= 0;
|
||||||
// 页面挂载后,等待表单初始化完成再加载数据
|
} catch {
|
||||||
onMounted(async () => {
|
return true;
|
||||||
// 等待 WxAccountSelect 组件加载并设置默认值
|
|
||||||
await nextTick();
|
|
||||||
if (gridApi.formApi) {
|
|
||||||
const formValues = await gridApi.formApi.getValues();
|
|
||||||
// 如果 accountId 有值,说明已经准备好了
|
|
||||||
if (formValues.accountId) {
|
|
||||||
// 设置为最新提交的值
|
|
||||||
gridApi.formApi.setLatestSubmissionValues(formValues);
|
|
||||||
// 触发首次查询
|
|
||||||
await gridApi.query();
|
|
||||||
updateTableDataLength();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<DocAlert title="自动回复" url="https://doc.iocoder.cn/mp/auto-reply/" />
|
<template #doc>
|
||||||
|
<DocAlert title="自动回复" url="https://doc.iocoder.cn/mp/auto-reply/" />
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- tab 切换 -->
|
<FormModal @success="handleRefresh" />
|
||||||
<ContentWrap>
|
<Grid table-title="自动回复列表">
|
||||||
<ElTabs v-model="msgType" @tab-change="onTabChange">
|
<!-- 在工具栏上方放置 Tab 切换 -->
|
||||||
<!-- tab 项 -->
|
<template #toolbar-actions>
|
||||||
<ElTabPane :name="MsgType.Follow">
|
<ElTabs
|
||||||
<template #label>
|
v-model="msgType"
|
||||||
<ElRow align="middle">
|
class="w-full"
|
||||||
<Icon icon="ep:star" class="mr-2px" /> 关注时回复
|
@tab-change="(activeName) => onTabChange(activeName as string)"
|
||||||
</ElRow>
|
>
|
||||||
</template>
|
<ElTabPane :name="String(MsgType.Follow)">
|
||||||
</ElTabPane>
|
<template #label>
|
||||||
<ElTabPane :name="MsgType.Message">
|
<ElRow align="middle">
|
||||||
<template #label>
|
<IconifyIcon icon="ep:star" class="mr-[2px]" /> 关注时回复
|
||||||
<ElRow align="middle">
|
</ElRow>
|
||||||
<Icon icon="ep:chat-line-round" class="mr-2px" /> 消息回复
|
</template>
|
||||||
</ElRow>
|
</ElTabPane>
|
||||||
</template>
|
<ElTabPane :name="String(MsgType.Message)">
|
||||||
</ElTabPane>
|
<template #label>
|
||||||
<ElTabPane :name="MsgType.Keyword">
|
<ElRow align="middle">
|
||||||
<template #label>
|
<IconifyIcon icon="ep:chat-line-round" class="mr-[2px]" />
|
||||||
<ElRow align="middle">
|
消息回复
|
||||||
<Icon icon="fa:newspaper-o" class="mr-2px" /> 关键词回复
|
</ElRow>
|
||||||
</ElRow>
|
</template>
|
||||||
</template>
|
</ElTabPane>
|
||||||
</ElTabPane>
|
<ElTabPane :name="String(MsgType.Keyword)">
|
||||||
</ElTabs>
|
<template #label>
|
||||||
<!-- 列表 -->
|
<ElRow align="middle">
|
||||||
<FormModal
|
<IconifyIcon icon="fa:newspaper-o" class="mr-[2px]" />
|
||||||
@success="
|
关键词回复
|
||||||
() => {
|
</ElRow>
|
||||||
gridApi.query().then(() => {
|
</template>
|
||||||
updateTableDataLength();
|
</ElTabPane>
|
||||||
});
|
</ElTabs>
|
||||||
}
|
</template>
|
||||||
"
|
<!-- 工具栏按钮 -->
|
||||||
/>
|
<template #toolbar-tools>
|
||||||
<Grid table-title="自动回复列表">
|
<TableAction
|
||||||
<template #toolbar-tools>
|
v-if="showCreateButton"
|
||||||
<TableAction
|
:actions="[
|
||||||
v-if="showCreateButton"
|
{
|
||||||
:actions="[
|
label: $t('ui.actionTitle.create', ['自动回复']),
|
||||||
{
|
type: 'primary',
|
||||||
label: $t('ui.actionTitle.create', ['自动回复']),
|
icon: ACTION_ICON.ADD,
|
||||||
type: 'primary',
|
auth: ['mp:auto-reply:create'],
|
||||||
icon: ACTION_ICON.ADD,
|
onClick: handleCreate,
|
||||||
auth: ['mp:auto-reply:create'],
|
},
|
||||||
onClick: handleCreate,
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #replyContent="{ row }">
|
||||||
|
<Content :row="row" />
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['mp:auto-reply:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mp:auto-reply:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除此数据?',
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
},
|
},
|
||||||
]"
|
},
|
||||||
/>
|
]"
|
||||||
</template>
|
/>
|
||||||
<template #replyContent="{ row }">
|
</template>
|
||||||
<ReplyContentCell :row="row" />
|
</Grid>
|
||||||
</template>
|
|
||||||
<template #actions="{ row }">
|
|
||||||
<TableAction
|
|
||||||
:actions="[
|
|
||||||
{
|
|
||||||
label: $t('common.edit'),
|
|
||||||
type: 'primary',
|
|
||||||
link: true,
|
|
||||||
icon: ACTION_ICON.EDIT,
|
|
||||||
auth: ['mp:auto-reply:update'],
|
|
||||||
onClick: handleEdit.bind(null, row),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('common.delete'),
|
|
||||||
type: 'danger',
|
|
||||||
link: true,
|
|
||||||
icon: ACTION_ICON.DELETE,
|
|
||||||
auth: ['mp:auto-reply:delete'],
|
|
||||||
popConfirm: {
|
|
||||||
title: '是否确认删除此数据?',
|
|
||||||
confirm: handleDelete.bind(null, row),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</Grid>
|
|
||||||
</ContentWrap>
|
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
<script lang="ts" setup>
|
|
||||||
import type { FormInstance } from 'element-plus';
|
|
||||||
|
|
||||||
import type { Reply } from '#/views/mp/modules/wx-reply';
|
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
|
||||||
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
|
||||||
import { getDictOptions } from '@vben/hooks';
|
|
||||||
|
|
||||||
import { ElForm, ElFormItem, ElInput, ElOption, ElSelect } from 'element-plus';
|
|
||||||
|
|
||||||
import WxReplySelect from '#/views/mp/modules/wx-reply';
|
|
||||||
|
|
||||||
import { MsgType } from './types';
|
|
||||||
|
|
||||||
defineOptions({ name: 'ReplyForm' });
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
modelValue: any;
|
|
||||||
msgType: MsgType;
|
|
||||||
reply: Reply;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(e: 'update:reply', v: Reply): void;
|
|
||||||
(e: 'update:modelValue', v: any): void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const reply = computed<Reply>({
|
|
||||||
get: () => props.reply,
|
|
||||||
set: (val) => emit('update:reply', val),
|
|
||||||
});
|
|
||||||
|
|
||||||
const replyForm = computed<any>({
|
|
||||||
get: () => props.modelValue,
|
|
||||||
set: (val) => emit('update:modelValue', val),
|
|
||||||
});
|
|
||||||
|
|
||||||
const formRef = ref<FormInstance | null>(null); // 表单 ref
|
|
||||||
|
|
||||||
const RequestMessageTypes = [
|
|
||||||
'text',
|
|
||||||
'image',
|
|
||||||
'voice',
|
|
||||||
'video',
|
|
||||||
'shortvideo',
|
|
||||||
'location',
|
|
||||||
'link',
|
|
||||||
]; // 允许选择的请求消息类型
|
|
||||||
|
|
||||||
// 表单校验
|
|
||||||
const rules = {
|
|
||||||
requestKeyword: [
|
|
||||||
{ required: true, message: '请求的关键字不能为空', trigger: 'blur' },
|
|
||||||
],
|
|
||||||
requestMatch: [
|
|
||||||
{ required: true, message: '请求的关键字的匹配不能为空', trigger: 'blur' },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
resetFields: () => formRef.value?.resetFields(),
|
|
||||||
validate: async () => formRef.value?.validate(),
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<ElForm ref="formRef" :model="replyForm" :rules="rules" label-width="80px">
|
|
||||||
<ElFormItem
|
|
||||||
label="消息类型"
|
|
||||||
prop="requestMessageType"
|
|
||||||
v-if="msgType === MsgType.Message"
|
|
||||||
>
|
|
||||||
<ElSelect v-model="replyForm.requestMessageType" placeholder="请选择">
|
|
||||||
<template
|
|
||||||
v-for="dict in getDictOptions(DICT_TYPE.MP_MESSAGE_TYPE)"
|
|
||||||
:key="dict.value"
|
|
||||||
>
|
|
||||||
<ElOption
|
|
||||||
v-if="RequestMessageTypes.includes(dict.value as string)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</ElSelect>
|
|
||||||
</ElFormItem>
|
|
||||||
<ElFormItem
|
|
||||||
label="匹配类型"
|
|
||||||
prop="requestMatch"
|
|
||||||
v-if="msgType === MsgType.Keyword"
|
|
||||||
>
|
|
||||||
<ElSelect
|
|
||||||
v-model="replyForm.requestMatch"
|
|
||||||
placeholder="请选择匹配类型"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<ElOption
|
|
||||||
v-for="dict in getDictOptions(
|
|
||||||
DICT_TYPE.MP_AUTO_REPLY_REQUEST_MATCH,
|
|
||||||
'number',
|
|
||||||
)"
|
|
||||||
:key="String(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</ElSelect>
|
|
||||||
</ElFormItem>
|
|
||||||
<ElFormItem
|
|
||||||
label="关键词"
|
|
||||||
prop="requestKeyword"
|
|
||||||
v-if="msgType === MsgType.Keyword"
|
|
||||||
>
|
|
||||||
<ElInput
|
|
||||||
v-model="replyForm.requestKeyword"
|
|
||||||
placeholder="请输入内容"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</ElFormItem>
|
|
||||||
<ElFormItem label="回复消息">
|
|
||||||
<WxReplySelect v-model="reply" />
|
|
||||||
</ElFormItem>
|
|
||||||
</ElForm>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import WxMusic from '#/views/mp/modules/wx-music';
|
import { Music, News, VideoPlayer, VoicePlayer } from '#/views/mp/components';
|
||||||
import WxNews from '#/views/mp/modules/wx-news';
|
|
||||||
import WxVideoPlayer from '#/views/mp/modules/wx-video-play';
|
|
||||||
import WxVoicePlayer from '#/views/mp/modules/wx-voice-play';
|
|
||||||
|
|
||||||
defineOptions({ name: 'ReplyContentCell' });
|
defineOptions({ name: 'ReplyContentCell' });
|
||||||
|
|
||||||
@@ -17,14 +14,14 @@ const props = defineProps<{
|
|||||||
{{ props.row.responseContent }}
|
{{ props.row.responseContent }}
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="props.row.responseMessageType === 'voice'">
|
<div v-else-if="props.row.responseMessageType === 'voice'">
|
||||||
<WxVoicePlayer
|
<VoicePlayer
|
||||||
v-if="props.row.responseMediaUrl"
|
v-if="props.row.responseMediaUrl"
|
||||||
:url="props.row.responseMediaUrl"
|
:url="props.row.responseMediaUrl"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="props.row.responseMessageType === 'image'">
|
<div v-else-if="props.row.responseMessageType === 'image'">
|
||||||
<a target="_blank" :href="props.row.responseMediaUrl">
|
<a target="_blank" :href="props.row.responseMediaUrl">
|
||||||
<img :src="props.row.responseMediaUrl" style="width: 100px" />
|
<img :src="props.row.responseMediaUrl" class="w-[100px]" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@@ -33,17 +30,17 @@ const props = defineProps<{
|
|||||||
props.row.responseMessageType === 'shortvideo'
|
props.row.responseMessageType === 'shortvideo'
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<WxVideoPlayer
|
<VideoPlayer
|
||||||
v-if="props.row.responseMediaUrl"
|
v-if="props.row.responseMediaUrl"
|
||||||
:url="props.row.responseMediaUrl"
|
:url="props.row.responseMediaUrl"
|
||||||
style="margin-top: 10px"
|
class="mt-[10px]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="props.row.responseMessageType === 'news'">
|
<div v-else-if="props.row.responseMessageType === 'news'">
|
||||||
<WxNews :articles="props.row.responseArticles" />
|
<News :articles="props.row.responseArticles" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="props.row.responseMessageType === 'music'">
|
<div v-else-if="props.row.responseMessageType === 'music'">
|
||||||
<WxMusic
|
<Music
|
||||||
:title="props.row.responseTitle"
|
:title="props.row.responseTitle"
|
||||||
:description="props.row.responseDescription"
|
:description="props.row.responseDescription"
|
||||||
:thumb-media-url="props.row.responseThumbMediaUrl"
|
:thumb-media-url="props.row.responseThumbMediaUrl"
|
||||||
@@ -1,61 +1,88 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Reply } from '#/views/mp/modules/wx-reply';
|
import type { Reply } from '#/views/mp/components/reply/types';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, nextTick, ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
import * as MpAutoReplyApi from '#/api/mp/autoReply';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { createAutoReply, updateAutoReply } from '#/api/mp/autoReply';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { ReplyType } from '#/views/mp/modules/wx-reply/modules/types';
|
import { ReplyType } from '#/views/mp/components/reply/types';
|
||||||
|
|
||||||
import ReplyForm from './ReplyForm.vue';
|
import { useFormSchema } from '../data';
|
||||||
import { MsgType } from './types';
|
import { MsgType } from './types';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
|
|
||||||
const formRef = ref<InstanceType<typeof ReplyForm> | null>(null);
|
const formData = ref<{
|
||||||
|
accountId?: number;
|
||||||
const formData = ref<{ isCreating: boolean; msgType: MsgType; row?: any }>();
|
msgType: MsgType;
|
||||||
const replyForm = ref<any>({});
|
row?: any;
|
||||||
const reply = ref<Reply>({
|
}>();
|
||||||
type: ReplyType.Text,
|
|
||||||
accountId: -1,
|
|
||||||
});
|
|
||||||
|
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
return formData.value?.isCreating
|
return formData.value?.row?.id
|
||||||
? $t('ui.actionTitle.create', ['自动回复'])
|
? $t('ui.actionTitle.edit', ['自动回复'])
|
||||||
: $t('ui.actionTitle.edit', ['自动回复']);
|
: $t('ui.actionTitle.create', ['自动回复']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 100,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: useFormSchema(Number(formData.value?.msgType) as MsgType),
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 注意:schema 的更新现在在 onOpenChange 中手动处理,避免时序问题
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
async onConfirm() {
|
async onConfirm() {
|
||||||
await formRef.value?.validate();
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 处理回复消息
|
// 处理回复消息
|
||||||
const submitForm: any = { ...replyForm.value };
|
const submitForm: any = await formApi.getValues();
|
||||||
submitForm.responseMessageType = reply.value.type;
|
// 确保 type 字段使用当前选中的 tab 值
|
||||||
submitForm.responseContent = reply.value.content;
|
submitForm.type = formData.value?.msgType;
|
||||||
submitForm.responseMediaId = reply.value.mediaId;
|
// 确保 accountId 字段存在
|
||||||
submitForm.responseMediaUrl = reply.value.url;
|
submitForm.accountId = formData.value?.accountId;
|
||||||
submitForm.responseTitle = reply.value.title;
|
// 编辑模式下,确保 id 字段存在(从 row 中获取,因为表单 schema 中没有 id 字段)
|
||||||
submitForm.responseDescription = reply.value.description;
|
if (formData.value?.row?.id && !submitForm.id) {
|
||||||
submitForm.responseThumbMediaId = reply.value.thumbMediaId;
|
submitForm.id = formData.value.row.id;
|
||||||
submitForm.responseThumbMediaUrl = reply.value.thumbMediaUrl;
|
}
|
||||||
submitForm.responseArticles = reply.value.articles;
|
const reply = submitForm.reply as Reply | undefined;
|
||||||
submitForm.responseMusicUrl = reply.value.musicUrl;
|
if (reply) {
|
||||||
submitForm.responseHqMusicUrl = reply.value.hqMusicUrl;
|
submitForm.responseMessageType = reply.type;
|
||||||
|
submitForm.responseContent = reply.content;
|
||||||
|
submitForm.responseMediaId = reply.mediaId;
|
||||||
|
submitForm.responseMediaUrl = reply.url;
|
||||||
|
submitForm.responseTitle = reply.title;
|
||||||
|
submitForm.responseDescription = reply.description;
|
||||||
|
submitForm.responseThumbMediaId = reply.thumbMediaId;
|
||||||
|
submitForm.responseThumbMediaUrl = reply.thumbMediaUrl;
|
||||||
|
submitForm.responseArticles = reply.articles;
|
||||||
|
submitForm.responseMusicUrl = reply.musicUrl;
|
||||||
|
submitForm.responseHqMusicUrl = reply.hqMusicUrl;
|
||||||
|
}
|
||||||
|
delete submitForm.reply;
|
||||||
|
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
if (replyForm.value.id === undefined) {
|
if (submitForm.id === undefined) {
|
||||||
await MpAutoReplyApi.createAutoReply(submitForm);
|
await createAutoReply(submitForm);
|
||||||
ElMessage.success('新增成功');
|
ElMessage.success('新增成功');
|
||||||
} else {
|
} else {
|
||||||
await MpAutoReplyApi.updateAutoReply(submitForm);
|
await updateAutoReply(submitForm);
|
||||||
ElMessage.success('修改成功');
|
ElMessage.success('修改成功');
|
||||||
}
|
}
|
||||||
await modalApi.close();
|
await modalApi.close();
|
||||||
@@ -67,50 +94,28 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
async onOpenChange(isOpen: boolean) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
formData.value = undefined;
|
formData.value = undefined;
|
||||||
replyForm.value = {};
|
|
||||||
reply.value = {
|
|
||||||
type: ReplyType.Text,
|
|
||||||
accountId: -1,
|
|
||||||
};
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 加载数据
|
// 加载数据
|
||||||
const data = modalApi.getData<{
|
const data = modalApi.getData<{
|
||||||
accountId?: number;
|
accountId?: number;
|
||||||
isCreating: boolean;
|
|
||||||
msgType: MsgType;
|
msgType: MsgType;
|
||||||
row?: any;
|
row?: any;
|
||||||
}>();
|
}>();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
formData.value = data;
|
// 先更新 schema,确保表单字段正确
|
||||||
|
formApi.setState({ schema: useFormSchema(data.msgType) });
|
||||||
|
// 等待 schema 更新完成
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
if (data.isCreating) {
|
formData.value = data;
|
||||||
// 新建:初始化表单
|
if (data.row?.id) {
|
||||||
replyForm.value = {
|
|
||||||
id: undefined,
|
|
||||||
accountId: data.accountId || -1,
|
|
||||||
type: data.msgType,
|
|
||||||
requestKeyword: undefined,
|
|
||||||
requestMatch: data.msgType === MsgType.Keyword ? 1 : undefined,
|
|
||||||
requestMessageType: undefined,
|
|
||||||
};
|
|
||||||
reply.value = {
|
|
||||||
type: ReplyType.Text,
|
|
||||||
accountId: data.accountId || -1,
|
|
||||||
};
|
|
||||||
} else if (data.row) {
|
|
||||||
// 编辑:加载数据
|
// 编辑:加载数据
|
||||||
const rowData = data.row;
|
const rowData = data.row;
|
||||||
replyForm.value = { ...rowData };
|
const formValues: any = { ...rowData };
|
||||||
delete replyForm.value.responseMessageType;
|
formValues.reply = {
|
||||||
delete replyForm.value.responseContent;
|
|
||||||
delete replyForm.value.responseMediaId;
|
|
||||||
delete replyForm.value.responseMediaUrl;
|
|
||||||
delete replyForm.value.responseDescription;
|
|
||||||
delete replyForm.value.responseArticles;
|
|
||||||
reply.value = {
|
|
||||||
type: rowData.responseMessageType,
|
type: rowData.responseMessageType,
|
||||||
accountId: data.accountId || -1,
|
accountId: data.accountId || -1,
|
||||||
content: rowData.responseContent,
|
content: rowData.responseContent,
|
||||||
@@ -124,6 +129,22 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
musicUrl: rowData.responseMusicUrl,
|
musicUrl: rowData.responseMusicUrl,
|
||||||
hqMusicUrl: rowData.responseHqMusicUrl,
|
hqMusicUrl: rowData.responseHqMusicUrl,
|
||||||
};
|
};
|
||||||
|
await formApi.setValues(formValues);
|
||||||
|
} else {
|
||||||
|
// 新建:初始化表单
|
||||||
|
const initialValues: any = {
|
||||||
|
id: undefined,
|
||||||
|
accountId: data.accountId || -1,
|
||||||
|
type: data.msgType,
|
||||||
|
requestKeyword: undefined,
|
||||||
|
requestMatch: data.msgType === MsgType.Keyword ? 1 : undefined,
|
||||||
|
requestMessageType: undefined,
|
||||||
|
reply: {
|
||||||
|
type: ReplyType.Text,
|
||||||
|
accountId: data.accountId || -1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await formApi.setValues(initialValues);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -131,12 +152,6 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal :title="getTitle" class="w-4/5">
|
<Modal :title="getTitle" class="w-4/5">
|
||||||
<ReplyForm
|
<Form class="mx-4" />
|
||||||
v-if="formData"
|
|
||||||
v-model="replyForm"
|
|
||||||
v-model:reply="reply"
|
|
||||||
:msg-type="formData.msgType"
|
|
||||||
ref="formRef"
|
|
||||||
/>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import { useRouter } from 'vue-router';
|
|||||||
|
|
||||||
import { useTabs } from '@vben/hooks';
|
import { useTabs } from '@vben/hooks';
|
||||||
|
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage, ElOption, ElSelect } from 'element-plus';
|
||||||
|
|
||||||
import { getSimpleAccountList } from '#/api/mp/account';
|
import { getSimpleAccountList } from '#/api/mp/account';
|
||||||
|
|
||||||
defineOptions({ name: 'WxAccountSelect' });
|
defineOptions({ name: 'AccountSelect' });
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue?: number;
|
modelValue?: number;
|
||||||
@@ -121,19 +121,19 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-select
|
<ElSelect
|
||||||
v-model="currentId"
|
v-model="currentId"
|
||||||
placeholder="请选择公众号"
|
placeholder="请选择公众号"
|
||||||
class="!w-240px"
|
class="!w-240px"
|
||||||
@change="onChanged"
|
@change="onChanged"
|
||||||
>
|
>
|
||||||
<el-option
|
<ElOption
|
||||||
v-for="item in accountList"
|
v-for="item in accountList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.id"
|
:value="item.id"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</ElSelect>
|
||||||
</template>
|
</template>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
:deep(.el-select__wrapper) {
|
:deep(.el-select__wrapper) {
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './account-select.vue';
|
||||||
23
apps/web-ele/src/views/mp/components/index.ts
Normal file
23
apps/web-ele/src/views/mp/components/index.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// 统一导出所有模块组件
|
||||||
|
|
||||||
|
export { default as Location } from './location/location.vue';
|
||||||
|
|
||||||
|
export { default as MaterialSelect } from './material-select/material-select.vue';
|
||||||
|
export * from './material-select/types';
|
||||||
|
|
||||||
|
export * from './msg/types';
|
||||||
|
|
||||||
|
export { default as Music } from './music/music.vue';
|
||||||
|
|
||||||
|
export { default as News } from './news/news.vue';
|
||||||
|
|
||||||
|
export { default as ReplySelect } from './reply/reply.vue';
|
||||||
|
|
||||||
|
export * from './reply/types';
|
||||||
|
|
||||||
|
export { default as VideoPlayer } from './video-play/video-play.vue';
|
||||||
|
|
||||||
|
export { default as VoicePlayer } from './voice-play/voice-play.vue';
|
||||||
|
|
||||||
|
export { default as AccountSelect } from './account-select/account-select.vue';
|
||||||
|
|
||||||
1
apps/web-ele/src/views/mp/components/location/index.ts
Normal file
1
apps/web-ele/src/views/mp/components/location/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './location.vue';
|
||||||
@@ -2,7 +2,11 @@
|
|||||||
【微信消息 - 定位】TODO @Dhb52 目前未启用
|
【微信消息 - 定位】TODO @Dhb52 目前未启用
|
||||||
-->
|
-->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
defineOptions({ name: 'WxLocation' });
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import { ElCol, ElLink, ElRow } from 'element-plus';
|
||||||
|
|
||||||
|
defineOptions({ name: 'Location' });
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
locationX: {
|
locationX: {
|
||||||
@@ -36,26 +40,26 @@ defineExpose({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-link
|
<ElLink
|
||||||
type="primary"
|
type="primary"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
:href="`https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx=${
|
:href="`https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx=${
|
||||||
locationY
|
locationY
|
||||||
}&pointy=${locationX}&name=${label}&ref=yudao`"
|
}&pointy=${locationX}&name=${label}&ref=yudao`"
|
||||||
>
|
>
|
||||||
<el-col>
|
<ElCol>
|
||||||
<el-row>
|
<ElRow>
|
||||||
<img
|
<img
|
||||||
:src="`https://apis.map.qq.com/ws/staticmap/v2/?zoom=10&markers=color:blue|label:A|${
|
:src="`https://apis.map.qq.com/ws/staticmap/v2/?zoom=10&markers=color:blue|label:A|${
|
||||||
locationX
|
locationX
|
||||||
},${locationY}&key=${qqMapKey}&size=250*180`"
|
},${locationY}&key=${qqMapKey}&size=250*180`"
|
||||||
/>
|
/>
|
||||||
</el-row>
|
</ElRow>
|
||||||
<el-row>
|
<ElRow>
|
||||||
<Icon icon="ep:location" />
|
<IconifyIcon icon="ep:location" />
|
||||||
{{ label }}
|
{{ label }}
|
||||||
</el-row>
|
</ElRow>
|
||||||
</el-col>
|
</ElCol>
|
||||||
</el-link>
|
</ElLink>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
export { default } from './main.vue';
|
export { default } from './material-select.vue';
|
||||||
|
|
||||||
export { MaterialType, NewsType } from './types';
|
export { MaterialType, NewsType } from './types';
|
||||||
@@ -7,18 +7,27 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, reactive, ref } from 'vue';
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
|
|
||||||
|
import { IconifyIcon } from '@vben/icons';
|
||||||
import { formatTime } from '@vben/utils';
|
import { formatTime } from '@vben/utils';
|
||||||
|
|
||||||
|
import {
|
||||||
|
ElButton,
|
||||||
|
ElPagination,
|
||||||
|
ElRow,
|
||||||
|
ElTable,
|
||||||
|
ElTableColumn,
|
||||||
|
} from 'element-plus';
|
||||||
|
|
||||||
import * as MpDraftApi from '#/api/mp/draft';
|
import * as MpDraftApi from '#/api/mp/draft';
|
||||||
import * as MpFreePublishApi from '#/api/mp/freePublish';
|
import * as MpFreePublishApi from '#/api/mp/freePublish';
|
||||||
import * as MpMaterialApi from '#/api/mp/material';
|
import * as MpMaterialApi from '#/api/mp/material';
|
||||||
import WxNews from '#/views/mp/modules/wx-news';
|
import News from '#/views/mp/components/news/news.vue';
|
||||||
import WxVideoPlayer from '#/views/mp/modules/wx-video-play';
|
import VideoPlayer from '#/views/mp/components/video-play/video-play.vue';
|
||||||
import WxVoicePlayer from '#/views/mp/modules/wx-voice-play';
|
import VoicePlayer from '#/views/mp/components/voice-play/voice-play.vue';
|
||||||
|
|
||||||
import { NewsType } from './types';
|
import { NewsType } from './types';
|
||||||
|
|
||||||
defineOptions({ name: 'WxMaterialSelect' });
|
defineOptions({ name: 'MaterialSelect' });
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -119,34 +128,37 @@ onMounted(async () => {
|
|||||||
<div class="waterfall-item" v-for="item in list" :key="item.mediaId">
|
<div class="waterfall-item" v-for="item in list" :key="item.mediaId">
|
||||||
<img class="material-img" :src="item.url" />
|
<img class="material-img" :src="item.url" />
|
||||||
<p class="item-name">{{ item.name }}</p>
|
<p class="item-name">{{ item.name }}</p>
|
||||||
<el-row class="ope-row">
|
<ElRow class="ope-row">
|
||||||
<el-button type="success" @click="selectMaterialFun(item)">
|
<ElButton type="success" @click="selectMaterialFun(item)">
|
||||||
选择
|
选择
|
||||||
<Icon icon="ep:circle-check" />
|
<IconifyIcon icon="ep:circle-check" />
|
||||||
</el-button>
|
</ElButton>
|
||||||
</el-row>
|
</ElRow>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 分页组件 -->
|
<!-- 分页组件 -->
|
||||||
<Pagination
|
<ElPagination
|
||||||
|
background
|
||||||
|
layout="prev, pager, next, sizes, total"
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:page="queryParams.pageNo"
|
v-model:current-page="queryParams.pageNo"
|
||||||
v-model:limit="queryParams.pageSize"
|
v-model:page-size="queryParams.pageSize"
|
||||||
@pagination="getMaterialPageFun"
|
@current-change="getMaterialPageFun"
|
||||||
|
@size-change="getMaterialPageFun"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- 类型:voice -->
|
<!-- 类型:voice -->
|
||||||
<div v-else-if="props.type === 'voice'">
|
<div v-else-if="props.type === 'voice'">
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<el-table v-loading="loading" :data="list">
|
<ElTable v-loading="loading" :data="list">
|
||||||
<el-table-column label="编号" align="center" prop="mediaId" />
|
<ElTableColumn label="编号" align="center" prop="mediaId" />
|
||||||
<el-table-column label="文件名" align="center" prop="name" />
|
<ElTableColumn label="文件名" align="center" prop="name" />
|
||||||
<el-table-column label="语音" align="center">
|
<ElTableColumn label="语音" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<WxVoicePlayer :url="scope.row.url" />
|
<VoicePlayer :url="scope.row.url" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</ElTableColumn>
|
||||||
<el-table-column
|
<ElTableColumn
|
||||||
label="上传时间"
|
label="上传时间"
|
||||||
align="center"
|
align="center"
|
||||||
prop="createTime"
|
prop="createTime"
|
||||||
@@ -155,41 +167,40 @@ onMounted(async () => {
|
|||||||
(row: any) => formatTime(row.createTime, 'YYYY-MM-DD HH:mm:ss')
|
(row: any) => formatTime(row.createTime, 'YYYY-MM-DD HH:mm:ss')
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
<el-table-column label="操作" align="center" fixed="right">
|
<ElTableColumn label="操作" align="center" fixed="right">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<ElButton type="primary" link @click="selectMaterialFun(scope.row)">
|
||||||
type="primary"
|
|
||||||
link
|
|
||||||
@click="selectMaterialFun(scope.row)"
|
|
||||||
>
|
|
||||||
选择
|
选择
|
||||||
<Icon icon="ep:plus" />
|
<IconifyIcon icon="ep:plus" />
|
||||||
</el-button>
|
</ElButton>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</ElTableColumn>
|
||||||
</el-table>
|
</ElTable>
|
||||||
<!-- 分页组件 -->
|
<!-- 分页组件 -->
|
||||||
<Pagination
|
<ElPagination
|
||||||
|
background
|
||||||
|
layout="prev, pager, next, sizes, total"
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:page="queryParams.pageNo"
|
v-model:current-page="queryParams.pageNo"
|
||||||
v-model:limit="queryParams.pageSize"
|
v-model:page-size="queryParams.pageSize"
|
||||||
@pagination="getPage"
|
@current-change="getPage"
|
||||||
|
@size-change="getPage"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- 类型:video -->
|
<!-- 类型:video -->
|
||||||
<div v-else-if="props.type === 'video'">
|
<div v-else-if="props.type === 'video'">
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<el-table v-loading="loading" :data="list">
|
<ElTable v-loading="loading" :data="list">
|
||||||
<el-table-column label="编号" align="center" prop="mediaId" />
|
<ElTableColumn label="编号" align="center" prop="mediaId" />
|
||||||
<el-table-column label="文件名" align="center" prop="name" />
|
<ElTableColumn label="文件名" align="center" prop="name" />
|
||||||
<el-table-column label="标题" align="center" prop="title" />
|
<ElTableColumn label="标题" align="center" prop="title" />
|
||||||
<el-table-column label="介绍" align="center" prop="introduction" />
|
<ElTableColumn label="介绍" align="center" prop="introduction" />
|
||||||
<el-table-column label="视频" align="center">
|
<ElTableColumn label="视频" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<WxVideoPlayer :url="scope.row.url" />
|
<VideoPlayer :url="scope.row.url" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</ElTableColumn>
|
||||||
<el-table-column
|
<ElTableColumn
|
||||||
label="上传时间"
|
label="上传时间"
|
||||||
align="center"
|
align="center"
|
||||||
prop="createTime"
|
prop="createTime"
|
||||||
@@ -198,30 +209,29 @@ onMounted(async () => {
|
|||||||
(row: any) => formatTime(row.createTime, 'YYYY-MM-DD HH:mm:ss')
|
(row: any) => formatTime(row.createTime, 'YYYY-MM-DD HH:mm:ss')
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
<el-table-column
|
<ElTableColumn
|
||||||
label="操作"
|
label="操作"
|
||||||
align="center"
|
align="center"
|
||||||
fixed="right"
|
fixed="right"
|
||||||
class-name="small-padding fixed-width"
|
class-name="small-padding fixed-width"
|
||||||
>
|
>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<ElButton type="primary" link @click="selectMaterialFun(scope.row)">
|
||||||
type="primary"
|
|
||||||
link
|
|
||||||
@click="selectMaterialFun(scope.row)"
|
|
||||||
>
|
|
||||||
选择
|
选择
|
||||||
<Icon icon="akar-icons:circle-plus" />
|
<IconifyIcon icon="akar-icons:circle-plus" />
|
||||||
</el-button>
|
</ElButton>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</ElTableColumn>
|
||||||
</el-table>
|
</ElTable>
|
||||||
<!-- 分页组件 -->
|
<!-- 分页组件 -->
|
||||||
<Pagination
|
<ElPagination
|
||||||
|
background
|
||||||
|
layout="prev, pager, next, sizes, total"
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:page="queryParams.pageNo"
|
v-model:current-page="queryParams.pageNo"
|
||||||
v-model:limit="queryParams.pageSize"
|
v-model:page-size="queryParams.pageSize"
|
||||||
@pagination="getMaterialPageFun"
|
@current-change="getMaterialPageFun"
|
||||||
|
@size-change="getMaterialPageFun"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- 类型:news -->
|
<!-- 类型:news -->
|
||||||
@@ -229,22 +239,25 @@ onMounted(async () => {
|
|||||||
<div class="waterfall" v-loading="loading">
|
<div class="waterfall" v-loading="loading">
|
||||||
<div class="waterfall-item" v-for="item in list" :key="item.mediaId">
|
<div class="waterfall-item" v-for="item in list" :key="item.mediaId">
|
||||||
<div v-if="item.content && item.content.newsItem">
|
<div v-if="item.content && item.content.newsItem">
|
||||||
<WxNews :articles="item.content.newsItem" />
|
<News :articles="item.content.newsItem" />
|
||||||
<el-row class="ope-row">
|
<ElRow class="ope-row">
|
||||||
<el-button type="success" @click="selectMaterialFun(item)">
|
<ElButton type="success" @click="selectMaterialFun(item)">
|
||||||
选择
|
选择
|
||||||
<Icon icon="ep:circle-check" />
|
<IconifyIcon icon="ep:circle-check" />
|
||||||
</el-button>
|
</ElButton>
|
||||||
</el-row>
|
</ElRow>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 分页组件 -->
|
<!-- 分页组件 -->
|
||||||
<Pagination
|
<ElPagination
|
||||||
|
background
|
||||||
|
layout="prev, pager, next, sizes, total"
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:page="queryParams.pageNo"
|
v-model:current-page="queryParams.pageNo"
|
||||||
v-model:limit="queryParams.pageSize"
|
v-model:page-size="queryParams.pageSize"
|
||||||
@pagination="getMaterialPageFun"
|
@current-change="getMaterialPageFun"
|
||||||
|
@size-change="getMaterialPageFun"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
3
apps/web-ele/src/views/mp/components/msg/index.ts
Normal file
3
apps/web-ele/src/views/mp/components/msg/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export { default } from './msg.vue';
|
||||||
|
|
||||||
|
export { MsgType } from './types';
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { ElTag } from 'element-plus';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
item: any;
|
item: any;
|
||||||
}>();
|
}>();
|
||||||
@@ -11,44 +13,44 @@ const item = ref(props.item);
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div v-if="item.event === 'subscribe'">
|
<div v-if="item.event === 'subscribe'">
|
||||||
<el-tag type="success">关注</el-tag>
|
<ElTag type="success">关注</ElTag>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'unsubscribe'">
|
<div v-else-if="item.event === 'unsubscribe'">
|
||||||
<el-tag type="danger">取消关注</el-tag>
|
<ElTag type="danger">取消关注</ElTag>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'CLICK'">
|
<div v-else-if="item.event === 'CLICK'">
|
||||||
<el-tag>点击菜单</el-tag>
|
<ElTag>点击菜单</ElTag>
|
||||||
【{{ item.eventKey }}】
|
【{{ item.eventKey }}】
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'VIEW'">
|
<div v-else-if="item.event === 'VIEW'">
|
||||||
<el-tag>点击菜单链接</el-tag>
|
<ElTag>点击菜单链接</ElTag>
|
||||||
【{{ item.eventKey }}】
|
【{{ item.eventKey }}】
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'scancode_waitmsg'">
|
<div v-else-if="item.event === 'scancode_waitmsg'">
|
||||||
<el-tag>扫码结果</el-tag>
|
<ElTag>扫码结果</ElTag>
|
||||||
【{{ item.eventKey }}】
|
【{{ item.eventKey }}】
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'scancode_push'">
|
<div v-else-if="item.event === 'scancode_push'">
|
||||||
<el-tag>扫码结果</el-tag>
|
<ElTag>扫码结果</ElTag>
|
||||||
【{{ item.eventKey }}】
|
【{{ item.eventKey }}】
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'pic_sysphoto'">
|
<div v-else-if="item.event === 'pic_sysphoto'">
|
||||||
<el-tag>系统拍照发图</el-tag>
|
<ElTag>系统拍照发图</ElTag>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'pic_photo_or_album'">
|
<div v-else-if="item.event === 'pic_photo_or_album'">
|
||||||
<el-tag>拍照或者相册</el-tag>
|
<ElTag>拍照或者相册</ElTag>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'pic_weixin'">
|
<div v-else-if="item.event === 'pic_weixin'">
|
||||||
<el-tag>微信相册</el-tag>
|
<ElTag>微信相册</ElTag>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'location_select'">
|
<div v-else-if="item.event === 'location_select'">
|
||||||
<el-tag>选择地理位置</el-tag>
|
<ElTag>选择地理位置</ElTag>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.event === 'SCAN'">
|
<div v-else-if="item.event === 'SCAN'">
|
||||||
<el-tag>扫码</el-tag>
|
<ElTag>扫码</ElTag>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<el-tag type="danger">未知事件类型</el-tag>
|
<ElTag type="danger">未知事件类型</ElTag>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import WxLocation from '#/views/mp/modules/wx-location';
|
import Location from '#/views/mp/components/location/location.vue';
|
||||||
import WxMusic from '#/views/mp/modules/wx-music';
|
import Music from '#/views/mp/components/music/music.vue';
|
||||||
import WxNews from '#/views/mp/modules/wx-news';
|
import News from '#/views/mp/components/news/news.vue';
|
||||||
import WxVideoPlayer from '#/views/mp/modules/wx-video-play';
|
import VideoPlayer from '#/views/mp/components/video-play/video-play.vue';
|
||||||
import WxVoicePlayer from '#/views/mp/modules/wx-voice-play';
|
import VoicePlayer from '#/views/mp/components/voice-play/voice-play.vue';
|
||||||
|
|
||||||
import { MsgType } from '../types';
|
import { MsgType } from '../types';
|
||||||
import MsgEvent from './msg-event.vue';
|
import MsgEvent from './msg-event.vue';
|
||||||
@@ -26,7 +26,7 @@ const item = ref<any>(props.item);
|
|||||||
<div v-else-if="item.type === MsgType.Text">{{ item.content }}</div>
|
<div v-else-if="item.type === MsgType.Text">{{ item.content }}</div>
|
||||||
|
|
||||||
<div v-else-if="item.type === MsgType.Voice">
|
<div v-else-if="item.type === MsgType.Voice">
|
||||||
<WxVoicePlayer :url="item.mediaUrl" :content="item.recognition" />
|
<VoicePlayer :url="item.mediaUrl" :content="item.recognition" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="item.type === MsgType.Image">
|
<div v-else-if="item.type === MsgType.Image">
|
||||||
@@ -39,7 +39,7 @@ const item = ref<any>(props.item);
|
|||||||
v-else-if="item.type === MsgType.Video || item.type === 'shortvideo'"
|
v-else-if="item.type === MsgType.Video || item.type === 'shortvideo'"
|
||||||
class="text-center"
|
class="text-center"
|
||||||
>
|
>
|
||||||
<WxVideoPlayer :url="item.mediaUrl" />
|
<VideoPlayer :url="item.mediaUrl" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="item.type === MsgType.Link" class="flex-1">
|
<div v-else-if="item.type === MsgType.Link" class="flex-1">
|
||||||
@@ -64,7 +64,7 @@ const item = ref<any>(props.item);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="item.type === MsgType.Location">
|
<div v-else-if="item.type === MsgType.Location">
|
||||||
<WxLocation
|
<Location
|
||||||
:label="item.label"
|
:label="item.label"
|
||||||
:location-y="item.locationY"
|
:location-y="item.locationY"
|
||||||
:location-x="item.locationX"
|
:location-x="item.locationX"
|
||||||
@@ -72,11 +72,11 @@ const item = ref<any>(props.item);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="item.type === MsgType.News" class="w-[300px]">
|
<div v-else-if="item.type === MsgType.News" class="w-[300px]">
|
||||||
<WxNews :articles="item.articles" />
|
<News :articles="item.articles" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="item.type === MsgType.Music">
|
<div v-else-if="item.type === MsgType.Music">
|
||||||
<WxMusic
|
<Music
|
||||||
:title="item.title"
|
:title="item.title"
|
||||||
:description="item.description"
|
:description="item.description"
|
||||||
:thumb-media-url="item.thumbMediaUrl"
|
:thumb-media-url="item.thumbMediaUrl"
|
||||||
1
apps/web-ele/src/views/mp/components/music/index.ts
Normal file
1
apps/web-ele/src/views/mp/components/music/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './music.vue';
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
【微信消息 - 音乐】
|
【微信消息 - 音乐】
|
||||||
-->
|
-->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
defineOptions({ name: 'WxMusic' });
|
defineOptions({ name: 'Music' });
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
title: {
|
title: {
|
||||||
@@ -66,5 +66,5 @@ defineExpose({
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
/* 因为 joolun 实现依赖 avue 组件,该页面使用了 card.scss */
|
/* 因为 joolun 实现依赖 avue 组件,该页面使用了 card.scss */
|
||||||
@import url('../wx-msg/card.scss');
|
@import url('../msg/card.scss');
|
||||||
</style>
|
</style>
|
||||||
1
apps/web-ele/src/views/mp/components/news/index.ts
Normal file
1
apps/web-ele/src/views/mp/components/news/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './news.vue';
|
||||||
@@ -6,7 +6,9 @@
|
|||||||
① 代码优化,补充注释,提升阅读性
|
① 代码优化,补充注释,提升阅读性
|
||||||
-->
|
-->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
defineOptions({ name: 'WxNews' });
|
import { ElImage } from 'element-plus';
|
||||||
|
|
||||||
|
defineOptions({ name: 'News' });
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -29,7 +31,7 @@ defineExpose({
|
|||||||
<a v-if="index === 0" :href="article.url" target="_blank">
|
<a v-if="index === 0" :href="article.url" target="_blank">
|
||||||
<div class="news-main">
|
<div class="news-main">
|
||||||
<div class="news-content">
|
<div class="news-content">
|
||||||
<el-image
|
<ElImage
|
||||||
:src="article.picUrl || article.thumbUrl"
|
:src="article.picUrl || article.thumbUrl"
|
||||||
class="material-img"
|
class="material-img"
|
||||||
style="width: 100%; height: 120px"
|
style="width: 100%; height: 120px"
|
||||||
@@ -46,7 +48,7 @@ defineExpose({
|
|||||||
<div class="news-content-item">
|
<div class="news-content-item">
|
||||||
<div class="news-content-item-title">{{ article.title }}</div>
|
<div class="news-content-item-title">{{ article.title }}</div>
|
||||||
<div class="news-content-item-img">
|
<div class="news-content-item-img">
|
||||||
<img
|
<ElImage
|
||||||
:src="article.picUrl || article.thumbUrl"
|
:src="article.picUrl || article.thumbUrl"
|
||||||
class="material-img"
|
class="material-img"
|
||||||
height="100%"
|
height="100%"
|
||||||
7
apps/web-ele/src/views/mp/components/reply/index.ts
Normal file
7
apps/web-ele/src/views/mp/components/reply/index.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export { default } from './reply.vue';
|
||||||
|
|
||||||
|
export {
|
||||||
|
createEmptyReply,
|
||||||
|
type Reply,
|
||||||
|
ReplyType,
|
||||||
|
} from './types';
|
||||||
@@ -8,27 +8,28 @@
|
|||||||
④ 支持发送【视频】消息时,支持新建视频
|
④ 支持发送【视频】消息时,支持新建视频
|
||||||
-->
|
-->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Reply } from './modules/types';
|
import type { Reply } from './types';
|
||||||
|
|
||||||
import { computed, ref, unref, watch } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import { ElRow, ElTabPane, ElTabs } from 'element-plus';
|
import { ElRow, ElTabPane, ElTabs } from 'element-plus';
|
||||||
|
|
||||||
import TabImage from './modules/tab-image.vue';
|
import { NewsType } from '../material-select/types';
|
||||||
import TabMusic from './modules/tab-music.vue';
|
import TabImage from './tab-image.vue';
|
||||||
import TabNews from './modules/tab-news.vue';
|
import TabMusic from './tab-music.vue';
|
||||||
import TabText from './modules/tab-text.vue';
|
import TabNews from './tab-news.vue';
|
||||||
import TabVideo from './modules/tab-video.vue';
|
import TabText from './tab-text.vue';
|
||||||
import TabVoice from './modules/tab-voice.vue';
|
import TabVideo from './tab-video.vue';
|
||||||
import { createEmptyReply, NewsType, ReplyType } from './modules/types';
|
import TabVoice from './tab-voice.vue';
|
||||||
|
import { createEmptyReply, ReplyType } from './types';
|
||||||
|
|
||||||
defineOptions({ name: 'WxReplySelect' });
|
defineOptions({ name: 'ReplySelect' });
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
modelValue: Reply;
|
modelValue: Reply | undefined;
|
||||||
newsType?: NewsType;
|
newsType?: NewsType;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
@@ -38,40 +39,16 @@ const props = withDefaults(
|
|||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'update:modelValue', v: Reply): void;
|
(e: 'update:modelValue', v: Reply): void;
|
||||||
}>();
|
}>();
|
||||||
|
// 提供一个默认的 Reply 对象,避免 undefined 导致的错误
|
||||||
|
const defaultReply: Reply = {
|
||||||
|
accountId: -1,
|
||||||
|
type: ReplyType.Text,
|
||||||
|
};
|
||||||
|
|
||||||
const reply = computed<Reply>({
|
const reply = computed<Reply>({
|
||||||
get: () => props.modelValue,
|
get: () => props.modelValue || defaultReply,
|
||||||
set: (val) => emit('update:modelValue', val),
|
set: (val) => emit('update:modelValue', val),
|
||||||
});
|
});
|
||||||
// 作为多个标签保存各自Reply的缓存
|
|
||||||
const tabCache = new Map<ReplyType, Reply>();
|
|
||||||
// 采用独立的ref来保存当前tab,避免在watch标签变化,对reply进行赋值会产生了循环调用
|
|
||||||
const currentTab = ref<ReplyType>(props.modelValue.type || ReplyType.Text);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
currentTab,
|
|
||||||
(newTab, oldTab) => {
|
|
||||||
// 第一次进入:oldTab 为 undefined
|
|
||||||
// 判断 newTab 是因为 Reply 为 Partial
|
|
||||||
if (oldTab === undefined || newTab === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tabCache.set(oldTab, unref(reply));
|
|
||||||
|
|
||||||
// 从缓存里面取出新tab内容,有则覆盖Reply,没有则创建空Reply
|
|
||||||
const temp = tabCache.get(newTab);
|
|
||||||
if (temp) {
|
|
||||||
reply.value = temp;
|
|
||||||
} else {
|
|
||||||
const newData = createEmptyReply(reply);
|
|
||||||
newData.type = newTab;
|
|
||||||
reply.value = newData;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
immediate: true,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/** 清除除了`type`, `accountId`的字段 */
|
/** 清除除了`type`, `accountId`的字段 */
|
||||||
function clear() {
|
function clear() {
|
||||||
@@ -84,7 +61,7 @@ defineExpose({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ElTabs type="border-card" v-model="currentTab">
|
<ElTabs type="border-card" v-model="reply.type" @tab-change="clear">
|
||||||
<!-- 类型 1:文本 -->
|
<!-- 类型 1:文本 -->
|
||||||
<ElTabPane :name="ReplyType.Text">
|
<ElTabPane :name="ReplyType.Text">
|
||||||
<template #label>
|
<template #label>
|
||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
} from 'element-plus';
|
} from 'element-plus';
|
||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
import WxMaterialSelect from '#/views/mp/modules/wx-material-select';
|
import MaterialSelect from '#/views/mp/components/material-select/material-select.vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: Reply;
|
modelValue: Reply;
|
||||||
@@ -122,7 +122,7 @@ function selectMaterial(item: any) {
|
|||||||
append-to-body
|
append-to-body
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
>
|
>
|
||||||
<WxMaterialSelect
|
<MaterialSelect
|
||||||
type="image"
|
type="image"
|
||||||
:account-id="reply.accountId"
|
:account-id="reply.accountId"
|
||||||
@select-material="selectMaterial"
|
@select-material="selectMaterial"
|
||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
// import { getAccessToken } from '@/utils/auth'
|
// import { getAccessToken } from '@/utils/auth'
|
||||||
import WxMaterialSelect from '#/views/mp/modules/wx-material-select';
|
import MaterialSelect from '#/views/mp/components/material-select/material-select.vue';
|
||||||
|
|
||||||
// 设置上传的请求头部
|
// 设置上传的请求头部
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ function selectMaterial(item: any) {
|
|||||||
append-to-body
|
append-to-body
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
>
|
>
|
||||||
<WxMaterialSelect
|
<MaterialSelect
|
||||||
type="image"
|
type="image"
|
||||||
:account-id="reply.accountId"
|
:account-id="reply.accountId"
|
||||||
@select-material="selectMaterial"
|
@select-material="selectMaterial"
|
||||||
@@ -7,10 +7,10 @@ import { IconifyIcon } from '@vben/icons';
|
|||||||
|
|
||||||
import { ElButton, ElCol, ElDialog, ElRow } from 'element-plus';
|
import { ElButton, ElCol, ElDialog, ElRow } from 'element-plus';
|
||||||
|
|
||||||
import WxMaterialSelect from '#/views/mp/modules/wx-material-select';
|
import MaterialSelect from '#/views/mp/components/material-select/material-select.vue';
|
||||||
import WxNews from '#/views/mp/modules/wx-news';
|
import News from '#/views/mp/components/news/news.vue';
|
||||||
|
|
||||||
import { NewsType } from './types';
|
import { NewsType } from '../material-select/types';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: Reply;
|
modelValue: Reply;
|
||||||
@@ -45,7 +45,7 @@ function onDelete() {
|
|||||||
class="mx-auto mb-[10px] w-[280px] border border-[#eaeaea] p-[10px]"
|
class="mx-auto mb-[10px] w-[280px] border border-[#eaeaea] p-[10px]"
|
||||||
v-if="reply.articles && reply.articles.length > 0"
|
v-if="reply.articles && reply.articles.length > 0"
|
||||||
>
|
>
|
||||||
<WxNews :articles="reply.articles" />
|
<News :articles="reply.articles" />
|
||||||
<ElCol class="pt-[10px] text-center">
|
<ElCol class="pt-[10px] text-center">
|
||||||
<ElButton type="danger" circle @click="onDelete">
|
<ElButton type="danger" circle @click="onDelete">
|
||||||
<IconifyIcon icon="ep:delete" />
|
<IconifyIcon icon="ep:delete" />
|
||||||
@@ -74,7 +74,7 @@ function onDelete() {
|
|||||||
append-to-body
|
append-to-body
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
>
|
>
|
||||||
<WxMaterialSelect
|
<MaterialSelect
|
||||||
type="news"
|
type="news"
|
||||||
:account-id="reply.accountId"
|
:account-id="reply.accountId"
|
||||||
:news-type="newsType"
|
:news-type="newsType"
|
||||||
@@ -19,8 +19,8 @@ import {
|
|||||||
} from 'element-plus';
|
} from 'element-plus';
|
||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
import WxMaterialSelect from '#/views/mp/modules/wx-material-select';
|
import MaterialSelect from '#/views/mp/components/material-select/material-select.vue';
|
||||||
import WxVideoPlayer from '#/views/mp/modules/wx-video-play';
|
import VideoPlayer from '#/views/mp/components/video-play/video-play.vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: Reply;
|
modelValue: Reply;
|
||||||
@@ -97,7 +97,7 @@ function selectMaterial(item: any) {
|
|||||||
placeholder="请输入描述"
|
placeholder="请输入描述"
|
||||||
/>
|
/>
|
||||||
<ElRow class="w-full pt-[10px] text-center" justify="center">
|
<ElRow class="w-full pt-[10px] text-center" justify="center">
|
||||||
<WxVideoPlayer v-if="reply.url" :url="reply.url" />
|
<VideoPlayer v-if="reply.url" :url="reply.url" />
|
||||||
</ElRow>
|
</ElRow>
|
||||||
<ElCol>
|
<ElCol>
|
||||||
<ElRow class="text-center" align="middle">
|
<ElRow class="text-center" align="middle">
|
||||||
@@ -113,7 +113,7 @@ function selectMaterial(item: any) {
|
|||||||
append-to-body
|
append-to-body
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
>
|
>
|
||||||
<WxMaterialSelect
|
<MaterialSelect
|
||||||
type="video"
|
type="video"
|
||||||
:account-id="reply.accountId"
|
:account-id="reply.accountId"
|
||||||
@select-material="selectMaterial"
|
@select-material="selectMaterial"
|
||||||
@@ -18,8 +18,8 @@ import {
|
|||||||
} from 'element-plus';
|
} from 'element-plus';
|
||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
import WxMaterialSelect from '#/views/mp/modules/wx-material-select';
|
import MaterialSelect from '#/views/mp/components/material-select/material-select.vue';
|
||||||
import WxVoicePlayer from '#/views/mp/modules/wx-voice-play';
|
import VoicePlayer from '#/views/mp/components/voice-play/voice-play.vue';
|
||||||
|
|
||||||
// 设置上传的请求头部
|
// 设置上传的请求头部
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ function selectMaterial(item: Reply) {
|
|||||||
{{ reply.name }}
|
{{ reply.name }}
|
||||||
</p>
|
</p>
|
||||||
<ElRow class="w-full pt-[10px] text-center" justify="center">
|
<ElRow class="w-full pt-[10px] text-center" justify="center">
|
||||||
<WxVoicePlayer :url="reply.url" />
|
<VoicePlayer :url="reply.url" />
|
||||||
</ElRow>
|
</ElRow>
|
||||||
<ElRow class="w-full pt-[10px] text-center" justify="center">
|
<ElRow class="w-full pt-[10px] text-center" justify="center">
|
||||||
<ElButton type="danger" circle @click="onDelete">
|
<ElButton type="danger" circle @click="onDelete">
|
||||||
@@ -123,7 +123,7 @@ function selectMaterial(item: Reply) {
|
|||||||
append-to-body
|
append-to-body
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
>
|
>
|
||||||
<WxMaterialSelect
|
<MaterialSelect
|
||||||
type="voice"
|
type="voice"
|
||||||
:account-id="reply.accountId"
|
:account-id="reply.accountId"
|
||||||
@select-material="selectMaterial"
|
@select-material="selectMaterial"
|
||||||
@@ -30,11 +30,6 @@ interface _Reply {
|
|||||||
|
|
||||||
type Reply = _Reply; // Partial<_Reply>
|
type Reply = _Reply; // Partial<_Reply>
|
||||||
|
|
||||||
enum NewsType {
|
|
||||||
Draft = '2',
|
|
||||||
Published = '1',
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 利用旧的reply[accountId, type]初始化新的Reply */
|
/** 利用旧的reply[accountId, type]初始化新的Reply */
|
||||||
const createEmptyReply = (old: Ref<Reply> | Reply): Reply => {
|
const createEmptyReply = (old: Ref<Reply> | Reply): Reply => {
|
||||||
return {
|
return {
|
||||||
@@ -55,4 +50,4 @@ const createEmptyReply = (old: Ref<Reply> | Reply): Reply => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export { createEmptyReply, NewsType, type Reply, ReplyType };
|
export { createEmptyReply, type Reply, ReplyType };
|
||||||
1
apps/web-ele/src/views/mp/components/video-play/index.ts
Normal file
1
apps/web-ele/src/views/mp/components/video-play/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './video-play.vue';
|
||||||
@@ -13,11 +13,14 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import { VideoPlayer } from '@videojs-player/vue';
|
import { VideoPlayer } from '@videojs-player/vue';
|
||||||
|
import { ElDialog } from 'element-plus';
|
||||||
|
|
||||||
import 'video.js/dist/video-js.css';
|
import 'video.js/dist/video-js.css';
|
||||||
|
|
||||||
defineOptions({ name: 'WxVideoPlayer' });
|
defineOptions({ name: 'VideoPlayer' });
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
@@ -40,13 +43,13 @@ const playVideo = () => {
|
|||||||
<template>
|
<template>
|
||||||
<div @click="playVideo()">
|
<div @click="playVideo()">
|
||||||
<!-- 提示 -->
|
<!-- 提示 -->
|
||||||
<div>
|
<div class="flex cursor-pointer flex-col items-center">
|
||||||
<Icon icon="ep:video-play" :size="32" class="mr-5px" />
|
<IconifyIcon icon="ep:video-play" :size="32" class="mr-5px" />
|
||||||
<p class="text-sm">点击播放视频</p>
|
<p class="text-sm">点击播放视频</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 弹窗播放 -->
|
<!-- 弹窗播放 -->
|
||||||
<el-dialog v-model="dialogVideo" title="视频播放" append-to-body>
|
<ElDialog v-model="dialogVideo" title="视频播放" append-to-body>
|
||||||
<VideoPlayer
|
<VideoPlayer
|
||||||
v-if="dialogVideo"
|
v-if="dialogVideo"
|
||||||
class="video-player vjs-big-play-centered"
|
class="video-player vjs-big-play-centered"
|
||||||
@@ -70,6 +73,6 @@ const playVideo = () => {
|
|||||||
<!-- @canplay="handleEvent($event)"-->
|
<!-- @canplay="handleEvent($event)"-->
|
||||||
<!-- @canplaythrough="handleEvent($event)"-->
|
<!-- @canplaythrough="handleEvent($event)"-->
|
||||||
<!-- @timeupdate="handleEvent(player?.currentTime())"-->
|
<!-- @timeupdate="handleEvent(player?.currentTime())"-->
|
||||||
</el-dialog>
|
</ElDialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
1
apps/web-ele/src/views/mp/components/voice-play/index.ts
Normal file
1
apps/web-ele/src/views/mp/components/voice-play/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './voice-play.vue';
|
||||||
@@ -12,10 +12,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
// 因为微信语音是 amr 格式,所以需要用到 amr 解码器:https://www.npmjs.com/package/benz-amr-recorder
|
// 因为微信语音是 amr 格式,所以需要用到 amr 解码器:https://www.npmjs.com/package/benz-amr-recorder
|
||||||
import BenzAMRRecorder from 'benz-amr-recorder';
|
import BenzAMRRecorder from 'benz-amr-recorder';
|
||||||
|
|
||||||
defineOptions({ name: 'WxVoicePlayer' });
|
defineOptions({ name: 'VoicePlayer' });
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
@@ -79,8 +81,8 @@ const amrStop = () => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="wx-voice-div" @click="playVoice">
|
<div class="wx-voice-div" @click="playVoice">
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<Icon v-if="playing !== true" icon="ep:video-play" :size="32" />
|
<IconifyIcon v-if="playing !== true" icon="ep:video-play" :size="32" />
|
||||||
<Icon v-else icon="ep:video-pause" :size="32" />
|
<IconifyIcon v-else icon="ep:video-pause" :size="32" />
|
||||||
<span class="amr-duration" v-if="duration">{{ duration }} 秒</span>
|
<span class="amr-duration" v-if="duration">{{ duration }} 秒</span>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<div v-if="content">
|
<div v-if="content">
|
||||||
@@ -3,7 +3,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|||||||
|
|
||||||
import { markRaw } from 'vue';
|
import { markRaw } from 'vue';
|
||||||
|
|
||||||
import WxAccountSelect from '#/views/mp/modules/wx-account-select/main.vue';
|
import AccountSelect from '#/views/mp/components/account-select/account-select.vue';
|
||||||
|
|
||||||
/** 获取表格列配置 */
|
/** 获取表格列配置 */
|
||||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
@@ -35,7 +35,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
{
|
{
|
||||||
fieldName: 'accountId',
|
fieldName: 'accountId',
|
||||||
label: '公众号',
|
label: '公众号',
|
||||||
component: markRaw(WxAccountSelect),
|
component: markRaw(AccountSelect),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { useAccessStore } from '@vben/stores';
|
|||||||
import { ElButton, ElDialog, ElImage, ElMessage, ElUpload } from 'element-plus';
|
import { ElButton, ElDialog, ElImage, ElMessage, ElUpload } from 'element-plus';
|
||||||
|
|
||||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||||
import WxMaterialSelect from '#/views/mp/modules/wx-material-select';
|
import MaterialSelect from '#/views/mp/components/material-select/material-select.vue';
|
||||||
|
|
||||||
// 设置上传的请求头部
|
// 设置上传的请求头部
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ function onUploadError(err: Error) {
|
|||||||
append-to-body
|
append-to-body
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
>
|
>
|
||||||
<WxMaterialSelect
|
<MaterialSelect
|
||||||
type="image"
|
type="image"
|
||||||
:account-id="accountId!"
|
:account-id="accountId!"
|
||||||
@select-material="onMaterialSelected"
|
@select-material="onMaterialSelected"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Article } from './types';
|
import type { Article } from './types';
|
||||||
|
|
||||||
import WxNews from '#/views/mp/modules/wx-news';
|
import News from '#/views/mp/components/news/news.vue';
|
||||||
|
|
||||||
defineOptions({ name: 'DraftTableCell' });
|
defineOptions({ name: 'DraftTableCell' });
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ const props = defineProps<{
|
|||||||
<template>
|
<template>
|
||||||
<div class="draft-content">
|
<div class="draft-content">
|
||||||
<div v-if="props.row.content && props.row.content.newsItem">
|
<div v-if="props.row.content && props.row.content.newsItem">
|
||||||
<WxNews :articles="props.row.content.newsItem" />
|
<News :articles="props.row.content.newsItem" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
|
||||||
|
import { getSimpleAccountList } from '#/api/mp/account';
|
||||||
/** 菜单未选中标识 */
|
/** 菜单未选中标识 */
|
||||||
export const MENU_NOT_SELECTED = '__MENU_NOT_SELECTED__';
|
export const MENU_NOT_SELECTED = '__MENU_NOT_SELECTED__';
|
||||||
|
|
||||||
@@ -7,3 +10,20 @@ export enum Level {
|
|||||||
Parent = '1',
|
Parent = '1',
|
||||||
Undefined = '0',
|
Undefined = '0',
|
||||||
}
|
}
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'accountId',
|
||||||
|
label: '公众号',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: getSimpleAccountList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
autoSelect: 'first',
|
||||||
|
placeholder: '请选择公众号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Menu, RawMenu } from './modules/types';
|
import type { Menu, RawMenu } from './modules/types';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { nextTick, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { confirm, ContentWrap, DocAlert, Page } from '@vben/common-ui';
|
import { confirm, ContentWrap, DocAlert, Page } from '@vben/common-ui';
|
||||||
|
|
||||||
import {
|
import { ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||||
ElButton,
|
|
||||||
ElForm,
|
|
||||||
ElFormItem,
|
|
||||||
ElLoading,
|
|
||||||
ElMessage,
|
|
||||||
} from 'element-plus';
|
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { getSimpleAccountList } from '#/api/mp/account';
|
||||||
import * as MpMenuApi from '#/api/mp/menu';
|
import * as MpMenuApi from '#/api/mp/menu';
|
||||||
import * as UtilsTree from '#/utils/tree';
|
import * as UtilsTree from '#/utils/tree';
|
||||||
import { Level, MENU_NOT_SELECTED } from '#/views/mp/menu/data';
|
import {
|
||||||
|
Level,
|
||||||
|
MENU_NOT_SELECTED,
|
||||||
|
useGridFormSchema,
|
||||||
|
} from '#/views/mp/menu/data';
|
||||||
import MenuEditor from '#/views/mp/menu/modules/menu-editor.vue';
|
import MenuEditor from '#/views/mp/menu/modules/menu-editor.vue';
|
||||||
import MenuPreviewer from '#/views/mp/menu/modules/menu-previewer.vue';
|
import MenuPreviewer from '#/views/mp/menu/modules/menu-previewer.vue';
|
||||||
import WxAccountSelect from '#/views/mp/modules/wx-account-select/main.vue';
|
|
||||||
|
// Assets for backgrounds
|
||||||
|
import iphoneBackImg from './assets/iphone_backImg.png';
|
||||||
|
import menuFootImg from './assets/menu_foot.png';
|
||||||
|
import menuHeadImg from './assets/menu_head.png';
|
||||||
|
|
||||||
defineOptions({ name: 'MpMenu' });
|
defineOptions({ name: 'MpMenu' });
|
||||||
|
|
||||||
@@ -56,10 +60,32 @@ const tempSelfObj = ref<{
|
|||||||
});
|
});
|
||||||
const dialogNewsVisible = ref(false); // 跳转图文时的素材选择弹窗
|
const dialogNewsVisible = ref(false); // 跳转图文时的素材选择弹窗
|
||||||
|
|
||||||
|
// 创建表单
|
||||||
|
const [AccountForm, accountFormApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-[240px]',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
wrapperClass: 'grid-cols-1',
|
||||||
|
showDefaultActions: false,
|
||||||
|
handleValuesChange: async (values, changedFields) => {
|
||||||
|
// 当 accountId 字段变化时(包括 autoSelect 自动选择),同步更新 accountId
|
||||||
|
if (changedFields.includes('accountId') && values.accountId) {
|
||||||
|
await onAccountChanged(values);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
/** 侦听公众号变化 */
|
/** 侦听公众号变化 */
|
||||||
function onAccountChanged(id: number, name: string) {
|
async function onAccountChanged(values: Record<string, any>) {
|
||||||
accountId.value = id;
|
accountId.value = values.accountId;
|
||||||
accountName.value = name;
|
// 从 API 获取公众号列表并查找对应的公众号名称
|
||||||
|
const accountList = await getSimpleAccountList();
|
||||||
|
const account = accountList.find((item) => item.id === values.accountId);
|
||||||
|
accountName.value = account?.name || '';
|
||||||
getList();
|
getList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,6 +283,27 @@ function menuToBackend(menu: any) {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 初始化账号ID - 作为备用方案,防止 handleValuesChange 未触发 */
|
||||||
|
async function initAccountId() {
|
||||||
|
// 等待表单初始化完成
|
||||||
|
await nextTick();
|
||||||
|
try {
|
||||||
|
const values = await accountFormApi.getValues();
|
||||||
|
if (values?.accountId && accountId.value === -1) {
|
||||||
|
// 如果表单有值但 accountId 还是初始值,则手动触发一次
|
||||||
|
await onAccountChanged(values);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// 忽略错误
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 组件挂载时初始化账号ID
|
||||||
|
onMounted(async () => {
|
||||||
|
await nextTick();
|
||||||
|
await initAccountId();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -267,21 +314,34 @@ function menuToBackend(menu: any) {
|
|||||||
|
|
||||||
<!-- 搜索工作栏 -->
|
<!-- 搜索工作栏 -->
|
||||||
<!-- <ContentWrap> -->
|
<!-- <ContentWrap> -->
|
||||||
<ElForm :inline="true" label-width="68px" class="-mb-15px w-240px">
|
<AccountForm class="-mb-15px w-240px" @values-change="onAccountChanged" />
|
||||||
<ElFormItem label="公众号" prop="accountId" class="w-240px">
|
|
||||||
<WxAccountSelect @change="onAccountChanged" />
|
|
||||||
</ElFormItem>
|
|
||||||
</ElForm>
|
|
||||||
<!-- </ContentWrap> -->
|
<!-- </ContentWrap> -->
|
||||||
|
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<div class="clearfix public-account-management" v-loading="loading">
|
<div
|
||||||
|
class="public-account-management mx-auto flex w-full max-w-[1200px] flex-wrap items-start gap-[20px]"
|
||||||
|
v-loading="loading"
|
||||||
|
>
|
||||||
<!--左边配置菜单-->
|
<!--左边配置菜单-->
|
||||||
<div class="left">
|
<div
|
||||||
<div class="weixin-hd">
|
class="left relative box-border block h-[715px] w-[350px] flex-shrink-0 bg-[length:100%_auto] bg-no-repeat px-[25px] pb-[88px] pt-[518px]"
|
||||||
<div class="weixin-title">{{ accountName }}</div>
|
:style="{ backgroundImage: `url(${iphoneBackImg})` }"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="relative bottom-[426px] left-0 h-[64px] w-[300px] bg-[length:100%_auto] bg-no-repeat text-center text-white"
|
||||||
|
:style="{ backgroundImage: `url(${menuHeadImg})` }"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="absolute left-0 top-[33px] w-full text-center text-[14px] text-white"
|
||||||
|
>
|
||||||
|
{{ accountName }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix weixin-menu">
|
<div
|
||||||
|
class="weixin-menu h-[46px] bg-no-repeat pl-[43px] text-[12px]"
|
||||||
|
:style="{ backgroundImage: `url(${menuFootImg})` }"
|
||||||
|
>
|
||||||
<MenuPreviewer
|
<MenuPreviewer
|
||||||
v-model="menuList"
|
v-model="menuList"
|
||||||
:account-id="accountId"
|
:account-id="accountId"
|
||||||
@@ -291,9 +351,9 @@ function menuToBackend(menu: any) {
|
|||||||
@submenu-clicked="(child, x, y) => subMenuClicked(child, x, y)"
|
@submenu-clicked="(child, x, y) => subMenuClicked(child, x, y)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="save-div">
|
<div class="mt-[15px] text-center">
|
||||||
<ElButton
|
<ElButton
|
||||||
class="save-btn"
|
class="mx-2"
|
||||||
type="success"
|
type="success"
|
||||||
@click="onSave"
|
@click="onSave"
|
||||||
v-access:code="['mp:menu:save']"
|
v-access:code="['mp:menu:save']"
|
||||||
@@ -301,7 +361,7 @@ function menuToBackend(menu: any) {
|
|||||||
保存并发布菜单
|
保存并发布菜单
|
||||||
</ElButton>
|
</ElButton>
|
||||||
<ElButton
|
<ElButton
|
||||||
class="save-btn"
|
class="mx-2"
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="onClear"
|
@click="onClear"
|
||||||
v-access:code="['mp:menu:delete']"
|
v-access:code="['mp:menu:delete']"
|
||||||
@@ -311,7 +371,10 @@ function menuToBackend(menu: any) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--右边配置-->
|
<!--右边配置-->
|
||||||
<div class="right" v-if="showRightPanel">
|
<div
|
||||||
|
class="right box-border flex-1 basis-[63%] bg-[#e8e7e7] p-[20px]"
|
||||||
|
v-if="showRightPanel"
|
||||||
|
>
|
||||||
<MenuEditor
|
<MenuEditor
|
||||||
:account-id="accountId"
|
:account-id="accountId"
|
||||||
:is-parent="isParent"
|
:is-parent="isParent"
|
||||||
@@ -320,94 +383,13 @@ function menuToBackend(menu: any) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- 一进页面就显示的默认页面,当点击左边按钮的时候,就不显示了-->
|
<!-- 一进页面就显示的默认页面,当点击左边按钮的时候,就不显示了-->
|
||||||
<div v-else class="right">
|
<div
|
||||||
<p>请选择菜单配置</p>
|
v-else
|
||||||
|
class="right box-border flex-1 basis-[63%] bg-[#e8e7e7] p-[20px]"
|
||||||
|
>
|
||||||
|
<p class="text-left">请选择菜单配置</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
/* 公共颜色变量 */
|
|
||||||
.clearfix {
|
|
||||||
*zoom: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.clearfix::after {
|
|
||||||
clear: both;
|
|
||||||
display: table;
|
|
||||||
content: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
div {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.weixin-hd {
|
|
||||||
position: relative;
|
|
||||||
bottom: 426px;
|
|
||||||
left: 0;
|
|
||||||
width: 300px;
|
|
||||||
height: 64px;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
background: transparent url('./assets/menu_head.png') no-repeat 0 0;
|
|
||||||
background-position: 0 0;
|
|
||||||
background-size: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.weixin-title {
|
|
||||||
position: absolute;
|
|
||||||
top: 33px;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
font-size: 14px;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.weixin-menu {
|
|
||||||
padding-left: 43px;
|
|
||||||
font-size: 12px;
|
|
||||||
background: transparent url('./assets/menu_foot.png') no-repeat 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.public-account-management {
|
|
||||||
width: 1200px;
|
|
||||||
// min-width: 1200px;
|
|
||||||
margin: 0 auto;
|
|
||||||
|
|
||||||
.left {
|
|
||||||
position: relative;
|
|
||||||
float: left;
|
|
||||||
box-sizing: border-box;
|
|
||||||
display: block;
|
|
||||||
width: 350px;
|
|
||||||
height: 715px;
|
|
||||||
padding: 518px 25px 88px;
|
|
||||||
background: url('./assets/iphone_backImg.png') no-repeat;
|
|
||||||
background-size: 100% auto;
|
|
||||||
|
|
||||||
.save-div {
|
|
||||||
margin-top: 15px;
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
.save-btn {
|
|
||||||
bottom: 20px;
|
|
||||||
left: 100px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 右边菜单内容 */
|
|
||||||
.right {
|
|
||||||
float: left;
|
|
||||||
box-sizing: border-box;
|
|
||||||
width: 63%;
|
|
||||||
padding: 20px;
|
|
||||||
margin-left: 20px;
|
|
||||||
background-color: #e8e7e7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import {
|
|||||||
ElSelect,
|
ElSelect,
|
||||||
} from 'element-plus';
|
} from 'element-plus';
|
||||||
|
|
||||||
import WxMaterialSelect from '#/views/mp/modules/wx-material-select';
|
import MaterialSelect from '#/views/mp/components/material-select/material-select.vue';
|
||||||
import WxNews from '#/views/mp/modules/wx-news';
|
import News from '#/views/mp/components/news/news.vue';
|
||||||
import WxReplySelect from '#/views/mp/modules/wx-reply';
|
import ReplySelect from '#/views/mp/components/reply/reply.vue';
|
||||||
|
|
||||||
import menuOptions from './menuOptions';
|
import menuOptions from './menuOptions';
|
||||||
|
|
||||||
@@ -82,199 +82,150 @@ function deleteMaterial() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="space-y-5">
|
||||||
<div class="configure-page">
|
<div class="flex justify-end">
|
||||||
<div class="delete-btn">
|
<ElButton type="danger" @click="emit('delete')">
|
||||||
<ElButton type="danger" @click="emit('delete')">
|
<IconifyIcon icon="ep:delete" />
|
||||||
<IconifyIcon icon="ep:delete" />
|
删除当前菜单
|
||||||
删除当前菜单
|
</ElButton>
|
||||||
</ElButton>
|
</div>
|
||||||
</div>
|
<div class="flex items-center gap-3">
|
||||||
<div>
|
<span class="w-[100px] text-base">菜单名称:</span>
|
||||||
<span>菜单名称:</span>
|
<ElInput
|
||||||
|
class="w-[40%] min-w-[220px]"
|
||||||
|
v-model="menu.name"
|
||||||
|
placeholder="请输入菜单名称"
|
||||||
|
:maxlength="isParent ? 4 : 7"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div v-if="isLeave" class="space-y-5">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<span class="w-[100px] text-base">菜单标识:</span>
|
||||||
<ElInput
|
<ElInput
|
||||||
class="input-width"
|
class="w-[40%] min-w-[220px]"
|
||||||
v-model="menu.name"
|
v-model="menu.menuKey"
|
||||||
placeholder="请输入菜单名称"
|
placeholder="请输入菜单 KEY"
|
||||||
:maxlength="isParent ? 4 : 7"
|
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isLeave">
|
<div class="flex items-center gap-3">
|
||||||
<div class="menu-content">
|
<span class="w-[100px] text-base">菜单内容:</span>
|
||||||
<span>菜单标识:</span>
|
<ElSelect
|
||||||
<ElInput
|
v-model="menu.type"
|
||||||
class="input-width"
|
clearable
|
||||||
v-model="menu.menuKey"
|
placeholder="请选择"
|
||||||
placeholder="请输入菜单 KEY"
|
class="w-[40%] min-w-[220px]"
|
||||||
clearable
|
>
|
||||||
|
<ElOption
|
||||||
|
v-for="item in menuOptions"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
:key="item.value"
|
||||||
/>
|
/>
|
||||||
</div>
|
</ElSelect>
|
||||||
<div class="menu-content">
|
</div>
|
||||||
<span>菜单内容:</span>
|
<div
|
||||||
<ElSelect
|
class="rounded bg-white px-3 py-5 shadow-sm"
|
||||||
v-model="menu.type"
|
v-if="menu.type === 'view'"
|
||||||
clearable
|
>
|
||||||
placeholder="请选择"
|
<div class="flex items-center gap-3">
|
||||||
class="menu_option"
|
<span class="text-base">跳转链接:</span>
|
||||||
>
|
|
||||||
<ElOption
|
|
||||||
v-for="item in menuOptions"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
:key="item.value"
|
|
||||||
/>
|
|
||||||
</ElSelect>
|
|
||||||
</div>
|
|
||||||
<div class="configur-content" v-if="menu.type === 'view'">
|
|
||||||
<span>跳转链接:</span>
|
|
||||||
<ElInput
|
<ElInput
|
||||||
class="input-width"
|
class="w-[40%] min-w-[220px]"
|
||||||
v-model="menu.url"
|
v-model="menu.url"
|
||||||
placeholder="请输入链接"
|
placeholder="请输入链接"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="configur-content" v-if="menu.type === 'miniprogram'">
|
</div>
|
||||||
<div class="applet">
|
<div
|
||||||
<span>小程序的 appid :</span>
|
class="space-y-5 rounded bg-white px-3 py-5 shadow-sm"
|
||||||
<ElInput
|
v-if="menu.type === 'miniprogram'"
|
||||||
class="input-width"
|
>
|
||||||
v-model="menu.miniProgramAppId"
|
<div class="flex items-center gap-3">
|
||||||
placeholder="请输入小程序的appid"
|
<span class="inline-block w-[25%] min-w-[120px] text-base">
|
||||||
clearable
|
小程序的 appid :
|
||||||
/>
|
</span>
|
||||||
</div>
|
<ElInput
|
||||||
<div class="applet">
|
class="w-[40%] min-w-[220px]"
|
||||||
<span>小程序的页面路径:</span>
|
v-model="menu.miniProgramAppId"
|
||||||
<ElInput
|
placeholder="请输入小程序的appid"
|
||||||
class="input-width"
|
clearable
|
||||||
v-model="menu.miniProgramPagePath"
|
/>
|
||||||
placeholder="请输入小程序的页面路径,如:pages/index"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="applet">
|
|
||||||
<span>小程序的备用网页:</span>
|
|
||||||
<ElInput
|
|
||||||
class="input-width"
|
|
||||||
v-model="menu.url"
|
|
||||||
placeholder="不支持小程序的老版本客户端将打开本网页"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<p class="blue">
|
|
||||||
tips:需要和公众号进行关联才可以把小程序绑定带微信菜单上哟!
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="flex items-center gap-3">
|
||||||
class="configur-content"
|
<span class="inline-block w-[25%] min-w-[120px] text-base">
|
||||||
v-if="menu.type === 'article_view_limited'"
|
小程序的页面路径:
|
||||||
>
|
</span>
|
||||||
<ElRow>
|
<ElInput
|
||||||
<div class="select-item" v-if="menu && menu.replyArticles">
|
class="w-[40%] min-w-[220px]"
|
||||||
<WxNews :articles="menu.replyArticles" />
|
v-model="menu.miniProgramPagePath"
|
||||||
<ElRow class="ope-row" justify="center" align="middle">
|
placeholder="请输入小程序的页面路径,如:pages/index"
|
||||||
<ElButton type="danger" circle @click="deleteMaterial">
|
clearable
|
||||||
<IconifyIcon icon="ep:delete" />
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<span class="inline-block w-[25%] min-w-[120px] text-base">
|
||||||
|
小程序的备用网页:
|
||||||
|
</span>
|
||||||
|
<ElInput
|
||||||
|
class="w-[40%] min-w-[220px]"
|
||||||
|
v-model="menu.url"
|
||||||
|
placeholder="不支持小程序的老版本客户端将打开本网页"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p class="text-sm text-[#29b6f6]">
|
||||||
|
tips:需要和公众号进行关联才可以把小程序绑定带微信菜单上哟!
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="rounded bg-white px-3 py-5 shadow-sm"
|
||||||
|
v-if="menu.type === 'article_view_limited'"
|
||||||
|
>
|
||||||
|
<ElRow>
|
||||||
|
<div
|
||||||
|
class="mx-auto mb-2.5 w-[280px] border border-[#eaeaea] p-2.5"
|
||||||
|
v-if="menu && menu.replyArticles"
|
||||||
|
>
|
||||||
|
<News :articles="menu.replyArticles" />
|
||||||
|
<ElRow class="pt-2.5 text-center" justify="center" align="middle">
|
||||||
|
<ElButton type="danger" circle @click="deleteMaterial">
|
||||||
|
<IconifyIcon icon="ep:delete" />
|
||||||
|
</ElButton>
|
||||||
|
</ElRow>
|
||||||
|
</div>
|
||||||
|
<div v-else class="w-full">
|
||||||
|
<ElRow justify="center">
|
||||||
|
<ElCol :span="24" class="text-center">
|
||||||
|
<ElButton type="success" @click="showNewsDialog = true">
|
||||||
|
素材库选择
|
||||||
|
<IconifyIcon icon="ep:circle-check" />
|
||||||
</ElButton>
|
</ElButton>
|
||||||
</ElRow>
|
</ElCol>
|
||||||
</div>
|
</ElRow>
|
||||||
<div v-else>
|
</div>
|
||||||
<ElRow justify="center">
|
<ElDialog
|
||||||
<ElCol :span="24" style="text-align: center">
|
title="选择图文"
|
||||||
<ElButton type="success" @click="showNewsDialog = true">
|
v-model="showNewsDialog"
|
||||||
素材库选择
|
width="80%"
|
||||||
<IconifyIcon icon="ep:circle-check" />
|
destroy-on-close
|
||||||
</ElButton>
|
>
|
||||||
</ElCol>
|
<MaterialSelect
|
||||||
</ElRow>
|
type="news"
|
||||||
</div>
|
:account-id="props.accountId"
|
||||||
<ElDialog
|
@select-material="selectMaterial"
|
||||||
title="选择图文"
|
/>
|
||||||
v-model="showNewsDialog"
|
</ElDialog>
|
||||||
width="80%"
|
</ElRow>
|
||||||
destroy-on-close
|
</div>
|
||||||
>
|
<div
|
||||||
<WxMaterialSelect
|
class="rounded bg-white px-3 py-5 shadow-sm"
|
||||||
type="news"
|
v-if="menu.type === 'click' || menu.type === 'scancode_waitmsg'"
|
||||||
:account-id="props.accountId"
|
>
|
||||||
@select-material="selectMaterial"
|
<ReplySelect v-model="menu.reply" />
|
||||||
/>
|
|
||||||
</ElDialog>
|
|
||||||
</ElRow>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="configur-content"
|
|
||||||
v-if="menu.type === 'click' || menu.type === 'scancode_waitmsg'"
|
|
||||||
>
|
|
||||||
<WxReplySelect v-if="hackResetWxReplySelect" v-model="menu.reply" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.el-input {
|
|
||||||
width: 70%;
|
|
||||||
margin-right: 2%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.configure-page {
|
|
||||||
.delete-btn {
|
|
||||||
margin-bottom: 15px;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-content {
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.configur-content {
|
|
||||||
padding: 20px 10px;
|
|
||||||
margin-top: 20px;
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 5px;
|
|
||||||
|
|
||||||
.select-item {
|
|
||||||
width: 280px;
|
|
||||||
padding: 10px;
|
|
||||||
margin: 0 auto 10px;
|
|
||||||
border: 1px solid #eaeaea;
|
|
||||||
|
|
||||||
.ope-row {
|
|
||||||
padding-top: 10px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.blue {
|
|
||||||
margin-top: 10px;
|
|
||||||
color: #29b6f6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.applet {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
|
|
||||||
span {
|
|
||||||
width: 20%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-width {
|
|
||||||
width: 40%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.material {
|
|
||||||
.input-width {
|
|
||||||
width: 30%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-textarea {
|
|
||||||
width: 80%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -127,17 +127,26 @@ function onChildDragEnd({ newIndex }: { newIndex: number }) {
|
|||||||
@end="onParentDragEnd"
|
@end="onParentDragEnd"
|
||||||
>
|
>
|
||||||
<template #item="{ element: parent, index: x }">
|
<template #item="{ element: parent, index: x }">
|
||||||
<div class="menu-bottom">
|
<div
|
||||||
|
class="relative float-left box-border block w-[85.5px] cursor-pointer border border-[#ebedee] bg-white text-center"
|
||||||
|
>
|
||||||
<!-- 一级菜单 -->
|
<!-- 一级菜单 -->
|
||||||
<div
|
<div
|
||||||
|
class="flex h-11 w-full items-center justify-center border leading-[44px]"
|
||||||
|
:class="
|
||||||
|
props.activeIndex === `${x}`
|
||||||
|
? 'border-[#2bb673]'
|
||||||
|
: 'border-transparent'
|
||||||
|
"
|
||||||
@click="menuClicked(parent, x)"
|
@click="menuClicked(parent, x)"
|
||||||
class="menu-item"
|
|
||||||
:class="{ active: props.activeIndex === `${x}` }"
|
|
||||||
>
|
>
|
||||||
<IconifyIcon icon="ep:fold" color="black" />{{ parent.name }}
|
<IconifyIcon icon="ep:fold" color="black" />{{ parent.name }}
|
||||||
</div>
|
</div>
|
||||||
<!-- 以下为二级菜单-->
|
<!-- 以下为二级菜单-->
|
||||||
<div class="submenu" v-if="props.parentIndex === x && parent.children">
|
<div
|
||||||
|
class="absolute bottom-[45px] w-[85.5px]"
|
||||||
|
v-if="props.parentIndex === x && parent.children"
|
||||||
|
>
|
||||||
<draggable
|
<draggable
|
||||||
v-model="parent.children"
|
v-model="parent.children"
|
||||||
item-key="id"
|
item-key="id"
|
||||||
@@ -146,11 +155,17 @@ function onChildDragEnd({ newIndex }: { newIndex: number }) {
|
|||||||
@end="onChildDragEnd"
|
@end="onChildDragEnd"
|
||||||
>
|
>
|
||||||
<template #item="{ element: child, index: y }">
|
<template #item="{ element: child, index: y }">
|
||||||
<div class="menu-bottom subtitle">
|
<div
|
||||||
|
class="relative float-left box-border block w-[85.5px] border border-[#ebedee] bg-white text-center"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="menu-sub-item"
|
class="box-border h-11 border leading-[44px]"
|
||||||
|
:class="
|
||||||
|
props.activeIndex === `${x}-${y}`
|
||||||
|
? 'border-[#2bb673]'
|
||||||
|
: 'border-transparent'
|
||||||
|
"
|
||||||
v-if="parent.children"
|
v-if="parent.children"
|
||||||
:class="{ active: props.activeIndex === `${x}-${y}` }"
|
|
||||||
@click="subMenuClicked(child, x, y)"
|
@click="subMenuClicked(child, x, y)"
|
||||||
>
|
>
|
||||||
{{ child.name }}
|
{{ child.name }}
|
||||||
@@ -160,11 +175,11 @@ function onChildDragEnd({ newIndex }: { newIndex: number }) {
|
|||||||
</draggable>
|
</draggable>
|
||||||
<!-- 二级菜单加号, 当长度 小于 5 才显示二级菜单的加号 -->
|
<!-- 二级菜单加号, 当长度 小于 5 才显示二级菜单的加号 -->
|
||||||
<div
|
<div
|
||||||
class="menu-bottom menu-addicon"
|
class="relative float-left box-border flex h-[46px] w-[85.5px] cursor-pointer items-center justify-center border border-[#ebedee] bg-white text-center"
|
||||||
v-if="!parent.children || parent.children.length < 5"
|
v-if="!parent.children || parent.children.length < 5"
|
||||||
@click="addSubMenu(x, parent)"
|
@click="addSubMenu(x, parent)"
|
||||||
>
|
>
|
||||||
<IconifyIcon icon="ep:plus" class="plus" />
|
<IconifyIcon icon="ep:plus" class="" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -173,80 +188,15 @@ function onChildDragEnd({ newIndex }: { newIndex: number }) {
|
|||||||
|
|
||||||
<!-- 一级菜单加号 -->
|
<!-- 一级菜单加号 -->
|
||||||
<div
|
<div
|
||||||
class="menu-bottom menu-addicon"
|
class="relative float-left box-border flex h-[46px] w-[85.5px] cursor-pointer items-center justify-center border border-[#ebedee] bg-white text-center"
|
||||||
v-if="menuList.length < 3"
|
v-if="menuList.length < 3"
|
||||||
@click="addMenu"
|
@click="addMenu"
|
||||||
>
|
>
|
||||||
<IconifyIcon icon="ep:plus" class="plus" />
|
<IconifyIcon icon="ep:plus" class="" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.menu-bottom {
|
|
||||||
position: relative;
|
|
||||||
float: left;
|
|
||||||
box-sizing: border-box;
|
|
||||||
display: block;
|
|
||||||
width: 85.5px;
|
|
||||||
text-align: center;
|
|
||||||
cursor: pointer;
|
|
||||||
background-color: #fff;
|
|
||||||
border: 1px solid #ebedee;
|
|
||||||
|
|
||||||
&.menu-addicon {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 46px;
|
|
||||||
line-height: 46px;
|
|
||||||
|
|
||||||
.plus {
|
|
||||||
color: #2bb673;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-item {
|
|
||||||
// text-align: center;
|
|
||||||
box-sizing: border-box;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 44px;
|
|
||||||
line-height: 44px;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
border: 1px solid #2bb673;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-sub-item {
|
|
||||||
box-sizing: border-box;
|
|
||||||
height: 44px;
|
|
||||||
line-height: 44px;
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
border: 1px solid #2bb673;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 第二级菜单 */
|
|
||||||
.submenu {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 45px;
|
|
||||||
width: 85.5px;
|
|
||||||
|
|
||||||
.subtitle {
|
|
||||||
box-sizing: border-box;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.draggable-ghost {
|
.draggable-ghost {
|
||||||
background: #f7fafc;
|
@apply border border-[#4299e1] bg-[#f7fafc] opacity-50;
|
||||||
border: 1px solid #4299e1;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './main.vue';
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './main.vue';
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export { default } from './main.vue';
|
|
||||||
|
|
||||||
export { MsgType } from './types';
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
<!--
|
|
||||||
- Copyright (C) 2018-2019
|
|
||||||
- All rights reserved, Designed By www.joolun.com
|
|
||||||
芋道源码:
|
|
||||||
① 移除暂时用不到的 websocket
|
|
||||||
② 代码优化,补充注释,提升阅读性
|
|
||||||
-->
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import type { User } from './types';
|
|
||||||
|
|
||||||
import type { Reply } from '#/views/mp/modules/wx-reply';
|
|
||||||
|
|
||||||
import { nextTick, onMounted, reactive, ref, unref } from 'vue';
|
|
||||||
|
|
||||||
import { ElMessage } from 'element-plus';
|
|
||||||
|
|
||||||
import { getMessagePage, sendMessage } from '#/api/mp/message';
|
|
||||||
import { getUser } from '#/api/mp/user';
|
|
||||||
import profile from '#/assets/imgs/profile.jpg';
|
|
||||||
import WxReplySelect, { ReplyType } from '#/views/mp/modules/wx-reply';
|
|
||||||
|
|
||||||
import MsgList from './modules/msg-list.vue';
|
|
||||||
|
|
||||||
defineOptions({ name: 'WxMsg' });
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
userId: {
|
|
||||||
type: Number,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const message = ElMessage; // 消息弹窗
|
|
||||||
const accountId = ref(-1); // 公众号ID,需要通过userId初始化
|
|
||||||
const loading = ref(false); // 消息列表是否正在加载中
|
|
||||||
const hasMore = ref(true); // 是否可以加载更多
|
|
||||||
const list = ref<any[]>([]); // 消息列表
|
|
||||||
const queryParams = reactive({
|
|
||||||
pageNo: 1, // 当前页数
|
|
||||||
pageSize: 14, // 每页显示多少条
|
|
||||||
accountId,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 由于微信不再提供昵称,直接使用"用户"展示
|
|
||||||
const user: User = reactive({
|
|
||||||
nickname: '用户',
|
|
||||||
avatar: profile,
|
|
||||||
accountId, // 公众号账号编号
|
|
||||||
});
|
|
||||||
|
|
||||||
// ========= 消息发送 =========
|
|
||||||
const sendLoading = ref(false); // 发送消息是否加载中
|
|
||||||
// 微信发送消息
|
|
||||||
const reply = ref<Reply>({
|
|
||||||
type: ReplyType.Text,
|
|
||||||
accountId: -1,
|
|
||||||
articles: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const replySelectRef = ref<InstanceType<typeof WxReplySelect> | null>(null); // WxReplySelect组件ref,用于消息发送成功后清除内容
|
|
||||||
const msgDivRef = ref<HTMLDivElement | null>(null); // 消息显示窗口ref,用于滚动到底部
|
|
||||||
|
|
||||||
/** 完成加载 */
|
|
||||||
onMounted(async () => {
|
|
||||||
const data = await getUser(props.userId);
|
|
||||||
user.nickname = data.nickname?.length > 0 ? data.nickname : user.nickname;
|
|
||||||
// API 返回的数据可能包含 headImageUrl,但类型定义中没有,使用类型断言
|
|
||||||
const userData = data as typeof data & { headImageUrl?: string };
|
|
||||||
user.avatar =
|
|
||||||
userData.headImageUrl && userData.headImageUrl.length > 0
|
|
||||||
? userData.headImageUrl
|
|
||||||
: user.avatar;
|
|
||||||
accountId.value = data.accountId;
|
|
||||||
reply.value.accountId = data.accountId;
|
|
||||||
|
|
||||||
refreshChange();
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 执行发送 */
|
|
||||||
async function sendMsg() {
|
|
||||||
if (!unref(reply)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 公众号限制:客服消息,公众号只允许发送一条
|
|
||||||
if (
|
|
||||||
reply.value.type === ReplyType.News &&
|
|
||||||
reply.value.articles &&
|
|
||||||
reply.value.articles.length > 1
|
|
||||||
) {
|
|
||||||
reply.value.articles = [reply.value.articles[0]];
|
|
||||||
message.success('图文消息条数限制在 1 条以内,已默认发送第一条');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 注意:sendMessage API 需要 openid,但这里传入的是 userId
|
|
||||||
// 这可能是后端 API 的特殊处理,使用类型断言绕过类型检查
|
|
||||||
const data = await sendMessage({
|
|
||||||
userId: props.userId,
|
|
||||||
...reply.value,
|
|
||||||
} as any);
|
|
||||||
sendLoading.value = false;
|
|
||||||
|
|
||||||
list.value = [...list.value, data];
|
|
||||||
await scrollToBottom();
|
|
||||||
|
|
||||||
// 发送后清空数据
|
|
||||||
replySelectRef.value?.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 加载更多 */
|
|
||||||
function loadMore() {
|
|
||||||
queryParams.pageNo++;
|
|
||||||
getPage(queryParams, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获取分页数据 */
|
|
||||||
async function getPage(page: any, params: any = null) {
|
|
||||||
loading.value = true;
|
|
||||||
const dataTemp = await getMessagePage(
|
|
||||||
Object.assign(
|
|
||||||
{
|
|
||||||
pageNo: page.pageNo,
|
|
||||||
pageSize: page.pageSize,
|
|
||||||
userId: props.userId,
|
|
||||||
accountId: page.accountId,
|
|
||||||
},
|
|
||||||
params,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
const scrollHeight = msgDivRef.value?.scrollHeight ?? 0;
|
|
||||||
// 处理数据
|
|
||||||
const data = dataTemp.list.reverse();
|
|
||||||
list.value = [...data, ...list.value];
|
|
||||||
loading.value = false;
|
|
||||||
if (data.length < queryParams.pageSize || data.length === 0) {
|
|
||||||
hasMore.value = false;
|
|
||||||
}
|
|
||||||
queryParams.pageNo = page.pageNo;
|
|
||||||
queryParams.pageSize = page.pageSize;
|
|
||||||
// 滚动到原来的位置
|
|
||||||
if (queryParams.pageNo === 1) {
|
|
||||||
// 定位到消息底部
|
|
||||||
await scrollToBottom();
|
|
||||||
} else if (data.length > 0) {
|
|
||||||
// 定位滚动条
|
|
||||||
await nextTick();
|
|
||||||
if (scrollHeight !== 0 && msgDivRef.value) {
|
|
||||||
msgDivRef.value.scrollTop =
|
|
||||||
msgDivRef.value.scrollHeight - scrollHeight - 100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 刷新消息 */
|
|
||||||
function refreshChange() {
|
|
||||||
getPage(queryParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 定位到消息底部 */
|
|
||||||
async function scrollToBottom() {
|
|
||||||
await nextTick();
|
|
||||||
if (msgDivRef.value) {
|
|
||||||
msgDivRef.value.scrollTop = msgDivRef.value.scrollHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<ContentWrap>
|
|
||||||
<div
|
|
||||||
class="ml-[10px] mr-[10px] h-[50vh] overflow-auto bg-[#eaeaea]"
|
|
||||||
ref="msgDivRef"
|
|
||||||
>
|
|
||||||
<!-- 加载更多 -->
|
|
||||||
<div v-loading="loading"></div>
|
|
||||||
<div v-if="!loading">
|
|
||||||
<div
|
|
||||||
class="cursor-pointer py-5 text-center"
|
|
||||||
v-if="hasMore"
|
|
||||||
@click="loadMore"
|
|
||||||
>
|
|
||||||
<span class="text-[#999]">点击加载更多</span>
|
|
||||||
</div>
|
|
||||||
<div class="py-5 text-center" v-if="!hasMore">
|
|
||||||
<span class="text-[#999]">没有更多了</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 消息列表 -->
|
|
||||||
<MsgList :list="list" :account-id="accountId" :user="user" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="p-[10px]" v-loading="sendLoading">
|
|
||||||
<WxReplySelect ref="replySelectRef" v-model="reply" />
|
|
||||||
<el-button type="success" class="float-right mb-2 mt-2" @click="sendMsg">
|
|
||||||
发送(S)
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</ContentWrap>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './main.vue';
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './main.vue';
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
export { default } from './main.vue';
|
|
||||||
|
|
||||||
export {
|
|
||||||
createEmptyReply,
|
|
||||||
NewsType,
|
|
||||||
type Reply,
|
|
||||||
ReplyType,
|
|
||||||
} from './modules/types';
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './main.vue';
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './main.vue';
|
|
||||||
Reference in New Issue
Block a user