index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <!-- 搜索工作栏 -->
  3. <ContentWrap>
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="公众号" prop="accountId">
  12. <WxAccountSelect @change="onAccountChanged" />
  13. </el-form-item>
  14. </el-form>
  15. </ContentWrap>
  16. <!-- 列表 -->
  17. <ContentWrap>
  18. <div class="waterfall" v-loading="loading">
  19. <div
  20. class="waterfall-item"
  21. v-show="item.content && item.content.newsItem"
  22. v-for="item in list"
  23. :key="item.articleId"
  24. >
  25. <wx-news :articles="item.content.newsItem" />
  26. <el-row justify="center" class="ope-row">
  27. <el-button
  28. type="danger"
  29. circle
  30. @click="handleDelete(item)"
  31. v-hasPermi="['mp:free-publish:delete']"
  32. >
  33. <Icon icon="ep:delete" />
  34. </el-button>
  35. </el-row>
  36. </div>
  37. </div>
  38. <!-- 分页 -->
  39. <Pagination
  40. :total="total"
  41. v-model:page="queryParams.pageNo"
  42. v-model:limit="queryParams.pageSize"
  43. @pagination="getList"
  44. />
  45. </ContentWrap>
  46. </template>
  47. <script lang="ts" setup>
  48. import * as FreePublishApi from '@/api/mp/freePublish'
  49. import WxNews from '@/views/mp/components/wx-news'
  50. import WxAccountSelect from '@/views/mp/components/wx-account-select'
  51. defineOptions({ name: 'MpFreePublish' })
  52. const message = useMessage() // 消息弹窗
  53. const { t } = useI18n() // 国际化
  54. const loading = ref(true) // 列表的加载中
  55. const total = ref(0) // 列表的总页数
  56. const list = ref<any[]>([]) // 列表的数据
  57. const queryParams = reactive({
  58. pageNo: 1,
  59. pageSize: 10,
  60. accountId: -1
  61. })
  62. /** 侦听公众号变化 **/
  63. const onAccountChanged = (id: number) => {
  64. queryParams.accountId = id
  65. queryParams.pageNo = 1
  66. getList()
  67. }
  68. /** 查询列表 */
  69. const getList = async () => {
  70. try {
  71. loading.value = true
  72. const data = await FreePublishApi.getFreePublishPage(queryParams)
  73. list.value = data.list
  74. total.value = data.total
  75. } finally {
  76. loading.value = false
  77. }
  78. }
  79. /** 删除按钮操作 */
  80. const handleDelete = async (item: any) => {
  81. try {
  82. // 删除的二次确认
  83. await message.delConfirm('删除后用户将无法访问此页面,确定删除?')
  84. // 发起删除
  85. await FreePublishApi.deleteFreePublish(queryParams.accountId, item.articleId)
  86. message.success(t('common.delSuccess'))
  87. // 刷新列表
  88. await getList()
  89. } catch {}
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. @media (width >= 992px) and (width <= 1300px) {
  94. .waterfall {
  95. column-count: 3;
  96. }
  97. p {
  98. color: red;
  99. }
  100. }
  101. @media (width >= 768px) and (width <= 991px) {
  102. .waterfall {
  103. column-count: 2;
  104. }
  105. p {
  106. color: orange;
  107. }
  108. }
  109. @media (width <= 767px) {
  110. .waterfall {
  111. column-count: 1;
  112. }
  113. }
  114. .ope-row {
  115. padding-top: 5px;
  116. margin-top: 5px;
  117. text-align: center;
  118. border-top: 1px solid #eaeaea;
  119. }
  120. .item-name {
  121. overflow: hidden;
  122. font-size: 12px;
  123. text-align: center;
  124. text-overflow: ellipsis;
  125. white-space: nowrap;
  126. }
  127. .el-upload__tip {
  128. margin-left: 5px;
  129. }
  130. /* 新增图文 */
  131. .left {
  132. display: inline-block;
  133. width: 35%;
  134. margin-top: 200px;
  135. vertical-align: top;
  136. }
  137. .right {
  138. display: inline-block;
  139. width: 60%;
  140. margin-top: -40px;
  141. }
  142. .avatar-uploader {
  143. display: inline-block;
  144. width: 20%;
  145. }
  146. .avatar-uploader .el-upload {
  147. position: relative;
  148. overflow: hidden;
  149. text-align: unset !important;
  150. cursor: pointer;
  151. border-radius: 6px;
  152. }
  153. .avatar-uploader .el-upload:hover {
  154. border-color: #165dff;
  155. }
  156. .avatar-uploader-icon {
  157. width: 120px;
  158. height: 120px;
  159. font-size: 28px;
  160. line-height: 120px;
  161. color: #8c939d;
  162. text-align: center;
  163. border: 1px solid #d9d9d9;
  164. }
  165. .avatar {
  166. width: 230px;
  167. height: 120px;
  168. }
  169. .avatar1 {
  170. width: 120px;
  171. height: 120px;
  172. }
  173. .digest {
  174. display: inline-block;
  175. width: 60%;
  176. vertical-align: top;
  177. }
  178. /* 新增图文 */
  179. /* 瀑布流样式 */
  180. .waterfall {
  181. width: 100%;
  182. column-gap: 10px;
  183. column-count: 5;
  184. margin: 0 auto;
  185. }
  186. .waterfall-item {
  187. padding: 10px;
  188. margin-bottom: 10px;
  189. break-inside: avoid;
  190. border: 1px solid #eaeaea;
  191. }
  192. p {
  193. line-height: 30px;
  194. }
  195. /* 瀑布流样式 */
  196. .news-main {
  197. width: 100%;
  198. height: 120px;
  199. margin: auto;
  200. background-color: #fff;
  201. }
  202. .news-content {
  203. position: relative;
  204. width: 100%;
  205. height: 120px;
  206. background-color: #acadae;
  207. }
  208. .news-content-title {
  209. position: absolute;
  210. bottom: 0;
  211. left: 0;
  212. display: inline-block;
  213. width: 98%;
  214. height: 25px;
  215. padding: 1%;
  216. overflow: hidden;
  217. font-size: 15px;
  218. color: #fff;
  219. text-overflow: ellipsis;
  220. white-space: nowrap;
  221. background-color: black;
  222. opacity: 0.65;
  223. }
  224. .news-main-item {
  225. width: 100%;
  226. padding: 5px 0;
  227. margin: auto;
  228. background-color: #fff;
  229. border-top: 1px solid #eaeaea;
  230. }
  231. .news-content-item {
  232. position: relative;
  233. margin-left: -3px;
  234. }
  235. .news-content-item-title {
  236. display: inline-block;
  237. width: 70%;
  238. font-size: 12px;
  239. }
  240. .news-content-item-img {
  241. display: inline-block;
  242. width: 25%;
  243. background-color: #acadae;
  244. }
  245. .input-tt {
  246. padding: 5px;
  247. }
  248. .activeAddNews {
  249. border: 5px solid #2bb673;
  250. }
  251. .news-main-plus {
  252. width: 280px;
  253. height: 50px;
  254. margin: auto;
  255. text-align: center;
  256. }
  257. .icon-plus {
  258. margin: 10px;
  259. font-size: 25px;
  260. }
  261. .select-item {
  262. width: 60%;
  263. padding: 10px;
  264. margin: 0 auto 10px;
  265. border: 1px solid #eaeaea;
  266. }
  267. .father .child {
  268. position: relative;
  269. bottom: 25px;
  270. display: none;
  271. text-align: center;
  272. }
  273. .father:hover .child {
  274. display: block;
  275. }
  276. .thumb-div {
  277. display: inline-block;
  278. width: 30%;
  279. text-align: center;
  280. }
  281. .thumb-but {
  282. margin: 5px;
  283. }
  284. .material-img {
  285. width: 100%;
  286. height: 100%;
  287. }
  288. </style>