AudioPost.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <el-row>
  3. <el-row :md="6" :sm="12" :xs="12">
  4. <el-table
  5. :data="dataList"
  6. style="width: 100%"
  7. >
  8. <el-table-column
  9. type="index">
  10. </el-table-column>
  11. <el-table-column
  12. prop="publishAt"
  13. label="发布时间">
  14. </el-table-column>
  15. <el-table-column
  16. prop="title"
  17. label="音频名字">
  18. <template slot-scope="scope">
  19. <router-link target="_blank" :to="`/audio/${scope.row.audioId}`">
  20. <span>{{scope.row.title}}</span>
  21. </router-link>
  22. </template>
  23. </el-table-column>
  24. <el-table-column
  25. prop="duration"
  26. label="时长">
  27. </el-table-column>
  28. <el-table-column
  29. prop="codec"
  30. label="编码">
  31. </el-table-column>
  32. <el-table-column
  33. prop="scope"
  34. label="可见范围">
  35. <template slot-scope="scope">
  36. <el-tooltip class="item" effect="dark" content="点击修改可见范围" placement="top-end">
  37. <el-button
  38. v-if="scope.row.scope === 1"
  39. size="mini"
  40. @click="handleScope(scope.$index, scope.row)">所有人可见</el-button>
  41. <el-button
  42. v-else-if="scope.row.scope === 2"
  43. size="mini"
  44. type="success"
  45. @click="handleScope(scope.$index, scope.row)">验证码可见</el-button>
  46. <el-button
  47. v-else-if="scope.row.scope === 3"
  48. size="mini"
  49. type="warning"
  50. @click="handleScope(scope.$index, scope.row)">VIP 可见</el-button>
  51. <el-button
  52. v-else
  53. size="mini"
  54. type="danger"
  55. @click="handleScope(scope.$index, scope.row)">本人可见</el-button>
  56. </el-tooltip>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="操作">
  60. <template slot-scope="scope">
  61. <el-button
  62. size="mini"
  63. @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  64. <el-button
  65. size="mini"
  66. type="danger"
  67. @click="handleDelete(scope.$index, scope.row)">删除</el-button>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. </el-row>
  72. <!-- 修改可见范围对话框 -->
  73. <el-dialog
  74. append-to-body
  75. :visible.sync="showEditScopeDialog"
  76. width="30%"
  77. center
  78. >
  79. <el-card class="box-card">
  80. <div slot="header" class="clearfix">
  81. <span>修改可见范围</span>
  82. <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateScope">更新</el-button>
  83. </div>
  84. <div class="text item">
  85. <el-select v-model="form.scope" placeholder="选择可见范围">
  86. <el-option label="所有人可见" value="1" />
  87. <el-option label="验证码可见" value="2" />
  88. <el-option label="VIP 可见" value="3" />
  89. <el-option label="仅自己可见" value="4" />
  90. </el-select>
  91. </div>
  92. </el-card>
  93. </el-dialog>
  94. </el-row>
  95. </template>
  96. <script>
  97. import { updateAudioScope, deleteAudioPost } from "@/api/audio";
  98. export default {
  99. name: 'AudioPost',
  100. props: {
  101. dataList: {
  102. type: Array,
  103. default: []
  104. },
  105. },
  106. components: {},
  107. data() {
  108. return {
  109. showEditScopeDialog: false,
  110. form: {
  111. audioId: null,
  112. scope: 1
  113. }
  114. }
  115. },
  116. created() {
  117. },
  118. methods: {
  119. handleScope(index, row) {
  120. this.form.audioId = row.audioId
  121. this.form.scope = ''+row.scope
  122. this.showEditScopeDialog = true
  123. },
  124. handleEdit(index, row) {
  125. const path = '/post/edit/audio/' + row.audioId
  126. this.$router.push(path)
  127. },
  128. handleDelete(index, row) {
  129. this.$confirm('确定要删除 ' + row.title + '?', '提示', {
  130. confirmButtonText: '确定',
  131. cancelButtonText: '取消',
  132. type: 'warning'
  133. }).then(() => {
  134. deleteAudioPost(row.audioId).then(res => {
  135. if (res.code === 0) {
  136. this.$notify({
  137. title: '稿件已删除',
  138. type: 'warning',
  139. duration: 3000
  140. })
  141. //this.$router.go(0)
  142. }
  143. })
  144. }).catch(() => {
  145. this.$message({
  146. type: 'info',
  147. message: '已取消'
  148. })
  149. })
  150. },
  151. onUpdateScope() {
  152. this.showEditScopeDialog = false
  153. updateAudioScope(this.form).then(res => {
  154. if (res.code === 0) {
  155. this.$notify({
  156. title: '提示',
  157. message: '可见范围已更新',
  158. type: 'warning',
  159. duration: 3000
  160. })
  161. }
  162. }).catch(error => {
  163. this.$notify({
  164. title: '提示',
  165. message: error.message,
  166. type: 'warning',
  167. duration: 3000
  168. })
  169. })
  170. }
  171. }
  172. }
  173. </script>
  174. <style>
  175. </style>