index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065
  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. :headers="uploadHeaders"
  269. :show-file-list="false"
  270. :on-success="handleAvatarSuccess"
  271. :before-upload="beforeAvatarUpload">
  272. <img v-if="form.thumbnail" :src="form.thumbnail" class="avatar" width="300px">
  273. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  274. </el-upload>
  275. </el-form-item>
  276. <video-upload
  277. :type="2"
  278. :videoUrl.sync="videoUrl"
  279. :fileKey.sync = "form.fileKey"
  280. :fileSize.sync = "form.fileSize"
  281. :line_1.sync="form.txPcdnUrl"
  282. :line_2.sync="form.hwObsUrl"
  283. :thumbnail.sync="form.thumbnail"
  284. :uploadType.sync="form.uploadType"
  285. @video-duration="handleVideoDuration"
  286. @change="handleVideoChange"
  287. ref="videoUpload"
  288. />
  289. <el-row>
  290. <el-col :span="8">
  291. <el-form-item label="收藏数" prop="favoriteNum">
  292. <el-input-number v-model="form.favoriteNum" :min="0" label="收藏数"></el-input-number>
  293. </el-form-item>
  294. </el-col>
  295. <el-col :span="8">
  296. <el-form-item label="播放量" prop="views">
  297. <el-input-number v-model="form.views" :min="0" label="浏览量"></el-input-number>
  298. </el-form-item>
  299. </el-col>
  300. <el-col :span="8">
  301. <el-form-item label="点赞量" prop="likes">
  302. <el-input-number v-model="form.likes" :min="0" label="点赞量"></el-input-number>
  303. </el-form-item>
  304. </el-col>
  305. </el-row>
  306. <el-row>
  307. <el-col :span="8">
  308. <el-form-item label="分享数" prop="shares">
  309. <el-input-number v-model="form.shares" :min="0" label="分享数"></el-input-number>
  310. </el-form-item>
  311. </el-col>
  312. <el-col :span="8">
  313. <el-form-item label="评论数" prop="comments">
  314. <el-input-number v-model="form.comments" :min="0" label="分享数"></el-input-number>
  315. </el-form-item>
  316. </el-col>
  317. <el-col :span="8">
  318. <el-form-item prop="tags" label="标签">
  319. <el-select v-model="tags" placeholder="请选择标签" multiple filterable clearable size="small">
  320. <el-option
  321. v-for="dict in tagList"
  322. :key="dict.tagId"
  323. :label="dict.tagName"
  324. :value="dict.tagId"
  325. />
  326. </el-select>
  327. </el-form-item>
  328. </el-col>
  329. </el-row>
  330. </el-form>
  331. <div slot="footer" class="dialog-footer">
  332. <el-button type="primary" @click="submitForm">确 定</el-button>
  333. <el-button @click="cancel">取 消</el-button>
  334. </div>
  335. </el-dialog>
  336. <el-dialog :title="auditDialog.title" :visible.sync="auditDialog.open" width="800px" append-to-body @close="auditDialogClose">
  337. <el-form ref="auditForm" :model="auditForm" :rules="auditRules" label-width="100px">
  338. <el-form-item label="审核" prop="isAudit">
  339. <el-radio-group v-model="auditForm.isAudit">
  340. <el-radio :label="item.dictValue" v-for="item in auditRadio" >{{item.dictLabel}}</el-radio>
  341. </el-radio-group>
  342. </el-form-item>
  343. <el-form-item label="备注" prop="remark">
  344. <el-input type="textarea" v-model="auditForm.remark" placeholder="备注" />
  345. </el-form-item>
  346. <el-form-item prop="tags" style="width: 500px" label="标签">
  347. <el-select v-model="auditTags" placeholder="请选择标签" multiple filterable clearable size="small">
  348. <el-option
  349. v-for="dict in tagList"
  350. :key="dict.tagId"
  351. :label="dict.tagName"
  352. :value="dict.tagId"
  353. />
  354. </el-select>
  355. </el-form-item>
  356. </el-form>
  357. <div slot="footer" class="dialog-footer" >
  358. <el-button type="primary" @click="submitAuditForm">提交</el-button>
  359. <el-button @click="auditDialogClose">取消</el-button>
  360. </div>
  361. </el-dialog>
  362. <el-drawer
  363. :with-header="false"
  364. size="75%"
  365. :visible.sync="show.open">
  366. <userVideoDetails ref="userVideoDetails" />
  367. </el-drawer>
  368. </div>
  369. </template>
  370. <script>
  371. import VideoUpload from '@/components/VideoUpload/index';
  372. import { listUserVideo, getUserVideo, delUserVideo, addUserVideo, updateUserVideo, exportUserVideo,auditUserVideo,putOn,pullOff } from "@/api/course/userVideo";
  373. import {getSignature,uploadHuaWeiVod} from "@/api/common"
  374. import { listBySearch} from "@/api/course/userTalent";
  375. import { subList} from "@/api/course/userVideoTags";
  376. import { packageBySearch} from "@/api/his/package";
  377. import TcVod from 'vod-js-sdk-v6'
  378. import userVideoDetails from '../../components/course/userVideoDetails.vue';
  379. import { BasicCredentials } from '@huaweicloud/huaweicloud-sdk-core';
  380. import { VodClient, VodRegion, CreateAssetByFileUploadRequest,ShowAssetTempAuthorityRequest } from '@huaweicloud/huaweicloud-sdk-vod';
  381. import axios from 'axios';
  382. import { Loading } from 'element-ui';
  383. import { uploadObject } from '@/utils/cos.js';
  384. import { uploadToOBS } from '@/utils/obs.js';
  385. import { getToken } from "@/utils/auth";
  386. export default {
  387. name: "UserVideo",
  388. components: {
  389. userVideoDetails,VideoUpload
  390. },
  391. data() {
  392. return {
  393. tagsOptions:[],
  394. tags:[],
  395. //所有的标签
  396. tagList:[],
  397. uploadTypeOptions:[{
  398. "dictLabel": "线路一",
  399. "dictValue": 1
  400. },
  401. {
  402. "dictLabel": "线路二",
  403. "dictValue": 2
  404. },
  405. ],
  406. specShowOptions:[],
  407. finalQuality:1,
  408. packageItem:{},
  409. uploadLoading:false,
  410. show:{
  411. title:"短视频详情",
  412. open :false
  413. },
  414. auditRadio: [{
  415. "dictLabel": "通过",
  416. "dictValue": 1
  417. }, {
  418. "dictLabel": "驳回",
  419. "dictValue": -1
  420. }],
  421. auditDialog:{
  422. title:"短视频审核",
  423. open:false
  424. },
  425. auditTags:[],
  426. auditForm:{
  427. videoIds:[],
  428. isAudit:null,
  429. tags:''
  430. },
  431. auditRules:{
  432. isAudit: [
  433. { required: true, message: "请选择审核状态", trigger: "blur" }
  434. ],
  435. },
  436. isAuditOptions:[],
  437. talentParam:{
  438. phone:null,
  439. talentId:null,
  440. },
  441. packageParam:{
  442. secondName:null,
  443. packageId:null,
  444. isShow:1,
  445. status:1
  446. },
  447. talentList:[],
  448. packageList:[],
  449. files:[],
  450. fileList: [],
  451. // 上传成功后的地址
  452. videoURL: '',
  453. // 进度条百分比
  454. progress: 0,
  455. // 上传视频获取成功后拿到的fileID【备用】
  456. fileId: '',
  457. // 遮罩层
  458. loading: true,
  459. // 导出遮罩层
  460. exportLoading: false,
  461. // 选中数组
  462. ids: [],
  463. videoUrl: "",
  464. videoAccept:"video/*",
  465. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  466. // el-upload 不会走 axios 拦截器,需手动带上 token
  467. uploadHeaders: { Authorization: "Bearer " + getToken() },
  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. // 上传前刷新 token
  768. this.uploadHeaders.Authorization = "Bearer " + getToken();
  769. return new Promise((resolve, reject) => {
  770. if (file.size / 1024 / 1024 > 3) {
  771. this.$message.error('上传的图片不能超过3MB');
  772. reject();
  773. return;
  774. }
  775. if (file.size / 1024 / 1024 > 1) {
  776. const loadingInstance = Loading.service({ text: '图片内存过大正在压缩图片...' });
  777. // 文件大于1MB时进行压缩
  778. this.compressImage(file).then((compressedFile) => {
  779. loadingInstance.close();
  780. if (compressedFile.size / 1024 > 500) {
  781. this.$message.error('图片压缩后仍大于500KB');
  782. reject();
  783. } else {
  784. // this.$message.success(`图片压缩成功,最终质量为: ${this.finalQuality.toFixed(2)}`);
  785. console.log(`图片压缩成功,最终质量为: ${this.finalQuality.toFixed(2)}`);
  786. console.log(`最终内存大小为: ${(compressedFile.size/1024).toFixed(2)}KB`);
  787. resolve(compressedFile);
  788. }
  789. }).catch((err) => {
  790. loadingInstance.close();
  791. console.error(err);
  792. reject();
  793. });
  794. } else {
  795. resolve(file);
  796. }
  797. });
  798. // const isLt1M = file.size / 1024 / 1024 < 1;
  799. // if (!isLt1M) {
  800. // this.$message.error('上传图片大小不能超过 1MB!');
  801. // }
  802. // return isLt1M;
  803. },
  804. compressImage(file) {
  805. return new Promise((resolve, reject) => {
  806. const reader = new FileReader();
  807. reader.readAsDataURL(file);
  808. reader.onload = (event) => {
  809. const img = new Image();
  810. img.src = event.target.result;
  811. img.onload = () => {
  812. const canvas = document.createElement('canvas');
  813. const ctx = canvas.getContext('2d');
  814. const width = img.width;
  815. const height = img.height;
  816. canvas.width = width;
  817. canvas.height = height;
  818. ctx.drawImage(img, 0, 0, width, height);
  819. let quality = 1; // 初始压缩质量
  820. let dataURL = canvas.toDataURL('image/jpeg', quality);
  821. // 逐步压缩,直到图片大小小于500KB并且压缩质量不再降低
  822. while (dataURL.length / 1024 > 500 && quality > 0.1) {
  823. quality -= 0.01;
  824. dataURL = canvas.toDataURL('image/jpeg', quality);
  825. }
  826. this.finalQuality = quality; // 存储最终的压缩质量
  827. if (dataURL.length / 1024 > 500) {
  828. reject(new Error('压缩后图片仍然大于500KB'));
  829. return;
  830. }
  831. const arr = dataURL.split(',');
  832. const mime = arr[0].match(/:(.*?);/)[1];
  833. const bstr = atob(arr[1]);
  834. let n = bstr.length;
  835. const u8arr = new Uint8Array(n);
  836. while (n--) {
  837. u8arr[n] = bstr.charCodeAt(n);
  838. }
  839. const compressedFile = new Blob([u8arr], { type: mime });
  840. compressedFile.name = file.name;
  841. resolve(compressedFile);
  842. };
  843. img.onerror = (error) => {
  844. reject(error);
  845. };
  846. };
  847. reader.onerror = (error) => {
  848. reject(error);
  849. };
  850. });
  851. },
  852. /** 新增按钮操作 */
  853. handleAdd() {
  854. this.reset();
  855. this.open = true;
  856. this.title = "添加课堂视频";
  857. this.process = 0;
  858. this.videoUrl=null;
  859. this.packageItem = null;
  860. setTimeout(() => {
  861. this.$refs.videoUpload.resetUpload();
  862. }, 500);
  863. },
  864. /** 修改按钮操作 */
  865. handleUpdate(row) {
  866. this.reset();
  867. const videoId = row.videoId || this.ids
  868. this.videoUrl=null;
  869. getUserVideo(videoId).then(response => {
  870. this.form = response.data;
  871. if(response.data.url!=null&&response.data.url!==''){
  872. this.videoUrl = response.data.url;
  873. }
  874. if(response.data.tags!=null){
  875. this.tags = response.data.tags.split(",");
  876. }
  877. this.form.status = response.data.status.toString();
  878. setTimeout(() => {
  879. this.$refs.videoUpload.resetUpload();
  880. }, 500);
  881. this.talentParam.talentId = response.data.talentId;
  882. listBySearch(this.talentParam).then(response => {
  883. this.talentList = response.data;
  884. });
  885. if(response.data.productId!=null){
  886. this.packageParam.packageId = response.data.productId;
  887. packageBySearch(this.packageParam).then(response => {
  888. this.packageList = response.data;
  889. });
  890. }
  891. this.open = true;
  892. this.title = "修改课堂视频";
  893. });
  894. // setTimeout(() => {
  895. // this.form.duration=parseInt(this.$refs.myvideo.duration);
  896. // console.log(this.$refs.myvideo.duration);
  897. // }, 2000);
  898. },
  899. /** 提交按钮 */
  900. submitForm() {
  901. this.$refs["form"].validate(valid => {
  902. if (valid) {
  903. if(this.tags.length>0){
  904. this.form.tags=this.tags.toString();
  905. }
  906. else{
  907. this.form.tags=null
  908. }
  909. this.form.url = this.videoUrl;
  910. if(this.form.url==null || this.form.url===''){
  911. this.$message({
  912. message: '请上传视频!',
  913. type: 'info'
  914. });
  915. return
  916. }
  917. if(this.form.duration==null){
  918. this.$message({
  919. message: '未识别到视频时长请稍等。。。',
  920. type: 'info'
  921. });
  922. return
  923. }
  924. if(this.packageItem!=null&&this.packageItem!==''){
  925. this.form.productJson = JSON.stringify(this.packageItem)
  926. }
  927. console.log("组装数据=====>",this.form);
  928. if (this.form.videoId != null) {
  929. updateUserVideo(this.form).then(response => {
  930. this.msgSuccess("修改成功");
  931. this.open = false;
  932. this.getList();
  933. });
  934. } else {
  935. addUserVideo(this.form).then(response => {
  936. this.msgSuccess("新增成功");
  937. this.open = false;
  938. this.getList();
  939. });
  940. }
  941. }
  942. });
  943. },
  944. /** 删除按钮操作 */
  945. handleDelete(row) {
  946. const videoIds = row.videoId || this.ids;
  947. this.$confirm('是否确认删除课堂视频编号为"' + videoIds + '"的数据项?', "警告", {
  948. confirmButtonText: "确定",
  949. cancelButtonText: "取消",
  950. type: "warning"
  951. }).then(function() {
  952. return delUserVideo(videoIds);
  953. }).then(() => {
  954. this.getList();
  955. this.msgSuccess("删除成功");
  956. }).catch(() => {});
  957. },
  958. /** 导出按钮操作 */
  959. handleExport() {
  960. const queryParams = this.queryParams;
  961. this.$confirm('是否确认导出所有课堂视频数据项?', "警告", {
  962. confirmButtonText: "确定",
  963. cancelButtonText: "取消",
  964. type: "warning"
  965. }).then(() => {
  966. this.exportLoading = true;
  967. return exportUserVideo(queryParams);
  968. }).then(response => {
  969. this.download(response.msg);
  970. this.exportLoading = false;
  971. }).catch(() => {});
  972. },
  973. putOn() {
  974. const videoIds =this.ids;
  975. if(videoIds==null||videoIds===""){
  976. return this.$message("未选择短视频");
  977. }
  978. this.$confirm('是否确认批量上架短视频?', "警告", {
  979. confirmButtonText: "确定",
  980. cancelButtonText: "取消",
  981. type: "warning"
  982. }).then(function() {
  983. return putOn(videoIds);
  984. }).then(() => {
  985. this.getList();
  986. this.msgSuccess("上架成功");
  987. }).catch(function() {});
  988. },
  989. pullOff() {
  990. const videoIds =this.ids;
  991. if(videoIds==null||videoIds===""){
  992. return this.$message("未选择短视频");
  993. }
  994. this.$confirm('是否确认批量下架短视频?', "警告", {
  995. confirmButtonText: "确定",
  996. cancelButtonText: "取消",
  997. type: "warning"
  998. }).then(function() {
  999. return pullOff(videoIds);
  1000. }).then(() => {
  1001. this.getList();
  1002. this.msgSuccess("下架成功");
  1003. }).catch(function() {});
  1004. }
  1005. }
  1006. };
  1007. </script>
  1008. <style scoped>
  1009. .tag-box{
  1010. margin: 10px;
  1011. padding: 5px;
  1012. background-color: #f7f7f7 ;
  1013. border-radius: 4px;
  1014. border: 1px solid #d0d0d0 ;
  1015. }
  1016. .tag-selectd{
  1017. background-color: rgb(231, 244, 255) ;
  1018. border: 1px solid rgb(11, 162, 255) ;
  1019. }
  1020. .el-tag + .el-tag {
  1021. margin-left: 10px;
  1022. }
  1023. .avatar-uploader .el-upload {
  1024. border: 1px dashed #d9d9d9;
  1025. border-radius: 6px;
  1026. cursor: pointer;
  1027. position: relative;
  1028. overflow: hidden;
  1029. }
  1030. .avatar-uploader .el-upload:hover {
  1031. border-color: #409EFF;
  1032. }
  1033. .avatar-uploader-icon {
  1034. font-size: 28px;
  1035. color: #8c939d;
  1036. width: 150px;
  1037. height: 150px;
  1038. line-height: 150px;
  1039. text-align: center;
  1040. }
  1041. </style>