index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="视频名称" prop="videoName">
  5. <el-input
  6. v-model="queryParams.videoName"
  7. placeholder="请输入视频名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="分类" prop="category">
  13. <el-input
  14. v-model="queryParams.category"
  15. placeholder="请输入分类"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="备注" prop="remark">
  21. <el-input
  22. v-model="queryParams.remark"
  23. placeholder="请输入备注"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item label="可见公司" prop="companyId">
  29. <el-select
  30. v-model="queryParams.companyId"
  31. placeholder="请选择可见公司"
  32. clearable
  33. filterable
  34. style="width: 200px"
  35. >
  36. <el-option
  37. v-for="company in allCompanyOptions"
  38. :key="company.companyId"
  39. :label="company.companyName"
  40. :value="company.companyId"
  41. />
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item>
  45. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  46. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  47. </el-form-item>
  48. </el-form>
  49. <el-row :gutter="10" class="mb8">
  50. <el-col :span="1.5">
  51. <el-button
  52. type="primary"
  53. plain
  54. icon="el-icon-plus"
  55. size="mini"
  56. @click="handleAdd"
  57. v-hasPermi="['live:liveVideo:add']"
  58. >新增</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="danger"
  63. plain
  64. icon="el-icon-delete"
  65. size="mini"
  66. :disabled="multiple"
  67. @click="handleDelete"
  68. v-hasPermi="['live:liveVideo:remove']"
  69. >删除</el-button>
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-button
  73. type="warning"
  74. plain
  75. icon="el-icon-edit"
  76. size="mini"
  77. :disabled="multiple"
  78. @click="handleBatchUpdateCategory"
  79. >批量修改分类</el-button>
  80. </el-col>
  81. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  82. </el-row>
  83. <el-table border v-loading="loading" :data="liveVideoList" @selection-change="handleSelectionChange">
  84. <el-table-column type="selection" width="55" align="center" />
  85. <el-table-column label="编号" align="center" prop="videoId" />
  86. <el-table-column label="视频名称" align="center" prop="videoName" />
  87. <el-table-column label="分类" align="center" prop="category" />
  88. <el-table-column label="排序" align="center" prop="sort" />
  89. <el-table-column label="备注" align="center" prop="remark" />
  90. <el-table-column label="视频地址" align="center" prop="videoUrl">
  91. <template slot-scope="scope">
  92. <video
  93. :src="scope.row.videoUrl"
  94. controls
  95. controlsList="nodownload"
  96. class="video-player"
  97. @contextmenu.prevent
  98. ></video>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="时长" align="center" prop="duration" :formatter="formatDuration"/>
  102. <el-table-column label="转码状态" align="center" prop="finishStatus">
  103. <template slot-scope="scope">
  104. <el-tag v-if="scope.row.finishStatus == 1">转码成功</el-tag>
  105. <el-tag v-else-if="scope.row.finishStatus == 0">转码中</el-tag>
  106. <el-tag v-else>---</el-tag>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
  110. <template slot-scope="scope">
  111. <el-button
  112. size="mini"
  113. type="text"
  114. icon="el-icon-edit"
  115. @click="handleUpdateVideoInfo(scope.row)"
  116. >修改</el-button>
  117. <el-button
  118. size="mini"
  119. type="text"
  120. icon="el-icon-edit"
  121. @click="handleUpdateCompanyIds(scope.row)"
  122. >修改公司范围</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <pagination
  127. v-show="total>0"
  128. :total="total"
  129. :page.sync="queryParams.pageNum"
  130. :limit.sync="queryParams.pageSize"
  131. @pagination="getList"
  132. />
  133. <!-- 添加或修改直播视频对话框 -->
  134. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  135. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  136. <live-video-upload
  137. :type = "1"
  138. :isPrivate = "isPrivate"
  139. :fileKey.sync = "form.fileKey"
  140. :fileSize.sync = "form.fileSize"
  141. :videoUrl.sync="form.videoUrl"
  142. :fileName.sync="form.fileName"
  143. :line_1.sync="form.lineOne"
  144. :thumbnail.sync="form.thumbnail"
  145. :uploadType.sync="form.uploadType"
  146. :isTranscode.sync="form.isTranscode"
  147. :transcodeFileKey.sync="form.transcodeFileKey"
  148. @video-duration="handleVideoDuration"
  149. @change="handleVideoChange"
  150. ref="videoUpload"
  151. append-to-body
  152. />
  153. <el-form-item label="视频名称" prop="videoName">
  154. <el-input v-model="form.videoName" placeholder="请输入视频名称" />
  155. </el-form-item>
  156. <el-form-item label="分类" prop="category">
  157. <el-input v-model="form.category" placeholder="请输入分类" />
  158. </el-form-item>
  159. <el-form-item label="排序" prop="sort">
  160. <el-input-number v-model="form.sort" :min="0" placeholder="请输入排序号" />
  161. </el-form-item>
  162. <el-form-item label="备注" prop="remark">
  163. <el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
  164. </el-form-item>
  165. <el-form-item label="公司列表" prop="companyIds">
  166. <div style="margin-bottom: 10px;">
  167. <el-button size="mini" type="text" @click="selectAllCompanies">全选</el-button>
  168. <el-button size="mini" type="text" @click="unselectAllCompanies">全不选</el-button>
  169. <el-button size="mini" type="text" @click="reverseSelectCompanies">反选</el-button>
  170. <span style="margin-left: 20px; color: #909399; font-size: 12px;">
  171. 已选择 {{ form.companyIds ? form.companyIds.length : 0 }} 个公司
  172. </span>
  173. </div>
  174. <el-select
  175. v-model="form.companyIds"
  176. multiple
  177. filterable
  178. placeholder="请选择公司"
  179. style="width: 100%"
  180. collapse-tags
  181. :loading="companyOptionsLoading"
  182. >
  183. <el-option
  184. v-for="company in allCompanyOptions"
  185. :key="company.companyId"
  186. :label="company.companyName"
  187. :value="company.companyId"
  188. />
  189. </el-select>
  190. </el-form-item>
  191. </el-form>
  192. <div slot="footer" class="dialog-footer">
  193. <el-button type="primary" @click="submitForm">确 定</el-button>
  194. <el-button @click="cancel">取 消</el-button>
  195. </div>
  196. </el-dialog>
  197. <!-- 修改视频信息对话框 -->
  198. <el-dialog title="修改视频信息" :visible.sync="editVideoInfoDialog" width="800px" append-to-body>
  199. <el-form ref="editVideoInfoForm" :model="editVideoInfoForm" label-width="120px">
  200. <el-form-item label="视频名称" prop="videoName">
  201. <el-input v-model="editVideoInfoForm.videoName" placeholder="请输入视频名称" />
  202. </el-form-item>
  203. <el-form-item label="分类" prop="category">
  204. <el-input v-model="editVideoInfoForm.category" placeholder="请输入分类" />
  205. </el-form-item>
  206. <el-form-item label="排序" prop="sort">
  207. <el-input-number v-model="editVideoInfoForm.sort" :min="0" placeholder="请输入排序号" />
  208. </el-form-item>
  209. <el-form-item label="备注" prop="remark">
  210. <el-input v-model="editVideoInfoForm.remark" type="textarea" placeholder="请输入备注" />
  211. </el-form-item>
  212. </el-form>
  213. <div slot="footer" class="dialog-footer">
  214. <el-button type="primary" @click="submitEditVideoInfo">确 定</el-button>
  215. <el-button @click="cancelEditVideoInfo">取 消</el-button>
  216. </div>
  217. </el-dialog>
  218. <!-- 修改公司范围对话框 -->
  219. <el-dialog title="修改公司范围" :visible.sync="editCompanyIdsDialog" width="800px" append-to-body>
  220. <el-form ref="editCompanyIdsForm" :model="editCompanyIdsForm" label-width="120px">
  221. <el-form-item label="视频名称">
  222. <el-input v-model="editCompanyIdsForm.videoName" :disabled="true" />
  223. </el-form-item>
  224. <el-form-item label="公司列表" prop="companyIds">
  225. <div style="margin-bottom: 10px;">
  226. <el-button size="mini" type="text" @click="selectAllCompaniesForEdit">全选</el-button>
  227. <el-button size="mini" type="text" @click="unselectAllCompaniesForEdit">全不选</el-button>
  228. <el-button size="mini" type="text" @click="reverseSelectCompaniesForEdit">反选</el-button>
  229. <span style="margin-left: 20px; color: #909399; font-size: 12px;">
  230. 已选择 {{ editCompanyIdsForm.companyIds ? editCompanyIdsForm.companyIds.length : 0 }} 个公司
  231. </span>
  232. </div>
  233. <el-select
  234. v-model="editCompanyIdsForm.companyIds"
  235. multiple
  236. filterable
  237. placeholder="请选择公司"
  238. style="width: 100%"
  239. collapse-tags
  240. :loading="companyOptionsLoading"
  241. >
  242. <el-option
  243. v-for="company in allCompanyOptions"
  244. :key="company.companyId"
  245. :label="company.companyName"
  246. :value="company.companyId"
  247. />
  248. </el-select>
  249. </el-form-item>
  250. </el-form>
  251. <div slot="footer" class="dialog-footer">
  252. <el-button type="primary" @click="submitEditCompanyIds">确 定</el-button>
  253. <el-button @click="cancelEditCompanyIds">取 消</el-button>
  254. </div>
  255. </el-dialog>
  256. <!-- 批量修改分类对话框 -->
  257. <el-dialog title="批量修改分类" :visible.sync="batchUpdateCategoryDialog" width="500px" append-to-body>
  258. <el-form ref="batchUpdateCategoryForm" :model="batchUpdateCategoryForm" label-width="100px">
  259. <el-form-item label="分类" prop="category">
  260. <el-input v-model="batchUpdateCategoryForm.category" placeholder="请输入分类" />
  261. </el-form-item>
  262. </el-form>
  263. <div slot="footer" class="dialog-footer">
  264. <el-button type="primary" @click="submitBatchUpdateCategory">确 定</el-button>
  265. <el-button @click="cancelBatchUpdateCategory">取 消</el-button>
  266. </div>
  267. </el-dialog>
  268. </div>
  269. </template>
  270. <script>
  271. import { listLiveVideo, getLiveVideo, delLiveVideo, addLiveVideo, updateLiveVideo, exportLiveVideo, batchUpdateCategory } from "@/api/live/liveVideo";
  272. import { getCompanyList } from "@/api/company/company";
  273. import LiveVideoUpload from "@/components/LiveVideoUpload/index.vue";
  274. export default {
  275. name: "LiveVideo",
  276. components: { LiveVideoUpload },
  277. data() {
  278. return {
  279. //字典
  280. videoTypeOptions: [],
  281. // 遮罩层
  282. loading: true,
  283. // 导出遮罩层
  284. exportLoading: false,
  285. // 选中数组
  286. ids: [],
  287. // 非单个禁用
  288. single: true,
  289. // 非多个禁用
  290. multiple: true,
  291. // 显示搜索条件
  292. showSearch: true,
  293. // 总条数
  294. total: 0,
  295. // 直播视频表格数据
  296. liveVideoList: [],
  297. // 弹出层标题
  298. title: "",
  299. // 是否显示弹出层
  300. open: false,
  301. // 查询参数
  302. queryParams: {
  303. pageNum: 1,
  304. pageSize: 10,
  305. liveId: -1,
  306. videoUrl: null,
  307. videoType: -1,
  308. sort: null,
  309. videoName: null,
  310. remark: null,
  311. category: null,
  312. companyId: null,
  313. },
  314. // 表单参数
  315. form: {
  316. uploadType: 1,
  317. isTranscode:0,
  318. transcodeFileKey:null,
  319. companyIds: []
  320. },
  321. // 表单校验
  322. rules: {
  323. },
  324. isPrivate:null,
  325. // 是否显示修改视频信息对话框
  326. editVideoInfoDialog: false,
  327. // 修改视频信息表单
  328. editVideoInfoForm: {
  329. videoId: null,
  330. videoName: '',
  331. category: '',
  332. sort: null,
  333. remark: ''
  334. },
  335. // 是否显示修改公司范围对话框
  336. editCompanyIdsDialog: false,
  337. // 修改公司范围表单
  338. editCompanyIdsForm: {
  339. videoId: null,
  340. videoName: '',
  341. companyIds: []
  342. },
  343. // 是否显示批量修改分类对话框
  344. batchUpdateCategoryDialog: false,
  345. // 批量修改分类表单
  346. batchUpdateCategoryForm: {
  347. category: ''
  348. },
  349. // 所有公司选项(用于下拉选择)
  350. allCompanyOptions: [],
  351. // 公司选项加载状态
  352. companyOptionsLoading: false
  353. };
  354. },
  355. created() {
  356. this.getList();
  357. this.getAllCompanyOptions();
  358. },
  359. mounted() {
  360. this.getAllCompanyOptions();
  361. },
  362. methods: {
  363. handleVideoDuration(duration) {
  364. this.form.duration = duration;
  365. },
  366. handleVideoChange(videoUrl,lineOne){
  367. this.videoUrl = videoUrl;
  368. this.form.videoUrl = videoUrl;
  369. console.log(this.videoUrl)
  370. },
  371. // 操作日志类型字典翻译
  372. formatDuration(row, column) {
  373. if(row.duration == null) return "00:00"
  374. const h = Math.floor(row.duration / 3600);
  375. const m = Math.floor((row.duration % 3600) / 60);
  376. const s = Math.floor(row.duration % 60);
  377. // 补零处理
  378. const format = (num) => num.toString().padStart(2, '0');
  379. return h > 0
  380. ? `${h}:${format(m)}:${format(s)}`
  381. : `${format(m)}:${format(s)}`;
  382. },
  383. /** 查询直播视频列表 */
  384. getList() {
  385. this.loading = true;
  386. listLiveVideo(this.queryParams).then(response => {
  387. this.liveVideoList = response.rows;
  388. this.liveVideoList.forEach(item => {
  389. item.videoUrl = item.videoUrl.replace(".m3u8", ".mp4");
  390. });
  391. this.total = response.total;
  392. this.loading = false;
  393. });
  394. },
  395. videoTypeFormatter(row, column) {
  396. return this.selectDictLabel(this.videoTypeOptions, row.status);
  397. },
  398. // 取消按钮
  399. cancel() {
  400. this.open = false;
  401. this.reset();
  402. },
  403. // 表单重置
  404. reset() {
  405. this.form = {
  406. videoId: null,
  407. liveId: null,
  408. videoUrl: null,
  409. videoType: null,
  410. videoName: null,
  411. category: null,
  412. sort: null,
  413. createTime: null,
  414. createBy: null,
  415. updateBy: null,
  416. updateTime: null,
  417. remark: null,
  418. uploadType: 1,
  419. isTranscode: 0,
  420. transcodeFileKey: null,
  421. companyIds: []
  422. };
  423. this.resetForm("form");
  424. },
  425. /** 搜索按钮操作 */
  426. handleQuery() {
  427. this.queryParams.pageNum = 1;
  428. this.getList();
  429. },
  430. /** 重置按钮操作 */
  431. resetQuery() {
  432. this.queryParams = {
  433. pageNum: 1,
  434. pageSize: 10,
  435. liveId: -1,
  436. videoUrl: null,
  437. videoType: -1,
  438. sort: null,
  439. videoName: null,
  440. remark: null,
  441. category: null,
  442. companyId: null,
  443. };
  444. this.handleQuery();
  445. },
  446. // 多选框选中数据
  447. handleSelectionChange(selection) {
  448. this.ids = selection.map(item => item.videoId)
  449. this.single = selection.length!==1
  450. this.multiple = !selection.length
  451. },
  452. /** 新增按钮操作 */
  453. handleAdd() {
  454. this.reset();
  455. this.open = true;
  456. this.title = "添加直播视频";
  457. this.videoUrl = '';
  458. setTimeout(() => {
  459. this.$refs.videoUpload.reset();
  460. }, 500);
  461. },
  462. /** 修改按钮操作 */
  463. handleUpdate(row) {
  464. this.reset();
  465. const videoId = row.videoId || this.ids
  466. getLiveVideo(videoId).then(response => {
  467. this.form = response.data;
  468. // 处理companyIds,可能是字符串或数组
  469. if (response.data.companyIds) {
  470. if (typeof response.data.companyIds === 'string') {
  471. this.form.companyIds = response.data.companyIds
  472. ? response.data.companyIds.split(',').map(Number)
  473. : [];
  474. } else if (Array.isArray(response.data.companyIds)) {
  475. this.form.companyIds = response.data.companyIds.map(Number);
  476. }
  477. } else {
  478. this.form.companyIds = [];
  479. }
  480. this.open = true;
  481. this.title = "修改直播视频";
  482. });
  483. },
  484. /** 获取所有公司选项 */
  485. getAllCompanyOptions() {
  486. this.companyOptionsLoading = true;
  487. getCompanyList().then(response => {
  488. if (response.code === 200 && response.data) {
  489. this.allCompanyOptions = response.data || [];
  490. } else {
  491. this.allCompanyOptions = [];
  492. }
  493. this.companyOptionsLoading = false;
  494. }).catch(() => {
  495. this.allCompanyOptions = [];
  496. this.companyOptionsLoading = false;
  497. });
  498. },
  499. /** 全选公司 */
  500. selectAllCompanies() {
  501. this.form.companyIds = this.allCompanyOptions.map(item => item.companyId);
  502. },
  503. /** 全不选公司 */
  504. unselectAllCompanies() {
  505. this.form.companyIds = [];
  506. },
  507. /** 反选公司 */
  508. reverseSelectCompanies() {
  509. const allIds = this.allCompanyOptions.map(item => item.companyId);
  510. const selectedIds = this.form.companyIds || [];
  511. this.form.companyIds = allIds.filter(id => !selectedIds.includes(id));
  512. },
  513. /** 全选公司(修改公司范围) */
  514. selectAllCompaniesForEdit() {
  515. this.editCompanyIdsForm.companyIds = this.allCompanyOptions.map(item => item.companyId);
  516. },
  517. /** 全不选公司(修改公司范围) */
  518. unselectAllCompaniesForEdit() {
  519. this.editCompanyIdsForm.companyIds = [];
  520. },
  521. /** 反选公司(修改公司范围) */
  522. reverseSelectCompaniesForEdit() {
  523. const allIds = this.allCompanyOptions.map(item => item.companyId);
  524. const selectedIds = this.editCompanyIdsForm.companyIds || [];
  525. this.editCompanyIdsForm.companyIds = allIds.filter(id => !selectedIds.includes(id));
  526. },
  527. /** 打开修改视频信息对话框 */
  528. handleUpdateVideoInfo(row) {
  529. const videoId = row.videoId;
  530. getLiveVideo(videoId).then(response => {
  531. if (response.code === 200) {
  532. this.editVideoInfoForm = {
  533. videoId: response.data.videoId,
  534. videoName: response.data.videoName || '',
  535. category: response.data.category || '',
  536. sort: response.data.sort || null,
  537. remark: response.data.remark || ''
  538. };
  539. this.editVideoInfoDialog = true;
  540. }
  541. }).catch(() => {
  542. this.msgError("获取数据失败");
  543. });
  544. },
  545. /** 取消修改视频信息 */
  546. cancelEditVideoInfo() {
  547. this.editVideoInfoDialog = false;
  548. this.editVideoInfoForm = {
  549. videoId: null,
  550. videoName: '',
  551. category: '',
  552. sort: null,
  553. remark: ''
  554. };
  555. },
  556. /** 提交修改视频信息 */
  557. submitEditVideoInfo() {
  558. const data = {
  559. videoId: this.editVideoInfoForm.videoId,
  560. videoName: this.editVideoInfoForm.videoName,
  561. category: this.editVideoInfoForm.category,
  562. sort: this.editVideoInfoForm.sort,
  563. remark: this.editVideoInfoForm.remark
  564. };
  565. updateLiveVideo(data).then(response => {
  566. if (response.code === 200) {
  567. this.msgSuccess("修改成功");
  568. this.editVideoInfoDialog = false;
  569. this.getList();
  570. } else {
  571. this.msgError(response.msg || "修改失败");
  572. }
  573. }).catch(() => {
  574. this.msgError("修改失败");
  575. });
  576. },
  577. /** 打开修改公司范围对话框 */
  578. handleUpdateCompanyIds(row) {
  579. const videoId = row.videoId;
  580. getLiveVideo(videoId).then(response => {
  581. if (response.code === 200) {
  582. this.editCompanyIdsForm = {
  583. videoId: response.data.videoId,
  584. videoName: response.data.videoName || '',
  585. companyIds: []
  586. };
  587. // 处理companyIds,可能是字符串或数组
  588. if (response.data.companyIds) {
  589. if (typeof response.data.companyIds === 'string') {
  590. this.editCompanyIdsForm.companyIds = response.data.companyIds
  591. ? response.data.companyIds.split(',').map(Number)
  592. : [];
  593. } else if (Array.isArray(response.data.companyIds)) {
  594. this.editCompanyIdsForm.companyIds = response.data.companyIds.map(Number);
  595. }
  596. }
  597. this.editCompanyIdsDialog = true;
  598. }
  599. }).catch(() => {
  600. this.msgError("获取数据失败");
  601. });
  602. },
  603. /** 取消修改公司范围 */
  604. cancelEditCompanyIds() {
  605. this.editCompanyIdsDialog = false;
  606. this.editCompanyIdsForm = {
  607. videoId: null,
  608. videoName: '',
  609. companyIds: []
  610. };
  611. },
  612. /** 提交修改公司范围 */
  613. submitEditCompanyIds() {
  614. const data = {
  615. videoId: this.editCompanyIdsForm.videoId,
  616. companyIds: Array.isArray(this.editCompanyIdsForm.companyIds)
  617. ? this.editCompanyIdsForm.companyIds
  618. : []
  619. };
  620. updateLiveVideo(data).then(response => {
  621. if (response.code === 200) {
  622. this.msgSuccess("修改成功");
  623. this.editCompanyIdsDialog = false;
  624. this.getList();
  625. } else {
  626. this.msgError(response.msg || "修改失败");
  627. }
  628. }).catch(() => {
  629. this.msgError("修改失败");
  630. });
  631. },
  632. /** 提交按钮 */
  633. submitForm() {
  634. this.$refs["form"].validate(valid => {
  635. if (valid) {
  636. this.form.videoType = -1;
  637. this.form.liveId = -1;
  638. if (!this.form.videoName) {
  639. this.form.videoName = this.form.fileName;
  640. }
  641. if (!this.form.remark) {
  642. this.form.remark = this.form.fileName;
  643. }
  644. if(this.form.videoUrl == null || this.form.videoUrl == "") {
  645. this.msgError("请上传视频");
  646. return;
  647. }
  648. this.form.videoUrl = this.form.videoUrl.replace('.mp4', '.m3u8');
  649. // 确保companyIds是数组
  650. const submitData = {
  651. ...this.form,
  652. companyIds: Array.isArray(this.form.companyIds) ? this.form.companyIds : []
  653. };
  654. if (this.form.videoId != null) {
  655. // 修改
  656. updateLiveVideo(submitData).then(response => {
  657. this.msgSuccess("修改成功");
  658. this.open = false;
  659. this.getList();
  660. this.reset();
  661. });
  662. } else {
  663. // 新增
  664. addLiveVideo(submitData).then(response => {
  665. this.msgSuccess("新增成功");
  666. this.open = false;
  667. this.getList();
  668. this.reset();
  669. });
  670. }
  671. }
  672. });
  673. },
  674. /** 删除按钮操作 */
  675. handleDelete(row) {
  676. const videoIds = row.videoId || this.ids;
  677. this.$confirm('是否确认删除直播视频编号为"' + videoIds + '"的数据项?', "警告", {
  678. confirmButtonText: "确定",
  679. cancelButtonText: "取消",
  680. type: "warning"
  681. }).then(function() {
  682. return delLiveVideo(videoIds);
  683. }).then(() => {
  684. this.getList();
  685. this.msgSuccess("删除成功");
  686. }).catch(() => {});
  687. },
  688. /** 导出按钮操作 */
  689. handleExport() {
  690. const queryParams = this.queryParams;
  691. this.$confirm('是否确认导出所有直播视频数据项?', "警告", {
  692. confirmButtonText: "确定",
  693. cancelButtonText: "取消",
  694. type: "warning"
  695. }).then(() => {
  696. this.exportLoading = true;
  697. return exportLiveVideo(queryParams);
  698. }).then(response => {
  699. this.download(response.msg);
  700. this.exportLoading = false;
  701. }).catch(() => {});
  702. },
  703. /** 批量修改分类 */
  704. handleBatchUpdateCategory() {
  705. if (this.ids.length === 0) {
  706. this.msgWarning("请选择要修改的视频");
  707. return;
  708. }
  709. this.batchUpdateCategoryForm.category = '';
  710. this.batchUpdateCategoryDialog = true;
  711. },
  712. /** 取消批量修改分类 */
  713. cancelBatchUpdateCategory() {
  714. this.batchUpdateCategoryDialog = false;
  715. this.batchUpdateCategoryForm.category = '';
  716. },
  717. /** 提交批量修改分类 */
  718. submitBatchUpdateCategory() {
  719. const data = {
  720. videoIds: this.ids,
  721. category: this.batchUpdateCategoryForm.category
  722. };
  723. batchUpdateCategory(data).then(response => {
  724. if (response.code === 200) {
  725. this.msgSuccess("批量修改成功");
  726. this.batchUpdateCategoryDialog = false;
  727. this.getList();
  728. } else {
  729. this.msgError(response.msg || "批量修改失败");
  730. }
  731. }).catch(() => {
  732. this.msgError("批量修改失败");
  733. });
  734. }
  735. }
  736. };
  737. </script>
  738. <style scoped>
  739. .video-player {
  740. width: 100%;
  741. height: 100%;
  742. object-fit: cover;
  743. }
  744. </style>