index.vue 6.8 KB

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