Blame view

yudao-ui-admin/src/views/mp/draft/index.vue 21.1 KB
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  <!--
  MIT License
  
  Copyright (c) 2020 www.joolun.com
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
23
24
    芋道源码:
    ① 优化代码,和项目的代码保持一致
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
25
26
    ② 清理冗余代码,保证代码整洁
    ③ 增加注释,提升可读性
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
27
28
29
  -->
  <template>
    <div class="app-container">
ca8bb724   YunaiV   版本 1.7.0 发布:增加微信公...
30
31
      <doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
  
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
      <!-- 搜索工作栏 -->
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="公众号" prop="accountId">
          <el-select v-model="queryParams.accountId" placeholder="请选择公众号">
            <el-option v-for="item in accounts" :key="parseInt(item.id)" :label="item.name" :value="parseInt(item.id)" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
  
      <!-- 操作工具栏 -->
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
48
          <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
49
50
51
52
53
54
55
56
57
58
59
                     v-hasPermi="['mp:draft:create']">新增
          </el-button>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
  
      <!-- 列表 -->
      <div class="waterfall" v-loading="loading">
        <div v-if="item.content && item.content.newsItem" class="waterfall-item" v-for="item in list"
             :key='item.articleId'>
          <wx-news :articles="item.content.newsItem" />
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
60
          <!-- 操作按钮 -->
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
61
          <el-row class="ope-row">
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
62
63
64
            <el-button type="success" circle @click="handlePublish(item)" v-hasPermi="['mp:free-publish:submit']">发布</el-button>
            <el-button type="primary" icon="el-icon-edit" circle @click="handleUpdate(item)" v-hasPermi="['mp:draft:update']" />
            <el-button type="danger" icon="el-icon-delete" circle @click="handleDelete(item)" v-hasPermi="['mp:draft:delete']" />
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
65
66
67
68
          </el-row>
        </div>
      </div>
      <!-- 分页记录 -->
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
69
70
71
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                  @pagination="getList"/>
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
72
      <!-- 添加或修改草稿对话框 -->
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
73
      <el-dialog :title="operateMaterial === 'add' ? '新建图文' : '修改图文'"
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
74
75
                 append-to-body width="80%" top="20px" :visible.sync="dialogNewsVisible"
                 :before-close="dialogNewsClose" :close-on-click-modal="false">
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
        <div class="left">
          <div class="select-item">
            <div v-for="(news, index) in articlesAdd" :key='news.id'>
              <div class="news-main father" v-if="index === 0" :class="{'activeAddNews': isActiveAddNews === index}"
                   @click="activeNews(index)">
                <div class="news-content">
                  <img class="material-img" v-if="news.thumbUrl" :src="news.thumbUrl"/>
                  <div class="news-content-title">{{news.title}}</div>
                </div>
                <div class="child" v-if="articlesAdd.length>1">
                  <el-button type="mini" icon="el-icon-sort-down" @click="downNews(index)">下移</el-button>
                  <el-button v-if="operateMaterial === 'add'" type="mini" icon="el-icon-delete"
                             @click="minusNews(index)">删除
                  </el-button>
                </div>
              </div>
              <div class="news-main-item father" v-if="index>0" :class="{'activeAddNews': isActiveAddNews === index}"
                   @click="activeNews(index)">
                <div class="news-content-item">
                  <div class="news-content-item-title ">{{news.title}}</div>
                  <div class="news-content-item-img">
                    <img class="material-img" v-if="news.thumbUrl" :src="news.thumbUrl" height="100%"/>
                  </div>
                </div>
                <div class="child">
                  <el-button v-if="articlesAdd.length > index+1" type="mini" icon="el-icon-sort-down"
                             @click="downNews(index)">下移
                  </el-button>
                  <el-button type="mini" icon="el-icon-sort-up" @click="upNews(index)">上移</el-button>
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
105
                  <el-button v-if="operateMaterial=== 'add'" type="mini" icon="el-icon-delete"
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
106
107
108
109
110
                             @click="minusNews(index)">删除
                  </el-button>
                </div>
              </div>
            </div>
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
111
            <div class="news-main-plus" @click="plusNews" v-if="articlesAdd.length<8 && operateMaterial==='add'">
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
112
113
114
115
              <i class="el-icon-circle-plus icon-plus"></i>
            </div>
          </div>
        </div>
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
116
        <div class="right" v-loading="addMaterialLoading" v-if="articlesAdd.length > 0">
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
117
118
119
120
121
          <br /> <br /> <br /> <br />
          <!-- 标题、作者、原文地址 -->
          <el-input v-model="articlesAdd[isActiveAddNews].title" placeholder="请输入标题(必填)" />
          <el-input v-model="articlesAdd[isActiveAddNews].author" placeholder="请输入作者" style="margin-top: 5px;" />
          <el-input v-model="articlesAdd[isActiveAddNews].contentSourceUrl" placeholder="请输入原文地址" style="margin-top: 5px;" />
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
122
          <!-- 封面和摘要 -->
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
123
124
125
126
          <div class="input-tt">封面和摘要:</div>
          <div>
            <div class="thumb-div">
              <img class="material-img" v-if="articlesAdd[isActiveAddNews].thumbUrl"
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
127
                   :src="articlesAdd[isActiveAddNews].thumbUrl" :class="isActiveAddNews === 0 ? 'avatar':'avatar1'">
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
128
129
130
              <i v-else class="el-icon-plus avatar-uploader-icon"
                 :class="isActiveAddNews === 0 ? 'avatar':'avatar1'"></i>
              <div class="thumb-but">
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
131
132
133
134
135
                <el-upload :action="actionUrl" :headers="headers" multiple :limit="1" :file-list="fileList" :data="uploadData"
                           :before-upload="beforeThumbImageUpload" :on-success="handleUploadSuccess">
                  <el-button slot="trigger" size="mini" type="primary">本地上传</el-button>
                  <el-button size="mini" type="primary" @click="openMaterial" style="margin-left: 5px">素材库选择</el-button>
                  <div slot="tip" class="el-upload__tip">支持 bmp/png/jpeg/jpg/gif 格式,大小不超过 2M</div>
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
136
137
                </el-upload>
              </div>
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
138
139
140
141
              <el-dialog title="选择图片" :visible.sync="dialogImageVisible" width="80%" append-to-body>
                <wx-material-select ref="materialSelect" :objData="{type: 'image', accountId: this.queryParams.accountId}"
                                    @selectMaterial="selectMaterial" />
              </el-dialog>
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
142
            </div>
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
143
            <el-input :rows="8" type="textarea" v-model="articlesAdd[isActiveAddNews].digest" placeholder="请输入摘要"
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
144
                      class="digest" maxlength="120" style="float: right" />
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
145
          </div>
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
146
147
148
149
150
          <!--富文本编辑器组件-->
          <el-row>
            <wx-editor v-model="articlesAdd[isActiveAddNews].content" :account-id="this.uploadData.accountId"
                       v-if="hackResetEditor"/>
          </el-row>
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
151
152
153
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogNewsVisible = false">取 消</el-button>
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
154
          <el-button type="primary" @click="submitForm">提 交</el-button>
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
155
156
157
158
159
160
        </div>
      </el-dialog>
    </div>
  </template>
  
  <script>
