Vue3 重构:REVIEW 图文发表记录

This commit is contained in:
YunaiV 2023-03-26 23:31:41 +08:00
parent 708aef3e10
commit f5177337cb
2 changed files with 51 additions and 52 deletions

View File

@ -1,37 +1,36 @@
<template>
<content-wrap>
<doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
<!-- 搜索工作栏 -->
<content-wrap>
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<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
v-for="item in accounts"
:key="parseInt(item.id)"
v-for="item in accountList"
:key="item.id"
:label="item.name"
:value="parseInt(item.id)"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" :icon="Search" @click="handleQuery">搜索</el-button>
<el-button :icon="Refresh" @click="resetQuery">重置</el-button>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
</el-form-item>
</el-form>
</content-wrap>
<!-- 列表 -->
<content-wrap>
<div class="waterfall" v-loading="loading">
<div
v-show="item.content && item.content.newsItem"
class="waterfall-item"
v-show="item.content && item.content.newsItem"
v-for="item in list"
:key="item.articleId"
>
@ -40,11 +39,12 @@
<el-row justify="center" class="ope-row">
<el-button
type="danger"
:icon="Delete"
circle
@click="handleDelete(item)"
v-hasPermi="['mp:free-publish:delete']"
/>
>
<Icon icon="ep:delete" />
</el-button>
</el-row>
</div>
</div>
@ -61,25 +61,21 @@
<script setup lang="ts" name="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 { Delete, Search, Refresh } from '@element-plus/icons-vue'
const message = useMessage() //
const queryParams = reactive({
total: 0, //
currentPage: 1, //
pageNo: 1, //
accountId: undefined, //
queryParamsSize: 10 //
})
const loading = ref(false) //
const showSearch = ref(true) //
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const accounts = ref([]) //
const queryParams = reactive({
currentPage: 1, //
pageNo: 1, //
accountId: undefined //
})
const queryFormRef = ref() //
const accountList = ref<MpAccountApi.AccountVO[]>([]) //
/** 查询列表 */
const getList = async () => {
//
@ -87,6 +83,7 @@ const getList = async () => {
message.error('未选中公众号,无法查询已发表图文')
return false
}
// TODO await
loading.value = true
getFreePublishPage(queryParams)
.then((data) => {
@ -106,18 +103,20 @@ const getList = async () => {
loading.value = false
})
}
/** 搜索按钮操作 */
const handleQuery = async () => {
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = async () => {
const resetQuery = () => {
queryFormRef.value.resetFields()
//
if (accounts.value.length > 0) {
queryParams.accountId = accounts[0].id
if (accountList.value.length > 0) {
// @ts-ignore
queryParams.accountId = accountList.value[0].id
}
handleQuery()
}
@ -125,6 +124,7 @@ const resetQuery = async () => {
/** 删除按钮操作 */
const handleDelete = async (item) => {
{
// TODO await
const articleId = item.articleId
const accountId = queryParams.accountId
message
@ -140,19 +140,16 @@ const handleDelete = async (item) => {
}
}
onMounted(() => {
getSimpleAccounts().then((response) => {
accounts.value = response
//
if (accounts.value.length > 0) {
queryParams.accountId = accounts.value[0]['id']
onMounted(async () => {
accountList.value = await MpAccountApi.getSimpleAccountList()
//
if (accountList.value.length > 0) {
// @ts-ignore
queryParams.accountId = accountList.value[0].id
}
//
getList()
})
await getList()
})
</script>
<style lang="scss" scoped>
.pagination {
float: right;
@ -182,7 +179,7 @@ onMounted(() => {
margin-left: 5px;
}
/*新增图文*/
/* 新增图文 */
.left {
display: inline-block;
width: 35%;

View File

@ -12,9 +12,9 @@
<el-select v-model="queryParams.accountId" placeholder="请选择公众号" class="!w-240px">
<el-option
v-for="item in accountList"
:key="parseInt(item.id)"
:key="item.id"
:label="item.name"
:value="parseInt(item.id)"
:value="item.id"
/>
</el-select>
</el-form-item>
@ -60,11 +60,13 @@
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list">
<el-table-column label="发送时间" align="center" prop="createTime" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="发送时间"
align="center"
prop="createTime"
width="180"
:formatter="dateFormatter"
/>
<el-table-column label="消息类型" align="center" prop="type" width="80" />
<el-table-column label="发送方" align="center" prop="sendFrom" width="80">
<template #default="scope">
@ -180,13 +182,13 @@
</template>
<script setup lang="ts" name="MpMessage">
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
// import WxVideoPlayer from '@/views/mp/components/wx-video-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 WxLocation from '@/views/mp/components/wx-location/main.vue'
// import WxMusic from '@/views/mp/components/wx-music/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 MpMessageApi from '@/api/mp/message'
const message = useMessage() //