index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <!--
  2. MIT License
  3. Copyright (c) 2020 www.joolun.com
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.
  19. 芋道源码:
  20. ① 优化代码,和项目的代码保持一致
  21. -->
  22. <template>
  23. <div class="app-container">
  24. <!-- 搜索工作栏 -->
  25. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  26. <el-form-item label="公众号" prop="accountId">
  27. <el-select v-model="queryParams.accountId" placeholder="请选择公众号">
  28. <el-option v-for="item in accounts" :key="parseInt(item.id)" :label="item.name" :value="parseInt(item.id)" />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <!-- 列表 -->
  37. <div class="waterfall" v-loading="loading">
  38. <div v-if="item.content && item.content.newsItem" class="waterfall-item" v-for="item in list"
  39. :key='item.articleId'>
  40. <wx-news :articles="item.content.newsItem" />
  41. <!-- 操作 -->
  42. <el-row class="ope-row">
  43. <el-button type="danger" icon="el-icon-delete" circle @click="handleDelete(item)"
  44. v-hasPermi="['mp:free-publish:delete']" />
  45. </el-row>
  46. </div>
  47. </div>
  48. <!-- 分页组件 -->
  49. <div v-if="list.length <=0 && !loading" class="el-table__empty-block">
  50. <span class="el-table__empty-text">暂无数据</span>
  51. </div>
  52. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  53. @pagination="getList"/>
  54. </div>
  55. </template>
  56. <script>
  57. import { getFreePublishPage, deleteFreePublish } from "@/api/mp/freePublish";
  58. import { getSimpleAccounts } from "@/api/mp/account";
  59. import WxNews from '@/views/mp/components/wx-news/main.vue';
  60. export default {
  61. name: 'mpDraft',
  62. components: {
  63. WxNews
  64. },
  65. data() {
  66. return {
  67. // 遮罩层
  68. loading: false,
  69. // 显示搜索条件
  70. showSearch: true,
  71. // 总条数
  72. total: 0,
  73. // 已发表列表
  74. list: [],
  75. // 查询参数
  76. queryParams: {
  77. total: 0, // 总页数
  78. currentPage: 1, // 当前页数
  79. queryParamsSize: 10 // 每页显示多少条
  80. },
  81. // 公众号账号列表
  82. accounts: [],
  83. }
  84. },
  85. created() {
  86. getSimpleAccounts().then(response => {
  87. this.accounts = response.data;
  88. // 默认选中第一个
  89. if (this.accounts.length > 0) {
  90. this.queryParams.accountId = this.accounts[0].id;
  91. }
  92. // 加载数据
  93. this.getList();
  94. })
  95. },
  96. methods: {
  97. /** 查询列表 */
  98. getList() {
  99. // 如果没有选中公众号账号,则进行提示。
  100. if (!this.queryParams.accountId) {
  101. this.$message.error('未选中公众号,无法查询已发表图文')
  102. return false
  103. }
  104. this.loading = true;
  105. getFreePublishPage(this.queryParams).then(response => {
  106. // 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面
  107. response.data.list.forEach(item => {
  108. const newsItem = item.content.newsItem;
  109. newsItem.forEach(article => {
  110. article.picUrl = article.thumbUrl;
  111. })
  112. })
  113. this.list = response.data.list
  114. this.total = response.data.total
  115. }).finally(() => {
  116. this.loading = false
  117. })
  118. },
  119. /** 搜索按钮操作 */
  120. handleQuery() {
  121. this.queryParams.pageNo = 1;
  122. this.getList();
  123. },
  124. /** 重置按钮操作 */
  125. resetQuery() {
  126. this.resetForm("queryForm");
  127. // 默认选中第一个
  128. if (this.accounts.length > 0) {
  129. this.queryParams.accountId = this.accounts[0].id;
  130. }
  131. this.handleQuery();
  132. },
  133. /** 删除按钮操作 */
  134. handleDelete(item){
  135. const articleId = item.articleId;
  136. const accountId = this.queryParams.accountId;
  137. this.$modal.confirm('删除后用户将无法访问此页面,确定删除?').then(function() {
  138. return deleteFreePublish(accountId, articleId);
  139. }).then(() => {
  140. this.getList();
  141. this.$modal.msgSuccess("删除成功");
  142. }).catch(() => {});
  143. },
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .pagination {
  149. float: right;
  150. margin-right: 25px;
  151. }
  152. .add_but {
  153. padding: 10px;
  154. }
  155. .ope-row {
  156. margin-top: 5px;
  157. text-align: center;
  158. border-top: 1px solid #eaeaea;
  159. padding-top: 5px;
  160. }
  161. .item-name {
  162. font-size: 12px;
  163. overflow: hidden;
  164. text-overflow: ellipsis;
  165. white-space: nowrap;
  166. text-align: center;
  167. }
  168. .el-upload__tip {
  169. margin-left: 5px;
  170. }
  171. /*新增图文*/
  172. .left {
  173. display: inline-block;
  174. width: 35%;
  175. vertical-align: top;
  176. margin-top: 200px;
  177. }
  178. .right {
  179. display: inline-block;
  180. width: 60%;
  181. margin-top: -40px;
  182. }
  183. .avatar-uploader {
  184. width: 20%;
  185. display: inline-block;
  186. }
  187. .avatar-uploader .el-upload {
  188. border-radius: 6px;
  189. cursor: pointer;
  190. position: relative;
  191. overflow: hidden;
  192. text-align: unset !important;
  193. }
  194. .avatar-uploader .el-upload:hover {
  195. border-color: #165dff;
  196. }
  197. .avatar-uploader-icon {
  198. border: 1px solid #d9d9d9;
  199. font-size: 28px;
  200. color: #8c939d;
  201. width: 120px;
  202. height: 120px;
  203. line-height: 120px;
  204. text-align: center;
  205. }
  206. .avatar {
  207. width: 230px;
  208. height: 120px;
  209. }
  210. .avatar1 {
  211. width: 120px;
  212. height: 120px;
  213. }
  214. .digest {
  215. width: 60%;
  216. display: inline-block;
  217. vertical-align: top;
  218. }
  219. /*新增图文*/
  220. /*瀑布流样式*/
  221. .waterfall {
  222. width: 100%;
  223. column-gap: 10px;
  224. column-count: 5;
  225. margin: 0 auto;
  226. }
  227. .waterfall-item {
  228. padding: 10px;
  229. margin-bottom: 10px;
  230. break-inside: avoid;
  231. border: 1px solid #eaeaea;
  232. }
  233. p {
  234. line-height: 30px;
  235. }
  236. @media (min-width: 992px) and (max-width: 1300px) {
  237. .waterfall {
  238. column-count: 3;
  239. }
  240. p {
  241. color: red;
  242. }
  243. }
  244. @media (min-width: 768px) and (max-width: 991px) {
  245. .waterfall {
  246. column-count: 2;
  247. }
  248. p {
  249. color: orange;
  250. }
  251. }
  252. @media (max-width: 767px) {
  253. .waterfall {
  254. column-count: 1;
  255. }
  256. }
  257. /*瀑布流样式*/
  258. .news-main {
  259. background-color: #FFFFFF;
  260. width: 100%;
  261. margin: auto;
  262. height: 120px;
  263. }
  264. .news-content {
  265. background-color: #acadae;
  266. width: 100%;
  267. height: 120px;
  268. position: relative;
  269. }
  270. .news-content-title {
  271. display: inline-block;
  272. font-size: 15px;
  273. color: #FFFFFF;
  274. position: absolute;
  275. left: 0px;
  276. bottom: 0px;
  277. background-color: black;
  278. width: 98%;
  279. padding: 1%;
  280. opacity: 0.65;
  281. overflow: hidden;
  282. text-overflow: ellipsis;
  283. white-space: nowrap;
  284. height: 25px;
  285. }
  286. .news-main-item {
  287. background-color: #FFFFFF;
  288. padding: 5px 0px;
  289. border-top: 1px solid #eaeaea;
  290. width: 100%;
  291. margin: auto;
  292. }
  293. .news-content-item {
  294. position: relative;
  295. margin-left: -3px
  296. }
  297. .news-content-item-title {
  298. display: inline-block;
  299. font-size: 12px;
  300. width: 70%;
  301. }
  302. .news-content-item-img {
  303. display: inline-block;
  304. width: 25%;
  305. background-color: #acadae
  306. }
  307. .input-tt {
  308. padding: 5px;
  309. }
  310. .activeAddNews {
  311. border: 5px solid #2bb673;
  312. }
  313. .news-main-plus {
  314. width: 280px;
  315. text-align: center;
  316. margin: auto;
  317. height: 50px;
  318. }
  319. .icon-plus {
  320. margin: 10px;
  321. font-size: 25px;
  322. }
  323. .select-item {
  324. width: 60%;
  325. padding: 10px;
  326. margin: 0 auto 10px auto;
  327. border: 1px solid #eaeaea;
  328. }
  329. .father .child {
  330. display: none;
  331. text-align: center;
  332. position: relative;
  333. bottom: 25px;
  334. }
  335. .father:hover .child {
  336. display: block;
  337. }
  338. .thumb-div {
  339. display: inline-block;
  340. width: 30%;
  341. text-align: center;
  342. }
  343. .thumb-but {
  344. margin: 5px;
  345. }
  346. .material-img {
  347. width: 100%;
  348. height: 100%;
  349. }
  350. </style>