f48276d2   YunaiV   mp:引入 wx-editor 组件
161
  import WxEditor from '@/views/mp/components/wx-editor/WxEditor.vue';
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
162
163
164
  import WxNews from '@/views/mp/components/wx-news/main.vue';
  import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
  import { getAccessToken } from '@/utils/auth'
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
165
  import {createDraft, deleteDraft, getDraftPage, updateDraft} from "@/api/mp/draft";
f48276d2   YunaiV   mp:引入 wx-editor 组件
166
  import { getSimpleAccounts } from "@/api/mp/account";
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
167
  import {deleteFreePublish, submitFreePublish} from "@/api/mp/freePublish";
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
168
169
  
  export default {
35ba9b36   YunaiV   菜单新增 alwaysShow 总...
170
    name: 'MpDraft',
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
171
    components: {
f48276d2   YunaiV   mp:引入 wx-editor 组件
172
      WxEditor,
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
      WxNews,
      WxMaterialSelect
    },
    data() {
      return {
        // 遮罩层
        loading: false,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 数据列表
        list: [],
        queryParams: {
          pageNo: 1,
          pageSize: 10,
          accountId: undefined,
        },
  
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
192
193
        // ========== 文件上传 ==========
        actionUrl: process.env.VUE_APP_BASE_API + "/admin-api/mp/material/upload-permanent", // 上传永久素材的地址
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
194
195
        headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
        fileList: [],
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
196
        uploadData: {
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
197
          "type": 'image',
28884ee6   YunaiV   mp:优化 wx-editor 图...
198
          // "accountId": 1,
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
199
        },
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
200
201
202
203
  
        // ========== 草稿新建 or 修改 ==========
        dialogNewsVisible: false,
        addMaterialLoading: false, // 添加草稿的 loading 标识
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
204
        articlesAdd: [],
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
205
206
        isActiveAddNews: 0,
        dialogImageVisible: false,
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
207
208
209
210
211
212
213
214
215
216
217
218
219
        operateMaterial: 'add',
        articlesMediaId: '',
        hackResetEditor: false,
  
        // 公众号账号列表
        accounts: [],
      }
    },
    created() {
      getSimpleAccounts().then(response => {
        this.accounts = response.data;
        // 默认选中第一个
        if (this.accounts.length > 0) {
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
220
          this.setAccountId(this.accounts[0].id);
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
221
222
        }
        // 加载数据
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
223
        this.getList();
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
224
225
226
      })
    },
    methods: {
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
227
      // ======================== 列表查询 ========================
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
228
229
230
231
232
      /** 设置账号编号 */
      setAccountId(accountId) {
        this.queryParams.accountId = accountId;
        this.uploadData.accountId = accountId;
      },
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
233
234
235
236
237
238
239
240
241
      /** 查询列表 */
      getList() {
        // 如果没有选中公众号账号,则进行提示。
        if (!this.queryParams.accountId) {
          this.$message.error('未选中公众号,无法查询草稿箱')
          return false
        }
  
        this.loading = true
5a1d02df   YunaiV   mp:素材管理,增加【图片】
242
        getDraftPage(this.queryParams).then(response => {
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
243
244
245
246
247
248
249
250
251
252
253
254
255
          // 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面
          response.data.list.forEach(item => {
            const newsItem = item.content.newsItem;
            newsItem.forEach(article => {
              article.picUrl = article.thumbUrl;
            })
          })
          this.list = response.data.list
          this.total = response.data.total
        }).finally(() => {
          this.loading = false
        })
      },
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
256
257
258
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNo = 1
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
259
260
261
262
        // 默认选中第一个
        if (this.queryParams.accountId) {
          this.setAccountId(this.queryParams.accountId)
        }
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
263
264
265
266
267
268
269
270
271
272
273
        this.getList()
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm('queryForm')
        // 默认选中第一个
        if (this.accounts.length > 0) {
          this.setAccountId(this.accounts[0].id)
        }
        this.handleQuery()
      },
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
274
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
275
276
277
278
279
280
281
282
      // ======================== 新增/修改草稿 ========================
      /** 新增按钮操作 */
      handleAdd() {
        this.resetEditor();
        this.reset();
        // 打开表单,并设置初始化
        this.operateMaterial = 'add'
        this.dialogNewsVisible = true
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
283
      },
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
284
285
286
287
288
289
290
291
292
      /** 更新按钮操作 */
      handleUpdate(item){
        this.resetEditor();
        this.reset();
        this.articlesMediaId = item.mediaId
        this.articlesAdd = JSON.parse(JSON.stringify(item.content.newsItem))
        // 打开表单,并设置初始化
        this.operateMaterial = 'edit'
        this.dialogNewsVisible = true
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
293
      },
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
294
295
      /** 提交按钮 */
      submitForm() {
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
296
        this.addMaterialLoading = true
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
297
        if (this.operateMaterial === 'add') {
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
298
          createDraft(this.queryParams.accountId, this.articlesAdd).then(response => {
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
299
300
301
            this.$modal.msgSuccess("新增成功");
            this.dialogNewsVisible = false;
            this.getList()
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
302
          }).finally(() => {
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
303
304
            this.addMaterialLoading = false
          })
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
305
306
307
308
309
310
        } else {
          updateDraft(this.queryParams.accountId, this.articlesMediaId, this.articlesAdd).then(response => {
            this.$modal.msgSuccess("更新成功");
            this.dialogNewsVisible = false;
            this.getList()
          }).finally(() => {
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
311
312
313
314
            this.addMaterialLoading = false
          })
        }
      },
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
315
316
317
318
319
320
321
      // 关闭弹窗
      dialogNewsClose(done) {
        this.$modal.confirm('修改内容可能还未保存,确定关闭吗?').then(() => {
         this.reset()
          this.resetEditor()
          done()
        }).catch(() => {})
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
322
323
324
325
326
327
328
329
      },
      // 表单重置
      reset() {
        this.isActiveAddNews = 0
        this.articlesAdd = [this.buildEmptyArticle()]
      },
      // 表单 Editor 重置
      resetEditor() {
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
330
        this.hackResetEditor = false // 销毁组件
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
331
        this.$nextTick(() => {
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
332
          this.hackResetEditor = true // 重建组件
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
333
        })
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
      },
      // 将图文向下移动
      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":''
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
381
        }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
