REVIEW 公众号的草稿箱

(cherry picked from commit f7fe794944)
This commit is contained in:
YunaiV 2023-04-08 20:28:33 +08:00 committed by shizhong
parent e7c5824f70
commit 35d3262924
2 changed files with 69 additions and 82 deletions

View File

@ -13,15 +13,14 @@
<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"> <el-row class="ope-row">
<el-button type="success" @click="selectMaterialFun(item)" <el-button type="success" @click="selectMaterialFun(item)">
>选择 <Icon icon="ep:circle-check" /> 选择 <Icon icon="ep:circle-check" />
</el-button> </el-button>
</el-row> </el-row>
</div> </div>
</div> </div>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination <Pagination
v-show="total > 0"
:total="total" :total="total"
v-model:page="queryParams.pageNo" v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
@ -39,27 +38,23 @@
<WxVoicePlayer :url="scope.row.url" /> <WxVoicePlayer :url="scope.row.url" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="上传时间" align="center" prop="createTime" width="180">
<template #default="scope">
<span>{{ formatDate(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column <el-table-column
label="操作" label="上传时间"
align="center" align="center"
fixed="right" prop="createTime"
class-name="small-padding fixed-width" width="180"
> :formatter="dateFormatter"
/>
<el-table-column label="操作" align="center" fixed="right">
<template #default="scope"> <template #default="scope">
<el-button type="text" @click="selectMaterialFun(scope.row)" <el-button type="text" @click="selectMaterialFun(scope.row)">
>选择<Icon icon="ep:plus" /> 选择<Icon icon="ep:plus" />
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination <Pagination
v-show="total > 0"
:total="total" :total="total"
v-model:page="queryParams.pageNo" v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
@ -79,11 +74,13 @@
<WxVideoPlayer :url="scope.row.url" /> <WxVideoPlayer :url="scope.row.url" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="上传时间" align="center" prop="createTime" width="180"> <el-table-column
<template #default="scope"> label="上传时间"
<span>{{ formatDate(scope.row.createTime) }}</span> align="center"
</template> prop="createTime"
</el-table-column> width="180"
:formatter="dateFormatter"
/>
<el-table-column <el-table-column
label="操作" label="操作"
align="center" align="center"
@ -91,15 +88,14 @@
class-name="small-padding fixed-width" class-name="small-padding fixed-width"
> >
<template #default="scope"> <template #default="scope">
<el-button type="text" @click="selectMaterialFun(scope.row)" <el-button type="text" @click="selectMaterialFun(scope.row)">
>选择<Icon icon="akar-icons:circle-plus" /> 选择<Icon icon="akar-icons:circle-plus" />
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination <Pagination
v-show="total > 0"
:total="total" :total="total"
v-model:page="queryParams.pageNo" v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
@ -121,8 +117,7 @@
</div> </div>
</div> </div>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination <Pagination
v-show="total > 0"
:total="total" :total="total"
v-model:page="queryParams.pageNo" v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize" v-model:limit="queryParams.pageSize"
@ -139,7 +134,7 @@ import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
import { getMaterialPage } from '@/api/mp/material' import { getMaterialPage } from '@/api/mp/material'
import { getFreePublishPage } from '@/api/mp/freePublish' import { getFreePublishPage } from '@/api/mp/freePublish'
import { getDraftPage } from '@/api/mp/draft' import { getDraftPage } from '@/api/mp/draft'
import { dateFormatter, formatDate } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import { defineComponent, PropType } from 'vue' import { defineComponent, PropType } from 'vue'
export default defineComponent({ export default defineComponent({
@ -244,7 +239,6 @@ export default defineComponent({
getMaterialPageFun, getMaterialPageFun,
getPage, getPage,
formatDate, formatDate,
newsTypeRef,
queryParams, queryParams,
objDataRef, objDataRef,
list, list,
@ -254,7 +248,6 @@ export default defineComponent({
} }
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/*瀑布流样式*/ /*瀑布流样式*/
.waterfall { .waterfall {

View File

@ -1,40 +1,37 @@
<template> <template>
<div class="app-container">
<doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" /> <doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryFormRef" size="small" :inline="true" label-width="68px"> <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 <Pagination
v-show="total > 0"
: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
@ -254,9 +256,7 @@
</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'
@ -264,30 +264,24 @@ import { getAccessToken } from '@/utils/auth'
import { createDraft, deleteDraft, getDraftPage, updateDraft } from '@/api/mp/draft' import { createDraft, deleteDraft, getDraftPage, updateDraft } from '@/api/mp/draft'
import { getSimpleAccountList } from '@/api/mp/account' import { getSimpleAccountList } from '@/api/mp/account'
import { submitFreePublish } from '@/api/mp/freePublish' import { submitFreePublish } 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 loading = ref(true) //
const total = ref(0) //
const message = useMessage() const list = ref([]) //
const materialSelectRef = ref()
const queryFormRef = ref()
//
const loading = ref(false)
//
//
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,9 +299,8 @@ 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 getSimpleAccountList()
// //
@ -393,6 +386,7 @@ 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) createDraft(queryParams.accountId, articlesAdd.value)
@ -560,23 +554,23 @@ const handlePublish = async (item) => {
try { try {
await message.confirm(content) await message.confirm(content)
await submitFreePublish(accountId, mediaId) await submitFreePublish(accountId, mediaId)
getList()
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) await deleteDraft(accountId, mediaId)
getList()
message.notifySuccess('删除成功') message.notifySuccess('删除成功')
await getList()
} catch {} } catch {}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.pagination { .pagination {
float: right; float: right;