index.vue 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="所属达人" prop="talentName">
  5. <el-input
  6. v-model="queryParams.talentName"
  7. placeholder="请输入所属达人"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="视频标题" prop="title">
  14. <el-input
  15. v-model="queryParams.title"
  16. placeholder="请输入视频标题"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="是否热门" prop="isHot">
  23. <el-select v-model="queryParams.isHot" placeholder="请选择来源" clearable size="small">
  24. <el-option
  25. v-for="dict in orOptions"
  26. :key="dict.dictValue"
  27. :label="dict.dictLabel"
  28. :value="dict.dictValue"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="状态" prop="status">
  33. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  34. <el-option
  35. v-for="dict in specShowOptions"
  36. :key="dict.dictValue"
  37. :label="dict.dictLabel"
  38. :value="dict.dictValue"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="线路" prop="uploadType">
  43. <el-select v-model="queryParams.uploadType" placeholder="请选择线路" clearable size="small">
  44. <el-option
  45. v-for="dict in uploadTypeOptions"
  46. :key="dict.dictValue"
  47. :label="dict.dictLabel"
  48. :value="dict.dictValue"
  49. />
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item label="来源" prop="source">
  53. <el-select v-model="queryParams.source" placeholder="请选择来源" clearable size="small">
  54. <el-option
  55. v-for="dict in sourceOptions"
  56. :key="dict.dictValue"
  57. :label="dict.dictLabel"
  58. :value="dict.dictValue"
  59. />
  60. </el-select>
  61. </el-form-item>
  62. <el-form-item label="创建时间" prop="createTime">
  63. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  64. </el-form-item>
  65. <el-form-item label="审核时间" prop="auditTime">
  66. <el-date-picker v-model="auditTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="auditChange"></el-date-picker>
  67. </el-form-item>
  68. <el-form-item>
  69. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  70. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  71. </el-form-item>
  72. </el-form>
  73. <el-row :gutter="10" class="mb8">
  74. <el-col :span="1.5">
  75. <el-button
  76. type="primary"
  77. plain
  78. icon="el-icon-plus"
  79. size="mini"
  80. @click="handleAdd"
  81. v-hasPermi="['course:userVideo:add']"
  82. >新增</el-button>
  83. </el-col>
  84. <el-col :span="1.5">
  85. <el-button
  86. type="success"
  87. plain
  88. icon="el-icon-edit"
  89. size="mini"
  90. :disabled="single"
  91. @click="handleUpdate"
  92. v-hasPermi="['course:userVideo:edit']"
  93. >修改</el-button>
  94. </el-col>
  95. <el-col :span="1.5">
  96. <el-button
  97. type="danger"
  98. plain
  99. icon="el-icon-delete"
  100. size="mini"
  101. :disabled="multiple"
  102. @click="handleDelete"
  103. v-hasPermi="['course:userVideo:remove']"
  104. >删除</el-button>
  105. </el-col>
  106. <el-col :span="1.5">
  107. <el-button
  108. type="warning"
  109. plain
  110. icon="el-icon-download"
  111. size="mini"
  112. :loading="exportLoading"
  113. @click="handleExport"
  114. v-hasPermi="['course:userVideo:export']"
  115. >导出</el-button>
  116. </el-col>
  117. <el-col :span="1.5">
  118. <el-button
  119. v-if="queryParams.isAudit==0 || queryParams.isAudit==-1"
  120. type="success"
  121. plain
  122. icon="el-icon-edit"
  123. size="mini"
  124. :disabled="multiple"
  125. @click="auditVideo"
  126. v-hasPermi="['course:userVideo:audit']"
  127. >批量审核</el-button>
  128. </el-col>
  129. <el-col :span="1.5">
  130. <el-button
  131. v-if="queryParams.status==0 && queryParams.status!=''"
  132. type="success"
  133. plain
  134. icon="el-icon-edit"
  135. size="mini"
  136. :disabled="multiple"
  137. @click="putOn"
  138. v-hasPermi="['course:userVideo:putOn']"
  139. >上架</el-button>
  140. </el-col>
  141. <el-col :span="1.5">
  142. <el-button
  143. v-if="queryParams.status==1 && queryParams.status!=''"
  144. type="success"
  145. plain
  146. icon="el-icon-edit"
  147. size="mini"
  148. :disabled="multiple"
  149. @click="pullOff"
  150. v-hasPermi="['course:userVideo:pullOff']"
  151. >下架</el-button>
  152. </el-col>
  153. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  154. </el-row>
  155. <el-tabs type="card" v-model="queryParams.isAudit" @tab-click="handleClickX">
  156. <el-tab-pane v-for="(item,index) in isAuditOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  157. </el-tabs>
  158. <el-table v-loading="loading" :data="userVideoList" @selection-change="handleSelectionChange" border>
  159. <el-table-column type="selection" width="55" align="center" />
  160. <el-table-column label="ID" align="center" prop="videoId" />
  161. <el-table-column label="视频标题" align="center" prop="title" show-overflow-tooltip />
  162. <el-table-column label="视频缩略图" align="center" prop="thumbnail" width="110px">
  163. <template slot-scope="scope">
  164. <el-popover
  165. placement="right"
  166. title=""
  167. trigger="hover">
  168. <img slot="reference" :src="scope.row.thumbnail" width="100" height="100">
  169. <img :src="scope.row.thumbnail" style="max-width: 150px;">
  170. </el-popover>
  171. </template>
  172. </el-table-column>
  173. <el-table-column label="视频时长(秒)" align="center" prop="duration" />
  174. <el-table-column label="所属达人" align="center" prop="talentName" />
  175. <el-table-column label="点赞量" align="center" prop="likes" />
  176. <el-table-column label="播放量" align="center" prop="views" />
  177. <el-table-column label="审核人" align="center" prop="auditUserName" />
  178. <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
  179. <el-table-column label="审核时间" align="center" prop="auditTime" width="180"/>
  180. <el-table-column label="来源" align="center" prop="source">
  181. <template slot-scope="scope">
  182. <dict-tag :options="sourceOptions" :value="scope.row.source"/>
  183. </template>
  184. </el-table-column>
  185. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150px">
  186. <template slot-scope="scope">
  187. <el-button v-if="scope.row.isAudit!=1"
  188. size="mini"
  189. type="text"
  190. icon="el-icon-edit"
  191. @click="auditVideo(scope.row)"
  192. v-hasPermi="['course:userVideo:audit']"
  193. >审核</el-button>
  194. <el-button
  195. size="mini"
  196. type="text"
  197. @click="handleDetails(scope.row)"
  198. >详情</el-button>
  199. <el-button
  200. size="mini"
  201. type="text"
  202. icon="el-icon-edit"
  203. @click="handleUpdate(scope.row)"
  204. v-hasPermi="['course:userVideo:edit']"
  205. >修改</el-button>
  206. <el-button
  207. size="mini"
  208. type="text"
  209. icon="el-icon-delete"
  210. @click="handleDelete(scope.row)"
  211. v-hasPermi="['course:userVideo:remove']"
  212. >删除</el-button>
  213. </template>
  214. </el-table-column>
  215. </el-table>
  216. <pagination
  217. v-show="total>0"
  218. :total="total"
  219. :page.sync="queryParams.pageNum"
  220. :limit.sync="queryParams.pageSize"
  221. @pagination="getList"
  222. />
  223. <!-- 添加或修改课堂视频对话框 -->
  224. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body >
  225. <el-form ref="form" :model="form" :rules="rules" label-width="110px" v-loading="uploadLoading">
  226. <el-form-item label="视频标题" prop="title">
  227. <el-input v-model="form.title" type="textarea" :rows="2" placeholder="请输入内容" />
  228. </el-form-item>
  229. <el-form-item label="视频描述" prop="description">
  230. <el-input v-model="form.description" type="textarea" :rows="2" placeholder="请输入内容" />
  231. </el-form-item>
  232. <el-form-item label="关联达人" >
  233. <el-select v-model="form.talentId" remote filterable reserve-keyword placeholder="输入手机号搜索" :remote-method="talentMethod" clearable >
  234. <el-option
  235. v-for="item in talentList"
  236. :key="item.talentId"
  237. :label="item.nickName +'#'+item.phone"
  238. :value="item.talentId">
  239. <span style="float: left">{{ item.talentId }}</span>
  240. <span style="margin-left: 30px ;">{{item.nickName}}</span>
  241. <span style="margin-left: 30px">{{ item.phone }}</span>
  242. </el-option>
  243. </el-select>
  244. </el-form-item>
  245. <el-form-item label="关联疗法" prop="productId" >
  246. <el-select v-model="form.productId" remote filterable reserve-keyword placeholder="输入套餐包别名搜索" :remote-method="packageMethod" clearable @change="selectPackage" >
  247. <el-option
  248. v-for="item in packageList"
  249. :key="item.packageId"
  250. :label="item.secondName +'#'+item.packageId"
  251. :value="item.packageId">
  252. <span style="float: left">{{ item.packageId }}</span>
  253. <span style="margin-left: 30px ;">{{item.packageName}}</span>
  254. <span style="margin-left: 30px">{{ item.secondName }}</span>
  255. </el-option>
  256. </el-select>
  257. </el-form-item>
  258. <el-form-item label="状态" prop="status" v-if="form.isAudit ==1">
  259. <el-radio-group v-model="form.status">
  260. <el-radio :label="item.dictValue" v-for="item in specShowOptions" >{{item.dictLabel}}</el-radio>
  261. </el-radio-group>
  262. </el-form-item>
  263. <el-form-item label="视频缩略图" prop="thumbnail">
  264. <el-upload
  265. v-model="form.thumbnail"
  266. class="avatar-uploader"
  267. :action="uploadUrl"
  268. :show-file-list="false"
  269. :on-success="handleAvatarSuccess"
  270. :before-upload="beforeAvatarUpload"
  271. :headers="uploadHeaders"
  272. >
  273. <img v-if="form.thumbnail" :src="form.thumbnail" class="avatar" width="300px">
  274. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  275. </el-upload>
  276. </el-form-item>
  277. <video-upload
  278. :type="2"
  279. :videoUrl.sync="videoUrl"
  280. :fileKey.sync = "form.fileKey"
  281. :fileSize.sync = "form.fileSize"
  282. :line_1.sync="form.txPcdnUrl"
  283. :line_2.sync="form.hwObsUrl"
  284. :thumbnail.sync="form.thumbnail"
  285. :uploadType.sync="form.uploadType"
  286. @video-duration="handleVideoDuration"
  287. @change="handleVideoChange"
  288. ref="videoUpload"
  289. />
  290. <el-row>
  291. <el-col :span="8">
  292. <el-form-item label="收藏数" prop="favoriteNum">
  293. <el-input-number v-model="form.favoriteNum" :min="0" label="收藏数"></el-input-number>
  294. </el-form-item>
  295. </el-col>
  296. <el-col :span="8">
  297. <el-form-item label="播放量" prop="views">
  298. <el-input-number v-model="form.views" :min="0" label="浏览量"></el-input-number>
  299. </el-form-item>
  300. </el-col>
  301. <el-col :span="8">
  302. <el-form-item label="点赞量" prop="likes">
  303. <el-input-number v-model="form.likes" :min="0" label="点赞量"></el-input-number>
  304. </el-form-item>
  305. </el-col>
  306. </el-row>
  307. <el-row>
  308. <el-col :span="8">
  309. <el-form-item label="分享数" prop="shares">
  310. <el-input-number v-model="form.shares" :min="0" label="分享数"></el-input-number>
  311. </el-form-item>
  312. </el-col>
  313. <el-col :span="8">
  314. <el-form-item label="评论数" prop="comments">
  315. <el-input-number v-model="form.comments" :min="0" label="分享数"></el-input-number>
  316. </el-form-item>
  317. </el-col>
  318. <el-col :span="8">
  319. <el-form-item prop="tags" label="标签">
  320. <el-select v-model="tags" placeholder="请选择标签" multiple filterable clearable size="small">
  321. <el-option
  322. v-for="dict in tagList"
  323. :key="dict.tagId"
  324. :label="dict.tagName"
  325. :value="dict.tagId"
  326. />
  327. </el-select>
  328. </el-form-item>
  329. </el-col>
  330. </el-row>
  331. </el-form>
  332. <div slot="footer" class="dialog-footer">
  333. <el-button type="primary" @click="submitForm">确 定</el-button>
  334. <el-button @click="cancel">取 消</el-button>
  335. </div>
  336. </el-dialog>
  337. <el-dialog :title="auditDialog.title" :visible.sync="auditDialog.open" width="800px" append-to-body @close="auditDialogClose">
  338. <el-form ref="auditForm" :model="auditForm" :rules="auditRules" label-width="100px">
  339. <el-form-item label="审核" prop="isAudit">
  340. <el-radio-group v-model="auditForm.isAudit">
  341. <el-radio :label="item.dictValue" v-for="item in auditRadio" >{{item.dictLabel}}</el-radio>
  342. </el-radio-group>
  343. </el-form-item>
  344. <el-form-item label="备注" prop="remark">
  345. <el-input type="textarea" v-model="auditForm.remark" placeholder="备注" />
  346. </el-form-item>
  347. <el-form-item prop="tags" style="width: 500px" label="标签">
  348. <el-select v-model="auditTags" placeholder="请选择标签" multiple filterable clearable size="small">
  349. <el-option
  350. v-for="dict in tagList"
  351. :key="dict.tagId"
  352. :label="dict.tagName"
  353. :value="dict.tagId"
  354. />
  355. </el-select>
  356. </el-form-item>
  357. </el-form>
  358. <div slot="footer" class="dialog-footer" >
  359. <el-button type="primary" @click="submitAuditForm">提交</el-button>
  360. <el-button @click="auditDialogClose">取消</el-button>
  361. </div>
  362. </el-dialog>
  363. <el-drawer
  364. :with-header="false"
  365. size="75%"
  366. :visible.sync="show.open">
  367. <userVideoDetails ref="userVideoDetails" />
  368. </el-drawer>
  369. </div>
  370. </template>
  371. <script>
  372. import { getToken } from '@/utils/auth'
  373. import VideoUpload from '@/components/VideoUpload/index';
  374. import { listUserVideo, getUserVideo, delUserVideo, addUserVideo, updateUserVideo, exportUserVideo,auditUserVideo,putOn,pullOff } from "@/api/course/userVideo";
  375. import {getSignature,uploadHuaWeiVod} from "@/api/common"
  376. import { listBySearch} from "@/api/course/userTalent";
  377. import { subList} from "@/api/course/userVideoTags";
  378. import { packageBySearch} from "@/api/his/package";
  379. import TcVod from 'vod-js-sdk-v6'
  380. import userVideoDetails from '../../components/course/userVideoDetails.vue';
  381. import { BasicCredentials } from '@huaweicloud/huaweicloud-sdk-core';
  382. import { VodClient, VodRegion, CreateAssetByFileUploadRequest,ShowAssetTempAuthorityRequest } from '@huaweicloud/huaweicloud-sdk-vod';
  383. import axios from 'axios';
  384. import { Loading } from 'element-ui';
  385. import { uploadObject } from '@/utils/cos.js';
  386. import { uploadToOBS } from '@/utils/obs.js';
  387. export default {
  388. name: "UserVideo",
  389. components: {
  390. userVideoDetails,VideoUpload
  391. },
  392. data() {
  393. return {
  394. uploadHeaders: { Authorization: "Bearer " + getToken() },
  395. tagsOptions:[],
  396. tags:[],
  397. //所有的标签
  398. tagList:[],
  399. uploadTypeOptions:[{
  400. "dictLabel": "线路一",
  401. "dictValue": 1
  402. },
  403. {
  404. "dictLabel": "线路二",
  405. "dictValue": 2
  406. },
  407. ],
  408. specShowOptions:[],
  409. finalQuality:1,
  410. packageItem:{},
  411. uploadLoading:false,
  412. show:{
  413. title:"短视频详情",
  414. open :false
  415. },
  416. auditRadio: [{
  417. "dictLabel": "通过",
  418. "dictValue": 1
  419. }, {
  420. "dictLabel": "驳回",
  421. "dictValue": -1
  422. }],
  423. auditDialog:{
  424. title:"短视频审核",
  425. open:false
  426. },
  427. auditTags:[],
  428. auditForm:{
  429. videoIds:[],
  430. isAudit:null,
  431. tags:''
  432. },
  433. auditRules:{
  434. isAudit: [
  435. { required: true, message: "请选择审核状态", trigger: "blur" }
  436. ],
  437. },
  438. isAuditOptions:[],
  439. talentParam:{
  440. phone:null,
  441. talentId:null,
  442. },
  443. packageParam:{
  444. secondName:null,
  445. packageId:null,
  446. isShow:1,
  447. status:1
  448. },
  449. talentList:[],
  450. packageList:[],
  451. files:[],
  452. fileList: [],
  453. // 上传成功后的地址
  454. videoURL: '',
  455. // 进度条百分比
  456. progress: 0,
  457. // 上传视频获取成功后拿到的fileID【备用】
  458. fileId: '',
  459. // 遮罩层
  460. loading: true,
  461. // 导出遮罩层
  462. exportLoading: false,
  463. // 选中数组
  464. ids: [],
  465. videoUrl: "",
  466. videoAccept:"video/*",
  467. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  468. baseUrl: process.env.VUE_APP_BASE_API,
  469. cateOptions:[],
  470. // 非单个禁用
  471. single: true,
  472. // 非多个禁用
  473. multiple: true,
  474. // 显示搜索条件
  475. showSearch: true,
  476. // 总条数
  477. total: 0,
  478. // 课堂视频表格数据
  479. userVideoList: [],
  480. // 弹出层标题
  481. title: "",
  482. // 是否显示弹出层
  483. open: false,
  484. // 课程ID字典
  485. courseIdOptions: [],
  486. // 视频状态 1:草稿,2:待审核,3:发布字典
  487. statusOptions: [],
  488. // 是否展示字典
  489. orOptions: [],
  490. // 来源 1 用户 2 后台字典
  491. sourceOptions: [],
  492. // 删除标志字典
  493. isDelOptions: [],
  494. // 查询参数
  495. queryParams: {
  496. pageNum: 1,
  497. pageSize: 10,
  498. title: null,
  499. description: null,
  500. url: null,
  501. thumbnail: null,
  502. duration: null,
  503. userId: null,
  504. cateId: null,
  505. courseId: null,
  506. likes: null,
  507. views: null,
  508. comments: null,
  509. status: null,
  510. courseSort: null,
  511. isHot: null,
  512. isShow: null,
  513. isAudit: 0,
  514. auditBy: null,
  515. auditTime: null,
  516. source: null,
  517. isDel: null,
  518. shares: null,
  519. tags: '',
  520. productId: null,
  521. productJson: null,
  522. sTime:null,
  523. eTime:null,
  524. auditsTime:null,
  525. auditeTime:null,
  526. },
  527. createTime:null,
  528. auditTime:null,
  529. // 表单参数
  530. form: {},
  531. // 表单校验
  532. rules: {
  533. title: [
  534. { required: true, message: "短视频标题不能为空", trigger: "blur" }
  535. ],
  536. // talentId: [
  537. // { required: true, message: "关联达人不能为空", trigger: "change" }
  538. // ],
  539. thumbnail: [
  540. { required: true, message: "请上传视频封面", trigger: "blur" }
  541. ]
  542. }
  543. };
  544. },
  545. created() {
  546. this.getList();
  547. this.getTagList();
  548. this.getDicts("sys_course_tags").then(response => {
  549. this.tagsOptions = response.data;
  550. });
  551. this.getDicts("sys_spec_show").then(response => {
  552. this.specShowOptions = response.data;
  553. });
  554. this.getDicts("sys_user_video_status").then(response => {
  555. this.statusOptions = response.data;
  556. });
  557. this.getDicts("sys_company_or").then(response => {
  558. this.orOptions = response.data;
  559. });
  560. this.getDicts("sys_user_video_cate").then(response => {
  561. this.cateOptions = response.data;
  562. });
  563. this.getDicts("sys_video_source").then(response => {
  564. this.sourceOptions = response.data;
  565. });
  566. this.getDicts("sys_company_isaudit").then(response => {
  567. this.isAuditOptions = response.data;
  568. });
  569. this.getDicts("sys_company_or").then(response => {
  570. this.isDelOptions = response.data;
  571. });
  572. },
  573. methods: {
  574. getTagList(){
  575. subList().then(response => {
  576. this.tagList = response.data;
  577. });
  578. },
  579. handleVideoChange(){
  580. if(this.form.uploadType===1){
  581. this.videoUrl = this.form.txPcdnUrl;
  582. }else if(this.form.uploadType===2){
  583. this.videoUrl = this.form.hwObsUrl;
  584. }
  585. console.log("选择的video=======>>>>>>>",this.videoUrl)
  586. },
  587. handleVideoDuration(duration) {
  588. this.form.duration = duration;
  589. },
  590. selectPackage(){
  591. const packageItem = this.packageList.find(item=> item.packageId === this.form.productId);
  592. console.log(packageItem);
  593. if (packageItem) {
  594. this.packageItem = packageItem;
  595. }
  596. },
  597. handleDetails(row){
  598. this.show.open=true;
  599. setTimeout(() => {
  600. this.$refs.userVideoDetails.getDetails(row.videoId);
  601. }, 500);
  602. },
  603. submitAuditForm(){
  604. this.$refs["auditForm"].validate(valid => {
  605. if(valid){
  606. if(this.auditTags.length>0){
  607. this.auditForm.tags=this.auditTags.toString();
  608. }
  609. else{
  610. this.auditForm.tags = null
  611. }
  612. if (this.auditForm.videoIds !== []) {
  613. auditUserVideo(this.auditForm).then(response => {
  614. this.msgSuccess("审核成功");
  615. this.auditDialogClose();
  616. this.getList();
  617. });
  618. }
  619. }
  620. });
  621. },
  622. change(){
  623. if(this.createTime!=null){
  624. this.queryParams.sTime=this.createTime[0];
  625. this.queryParams.eTime=this.createTime[1];
  626. }else{
  627. this.queryParams.sTime=null;
  628. this.queryParams.eTime=null;
  629. }
  630. },
  631. auditChange(){
  632. if(this.auditTime!=null){
  633. this.queryParams.auditsTime=this.auditTime[0];
  634. this.queryParams.auditeTime=this.auditTime[1];
  635. }else{
  636. this.queryParams.auditsTime=null;
  637. this.queryParams.auditeTime=null;
  638. }
  639. },
  640. auditDialogClose(){
  641. this.auditDialog.open = false;
  642. },
  643. auditVideo(row){
  644. this.auditForm={
  645. videoIds:[],
  646. isAudit:1
  647. },
  648. this.auditDialog.open=true;
  649. this.auditForm.videoIds = row.videoId ? [row.videoId] : this.ids;
  650. },
  651. handleClickX(){
  652. this.getList()
  653. },
  654. talentMethod(query){
  655. if (query !== '') {
  656. this.talentParam.phone = query;
  657. listBySearch(this.talentParam).then(response => {
  658. this.talentList = response.data;
  659. });
  660. }
  661. },
  662. packageMethod(query){
  663. if (query !== '') {
  664. this.packageParam.secondName = query;
  665. packageBySearch(this.packageParam).then(response => {
  666. this.packageList = response.data;
  667. });
  668. }
  669. },
  670. /** 查询课堂视频列表 */
  671. getList() {
  672. this.loading = true;
  673. listUserVideo(this.queryParams).then(response => {
  674. this.userVideoList = response.rows;
  675. this.total = response.total;
  676. this.loading = false;
  677. });
  678. },
  679. // 取消按钮
  680. cancel() {
  681. this.open = false;
  682. this.reset();
  683. },
  684. // 表单重置
  685. reset() {
  686. this.form = {
  687. videoId: null,
  688. title: null,
  689. description: null,
  690. url: null,
  691. thumbnail: null,
  692. duration: null,
  693. createTime: null,
  694. userId: null,
  695. cateId: null,
  696. courseId: null,
  697. likes: null,
  698. views: null,
  699. comments: null,
  700. favoriteNum:null,
  701. status: null,
  702. isHot: null,
  703. isShow: null,
  704. isAudit: null,
  705. auditBy: null,
  706. auditTime: null,
  707. updateTime: null,
  708. source: null,
  709. isDel: null,
  710. shares: null,
  711. tags: null,
  712. txCdnUrl:null,
  713. txPcdnUrl:null,
  714. hwObsUrl:null,
  715. productId: null,
  716. productJson: null
  717. };
  718. this.tags=[];
  719. this.talentList=null
  720. this.packageList=null
  721. this.packageParam={
  722. packageId:null,
  723. secondName:null
  724. }
  725. this.packageParam={
  726. packageId:null,
  727. secondName:null
  728. }
  729. this.talentParam={
  730. talentId:null,
  731. phone:null
  732. }
  733. this.resetForm("form");
  734. },
  735. /** 搜索按钮操作 */
  736. handleQuery() {
  737. this.queryParams.pageNum = 1;
  738. this.getList();
  739. },
  740. /** 重置按钮操作 */
  741. resetQuery() {
  742. this.resetForm("queryForm");
  743. this.createTime=null;
  744. this.queryParams.sTime=null;
  745. this.queryParams.eTime=null;
  746. this.auditTime=null;
  747. this.queryParams.auditsTime=null;
  748. this.queryParams.auditeTime=null;
  749. this.handleQuery();
  750. },
  751. // 多选框选中数据
  752. handleSelectionChange(selection) {
  753. this.ids = selection.map(item => item.videoId)
  754. this.single = selection.length!==1
  755. this.multiple = !selection.length
  756. },
  757. handleAvatarSuccess(res, file) {
  758. if(res.code===200){
  759. this.form.thumbnail=res.url;
  760. this.$forceUpdate()
  761. }
  762. else{
  763. this.msgError(res.msg);
  764. }
  765. },
  766. beforeAvatarUpload(file) {
  767. return new Promise((resolve, reject) => {
  768. if (file.size / 1024 / 1024 > 3) {
  769. this.$message.error('上传的图片不能超过3MB');
  770. reject();
  771. return;
  772. }
  773. if (file.size / 1024 / 1024 > 1) {
  774. const loadingInstance = Loading.service({ text: '图片内存过大正在压缩图片...' });
  775. // 文件大于1MB时进行压缩
  776. this.compressImage(file).then((compressedFile) => {
  777. loadingInstance.close();
  778. if (compressedFile.size / 1024 > 500) {
  779. this.$message.error('图片压缩后仍大于500KB');
  780. reject();
  781. } else {
  782. // this.$message.success(`图片压缩成功,最终质量为: ${this.finalQuality.toFixed(2)}`);
  783. console.log(`图片压缩成功,最终质量为: ${this.finalQuality.toFixed(2)}`);
  784. console.log(`最终内存大小为: ${(compressedFile.size/1024).toFixed(2)}KB`);
  785. resolve(compressedFile);
  786. }
  787. }).catch((err) => {
  788. loadingInstance.close();
  789. console.error(err);
  790. reject();
  791. });
  792. } else {
  793. resolve(file);
  794. }
  795. });
  796. // const isLt1M = file.size / 1024 / 1024 < 1;
  797. // if (!isLt1M) {
  798. // this.$message.error('上传图片大小不能超过 1MB!');
  799. // }
  800. // return isLt1M;
  801. },
  802. compressImage(file) {
  803. return new Promise((resolve, reject) => {
  804. const reader = new FileReader();
  805. reader.readAsDataURL(file);
  806. reader.onload = (event) => {
  807. const img = new Image();
  808. img.src = event.target.result;
  809. img.onload = () => {
  810. const canvas = document.createElement('canvas');
  811. const ctx = canvas.getContext('2d');
  812. const width = img.width;
  813. const height = img.height;
  814. canvas.width = width;
  815. canvas.height = height;
  816. ctx.drawImage(img, 0, 0, width, height);
  817. let quality = 1; // 初始压缩质量
  818. let dataURL = canvas.toDataURL('image/jpeg', quality);
  819. // 逐步压缩,直到图片大小小于500KB并且压缩质量不再降低
  820. while (dataURL.length / 1024 > 500 && quality > 0.1) {
  821. quality -= 0.01;
  822. dataURL = canvas.toDataURL('image/jpeg', quality);
  823. }
  824. this.finalQuality = quality; // 存储最终的压缩质量
  825. if (dataURL.length / 1024 > 500) {
  826. reject(new Error('压缩后图片仍然大于500KB'));
  827. return;
  828. }
  829. const arr = dataURL.split(',');
  830. const mime = arr[0].match(/:(.*?);/)[1];
  831. const bstr = atob(arr[1]);
  832. let n = bstr.length;
  833. const u8arr = new Uint8Array(n);
  834. while (n--) {
  835. u8arr[n] = bstr.charCodeAt(n);
  836. }
  837. const compressedFile = new Blob([u8arr], { type: mime });
  838. compressedFile.name = file.name;
  839. resolve(compressedFile);
  840. };
  841. img.onerror = (error) => {
  842. reject(error);
  843. };
  844. };
  845. reader.onerror = (error) => {
  846. reject(error);
  847. };
  848. });
  849. },
  850. /** 新增按钮操作 */
  851. handleAdd() {
  852. this.reset();
  853. this.open = true;
  854. this.title = "添加课堂视频";
  855. this.process = 0;
  856. this.videoUrl=null;
  857. this.packageItem = null;
  858. setTimeout(() => {
  859. this.$refs.videoUpload.resetUpload();
  860. }, 500);
  861. },
  862. /** 修改按钮操作 */
  863. handleUpdate(row) {
  864. this.reset();
  865. const videoId = row.videoId || this.ids
  866. this.videoUrl=null;
  867. getUserVideo(videoId).then(response => {
  868. this.form = response.data;
  869. if(response.data.url!=null&&response.data.url!==''){
  870. this.videoUrl = response.data.url;
  871. }
  872. if(response.data.tags!=null){
  873. this.tags = response.data.tags.split(",");
  874. }
  875. this.form.status = response.data.status.toString();
  876. setTimeout(() => {
  877. this.$refs.videoUpload.resetUpload();
  878. }, 500);
  879. this.talentParam.talentId = response.data.talentId;
  880. listBySearch(this.talentParam).then(response => {
  881. this.talentList = response.data;
  882. });
  883. if(response.data.productId!=null){
  884. this.packageParam.packageId = response.data.productId;
  885. packageBySearch(this.packageParam).then(response => {
  886. this.packageList = response.data;
  887. });
  888. }
  889. this.open = true;
  890. this.title = "修改课堂视频";
  891. });
  892. // setTimeout(() => {
  893. // this.form.duration=parseInt(this.$refs.myvideo.duration);
  894. // console.log(this.$refs.myvideo.duration);
  895. // }, 2000);
  896. },
  897. /** 提交按钮 */
  898. submitForm() {
  899. this.$refs["form"].validate(valid => {
  900. if (valid) {
  901. if(this.tags.length>0){
  902. this.form.tags=this.tags.toString();
  903. }
  904. else{
  905. this.form.tags=null
  906. }
  907. this.form.url = this.videoUrl;
  908. if(this.form.url==null || this.form.url===''){
  909. this.$message({
  910. message: '请上传视频!',
  911. type: 'info'
  912. });
  913. return
  914. }
  915. if(this.form.duration==null){
  916. this.$message({
  917. message: '未识别到视频时长请稍等。。。',
  918. type: 'info'
  919. });
  920. return
  921. }
  922. if(this.packageItem!=null&&this.packageItem!==''){
  923. this.form.productJson = JSON.stringify(this.packageItem)
  924. }
  925. console.log("组装数据=====>",this.form);
  926. if (this.form.videoId != null) {
  927. updateUserVideo(this.form).then(response => {
  928. this.msgSuccess("修改成功");
  929. this.open = false;
  930. this.getList();
  931. });
  932. } else {
  933. addUserVideo(this.form).then(response => {
  934. this.msgSuccess("新增成功");
  935. this.open = false;
  936. this.getList();
  937. });
  938. }
  939. }
  940. });
  941. },
  942. /** 删除按钮操作 */
  943. handleDelete(row) {
  944. const videoIds = row.videoId || this.ids;
  945. this.$confirm('是否确认删除课堂视频编号为"' + videoIds + '"的数据项?', "警告", {
  946. confirmButtonText: "确定",
  947. cancelButtonText: "取消",
  948. type: "warning"
  949. }).then(function() {
  950. return delUserVideo(videoIds);
  951. }).then(() => {
  952. this.getList();
  953. this.msgSuccess("删除成功");
  954. }).catch(() => {});
  955. },
  956. /** 导出按钮操作 */
  957. handleExport() {
  958. const queryParams = this.queryParams;
  959. this.$confirm('是否确认导出所有课堂视频数据项?', "警告", {
  960. confirmButtonText: "确定",
  961. cancelButtonText: "取消",
  962. type: "warning"
  963. }).then(() => {
  964. this.exportLoading = true;
  965. return exportUserVideo(queryParams);
  966. }).then(response => {
  967. this.download(response.msg);
  968. this.exportLoading = false;
  969. }).catch(() => {});
  970. },
  971. putOn() {
  972. const videoIds =this.ids;
  973. if(videoIds==null||videoIds===""){
  974. return this.$message("未选择短视频");
  975. }
  976. this.$confirm('是否确认批量上架短视频?', "警告", {
  977. confirmButtonText: "确定",
  978. cancelButtonText: "取消",
  979. type: "warning"
  980. }).then(function() {
  981. return putOn(videoIds);
  982. }).then(() => {
  983. this.getList();
  984. this.msgSuccess("上架成功");
  985. }).catch(function() {});
  986. },
  987. pullOff() {
  988. const videoIds =this.ids;
  989. if(videoIds==null||videoIds===""){
  990. return this.$message("未选择短视频");
  991. }
  992. this.$confirm('是否确认批量下架短视频?', "警告", {
  993. confirmButtonText: "确定",
  994. cancelButtonText: "取消",
  995. type: "warning"
  996. }).then(function() {
  997. return pullOff(videoIds);
  998. }).then(() => {
  999. this.getList();
  1000. this.msgSuccess("下架成功");
  1001. }).catch(function() {});
  1002. }
  1003. }
  1004. };
  1005. </script>
  1006. <style scoped>
  1007. .tag-box{
  1008. margin: 10px;
  1009. padding: 5px;
  1010. background-color: #f7f7f7 ;
  1011. border-radius: 4px;
  1012. border: 1px solid #d0d0d0 ;
  1013. }
  1014. .tag-selectd{
  1015. background-color: rgb(231, 244, 255) ;
  1016. border: 1px solid rgb(11, 162, 255) ;
  1017. }
  1018. .el-tag + .el-tag {
  1019. margin-left: 10px;
  1020. }
  1021. .avatar-uploader .el-upload {
  1022. border: 1px dashed #d9d9d9;
  1023. border-radius: 6px;
  1024. cursor: pointer;
  1025. position: relative;
  1026. overflow: hidden;
  1027. }
  1028. .avatar-uploader .el-upload:hover {
  1029. border-color: #409EFF;
  1030. }
  1031. .avatar-uploader-icon {
  1032. font-size: 28px;
  1033. color: #8c939d;
  1034. width: 150px;
  1035. height: 150px;
  1036. line-height: 150px;
  1037. text-align: center;
  1038. }
  1039. </style>