index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  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. <img v-if="form.thumbnail" :src="form.thumbnail" class="avatar" width="300px">
  272. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  273. </el-upload>
  274. </el-form-item>
  275. <video-upload
  276. :type="2"
  277. :videoUrl.sync="videoUrl"
  278. :fileKey.sync = "form.fileKey"
  279. :fileSize.sync = "form.fileSize"
  280. :line_1.sync="form.txPcdnUrl"
  281. :line_2.sync="form.hwObsUrl"
  282. :thumbnail.sync="form.thumbnail"
  283. :uploadType.sync="form.uploadType"
  284. @video-duration="handleVideoDuration"
  285. @change="handleVideoChange"
  286. ref="videoUpload"
  287. />
  288. <el-row>
  289. <el-col :span="8">
  290. <el-form-item label="收藏数" prop="favoriteNum">
  291. <el-input-number v-model="form.favoriteNum" :min="0" label="收藏数"></el-input-number>
  292. </el-form-item>
  293. </el-col>
  294. <el-col :span="8">
  295. <el-form-item label="播放量" prop="views">
  296. <el-input-number v-model="form.views" :min="0" label="浏览量"></el-input-number>
  297. </el-form-item>
  298. </el-col>
  299. <el-col :span="8">
  300. <el-form-item label="点赞量" prop="likes">
  301. <el-input-number v-model="form.likes" :min="0" label="点赞量"></el-input-number>
  302. </el-form-item>
  303. </el-col>
  304. </el-row>
  305. <el-row>
  306. <el-col :span="8">
  307. <el-form-item label="分享数" prop="shares">
  308. <el-input-number v-model="form.shares" :min="0" label="分享数"></el-input-number>
  309. </el-form-item>
  310. </el-col>
  311. <el-col :span="8">
  312. <el-form-item label="评论数" prop="comments">
  313. <el-input-number v-model="form.comments" :min="0" label="分享数"></el-input-number>
  314. </el-form-item>
  315. </el-col>
  316. <el-col :span="8">
  317. <el-form-item prop="tags" label="标签">
  318. <el-select v-model="tags" placeholder="请选择标签" multiple filterable clearable size="small">
  319. <el-option
  320. v-for="dict in tagList"
  321. :key="dict.tagId"
  322. :label="dict.tagName"
  323. :value="dict.tagId"
  324. />
  325. </el-select>
  326. </el-form-item>
  327. </el-col>
  328. </el-row>
  329. </el-form>
  330. <div slot="footer" class="dialog-footer">
  331. <el-button type="primary" @click="submitForm">确 定</el-button>
  332. <el-button @click="cancel">取 消</el-button>
  333. </div>
  334. </el-dialog>
  335. <el-dialog :title="auditDialog.title" :visible.sync="auditDialog.open" width="800px" append-to-body @close="auditDialogClose">
  336. <el-form ref="auditForm" :model="auditForm" :rules="auditRules" label-width="100px">
  337. <el-form-item label="审核" prop="isAudit">
  338. <el-radio-group v-model="auditForm.isAudit">
  339. <el-radio :label="item.dictValue" v-for="item in auditRadio" >{{item.dictLabel}}</el-radio>
  340. </el-radio-group>
  341. </el-form-item>
  342. <el-form-item label="备注" prop="remark">
  343. <el-input type="textarea" v-model="auditForm.remark" placeholder="备注" />
  344. </el-form-item>
  345. <el-form-item prop="tags" style="width: 500px" label="标签">
  346. <el-select v-model="auditTags" placeholder="请选择标签" multiple filterable clearable size="small">
  347. <el-option
  348. v-for="dict in tagList"
  349. :key="dict.tagId"
  350. :label="dict.tagName"
  351. :value="dict.tagId"
  352. />
  353. </el-select>
  354. </el-form-item>
  355. </el-form>
  356. <div slot="footer" class="dialog-footer" >
  357. <el-button type="primary" @click="submitAuditForm">提交</el-button>
  358. <el-button @click="auditDialogClose">取消</el-button>
  359. </div>
  360. </el-dialog>
  361. <el-drawer
  362. :with-header="false"
  363. size="75%"
  364. :visible.sync="show.open">
  365. <userVideoDetails ref="userVideoDetails" />
  366. </el-drawer>
  367. </div>
  368. </template>
  369. <script>
  370. import VideoUpload from '@/components/VideoUpload/index';
  371. import { listUserVideo, getUserVideo, delUserVideo, addUserVideo, updateUserVideo, exportUserVideo,auditUserVideo,putOn,pullOff } from "@/api/course/userVideo";
  372. import {getSignature,uploadHuaWeiVod} from "@/api/common"
  373. import { listBySearch} from "@/api/course/userTalent";
  374. import { subList} from "@/api/course/userVideoTags";
  375. import { packageBySearch} from "@/api/his/package";
  376. import TcVod from 'vod-js-sdk-v6'
  377. import userVideoDetails from '../../components/course/userVideoDetails.vue';
  378. import { BasicCredentials } from '@huaweicloud/huaweicloud-sdk-core';
  379. import { VodClient, VodRegion, CreateAssetByFileUploadRequest,ShowAssetTempAuthorityRequest } from '@huaweicloud/huaweicloud-sdk-vod';
  380. import axios from 'axios';
  381. import { Loading } from 'element-ui';
  382. import { uploadObject } from '@/utils/cos.js';
  383. import { uploadToOBS } from '@/utils/obs.js';
  384. export default {
  385. name: "UserVideo",
  386. components: {
  387. userVideoDetails,VideoUpload
  388. },
  389. data() {
  390. return {
  391. tagsOptions:[],
  392. tags:[],
  393. //所有的标签
  394. tagList:[],
  395. uploadTypeOptions:[{
  396. "dictLabel": "线路一",
  397. "dictValue": 1
  398. },
  399. {
  400. "dictLabel": "线路二",
  401. "dictValue": 2
  402. },
  403. ],
  404. specShowOptions:[],
  405. finalQuality:1,
  406. packageItem:{},
  407. uploadLoading:false,
  408. show:{
  409. title:"短视频详情",
  410. open :false
  411. },
  412. auditRadio: [{
  413. "dictLabel": "通过",
  414. "dictValue": 1
  415. }, {
  416. "dictLabel": "驳回",
  417. "dictValue": -1
  418. }],
  419. auditDialog:{
  420. title:"短视频审核",
  421. open:false
  422. },
  423. auditTags:[],
  424. auditForm:{
  425. videoIds:[],
  426. isAudit:null,
  427. tags:''
  428. },
  429. auditRules:{
  430. isAudit: [
  431. { required: true, message: "请选择审核状态", trigger: "blur" }
  432. ],
  433. },
  434. isAuditOptions:[],
  435. talentParam:{
  436. phone:null,
  437. talentId:null,
  438. },
  439. packageParam:{
  440. secondName:null,
  441. packageId:null,
  442. isShow:1,
  443. status:1
  444. },
  445. talentList:[],
  446. packageList:[],
  447. files:[],
  448. fileList: [],
  449. // 上传成功后的地址
  450. videoURL: '',
  451. // 进度条百分比
  452. progress: 0,
  453. // 上传视频获取成功后拿到的fileID【备用】
  454. fileId: '',
  455. // 遮罩层
  456. loading: true,
  457. // 导出遮罩层
  458. exportLoading: false,
  459. // 选中数组
  460. ids: [],
  461. videoUrl: "",
  462. videoAccept:"video/*",
  463. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  464. baseUrl: process.env.VUE_APP_BASE_API,
  465. cateOptions:[],
  466. // 非单个禁用
  467. single: true,
  468. // 非多个禁用
  469. multiple: true,
  470. // 显示搜索条件
  471. showSearch: true,
  472. // 总条数
  473. total: 0,
  474. // 课堂视频表格数据
  475. userVideoList: [],
  476. // 弹出层标题
  477. title: "",
  478. // 是否显示弹出层
  479. open: false,
  480. // 课程ID字典
  481. courseIdOptions: [],
  482. // 视频状态 1:草稿,2:待审核,3:发布字典
  483. statusOptions: [],
  484. // 是否展示字典
  485. orOptions: [],
  486. // 来源 1 用户 2 后台字典
  487. sourceOptions: [],
  488. // 删除标志字典
  489. isDelOptions: [],
  490. // 查询参数
  491. queryParams: {
  492. pageNum: 1,
  493. pageSize: 10,
  494. title: null,
  495. description: null,
  496. url: null,
  497. thumbnail: null,
  498. duration: null,
  499. userId: null,
  500. cateId: null,
  501. courseId: null,
  502. likes: null,
  503. views: null,
  504. comments: null,
  505. status: null,
  506. courseSort: null,
  507. isHot: null,
  508. isShow: null,
  509. isAudit: 0,
  510. auditBy: null,
  511. auditTime: null,
  512. source: null,
  513. isDel: null,
  514. shares: null,
  515. tags: '',
  516. productId: null,
  517. productJson: null,
  518. sTime:null,
  519. eTime:null,
  520. auditsTime:null,
  521. auditeTime:null,
  522. },
  523. createTime:null,
  524. auditTime:null,
  525. // 表单参数
  526. form: {},
  527. // 表单校验
  528. rules: {
  529. title: [
  530. { required: true, message: "短视频标题不能为空", trigger: "blur" }
  531. ],
  532. // talentId: [
  533. // { required: true, message: "关联达人不能为空", trigger: "change" }
  534. // ],
  535. thumbnail: [
  536. { required: true, message: "请上传视频封面", trigger: "blur" }
  537. ]
  538. }
  539. };
  540. },
  541. created() {
  542. this.getList();
  543. this.getTagList();
  544. this.getDicts("sys_course_tags").then(response => {
  545. this.tagsOptions = response.data;
  546. });
  547. this.getDicts("sys_spec_show").then(response => {
  548. this.specShowOptions = response.data;
  549. });
  550. this.getDicts("sys_user_video_status").then(response => {
  551. this.statusOptions = response.data;
  552. });
  553. this.getDicts("sys_company_or").then(response => {
  554. this.orOptions = response.data;
  555. });
  556. this.getDicts("sys_user_video_cate").then(response => {
  557. this.cateOptions = response.data;
  558. });
  559. this.getDicts("sys_video_source").then(response => {
  560. this.sourceOptions = response.data;
  561. });
  562. this.getDicts("sys_company_isaudit").then(response => {
  563. this.isAuditOptions = response.data;
  564. });
  565. this.getDicts("sys_company_or").then(response => {
  566. this.isDelOptions = response.data;
  567. });
  568. },
  569. methods: {
  570. getTagList(){
  571. subList().then(response => {
  572. this.tagList = response.data;
  573. });
  574. },
  575. handleVideoChange(){
  576. if(this.form.uploadType===1){
  577. this.videoUrl = this.form.txPcdnUrl;
  578. }else if(this.form.uploadType===2){
  579. this.videoUrl = this.form.hwObsUrl;
  580. }
  581. console.log("选择的video=======>>>>>>>",this.videoUrl)
  582. },
  583. handleVideoDuration(duration) {
  584. this.form.duration = duration;
  585. },
  586. selectPackage(){
  587. const packageItem = this.packageList.find(item=> item.packageId === this.form.productId);
  588. console.log(packageItem);
  589. if (packageItem) {
  590. this.packageItem = packageItem;
  591. }
  592. },
  593. handleDetails(row){
  594. this.show.open=true;
  595. setTimeout(() => {
  596. this.$refs.userVideoDetails.getDetails(row.videoId);
  597. }, 500);
  598. },
  599. submitAuditForm(){
  600. this.$refs["auditForm"].validate(valid => {
  601. if(valid){
  602. if(this.auditTags.length>0){
  603. this.auditForm.tags=this.auditTags.toString();
  604. }
  605. else{
  606. this.auditForm.tags = null
  607. }
  608. if (this.auditForm.videoIds !== []) {
  609. auditUserVideo(this.auditForm).then(response => {
  610. this.msgSuccess("审核成功");
  611. this.auditDialogClose();
  612. this.getList();
  613. });
  614. }
  615. }
  616. });
  617. },
  618. change(){
  619. if(this.createTime!=null){
  620. this.queryParams.sTime=this.createTime[0];
  621. this.queryParams.eTime=this.createTime[1];
  622. }else{
  623. this.queryParams.sTime=null;
  624. this.queryParams.eTime=null;
  625. }
  626. },
  627. auditChange(){
  628. if(this.auditTime!=null){
  629. this.queryParams.auditsTime=this.auditTime[0];
  630. this.queryParams.auditeTime=this.auditTime[1];
  631. }else{
  632. this.queryParams.auditsTime=null;
  633. this.queryParams.auditeTime=null;
  634. }
  635. },
  636. auditDialogClose(){
  637. this.auditDialog.open = false;
  638. },
  639. auditVideo(row){
  640. this.auditForm={
  641. videoIds:[],
  642. isAudit:1
  643. },
  644. this.auditDialog.open=true;
  645. this.auditForm.videoIds = row.videoId || this.ids;
  646. },
  647. handleClickX(){
  648. this.getList()
  649. },
  650. talentMethod(query){
  651. if (query !== '') {
  652. this.talentParam.phone = query;
  653. listBySearch(this.talentParam).then(response => {
  654. this.talentList = response.data;
  655. });
  656. }
  657. },
  658. packageMethod(query){
  659. if (query !== '') {
  660. this.packageParam.secondName = query;
  661. packageBySearch(this.packageParam).then(response => {
  662. this.packageList = response.data;
  663. });
  664. }
  665. },
  666. /** 查询课堂视频列表 */
  667. getList() {
  668. this.loading = true;
  669. listUserVideo(this.queryParams).then(response => {
  670. this.userVideoList = response.rows;
  671. this.total = response.total;
  672. this.loading = false;
  673. });
  674. },
  675. // 取消按钮
  676. cancel() {
  677. this.open = false;
  678. this.reset();
  679. },
  680. // 表单重置
  681. reset() {
  682. this.form = {
  683. videoId: null,
  684. title: null,
  685. description: null,
  686. url: null,
  687. thumbnail: null,
  688. duration: null,
  689. createTime: null,
  690. userId: null,
  691. cateId: null,
  692. courseId: null,
  693. likes: null,
  694. views: null,
  695. comments: null,
  696. favoriteNum:null,
  697. status: null,
  698. isHot: null,
  699. isShow: null,
  700. isAudit: null,
  701. auditBy: null,
  702. auditTime: null,
  703. updateTime: null,
  704. source: null,
  705. isDel: null,
  706. shares: null,
  707. tags: null,
  708. txCdnUrl:null,
  709. txPcdnUrl:null,
  710. hwObsUrl:null,
  711. productId: null,
  712. productJson: null
  713. };
  714. this.tags=[];
  715. this.talentList=null
  716. this.packageList=null
  717. this.packageParam={
  718. packageId:null,
  719. secondName:null
  720. }
  721. this.packageParam={
  722. packageId:null,
  723. secondName:null
  724. }
  725. this.talentParam={
  726. talentId:null,
  727. phone:null
  728. }
  729. this.resetForm("form");
  730. },
  731. /** 搜索按钮操作 */
  732. handleQuery() {
  733. this.queryParams.pageNum = 1;
  734. this.getList();
  735. },
  736. /** 重置按钮操作 */
  737. resetQuery() {
  738. this.resetForm("queryForm");
  739. this.createTime=null;
  740. this.queryParams.sTime=null;
  741. this.queryParams.eTime=null;
  742. this.auditTime=null;
  743. this.queryParams.auditsTime=null;
  744. this.queryParams.auditeTime=null;
  745. this.handleQuery();
  746. },
  747. // 多选框选中数据
  748. handleSelectionChange(selection) {
  749. this.ids = selection.map(item => item.videoId)
  750. this.single = selection.length!==1
  751. this.multiple = !selection.length
  752. },
  753. handleAvatarSuccess(res, file) {
  754. if(res.code===200){
  755. this.form.thumbnail=res.url;
  756. this.$forceUpdate()
  757. }
  758. else{
  759. this.msgError(res.msg);
  760. }
  761. },
  762. beforeAvatarUpload(file) {
  763. return new Promise((resolve, reject) => {
  764. if (file.size / 1024 / 1024 > 3) {
  765. this.$message.error('上传的图片不能超过3MB');
  766. reject();
  767. return;
  768. }
  769. if (file.size / 1024 / 1024 > 1) {
  770. const loadingInstance = Loading.service({ text: '图片内存过大正在压缩图片...' });
  771. // 文件大于1MB时进行压缩
  772. this.compressImage(file).then((compressedFile) => {
  773. loadingInstance.close();
  774. if (compressedFile.size / 1024 > 500) {
  775. this.$message.error('图片压缩后仍大于500KB');
  776. reject();
  777. } else {
  778. // this.$message.success(`图片压缩成功,最终质量为: ${this.finalQuality.toFixed(2)}`);
  779. console.log(`图片压缩成功,最终质量为: ${this.finalQuality.toFixed(2)}`);
  780. console.log(`最终内存大小为: ${(compressedFile.size/1024).toFixed(2)}KB`);
  781. resolve(compressedFile);
  782. }
  783. }).catch((err) => {
  784. loadingInstance.close();
  785. console.error(err);
  786. reject();
  787. });
  788. } else {
  789. resolve(file);
  790. }
  791. });
  792. // const isLt1M = file.size / 1024 / 1024 < 1;
  793. // if (!isLt1M) {
  794. // this.$message.error('上传图片大小不能超过 1MB!');
  795. // }
  796. // return isLt1M;
  797. },
  798. compressImage(file) {
  799. return new Promise((resolve, reject) => {
  800. const reader = new FileReader();
  801. reader.readAsDataURL(file);
  802. reader.onload = (event) => {
  803. const img = new Image();
  804. img.src = event.target.result;
  805. img.onload = () => {
  806. const canvas = document.createElement('canvas');
  807. const ctx = canvas.getContext('2d');
  808. const width = img.width;
  809. const height = img.height;
  810. canvas.width = width;
  811. canvas.height = height;
  812. ctx.drawImage(img, 0, 0, width, height);
  813. let quality = 1; // 初始压缩质量
  814. let dataURL = canvas.toDataURL('image/jpeg', quality);
  815. // 逐步压缩,直到图片大小小于500KB并且压缩质量不再降低
  816. while (dataURL.length / 1024 > 500 && quality > 0.1) {
  817. quality -= 0.01;
  818. dataURL = canvas.toDataURL('image/jpeg', quality);
  819. }
  820. this.finalQuality = quality; // 存储最终的压缩质量
  821. if (dataURL.length / 1024 > 500) {
  822. reject(new Error('压缩后图片仍然大于500KB'));
  823. return;
  824. }
  825. const arr = dataURL.split(',');
  826. const mime = arr[0].match(/:(.*?);/)[1];
  827. const bstr = atob(arr[1]);
  828. let n = bstr.length;
  829. const u8arr = new Uint8Array(n);
  830. while (n--) {
  831. u8arr[n] = bstr.charCodeAt(n);
  832. }
  833. const compressedFile = new Blob([u8arr], { type: mime });
  834. compressedFile.name = file.name;
  835. resolve(compressedFile);
  836. };
  837. img.onerror = (error) => {
  838. reject(error);
  839. };
  840. };
  841. reader.onerror = (error) => {
  842. reject(error);
  843. };
  844. });
  845. },
  846. /** 新增按钮操作 */
  847. handleAdd() {
  848. this.reset();
  849. this.open = true;
  850. this.title = "添加课堂视频";
  851. this.process = 0;
  852. this.videoUrl=null;
  853. this.packageItem = null;
  854. setTimeout(() => {
  855. this.$refs.videoUpload.resetUpload();
  856. }, 500);
  857. },
  858. /** 修改按钮操作 */
  859. handleUpdate(row) {
  860. this.reset();
  861. const videoId = row.videoId || this.ids
  862. this.videoUrl=null;
  863. getUserVideo(videoId).then(response => {
  864. this.form = response.data;
  865. if(response.data.url!=null&&response.data.url!==''){
  866. this.videoUrl = response.data.url;
  867. }
  868. if(response.data.tags!=null){
  869. this.tags = response.data.tags.split(",");
  870. }
  871. this.form.status = response.data.status.toString();
  872. setTimeout(() => {
  873. this.$refs.videoUpload.resetUpload();
  874. }, 500);
  875. this.talentParam.talentId = response.data.talentId;
  876. listBySearch(this.talentParam).then(response => {
  877. this.talentList = response.data;
  878. });
  879. if(response.data.productId!=null){
  880. this.packageParam.packageId = response.data.productId;
  881. packageBySearch(this.packageParam).then(response => {
  882. this.packageList = response.data;
  883. });
  884. }
  885. this.open = true;
  886. this.title = "修改课堂视频";
  887. });
  888. // setTimeout(() => {
  889. // this.form.duration=parseInt(this.$refs.myvideo.duration);
  890. // console.log(this.$refs.myvideo.duration);
  891. // }, 2000);
  892. },
  893. /** 提交按钮 */
  894. submitForm() {
  895. this.$refs["form"].validate(valid => {
  896. if (valid) {
  897. if(this.tags.length>0){
  898. this.form.tags=this.tags.toString();
  899. }
  900. else{
  901. this.form.tags=null
  902. }
  903. this.form.url = this.videoUrl;
  904. if(this.form.url==null || this.form.url===''){
  905. this.$message({
  906. message: '请上传视频!',
  907. type: 'info'
  908. });
  909. return
  910. }
  911. if(this.form.duration==null){
  912. this.$message({
  913. message: '未识别到视频时长请稍等。。。',
  914. type: 'info'
  915. });
  916. return
  917. }
  918. if(this.packageItem!=null&&this.packageItem!==''){
  919. this.form.productJson = JSON.stringify(this.packageItem)
  920. }
  921. console.log("组装数据=====>",this.form);
  922. if (this.form.videoId != null) {
  923. updateUserVideo(this.form).then(response => {
  924. this.msgSuccess("修改成功");
  925. this.open = false;
  926. this.getList();
  927. });
  928. } else {
  929. addUserVideo(this.form).then(response => {
  930. this.msgSuccess("新增成功");
  931. this.open = false;
  932. this.getList();
  933. });
  934. }
  935. }
  936. });
  937. },
  938. /** 删除按钮操作 */
  939. handleDelete(row) {
  940. const videoIds = row.videoId || this.ids;
  941. this.$confirm('是否确认删除课堂视频编号为"' + videoIds + '"的数据项?', "警告", {
  942. confirmButtonText: "确定",
  943. cancelButtonText: "取消",
  944. type: "warning"
  945. }).then(function() {
  946. return delUserVideo(videoIds);
  947. }).then(() => {
  948. this.getList();
  949. this.msgSuccess("删除成功");
  950. }).catch(() => {});
  951. },
  952. /** 导出按钮操作 */
  953. handleExport() {
  954. const queryParams = this.queryParams;
  955. this.$confirm('是否确认导出所有课堂视频数据项?', "警告", {
  956. confirmButtonText: "确定",
  957. cancelButtonText: "取消",
  958. type: "warning"
  959. }).then(() => {
  960. this.exportLoading = true;
  961. return exportUserVideo(queryParams);
  962. }).then(response => {
  963. this.download(response.msg);
  964. this.exportLoading = false;
  965. }).catch(() => {});
  966. },
  967. putOn() {
  968. const videoIds =this.ids;
  969. if(videoIds==null||videoIds===""){
  970. return this.$message("未选择短视频");
  971. }
  972. this.$confirm('是否确认批量上架短视频?', "警告", {
  973. confirmButtonText: "确定",
  974. cancelButtonText: "取消",
  975. type: "warning"
  976. }).then(function() {
  977. return putOn(videoIds);
  978. }).then(() => {
  979. this.getList();
  980. this.msgSuccess("上架成功");
  981. }).catch(function() {});
  982. },
  983. pullOff() {
  984. const videoIds =this.ids;
  985. if(videoIds==null||videoIds===""){
  986. return this.$message("未选择短视频");
  987. }
  988. this.$confirm('是否确认批量下架短视频?', "警告", {
  989. confirmButtonText: "确定",
  990. cancelButtonText: "取消",
  991. type: "warning"
  992. }).then(function() {
  993. return pullOff(videoIds);
  994. }).then(() => {
  995. this.getList();
  996. this.msgSuccess("下架成功");
  997. }).catch(function() {});
  998. }
  999. }
  1000. };
  1001. </script>
  1002. <style scoped>
  1003. .tag-box{
  1004. margin: 10px;
  1005. padding: 5px;
  1006. background-color: #f7f7f7 ;
  1007. border-radius: 4px;
  1008. border: 1px solid #d0d0d0 ;
  1009. }
  1010. .tag-selectd{
  1011. background-color: rgb(231, 244, 255) ;
  1012. border: 1px solid rgb(11, 162, 255) ;
  1013. }
  1014. .el-tag + .el-tag {
  1015. margin-left: 10px;
  1016. }
  1017. .avatar-uploader .el-upload {
  1018. border: 1px dashed #d9d9d9;
  1019. border-radius: 6px;
  1020. cursor: pointer;
  1021. position: relative;
  1022. overflow: hidden;
  1023. }
  1024. .avatar-uploader .el-upload:hover {
  1025. border-color: #409EFF;
  1026. }
  1027. .avatar-uploader-icon {
  1028. font-size: 28px;
  1029. color: #8c939d;
  1030. width: 150px;
  1031. height: 150px;
  1032. line-height: 150px;
  1033. text-align: center;
  1034. }
  1035. </style>