index.vue 5.8 KB

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