index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeTab" @tab-click="handleClick">
  4. <el-tab-pane v-for="item in tabs" :key="item.id" :label="item.name" :name="item.id.toString()" />
  5. </el-tabs>
  6. <!-- 内容 -->
  7. <div style="display: flex; position: relative; align-items: flex-start">
  8. <el-image class="bg" :src="img" />
  9. <div :class="['item', active === index ? 'active' : '']"
  10. :style="{top: item.top + 'px', height: item.height + 'px'}" v-for="(item, index) in style[tabIndex]"
  11. :key="index" @click="getActive(index)" />
  12. <div class="form">
  13. <!-- 标题内容模块 -->
  14. <el-form v-if="content()" label-width="auto">
  15. <el-form-item label="标题">
  16. <el-input v-model="contentForm.name" placeholder="请输入标题" />
  17. </el-form-item>
  18. <el-form-item label="简介:" v-if="tabIndex === 1 && active === 8">
  19. <el-input v-model="contentForm.description" type="textarea" rows="4" placeholder="请输入简介" />
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" @click="getChange">提交</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <!-- 标签 -->
  26. <el-form class="label" v-if="label()">
  27. <el-form-item v-for="item in list" :key="item.id">
  28. <el-button type="primary">{{ item.title }}</el-button>
  29. </el-form-item>
  30. </el-form>
  31. <!-- 内容列表模块 -->
  32. <div v-else>
  33. <el-form label-width="auto" v-for="(item, index) in list" :key="item.id">
  34. <el-form-item label-width="0" :label="item.sort.toString()" />
  35. <el-form-item label="时间:" v-if="time()">
  36. <el-date-picker v-model="item.date" type="datetimerange" start-placeholder="开始日期"
  37. end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" />
  38. </el-form-item>
  39. <el-form-item label="标题:" v-if="title()">
  40. <el-input v-model="item.title" placeholder="请输入标题" />
  41. </el-form-item>
  42. <el-form-item label="模式:" v-if="model()">
  43. <el-select v-model="item.model" placeholder="请选择模式">
  44. <el-option v-for="item in dict.type.content_model" :key="item.value" :label="item.label"
  45. :value="Number(item.value)" />
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item label="跳转方式:" v-if="forwardType()">
  49. <el-select v-model="item.forwardType" placeholder="请选择跳转方式">
  50. <el-option v-for="item in dict.type.nav_address_status" :key="item.value" :label="item.label"
  51. :value="Number(item.value)" />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="内容:" v-if="contentName(item)">
  55. <el-input v-model="item.contentName" prefix-icon="el-icon-search" placeholder="选择内容"
  56. @focus="getDialog(index)" />
  57. </el-form-item>
  58. <el-form-item label="简介:" v-if="description(item)">
  59. <el-input v-model="item.description" type="textarea" rows="4" placeholder="请输入简介" />
  60. </el-form-item>
  61. <el-form-item label="跳转地址:" v-if="forwardUrl(item)">
  62. <el-input v-model="item.forwardUrl" placeholder="请输入跳转地址" />
  63. </el-form-item>
  64. <el-form-item label="封面模式:" v-if="isCustom(item)">
  65. <el-select v-model="item.isCustom" placeholder="选择封面模式">
  66. <el-option v-for="item in dict.type.is_custom" :key="item.value" :label="item.label"
  67. :value="Number(item.value)" />
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item label="图片:" v-if="pic(item)">
  71. <Upload listType="picture-card" :url="item.pic" @upload="getUpload($event, index)" />
  72. </el-form-item>
  73. <el-form-item label="列表:" v-if="isList()">
  74. <el-button type="primary" @click="getDialog(index)">添加内容</el-button>
  75. <el-table :data="item.list">
  76. <el-table-column label="电台名称:" prop="contentName" align="center" />
  77. <el-table-column label="操作" align="center">
  78. <template>
  79. <el-button type="delete">删除</el-button>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. </el-form-item>
  84. <el-form-item>
  85. <el-button @click="getEmpty(item)">清空</el-button>
  86. <el-button type="primary" @click="getSubmit(item)">提交</el-button>
  87. </el-form-item>
  88. </el-form>
  89. </div>
  90. </div>
  91. </div>
  92. <!-- 弹窗 -->
  93. <el-dialog :visible.sync="dialogVisible" title="添加内容" width="1000px">
  94. <el-form inline size="mini">
  95. <el-form-item label="平台:">
  96. <el-select v-model="form.platformId" placeholder="请选择平台">
  97. <el-option v-for="item in dict.type.platform_type" :key="item.value" :label="item.label"
  98. :value="Number(item.value)" />
  99. </el-select>
  100. </el-form-item>
  101. <el-form-item label="类型:">
  102. <el-select v-model="form.audioType" placeholder="请选择类型"
  103. :disabled="this.tabIndex == 2 && this.active === 1">
  104. <el-option v-for="item in dict.type.audio_type" :key="item.value" :label="item.label"
  105. :value="Number(item.value)" />
  106. </el-select>
  107. </el-form-item>
  108. <el-form-item label="内容:">
  109. <el-input v-model="form.keyword" placeholder="请输入内容关键词" clearable />
  110. </el-form-item>
  111. <el-form-item>
  112. <el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
  113. </el-form-item>
  114. </el-form>
  115. <el-table :data="tableData" height="584" @selection-change="handleSelectionChange">
  116. <el-table-column type="selection" align="center" />
  117. <el-table-column label="音频ID" prop="audioId" align="center" />
  118. <el-table-column label="音频名称" prop="audioName" align="center" show-overflow-tooltip />
  119. <el-table-column label="音频封面" align="center" width="100px">
  120. <template slot-scope="scope">
  121. <el-image :src="scope.row.audioPic" />
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="音频类型" prop="audioType" align="center" :formatter="audioFormatter" />
  125. <el-table-column label="节目数量" prop="programCount" align="center" />
  126. <el-table-column label="付费类型" align="center" :formatter="freeFormatter" width="100px" />
  127. <el-table-column label="操作" align="center" v-if="this.tabIndex !== 2 && this.active !== 1">
  128. <template slot-scope="scope">
  129. <el-button type="text" @click="getSelect(scope.row)">选择</el-button>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <pagination v-show="total>0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
  134. @pagination="getContentList" />
  135. </el-dialog>
  136. </div>
  137. </template>
  138. <script>
  139. import {
  140. listAll,
  141. recommendList,
  142. moduleDetail,
  143. submit,
  144. contentList,
  145. radioList,
  146. moduleContent
  147. } from '@/api/operation/recommend'
  148. import Upload from '@/components/Upload/index'
  149. export default {
  150. dicts: [
  151. 'platform_type',
  152. 'audio_type',
  153. 'free_yes_no',
  154. 'is_custom',
  155. 'nav_address_status',
  156. 'content_model'
  157. ],
  158. components: {
  159. Upload
  160. },
  161. data() {
  162. return {
  163. // 分类列表
  164. tabs: [],
  165. // 选中分类
  166. activeTab: '77',
  167. // 分类排序
  168. tabIndex: 1,
  169. // 模板列表
  170. module: [],
  171. // 模板图
  172. imgOptions: {
  173. '0': require('@/assets/images/operation/recommend.svg'),
  174. '1': require('@/assets/images/operation/radio.svg'),
  175. '2': require('@/assets/images/operation/music.svg'),
  176. '3': require('@/assets/images/operation/story.svg'),
  177. '4': require('@/assets/images/operation/kid.svg'),
  178. '5': require('@/assets/images/operation/other.svg')
  179. },
  180. img: require('@/assets/images/operation/recommend.svg'),
  181. // 选中模块
  182. style: {
  183. '1': [
  184. { top: 150, height: 225 },
  185. { top: 380, height: 175 },
  186. { top: 560, height: 185 },
  187. { top: 750, height: 315 },
  188. { top: 1070, height: 645 },
  189. { top: 1720, height: 185 },
  190. { top: 1910, height: 220 },
  191. { top: 2140, height: 315 },
  192. { top: 2460, height: 295 },
  193. { top: 2760, height: 600 },
  194. { top: 3370, height: 260 },
  195. { top: 3635, height: 600 }
  196. ],
  197. '2': [
  198. { top: 135, height: 165 },
  199. { top: 310, height: 250 },
  200. { top: 570, height: 100 },
  201. { top: 1465, height: 570 }
  202. ],
  203. '3': [
  204. { top: 150, height: 170 },
  205. { top: 385, height: 90 },
  206. { top: 480, height: 215 },
  207. { top: 700, height: 175 },
  208. { top: 880, height: 310 },
  209. { top: 1195, height: 300 },
  210. { top: 1500, height: 215 },
  211. { top: 1720, height: 305 },
  212. { top: 2490, height: 210 },
  213. { top: 2705, height: 220 },
  214. ],
  215. '4': [
  216. { top: 150, height: 165 },
  217. { top: 320, height: 115 },
  218. { top: 440, height: 405 },
  219. { top: 850, height: 230 },
  220. { top: 1085, height: 410 },
  221. { top: 1500, height: 130 },
  222. { top: 1635, height: 405 },
  223. { top: 2045, height: 170 },
  224. { top: 2220, height: 405 },
  225. { top: 2850, height: 405 },
  226. { top: 3260, height: 405 },
  227. { top: 3670, height: 620 }
  228. ],
  229. '5': [
  230. { top: 150, height: 180 },
  231. { top: 335, height: 120 },
  232. { top: 460, height: 425 },
  233. { top: 890, height: 125 },
  234. { top: 1020, height: 425 },
  235. { top: 1450, height: 210 },
  236. { top: 1665, height: 425 },
  237. { top: 2325, height: 640 }
  238. ],
  239. '6': [
  240. { top: 140, height: 165 },
  241. { top: 310, height: 115 },
  242. { top: 430, height: 375 },
  243. { top: 810, height: 385 },
  244. { top: 1200, height: 120 },
  245. { top: 1325, height: 390 },
  246. { top: 1720, height: 160 },
  247. { top: 1885, height: 385 },
  248. { top: 2480, height: 390 },
  249. { top: 2875, height: 590 }
  250. ]
  251. },
  252. active: 0,
  253. // 模块内容
  254. contentForm: {},
  255. list: [],
  256. // 表单
  257. form: {},
  258. // 弹窗
  259. dialogVisible: false,
  260. form: {
  261. audioType: 2,
  262. platformId: 1,
  263. pageNum: 1,
  264. pageSize: 10
  265. },
  266. total: 0,
  267. index: 0,
  268. // 列表
  269. tableData: []
  270. }
  271. },
  272. mounted() {
  273. this.getTab()
  274. },
  275. methods: {
  276. // 分类列表
  277. getTab() {
  278. listAll().then(res => {
  279. if (res.code === 0) {
  280. this.tabs = res.data
  281. this.getModule(this.activeTab)
  282. }
  283. })
  284. },
  285. // 切换分类
  286. handleClick(e) {
  287. this.activeTab = this.tabs[e.index].id.toString()
  288. this.tabIndex = this.tabs[e.index].tabIndex
  289. e.index >= 5 ? e.index = 5 : e.index
  290. this.img = this.imgOptions[e.index]
  291. this.active = 0
  292. this.list = []
  293. this.getModule(this.activeTab)
  294. },
  295. // 模块列表
  296. getModule(id) {
  297. recommendList({
  298. categoryId: id
  299. }).then(res => {
  300. if (res.code === 0) {
  301. this.module = res.data
  302. this.getDetail(res.data[0].id)
  303. }
  304. })
  305. },
  306. // 选择模块
  307. getActive(index) {
  308. if (this.active !== index) {
  309. this.active = index
  310. this.getDetail(this.module[index].id)
  311. }
  312. },
  313. // 模块详情
  314. getDetail(id) {
  315. // 标题模块内容
  316. moduleDetail({
  317. id: id
  318. }).then(res => {
  319. if (res.code === 0) {
  320. this.contentForm = res.data
  321. }
  322. })
  323. // 模块内容列表
  324. this.list = []
  325. contentList({
  326. moduleId: id
  327. }).then(res => {
  328. if (res.code === 0) {
  329. res.data.map(i => {
  330. this.list.push({
  331. ...i,
  332. date: [i.startTime, i.endTime]
  333. })
  334. })
  335. }
  336. })
  337. },
  338. // 标题模块提交
  339. getChange() {
  340. moduleContent(this.contentForm).then(res => {
  341. if (res.code === 0) {
  342. this.$message.success('提交成功!')
  343. this.getDetail(this.contentForm.id)
  344. }
  345. })
  346. },
  347. // 内容列表提交
  348. getSubmit(item) {
  349. item.startTime = item.date[0]
  350. item.endTime = item.date[1]
  351. delete item.date
  352. submit(item).then(res => {
  353. if (res.code === 0) {
  354. this.$message.success('提交成功!')
  355. this.getDetail(item.moduleId)
  356. }
  357. })
  358. },
  359. // 弹窗
  360. getDialog(index) {
  361. this.dialogVisible = true
  362. this.index = index
  363. this.list[this.index].list = []
  364. this.getContentList()
  365. },
  366. // 搜索
  367. getSearch(){
  368. this.form.pageNum = 1
  369. this.getContentList()
  370. },
  371. // 内容列表
  372. getContentList() {
  373. radioList(this.form).then(res => {
  374. if (res.code === 0) {
  375. this.tableData = res.data.records
  376. this.total = res.data.total
  377. }
  378. })
  379. },
  380. // 选择某一个音频内容
  381. getSelect(row) {
  382. let e = this.list[this.index]
  383. e.contentId = row.audioId
  384. e.contentName = row.audioName
  385. e.platformId = row.platformId
  386. e.contentType = row.audioType
  387. this.dialogVisible = false
  388. this.$message.success('选择成功!')
  389. },
  390. // 批量选择
  391. handleSelectionChange(row) {
  392. row.map(i => {
  393. this.list[this.index].list.push({
  394. contentId: i.audioId,
  395. contentName: i.audioName
  396. })
  397. })
  398. },
  399. // 上传图片
  400. getUpload(e, index) {
  401. this.list[index].pic = e.file
  402. },
  403. // 清空
  404. getEmpty(item) {
  405. Object.keys(item).map(key => {
  406. if (key !== 'id' && key !== 'moduleId') {
  407. item[key] = ''
  408. }
  409. })
  410. },
  411. // 字典翻译
  412. audioFormatter(row) {
  413. return this.selectDictLabel(this.dict.type.audio_type, row.audioType)
  414. },
  415. freeFormatter(row) {
  416. return this.selectDictLabel(this.dict.type.free_yes_no, row.isFree)
  417. },
  418. // v-if判断
  419. // 标题模块
  420. content() {
  421. let rules = {
  422. '1': [3, 4, 5, 6, 8].includes(this.active),
  423. '2': [1, 3].includes(this.active),
  424. '3': [2, 4, 6, 7, 8, 9].includes(this.active),
  425. '4': [2, 4, 6, 8, 9, 10, 11].includes(this.active),
  426. '5': [2, 4, 5, 6, 7].includes(this.active),
  427. '6': [2, 3, 5, 7, 8, 9].includes(this.active)
  428. }
  429. return rules[this.tabIndex]
  430. },
  431. // 标签模块
  432. label() {
  433. let rules = {
  434. '2': this.tabIndex === 2 && this.active === 2,
  435. '3': this.tabIndex === 3 && this.active === 1,
  436. '4': [1, 5].includes(this.active) && this.tabIndex === 4,
  437. '5': [1, 3].includes(this.active) && this.tabIndex === 5,
  438. '6': [1, 4].includes(this.active) && this.tabIndex === 6
  439. }
  440. return rules[this.tabIndex]
  441. },
  442. // 时间
  443. time() {
  444. let rules = {
  445. '1': this.active !== 3 && this.active !== 8,
  446. '2': [0, 3].includes(this.active),
  447. '3': this.active !== 1,
  448. '4': this.active !== 1 || this.active !== 5,
  449. '5': this.active !== 1 || this.active !== 3,
  450. '6': this.active !== 1 || this.active !== 4
  451. }
  452. return rules[this.tabIndex]
  453. },
  454. // 标题
  455. title() {
  456. let rules = {
  457. '1': this.active === 10,
  458. '2': this.active === 1,
  459. '3': [3, 5, 9].includes(this.active),
  460. '4': [7].includes(this.active),
  461. '5': [5].includes(this.active)
  462. }
  463. return rules[this.tabIndex]
  464. },
  465. // 模式
  466. model() {
  467. let rules = {
  468. '1': [4, 5, 7, 9, 11].includes(this.active),
  469. '2': [3].includes(this.active),
  470. '3': [4, 7, 8].includes(this.active),
  471. '4': [2, 4, 6, 8, 9, 10, 11].includes(this.active),
  472. '5': [2, 4, 6, 7].includes(this.active),
  473. '6': [2, 3, 5, 7, 8, 9].includes(this.active)
  474. }
  475. return rules[this.tabIndex]
  476. },
  477. // 跳转方式
  478. forwardType() {
  479. let rules = {
  480. '1': [1, 2].includes(this.active),
  481. '2': [0].includes(this.active),
  482. '3': [0].includes(this.active),
  483. '4': [0, 3].includes(this.active),
  484. '5': [0].includes(this.active),
  485. '6': [0].includes(this.active)
  486. }
  487. return rules[this.tabIndex]
  488. },
  489. // 内容
  490. contentName(item) {
  491. let rules = {
  492. '1': [0, 6, 8, 10].includes(this.active),
  493. '3': [2, 3, 5, 6, 9].includes(this.active),
  494. '4': [7].includes(this.active),
  495. '5': [5].includes(this.active),
  496. '6': [6].includes(this.active)
  497. }
  498. return rules[this.tabIndex] || [0, 1].includes(item.forwardType) || item.model === 1
  499. },
  500. // 简介
  501. description(item) {
  502. let rules = {
  503. '1': (this.active === 7 && item.model === 1) || this.active === 10,
  504. '3': [3, 5].includes(this.active) || [4, 7, 8].includes(this.active) && item.model === 1,
  505. '4': [7].includes(this.active)
  506. }
  507. return rules[this.tabIndex]
  508. },
  509. // 跳转连接
  510. forwardUrl(item) {
  511. return [2, 3].includes(item.forwardType)
  512. },
  513. // 封面模式
  514. isCustom(item) {
  515. let rules = {
  516. '1': [0, 8].includes(this.active),
  517. '5': [5].includes(this.active),
  518. }
  519. return rules[this.tabIndex] || item.model === 1
  520. },
  521. // 图片
  522. pic(item) {
  523. let rules = {
  524. '1': [1, 2, 6, 8, 10].includes(this.active),
  525. '2': [0, 1].includes(this.active),
  526. '3': [0, 2, 3, 5, 6, 9].includes(this.active),
  527. '4': [0, 3, 7].includes(this.active),
  528. '5': [0, 5].includes(this.active),
  529. '6': [0, 6].includes(this.active)
  530. }
  531. return rules[this.tabIndex] || item.isCustom === 0
  532. },
  533. // 列表
  534. isList() {
  535. return this.tabIndex === 2 && this.active === 1
  536. }
  537. }
  538. }
  539. </script>
  540. <style lang="scss" scoped>
  541. .bg {
  542. width: 365px;
  543. .el-image__error,
  544. .el-image__placeholder,
  545. .el-image__inner {
  546. height: auto;
  547. }
  548. }
  549. .item {
  550. position: absolute;
  551. left: 0;
  552. width: 365px;
  553. border: 1px solid yellow;
  554. }
  555. .active {
  556. background: rgba(255, 255, 0, 0.3);
  557. }
  558. .form {
  559. width: calc(100% - 395px);
  560. .el-form {
  561. width: 500px;
  562. margin-left: 30px;
  563. border: 1px solid #dcdfe6;
  564. box-shadow: 5px 5px 5px 0px #dcdfe6;
  565. padding: 20px;
  566. margin-bottom: 20px;
  567. }
  568. }
  569. .label {
  570. display: flex;
  571. flex-wrap: wrap;
  572. .el-form-item {
  573. width: calc(100% / 4);
  574. margin: 0;
  575. text-align: center;
  576. }
  577. }
  578. </style>