382
      },
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
383
384
385
  
      // ======================== 文件上传 ========================
      beforeThumbImageUpload(file) {
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
386
        this.addMaterialLoading = true
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
387
388
389
390
391
        const isType = file.type === 'image/jpeg'
            || file.type === 'image/png'
            || file.type === 'image/gif'
            || file.type === 'image/bmp'
            || file.type === 'image/jpg';
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
392
393
        if (!isType) {
          this.$message.error('上传图片格式不对!')
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
394
395
          this.addMaterialLoading = false
          return false;
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
396
        }
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
397
        const isLt = file.size / 1024 / 1024 < 2
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
398
        if (!isLt) {
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
399
400
401
          this.$message.error('上传图片大小不能超过 2M!')
          this.addMaterialLoading = false
          return false;
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
402
        }
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
403
404
        // 校验通过
        return true;
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
405
      },
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
406
407
408
      handleUploadSuccess(response, file, fileList) {
        this.addMaterialLoading = false // 关闭 loading
        if (response.code !== 0) {
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
409
          this.$message.error('上传出错:' + response.msg)
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
410
          return false;
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
411
        }
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
412
413
414
  
        // 重置上传文件的表单
        this.fileList = []
4080d2de   YunaiV   mp:初步实现【草稿】的前端新增
415
416
417
418
  
        // 设置草稿的封面字段
        this.articlesAdd[this.isActiveAddNews].thumbMediaId = response.data.mediaId
        this.articlesAdd[this.isActiveAddNews].thumbUrl = response.data.url
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
419
      },
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
420
421
      // 选择 or 上传完素材,设置回草稿
      selectMaterial(item) {
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
422
423
424
425
        this.dialogImageVisible = false
        this.articlesAdd[this.isActiveAddNews].thumbMediaId = item.mediaId
        this.articlesAdd[this.isActiveAddNews].thumbUrl = item.url
      },
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
426
427
428
429
430
431
432
433
      // 打开素材选择
      openMaterial() {
        this.dialogImageVisible = true
        try {
          this.$refs['materialSelect'].queryParams.accountId = this.queryParams.accountId // 强制设置下 accountId,避免二次查询不对
          this.$refs['materialSelect'].handleQuery(); // 刷新列表,失败也无所谓
        } catch (e) {}
      },
