|
|
@@ -1,7 +1,8 @@
|
|
|
<template>
|
|
|
<schedule-wrapper
|
|
|
class="c-schedule-swiper"
|
|
|
- v-bind="scheduleOptions"
|
|
|
+ :name="name"
|
|
|
+ :hide-header="hideHeader"
|
|
|
:editable="editable"
|
|
|
:dirty="dirty"
|
|
|
@add="onAdd"
|
|
|
@@ -30,7 +31,7 @@
|
|
|
<i class="l-flex__none c-schedule-swiper__mover el-icon-sort" />
|
|
|
<div
|
|
|
class="l-flex__auto c-schedule-swiper__program u-ellipsis u-pointer"
|
|
|
- @click="toView(program)"
|
|
|
+ @click="onView(program)"
|
|
|
>
|
|
|
{{ program.name }}
|
|
|
</div>
|
|
|
@@ -45,15 +46,10 @@
|
|
|
:step="1"
|
|
|
step-strictly
|
|
|
/>
|
|
|
- <el-tooltip
|
|
|
- content="删除"
|
|
|
- :hide-after="2000"
|
|
|
- >
|
|
|
- <i
|
|
|
- class="l-flex__none c-schedule-swiper__del o-icon--active el-icon-delete u-pointer"
|
|
|
- @click="toDel(program, index)"
|
|
|
- />
|
|
|
- </el-tooltip>
|
|
|
+ <i
|
|
|
+ class="l-flex__none c-schedule-swiper__del o-icon--active el-icon-delete u-pointer"
|
|
|
+ @click="onDel(program, index)"
|
|
|
+ />
|
|
|
</div>
|
|
|
</draggable>
|
|
|
<el-dialog
|
|
|
@@ -75,7 +71,7 @@
|
|
|
v-for="program in events"
|
|
|
:key="program.key"
|
|
|
class="l-flex--row c-schedule-swiper__item readonly u-pointer"
|
|
|
- @click="toView(program)"
|
|
|
+ @click="onView(program)"
|
|
|
>
|
|
|
<div class="c-schedule-swiper__program u-ellipsis">
|
|
|
{{ program.name }}
|
|
|
@@ -112,13 +108,14 @@ export default {
|
|
|
return this.events.length < 2
|
|
|
},
|
|
|
dirty () {
|
|
|
- if (this.record) {
|
|
|
+ if (this.editable && this.record) {
|
|
|
const { events, count } = this.record
|
|
|
- if (count !== this.events.length) {
|
|
|
+ const currEvents = this.events
|
|
|
+ if (count !== currEvents.length) {
|
|
|
return true
|
|
|
}
|
|
|
for (let i = 0; i < events.length; i++) {
|
|
|
- if (events[i].id !== this.events[i].id || events[i].duration !== this.events[i].duration) {
|
|
|
+ if (events[i].id !== currEvents[i].id || events[i].duration !== currEvents[i].duration) {
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
@@ -127,17 +124,6 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- init () {
|
|
|
- this.record = {
|
|
|
- events: this.events.map(({ id, duration }) => {
|
|
|
- return { id, duration }
|
|
|
- }),
|
|
|
- count: this.events.length
|
|
|
- }
|
|
|
- },
|
|
|
- onSave () {
|
|
|
- this.save().then(this.init)
|
|
|
- },
|
|
|
_transformEvents (events) {
|
|
|
return events.sort((a, b) => a.index - b.index)
|
|
|
},
|
|
|
@@ -148,10 +134,22 @@ export default {
|
|
|
id: programId,
|
|
|
name: programName,
|
|
|
url: programUrl,
|
|
|
- duration: this._transformDuration(spend)
|
|
|
+ duration: this.transformDuration(spend)
|
|
|
}
|
|
|
},
|
|
|
- _transformDuration (duration) {
|
|
|
+ _getEvents () {
|
|
|
+ return this.events.map(({ id, name, url, duration }, index) => {
|
|
|
+ return {
|
|
|
+ index,
|
|
|
+ freq: 'SECONDLY',
|
|
|
+ spend: duration,
|
|
|
+ programId: id,
|
|
|
+ programName: name,
|
|
|
+ programUrl: url
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ transformDuration (duration) {
|
|
|
if (this.editable) {
|
|
|
return duration
|
|
|
}
|
|
|
@@ -175,17 +173,16 @@ export default {
|
|
|
}
|
|
|
return s
|
|
|
},
|
|
|
- _getEvents () {
|
|
|
- return this.events.map(({ id, name, url, duration }, index) => {
|
|
|
- return {
|
|
|
- index,
|
|
|
- freq: 'SECONDLY',
|
|
|
- spend: duration,
|
|
|
- programId: id,
|
|
|
- programName: name,
|
|
|
- programUrl: url
|
|
|
- }
|
|
|
- })
|
|
|
+ init () {
|
|
|
+ this.record = {
|
|
|
+ events: this.events.map(({ id, duration }) => {
|
|
|
+ return { id, duration }
|
|
|
+ }),
|
|
|
+ count: this.events.length
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onSave () {
|
|
|
+ this.save().then(this.init)
|
|
|
},
|
|
|
onAdd () {
|
|
|
this.choosing = true
|
|
|
@@ -199,13 +196,13 @@ export default {
|
|
|
duration: duration || 60
|
|
|
})
|
|
|
},
|
|
|
- toView ({ id }) {
|
|
|
+ onView ({ id }) {
|
|
|
window.open(this.$router.resolve({
|
|
|
name: 'view',
|
|
|
params: { id }
|
|
|
}).href, '_blank')
|
|
|
},
|
|
|
- toDel ({ name }, index) {
|
|
|
+ onDel ({ name }, index) {
|
|
|
this.$confirm(
|
|
|
`确定移除节目 ${name}?`,
|
|
|
{ type: 'warning' }
|
|
|
@@ -279,7 +276,6 @@ export default {
|
|
|
&__del {
|
|
|
padding: 10px 16px;
|
|
|
margin-left: 6px;
|
|
|
- color: #606266;
|
|
|
font-size: 18px;
|
|
|
}
|
|
|
}
|