detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <!-- 多频多台 详情 -->
  2. <template>
  3. <div class="app-container">
  4. <!-- 表单 -->
  5. <el-form class="form" label-width="100px" :disabled="isRead">
  6. <el-row>
  7. <el-col :span="12">
  8. <el-form-item label="频道名称:">
  9. <el-input v-model="form.aliasName" placeholder="请输入频道名称" />
  10. </el-form-item>
  11. <el-form-item label="频道属性:">
  12. <el-select
  13. v-model="form.channelType"
  14. placeholder="请选择频道属性"
  15. @change="handleChange"
  16. >
  17. <el-option
  18. v-for="item in channelTypeOptions"
  19. :key="item.value"
  20. :value="Number(item.value)"
  21. :label="item.label"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="频道封面:">
  26. <Upload
  27. listType="picture-card"
  28. :url="form.pic"
  29. @upload="getUpload"
  30. :disabled="isRead"
  31. />
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="12">
  35. <el-form-item label="频道简介:">
  36. <el-input
  37. v-model="form.description"
  38. type="textarea"
  39. rows="12"
  40. placeholder="请输入频道简介"
  41. />
  42. </el-form-item>
  43. </el-col>
  44. </el-row>
  45. <el-form-item label="频道内容:">
  46. <el-button type="primary" icon="el-icon-plus" @click="getDialog">
  47. 新增内容
  48. </el-button>
  49. <el-table :data="form.list" v-loading="loading">
  50. <el-table-column
  51. label="音频ID"
  52. prop="audioId"
  53. align="center"
  54. show-overflow-tooltip
  55. />
  56. <el-table-column
  57. label="音频名称"
  58. prop="audioName"
  59. align="center"
  60. show-overflow-tooltip
  61. />
  62. <el-table-column label="音频封面" align="center" width="100px">
  63. <template slot-scope="scope">
  64. <el-image :src="scope.row.audioPic" />
  65. </template>
  66. </el-table-column>
  67. <el-table-column
  68. label="音频作者"
  69. align="center"
  70. show-overflow-tooltip
  71. >
  72. <template slot-scope="scope">
  73. <span>
  74. {{ scope.row.singerName ? scope.row.singerName : "-" }}
  75. </span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column
  79. label="专辑名称"
  80. prop="songName"
  81. align="center"
  82. show-overflow-tooltip
  83. >
  84. <template slot-scope="scope">
  85. <span>
  86. {{ scope.row.songName ? scope.row.songName : "-" }}
  87. </span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column
  91. label="付费类型"
  92. prop="isFree"
  93. align="center"
  94. :formatter="freeFormatter"
  95. />
  96. <el-table-column
  97. label="资源平台"
  98. align="center"
  99. :formatter="platfromFormatter"
  100. />
  101. <el-table-column
  102. label="当前状态"
  103. align="center"
  104. :formatter="statusFormatter"
  105. />
  106. <!-- ///排序 -->
  107. <el-table-column label="序号" align="center">
  108. <template slot-scope="scope">
  109. <div v-if="editData.currentEditIndex !== scope.$index">
  110. <span style="margin-right: 8px">
  111. {{ scope.row.indexNum }}
  112. <!-- {{ scope.$index + 1 }} -->
  113. <!-- {{ scope.row.sort || "" }} -->
  114. </span>
  115. <svg-icon
  116. v-if="!isRead"
  117. icon-class="edit"
  118. @click.native="handleEditClick(scope.row, scope.$index)"
  119. />
  120. </div>
  121. <!--
  122. <el-input
  123. v-else
  124. v-model="scope.row.indexNum"
  125. type="number"
  126. rows="12"
  127. placeholder="序号"
  128. @blur="onNumberBlur(scope.row, scope.$index)"
  129. @keyup.enter.native="onNumberBlurEnter(scope.row, scope.$index)"
  130. /> -->
  131. <el-input
  132. v-else
  133. v-model="scope.row.indexNum"
  134. size="mini"
  135. style="width: 60px"
  136. type="number"
  137. @blur="onNumberBlur(scope.row, scope.$index)"
  138. @keyup.enter.native="onNumberBlurEnter(scope.row, scope.$index)"
  139. placeholder="序号"
  140. ref="numberInput"
  141. />
  142. </template>
  143. </el-table-column>
  144. <!-- ///排序 -->
  145. <el-table-column label="操作" align="center">
  146. <template slot-scope="scope">
  147. <el-button type="delete" @click="getDelete(scope.row)"
  148. >删除</el-button
  149. >
  150. <el-button
  151. type="text"
  152. icon="el-icon-caret-top"
  153. @click="getChangeSort(scope.$index, scope.$index - 1)"
  154. :disabled="scope.$index <= 0"
  155. />
  156. <el-button
  157. type="text"
  158. icon="el-icon-caret-bottom"
  159. @click="getChangeSort(scope.$index, scope.$index + 1)"
  160. :disabled="scope.$index > form.list.length - 2"
  161. />
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. </el-form-item>
  166. </el-form>
  167. <!-- 按钮 -->
  168. <div class="form-btn">
  169. <el-button @click="cancel">取消</el-button>
  170. <el-button v-if="!isRead" type="primary" @click="submit">提交</el-button>
  171. </div>
  172. <!-- 弹窗 -->
  173. <Dialog
  174. :visible="dialogVisible"
  175. :data="form.list"
  176. :channelType="form.channelType"
  177. @close="close"
  178. />
  179. </div>
  180. </template>
  181. <script>
  182. import { channelDetail, channeledit } from "@/api/operation/channels";
  183. import Dialog from "@/components/Dialog/index.vue";
  184. import { disabledMixin, isFreeMixin, platformMixin } from "@/mixin/index";
  185. export default {
  186. name: "operationChannelsDetail",
  187. mixins: [platformMixin, isFreeMixin, disabledMixin],
  188. components: {
  189. Dialog,
  190. },
  191. data() {
  192. return {
  193. editData: {
  194. currentEditIndex: -1,
  195. currentEditSort: 1,
  196. },
  197. // 遮罩层
  198. loading: false,
  199. // 弹窗
  200. dialogVisible: false,
  201. // 表单
  202. form: {},
  203. channelTypeOptions: [
  204. { value: 2, label: "广播" },
  205. { value: 6, label: "节目" },
  206. { value: 8, label: "专辑" },
  207. ],
  208. // 只读
  209. isRead: Boolean(this.$route.query.boolean),
  210. };
  211. },
  212. mounted() {
  213. this.getDetail();
  214. this.getPlatform({});
  215. },
  216. methods: {
  217. // 点击编辑图标显示输入框
  218. handleEditClick(row, index) {
  219. if (this.isRead) {
  220. return;
  221. }
  222. this.editData.currentEditIndex = index;
  223. this.editData.currentEditSort = row.indexNum;
  224. this.$nextTick(() => {
  225. this.$refs.numberInput.focus();
  226. });
  227. },
  228. onNumberBlurEnter(row, index) {
  229. this.editData.currentEditIndex = -1;
  230. },
  231. // 输入框失去焦点时隐藏
  232. onNumberBlur(row, index) {
  233. var newSort = row.indexNum;
  234. if (newSort === "") {
  235. row.indexNum = this.editData.currentEditSort;
  236. this.$message.warning("序号不能为空");
  237. return;
  238. }
  239. if (newSort <= 0) {
  240. row.indexNum = this.editData.currentEditSort;
  241. this.$message.warning("序号必须大于0");
  242. return;
  243. }
  244. if (newSort === this.editData.currentEditSort) {
  245. this.editData.currentEditIndex = -1;
  246. return;
  247. }
  248. ///删除第index个元素
  249. this.form.list.splice(index, 1);
  250. this.form.list.splice(newSort - 1, 0, row);
  251. for (var i = 0; i < this.form.list.length; i++) {
  252. this.form.list[i].indexNum = i + 1;
  253. }
  254. this.form.list = this.form.list.filter((i) => i);
  255. this.editData.currentEditIndex = -1;
  256. },
  257. // 排序
  258. getChangeSort(row, sort) {
  259. const rowBean = this.form.list[row];
  260. const sortBean = this.form.list[sort];
  261. this.form.list[row] = sortBean;
  262. this.form.list[sort] = rowBean;
  263. for (var i = 0; i < this.form.list.length; i++) {
  264. this.form.list[i].indexNum = i + 1;
  265. }
  266. this.form.list = this.form.list.filter((i) => i);
  267. // this.form.audioList = [];
  268. // this.form.list.map((i) => {
  269. // this.form.audioList.push({
  270. // audioId: i.audioId,
  271. // audioType: i.audioType,
  272. // });
  273. // });
  274. // channeledit(this.form).then((res) => {
  275. // if (res.code === 0) {
  276. // this.$message.success("修改成功!");
  277. // this.getDetail();
  278. // }
  279. // });
  280. },
  281. // 频道详情
  282. getDetail() {
  283. const channelId = this.$route.query.channelId;
  284. channelDetail({
  285. channelId: channelId,
  286. }).then((res) => {
  287. if (res.code === 0) {
  288. this.form = res.data;
  289. if (this.form.list) {
  290. for (var i = 0; i < this.form.list.length; i++) {
  291. this.form.list[i].indexNum = i + 1;
  292. }
  293. this.form.list = this.form.list.filter((i) => i);
  294. }
  295. }
  296. });
  297. },
  298. // 修改频道属性
  299. handleChange() {
  300. this.form.list = this.form.audioList = [];
  301. },
  302. // 上传频道封面
  303. getUpload(e) {
  304. this.form.pic = e.file;
  305. },
  306. // 打开弹窗
  307. getDialog() {
  308. this.dialogVisible = true;
  309. },
  310. // 关闭弹窗
  311. close() {
  312. this.dialogVisible = false;
  313. },
  314. // 删除
  315. getDelete(row) {
  316. this.form.list = this.form.list.filter((i) => i.audioId !== row.audioId);
  317. },
  318. // 提交
  319. submit() {
  320. this.form.audioList = [];
  321. this.form.list.map((i) => {
  322. this.form.audioList.push({
  323. audioId: i.audioId,
  324. audioType: i.audioType,
  325. });
  326. });
  327. channeledit(this.form).then((res) => {
  328. if (res.code === 0) {
  329. this.$message.success("修改成功!");
  330. this.getDetail();
  331. }
  332. });
  333. },
  334. // 取消
  335. cancel() {
  336. this.$tab.closeOpenPage("/operation/operationChannels");
  337. },
  338. // 字典翻译
  339. platfromFormatter(row) {
  340. return this.selectDictLabel(this.platformTypeOptions, row.platformId);
  341. },
  342. freeFormatter(row) {
  343. return this.selectDictLabel(this.freeOptions, row.isFree);
  344. },
  345. statusFormatter(row) {
  346. return this.selectDictLabel(this.disabledOptions, row.status);
  347. },
  348. },
  349. };
  350. </script>
  351. <style lang="scss" scoped>
  352. .el-image {
  353. width: 80px;
  354. height: 80px;
  355. }
  356. ::v-deep .el-dialog__body {
  357. height: 610px;
  358. overflow-y: scroll;
  359. }
  360. </style>