index.vue 18 KB

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