index.vue 7.4 KB

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