2025-10-30 16:33:33 +08:00
|
|
|
|
<!--
|
|
|
|
|
|
- Copyright (C) 2018-2019
|
|
|
|
|
|
- All rights reserved, Designed By www.joolun.com
|
|
|
|
|
|
芋道源码:
|
|
|
|
|
|
-->
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
|
import { onMounted, reactive, ref } from 'vue';
|
|
|
|
|
|
|
2025-11-13 18:35:10 +08:00
|
|
|
|
import { IconifyIcon } from '@vben/icons';
|
2025-10-30 16:33:33 +08:00
|
|
|
|
import { formatTime } from '@vben/utils';
|
|
|
|
|
|
|
2025-11-13 18:35:10 +08:00
|
|
|
|
import {
|
|
|
|
|
|
ElButton,
|
|
|
|
|
|
ElPagination,
|
|
|
|
|
|
ElRow,
|
|
|
|
|
|
ElTable,
|
|
|
|
|
|
ElTableColumn,
|
|
|
|
|
|
} from 'element-plus';
|
|
|
|
|
|
|
2025-10-30 16:33:33 +08:00
|
|
|
|
import * as MpDraftApi from '#/api/mp/draft';
|
|
|
|
|
|
import * as MpFreePublishApi from '#/api/mp/freePublish';
|
|
|
|
|
|
import * as MpMaterialApi from '#/api/mp/material';
|
2025-11-13 18:35:10 +08:00
|
|
|
|
import News from '#/views/mp/components/news/news.vue';
|
|
|
|
|
|
import VideoPlayer from '#/views/mp/components/video-play/video-play.vue';
|
|
|
|
|
|
import VoicePlayer from '#/views/mp/components/voice-play/voice-play.vue';
|
2025-10-30 16:33:33 +08:00
|
|
|
|
|
|
|
|
|
|
import { NewsType } from './types';
|
|
|
|
|
|
|
2025-11-13 18:35:10 +08:00
|
|
|
|
defineOptions({ name: 'MaterialSelect' });
|
2025-10-30 16:33:33 +08:00
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(
|
|
|
|
|
|
defineProps<{
|
|
|
|
|
|
accountId: number;
|
|
|
|
|
|
newsType?: NewsType;
|
|
|
|
|
|
type: string;
|
|
|
|
|
|
}>(),
|
|
|
|
|
|
{
|
|
|
|
|
|
newsType: NewsType.Published,
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['selectMaterial']);
|
|
|
|
|
|
|
|
|
|
|
|
// 遮罩层
|
|
|
|
|
|
const loading = ref(false);
|
|
|
|
|
|
// 总条数
|
|
|
|
|
|
const total = ref(0);
|
|
|
|
|
|
// 数据列表
|
|
|
|
|
|
const list = ref<any[]>([]);
|
|
|
|
|
|
// 查询参数
|
|
|
|
|
|
const queryParams = reactive({
|
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
accountId: props.accountId,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-11-03 11:18:45 +08:00
|
|
|
|
/** 选择素材 */
|
|
|
|
|
|
function selectMaterialFun(item: any) {
|
2025-10-30 16:33:33 +08:00
|
|
|
|
emit('selectMaterial', item);
|
2025-11-03 11:18:45 +08:00
|
|
|
|
}
|
2025-10-30 16:33:33 +08:00
|
|
|
|
|
2025-11-03 11:18:45 +08:00
|
|
|
|
/** 获取分页数据 */
|
|
|
|
|
|
async function getPage() {
|
2025-10-30 16:33:33 +08:00
|
|
|
|
loading.value = true;
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (props.type === 'news' && props.newsType === NewsType.Published) {
|
|
|
|
|
|
// 【图文】+ 【已发布】
|
|
|
|
|
|
await getFreePublishPageFun();
|
|
|
|
|
|
} else if (props.type === 'news' && props.newsType === NewsType.Draft) {
|
|
|
|
|
|
// 【图文】+ 【草稿】
|
|
|
|
|
|
await getDraftPageFun();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 【素材】
|
|
|
|
|
|
await getMaterialPageFun();
|
|
|
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false;
|
|
|
|
|
|
}
|
2025-11-03 11:18:45 +08:00
|
|
|
|
}
|
2025-10-30 16:33:33 +08:00
|
|
|
|
|
2025-11-03 11:18:45 +08:00
|
|
|
|
/** 获取素材分页 */
|
|
|
|
|
|
async function getMaterialPageFun() {
|
2025-10-30 16:33:33 +08:00
|
|
|
|
const data = await MpMaterialApi.getMaterialPage({
|
|
|
|
|
|
...queryParams,
|
|
|
|
|
|
type: props.type,
|
|
|
|
|
|
});
|
|
|
|
|
|
list.value = data.list;
|
|
|
|
|
|
total.value = data.total;
|
2025-11-03 11:18:45 +08:00
|
|
|
|
}
|
2025-10-30 16:33:33 +08:00
|
|
|
|
|
2025-11-03 11:18:45 +08:00
|
|
|
|
/** 获取已发布图文分页 */
|
|
|
|
|
|
async function getFreePublishPageFun() {
|
2025-10-30 16:33:33 +08:00
|
|
|
|
const data = await MpFreePublishApi.getFreePublishPage(queryParams);
|
|
|
|
|
|
data.list.forEach((item: any) => {
|
|
|
|
|
|
const articles = item.content.newsItem;
|
|
|
|
|
|
articles.forEach((article: any) => {
|
|
|
|
|
|
article.picUrl = article.thumbUrl;
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
list.value = data.list;
|
|
|
|
|
|
total.value = data.total;
|
2025-11-03 11:18:45 +08:00
|
|
|
|
}
|
2025-10-30 16:33:33 +08:00
|
|
|
|
|
2025-11-03 11:18:45 +08:00
|
|
|
|
/** 获取草稿图文分页 */
|
|
|
|
|
|
async function getDraftPageFun() {
|
2025-10-30 16:33:33 +08:00
|
|
|
|
const data = await MpDraftApi.getDraftPage(queryParams);
|
|
|
|
|
|
data.list.forEach((draft: any) => {
|
|
|
|
|
|
const articles = draft.content.newsItem;
|
|
|
|
|
|
articles.forEach((article: any) => {
|
|
|
|
|
|
article.picUrl = article.thumbUrl;
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
list.value = data.list;
|
|
|
|
|
|
total.value = data.total;
|
2025-11-03 11:18:45 +08:00
|
|
|
|
}
|
2025-10-30 16:33:33 +08:00
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
getPage();
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<div class="pb-30px">
|
|
|
|
|
|
<!-- 类型:image -->
|
|
|
|
|
|
<div v-if="props.type === 'image'">
|
|
|
|
|
|
<div class="waterfall" v-loading="loading">
|
|
|
|
|
|
<div class="waterfall-item" v-for="item in list" :key="item.mediaId">
|
|
|
|
|
|
<img class="material-img" :src="item.url" />
|
|
|
|
|
|
<p class="item-name">{{ item.name }}</p>
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElRow class="ope-row">
|
|
|
|
|
|
<ElButton type="success" @click="selectMaterialFun(item)">
|
2025-10-30 16:33:33 +08:00
|
|
|
|
选择
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<IconifyIcon icon="ep:circle-check" />
|
|
|
|
|
|
</ElButton>
|
|
|
|
|
|
</ElRow>
|
2025-10-30 16:33:33 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 分页组件 -->
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElPagination
|
|
|
|
|
|
background
|
|
|
|
|
|
layout="prev, pager, next, sizes, total"
|
2025-10-30 16:33:33 +08:00
|
|
|
|
:total="total"
|
2025-11-13 18:35:10 +08:00
|
|
|
|
v-model:current-page="queryParams.pageNo"
|
|
|
|
|
|
v-model:page-size="queryParams.pageSize"
|
|
|
|
|
|
@current-change="getMaterialPageFun"
|
|
|
|
|
|
@size-change="getMaterialPageFun"
|
2025-10-30 16:33:33 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 类型:voice -->
|
|
|
|
|
|
<div v-else-if="props.type === 'voice'">
|
|
|
|
|
|
<!-- 列表 -->
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElTable v-loading="loading" :data="list">
|
|
|
|
|
|
<ElTableColumn label="编号" align="center" prop="mediaId" />
|
|
|
|
|
|
<ElTableColumn label="文件名" align="center" prop="name" />
|
|
|
|
|
|
<ElTableColumn label="语音" align="center">
|
2025-10-30 16:33:33 +08:00
|
|
|
|
<template #default="scope">
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<VoicePlayer :url="scope.row.url" />
|
2025-10-30 16:33:33 +08:00
|
|
|
|
</template>
|
2025-11-13 18:35:10 +08:00
|
|
|
|
</ElTableColumn>
|
|
|
|
|
|
<ElTableColumn
|
2025-10-30 16:33:33 +08:00
|
|
|
|
label="上传时间"
|
|
|
|
|
|
align="center"
|
|
|
|
|
|
prop="createTime"
|
|
|
|
|
|
width="180"
|
|
|
|
|
|
:formatter="
|
|
|
|
|
|
(row: any) => formatTime(row.createTime, 'YYYY-MM-DD HH:mm:ss')
|
|
|
|
|
|
"
|
|
|
|
|
|
/>
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElTableColumn label="操作" align="center" fixed="right">
|
2025-10-30 16:33:33 +08:00
|
|
|
|
<template #default="scope">
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElButton type="primary" link @click="selectMaterialFun(scope.row)">
|
2025-10-30 16:33:33 +08:00
|
|
|
|
选择
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<IconifyIcon icon="ep:plus" />
|
|
|
|
|
|
</ElButton>
|
2025-10-30 16:33:33 +08:00
|
|
|
|
</template>
|
2025-11-13 18:35:10 +08:00
|
|
|
|
</ElTableColumn>
|
|
|
|
|
|
</ElTable>
|
2025-10-30 16:33:33 +08:00
|
|
|
|
<!-- 分页组件 -->
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElPagination
|
|
|
|
|
|
background
|
|
|
|
|
|
layout="prev, pager, next, sizes, total"
|
2025-10-30 16:33:33 +08:00
|
|
|
|
:total="total"
|
2025-11-13 18:35:10 +08:00
|
|
|
|
v-model:current-page="queryParams.pageNo"
|
|
|
|
|
|
v-model:page-size="queryParams.pageSize"
|
|
|
|
|
|
@current-change="getPage"
|
|
|
|
|
|
@size-change="getPage"
|
2025-10-30 16:33:33 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 类型:video -->
|
|
|
|
|
|
<div v-else-if="props.type === 'video'">
|
|
|
|
|
|
<!-- 列表 -->
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElTable v-loading="loading" :data="list">
|
|
|
|
|
|
<ElTableColumn label="编号" align="center" prop="mediaId" />
|
|
|
|
|
|
<ElTableColumn label="文件名" align="center" prop="name" />
|
|
|
|
|
|
<ElTableColumn label="标题" align="center" prop="title" />
|
|
|
|
|
|
<ElTableColumn label="介绍" align="center" prop="introduction" />
|
|
|
|
|
|
<ElTableColumn label="视频" align="center">
|
2025-10-30 16:33:33 +08:00
|
|
|
|
<template #default="scope">
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<VideoPlayer :url="scope.row.url" />
|
2025-10-30 16:33:33 +08:00
|
|
|
|
</template>
|
2025-11-13 18:35:10 +08:00
|
|
|
|
</ElTableColumn>
|
|
|
|
|
|
<ElTableColumn
|
2025-10-30 16:33:33 +08:00
|
|
|
|
label="上传时间"
|
|
|
|
|
|
align="center"
|
|
|
|
|
|
prop="createTime"
|
|
|
|
|
|
width="180"
|
|
|
|
|
|
:formatter="
|
|
|
|
|
|
(row: any) => formatTime(row.createTime, 'YYYY-MM-DD HH:mm:ss')
|
|
|
|
|
|
"
|
|
|
|
|
|
/>
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElTableColumn
|
2025-10-30 16:33:33 +08:00
|
|
|
|
label="操作"
|
|
|
|
|
|
align="center"
|
|
|
|
|
|
fixed="right"
|
|
|
|
|
|
class-name="small-padding fixed-width"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #default="scope">
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElButton type="primary" link @click="selectMaterialFun(scope.row)">
|
2025-10-30 16:33:33 +08:00
|
|
|
|
选择
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<IconifyIcon icon="akar-icons:circle-plus" />
|
|
|
|
|
|
</ElButton>
|
2025-10-30 16:33:33 +08:00
|
|
|
|
</template>
|
2025-11-13 18:35:10 +08:00
|
|
|
|
</ElTableColumn>
|
|
|
|
|
|
</ElTable>
|
2025-10-30 16:33:33 +08:00
|
|
|
|
<!-- 分页组件 -->
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElPagination
|
|
|
|
|
|
background
|
|
|
|
|
|
layout="prev, pager, next, sizes, total"
|
2025-10-30 16:33:33 +08:00
|
|
|
|
:total="total"
|
2025-11-13 18:35:10 +08:00
|
|
|
|
v-model:current-page="queryParams.pageNo"
|
|
|
|
|
|
v-model:page-size="queryParams.pageSize"
|
|
|
|
|
|
@current-change="getMaterialPageFun"
|
|
|
|
|
|
@size-change="getMaterialPageFun"
|
2025-10-30 16:33:33 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 类型:news -->
|
|
|
|
|
|
<div v-else-if="props.type === 'news'">
|
|
|
|
|
|
<div class="waterfall" v-loading="loading">
|
|
|
|
|
|
<div class="waterfall-item" v-for="item in list" :key="item.mediaId">
|
|
|
|
|
|
<div v-if="item.content && item.content.newsItem">
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<News :articles="item.content.newsItem" />
|
|
|
|
|
|
<ElRow class="ope-row">
|
|
|
|
|
|
<ElButton type="success" @click="selectMaterialFun(item)">
|
2025-10-30 16:33:33 +08:00
|
|
|
|
选择
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<IconifyIcon icon="ep:circle-check" />
|
|
|
|
|
|
</ElButton>
|
|
|
|
|
|
</ElRow>
|
2025-10-30 16:33:33 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 分页组件 -->
|
2025-11-13 18:35:10 +08:00
|
|
|
|
<ElPagination
|
|
|
|
|
|
background
|
|
|
|
|
|
layout="prev, pager, next, sizes, total"
|
2025-10-30 16:33:33 +08:00
|
|
|
|
:total="total"
|
2025-11-13 18:35:10 +08:00
|
|
|
|
v-model:current-page="queryParams.pageNo"
|
|
|
|
|
|
v-model:page-size="queryParams.pageSize"
|
|
|
|
|
|
@current-change="getMaterialPageFun"
|
|
|
|
|
|
@size-change="getMaterialPageFun"
|
2025-10-30 16:33:33 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
@media (width >= 992px) and (width <= 1300px) {
|
|
|
|
|
|
.waterfall {
|
|
|
|
|
|
column-count: 3;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
p {
|
|
|
|
|
|
color: red;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (width >= 768px) and (width <= 991px) {
|
|
|
|
|
|
.waterfall {
|
|
|
|
|
|
column-count: 2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
p {
|
|
|
|
|
|
color: orange;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (width <= 767px) {
|
|
|
|
|
|
.waterfall {
|
|
|
|
|
|
column-count: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.waterfall {
|
|
|
|
|
|
column-gap: 10px;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
column-count: 5;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.waterfall-item {
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
border: 1px solid #eaeaea;
|
|
|
|
|
|
break-inside: avoid;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.material-img {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
p {
|
|
|
|
|
|
line-height: 30px;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|