detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <!-- 音频管理 播客专辑详情 -->
  2. <template>
  3. <div class="app-container">
  4. <el-form
  5. class="form"
  6. :model="form"
  7. ref="form"
  8. :rules="rules"
  9. label-width="100px"
  10. :disabled="disabled"
  11. >
  12. <el-form-item label="播客名称:" prop="name">
  13. <el-input v-model="form.name" placeholder="请输入播客名称" />
  14. </el-form-item>
  15. <el-form-item label="主播名称:" prop="podcasterIds">
  16. <el-select
  17. v-model="form.podcasterIds"
  18. multiple
  19. filterable
  20. remote
  21. reserve-keyword
  22. placeholder="请输入主播名称"
  23. :remote-method="getSelect"
  24. no-data-text="请新增主播"
  25. >
  26. <el-option
  27. v-for="item in anchorOptions"
  28. :key="item.value"
  29. :value="item.value"
  30. :label="item.label"
  31. />
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="播客分类:" prop="categoryIds">
  35. <el-select
  36. v-model="form.categoryIds"
  37. multiple
  38. placeholder="请选择播客分类"
  39. >
  40. <el-option
  41. v-for="item in blogClassOptions"
  42. :key="item.value"
  43. :value="item.value"
  44. :label="item.label"
  45. />
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item label="播客介绍:" prop="description">
  49. <el-input
  50. v-model="form.description"
  51. type="textarea"
  52. :autosize="{ minRows: 5, maxRows: 10 }"
  53. maxlength="300"
  54. show-word-limit
  55. placeholder=" 请输入播客介绍"
  56. />
  57. </el-form-item>
  58. <el-form-item label="资源平台:" prop="platformId">
  59. <el-select
  60. v-model="form.platformId"
  61. placeholder="请选择资源平台"
  62. :disabled="disabledPlatformId(form.platformId)"
  63. >
  64. <el-option
  65. v-for="item in platformOptions"
  66. :key="item.value"
  67. :value="item.value"
  68. :label="item.label"
  69. :disabled="disabledJoinType(item.joinType)"
  70. />
  71. </el-select>
  72. </el-form-item>
  73. <el-form-item label="付费类型:" prop="charging">
  74. <el-select v-model="form.charging" placeholder="请选择付费类型">
  75. <el-option
  76. v-for="item in payTypeOptions"
  77. :key="item.value"
  78. :value="item.value"
  79. :label="item.label"
  80. />
  81. </el-select>
  82. </el-form-item>
  83. <el-form-item v-if="form.charging !== 1" label="原价:" prop="price">
  84. <el-input-number
  85. v-model="form.price"
  86. placeholder="请输入原价"
  87. :min="1"
  88. :precision="2"
  89. :controls="false"
  90. />
  91. </el-form-item>
  92. <el-form-item
  93. v-if="form.charging !== 1"
  94. label="折扣价:"
  95. prop="discountedPrice"
  96. >
  97. <el-input-number
  98. v-model="form.discountedPrice"
  99. placeholder="请输入折扣价"
  100. :min="1"
  101. :precision="2"
  102. :controls="false"
  103. />
  104. </el-form-item>
  105. <el-form-item label="播客封面" prop="thumb">
  106. <Upload
  107. listType="picture-card"
  108. :url="form.thumb"
  109. @upload="upload"
  110. :disabled="disabled"
  111. />
  112. </el-form-item>
  113. <el-form-item label="关联节目:" prop="adminPodCastProgramDetailResp">
  114. <el-button type="primary" @click="getDialog">关联节目</el-button>
  115. <el-button @click="getDelete" :disabled="ids.length > 0 ? false : true"
  116. >解除关联</el-button
  117. >
  118. </el-form-item>
  119. <el-form-item style="width: 100%">
  120. <el-table
  121. :data="form.adminPodCastProgramDetailResp"
  122. @selection-change="handleSelect"
  123. >
  124. <!-- <el-table-column type="selection" align="center" /> -->
  125. <el-table-column
  126. label="ID"
  127. prop="id"
  128. align="center"
  129. show-overflow-tooltip
  130. />
  131. <el-table-column
  132. label="节目名称"
  133. prop="name"
  134. align="center"
  135. show-overflow-tooltip
  136. />
  137. <el-table-column
  138. label="资源平台"
  139. prop="platformId"
  140. align="center"
  141. :formatter="platformFormatter"
  142. />
  143. <el-table-column
  144. label="当前状态"
  145. prop="status"
  146. align="center"
  147. :formatter="statusFormatter"
  148. />
  149. <el-table-column label="操作" align="center">
  150. <template slot-scope="scope">
  151. <!-- <Audio :src="scope.row.progaramUrl" /> -->
  152. <!-- 向上移动 -->
  153. <el-button
  154. type="text"
  155. icon="el-icon-caret-top"
  156. @click="getChange(true, scope.$index, scope.$index - 1)"
  157. :disabled="scope.$index < 1 && !disabled"
  158. />
  159. <!-- 向下移动 -->
  160. <el-button
  161. type="text"
  162. icon="el-icon-caret-bottom"
  163. @click="getChange(false, scope.$index, scope.$index + 1)"
  164. :disabled="
  165. scope.$index >
  166. form.adminPodCastProgramDetailResp.length - 2 && !disabled
  167. "
  168. />
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. </el-form-item>
  173. </el-form>
  174. <div class="form-btn">
  175. <el-button @click="cancel">取消</el-button>
  176. <el-button v-if="!disabled" type="primary" @click="getSubmit"
  177. >确定</el-button
  178. >
  179. </div>
  180. <!-- 弹窗 -->
  181. <el-dialog :visible.sync="dialogVisible" title="关联节目" width="1200px">
  182. <el-form inline size="mini" style="width: 100%">
  183. <el-form-item label="节目ID:">
  184. <el-input
  185. v-model="dialogForm.id"
  186. placeholder="请输入节目ID"
  187. clearable
  188. />
  189. </el-form-item>
  190. <el-form-item label="节目名称:">
  191. <el-input
  192. v-model="dialogForm.name"
  193. placeholder="请输入节目名称"
  194. clearable
  195. />
  196. </el-form-item>
  197. <el-form-item label="付费类型:">
  198. <el-select
  199. v-model="dialogForm.isFree"
  200. placeholder="请选择付费类型"
  201. clearable
  202. >
  203. <el-option
  204. v-for="item in freeOptions"
  205. :key="item.value"
  206. :value="item.value"
  207. :label="item.label"
  208. />
  209. </el-select>
  210. </el-form-item>
  211. <el-form-item label="资源平台:">
  212. <el-select
  213. v-model="dialogForm.platformId"
  214. placeholder="请选择资源平台"
  215. >
  216. <el-option
  217. v-for="item in platformOptions.filter(
  218. (i) => !i.joinType.includes('1')
  219. )"
  220. :key="item.value"
  221. :value="item.value"
  222. :label="item.label"
  223. />
  224. </el-select>
  225. </el-form-item>
  226. <el-form-item>
  227. <el-button type="primary" icon="el-icon-search" @click="getSearch"
  228. >搜索</el-button
  229. >
  230. <el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
  231. </el-form-item>
  232. </el-form>
  233. <el-table
  234. :data="dialogTableData"
  235. ref="multipleTable"
  236. :row-key="tableKey"
  237. v-loading="loading"
  238. @selection-change="handleSelectionChange"
  239. >
  240. <el-table-column
  241. type="selection"
  242. align="center"
  243. key="selection"
  244. reserve-selection
  245. />
  246. <el-table-column label="ID" prop="id" align="center" />
  247. <el-table-column
  248. label="节目名称"
  249. prop="name"
  250. align="center"
  251. show-overflow-tooltip
  252. />
  253. <el-table-column
  254. label="资源平台"
  255. prop="platformId"
  256. align="center"
  257. :formatter="platformFormatter"
  258. />
  259. <el-table-column
  260. label="付费类型"
  261. prop="isFree"
  262. align="center"
  263. :formatter="freeFormatter"
  264. />
  265. <el-table-column
  266. label="当前状态"
  267. prop="status"
  268. align="center"
  269. :formatter="statusFormatter"
  270. />
  271. <!-- <el-table-column label="操作" align="center">
  272. <template slot-scope="scope">
  273. <el-button
  274. type="text"
  275. @click="getChecked(scope.row)"
  276. :disabled="
  277. form.adminPodCastProgramDetailResp.findIndex(
  278. (i) => i.id === scope.row.id
  279. ) === -1
  280. ? false
  281. : true
  282. "
  283. >
  284. 选择
  285. </el-button>
  286. </template>
  287. </el-table-column> -->
  288. </el-table>
  289. <pagination
  290. v-show="total > 0"
  291. :total="total"
  292. :page.sync="dialogForm.pageNum"
  293. :limit.sync="dialogForm.pageSize"
  294. @pagination="getList"
  295. />
  296. </el-dialog>
  297. </div>
  298. </template>
  299. <script>
  300. import { selectAnchor } from "@/api/music/anchor";
  301. import { checkList, detail, relieve, submit } from "@/api/music/blog";
  302. import {
  303. blogClassMixin,
  304. isFreeMixin,
  305. onOrOffMixin,
  306. payTypeMixin,
  307. platformMixin,
  308. } from "@/mixin/index";
  309. export default {
  310. mixins: [
  311. blogClassMixin,
  312. platformMixin,
  313. payTypeMixin,
  314. onOrOffMixin,
  315. isFreeMixin,
  316. ],
  317. data() {
  318. // 判断原价是否大于折扣价
  319. var checkPrice = (rule, value, callback) => {
  320. if (!value) {
  321. callback(new Error("请输入原价"));
  322. } else {
  323. if (this.form.discountedPrice && value <= this.form.discountedPrice) {
  324. callback(new Error("原价必须大于折扣价"));
  325. }
  326. callback();
  327. }
  328. };
  329. // 判断折扣价是否小于原价
  330. var checkDiscount = (rule, value, callback) => {
  331. if (this.form.price && value >= this.form.price) {
  332. callback(new Error("折扣价必须小于原价"));
  333. } else {
  334. callback();
  335. }
  336. };
  337. return {
  338. // 遮罩层
  339. loading: false,
  340. // 表单
  341. form: {
  342. adminPodCastProgramDetailResp: [],
  343. podcastProgramIds: [],
  344. categoryIds: [],
  345. status: 1,
  346. },
  347. // 主播
  348. anchorOptions: [],
  349. // 弹窗
  350. dialogVisible: false,
  351. // 弹窗表单
  352. dialogForm: {
  353. pageNum: 1,
  354. pageSize: 10,
  355. status: 1,
  356. platformId: null,
  357. },
  358. // 总数据
  359. total: 0,
  360. // 弹窗列表
  361. dialogTableData: [],
  362. // 只读
  363. disabled: false,
  364. // 校验
  365. rules: {
  366. name: [
  367. {
  368. required: true,
  369. message: "请输入播客专辑名称",
  370. trigger: "blur",
  371. },
  372. ],
  373. podcasterIds: [
  374. {
  375. required: true,
  376. message: "请输入主播名称",
  377. trigger: "blur",
  378. },
  379. ],
  380. categoryIds: [
  381. {
  382. required: true,
  383. message: "请选择播客分类",
  384. trigger: "change",
  385. },
  386. ],
  387. platformId: [
  388. {
  389. required: true,
  390. message: "请选择资源平台",
  391. trigger: "change",
  392. },
  393. ],
  394. charging: [
  395. {
  396. required: true,
  397. message: "请选择付费类型",
  398. trigger: "change",
  399. },
  400. ],
  401. price: [
  402. {
  403. required: true,
  404. validator: checkPrice,
  405. trigger: "blur",
  406. },
  407. ],
  408. discountedPrice: [
  409. {
  410. validator: checkDiscount,
  411. trigger: "blur",
  412. },
  413. ],
  414. thumb: [
  415. {
  416. required: true,
  417. message: "请上传播客封面",
  418. trigger: "change",
  419. },
  420. ],
  421. adminPodCastProgramDetailResp: [
  422. {
  423. required: true,
  424. message: "请关联节目",
  425. trigger: "change",
  426. },
  427. ],
  428. },
  429. // 解除关联
  430. ids: [],
  431. // 是否已选
  432. disabledChecked: false,
  433. };
  434. },
  435. mounted() {
  436. // 获取资源平台
  437. this.getPlatform({
  438. audioType: 8,
  439. });
  440. if (this.$route.query.id) {
  441. this.form.id = this.$route.query.id;
  442. this.disabled = Boolean(this.$route.query.disabled);
  443. this.getDetail();
  444. }
  445. },
  446. methods: {
  447. // 排序
  448. getChange(top, index, laterIndex) {
  449. var row = this.form.adminPodCastProgramDetailResp[index];
  450. var laterRow = this.form.adminPodCastProgramDetailResp[laterIndex];
  451. if (top) {
  452. this.form.adminPodCastProgramDetailResp[index] = laterRow;
  453. this.form.adminPodCastProgramDetailResp[laterIndex] = row;
  454. } else {
  455. this.form.adminPodCastProgramDetailResp[laterIndex] = row;
  456. this.form.adminPodCastProgramDetailResp[index] = laterRow;
  457. }
  458. this.form.adminPodCastProgramDetailResp =
  459. this.form.adminPodCastProgramDetailResp.filter((i) => i);
  460. },
  461. tableKey(row) {
  462. return row.id;
  463. },
  464. handleSelectionChange(val) {
  465. this.form.adminPodCastProgramDetailResp = JSON.parse(JSON.stringify(val));
  466. this.$message.success("操作成功!");
  467. },
  468. // 排序
  469. getChangeSort(row, sort) {
  470. const rowBean = this.form.adminPodCastProgramDetailResp[row];
  471. const sortBean = this.form.adminPodCastProgramDetailResp[sort];
  472. this.form.adminPodCastProgramDetailResp[row] = sortBean;
  473. this.form.adminPodCastProgramDetailResp[sort] = rowBean;
  474. this.form.adminPodCastProgramDetailResp =
  475. this.form.adminPodCastProgramDetailResp.filter((i) => i);
  476. // this.form.podcastProgramIds = [];
  477. // this.form.adminPodCastProgramDetailResp.map((i) => {
  478. // this.form.podcastProgramIds.push(i.id);
  479. // });
  480. // submit(this.form).then((res) => {
  481. // if (res.code === 0) {
  482. // let title = "修改成功!";
  483. // this.$message.success(`${title}`);
  484. // this.getDetail();
  485. // }
  486. // });
  487. },
  488. // 详情
  489. getDetail() {
  490. detail(this.form.id).then((res) => {
  491. if (res.code === 0) {
  492. this.form = res.data;
  493. this.anchorOptions = [];
  494. res.data.adminPrdCasterResp.map((i) => {
  495. this.anchorOptions.push({
  496. value: i.podcasterId,
  497. label: i.podcasterName,
  498. });
  499. });
  500. this.form.podcasterIds = res.data.podcasterIds.split(",");
  501. }
  502. });
  503. },
  504. // 查询主播
  505. getSelect(e) {
  506. if (e) {
  507. setTimeout(() => {
  508. this.anchorOptions = [];
  509. selectAnchor(e).then((res) => {
  510. if (res.code === 0) {
  511. res.data.map((i) => {
  512. this.anchorOptions.push({
  513. value: i.id,
  514. label: i.nickname,
  515. });
  516. });
  517. }
  518. }, 500);
  519. });
  520. }
  521. },
  522. // 上传
  523. upload(e) {
  524. this.form.thumb = e.file;
  525. },
  526. // 弹窗
  527. getDialog() {
  528. this.dialogVisible = true;
  529. this.dialogForm.platformId = this.platformOptions.filter(
  530. (i) => !i.joinType.includes("1")
  531. )[0].value;
  532. this.getList();
  533. },
  534. // 节目列表
  535. getList() {
  536. this.loading = true;
  537. checkList(this.dialogForm).then((res) => {
  538. if (res.code === 0) {
  539. this.dialogTableData = res.data.records;
  540. this.total = res.data.total;
  541. this.loading = false;
  542. }
  543. });
  544. },
  545. // 搜索
  546. getSearch() {
  547. this.dialogForm.pageNum = 1;
  548. this.getList();
  549. },
  550. // 重置
  551. getRefresh() {
  552. this.dialogForm = {
  553. pageNum: 1,
  554. pageSize: 10,
  555. status: 1,
  556. platformId: this.platformOptions[0].value,
  557. };
  558. this.getList();
  559. },
  560. // 选择
  561. getChecked(row) {
  562. this.form.adminPodCastProgramDetailResp.push(row);
  563. this.$message.success("选择成功!");
  564. },
  565. // 解除关联
  566. getDelete() {
  567. if (this.form.id) {
  568. relieve({
  569. id: this.form.id,
  570. podcastProgramIds: this.ids,
  571. }).then((res) => {
  572. if (res.code === 0) {
  573. this.$message.success("解除成功!");
  574. this.getDetail();
  575. }
  576. });
  577. } else {
  578. this.ids.map((i) => {
  579. this.form.adminPodCastProgramDetailResp.map((j, index) => {
  580. if (j.id === i) {
  581. this.form.adminPodCastProgramDetailResp.splice(index, 1);
  582. this.$message.success("解除成功!");
  583. }
  584. });
  585. });
  586. }
  587. },
  588. // 确定
  589. getSubmit() {
  590. this.$refs.form.validate((valid) => {
  591. if (valid) {
  592. let title = this.form.id ? "编辑成功!" : "新增成功!";
  593. this.form.podcastProgramIds = [];
  594. this.form.adminPodCastProgramDetailResp.map((i) => {
  595. this.form.podcastProgramIds.push(i.id);
  596. });
  597. submit(this.form).then((res) => {
  598. if (res.code === 0) {
  599. this.$message.success(`${title}`);
  600. if (this.form.id) {
  601. delete this.form.adminPodCastProgramDetailResp;
  602. this.getDetail();
  603. } else {
  604. this.cancel();
  605. }
  606. }
  607. });
  608. } else {
  609. return false;
  610. }
  611. });
  612. },
  613. // 多选
  614. // handleSelect(e) {
  615. // this.ids = [];
  616. // e.map((i) => {
  617. // this.ids.push(i.id);
  618. // });
  619. // },
  620. // 取消
  621. cancel() {
  622. this.$tab.closeOpenPage("/music/blog");
  623. },
  624. // 字典翻译
  625. platformFormatter(row) {
  626. return this.selectDictLabel(this.platformOptions, row.platformId);
  627. },
  628. statusFormatter(row) {
  629. return this.selectDictLabel(this.onOrOffOptions, row.status);
  630. },
  631. freeFormatter(row) {
  632. return this.selectDictLabel(this.freeOptions, row.isFree);
  633. },
  634. },
  635. };
  636. </script>
  637. <style lang="scss" scoped>
  638. .form {
  639. .el-form-item {
  640. width: 500px;
  641. }
  642. }
  643. </style>