|
@@ -76,18 +76,14 @@ import {
|
|
|
|
|
|
const message = useMessage() // 消息
|
|
|
|
|
|
-const accountId = ref<number>(-1)
|
|
|
+const accountId = ref(-1)
|
|
|
provide('accountId', accountId)
|
|
|
|
|
|
const loading = ref(true) // 列表的加载中
|
|
|
const list = ref<any[]>([]) // 列表的数据
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
-interface QueryParams {
|
|
|
- pageNo: number
|
|
|
- pageSize: number
|
|
|
- accountId: number
|
|
|
-}
|
|
|
-const queryParams: QueryParams = reactive({
|
|
|
+
|
|
|
+const queryParams = reactive({
|
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
|
accountId: accountId
|
|
@@ -102,7 +98,8 @@ const isSubmitting = ref(false)
|
|
|
|
|
|
/** 侦听公众号变化 **/
|
|
|
const onAccountChanged = (id: number) => {
|
|
|
- setAccountId(id)
|
|
|
+ accountId.value = id
|
|
|
+ queryParams.pageNo = 1
|
|
|
getList()
|
|
|
}
|
|
|
|
|
@@ -115,12 +112,6 @@ const onBeforeDialogClose = async (onDone: () => {}) => {
|
|
|
}
|
|
|
|
|
|
// ======================== 列表查询 ========================
|
|
|
-/** 设置账号编号 */
|
|
|
-const setAccountId = (id: number) => {
|
|
|
- accountId.value = id
|
|
|
- // queryParams.accountId = id
|
|
|
-}
|
|
|
-
|
|
|
/** 查询列表 */
|
|
|
const getList = async () => {
|
|
|
loading.value = true
|
|
@@ -161,10 +152,10 @@ const onSubmitNewsItem = async () => {
|
|
|
isSubmitting.value = true
|
|
|
try {
|
|
|
if (isCreating.value) {
|
|
|
- await MpDraftApi.createDraft(queryParams.accountId, newsList.value)
|
|
|
+ await MpDraftApi.createDraft(accountId.value, newsList.value)
|
|
|
message.notifySuccess('新增成功')
|
|
|
} else {
|
|
|
- await MpDraftApi.updateDraft(queryParams.accountId, mediaId.value, newsList.value)
|
|
|
+ await MpDraftApi.updateDraft(accountId.value, mediaId.value, newsList.value)
|
|
|
message.notifySuccess('更新成功')
|
|
|
}
|
|
|
} finally {
|
|
@@ -176,7 +167,6 @@ const onSubmitNewsItem = async () => {
|
|
|
|
|
|
// ======================== 草稿箱发布 ========================
|
|
|
const onPublish = async (item: Article) => {
|
|
|
- const accountId = queryParams.accountId
|
|
|
const mediaId = item.mediaId
|
|
|
const content =
|
|
|
'你正在通过发布的方式发表内容。 发布不占用群发次数,一天可多次发布。' +
|
|
@@ -184,7 +174,7 @@ const onPublish = async (item: Article) => {
|
|
|
'发布后,你可以前往发表记录获取链接,也可以将发布内容添加到自定义菜单、自动回复、话题和页面模板中。'
|
|
|
try {
|
|
|
await message.confirm(content)
|
|
|
- await MpFreePublishApi.submitFreePublish(accountId, mediaId)
|
|
|
+ await MpFreePublishApi.submitFreePublish(accountId.value, mediaId)
|
|
|
message.notifySuccess('发布成功')
|
|
|
await getList()
|
|
|
} catch {}
|
|
@@ -192,11 +182,10 @@ const onPublish = async (item: Article) => {
|
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
const onDelete = async (item: Article) => {
|
|
|
- const accountId = queryParams.accountId
|
|
|
const mediaId = item.mediaId
|
|
|
try {
|
|
|
await message.confirm('此操作将永久删除该草稿, 是否继续?')
|
|
|
- await MpDraftApi.deleteDraft(accountId, mediaId)
|
|
|
+ await MpDraftApi.deleteDraft(accountId.value, mediaId)
|
|
|
message.notifySuccess('删除成功')
|
|
|
await getList()
|
|
|
} catch {}
|