main.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <!--
  2. - Copyright (C) 2018-2019
  3. - All rights reserved, Designed By www.joolun.com
  4. -->
  5. <template>
  6. <!-- 类型:图片 -->
  7. <div v-if="objData.type === 'image'">
  8. <div class="waterfall" v-loading="loading">
  9. <div class="waterfall-item" v-for="item in list" :key="item.mediaId">
  10. <img class="material-img" :src="item.url">
  11. <p class="item-name">{{item.name}}</p>
  12. <el-row class="ope-row">
  13. <el-button size="mini" type="success" @click="selectMaterial(item)">选择
  14. <i class="el-icon-circle-check el-icon--right"></i>
  15. </el-button>
  16. </el-row>
  17. </div>
  18. </div>
  19. <!-- 分页组件 -->
  20. <div v-if="list.length <= 0 && !loading" class="el-table__empty-block">
  21. <span class="el-table__empty-text">暂无数据</span>
  22. </div>
  23. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  24. @pagination="getMaterialPage"/>
  25. </div>
  26. <div v-else-if="objData.type == 'voice'">
  27. <!-- TODO 芋艿:需要翻译 -->
  28. <!-- <avue-crud ref="crud"-->
  29. <!-- :page="page"-->
  30. <!-- :data="tableData"-->
  31. <!-- :table-loading="tableLoading"-->
  32. <!-- :option="tableOptionVoice"-->
  33. <!-- @on-load="getPage"-->
  34. <!-- @size-change="sizeChange"-->
  35. <!-- @refresh-change="refreshChange">-->
  36. <!-- <template slot-scope="scope"-->
  37. <!-- slot="menu">-->
  38. <!-- <el-button type="text"-->
  39. <!-- icon="el-icon-circle-plus"-->
  40. <!-- size="small"-->
  41. <!-- plain-->
  42. <!-- @click="selectMaterial(scope.row)">选择</el-button>-->
  43. <!-- </template>-->
  44. <!-- </avue-crud>-->
  45. </div>
  46. <div v-else-if="objData.type == 'video'">
  47. <!-- TODO 芋艿:需要翻译 -->
  48. <!-- <avue-crud ref="crud"-->
  49. <!-- :page="page"-->
  50. <!-- :data="tableData"-->
  51. <!-- :table-loading="tableLoading"-->
  52. <!-- :option="tableOptionVideo"-->
  53. <!-- @on-load="getPage"-->
  54. <!-- @size-change="sizeChange"-->
  55. <!-- @refresh-change="refreshChange">-->
  56. <!-- <template slot-scope="scope"-->
  57. <!-- slot="menu">-->
  58. <!-- <el-button type="text"-->
  59. <!-- icon="el-icon-circle-plus"-->
  60. <!-- size="small"-->
  61. <!-- plain-->
  62. <!-- @click="selectMaterial(scope.row)">选择</el-button>-->
  63. <!-- </template>-->
  64. <!-- </avue-crud>-->
  65. </div>
  66. <div v-else-if="objData.type == 'news'">
  67. <div class="waterfall" v-loading="loading">
  68. <div class="waterfall-item" v-for="item in list" :key="item.mediaId" v-if="item.content && item.content.articles">
  69. <WxNews :objData="item.content.articles"></WxNews>
  70. <el-row class="ope-row">
  71. <el-button size="mini" type="success" @click="selectMaterial(item)">选择<i class="el-icon-circle-check el-icon--right"></i></el-button>
  72. </el-row>
  73. </div>
  74. </div>
  75. <div v-if="list.length <=0 && !loading" class="el-table__empty-block">
  76. <span class="el-table__empty-text">暂无数据</span>
  77. </div>
  78. <span slot="footer" class="dialog-footer">
  79. <el-pagination
  80. @size-change="sizeChange"
  81. :current-page.sync="page.currentPage"
  82. :page-sizes="[10, 20]"
  83. :page-size="page.pageSize"
  84. layout="total, sizes, prev, pager, next, jumper"
  85. :total="page.total"
  86. class="pagination"
  87. >
  88. </el-pagination>
  89. </span>
  90. </div>
  91. </template>
  92. <script>
  93. // import { tableOptionVoice } from '@/const/crud/wxmp/wxmaterial_voice'
  94. // import { tableOptionVideo } from '@/const/crud/wxmp/wxmaterial_video'
  95. import WxNews from '@/views/mp/components/wx-news/main.vue';
  96. import { getMaterialPage } from "@/api/mp/material";
  97. // import {getPage as getPageNews} from '@/api/wxmp/wxfreepublish'
  98. // import {getPage as getPageNewsDraft} from '@/api/wxmp/wxdraft'
  99. export default {
  100. name: "wxMaterialSelect",
  101. components: {
  102. WxNews
  103. },
  104. props: {
  105. objData: {
  106. type: Object,
  107. required: true
  108. },
  109. //图文类型:1、已发布图文;2、草稿箱图文
  110. newsType:{
  111. type: String,
  112. default: "1"
  113. },
  114. },
  115. data() {
  116. return {
  117. // 遮罩层
  118. loading: false,
  119. // 总条数
  120. total: 0,
  121. // 数据列表
  122. list: [],
  123. // 查询参数
  124. queryParams: {
  125. pageNo: 1,
  126. pageSize: 10,
  127. },
  128. // tableOptionVoice: tableOptionVoice,
  129. // tableOptionVideo: tableOptionVideo,
  130. }
  131. },
  132. created() {
  133. this.getPage(this.page)
  134. },
  135. methods:{
  136. selectMaterial(item){
  137. this.$emit('selectMaterial', item)
  138. },
  139. getPage(page, params) {
  140. this.loading = true
  141. if(this.objData.type == 'news'){ // 【图文】
  142. if(this.newsType == '1'){
  143. getPageNews(Object.assign({
  144. current: page.currentPage,
  145. size: page.pageSize,
  146. appId:this.appId,
  147. }, params)).then(response => {
  148. let tableData = response.data.items
  149. tableData.forEach(item => {
  150. item.mediaId = item.articleId
  151. item.content.articles = item.content.newsItem
  152. })
  153. this.list = tableData
  154. this.page.total = response.data.totalCount
  155. this.page.currentPage = page.currentPage
  156. this.page.pageSize = page.pageSize
  157. this.loading = false
  158. })
  159. }else if(this.newsType == '2'){
  160. getPageNewsDraft(Object.assign({
  161. current: page.currentPage,
  162. size: page.pageSize,
  163. appId:this.appId,
  164. }, params)).then(response => {
  165. let tableData = response.data.items
  166. tableData.forEach(item => {
  167. item.mediaId = item.mediaId
  168. item.content.articles = item.content.newsItem
  169. })
  170. this.list = tableData
  171. this.page.total = response.data.totalCount
  172. this.page.currentPage = page.currentPage
  173. this.page.pageSize = page.pageSize
  174. this.loading = false
  175. })
  176. }
  177. } else { // 【素材】
  178. this.getMaterialPage();
  179. }
  180. },
  181. getMaterialPage() {
  182. getMaterialPage({
  183. ...this.queryParams,
  184. type: this.objData.type
  185. }).then(response => {
  186. this.list = response.data.list
  187. this.total = response.data.total
  188. }).finally(() => {
  189. this.loading = false
  190. })
  191. },
  192. sizeChange(val) {
  193. this.page.currentPage = 1
  194. this.page.pageSize = val
  195. this.getPage(this.page)
  196. },
  197. currentChange(val) {
  198. this.page.currentPage = val
  199. this.getPage(this.page)
  200. },
  201. /**
  202. * 刷新回调
  203. */
  204. refreshChange(page) {
  205. this.getPage(this.page)
  206. }
  207. }
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. /*瀑布流样式*/
  212. .waterfall {
  213. width: 100%;
  214. column-gap:10px;
  215. column-count: 5;
  216. margin: 0 auto;
  217. }
  218. .waterfall-item {
  219. padding: 10px;
  220. margin-bottom: 10px;
  221. break-inside: avoid;
  222. border: 1px solid #eaeaea;
  223. }
  224. .material-img {
  225. width: 100%;
  226. }
  227. p {
  228. line-height: 30px;
  229. }
  230. @media (min-width: 992px) and (max-width: 1300px) {
  231. .waterfall {
  232. column-count: 3;
  233. }
  234. p {
  235. color:red;
  236. }
  237. }
  238. @media (min-width: 768px) and (max-width: 991px) {
  239. .waterfall {
  240. column-count: 2;
  241. }
  242. p {
  243. color: orange;
  244. }
  245. }
  246. @media (max-width: 767px) {
  247. .waterfall {
  248. column-count: 1;
  249. }
  250. }
  251. /*瀑布流样式*/
  252. </style>