|
@@ -1,40 +1,37 @@
|
|
<template>
|
|
<template>
|
|
- <div class="app-container">
|
|
|
|
- <doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
|
|
|
|
-
|
|
|
|
- <!-- 搜索工作栏 -->
|
|
|
|
- <el-form :model="queryParams" ref="queryFormRef" size="small" :inline="true" label-width="68px">
|
|
|
|
|
|
+ <doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
|
|
|
|
+
|
|
|
|
+ <!-- 搜索工作栏 -->
|
|
|
|
+ <ContentWrap>
|
|
|
|
+ <el-form
|
|
|
|
+ class="-mb-15px"
|
|
|
|
+ :model="queryParams"
|
|
|
|
+ ref="queryFormRef"
|
|
|
|
+ :inline="true"
|
|
|
|
+ label-width="68px"
|
|
|
|
+ >
|
|
<el-form-item label="公众号" prop="accountId">
|
|
<el-form-item label="公众号" prop="accountId">
|
|
<el-select v-model="queryParams.accountId" placeholder="请选择公众号">
|
|
<el-select v-model="queryParams.accountId" placeholder="请选择公众号">
|
|
<el-option
|
|
<el-option
|
|
v-for="item in accountList"
|
|
v-for="item in accountList"
|
|
- :key="parseInt(item.id)"
|
|
|
|
|
|
+ :key="item.id"
|
|
:label="item.name"
|
|
:label="item.name"
|
|
- :value="parseInt(item.id)"
|
|
|
|
|
|
+ :value="item.id"
|
|
/>
|
|
/>
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-form-item>
|
|
- <el-button type="primary" @click="handleQuery"><Icon icon="ep:search" />搜索</el-button>
|
|
|
|
|
|
+ <el-button @click="handleQuery"><Icon icon="ep:search" />搜索</el-button>
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" />重置</el-button>
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" />重置</el-button>
|
|
|
|
+ <el-button type="primary" plain @click="handleAdd" v-hasPermi="['mp:draft:create']">
|
|
|
|
+ <Icon icon="ep:plus" />新增
|
|
|
|
+ </el-button>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
|
|
+ </ContentWrap>
|
|
|
|
|
|
- <!-- 操作工具栏 -->
|
|
|
|
- <el-row :gutter="10" class="mb8">
|
|
|
|
- <el-col :span="1.5">
|
|
|
|
- <el-button
|
|
|
|
- type="primary"
|
|
|
|
- plain
|
|
|
|
- size="small"
|
|
|
|
- @click="handleAdd"
|
|
|
|
- v-hasPermi="['mp:draft:create']"
|
|
|
|
- ><Icon icon="ep:plus" />新增
|
|
|
|
- </el-button>
|
|
|
|
- </el-col>
|
|
|
|
- </el-row>
|
|
|
|
-
|
|
|
|
- <!-- 列表 -->
|
|
|
|
|
|
+ <!-- 列表 -->
|
|
|
|
+ <ContentWrap>
|
|
<div class="waterfall" v-loading="loading">
|
|
<div class="waterfall" v-loading="loading">
|
|
<template v-for="item in list" :key="item.articleId">
|
|
<template v-for="item in list" :key="item.articleId">
|
|
<div class="waterfall-item" v-if="item.content && item.content.newsItem">
|
|
<div class="waterfall-item" v-if="item.content && item.content.newsItem">
|
|
@@ -46,35 +43,40 @@
|
|
circle
|
|
circle
|
|
@click="handlePublish(item)"
|
|
@click="handlePublish(item)"
|
|
v-hasPermi="['mp:free-publish:submit']"
|
|
v-hasPermi="['mp:free-publish:submit']"
|
|
- ><Icon icon="fa:upload"
|
|
|
|
- /></el-button>
|
|
|
|
|
|
+ >
|
|
|
|
+ <Icon icon="fa:upload" />
|
|
|
|
+ </el-button>
|
|
<el-button
|
|
<el-button
|
|
type="primary"
|
|
type="primary"
|
|
circle
|
|
circle
|
|
@click="handleUpdate(item)"
|
|
@click="handleUpdate(item)"
|
|
v-hasPermi="['mp:draft:update']"
|
|
v-hasPermi="['mp:draft:update']"
|
|
- ><Icon icon="ep:edit"
|
|
|
|
- /></el-button>
|
|
|
|
|
|
+ >
|
|
|
|
+ <Icon icon="ep:edit" />
|
|
|
|
+ </el-button>
|
|
<el-button
|
|
<el-button
|
|
type="danger"
|
|
type="danger"
|
|
circle
|
|
circle
|
|
@click="handleDelete(item)"
|
|
@click="handleDelete(item)"
|
|
v-hasPermi="['mp:draft:delete']"
|
|
v-hasPermi="['mp:draft:delete']"
|
|
- ><Icon icon="ep:delete"
|
|
|
|
- /></el-button>
|
|
|
|
|
|
+ >
|
|
|
|
+ <Icon icon="ep:delete" />
|
|
|
|
+ </el-button>
|
|
</el-row>
|
|
</el-row>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
<!-- 分页记录 -->
|
|
<!-- 分页记录 -->
|
|
- <pagination
|
|
|
|
- v-show="total > 0"
|
|
|
|
|
|
+ <Pagination
|
|
:total="total"
|
|
:total="total"
|
|
v-model:page="queryParams.pageNo"
|
|
v-model:page="queryParams.pageNo"
|
|
v-model:limit="queryParams.pageSize"
|
|
v-model:limit="queryParams.pageSize"
|
|
@pagination="getList"
|
|
@pagination="getList"
|
|
/>
|
|
/>
|
|
|
|
+ </ContentWrap>
|
|
|
|
|
|
|
|
+ <!-- TODO @Dhb52:迁移成独立路由 -->
|
|
|
|
+ <div class="app-container">
|
|
<!-- 添加或修改草稿对话框 -->
|
|
<!-- 添加或修改草稿对话框 -->
|
|
<Teleport to="body">
|
|
<Teleport to="body">
|
|
<el-dialog
|
|
<el-dialog
|
|
@@ -245,49 +247,39 @@
|
|
</el-row>
|
|
</el-row>
|
|
</div>
|
|
</div>
|
|
<template #footer>
|
|
<template #footer>
|
|
- <div class="dialog-footer">
|
|
|
|
- <el-button @click="dialogNewsVisible = false">取 消</el-button>
|
|
|
|
- <el-button type="primary" @click="submitForm">提 交</el-button>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <el-button @click="dialogNewsVisible = false">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="submitForm">提 交</el-button>
|
|
</template>
|
|
</template>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
</Teleport>
|
|
</Teleport>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
-
|
|
|
|
<script setup name="MpDraft">
|
|
<script setup name="MpDraft">
|
|
-import { ref, onMounted, reactive, nextTick } from 'vue'
|
|
|
|
import WxEditor from '@/views/mp/components/wx-editor/WxEditor.vue'
|
|
import WxEditor from '@/views/mp/components/wx-editor/WxEditor.vue'
|
|
import WxNews from '@/views/mp/components/wx-news/main.vue'
|
|
import WxNews from '@/views/mp/components/wx-news/main.vue'
|
|
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
|
|
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
|
|
import { getAccessToken } from '@/utils/auth'
|
|
import { getAccessToken } from '@/utils/auth'
|
|
-import { createDraft, deleteDraft, getDraftPage, updateDraft } from '@/api/mp/draft'
|
|
|
|
-import { getSimpleAccountList } from '@/api/mp/account'
|
|
|
|
-import { submitFreePublish } from '@/api/mp/freePublish'
|
|
|
|
|
|
+import * as MpAccountApi from '@/api/mp/account'
|
|
|
|
+import * as MpDraftApi from '@/api/mp/draft'
|
|
|
|
+import * as MpFreePublishApi from '@/api/mp/freePublish'
|
|
|
|
+const message = useMessage() // 消息
|
|
// 可以用改本地数据模拟,避免API调用超限
|
|
// 可以用改本地数据模拟,避免API调用超限
|
|
// import drafts from './mock'
|
|
// import drafts from './mock'
|
|
|
|
|
|
-const BASE_URL = import.meta.env.VITE_BASE_URL
|
|
|
|
-
|
|
|
|
-const message = useMessage()
|
|
|
|
-
|
|
|
|
-const materialSelectRef = ref()
|
|
|
|
-const queryFormRef = ref()
|
|
|
|
-
|
|
|
|
-// 遮罩层
|
|
|
|
-const loading = ref(false)
|
|
|
|
-// 显示搜索条件
|
|
|
|
-// 总条数
|
|
|
|
-const total = ref(0)
|
|
|
|
-// 数据列表
|
|
|
|
-const list = ref([])
|
|
|
|
|
|
+const loading = ref(true) // 列表的加载中
|
|
|
|
+const total = ref(0) // 列表的总页数
|
|
|
|
+const list = ref([]) // 列表的数据
|
|
const queryParams = reactive({
|
|
const queryParams = reactive({
|
|
pageNo: 1,
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
accountId: undefined
|
|
accountId: undefined
|
|
})
|
|
})
|
|
|
|
+const queryFormRef = ref() // 搜索的表单
|
|
|
|
+const accountList = ref([]) // 公众号账号列表
|
|
|
|
|
|
// ========== 文件上传 ==========
|
|
// ========== 文件上传 ==========
|
|
|
|
+const materialSelectRef = ref()
|
|
|
|
+const BASE_URL = import.meta.env.VITE_BASE_URL
|
|
const actionUrl = ref(BASE_URL + '/admin-api/mp/material/upload-permanent') // 上传永久素材的地址
|
|
const actionUrl = ref(BASE_URL + '/admin-api/mp/material/upload-permanent') // 上传永久素材的地址
|
|
const headers = ref({ Authorization: 'Bearer ' + getAccessToken() }) // 设置上传的请求头部
|
|
const headers = ref({ Authorization: 'Bearer ' + getAccessToken() }) // 设置上传的请求头部
|
|
const fileList = ref([])
|
|
const fileList = ref([])
|
|
@@ -305,11 +297,10 @@ const dialogImageVisible = ref(false)
|
|
const operateMaterial = ref('add')
|
|
const operateMaterial = ref('add')
|
|
const articlesMediaId = ref('')
|
|
const articlesMediaId = ref('')
|
|
const hackResetEditor = ref(false)
|
|
const hackResetEditor = ref(false)
|
|
-// 公众号账号列表
|
|
|
|
-const accountList = ref([])
|
|
|
|
|
|
|
|
|
|
+/** 初始化 **/
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
- accountList.value = await getSimpleAccountList()
|
|
|
|
|
|
+ accountList.value = await MpAccountApi.getSimpleAccountList()
|
|
// 选中第一个
|
|
// 选中第一个
|
|
if (accountList.value.length > 0) {
|
|
if (accountList.value.length > 0) {
|
|
// @ts-ignore
|
|
// @ts-ignore
|
|
@@ -335,7 +326,7 @@ const getList = async () => {
|
|
|
|
|
|
loading.value = true
|
|
loading.value = true
|
|
try {
|
|
try {
|
|
- const drafts = await getDraftPage(queryParams)
|
|
|
|
|
|
+ const drafts = await MpDraftApi.getDraftPage(queryParams)
|
|
drafts.list.forEach((item) => {
|
|
drafts.list.forEach((item) => {
|
|
const newsItem = item.content.newsItem
|
|
const newsItem = item.content.newsItem
|
|
// 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面
|
|
// 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面
|
|
@@ -393,9 +384,10 @@ const handleUpdate = (item) => {
|
|
|
|
|
|
/** 提交按钮 */
|
|
/** 提交按钮 */
|
|
const submitForm = () => {
|
|
const submitForm = () => {
|
|
|
|
+ // TODO @Dhb52: 参考别的模块写法,改成 await 方式
|
|
addMaterialLoading.value = true
|
|
addMaterialLoading.value = true
|
|
if (operateMaterial.value === 'add') {
|
|
if (operateMaterial.value === 'add') {
|
|
- createDraft(queryParams.accountId, articlesAdd.value)
|
|
|
|
|
|
+ MpDraftApi.createDraft(queryParams.accountId, articlesAdd.value)
|
|
.then(() => {
|
|
.then(() => {
|
|
message.notifySuccess('新增成功')
|
|
message.notifySuccess('新增成功')
|
|
dialogNewsVisible.value = false
|
|
dialogNewsVisible.value = false
|
|
@@ -405,7 +397,7 @@ const submitForm = () => {
|
|
addMaterialLoading.value = false
|
|
addMaterialLoading.value = false
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
- updateDraft(queryParams.accountId, articlesMediaId.value, articlesAdd.value)
|
|
|
|
|
|
+ MpDraftApi.updateDraft(queryParams.accountId, articlesMediaId.value, articlesAdd.value)
|
|
.then(() => {
|
|
.then(() => {
|
|
message.notifySuccess('更新成功')
|
|
message.notifySuccess('更新成功')
|
|
dialogNewsVisible.value = false
|
|
dialogNewsVisible.value = false
|
|
@@ -559,24 +551,24 @@ const handlePublish = async (item) => {
|
|
'你正在通过发布的方式发表内容。 发布不占用群发次数,一天可多次发布。已发布内容不会推送给用户,也不会展示在公众号主页中。 发布后,你可以前往发表记录获取链接,也可以将发布内容添加到自定义菜单、自动回复、话题和页面模板中。'
|
|
'你正在通过发布的方式发表内容。 发布不占用群发次数,一天可多次发布。已发布内容不会推送给用户,也不会展示在公众号主页中。 发布后,你可以前往发表记录获取链接,也可以将发布内容添加到自定义菜单、自动回复、话题和页面模板中。'
|
|
try {
|
|
try {
|
|
await message.confirm(content)
|
|
await message.confirm(content)
|
|
- await submitFreePublish(accountId, mediaId)
|
|
|
|
- getList()
|
|
|
|
|
|
+ await MpFreePublishApi.submitFreePublish(accountId, mediaId)
|
|
message.notifySuccess('发布成功')
|
|
message.notifySuccess('发布成功')
|
|
|
|
+ await getList()
|
|
} catch {}
|
|
} catch {}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/** 删除按钮操作 */
|
|
const handleDelete = async (item) => {
|
|
const handleDelete = async (item) => {
|
|
const accountId = queryParams.accountId
|
|
const accountId = queryParams.accountId
|
|
const mediaId = item.mediaId
|
|
const mediaId = item.mediaId
|
|
try {
|
|
try {
|
|
await message.confirm('此操作将永久删除该草稿, 是否继续?')
|
|
await message.confirm('此操作将永久删除该草稿, 是否继续?')
|
|
- await deleteDraft(accountId, mediaId)
|
|
|
|
- getList()
|
|
|
|
|
|
+ await MpDraftApi.deleteDraft(accountId, mediaId)
|
|
message.notifySuccess('删除成功')
|
|
message.notifySuccess('删除成功')
|
|
|
|
+ await getList()
|
|
} catch {}
|
|
} catch {}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
-
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
.pagination {
|
|
.pagination {
|
|
float: right;
|
|
float: right;
|