index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  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" v-hasPermi="['operation:recommend:submit']">
  23. 提交
  24. </el-button>
  25. </el-form-item>
  26. </el-form>
  27. <!-- 推荐时间段配置 -->
  28. <div v-if="tabIndex === 1 && active === 0" style="float: left">
  29. <el-form label-width="auto" v-for="(item, index) in timeList" :key="item.id">
  30. <el-form-item label-width="0">
  31. <span style="font-weight: bold">场景电台时间设置</span>
  32. <el-link icon="el-icon-close" :underline="false" style="float:right" @click="getChangeTime(item.id, 2)" />
  33. </el-form-item>
  34. <el-form-item label="时间段:">
  35. <el-time-picker is-range v-model="item.date" start-placeholder="开始时间" end-placeholder="结束时间"
  36. value-format="HH:mm:ss" format="HH:mm:ss" placeholder="选择时间范围" />
  37. </el-form-item>
  38. <el-form-item label="时间段文案:">
  39. <el-input v-model="item.name" placeholder="请输入文案" />
  40. </el-form-item>
  41. <el-form-item label="时间段Icon:">
  42. <Upload listType="picture-card" :url="item.pic" @upload="uploadIcon($event, index)" />
  43. </el-form-item>
  44. <el-form-item>
  45. <el-button @click="getEmpty(item)" v-hasPermi="['operation:recommend:delete']">清空</el-button>
  46. <el-button type="primary" @click="getSubmitTime(item)"
  47. v-hasPermi="['operation:recommend:submit']">提交</el-button>
  48. <el-button v-if="item.status === 0" type="primary" plain @click="getChangeTime(item.id, 1)"
  49. v-hasPermi="['operation:recommend:up']">上架
  50. </el-button>
  51. <el-button v-else type="primary" plain @click="getChangeTime(item.id, 0)"
  52. v-hasPermi="['operation:recommend:down']">下架</el-button>
  53. </el-form-item>
  54. </el-form>
  55. <el-button type="primary" style="margin-left: 30px" @click="getAddTime"
  56. v-hasPermi="['operation:recommend:add']">新增</el-button>
  57. </div>
  58. <!-- 标签 -->
  59. <el-form class="label" v-if="label()">
  60. <el-form-item v-for="item in list" :key="item.id">
  61. <el-button type="primary">{{ item.title }}</el-button>
  62. </el-form-item>
  63. </el-form>
  64. <!-- 内容列表模块 -->
  65. <div v-else :style="{ 'display': tabIndex === 1 && active === 0 ? 'inline-block' : 'block' }">
  66. <el-form label-width="auto" v-for="(item, index) in list" :key="item.id">
  67. <el-form-item label-width="0" :label="(index + 1).toString()">
  68. <el-link v-if="close()" icon="el-icon-close" :underline="false" style="float:right"
  69. @click="getRemoveList(item, index)" />
  70. </el-form-item>
  71. <el-form-item label="时间:" v-if="time()">
  72. <el-date-picker v-model="item.date" type="datetimerange" start-placeholder="开始日期" end-placeholder="结束日期"
  73. value-format="yyyy-MM-dd HH:mm:ss" />
  74. </el-form-item>
  75. <el-form-item label="标题:" v-if="title()">
  76. <el-input v-model="item.title" placeholder="请输入标题" />
  77. </el-form-item>
  78. <el-form-item label="模式:" v-if="model()">
  79. <el-select v-model="item.model" placeholder="请选择模式" @change="getModel(item)">
  80. <el-option v-for="item in contentOptions" :key="item.value" :label="item.label"
  81. :value="Number(item.value)" />
  82. </el-select>
  83. </el-form-item>
  84. <el-form-item label="跳转方式:" v-if="forwardType()">
  85. <el-select v-model="item.forwardType" placeholder="请选择跳转方式">
  86. <el-option v-for="item in typeOptions" :key="item.value" :label="item.label"
  87. :value="Number(item.value)" />
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item label="专区页面:" v-if="item.forwardType === 7">
  91. <el-select placeholder="请选择跳转专区">
  92. <el-option v-for="item in locationOptions" :key="item.value" :value="item.value" :label="item.label" />
  93. </el-select>
  94. </el-form-item>
  95. <el-form-item label="内容:" v-if="contentName(item)">
  96. <el-input v-model="item.contentName" prefix-icon="el-icon-search" placeholder="选择内容"
  97. @focus="getDialog(index)" />
  98. </el-form-item>
  99. <el-form-item label="简介:" v-if="description(item)">
  100. <el-input v-model="item.description" type="textarea" rows="4" placeholder="请输入简介" />
  101. </el-form-item>
  102. <el-form-item label="跳转地址:" v-if="forwardUrl(item)">
  103. <el-input v-model="item.forwardUrl" placeholder="请输入跳转地址" />
  104. </el-form-item>
  105. <el-form-item label="封面模式:" v-if="isCustom(item)">
  106. <el-select v-model="item.isCustom" placeholder="选择封面模式">
  107. <el-option v-for="item in coverOptions" :key="item.value" :label="item.label"
  108. :value="Number(item.value)" />
  109. </el-select>
  110. </el-form-item>
  111. <el-form-item label="图片:" v-if="pic(item)">
  112. <Upload listType="picture-card" :url="item.pic" @upload="getUpload($event, index)" />
  113. </el-form-item>
  114. <el-form-item label="排序:" v-if="sort()">
  115. <el-input-number v-model="item.sort" />
  116. </el-form-item>
  117. <el-form-item label="列表:" v-if="isList()">
  118. <el-button type="primary" @click="getDialog(index)" v-hasPermi="['operation:recommend:add']">
  119. 添加内容
  120. </el-button>
  121. <el-table :data="item.childList">
  122. <el-table-column label="电台名称:" prop="contentName" align="center" show-overflow-tooltip />
  123. <el-table-column label="当前状态" prop="status" align="center" :formatter="statusFormatter" />
  124. <el-table-column label="操作" align="center">
  125. <template slot-scope="scope">
  126. <el-button type="delete" @click="getDelete(scope.row, index)"
  127. v-hasPermi="['operation:recommend:delete']">删除</el-button>
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. </el-form-item>
  132. <el-form-item size="small">
  133. <el-button @click="getEmpty(item)" v-hasPermi="['operation:recommend:delete']">清空</el-button>
  134. <el-button type="primary" @click="getSubmit(item)" v-hasPermi="['operation:recommend:submit']">
  135. 提交
  136. </el-button>
  137. <el-button v-if="item.status === 1" type="primary" plain @click="handleChange(item, 0)"
  138. v-hasPermi="['operation:recommend:up']">上架
  139. </el-button>
  140. <el-button v-else type="primary" plain @click="handleChange(item, 1)"
  141. v-hasPermi="['operation:recommend:down']">下架</el-button>
  142. </el-form-item>
  143. </el-form>
  144. <el-button v-if="add()" type="primary" style="margin-left: 30px" @click="getAdd"
  145. v-hasPermi="['operation:recommend:add']">新增</el-button>
  146. </div>
  147. </div>
  148. </div>
  149. <!-- 弹窗 -->
  150. <el-dialog :visible.sync="dialogVisible" title="添加内容" width="1000px">
  151. <el-form inline size="mini">
  152. <el-form-item label="音频类型:">
  153. <el-select v-model="form.audioType" placeholder="请选择类型" :disabled="disabled">
  154. <el-option v-for="item in audioOptions" :key="item.value" :label="item.label" :value="item.value" />
  155. </el-select>
  156. </el-form-item>
  157. <el-form-item label="资源平台:">
  158. <el-select v-model="form.platformId" placeholder="请选择平台">
  159. <el-option v-for="item in platformOptions" :key="item.value" :label="item.label" :value="item.value" />
  160. </el-select>
  161. </el-form-item>
  162. <el-form-item label="内容:">
  163. <el-input v-model="form.keyword" placeholder="请输入内容关键词" clearable />
  164. </el-form-item>
  165. <el-form-item>
  166. <el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
  167. </el-form-item>
  168. </el-form>
  169. <el-table :data="tableData" ref="tableData" :row-key="rowKey" @selection-change="handleSelectionChange"
  170. v-loading="loading">
  171. <el-table-column type="selection" align="center" reserve-selection key="selection"
  172. v-if="tabIndex === 2 && active === 1" />
  173. <el-table-column label="音频ID" prop="audioId" align="center" key="audioId" show-overflow-tooltip />
  174. <el-table-column label="音频名称" prop="audioName" align="center" key="audioName" show-overflow-tooltip />
  175. <el-table-column label="音频封面" align="center" key="audioPic" width="100px">
  176. <template slot-scope="scope">
  177. <el-image :src="scope.row.audioPic" />
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="音频类型" prop="audioType" align="center" key="audioType" :formatter="audioFormatter" />
  181. <el-table-column label="音频数量" prop="programCount" align="center" key="programCount" />
  182. <el-table-column label="付费类型" align="center" key="isFree" :formatter="freeFormatter" width="100px" />
  183. <el-table-column label="当前状态" align="center" key="status" :formatter="statusFormatter" />
  184. <el-table-column label="操作" align="center" key="change" v-if="tabIndex === 2 && active === 1 ? false : true">
  185. <template slot-scope="scope">
  186. <el-button type="text" @click="getSelect(scope.row)">
  187. 选择
  188. </el-button>
  189. </template>
  190. </el-table-column>
  191. </el-table>
  192. <pagination v-show="total > 0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
  193. @pagination="getContentList" />
  194. </el-dialog>
  195. <!-- 置顶按钮 -->
  196. <el-backtop />
  197. </div>
  198. </template>
  199. <script>
  200. import {
  201. listAll,
  202. recommendList,
  203. moduleDetail,
  204. submit,
  205. contentList,
  206. radioList,
  207. moduleContent,
  208. upOrDown,
  209. timeList,
  210. submitTime,
  211. changeTime,
  212. expandSave,
  213. removeList
  214. } from '@/api/operation/recommend'
  215. import { isFreeMixin, audioMixin, platformMixin, onOrOffMixin, coverMixin } from '@/mixin/index'
  216. export default {
  217. mixins: [isFreeMixin, audioMixin, platformMixin, onOrOffMixin, coverMixin],
  218. data() {
  219. return {
  220. // 遮罩层
  221. loading: false,
  222. // 分类列表
  223. tabs: [],
  224. // 选中分类
  225. activeTab: '77',
  226. // 分类排序
  227. tabIndex: 1,
  228. // 模板列表
  229. module: [],
  230. // 模板图
  231. imgOptions: {
  232. '0': require('@/assets/images/operation/recommend.svg'),
  233. '1': require('@/assets/images/operation/radio.svg'),
  234. '2': require('@/assets/images/operation/music.svg'),
  235. '3': require('@/assets/images/operation/story.svg'),
  236. '4': require('@/assets/images/operation/kid.svg'),
  237. '5': require('@/assets/images/operation/other.svg'),
  238. '27': require('@/assets/images/operation/kugou.png')
  239. },
  240. img: require('@/assets/images/operation/recommend.svg'),
  241. // 选中模块
  242. style: {
  243. '1': [
  244. { top: 150, height: 225 },
  245. { top: 380, height: 175 },
  246. { top: 560, height: 185 },
  247. { top: 750, height: 315 },
  248. { top: 1070, height: 645 },
  249. { top: 1720, height: 185 },
  250. { top: 1910, height: 220 },
  251. { top: 2140, height: 315 },
  252. { top: 2460, height: 295 },
  253. { top: 2760, height: 600 },
  254. { top: 3370, height: 260 },
  255. { top: 3635, height: 600 },
  256. { top: 4245, height: 215 }
  257. ],
  258. '2': [
  259. { top: 135, height: 165 },
  260. { top: 310, height: 250 },
  261. { top: 570, height: 100 },
  262. { top: 1465, height: 570 }
  263. ],
  264. '3': [
  265. { top: 150, height: 170 },
  266. { top: 385, height: 90 },
  267. { top: 480, height: 215 },
  268. { top: 700, height: 175 },
  269. { top: 880, height: 310 },
  270. { top: 1195, height: 300 },
  271. { top: 1500, height: 215 },
  272. { top: 1720, height: 305 },
  273. { top: 2490, height: 210 },
  274. { top: 2705, height: 220 },
  275. ],
  276. '4': [
  277. { top: 150, height: 165 },
  278. { top: 320, height: 115 },
  279. { top: 440, height: 405 },
  280. { top: 850, height: 230 },
  281. { top: 1085, height: 410 },
  282. { top: 1500, height: 130 },
  283. { top: 1635, height: 405 },
  284. { top: 2045, height: 170 },
  285. { top: 2220, height: 405 },
  286. { top: 2850, height: 405 },
  287. { top: 3260, height: 405 },
  288. { top: 3670, height: 620 }
  289. ],
  290. '5': [
  291. { top: 150, height: 180 },
  292. { top: 335, height: 120 },
  293. { top: 460, height: 425 },
  294. { top: 890, height: 125 },
  295. { top: 1020, height: 425 },
  296. { top: 1450, height: 210 },
  297. { top: 1665, height: 425 },
  298. { top: 2325, height: 640 }
  299. ],
  300. '6': [
  301. { top: 140, height: 165 },
  302. { top: 310, height: 115 },
  303. { top: 430, height: 375 },
  304. { top: 810, height: 385 },
  305. { top: 1200, height: 120 },
  306. { top: 1325, height: 390 },
  307. { top: 1720, height: 160 },
  308. { top: 1885, height: 385 },
  309. { top: 2480, height: 390 },
  310. { top: 2875, height: 590 }
  311. ],
  312. '7': [
  313. { top: 130, height: 160 },
  314. { top: 375, height: 205 },
  315. { top: 585, height: 205 },
  316. { top: 800, height: 150 },
  317. { top: 960, height: 300 }
  318. ]
  319. },
  320. active: 0,
  321. // 模块内容
  322. contentForm: {},
  323. list: [],
  324. // 时间段列表
  325. timeList: [],
  326. // 弹窗
  327. dialogVisible: false,
  328. form: {
  329. pageNum: 1,
  330. pageSize: 10,
  331. audioType: null,
  332. platformId: null
  333. },
  334. total: 0,
  335. index: 0,
  336. disabled: false,
  337. // 列表
  338. tableData: [],
  339. // 跳转方式
  340. typeOptions: [{
  341. value: 0,
  342. label: 'APP内容跳转广播',
  343. type: 2
  344. }, {
  345. value: 1,
  346. label: 'APP内容跳转歌曲',
  347. type: 11
  348. }, {
  349. value: 2,
  350. label: 'APP内容跳转歌单',
  351. type: 10
  352. }, {
  353. value: 3,
  354. label: 'APP内容跳转专辑',
  355. type: 8
  356. }, {
  357. value: 4,
  358. label: 'APP内容跳转节目',
  359. type: 6
  360. }, {
  361. value: 7,
  362. label: 'APP内容跳转专区'
  363. }, {
  364. value: 5,
  365. label: 'H5内链'
  366. }, {
  367. value: 6,
  368. label: 'H5外链'
  369. }],
  370. contentOptions: [{
  371. value: 0,
  372. label: '自动推荐内容'
  373. }, {
  374. value: 1,
  375. label: '手动推荐内容'
  376. }],
  377. // 专区
  378. locationOptions: [{
  379. value: 0,
  380. label: '运动专区'
  381. }, {
  382. value: 1,
  383. label: '睡眠专区'
  384. }, {
  385. value: 2,
  386. label: '儿童专区'
  387. }]
  388. }
  389. },
  390. watch: {
  391. async 'form.audioType'(val) {
  392. if (this.tabIndex !== 1 || this.active !== 12) {
  393. await this.getPlatform({
  394. audioType: val
  395. })
  396. this.platformId = this.platformOptions[0].value
  397. this.getContentList()
  398. }
  399. }
  400. },
  401. mounted() {
  402. this.getTab()
  403. },
  404. methods: {
  405. // 分类列表
  406. getTab() {
  407. listAll().then(res => {
  408. if (res.code === 0) {
  409. this.tabs = res.data
  410. this.getModule(this.activeTab)
  411. this.getTimeList()
  412. }
  413. })
  414. },
  415. // 切换分类
  416. handleClick(e) {
  417. this.activeTab = this.tabs[e.index].id.toString()
  418. this.tabIndex = this.tabs[e.index].tabIndex
  419. e.index = e.index < 5 ? e.index : e.index == 27 ? 27 : 5
  420. this.img = this.imgOptions[e.index]
  421. this.active = 0
  422. this.list = []
  423. this.getModule(this.activeTab)
  424. },
  425. // 模块列表
  426. getModule(id) {
  427. recommendList({
  428. categoryId: id
  429. }).then(res => {
  430. if (res.code === 0) {
  431. this.module = res.data
  432. this.getModuleDetail(res.data[0].id)
  433. this.getContentDetail(res.data[0].id)
  434. }
  435. })
  436. },
  437. // 选择模块
  438. getActive(index) {
  439. if (this.active !== index) {
  440. this.active = index
  441. this.form.audioType = 2
  442. this.getModuleDetail(this.module[index].id)
  443. this.getContentDetail(this.module[index].id)
  444. }
  445. if (this.tabIndex === 1 && this.active === 0) {
  446. this.getTimeList()
  447. }
  448. },
  449. // 模块详情
  450. getModuleDetail(id) {
  451. moduleDetail({
  452. id: id
  453. }).then(res => {
  454. if (res.code === 0) {
  455. this.contentForm = res.data
  456. }
  457. })
  458. },
  459. // 时间段列表
  460. getTimeList() {
  461. this.timeList = []
  462. timeList().then(res => {
  463. if (res.code === 0) {
  464. res.data.map(i => {
  465. this.timeList.push({
  466. ...i,
  467. date: [i.startTime, i.endTime]
  468. })
  469. })
  470. }
  471. })
  472. },
  473. // 模块内容列表
  474. getContentDetail(id) {
  475. this.list = []
  476. contentList({
  477. moduleId: id
  478. }).then(res => {
  479. if (res.code === 0) {
  480. res.data.map(i => {
  481. this.list.push({
  482. ...i,
  483. date: [i.startTime, i.endTime]
  484. })
  485. })
  486. }
  487. })
  488. },
  489. // 标题模块提交
  490. getChange() {
  491. moduleContent(this.contentForm).then(res => {
  492. if (res.code === 0) {
  493. this.$message.success('提交成功!')
  494. this.getModuleDetail(this.contentForm.id)
  495. }
  496. })
  497. },
  498. // 内容列表提交
  499. getSubmit(item) {
  500. if (this.tabIndex === 2 && this.active === 1) {
  501. expandSave(item).then(res => {
  502. if (res.code === 0) {
  503. this.$message.success('提交成功!')
  504. this.getContentDetail(item.moduleId)
  505. }
  506. })
  507. } else {
  508. item.startTime = item.date[0]
  509. item.endTime = item.date[1]
  510. delete item.date
  511. submit(item).then(res => {
  512. if (res.code === 0) {
  513. this.$message.success('提交成功!')
  514. this.getContentDetail(item.moduleId)
  515. }
  516. })
  517. }
  518. },
  519. // 弹窗
  520. async getDialog(index) {
  521. this.dialogVisible = true
  522. this.index = index
  523. if (this.tabIndex === 1 && this.active === 12) {
  524. await this.getAudioType(9)
  525. this.audioOptions = this.audioTypeOptions
  526. this.platformOptions = [{
  527. value: 9,
  528. label: '酷狗音乐'
  529. }]
  530. this.form.platformId = 9
  531. this.form.audioType = this.audioOptions[0].value
  532. } else {
  533. this.form.audioType = this.list[index].forwardType ? this.typeOptions.find(i => i.value === this.list[index].forwardType).type : 2
  534. this.disabled = this.tabIndex == 2 && this.active === 1 || this.list[index].forwardType !== null ? true : false
  535. }
  536. this.getContentList()
  537. },
  538. // 搜索
  539. getSearch() {
  540. this.form.pageNum = 1
  541. this.getContentList()
  542. },
  543. // 内容列表
  544. getContentList() {
  545. this.loading = true
  546. radioList(this.form).then(res => {
  547. if (res.code === 0) {
  548. this.tableData = res.data.records
  549. this.total = res.data.total
  550. if (this.list[this.index].childList && this.list[this.index].childList.length > 0) {
  551. this.list[this.index].childList.map(i => {
  552. let row = res.data.records.find(j => j.audioId === i.contentId)
  553. if (row) {
  554. this.$refs.tableData.toggleRowSelection(row, true)
  555. }
  556. })
  557. }
  558. this.loading = false
  559. }
  560. })
  561. },
  562. // 选择某一个音频内容
  563. getSelect(row) {
  564. let e = this.list[this.index]
  565. e.contentId = row.audioId
  566. e.contentName = row.audioName
  567. e.pic = row.audioPic
  568. e.platformId = row.platformId
  569. e.contentType = row.audioType
  570. e.description = row.description
  571. this.dialogVisible = false
  572. this.$message.success('选择成功!')
  573. },
  574. rowKey(row) {
  575. return row.audioId
  576. },
  577. // 批量选择
  578. handleSelectionChange(row) {
  579. if (row.length > 0) {
  580. row.map(i => {
  581. if (this.list[this.index].childList.findIndex(j => j.contentId === i.audioId) === -1) {
  582. this.list[this.index].childList.push({
  583. contentId: i.audioId,
  584. contentName: i.audioName,
  585. platformId: i.platformId,
  586. contentType: i.audioType,
  587. pic: i.audioPic,
  588. description: i.description,
  589. status: i.status
  590. })
  591. }
  592. })
  593. }
  594. },
  595. // 删除已添加的内容
  596. getDelete(row, index) {
  597. let e = this.list[index].childList.findIndex(i => i.contentId === row.contentId)
  598. this.list[index].childList.splice(e, 1)
  599. },
  600. // 上传图片
  601. getUpload(e, index) {
  602. this.list[index].pic = e.file
  603. },
  604. // 清空
  605. getEmpty(item) {
  606. Object.keys(item).map(key => {
  607. if (!['id', 'moduleId', 'sort', 'status'].includes(key)) {
  608. item[key] = key === 'childList' ? [] : ''
  609. }
  610. })
  611. },
  612. // 上下架内容模块
  613. handleChange(item, status) {
  614. let tips = status === 0 ? '上架' : '下架'
  615. this.$confirm(`是否要${tips}?`, '提醒', {
  616. type: 'warning'
  617. }).then(() => {
  618. upOrDown(item.id, status).then(res => {
  619. if (res.code === 0) {
  620. this.$message.success(`${tips}成功!`)
  621. this.getContentDetail(item.moduleId)
  622. }
  623. })
  624. }).catch(() => { })
  625. },
  626. // 删除内容模块
  627. getRemoveList(item, index) {
  628. if (item.id) {
  629. this.$confirm(`是否要删除${item.title}?`, '提醒', {
  630. type: 'warning'
  631. }).then(() => {
  632. removeList(item.id, 2).then(res => {
  633. if (res.code === 0) {
  634. this.$message.success(`删除成功!`)
  635. this.getContentDetail(item.moduleId)
  636. }
  637. })
  638. }).catch(() => { })
  639. } else {
  640. this.list.splice(index, 1)
  641. }
  642. },
  643. // 提交场景电台时间段
  644. getSubmitTime(item) {
  645. item.startTime = item.date[0]
  646. item.endTime = item.date[1]
  647. delete item.date
  648. submitTime(item).then(res => {
  649. if (res.code === 0) {
  650. this.$message.success('提交成功!')
  651. this.getTimeList()
  652. }
  653. })
  654. },
  655. // 上传icon
  656. uploadIcon(e, index) {
  657. this.timeList[index].pic = e.file
  658. },
  659. // 新增时间段
  660. getAddTime() {
  661. this.timeList.push({})
  662. },
  663. // 新增列表
  664. getAdd() {
  665. this.list.push({
  666. moduleId: this.module[this.active].id,
  667. childList: []
  668. })
  669. },
  670. // 上下架 / 删除时间段
  671. getChangeTime(id, status, index) {
  672. if (id) {
  673. let title = status === 0 ? '下架' : status === 1 ? '上架' : '删除'
  674. this.$confirm(`是否${title}?`, '提醒', {
  675. type: 'warning'
  676. }).then(() => {
  677. changeTime(id, status).then(res => {
  678. if (res.code === 0) {
  679. this.$message.success(`${title}成功!`)
  680. this.getTimeList()
  681. }
  682. })
  683. })
  684. } else {
  685. this.timeList.splice(index, 1)
  686. }
  687. },
  688. // 监听模式模块
  689. getModel(item) {
  690. item.isCustom = item.model === 0 ? 1 : 0
  691. },
  692. // 字典翻译
  693. audioFormatter(row) {
  694. return this.selectDictLabel(this.audioOptions, row.audioType)
  695. },
  696. freeFormatter(row) {
  697. return this.selectDictLabel(this.freeOptions, row.isFree)
  698. },
  699. statusFormatter(row) {
  700. return row.status === 0 ? '上架' : '下架'
  701. },
  702. // v-if判断
  703. // 标题模块
  704. content() {
  705. let rules = {
  706. '1': [3, 4, 5, 6, 7, 8, 12].includes(this.active),
  707. '2': [1, 3].includes(this.active),
  708. '3': [2, 4, 6, 7, 8, 9].includes(this.active),
  709. '4': [2, 4, 6, 8, 9, 10, 11].includes(this.active),
  710. '5': [2, 4, 5, 6, 7].includes(this.active),
  711. '6': [2, 3, 5, 7, 8, 9].includes(this.active),
  712. '7': ![0].includes(this.active)
  713. }
  714. return rules[this.tabIndex]
  715. },
  716. // 标签模块
  717. label() {
  718. let rules = {
  719. '2': this.active === 2,
  720. '3': this.active === 1,
  721. '4': [1, 5].includes(this.active),
  722. '5': [1, 3].includes(this.active),
  723. '6': [1, 4].includes(this.active),
  724. }
  725. return rules[this.tabIndex]
  726. },
  727. // 删除按钮
  728. close() {
  729. let rules = {
  730. '1': [1].includes(this.active),
  731. '2': [0, 1].includes(this.active),
  732. '3': [0].includes(this.active),
  733. '7': ![3].includes(this.active)
  734. }
  735. return rules[this.tabIndex]
  736. },
  737. // 时间
  738. time() {
  739. let rules = {
  740. '1': ![3, 8].includes(this.active),
  741. '2': [0, 3].includes(this.active),
  742. '3': ![1].includes(this.active),
  743. '4': ![1, 5].includes(this.active),
  744. '5': ![1, 3].includes(this.active),
  745. '6': ![1, 4].includes(this.active),
  746. '7': [0, 1, 2, 3, 4].includes(this.active)
  747. }
  748. return rules[this.tabIndex]
  749. },
  750. // 标题
  751. title() {
  752. let rules = {
  753. '1': [10].includes(this.active),
  754. '2': [1].includes(this.active),
  755. '3': [3, 5, 9].includes(this.active),
  756. '4': [7].includes(this.active),
  757. '5': [5].includes(this.active)
  758. }
  759. return rules[this.tabIndex]
  760. },
  761. // 模式
  762. model() {
  763. let rules = {
  764. '1': [4, 5, 7, 9, 11].includes(this.active),
  765. '2': [3].includes(this.active),
  766. '3': [4, 7, 8].includes(this.active),
  767. '4': [2, 4, 6, 8, 9, 10, 11].includes(this.active),
  768. '5': [2, 4, 6, 7].includes(this.active),
  769. '6': [2, 3, 5, 7, 8, 9].includes(this.active),
  770. '7': [4].includes(this.active)
  771. }
  772. return rules[this.tabIndex]
  773. },
  774. // 跳转方式
  775. forwardType() {
  776. let rules = {
  777. '1': [1, 2].includes(this.active),
  778. '2': [0].includes(this.active),
  779. '3': [0].includes(this.active),
  780. '4': [0, 3].includes(this.active),
  781. '5': [0].includes(this.active),
  782. '6': [0].includes(this.active),
  783. '7': [0].includes(this.active)
  784. }
  785. return rules[this.tabIndex]
  786. },
  787. // 内容
  788. contentName(item) {
  789. let rules = {
  790. '1': [0, 6, 8, 10, 12].includes(this.active),
  791. '3': [2, 3, 5, 6, 9].includes(this.active),
  792. '4': [7].includes(this.active),
  793. '5': [5].includes(this.active),
  794. '6': [6].includes(this.active),
  795. '7': ![0, 4].includes(this.active)
  796. }
  797. return rules[this.tabIndex] || [0, 1, 2, 3, 4].includes(item.forwardType) || item.model === 1
  798. },
  799. // 简介
  800. description(item) {
  801. let rules = {
  802. '1': [7, 10].includes(this.active),
  803. '3': [3, 4, 5, 7, 8].includes(this.active),
  804. '4': [7].includes(this.active),
  805. '7': [3].includes(this.active)
  806. }
  807. return rules[this.tabIndex] || item.model === 1
  808. },
  809. // 跳转连接
  810. forwardUrl(item) {
  811. return [5, 6].includes(item.forwardType)
  812. },
  813. // 封面模式
  814. isCustom(item) {
  815. let rules = {
  816. '1': [0, 8].includes(this.active),
  817. '5': [5].includes(this.active)
  818. }
  819. return rules[this.tabIndex] || item.model === 1
  820. },
  821. // 图片
  822. pic(item) {
  823. let rules = {
  824. '1': [1, 2, 6, 8, 10, 12].includes(this.active),
  825. '2': [0, 1].includes(this.active),
  826. '3': [0, 2, 3, 5, 6, 9].includes(this.active),
  827. '4': [0, 3, 7].includes(this.active),
  828. '5': [0, 5].includes(this.active),
  829. '6': [0, 6].includes(this.active),
  830. '7': ![4].includes(this.active)
  831. }
  832. return rules[this.tabIndex] || item.isCustom === 0
  833. },
  834. // 排序
  835. sort() {
  836. let rules = {
  837. '1': [1].includes(this.active),
  838. '2': [0, 1].includes(this.active),
  839. '3': [0].includes(this.active),
  840. '7': ![3].includes(this.active)
  841. }
  842. return rules[this.tabIndex]
  843. },
  844. // 列表
  845. isList() {
  846. return this.tabIndex === 2 && this.active === 1
  847. },
  848. // 新增
  849. add() {
  850. let rules = {
  851. '1': [1].includes(this.active),
  852. '2': [0, 1].includes(this.active),
  853. '3': [0].includes(this.active),
  854. '7': ![3].includes(this.active)
  855. }
  856. return rules[this.tabIndex]
  857. }
  858. }
  859. }
  860. </script>
  861. <style lang="scss" scoped>
  862. .bg {
  863. width: 365px;
  864. .el-image__error,
  865. .el-image__placeholder,
  866. .el-image__inner {
  867. height: auto;
  868. }
  869. }
  870. .item {
  871. position: absolute;
  872. left: 0;
  873. width: 365px;
  874. border: 1px solid yellow;
  875. }
  876. .active {
  877. background: rgba(255, 255, 0, 0.3);
  878. }
  879. .form {
  880. width: calc(100% - 395px);
  881. .el-form {
  882. width: 500px;
  883. margin-left: 30px;
  884. border: 1px solid #dcdfe6;
  885. box-shadow: 5px 5px 5px 0px #dcdfe6;
  886. padding: 20px;
  887. margin-bottom: 20px;
  888. }
  889. }
  890. .label {
  891. display: flex;
  892. flex-wrap: wrap;
  893. .el-form-item {
  894. width: calc(100% / 4);
  895. margin: 0;
  896. text-align: center;
  897. }
  898. }
  899. </style>