userCourseCatalogDetails.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <div class="app-container">
  3. <div style="padding-bottom: 20px">
  4. <span v-if="courseName!=null">{{ courseName }}</span>
  5. </div>
  6. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  7. <el-form-item label="小节名称" prop="title">
  8. <el-input
  9. v-model="queryParams.title"
  10. placeholder="请输入小节名称"
  11. clearable
  12. size="small"
  13. @keyup.enter.native="handleQuery"
  14. />
  15. </el-form-item>
  16. <el-form-item>
  17. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  18. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  19. </el-form-item>
  20. </el-form>
  21. <el-table border v-loading="loading" :data="userCourseVideoList" @selection-change="handleSelectionChange">
  22. <el-table-column type="selection" width="55" align="center" />
  23. <el-table-column label="视频ID" align="center" prop="videoId" />
  24. <el-table-column label="小节名称" align="center" show-overflow-tooltip prop="title" />
  25. <el-table-column label="视频文件名称" align="center" show-overflow-tooltip prop="fileName" >
  26. </el-table-column>
  27. <el-table-column label="视频时长" align="center" prop="duration">
  28. <template slot-scope="{ row }">
  29. {{ formatDuration(row.duration) }}
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="排序" align="center" prop="courseSort" />
  33. <el-table-column label="上传时间" align="center" prop="createTime" />
  34. <el-table-column label="默认红包" align="center" prop="redPacketMoney" />
  35. <el-table-column label="公司红包" align="center" prop="companyRedPacketMoney" />
  36. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  37. <template slot-scope="scope">
  38. <el-button
  39. size="mini"
  40. type="text"
  41. @click="handleDetails(scope.row)"
  42. >查看</el-button>
  43. <el-button
  44. size="mini"
  45. type="text"
  46. v-hasPermi="['course:userCourseVideo:edit']"
  47. @click="updateMoney(scope.row)"
  48. >设置红包金额</el-button>
  49. <el-button size="mini"
  50. type="text" @click="openTagDialog(scope.row)">
  51. 绑定看课标签
  52. </el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <pagination
  57. v-show="total>0"
  58. :total="total"
  59. :page.sync="queryParams.pageNum"
  60. :limit.sync="queryParams.pageSize"
  61. @pagination="getList"
  62. />
  63. <el-drawer
  64. :with-header="false"
  65. size="75%"
  66. :visible.sync="open" append-to-body>
  67. <userCourseVideoDetails ref="userCourseVideoDetails" />
  68. </el-drawer>
  69. <el-dialog title="设置红包金额" :visible.sync="moneyOpen" width="600px" append-to-body>
  70. <el-form ref="form" label-width="100px">
  71. <el-form-item label="红包金额" prop="corpId">
  72. <el-input-number v-model="redPacketMoneyForm.redPacketMoney" :min="0.1" :max="200" :step="0.1" ></el-input-number>
  73. </el-form-item>
  74. </el-form>
  75. <div slot="footer" class="dialog-footer">
  76. <el-button type="primary" @click="submitForm">确 定</el-button>
  77. <el-button @click="cancel">取 消</el-button>
  78. </div>
  79. </el-dialog>
  80. <el-dialog
  81. title="生成链接"
  82. :visible.sync="dialogVisible"
  83. width="400px"
  84. @close="resetForm"
  85. append-to-body>
  86. <div>
  87. <p style="color: gray;">不传默认以系统参数为准</p>
  88. <el-form :model="linkForm" label-width="120px">
  89. <el-form-item label="链接有效时长(天)">
  90. <el-input
  91. v-model="linkForm.days"
  92. placeholder="请输入有效时长"
  93. type="number"
  94. ></el-input>
  95. </el-form-item>
  96. </el-form>
  97. </div>
  98. <div slot="footer" class="dialog-footer">
  99. <el-button @click="dialogVisible = false">取消</el-button>
  100. <el-button type="primary" @click="confirm">确认</el-button>
  101. </div>
  102. </el-dialog>
  103. <AutoTagDialog
  104. :visible.sync="tagDialogVisible"
  105. :title="tagDialogTitle"
  106. :videoId="currentVideoId"
  107. append-to-body
  108. />
  109. </div>
  110. </template>
  111. <script>
  112. import {getVideoListByCourseId, updatePacketMoney, updateUserCourseVideoUpdate} from "@/api/course/userCourseVideo";
  113. import userCourseVideoDetails from '../../components/course/userCourseVideoDetails.vue';
  114. import {createLinkUrl} from "@/api/course/sopCourseLink";
  115. import AutoTagDialog from "@/views/components/tag/AutoTagDialog.vue";
  116. import {addTag, updateTag} from "@/api/tag/api";
  117. export default {
  118. name: "userCourseCatalog",
  119. components: {
  120. userCourseVideoDetails,
  121. AutoTagDialog
  122. },
  123. props: {
  124. video: {
  125. type: Object,
  126. required: true,
  127. },
  128. },
  129. data() {
  130. return {
  131. currentRow: null,
  132. // 假设这里有当前课程小节的数据传入,里面含id等
  133. tagGroups: [],
  134. tagsInGroup: [],
  135. tagDialogVisible: false,
  136. tagDialogTitle: "",
  137. tagDialogFormData: null,
  138. currentVideoId:null,
  139. tagDialog: {
  140. videoId: null,
  141. groupId: null,
  142. watchTagId: null,
  143. finishTagId: null,
  144. tgId: null,
  145. watchingTgId: null,
  146. watchedTgId: null
  147. },
  148. linkForm:{
  149. days:null,
  150. courseId:null,
  151. videoId:null
  152. },
  153. dialogVisible: false, // 控制弹框显示
  154. //短链
  155. sortLink:'',
  156. //课题
  157. questionBank:{
  158. title:'',
  159. open:false,
  160. },
  161. moneyOpen:false,
  162. videoUrl: "",
  163. uploadTypeOptions: [
  164. { dictLabel: "线路一", dictValue: 2 },
  165. { dictLabel: "线路二", dictValue: 1 },
  166. { dictLabel: "线路三", dictValue: 3 },
  167. ],
  168. uploadLoading:false,
  169. courseId:null,
  170. videoName:'',
  171. title: "",
  172. redPacketMoneyForm:{
  173. redPacketMoney:null,
  174. voidId:null
  175. },
  176. // 是否显示弹出层
  177. open: false,
  178. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadHuaWeiObs",
  179. baseUrl: process.env.VUE_APP_BASE_API,
  180. typeOptions:[],
  181. files:[],
  182. fileList: [],
  183. // 上传成功后的地址
  184. videoURL: '',
  185. // 进度条百分比
  186. progress: 0,
  187. // 上传视频获取成功后拿到的fileID【备用】
  188. fileId: '',
  189. courseName:null,
  190. userCourseVideoList:[],
  191. total: 0,
  192. queryParams: {
  193. pageNum: 1,
  194. pageSize: 10,
  195. courseId:null,
  196. title:null
  197. },
  198. // 显示搜索条件
  199. showSearch: true,
  200. // 遮罩层
  201. loading: true,
  202. // 导出遮罩层
  203. exportLoading: false,
  204. // 选中数组
  205. ids: [],
  206. // 非单个禁用
  207. single: true,
  208. // 非多个禁用
  209. multiple: true,
  210. // 表单参数
  211. form: {},
  212. // 表单校验
  213. rules: {
  214. title: [
  215. { required: true, message: "小节名称不能为空", trigger: "change" }
  216. ],
  217. courseSort: [
  218. { required: true, message: "排序不能为空", trigger: "change" }
  219. ],
  220. }
  221. }
  222. },
  223. created() {
  224. this.getDicts("sys_course_temp_type").then(response => {
  225. this.typeOptions = response.data;
  226. });
  227. },
  228. methods: {
  229. closeTagDialog(){
  230. this.tagDialogVisible = false;
  231. },
  232. openTagDialog(row) {
  233. this.currentRow = row;
  234. this.tagDialogVisible = true;
  235. this.currentVideoId = row.videoId;
  236. },
  237. updateTagsInGroup(groupId) {
  238. let tagGroup = this.tagGroups.find(e=> e.groupId === groupId);
  239. this.tagsInGroup = tagGroup.tag || [];
  240. // 切换组时清空标签选择
  241. this.tagDialog.watchTagId = null;
  242. this.tagDialog.finishTagId = null;
  243. this.tagDialog.tgId = tagGroup.id;
  244. },
  245. resetDialog() {
  246. this.tagDialog = {
  247. videoId: null,
  248. groupId: null,
  249. watchTagId: null,
  250. finishTagId: null,
  251. };
  252. this.tagGroups = [];
  253. this.tagsInGroup = [];
  254. },
  255. // 打开弹框
  256. openDialog(row) {
  257. this.linkForm.courseId = row.courseId;
  258. this.linkForm.videoId = row.videoId;
  259. this.dialogVisible = true;
  260. },
  261. // 确认按钮操作
  262. confirm() {
  263. if (!this.linkForm.days) {
  264. this.$message.error("请输入有效时长!");
  265. return;
  266. }
  267. this.handleCreateLink();
  268. // 关闭弹框
  269. this.dialogVisible = false;
  270. },
  271. // 重置表单
  272. resetForm() {
  273. this.linkForm={
  274. days:null,
  275. courseId:null,
  276. videoId:null
  277. }
  278. },
  279. handleCreateLink(){
  280. createLinkUrl(this.linkForm).then(response => {
  281. if (response.code === 200){
  282. this.copyLink(response.url);
  283. }
  284. });
  285. },
  286. copyLink(url) {
  287. const link = url;
  288. // navigator clipboard 需要https等安全上下文
  289. if (navigator.clipboard && window.isSecureContext) {
  290. // navigator clipboard 向剪贴板写文本
  291. navigator.clipboard.writeText(link).then(() => {
  292. this.$message.success('链接已复制到剪贴板');
  293. });
  294. } else {
  295. // document.execCommand('copy') 向剪贴板写文本
  296. let input = document.createElement('input')
  297. input.style.position = 'fixed'
  298. input.style.top = '-10000px'
  299. input.style.zIndex = '-999'
  300. document.body.appendChild(input)
  301. input.value = link
  302. input.focus()
  303. input.select()
  304. try {
  305. let result = document.execCommand('copy')
  306. document.body.removeChild(input)
  307. if (!result || result === 'unsuccessful') {
  308. this.$message.error('复制失败');
  309. console.log('复制失败')
  310. } else {
  311. this.$message.success('链接已复制到剪贴板');
  312. console.log('复制成功')
  313. }
  314. } catch (e) {
  315. document.body.removeChild(input)
  316. alert('当前浏览器不支持复制功能,请检查更新或更换其他浏览器操作')
  317. }
  318. }
  319. },
  320. formatDuration(seconds) {
  321. if (seconds === null || seconds === undefined) {
  322. return '未上传视频'; // 或者您可以根据具体需求返回其他默认值
  323. }
  324. const hours = Math.floor(seconds / 3600);
  325. const minutes = Math.floor((seconds % 3600) / 60);
  326. const remainingSeconds = seconds % 60;
  327. const formattedHours = hours > 0 ? hours.toString() + ':' : '';
  328. const formattedMinutes = minutes.toString().padStart(2, '0');
  329. const formattedSeconds = remainingSeconds.toString().padStart(2, '0');
  330. return `${formattedHours}${formattedMinutes}:${formattedSeconds}`;
  331. },
  332. getDetails(courseId,courseName) {
  333. this.courseName = courseName
  334. this.courseId = courseId;
  335. this.queryParams.courseId = courseId;
  336. this.getList();
  337. },
  338. getList() {
  339. this.loading = true;
  340. getVideoListByCourseId(this.queryParams).then(response => {
  341. this.userCourseVideoList = response.rows;
  342. this.total = response.total;
  343. this.loading = false;
  344. });
  345. },
  346. // 取消按钮
  347. cancel() {
  348. this.open = false;
  349. this.reset();
  350. },
  351. updateMoney(row){
  352. this.redPacketMoneyForm.redPacketMoney=row.companyRedPacketMoney;
  353. this.redPacketMoneyForm.videoId=row.videoId;
  354. this.moneyOpen=true;
  355. },
  356. submitForm(){
  357. updatePacketMoney(this.redPacketMoneyForm).then(response => {
  358. this.msgSuccess("修改成功");
  359. this.moneyOpen=false;
  360. this.getList()
  361. });
  362. },
  363. updateMoneycancel(){
  364. this.moneyOpen=false;
  365. },
  366. // 表单重置
  367. reset() {
  368. this.form = {
  369. videoId: null,
  370. title: null,
  371. description: null,
  372. url: null,
  373. thumbnail: null,
  374. duration: null,
  375. createTime: null,
  376. uploadType:null,
  377. lineOne:null,
  378. lineTwo:null,
  379. lineThree:null,
  380. fileName:null,
  381. userId: null,
  382. cateId: null,
  383. courseId: null,
  384. likes: null,
  385. views: null,
  386. comments: null,
  387. status: 0,
  388. courseSort: 1,
  389. isHot: null,
  390. isShow: null,
  391. isAudit: null,
  392. auditBy: null,
  393. auditTime: null,
  394. updateTime: null,
  395. source: null,
  396. isDel: null,
  397. shares: null,
  398. tags: null,
  399. productId: null,
  400. productJson: null,
  401. questionBankId:null,
  402. questionBankList:[],
  403. };
  404. this.videoURL = '';
  405. this.progress=0;
  406. this.resetForm("form");
  407. },
  408. /** 搜索按钮操作 */
  409. handleQuery() {
  410. this.queryParams.pageNum = 1;
  411. this.getList();
  412. },
  413. /** 重置按钮操作 */
  414. resetQuery() {
  415. this.resetForm("queryForm");
  416. this.queryParams.title = null;
  417. this.handleQuery();
  418. },
  419. // 多选框选中数据
  420. handleSelectionChange(selection) {
  421. this.ids = selection.map(item => item.courseId)
  422. this.single = selection.length!==1
  423. this.multiple = !selection.length
  424. },
  425. /** 修改按钮操作 */
  426. handleDetails(row) {
  427. this.open=true;
  428. setTimeout(() => {
  429. this.$refs.userCourseVideoDetails.getDetails(row.videoId);
  430. }, 500);
  431. }
  432. }
  433. }
  434. </script>
  435. <style>
  436. .avatar-uploader .el-upload {
  437. border: 1px dashed #d9d9d9;
  438. border-radius: 6px;
  439. cursor: pointer;
  440. position: relative;
  441. overflow: hidden;
  442. }
  443. .avatar-uploader .el-upload:hover {
  444. border-color: #409EFF;
  445. }
  446. .avatar-uploader-icon {
  447. font-size: 28px;
  448. color: #8c939d;
  449. width: 150px;
  450. height: 150px;
  451. line-height: 150px;
  452. text-align: center;
  453. }
  454. </style>