PostList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <el-row>
  3. <el-col :md="2">
  4. <el-menu
  5. :default-active="this.$route.path"
  6. router
  7. class="el-menu-vertical-demo"
  8. >
  9. <el-menu-item v-for="(item,i) in navList" :key="i" :index="item.path">
  10. <i :class="item.icon" />
  11. <span slot="title">{{ item.name }}</span>
  12. </el-menu-item>
  13. </el-menu>
  14. </el-col>
  15. <el-col :md="22">
  16. <el-tabs v-model="activeName" @tab-click='tabClick'>
  17. <el-tab-pane label="视频" name="video">
  18. <el-row :md="6" :sm="12" :xs="12">
  19. <el-table
  20. :data="dataList"
  21. style="width: 100%"
  22. >
  23. <el-table-column
  24. type="index">
  25. </el-table-column>
  26. <el-table-column
  27. prop="pubDate"
  28. label="发布时间">
  29. </el-table-column>
  30. <el-table-column
  31. prop="coverUrl"
  32. label="封面"
  33. width="80">
  34. <template slot-scope="scope">
  35. <el-image :src="scope.row.coverUrl" min-width="40" height="30" />
  36. </template>
  37. </el-table-column>
  38. <el-table-column
  39. prop="videoId"
  40. label="视频 ID">
  41. <template slot-scope="scope">
  42. <router-link target="_blank" :to="`/video/${scope.row.videoId}`">
  43. <span>{{scope.row.videoId}}</span>
  44. </router-link>
  45. </template>
  46. </el-table-column>
  47. <el-table-column
  48. prop="title"
  49. label="标题">
  50. </el-table-column>
  51. <el-table-column
  52. prop="description"
  53. label="描述">
  54. </el-table-column>
  55. <el-table-column
  56. prop="scope"
  57. label="可见范围">
  58. <template slot-scope="scope">
  59. <el-tooltip class="item" effect="dark" content="点击修改视频可见范围" placement="top-end">
  60. <el-button
  61. v-if="scope.row.scope === 1"
  62. size="mini"
  63. @click="handleScope(scope.$index, scope.row)">所有人可见</el-button>
  64. <el-button
  65. v-else-if="scope.row.scope === 2"
  66. size="mini"
  67. type="success"
  68. @click="handleScope(scope.$index, scope.row)">VIP 可见</el-button>
  69. <el-button
  70. v-else-if="scope.row.scope === 3"
  71. size="mini"
  72. type="warning"
  73. @click="handleScope(scope.$index, scope.row)">验证码可见</el-button>
  74. <el-button
  75. v-else
  76. size="mini"
  77. type="danger"
  78. @click="handleScope(scope.$index, scope.row)">本人可见</el-button>
  79. </el-tooltip>
  80. </template>
  81. </el-table-column>
  82. <el-table-column
  83. prop="scope"
  84. label="审核状态">
  85. <template slot-scope="scope">
  86. <el-tag v-if="scope.row.status === 1" :type="'warning'" disable-transitions>
  87. 审核中
  88. </el-tag>
  89. <el-tag v-else-if="scope.row.status === 2" :type="'success'" disable-transitions>
  90. 审核通过
  91. </el-tag>
  92. <el-tag v-else :type="'danger'" disable-transitions>
  93. 审核未通过
  94. </el-tag>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="操作" width="210">
  98. <template slot-scope="scope">
  99. <el-button
  100. size="mini"
  101. @click="handlePreview(scope.$index, scope.row)">预览</el-button>
  102. <el-button
  103. size="mini"
  104. @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  105. <el-button
  106. size="mini"
  107. type="danger"
  108. @click="handleDelete(scope.$index, scope.row)">删除</el-button>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. </el-row>
  113. </el-tab-pane>
  114. <el-tab-pane label="相册" name="image">
  115. <el-row :md="6" :sm="12" :xs="12">
  116. <el-table
  117. :data="dataList"
  118. style="width: 100%"
  119. >
  120. <el-table-column
  121. type="index">
  122. </el-table-column>
  123. <el-table-column
  124. prop="coverUrl"
  125. label="相册封面"
  126. width="150">
  127. <template slot-scope="scope">
  128. <el-image :src="scope.row.coverUrl" min-width="40" height="30" />
  129. </template>
  130. </el-table-column>
  131. <el-table-column
  132. prop="pubDate"
  133. label="发布时间">
  134. </el-table-column>
  135. <el-table-column
  136. prop="albumName"
  137. label="相册名字"
  138. width="180">
  139. </el-table-column>
  140. <el-table-column
  141. prop="total"
  142. label="图片数量">
  143. </el-table-column>
  144. <el-table-column
  145. prop="scope"
  146. label="可见范围">
  147. <template slot-scope="scope">
  148. <el-tag v-if="scope.row.viewCount === 1" disable-transitions>
  149. 全部可见
  150. </el-tag>
  151. <el-tag v-else-if="scope.row.viewCount === 2" :type="'success'" disable-transitions>
  152. VIP 可见
  153. </el-tag>
  154. <el-tag v-else-if="scope.row.viewCount === 3" :type="'warning'" disable-transitions>
  155. 验证码可见
  156. </el-tag>
  157. <el-tag v-else :type="'danger'" disable-transitions>
  158. 本人可见
  159. </el-tag>
  160. </template>
  161. </el-table-column>
  162. <el-table-column label="操作">
  163. <template slot-scope="scope">
  164. <el-button
  165. size="mini"
  166. @click="handleEditImage(scope.$index, scope.row)">编辑</el-button>
  167. <el-button
  168. size="mini"
  169. type="danger"
  170. @click="handleDeleteImage(scope.$index, scope.row)">删除</el-button>
  171. </template>
  172. </el-table-column>
  173. </el-table>
  174. </el-row>
  175. </el-tab-pane>
  176. <el-tab-pane label="音频" name="audio">
  177. <el-row :md="6" :sm="12" :xs="12">
  178. <el-table
  179. :data="dataList"
  180. style="width: 100%"
  181. >
  182. <el-table-column
  183. type="index">
  184. </el-table-column>
  185. <el-table-column
  186. prop="coverUrl"
  187. label="音频封面"
  188. width="150">
  189. <template slot-scope="scope">
  190. <el-image :src="scope.row.coverUrl" min-width="40" height="30" />
  191. </template>
  192. </el-table-column>
  193. <el-table-column
  194. prop="pubDate"
  195. label="发布时间">
  196. </el-table-column>
  197. <el-table-column
  198. prop="title"
  199. label="音频名字">
  200. </el-table-column>
  201. <!-- <el-table-column
  202. prop="description"
  203. label="音频简介">
  204. </el-table-column>-->
  205. <el-table-column
  206. prop="scope"
  207. label="可见范围">
  208. <template slot-scope="scope">
  209. <el-tag v-if="scope.row.viewCount === 1" disable-transitions>
  210. 全部可见
  211. </el-tag>
  212. <el-tag v-else-if="scope.row.viewCount === 2" :type="'success'" disable-transitions>
  213. VIP 可见
  214. </el-tag>
  215. <el-tag v-else-if="scope.row.viewCount === 3" :type="'warning'" disable-transitions>
  216. 验证码可见
  217. </el-tag>
  218. <el-tag v-else :type="'danger'" disable-transitions>
  219. 本人可见
  220. </el-tag>
  221. </template>
  222. </el-table-column>
  223. <el-table-column label="操作">
  224. <template slot-scope="scope">
  225. <el-button
  226. size="mini"
  227. @click="handleEditAudio(scope.$index, scope.row)">编辑</el-button>
  228. <el-button
  229. size="mini"
  230. type="danger"
  231. @click="handleDeleteAudio(scope.$index, scope.row)">删除</el-button>
  232. </template>
  233. </el-table-column>
  234. </el-table>
  235. </el-row>
  236. </el-tab-pane>
  237. <el-tab-pane label="文章" name="article">
  238. <span>
  239. <h4>文章稿件</h4>
  240. </span>
  241. </el-tab-pane>
  242. </el-tabs>
  243. </el-col>
  244. <!-- 修改视频可见范围对话框 -->
  245. <el-dialog
  246. append-to-body
  247. :visible.sync="showEditScopeDialog"
  248. width="30%"
  249. center
  250. >
  251. <el-card class="box-card">
  252. <div slot="header" class="clearfix">
  253. <span>修改视频可见范围</span>
  254. <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateVideoScope">更新</el-button>
  255. </div>
  256. <div class="text item">
  257. <el-form ref="form" :model="form" label-width="80px">
  258. <el-form-item label="可见范围">
  259. <el-select v-model="form.scope" placeholder="选择可见范围">
  260. <el-option label="所有人可见" value="1" />
  261. <el-option label="验证码可见" value="2" />
  262. <el-option label="VIP 可见" value="3" />
  263. <el-option label="仅自己可见" value="4" />
  264. </el-select>
  265. </el-form-item>
  266. </el-form>
  267. </div>
  268. </el-card>
  269. </el-dialog>
  270. <!-- 视频预览对话框 -->
  271. <el-dialog
  272. title="预览视频"
  273. append-to-body
  274. :visible.sync="showPreviewDialog"
  275. :before-close="handleDialogClose"
  276. width="70%"
  277. center
  278. >
  279. <template>
  280. <video-preview-player :video-prop.sync="this.videoProp"/>
  281. </template>
  282. </el-dialog>
  283. </el-row>
  284. </template>
  285. <script>
  286. import VideoPreviewPlayer from 'components/VideoPreviewPlayer'
  287. import {userVideoPost, updateVideoScope, videoInfo, deleteVideo} from "@/api/video";
  288. import {getUserAlbums} from "@/api/image";
  289. import { getUserAudio } from "@/api/audio";
  290. export default {
  291. name: 'PostList',
  292. components: { VideoPreviewPlayer },
  293. data() {
  294. return {
  295. navList: [
  296. { path: '/post/publish', name: '发布', icon: 'el-icon-upload' },
  297. { path: '/post/list', name: '稿件', icon: 'el-icon-files' },
  298. { path: '/post/analysis', name: '数据', icon: 'el-icon-data-analysis' }
  299. ],
  300. activeName: 'video',
  301. userId: 10001,
  302. dataList: [],
  303. showPreviewDialog: false,
  304. videoProp: null,
  305. showEditScopeDialog: false,
  306. form: {
  307. videoId: null,
  308. scope: null
  309. }
  310. }
  311. },
  312. created() {
  313. document.title = "稿件列表"
  314. const path = this.$route.path
  315. if (path.endsWith("video")) {
  316. this.activeName = 'video'
  317. document.title = '视频稿件'
  318. } else if (path.endsWith("image")) {
  319. this.activeName = 'image'
  320. document.title = '图片稿件'
  321. } else if (path.endsWith("audio")) {
  322. this.activeName = 'audio'
  323. document.title = '音频稿件'
  324. } else if (path.endsWith("article")) {
  325. this.activeName = 'article'
  326. document.title = '文章稿件'
  327. }
  328. this.getData()
  329. },
  330. watch: {
  331. $route(){
  332. this.$router.go()
  333. }
  334. },
  335. methods: {
  336. handleScope(index, row) {
  337. this.form.videoId = row.videoId
  338. this.form.scope = row.scope
  339. this.showEditScopeDialog = true
  340. },
  341. handleDialogClose(done) {
  342. this.showPreviewDialog = false
  343. this.videoProp = {
  344. videoId: null,
  345. play: false
  346. }
  347. done()
  348. },
  349. handlePreview(index, row) {
  350. videoInfo(row.videoId).then(res => {
  351. if (res.code === 0) {
  352. this.showPreviewDialog = true
  353. this.videoProp = {
  354. videoId: res.data.videoId,
  355. play: true
  356. }
  357. }
  358. })
  359. console.log('预览 ' + row.videoId);
  360. },
  361. handleEdit(index, row) {
  362. console.log(row.videoId);
  363. const path = '/post/edit/video/' + row.videoId
  364. this.$router.push(path)
  365. },
  366. handleDelete(index, row) {
  367. deleteVideo(row.videoId).then(res => {
  368. if (res.code === 0) {
  369. this.$notify({
  370. title: '提示',
  371. message: '视频稿件已删除',
  372. type: 'warning',
  373. duration: 3000
  374. })
  375. this.$router.go(0)
  376. }
  377. })
  378. },
  379. handleEditImage(index, row) {
  380. console.log(row.videoId);
  381. const path = '/post/edit/album/' + row.albumId
  382. this.$router.push(path)
  383. },
  384. handleDeleteImage(index, row) {
  385. console.log(row.videoId);
  386. },
  387. handleEditAudio(index, row) {
  388. console.log(row.videoId);
  389. const path = '/post/edit/audio/' + row.audioId
  390. this.$router.push(path)
  391. },
  392. handleDeleteAudio(index, row) {
  393. console.log(row.videoId);
  394. },
  395. tabClick(tab) {
  396. this.activeName = tab.name
  397. this.goToTab(this.activeName)
  398. },
  399. goToTab(activeName) {
  400. const path = '/post/' + activeName
  401. if (this.$route.path === path) {
  402. this.$router.go(0)
  403. return
  404. }
  405. this.$router.push(path)
  406. },
  407. getData() {
  408. this.dataList = []
  409. if (this.activeName === 'video') {
  410. userVideoPost(1, this.userId, 1).then(res => {
  411. if (res.code === 0) {
  412. const resData = res.data.list
  413. if (resData.length !== 0) {
  414. this.showEmpty = false
  415. for (const item of resData) {
  416. this.dataList.push(item)
  417. }
  418. } else {
  419. this.showEmpty = true
  420. }
  421. } else {
  422. this.$notify({
  423. title: '提示',
  424. message: res.msg,
  425. type: 'warning',
  426. duration: 3000
  427. })
  428. }
  429. }).catch(error => {
  430. this.$notify({
  431. title: '提示',
  432. message: error.message,
  433. type: 'error',
  434. duration: 3000
  435. })
  436. })
  437. } else if (this.activeName === 'image') {
  438. getUserAlbums(this.userId).then(res => {
  439. if (res.code === 0) {
  440. const resData = res.data
  441. if (resData.length !== 0) {
  442. this.showEmpty = false
  443. for (const item of resData) {
  444. this.dataList.push(item)
  445. }
  446. } else {
  447. this.showEmpty = true
  448. }
  449. }
  450. })
  451. } else if (this.activeName === 'audio') {
  452. this.currentPage = 1
  453. this.lastId = 0
  454. getUserAudio(this.userId).then(res => {
  455. if (res.code === 0) {
  456. const resData = res.data.list
  457. if (resData.length !== 0) {
  458. this.showEmpty = false
  459. for (const item of resData) {
  460. this.dataList.push(item)
  461. }
  462. } else {
  463. this.showEmpty = true
  464. }
  465. }
  466. })
  467. } else if (this.activeName === 'article') {
  468. this.currentPage = 1
  469. this.lastId = 0
  470. }
  471. },
  472. onUpdateVideoScope() {
  473. this.showEditScopeDialog = false
  474. updateVideoScope(this.form).then(res => {
  475. if (res.code === 0) {
  476. this.$notify({
  477. title: '提示',
  478. message: '视频可见范围已更新',
  479. type: 'warning',
  480. duration: 3000
  481. })
  482. }
  483. }).catch(error => {
  484. this.$notify({
  485. title: '提示',
  486. message: error.message,
  487. type: 'warning',
  488. duration: 3000
  489. })
  490. })
  491. }
  492. }
  493. }
  494. </script>
  495. <style>
  496. .uploader-example {
  497. width: 500px;
  498. padding: 15px;
  499. margin: 40px auto 0;
  500. font-size: 12px;
  501. box-shadow: 0 0 10px rgba(0, 0, 0, .4);
  502. }
  503. .uploader-example .uploader-btn {
  504. margin-right: 4px;
  505. }
  506. .uploader-example .uploader-list {
  507. max-height: 440px;
  508. overflow: auto;
  509. overflow-x: hidden;
  510. overflow-y: auto;
  511. }
  512. .avatar-uploader .el-upload {
  513. border: 1px dashed #d9d9d9;
  514. border-radius: 6px;
  515. cursor: pointer;
  516. position: relative;
  517. overflow: hidden;
  518. }
  519. .avatar-uploader .el-upload:hover {
  520. border-color: #409EFF;
  521. }
  522. .avatar-uploader-icon {
  523. font-size: 28px;
  524. color: #8c939d;
  525. width: 320px;
  526. height: 240px;
  527. line-height: 178px;
  528. text-align: center;
  529. }
  530. .avatar {
  531. width: 320px;
  532. height: 240px;
  533. display: block;
  534. }
  535. </style>