club-list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container activity">
  4. <div class="filter-control">
  5. <span>活动时间:</span>
  6. <el-date-picker
  7. v-model="activityFormData.time"
  8. format="yyyy-MM-dd HH:mm:ss"
  9. value-format="yyyy-MM-dd HH:mm:ss"
  10. type="datetimerange"
  11. range-separator="至"
  12. start-placeholder="开始日期"
  13. end-placeholder="结束日期"
  14. :disabled="activityFormData.status === 1"
  15. />
  16. </div>
  17. <div class="filter-control">
  18. <span>活动状态:</span>
  19. <el-switch
  20. v-model="activityFormData.status"
  21. el-switch
  22. :active-value="1"
  23. :inactive-value="0"
  24. @change="onUpdateActivityStatus"
  25. />
  26. </div>
  27. </div>
  28. <el-divider />
  29. <div class="filter-container">
  30. <div class="filter-control">
  31. <span>登录账号:</span>
  32. <el-input v-model="listQuery.mobile" placeholder="登录账号" @keyup.enter.native="getList" />
  33. </div>
  34. <div class="filter-control">
  35. <span>机构类型:</span>
  36. <el-select v-model="listQuery.authenticationStatus" placeholder="机构类型" clearable @change="getList">
  37. <el-option label="全部" value="" />
  38. <el-option label="未认证机构" :value="0" />
  39. <el-option label="已认证机构" :value="1" />
  40. </el-select>
  41. </div>
  42. <div class="filter-control">
  43. <el-button type="primary" @click="getList">查询</el-button>
  44. </div>
  45. </div>
  46. <!-- 列表 -->
  47. <el-table
  48. v-loading="listLoading"
  49. :data="list"
  50. border
  51. fit
  52. highlight-current-row
  53. style="width: 100%"
  54. header-row-class-name="tableHeader"
  55. >
  56. <el-table-column label="序号" :index="indexMethod" align="center" width="80" type="index" />
  57. <el-table-column label="登录账号" align="center" prop="userName" width="240" />
  58. <el-table-column label="机构名称" align="center" prop="authParty">
  59. <template slot-scope="{ row }">
  60. <span v-if="row.authParty">{{ row.authParty }}</span>
  61. <span v-else>-</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="机构类型" align="center" width="160">
  65. <template slot-scope="{ row }">
  66. <span v-if="row.authId" class="status success">已认证机构</span>
  67. <span v-else class="status danger" title="当前机构未认证">未认证机构</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="机构资质" align="center" width="160">
  71. <template slot-scope="{ row }">
  72. <span
  73. v-if="!row.authId"
  74. class="status success cursor-pointer"
  75. @click="onShowCertification(row)"
  76. >查看资质</span>
  77. <span v-else>-</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="报名时间" align="center" width="160">
  81. <template slot-scope="{ row }">
  82. {{ row.contestDate | formatTime }}
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="操作" align="center" width="240">
  86. <template slot-scope="{ row }">
  87. <permission-button size="mini" type="primary" @click="onShowVideoList(row)">视频列表</permission-button>
  88. <permission-button size="mini" type="primary" @click="onRemoveClub(row)">删除</permission-button>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <!-- 查看机构资质 -->
  93. <el-dialog title="机构资质" :visible.sync="certificationDialog" width="600px" center :close-on-click-modal="false">
  94. <img :src="certificationUrl" class="certification">
  95. </el-dialog>
  96. <el-dialog title="视频列表" :visible.sync="showVideoListDialog" width="1000px" center :close-on-click-modal="false">
  97. <VideoList :list="videoList" :is-loading="videoListLoading" @delete="onDeleteVideo" @preview="onPlayVideo" />
  98. <!-- 视频播放 -->
  99. <el-dialog
  100. title="视频播放"
  101. :visible.sync="videoDialog"
  102. width="800px"
  103. center
  104. :close-on-click-modal="false"
  105. append-to-body
  106. >
  107. <video class="video-play" :src="videoUrl" controls />
  108. </el-dialog>
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. import {
  114. deleteClub,
  115. deleteClubVideo,
  116. fetchClubVideoList,
  117. fetchDouyinActivityStatus,
  118. fetchSignInClubList,
  119. updateDouyinActivityStatus
  120. } from '@/api/activity'
  121. import VideoList from '../components/video-list.vue'
  122. export default {
  123. name: 'ChallengeVideoList',
  124. components: {
  125. VideoList
  126. },
  127. data() {
  128. return {
  129. listQuery: {
  130. status: '',
  131. mobile: '',
  132. authenticationStatus: '',
  133. pageNum: 1,
  134. pageSize: 10
  135. },
  136. listLoading: false,
  137. list: [],
  138. // 活动表单数据
  139. activityFormData: {
  140. time: [],
  141. status: 0
  142. },
  143. // 机构资质
  144. certificationDialog: false,
  145. certificationUrl: '',
  146. // 机构视频列表
  147. videoList: [],
  148. videoListLoading: false,
  149. showVideoListDialog: false,
  150. currentClub: null,
  151. // 视频预览
  152. videoDialog: false,
  153. videoUrl: ''
  154. }
  155. },
  156. created() {
  157. this.initPage()
  158. },
  159. activated() {
  160. this.initPage()
  161. },
  162. methods: {
  163. initPage() {
  164. this.getList()
  165. this.fetchActivityStatus()
  166. },
  167. // 获取参赛机构列表
  168. getList() {
  169. this.list = []
  170. this.listQuery.pageNum = 1
  171. this.fetchClubList()
  172. },
  173. // 获取参赛机构列表
  174. async fetchClubList() {
  175. try {
  176. this.listLoading = true
  177. const res = await fetchSignInClubList(this.listQuery)
  178. this.list = res.data.list
  179. this.listLoading = false
  180. console.log(res)
  181. } catch (error) {
  182. console.log(error)
  183. }
  184. },
  185. // 删除参赛机构操作
  186. async onRemoveClub(row) {
  187. try {
  188. await this.$confirm('确定删除该机构用户吗?', {
  189. confirmButtonText: '确定',
  190. cancelButtonText: '取消',
  191. type: 'warning',
  192. closeOnClickModal: false,
  193. showClose: false
  194. })
  195. this.deleteClub(row)
  196. } catch (error) {
  197. this.$message.info('已取消操作!')
  198. console.log(error)
  199. }
  200. },
  201. // 删除参赛机构操作
  202. async deleteClub(row) {
  203. try {
  204. await deleteClub({ id: row.id })
  205. this.fetchClubList()
  206. this.$message.success('机构删除成功')
  207. } catch (error) {
  208. console.log(error)
  209. this.$message.error('机构删除失败')
  210. }
  211. },
  212. // 获取机构上传视频列表
  213. async onShowVideoList(row) {
  214. try {
  215. this.currentClub = row
  216. const res = await fetchClubVideoList({ mobile: row.userName, clubUserId: '' })
  217. this.videoList = res.data
  218. if (this.videoList.length === 0) {
  219. this.$message.warning('当前机构未上传视频')
  220. return
  221. }
  222. this.showVideoListDialog = true
  223. } catch (error) {
  224. console.log(error)
  225. }
  226. },
  227. // 删除机构已上传的视频
  228. async onDeleteVideo(row) {
  229. try {
  230. await this.$confirm('确定删除该机构用户上传视频吗?删除后,抖音视频挑战首页将不再显示该视频!', {
  231. confirmButtonText: '确定',
  232. cancelButtonText: '取消',
  233. type: 'warning',
  234. closeOnClickModal: false,
  235. showClose: false
  236. })
  237. this.deleteVideo(row)
  238. } catch (error) {
  239. this.$message.info('已取消操作!')
  240. console.log(error)
  241. }
  242. },
  243. // 视频删除
  244. async deleteVideo(row) {
  245. try {
  246. await deleteClubVideo({ id: row.id })
  247. this.$message.success('视频删除成功')
  248. this.onShowVideoList(this.currentClub)
  249. } catch (error) {
  250. console.log(error)
  251. this.$message.success('视频删除失败')
  252. }
  253. },
  254. // 播放视频
  255. onPlayVideo(row) {
  256. this.videoDialog = true
  257. this.videoUrl = row.ossUrl
  258. },
  259. // 获取活动状态
  260. async fetchActivityStatus() {
  261. try {
  262. const res = await fetchDouyinActivityStatus()
  263. if (!res.data) return
  264. const { startTime, endTime } = res.data
  265. if (startTime && endTime) {
  266. this.activityFormData.time = [startTime, endTime]
  267. }
  268. this.activityFormData.status = res.data.status
  269. } catch (error) {
  270. console.log(error)
  271. }
  272. },
  273. // 验证活动时间
  274. checkActivityTime(startTime, endTime) {
  275. startTime = new Date(startTime).getTime()
  276. endTime = new Date(endTime).getTime()
  277. const nowTime = Date.now()
  278. if (startTime < nowTime) {
  279. return 1
  280. }
  281. if (endTime < startTime) {
  282. return 2
  283. }
  284. if (endTime < nowTime) {
  285. return 3
  286. }
  287. },
  288. // 更新活动时间状态
  289. async onUpdateActivityStatus(value) {
  290. let flag = -1
  291. const dialog = {
  292. 0: '请先设置活动时间后,再来开启活动按钮',
  293. 1: '活动开始时间不能小于当前时间',
  294. 2: '活动结束时间不能小于活动开始时间',
  295. 3: '你设置的活动时间已失效,请重新设置有效活动时间后,再来开启活动按钮'
  296. }
  297. if (!this.activityFormData.time) {
  298. flag = 0
  299. } else {
  300. const [start, end] = this.activityFormData.time
  301. flag = this.checkActivityTime(start, end)
  302. }
  303. if (flag > -1 && value === 1) {
  304. this.$confirm(dialog[flag], '提示', {
  305. confirmButtonText: '确定',
  306. cancelButtonText: '取消',
  307. type: 'warning',
  308. closeOnClickModal: false,
  309. showClose: false
  310. })
  311. .then(() => {
  312. this.activityFormData.status = 0
  313. })
  314. .catch(() => {
  315. this.activityFormData.status = 0
  316. })
  317. return
  318. }
  319. try {
  320. const {
  321. status,
  322. time: [startTime, endTime]
  323. } = this.activityFormData
  324. await updateDouyinActivityStatus({
  325. startTime,
  326. endTime,
  327. status
  328. })
  329. this.$message.success(`活动已${status ? '开启' : '关闭'}`)
  330. } catch (error) {
  331. console.log(error)
  332. }
  333. },
  334. // 产看资质
  335. onShowCertification(row) {
  336. this.certificationUrl = row.licenseOssUrl
  337. this.certificationDialog = true
  338. },
  339. // 表格索引
  340. indexMethod(index) {
  341. return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
  342. }
  343. }
  344. }
  345. </script>
  346. <style lang="scss" scoped>
  347. .cursor-pointer {
  348. cursor: pointer;
  349. user-select: none;
  350. }
  351. .activity {
  352. .filter-control {
  353. margin-bottom: 0;
  354. }
  355. }
  356. .el-divider {
  357. margin: 12px 0;
  358. }
  359. .el-dialog {
  360. .control {
  361. text-align: right;
  362. }
  363. .certification {
  364. width: 100%;
  365. display: block;
  366. }
  367. }
  368. .video-play {
  369. display: block;
  370. width: 100%;
  371. height: 480px;
  372. background: #666;
  373. }
  374. </style>