detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. <el-input
  122. v-else
  123. v-model="scope.row.indexNum"
  124. size="mini"
  125. style="width: 60px"
  126. type="number"
  127. @blur="onNumberBlur(scope.row, scope.$index)"
  128. @input="handleInput"f s s s s
  129. @keyup.enter.native="onNumberBlurEnter(scope.row, scope.$index)"
  130. placeholder="序号"
  131. ref="numberInput"
  132. />
  133. </template>
  134. </el-table-column>
  135. <!-- ///排序 -->
  136. <el-table-column label="操作" align="center">
  137. <template slot-scope="scope">
  138. <el-button type="delete" @click="getDelete(scope.row)"
  139. >删除</el-button
  140. >
  141. <el-button
  142. type="text"
  143. icon="el-icon-caret-top"
  144. @click="getChangeSort(scope.$index, scope.$index - 1)"
  145. :disabled="scope.$index <= 0"
  146. />
  147. <el-button
  148. type="text"
  149. icon="el-icon-caret-bottom"
  150. @click="getChangeSort(scope.$index, scope.$index + 1)"
  151. :disabled="scope.$index > form.list.length - 2"
  152. />
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. </el-form-item>
  157. </el-form>
  158. <!-- 按钮 -->
  159. <div class="form-btn">
  160. <el-button @click="cancel">取消</el-button>
  161. <el-button v-if="!isRead" type="primary" @click="submit">提交</el-button>
  162. </div>
  163. <!-- 弹窗 -->
  164. <Dialog
  165. :visible="dialogVisible"
  166. :data="form.list"
  167. :channelType="form.channelType"
  168. @close="close"
  169. />
  170. </div>
  171. </template>
  172. <script>
  173. import { channelDetail, channeledit } from "@/api/operation/channels";
  174. import Dialog from "@/components/Dialog/index.vue";
  175. import { disabledMixin, isFreeMixin, platformMixin } from "@/mixin/index";
  176. export default {
  177. // name: "operationChannelsDetail",
  178. mixins: [platformMixin, isFreeMixin, disabledMixin],
  179. components: {
  180. Dialog,
  181. },
  182. data() {
  183. return {
  184. editData: {
  185. currentEditIndex: -1,
  186. currentEditSort: 1,
  187. },
  188. // 遮罩层
  189. loading: false,
  190. // 弹窗
  191. dialogVisible: false,
  192. // 表单
  193. form: {},
  194. channelTypeOptions: [
  195. { value: 2, label: "广播" },
  196. { value: 6, label: "节目" },
  197. { value: 8, label: "专辑" },
  198. ],
  199. // 只读
  200. isRead: Boolean(this.$route.query.boolean),
  201. };
  202. },
  203. mounted() {
  204. this.getDetail();
  205. this.getPlatform({});
  206. },
  207. methods: {
  208. // 点击编辑图标显示输入框
  209. handleEditClick(row, index) {
  210. if (this.isRead) {
  211. return;
  212. }
  213. this.editData.currentEditIndex = index;
  214. this.editData.currentEditSort = row.indexNum;
  215. this.$nextTick(() => {
  216. this.$refs.numberInput.focus();
  217. this.$refs.numberInput.select();
  218. });
  219. },
  220. handleInput(value) {
  221. this.form.list[this.editData.currentEditIndex].indexNum = value;
  222. this.form.list = this.form.list.filter((i) => i);
  223. },
  224. onNumberBlurEnter(row, index) {
  225. this.editData.currentEditIndex = -1;
  226. },
  227. // 输入框失去焦点时隐藏
  228. onNumberBlur(row, index) {
  229. var newSort = row.indexNum;
  230. if (newSort === "") {
  231. row.indexNum = this.editData.currentEditSort;
  232. this.$message.warning("序号不能为空");
  233. return;
  234. }
  235. if (newSort <= 0) {
  236. row.indexNum = this.editData.currentEditSort;
  237. this.$message.warning("序号必须大于0");
  238. return;
  239. }
  240. if (newSort === this.editData.currentEditSort) {
  241. this.editData.currentEditIndex = -1;
  242. return;
  243. }
  244. ///删除第index个元素
  245. this.form.list.splice(index, 1);
  246. this.form.list.splice(newSort - 1, 0, row);
  247. for (var i = 0; i < this.form.list.length; i++) {
  248. this.form.list[i].indexNum = i + 1;
  249. }
  250. this.form.list = this.form.list.filter((i) => i);
  251. this.editData.currentEditIndex = -1;
  252. },
  253. // 排序
  254. getChangeSort(row, sort) {
  255. const rowBean = this.form.list[row];
  256. const sortBean = this.form.list[sort];
  257. this.form.list[row] = sortBean;
  258. this.form.list[sort] = rowBean;
  259. for (var i = 0; i < this.form.list.length; i++) {
  260. this.form.list[i].indexNum = i + 1;
  261. }
  262. this.form.list = this.form.list.filter((i) => i);
  263. // this.form.audioList = [];
  264. // this.form.list.map((i) => {
  265. // this.form.audioList.push({
  266. // audioId: i.audioId,
  267. // audioType: i.audioType,
  268. // });
  269. // });
  270. // channeledit(this.form).then((res) => {
  271. // if (res.code === 0) {
  272. // this.$message.success("修改成功!");
  273. // this.getDetail();
  274. // }
  275. // });
  276. },
  277. // 频道详情
  278. getDetail() {
  279. const channelId = this.$route.query.channelId;
  280. channelDetail({
  281. channelId: channelId,
  282. }).then((res) => {
  283. if (res.code === 0) {
  284. this.form = res.data;
  285. if (this.form.list) {
  286. for (var i = 0; i < this.form.list.length; i++) {
  287. this.form.list[i].indexNum = i + 1;
  288. }
  289. this.form.list = this.form.list.filter((i) => i);
  290. }
  291. }
  292. });
  293. },
  294. // 修改频道属性
  295. handleChange() {
  296. this.form.list = this.form.audioList = [];
  297. },
  298. // 上传频道封面
  299. getUpload(e) {
  300. this.form.pic = e.file;
  301. },
  302. // 打开弹窗
  303. getDialog() {
  304. this.dialogVisible = true;
  305. },
  306. // 关闭弹窗
  307. close() {
  308. this.dialogVisible = false;
  309. },
  310. // 删除
  311. getDelete(row) {
  312. this.form.list = this.form.list.filter((i) => i.audioId !== row.audioId);
  313. },
  314. // 提交
  315. submit() {
  316. this.form.audioList = [];
  317. this.form.list.map((i) => {
  318. this.form.audioList.push({
  319. audioId: i.audioId,
  320. audioType: i.audioType,
  321. });
  322. });
  323. channeledit(this.form).then((res) => {
  324. if (res.code === 0) {
  325. this.$message.success("修改成功!");
  326. this.getDetail();
  327. }
  328. });
  329. },
  330. // 取消
  331. cancel() {
  332. this.$tab.closeOpenPage("/operation/operationChannels");
  333. },
  334. // 字典翻译
  335. platfromFormatter(row) {
  336. return this.selectDictLabel(this.platformTypeOptions, row.platformId);
  337. },
  338. freeFormatter(row) {
  339. return this.selectDictLabel(this.freeOptions, row.isFree);
  340. },
  341. statusFormatter(row) {
  342. return this.selectDictLabel(this.disabledOptions, row.status);
  343. },
  344. },
  345. };
  346. </script>
  347. <style lang="scss" scoped>
  348. .el-image {
  349. width: 80px;
  350. height: 80px;
  351. }
  352. ::v-deep .el-dialog__body {
  353. height: 610px;
  354. overflow-y: scroll;
  355. }
  356. </style>