From c0bd3471d5382b9fd8f8f015cf12558b4f26c778 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 14 Jan 2023 00:42:22 +0800 Subject: [PATCH] =?UTF-8?q?mp=EF=BC=9A=E5=88=9D=E6=AD=A5=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E3=80=90=E8=8D=89=E7=A8=BF=E3=80=91=E7=9A=84=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=88=E4=BC=98=E5=8C=96=EF=BC=8C=E5=87=8F?= =?UTF-8?q?=E5=B0=91=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-admin/src/views/mp/draft/index.vue | 186 ++++++++------------ 1 file changed, 78 insertions(+), 108 deletions(-) diff --git a/yudao-ui-admin/src/views/mp/draft/index.vue b/yudao-ui-admin/src/views/mp/draft/index.vue index 39467d810..52ea208eb 100644 --- a/yudao-ui-admin/src/views/mp/draft/index.vue +++ b/yudao-ui-admin/src/views/mp/draft/index.vue @@ -39,7 +39,7 @@ SOFTWARE. - 新增 @@ -114,7 +114,7 @@ SOFTWARE. -
+
@@ -212,18 +212,7 @@ export default { // ========== 草稿新建 or 修改 ========== dialogNewsVisible: false, addMaterialLoading: false, // 添加草稿的 loading 标识 - articlesAdd: [{ - "title": '', - "thumbMediaId": '', - "author": '', - "digest": '', - "showCoverPic": '', - "content": '123', // TODO 芋艿:临时测试 - "contentSourceUrl": '', - "needOpenComment": '', - "onlyFansCanComment": '', - "thumbUrl": '', - }], + articlesAdd: [], isActiveAddNews: 0, dialogImageVisible: false, imageListData: [], @@ -349,80 +338,14 @@ export default { }).catch(() => { }) }, - downNews(index){ - let temp = this.articlesAdd[index] - this.articlesAdd[index] = this.articlesAdd[index+1] - this.articlesAdd[index+1] = temp - this.isActiveAddNews = index+1 - }, - upNews(index){ - let temp = this.articlesAdd[index] - this.articlesAdd[index] = this.articlesAdd[index-1] - this.articlesAdd[index-1] = temp - this.isActiveAddNews = index-1 - }, - activeNews(index){ - this.hackResetEditor = false//销毁组件 - this.$nextTick(() => { - this.hackResetEditor = true//重建组件 - }) - this.isActiveAddNews = index - }, - minusNews(index){ - this.$confirm('确定删除该图文吗?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - }).then(() => { - this.articlesAdd.splice(index,1); - if(this.isActiveAddNews === index){ - this.isActiveAddNews = 0 - } - }).catch(() => {}) - }, - plusNews(){ - this.articlesAdd.push( - { - "title": '', - "thumbMediaId": '', - "author": '', - "digest": '', - "showCoverPic": '', - "content": '', - "contentSourceUrl": '', - "needOpenComment":'', - "onlyFansCanComment":'', - "thumbUrl":'' - } - ) - this.isActiveAddNews = this.articlesAdd.length - 1 - }, - subNews() { + /** 提交按钮 */ + submitForm() { this.addMaterialLoading = true - if(this.operateMaterial === 'add'){ + if (this.operateMaterial === 'add') { createDraft(this.queryParams.accountId, this.articlesAdd).then(response => { - this.addMaterialLoading = false - this.dialogNewsVisible = false - if(response.code == 200){ - this.isActiveAddNews = 0 - this.articlesAdd = [ - { - "title": '', - "thumbMediaId": '', - "author": '', - "digest": '', - "showCoverPic": '', - "content": '', - "contentSourceUrl": '', - "needOpenComment":'', - "onlyFansCanComment":'', - "thumbUrl":'' - } - ] - this.getList() - } else { - this.$message.error('新增图文出错:' + response.msg) - } + this.$modal.msgSuccess("新增成功"); + this.dialogNewsVisible = false; + this.getList() }).finally(() => { this.addMaterialLoading = false }) @@ -472,32 +395,77 @@ export default { this.articlesMediaId = item.mediaId this.dialogNewsVisible = true }, - handleAddNews(){ + /** 新增按钮操作 */ + handleAdd() { + this.resetEditor(); + this.reset(); + // 打开表单,并设置初始化 + this.operateMaterial = 'add' + this.dialogNewsVisible = true + }, + // 表单重置 + reset() { + this.isActiveAddNews = 0 + this.articlesAdd = [this.buildEmptyArticle()] + }, + // 表单 Editor 重置 + resetEditor() { this.hackResetEditor = false // 销毁组件 this.$nextTick(() => { this.hackResetEditor = true // 重建组件 }) - if(this.operateMaterial == 'edit'){ - this.isActiveAddNews = 0 - this.articlesAdd = [ - { - "title": '', - "thumbMediaId": '', - "author": '', - "digest": '', - "showCoverPic": '', - "content": '', - "contentSourceUrl": '', - "needOpenComment":'', - "onlyFansCanComment":'', - "thumbUrl":'' - } - ] - } - this.operateMaterial = 'add' - this.dialogNewsVisible = true }, - beforeThumbImageUpload(file){ + // 将图文向下移动 + downNews(index) { + let temp = this.articlesAdd[index] + this.articlesAdd[index] = this.articlesAdd[index+1] + this.articlesAdd[index + 1] = temp + this.isActiveAddNews = index + 1 + }, + // 将图文向上移动 + upNews(index) { + let temp = this.articlesAdd[index] + this.articlesAdd[index] = this.articlesAdd[index - 1] + this.articlesAdd[index - 1] = temp + this.isActiveAddNews = index - 1 + }, + // 选中指定 index 的图文 + activeNews(index) { + this.resetEditor(); + this.isActiveAddNews = index + }, + // 删除指定 index 的图文 + minusNews(index) { + this.$modal.confirm('确定删除该图文吗?').then(() => { + this.articlesAdd.splice(index,1); + if (this.isActiveAddNews === index) { + this.isActiveAddNews = 0 + } + }).catch(() => {}) + }, + // 添加一个图文 + plusNews() { + this.articlesAdd.push(this.buildEmptyArticle()) + this.isActiveAddNews = this.articlesAdd.length - 1 + }, + // 创建空的 article + buildEmptyArticle() { + return { + "title": '', + "thumbMediaId": '', + "author": '', + "digest": '', + "showCoverPic": '', + "content": '', + "contentSourceUrl": '', + "needOpenComment":'', + "onlyFansCanComment":'', + "thumbUrl":'' + } + }, + + // ======================== 文件上传 ======================== + beforeThumbImageUpload(file) { this.addMaterialLoading = true const isType = file.type === 'image/jpeg' || file.type === 'image/png' @@ -539,6 +507,8 @@ export default { this.articlesAdd[this.isActiveAddNews].thumbMediaId = item.mediaId this.articlesAdd[this.isActiveAddNews].thumbUrl = item.url }, + + // ======================== 草稿箱发布 ======================== handlePublishNews(item){ this.$confirm('你正在通过发布的方式发表内容。 发布不占用群发次数,一天可多次发布。已发布内容不会推送给用户,也不会展示在公众号主页中。 发布后,你可以前往发表记录获取链接,也可以将发布内容添加到自定义菜单、自动回复、话题和页面模板中。', '提示', { confirmButtonText: '确定',