|
48 | 48 | </el-table>
|
49 | 49 | <!-- 分页组件 -->
|
50 | 50 | <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
51 |
| - @pagination="getMaterialPage"/> |
| 51 | + @pagination="getPage"/> |
52 | 52 | </div>
|
53 | 53 | <div v-else-if="objData.type === 'video'">
|
54 | 54 | <!-- 列表 -->
|
|
78 | 78 | <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
79 | 79 | @pagination="getMaterialPage"/>
|
80 | 80 | </div>
|
81 |
| - <div v-else-if="objData.type == 'news'"> |
| 81 | + <div v-else-if="objData.type === 'news'"> |
82 | 82 | <div class="waterfall" v-loading="loading">
|
83 |
| - <div class="waterfall-item" v-for="item in list" :key="item.mediaId" v-if="item.content && item.content.articles"> |
84 |
| - <WxNews :objData="item.content.articles"></WxNews> |
| 83 | + <div class="waterfall-item" v-for="item in list" :key="item.mediaId" v-if="item.content && item.content.newsItem"> |
| 84 | + <wx-news :articles="item.content.newsItem" /> |
85 | 85 | <el-row class="ope-row">
|
86 |
| - <el-button size="mini" type="success" @click="selectMaterial(item)">选择<i class="el-icon-circle-check el-icon--right"></i></el-button> |
| 86 | + <el-button size="mini" type="success" @click="selectMaterial(item)"> |
| 87 | + 选择<i class="el-icon-circle-check el-icon--right"></i> |
| 88 | + </el-button> |
87 | 89 | </el-row>
|
88 | 90 | </div>
|
89 | 91 | </div>
|
90 |
| - <div v-if="list.length <=0 && !loading" class="el-table__empty-block"> |
| 92 | + <!-- 分页组件 --> |
| 93 | + <div v-if="list.length <= 0 && !loading" class="el-table__empty-block"> |
91 | 94 | <span class="el-table__empty-text">暂无数据</span>
|
92 | 95 | </div>
|
93 |
| - <span slot="footer" class="dialog-footer"> |
94 |
| - <el-pagination |
95 |
| - @size-change="sizeChange" |
96 |
| - :current-page.sync="page.currentPage" |
97 |
| - :page-sizes="[10, 20]" |
98 |
| - :page-size="page.pageSize" |
99 |
| - layout="total, sizes, prev, pager, next, jumper" |
100 |
| - :total="page.total" |
101 |
| - class="pagination" |
102 |
| - > |
103 |
| - </el-pagination> |
104 |
| - </span> |
| 96 | + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" |
| 97 | + @pagination="getMaterialPage"/> |
105 | 98 | </div>
|
106 | 99 | </template>
|
107 | 100 |
|
108 | 101 | <script>
|
109 |
| -
|
110 |
| - // import { tableOptionVoice } from '@/const/crud/wxmp/wxmaterial_voice' |
111 |
| - // import { tableOptionVideo } from '@/const/crud/wxmp/wxmaterial_video' |
112 | 102 | import WxNews from '@/views/mp/components/wx-news/main.vue';
|
113 | 103 | import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue';
|
114 | 104 | import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue';
|
115 | 105 | import { getMaterialPage } from "@/api/mp/material";
|
| 106 | + import {getFreePublishPage} from "@/api/mp/freePublish"; |
116 | 107 |
|
117 | 108 | export default {
|
118 | 109 | name: "wxMaterialSelect",
|
|
143 | 134 | queryParams: {
|
144 | 135 | pageNo: 1,
|
145 | 136 | pageSize: 10,
|
| 137 | + accountId: this.objData.accountId, |
146 | 138 | },
|
147 | 139 | // tableOptionVoice: tableOptionVoice,
|
148 | 140 | // tableOptionVideo: tableOptionVideo,
|
149 | 141 | }
|
150 | 142 | },
|
151 | 143 | created() {
|
152 |
| - this.getPage(this.page) |
| 144 | + this.getPage() |
153 | 145 | },
|
154 | 146 | methods:{
|
155 |
| - selectMaterial(item){ |
| 147 | + selectMaterial(item) { |
156 | 148 | this.$emit('selectMaterial', item)
|
157 | 149 | },
|
158 |
| - getPage(page, params) { |
| 150 | + getPage() { |
159 | 151 | this.loading = true
|
160 |
| - if(this.objData.type == 'news'){ // 【图文】 |
161 |
| - if(this.newsType == '1'){ |
162 |
| - getPageNews(Object.assign({ |
163 |
| - current: page.currentPage, |
164 |
| - size: page.pageSize, |
165 |
| - appId:this.appId, |
166 |
| - }, params)).then(response => { |
167 |
| - let tableData = response.data.items |
168 |
| - tableData.forEach(item => { |
169 |
| - item.mediaId = item.articleId |
170 |
| - item.content.articles = item.content.newsItem |
171 |
| - }) |
172 |
| - this.list = tableData |
173 |
| - this.page.total = response.data.totalCount |
174 |
| - this.page.currentPage = page.currentPage |
175 |
| - this.page.pageSize = page.pageSize |
176 |
| - this.loading = false |
177 |
| - }) |
178 |
| - }else if(this.newsType == '2'){ |
179 |
| - getPageNewsDraft(Object.assign({ |
180 |
| - current: page.currentPage, |
181 |
| - size: page.pageSize, |
182 |
| - appId:this.appId, |
183 |
| - }, params)).then(response => { |
184 |
| - let tableData = response.data.items |
185 |
| - tableData.forEach(item => { |
186 |
| - item.mediaId = item.mediaId |
187 |
| - item.content.articles = item.content.newsItem |
188 |
| - }) |
189 |
| - this.list = tableData |
190 |
| - this.page.total = response.data.totalCount |
191 |
| - this.page.currentPage = page.currentPage |
192 |
| - this.page.pageSize = page.pageSize |
193 |
| - this.loading = false |
| 152 | + if (this.objData.type === 'news' && this.newsType === '1') { // 【图文】+ 【已发布】 |
| 153 | + this.getFreePublishPage(); |
| 154 | + } else if (this.objData.type === 'news' && this.newsType === '2') { // 【图文】+ 【草稿】 |
| 155 | + getPageNewsDraft(Object.assign({ |
| 156 | + current: page.currentPage, |
| 157 | + size: page.pageSize, |
| 158 | + appId:this.appId, |
| 159 | + }, params)).then(response => { |
| 160 | + let tableData = response.data.items |
| 161 | + tableData.forEach(item => { |
| 162 | + item.mediaId = item.mediaId |
| 163 | + item.content.articles = item.content.newsItem |
194 | 164 | })
|
195 |
| - } |
| 165 | + this.list = tableData |
| 166 | + this.page.total = response.data.totalCount |
| 167 | + this.page.currentPage = page.currentPage |
| 168 | + this.page.pageSize = page.pageSize |
| 169 | + this.loading = false |
| 170 | + }) |
196 | 171 | } else { // 【素材】
|
197 | 172 | this.getMaterialPage();
|
198 | 173 | }
|
|
208 | 183 | this.loading = false
|
209 | 184 | })
|
210 | 185 | },
|
211 |
| - sizeChange(val) { |
212 |
| - this.page.currentPage = 1 |
213 |
| - this.page.pageSize = val |
214 |
| - this.getPage(this.page) |
215 |
| - }, |
216 |
| - currentChange(val) { |
217 |
| - this.page.currentPage = val |
218 |
| - this.getPage(this.page) |
219 |
| - }, |
220 |
| - /** |
221 |
| - * 刷新回调 |
222 |
| - */ |
223 |
| - refreshChange(page) { |
224 |
| - this.getPage(this.page) |
| 186 | + getFreePublishPage() { |
| 187 | + getFreePublishPage(this.queryParams).then(response => { |
| 188 | + // 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面 |
| 189 | + response.data.list.forEach(item => { |
| 190 | + const newsItem = item.content.newsItem; |
| 191 | + newsItem.forEach(article => { |
| 192 | + article.picUrl = article.thumbUrl; |
| 193 | + }) |
| 194 | + }) |
| 195 | + this.list = response.data.list |
| 196 | + this.total = response.data.total |
| 197 | + }).finally(() => { |
| 198 | + this.loading = false |
| 199 | + }) |
225 | 200 | }
|
226 | 201 | }
|
227 | 202 | };
|
|
0 commit comments