index.vue 6.8 KB

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