Vue3 重构:REVIEW 图文发表记录
This commit is contained in:
parent
708aef3e10
commit
f5177337cb
@ -1,37 +1,36 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
<content-wrap>
|
<content-wrap>
|
||||||
<doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
|
|
||||||
|
|
||||||
<!-- 搜索工作栏 -->
|
|
||||||
<el-form
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
:model="queryParams"
|
:model="queryParams"
|
||||||
ref="queryFormRef"
|
ref="queryFormRef"
|
||||||
size="small"
|
|
||||||
:inline="true"
|
:inline="true"
|
||||||
v-show="showSearch"
|
|
||||||
label-width="68px"
|
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="请选择公众号" class="!w-240px">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in accounts"
|
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" :icon="Search" @click="handleQuery">搜索</el-button>
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
<el-button :icon="Refresh" @click="resetQuery">重置</el-button>
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
</content-wrap>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
|
<content-wrap>
|
||||||
<div class="waterfall" v-loading="loading">
|
<div class="waterfall" v-loading="loading">
|
||||||
<div
|
<div
|
||||||
v-show="item.content && item.content.newsItem"
|
|
||||||
class="waterfall-item"
|
class="waterfall-item"
|
||||||
|
v-show="item.content && item.content.newsItem"
|
||||||
v-for="item in list"
|
v-for="item in list"
|
||||||
:key="item.articleId"
|
:key="item.articleId"
|
||||||
>
|
>
|
||||||
@ -40,11 +39,12 @@
|
|||||||
<el-row justify="center" class="ope-row">
|
<el-row justify="center" class="ope-row">
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
:icon="Delete"
|
|
||||||
circle
|
circle
|
||||||
@click="handleDelete(item)"
|
@click="handleDelete(item)"
|
||||||
v-hasPermi="['mp:free-publish:delete']"
|
v-hasPermi="['mp:free-publish:delete']"
|
||||||
/>
|
>
|
||||||
|
<Icon icon="ep:delete" />
|
||||||
|
</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -61,25 +61,21 @@
|
|||||||
|
|
||||||
<script setup lang="ts" name="freePublish">
|
<script setup lang="ts" name="freePublish">
|
||||||
import { getFreePublishPage, deleteFreePublish } from '@/api/mp/freePublish'
|
import { getFreePublishPage, deleteFreePublish } from '@/api/mp/freePublish'
|
||||||
import { getSimpleAccounts } from '@/api/mp/account'
|
import * as MpAccountApi from '@/api/mp/account'
|
||||||
import WxNews from '@/views/mp/components/wx-news/main.vue'
|
import WxNews from '@/views/mp/components/wx-news/main.vue'
|
||||||
import { Delete, Search, Refresh } from '@element-plus/icons-vue'
|
|
||||||
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
const queryParams = reactive({
|
const loading = ref(true) // 列表的加载中
|
||||||
total: 0, // 总页数
|
|
||||||
currentPage: 1, // 当前页数
|
|
||||||
pageNo: 1, // 当前页数
|
|
||||||
accountId: undefined, // 当前页数
|
|
||||||
queryParamsSize: 10 // 每页显示多少条
|
|
||||||
})
|
|
||||||
const loading = ref(false) // 列表的加载中
|
|
||||||
const showSearch = ref(true) // 列表的加载中
|
|
||||||
const total = ref(0) // 列表的总页数
|
const total = ref(0) // 列表的总页数
|
||||||
const list = ref([]) // 列表的数据
|
const list = ref([]) // 列表的数据
|
||||||
const accounts = ref([]) // 列表的数据
|
const queryParams = reactive({
|
||||||
|
currentPage: 1, // 当前页数
|
||||||
|
pageNo: 1, // 当前页数
|
||||||
|
accountId: undefined // 当前页数
|
||||||
|
})
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
const accountList = ref<MpAccountApi.AccountVO[]>([]) // 公众号账号列表
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
// 如果没有选中公众号账号,则进行提示。
|
// 如果没有选中公众号账号,则进行提示。
|
||||||
@ -87,6 +83,7 @@ const getList = async () => {
|
|||||||
message.error('未选中公众号,无法查询已发表图文')
|
message.error('未选中公众号,无法查询已发表图文')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// TODO 改成 await 形式
|
||||||
loading.value = true
|
loading.value = true
|
||||||
getFreePublishPage(queryParams)
|
getFreePublishPage(queryParams)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
@ -106,18 +103,20 @@ const getList = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
const handleQuery = async () => {
|
const handleQuery = () => {
|
||||||
queryParams.pageNo = 1
|
queryParams.pageNo = 1
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
const resetQuery = async () => {
|
const resetQuery = () => {
|
||||||
queryFormRef.value.resetFields()
|
queryFormRef.value.resetFields()
|
||||||
// 默认选中第一个
|
// 默认选中第一个
|
||||||
if (accounts.value.length > 0) {
|
if (accountList.value.length > 0) {
|
||||||
queryParams.accountId = accounts[0].id
|
// @ts-ignore
|
||||||
|
queryParams.accountId = accountList.value[0].id
|
||||||
}
|
}
|
||||||
handleQuery()
|
handleQuery()
|
||||||
}
|
}
|
||||||
@ -125,6 +124,7 @@ const resetQuery = async () => {
|
|||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (item) => {
|
const handleDelete = async (item) => {
|
||||||
{
|
{
|
||||||
|
// TODO 改成 await 形式
|
||||||
const articleId = item.articleId
|
const articleId = item.articleId
|
||||||
const accountId = queryParams.accountId
|
const accountId = queryParams.accountId
|
||||||
message
|
message
|
||||||
@ -140,19 +140,16 @@ const handleDelete = async (item) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
getSimpleAccounts().then((response) => {
|
accountList.value = await MpAccountApi.getSimpleAccountList()
|
||||||
accounts.value = response
|
// 选中第一个
|
||||||
// 默认选中第一个
|
if (accountList.value.length > 0) {
|
||||||
if (accounts.value.length > 0) {
|
// @ts-ignore
|
||||||
queryParams.accountId = accounts.value[0]['id']
|
queryParams.accountId = accountList.value[0].id
|
||||||
}
|
}
|
||||||
// 加载数据
|
await getList()
|
||||||
getList()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.pagination {
|
.pagination {
|
||||||
float: right;
|
float: right;
|
||||||
@ -182,7 +179,7 @@ onMounted(() => {
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*新增图文*/
|
/* 新增图文 */
|
||||||
.left {
|
.left {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 35%;
|
width: 35%;
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
<el-select v-model="queryParams.accountId" placeholder="请选择公众号" class="!w-240px">
|
<el-select v-model="queryParams.accountId" placeholder="请选择公众号" class="!w-240px">
|
||||||
<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>
|
||||||
@ -60,11 +60,13 @@
|
|||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<el-table v-loading="loading" :data="list">
|
<el-table v-loading="loading" :data="list">
|
||||||
<el-table-column label="发送时间" align="center" prop="createTime" width="180">
|
<el-table-column
|
||||||
<template #default="scope">
|
label="发送时间"
|
||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
align="center"
|
||||||
</template>
|
prop="createTime"
|
||||||
</el-table-column>
|
width="180"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
/>
|
||||||
<el-table-column label="消息类型" align="center" prop="type" width="80" />
|
<el-table-column label="消息类型" align="center" prop="type" width="80" />
|
||||||
<el-table-column label="发送方" align="center" prop="sendFrom" width="80">
|
<el-table-column label="发送方" align="center" prop="sendFrom" width="80">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@ -180,13 +182,13 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts" name="MpMessage">
|
<script setup lang="ts" name="MpMessage">
|
||||||
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
// import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
|
// import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
|
||||||
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'
|
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'
|
||||||
// import WxMsg from '@/views/mp/components/wx-msg/main.vue'
|
// import WxMsg from '@/views/mp/components/wx-msg/main.vue'
|
||||||
import WxLocation from '@/views/mp/components/wx-location/main.vue'
|
import WxLocation from '@/views/mp/components/wx-location/main.vue'
|
||||||
// import WxMusic from '@/views/mp/components/wx-music/main.vue'
|
// import WxMusic from '@/views/mp/components/wx-music/main.vue'
|
||||||
// import WxNews from '@/views/mp/components/wx-news/main.vue'
|
// import WxNews from '@/views/mp/components/wx-news/main.vue'
|
||||||
import { parseTime } from '@/utils/formatTime'
|
|
||||||
import * as MpAccountApi from '@/api/mp/account'
|
import * as MpAccountApi from '@/api/mp/account'
|
||||||
import * as MpMessageApi from '@/api/mp/message'
|
import * as MpMessageApi from '@/api/mp/message'
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
Loading…
Reference in New Issue
Block a user