index.vue 31 KB

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