c0bd3471   YunaiV   mp:初步实现【草稿】的前端新增(...
434
435
  
      // ======================== 草稿箱发布 ========================
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
436
437
438
439
440
441
      handlePublish(item) {
        const accountId = this.queryParams.accountId;
        const mediaId = item.mediaId;
        const content = '你正在通过发布的方式发表内容。 发布不占用群发次数,一天可多次发布。已发布内容不会推送给用户,也不会展示在公众号主页中。 发布后,你可以前往发表记录获取链接,也可以将发布内容添加到自定义菜单、自动回复、话题和页面模板中。';
        this.$modal.confirm(content).then(function() {
          return submitFreePublish(accountId, mediaId);
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
442
        }).then(() => {
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
443
444
445
          this.getList();
          this.$modal.msgSuccess("发布成功");
        }).catch(() => {});
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
446
      },
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
447
448
449
450
451
      handleDelete(item) {
        const accountId = this.queryParams.accountId;
        const mediaId = item.mediaId;
        this.$modal.confirm('此操作将永久删除该草稿, 是否继续?').then(function() {
          return deleteDraft(accountId, mediaId);
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
452
        }).then(() => {
d1cbe0c3   YunaiV   mp:增加图文草稿箱的删除、发布功能
453
454
455
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
456
      },
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
457
458
459
460
461
    }
  }
  </script>
  
  <style lang="scss" scoped>
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
462
463
464
465
  .pagination {
    float: right;
    margin-right: 25px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
466
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
467
468
469
  .add_but {
    padding: 10px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
470
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
471
472
473
474
475
476
  .ope-row {
    margin-top: 5px;
    text-align: center;
    border-top: 1px solid #eaeaea;
    padding-top: 5px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
477
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
478
479
480
481
482
483
484
  .item-name {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
485
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
486
487
488
  .el-upload__tip {
    margin-left: 5px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
489
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
490
491
492
493
494
495
496
  /*新增图文*/
  .left {
    display: inline-block;
    width: 35%;
    vertical-align: top;
    margin-top: 200px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
497
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
498
499
500
501
502
  .right {
    display: inline-block;
    width: 60%;
    margin-top: -40px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
503
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
504
505
506
507
  .avatar-uploader {
    width: 20%;
    display: inline-block;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
508
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
509
510
511
512
513
514
515
  .avatar-uploader .el-upload {
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-align: unset !important;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
516
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
517
518
519
  .avatar-uploader .el-upload:hover {
    border-color: #165dff;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
520
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
521
522
523
524
525
526
527
528
529
  .avatar-uploader-icon {
    border: 1px solid #d9d9d9;
    font-size: 28px;
    color: #8c939d;
    width: 120px;
    height: 120px;
    line-height: 120px;
    text-align: center;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
530
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
531
532
533
534
  .avatar {
    width: 230px;
    height: 120px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
535
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
536
537
538
539
  .avatar1 {
    width: 120px;
    height: 120px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
540
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
541
542
543
544
545
  .digest {
    width: 60%;
    display: inline-block;
    vertical-align: top;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
546
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
547
548
549
550
551
552
553
554
  /*新增图文*/
  /*瀑布流样式*/
  .waterfall {
    width: 100%;
    column-gap: 10px;
    column-count: 5;
    margin: 0 auto;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
555
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
556
557
558
559
560
561
  .waterfall-item {
    padding: 10px;
    margin-bottom: 10px;
    break-inside: avoid;
    border: 1px solid #eaeaea;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
562
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
563
564
565
566
567
568
569
570
  p {
    line-height: 30px;
  }
  
  @media (min-width: 992px) and (max-width: 1300px) {
    .waterfall {
      column-count: 3;
    }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
571
    p {
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
572
      color: red;
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
573
    }
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
574
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
575
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
576
577
578
  @media (min-width: 768px) and (max-width: 991px) {
    .waterfall {
      column-count: 2;
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
579
    }
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
580
581
    p {
      color: orange;
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
582
    }
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
583
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
584
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
585
586
587
  @media (max-width: 767px) {
    .waterfall {
      column-count: 1;
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
588
    }
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
589
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
590
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
591
592
593
594
595
596
597
  /*瀑布流样式*/
  .news-main {
    background-color: #FFFFFF;
    width: 100%;
    margin: auto;
    height: 120px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
598
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
599
600
601
602
603
604
  .news-content {
    background-color: #acadae;
    width: 100%;
    height: 120px;
    position: relative;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
605
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
  .news-content-title {
    display: inline-block;
    font-size: 15px;
    color: #FFFFFF;
    position: absolute;
    left: 0px;
    bottom: 0px;
    background-color: black;
    width: 98%;
    padding: 1%;
    opacity: 0.65;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    height: 25px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
622
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
623
624
625
626
627
628
629
  .news-main-item {
    background-color: #FFFFFF;
    padding: 5px 0px;
    border-top: 1px solid #eaeaea;
    width: 100%;
    margin: auto;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
630
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
631
632
633
634
  .news-content-item {
    position: relative;
    margin-left: -3px
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
635
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
636
637
638
639
640
  .news-content-item-title {
    display: inline-block;
    font-size: 12px;
    width: 70%;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
641
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
642
643
644
645
646
  .news-content-item-img {
    display: inline-block;
    width: 25%;
    background-color: #acadae
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
647
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
648
649
650
  .input-tt {
    padding: 5px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
651
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
652
653
654
  .activeAddNews {
    border: 5px solid #2bb673;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
655
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
656
657
658
659
660
661
  .news-main-plus {
    width: 280px;
    text-align: center;
    margin: auto;
    height: 50px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
662
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
663
664
665
666
  .icon-plus {
    margin: 10px;
    font-size: 25px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
667
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
668
669
670
671
672
673
  .select-item {
    width: 60%;
    padding: 10px;
    margin: 0 auto 10px auto;
    border: 1px solid #eaeaea;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
674
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
675
676
677
678
679
680
  .father .child {
    display: none;
    text-align: center;
    position: relative;
    bottom: 25px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
681
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
682
683
684
  .father:hover .child {
    display: block;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
685
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
686
687
688
689
690
  .thumb-div {
    display: inline-block;
    width: 30%;
    text-align: center;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
691
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
692
693
694
  .thumb-but {
    margin: 5px;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
695
  
90ffe5ad   YunaiV   mp:增加图文草稿箱的修改;优化前端代码
696
697
698
699
  .material-img {
    width: 100%;
    height: 100%;
  }
bc870434   YunaiV   mp:初始化【图文草稿箱】前端界面
700
  </style>