index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. <template>
  2. <wrapper
  3. class="c-step"
  4. fill
  5. margin
  6. padding
  7. background
  8. >
  9. <div class="l-flex__none l-flex--row c-step__header">
  10. <button
  11. class="l-flex__none c-sibling-item o-button"
  12. @click="onPresent"
  13. >
  14. 导入历史编单
  15. </button>
  16. <div class="l-flex__fill u-text--center">
  17. 请选择需要上播的设备并配置相关上播内容
  18. </div>
  19. <button
  20. class="l-flex__none c-sibling-item o-button"
  21. @click="onNext"
  22. >
  23. 发布
  24. </button>
  25. </div>
  26. <div class="l-flex__fill l-flex">
  27. <device-tree
  28. ref="tree"
  29. class="c-sibling-item c-step__column u-width--md"
  30. exact
  31. checkbox
  32. check-on-click-node
  33. @change="onChange"
  34. />
  35. <div
  36. class="l-flex__none l-flex--col c-step__column"
  37. style="width: 360px"
  38. >
  39. <div class="c-sibling-item--v near u-font-size--sm u-bold">
  40. 上播类型
  41. </div>
  42. <el-select
  43. v-model="eventType"
  44. class="c-sibling-item--v nearer u-width--sm"
  45. size="small"
  46. >
  47. <el-option
  48. v-for="option in eventTypeOptions"
  49. :key="option.value"
  50. :label="option.label"
  51. :value="option.value"
  52. />
  53. </el-select>
  54. <template v-if="isNormal">
  55. <div class="c-sibling-item--v near u-font-size--sm">
  56. 优先级
  57. </div>
  58. <el-select
  59. v-model="priority"
  60. class="c-sibling-item--v nearer u-width--sm"
  61. size="small"
  62. >
  63. <el-option
  64. v-for="option in priorityOptions"
  65. :key="option.value"
  66. :label="option.label"
  67. :value="option.value"
  68. />
  69. </el-select>
  70. <div class="l-flex--row c-sibling-item--v near">
  71. <div
  72. class="l-flex__none l-flex--row inline c-sibling-item u-font-size--sm has-active"
  73. @click="onAddEvent"
  74. >
  75. <span class="c-sibling-item">
  76. 播放时段
  77. </span>
  78. <i class="c-sibling-item near el-icon-circle-plus-outline" />
  79. </div>
  80. </div>
  81. <schema-table
  82. ref="timeTable"
  83. class="c-sibling-item--v nearer"
  84. :schema="timeSchema"
  85. />
  86. </template>
  87. <template v-if="isIntercut">
  88. <div class="c-sibling-item--v near u-font-size--sm u-required">
  89. 下架日期
  90. <span class="u-color--info u-font-size--xs">
  91. 下架当日插播依然生效
  92. </span>
  93. </div>
  94. <el-date-picker
  95. v-model="intercutFinishDate"
  96. class="c-sibling-item--v nearer u-width--sm"
  97. value-format="yyyy-MM-dd"
  98. placeholder="选择日期"
  99. :clearable="false"
  100. :picker-options="pickerOptions"
  101. />
  102. </template>
  103. </div>
  104. <event-target-picker
  105. ref="eventTargetPicker"
  106. class="l-flex__fill c-step__column"
  107. :event-target="eventTarget"
  108. :only-assets="isIntercut"
  109. />
  110. </div>
  111. <radio-table-dialog
  112. ref="workflowTableDialog"
  113. title="历史编单"
  114. size="lg"
  115. :schema="workflowSchema"
  116. @confirm="onChooseWorkflow"
  117. />
  118. <workflow-dialog ref="workflowDialog" />
  119. <intercut-workflow-dialog ref="intercutWorkflowDialog" />
  120. <event-frequency-config-dialog
  121. ref="eventFrequencyConfigDialog"
  122. @confirm="onConfirmEventFrequency"
  123. />
  124. <confirm-dialog
  125. ref="selfConflictDialog"
  126. title="冲突提醒"
  127. cancel-text="重新编辑"
  128. confirm-text="覆盖"
  129. append-to-body
  130. @confirm="onCover"
  131. >
  132. <div
  133. v-for="conflict in selfConflicts"
  134. :key="conflict.key"
  135. >
  136. {{ conflict.info }}
  137. </div>
  138. </confirm-dialog>
  139. <c-dialog
  140. ref="priorityConflictDialog"
  141. title="冲突数据"
  142. size="medium"
  143. append-to-body
  144. >
  145. <div class="c-sibling-item--v u-color--error">
  146. 以下设备将与新发布的时段存在冲突
  147. </div>
  148. <schema-table
  149. class="c-sibling-item--v nearer sm"
  150. :schema="priorityConflictSchema"
  151. />
  152. </c-dialog>
  153. <confirm-dialog
  154. ref="conflictDialog"
  155. title="冲突数据提醒"
  156. size="medium"
  157. cancel-text="重新编辑"
  158. confirm-text="覆盖"
  159. append-to-body
  160. @confirm="onCoverConfilcts"
  161. >
  162. <schema-table :schema="conflictSchema" />
  163. </confirm-dialog>
  164. </wrapper>
  165. </template>
  166. <script>
  167. import {
  168. ONE_DAY,
  169. State,
  170. EventTarget,
  171. WorkflowType,
  172. PublishType,
  173. PublishTargetType,
  174. EventFrequency,
  175. PlayPriority,
  176. PlayPriorityInfo
  177. } from '@/constant.js'
  178. import {
  179. toDateStr,
  180. getConflict,
  181. getEventDescription
  182. } from '@/utils/event.js'
  183. import {
  184. publish,
  185. getPublishConflicts,
  186. publishIntercut
  187. } from '@/api/platform.js'
  188. import {
  189. getWorkflowsByUser,
  190. getWorkflowsBySuperAdmin,
  191. getWorkflowDetail
  192. } from '@/api/workflow.js'
  193. import EventFrequencyConfigDialog from '../components/EventFrequencyConfigDialog.vue'
  194. import WorkflowDialog from '../workflow/components/WorkflowDialog.vue'
  195. import IntercutWorkflowDialog from '../workflow/components/IntercutWorkflowDialog.vue'
  196. import PriorityChecking from './components/PriorityChecking.vue'
  197. const PublishDataType = {
  198. NORMAL: 'NORMAL',
  199. DEFAULT_PLAYBACK: 'DEFAULT_PLAYBACK',
  200. INTERCUT: 'INTERCUT'
  201. }
  202. export default {
  203. name: 'DeployDevice',
  204. components: {
  205. EventFrequencyConfigDialog,
  206. WorkflowDialog,
  207. IntercutWorkflowDialog
  208. },
  209. data () {
  210. return {
  211. selectedDevices: [],
  212. eventType: PublishDataType.NORMAL,
  213. eventTypeOptions: [
  214. { value: PublishDataType.NORMAL, label: '常规' },
  215. { value: PublishDataType.INTERCUT, label: '资源插播' },
  216. { value: PublishDataType.DEFAULT_PLAYBACK, label: '默认播放' }
  217. ],
  218. priority: PlayPriority.FIRST,
  219. priorityOptions: [
  220. {
  221. value: PlayPriority.FIRST,
  222. label: PlayPriorityInfo[PlayPriority.FIRST]
  223. },
  224. {
  225. value: PlayPriority.SECOND,
  226. label: PlayPriorityInfo[PlayPriority.SECOND]
  227. },
  228. {
  229. value: PlayPriority.THIRD,
  230. label: PlayPriorityInfo[PlayPriority.THIRD]
  231. },
  232. {
  233. value: PlayPriority.FOURTH,
  234. label: PlayPriorityInfo[PlayPriority.FOURTH]
  235. },
  236. {
  237. value: PlayPriority.FIFTH,
  238. label: PlayPriorityInfo[PlayPriority.FIFTH]
  239. }
  240. ],
  241. intercutFinishDate: null,
  242. timeSchema: {
  243. nonPagination: true,
  244. props: {
  245. size: 'small',
  246. 'row-key': 'key'
  247. },
  248. list: this.getEvents,
  249. cols: [
  250. {
  251. label: '在播',
  252. render: ({ origin }, h) => h(PriorityChecking, {
  253. props: {
  254. deviceIds: this.selectedDeviceIds,
  255. priority: this.priority,
  256. event: origin
  257. },
  258. on: {
  259. click: this.onViewPriorityConflicts
  260. }
  261. }),
  262. width: 84,
  263. align: 'center'
  264. },
  265. { prop: 'time', label: '生效时间', 'show-overflow-tip': false },
  266. {
  267. type: 'invoke',
  268. render: [{ label: '移除', on: this.removeEventProxy }],
  269. width: 52
  270. }
  271. ]
  272. },
  273. priorityConflicts: [],
  274. priorityConflictSchema: {
  275. list: this.getPriorityConflicts,
  276. props: {
  277. size: 'small'
  278. },
  279. cols: [
  280. { prop: 'deviceName', label: '设备名称' },
  281. { prop: 'name', label: '上播内容' },
  282. { prop: 'priority', label: '优先级', render: row => PlayPriorityInfo[row.priority], size: 'sm', width: 84, align: 'center' },
  283. { prop: 'start', label: '开始时间', width: 140, align: 'center' },
  284. { prop: 'until', label: '结束时间', width: 140, align: 'center' }
  285. ]
  286. },
  287. conflicts: [],
  288. conflictSchema: {
  289. list: this.getConflicts,
  290. props: {
  291. size: 'small'
  292. },
  293. cols: [
  294. { prop: 'deviceName', label: '设备名称' },
  295. { prop: 'name', label: '上播内容' },
  296. { prop: 'priority', label: '优先级', render: row => PlayPriorityInfo[row.priority], size: 'sm', width: 84, align: 'center' },
  297. { prop: 'start', label: '开始时间', width: 140, align: 'center' },
  298. { prop: 'until', label: '结束时间', width: 140, align: 'center' }
  299. ]
  300. },
  301. events: [],
  302. selfConflicts: [],
  303. eventTarget: this.createEventTarget(),
  304. workflowSchema: {
  305. props: {
  306. size: 'small'
  307. },
  308. list: this.$store.getters.isSuperAdmin ? getWorkflowsBySuperAdmin : getWorkflowsByUser,
  309. filters: [
  310. { key: 'status', type: 'select', placeholder: '流程状态', options: [
  311. { value: State.SUBMITTED, label: '待审核' },
  312. { value: State.RESOLVED, label: '通过' },
  313. { value: State.REJECTED, label: '驳回' }
  314. ] },
  315. { key: 'flowName', type: 'search', placeholder: '上播内容' },
  316. { type: 'refresh' }
  317. ],
  318. cols: [
  319. { prop: 'flowDesc', label: '优先级', width: 120, align: 'center' },
  320. { prop: 'flowName', label: '上播内容' },
  321. { label: '状态', type: 'tag', render: ({ status }) => {
  322. return {
  323. type: ['', 'primary', 'success', 'danger'][status],
  324. label: ['', '待审核', '通过', '驳回'][status]
  325. }
  326. } },
  327. this.$store.getters.isSuperAdmin && { prop: 'createUser', label: '提交人', width: 140, align: 'center' },
  328. { prop: 'createTime', label: '提交时间', width: 140, align: 'center' },
  329. { type: 'invoke', render: [
  330. { label: '详情', on: this.onViewWorkflow }
  331. ] }
  332. ]
  333. }
  334. }
  335. },
  336. computed: {
  337. isNormal () {
  338. return this.eventType === PublishDataType.NORMAL
  339. },
  340. isDefaultPlayback () {
  341. return this.eventType === PublishDataType.DEFAULT_PLAYBACK
  342. },
  343. isIntercut () {
  344. return this.eventType === PublishDataType.INTERCUT
  345. },
  346. selectedDeviceIds () {
  347. return this.selectedDevices.map(device => device.id)
  348. },
  349. pickerOptions () {
  350. return {
  351. disabledDate: date => date <= Date.now() - ONE_DAY
  352. }
  353. }
  354. },
  355. methods: {
  356. createEventTarget (options) {
  357. return { type: EventTarget.ASSETS, ...options }
  358. },
  359. onPresent () {
  360. this.$refs.workflowTableDialog.show()
  361. },
  362. onNext () {
  363. const devices = this.selectedDevices
  364. const length = devices.length
  365. if (!length) {
  366. this.$message({
  367. type: 'warning',
  368. message: '请选择目标设备'
  369. })
  370. return
  371. }
  372. switch (this.eventType) {
  373. case PublishDataType.NORMAL:
  374. this.onPublishNormal()
  375. break
  376. case PublishDataType.DEFAULT_PLAYBACK:
  377. this.onPublishDefaultPlayback()
  378. break
  379. case PublishDataType.INTERCUT:
  380. this.onPublishIntercut()
  381. break
  382. default:
  383. break
  384. }
  385. },
  386. onChange (devices) {
  387. this.selectedDevices = Object.freeze(devices)
  388. },
  389. getEvents () {
  390. return Promise.resolve({ data: this.events })
  391. },
  392. getPriorityConflicts () {
  393. return Promise.resolve({ data: this.priorityConflicts })
  394. },
  395. getConflicts () {
  396. return Promise.resolve({ data: this.conflicts })
  397. },
  398. onAddEvent () {
  399. this.$refs.eventFrequencyConfigDialog.show()
  400. },
  401. onConfirmEventFrequency ({ value, done }) {
  402. this.$mergedValue = value
  403. const selfConflicts = new Map()
  404. if (this.events.length) {
  405. this.events.forEach(eventProxy => {
  406. value.forEach(event => {
  407. const date = getConflict(event, eventProxy.origin)
  408. if (date) {
  409. selfConflicts.set(eventProxy.key, {
  410. key: eventProxy.key,
  411. info: `与 ${eventProxy.time} 有冲突`
  412. })
  413. }
  414. })
  415. })
  416. }
  417. if (selfConflicts.size) {
  418. this.selfConflicts = [...selfConflicts.values()]
  419. this.$conflictOptions = { value, done }
  420. this.$refs.selfConflictDialog.show()
  421. return
  422. }
  423. this.onAdded(value, done)
  424. },
  425. onCover (closeCb) {
  426. this.selfConflicts.forEach(this.removeEventProxy)
  427. const { value, done } = this.$conflictOptions
  428. this.$conflictOptions = null
  429. closeCb()
  430. this.onAdded(value, done)
  431. },
  432. getDeviceName (deviceId) {
  433. if (!this._deviceNameCache) {
  434. this._deviceNameCache = {}
  435. }
  436. if (!this._deviceNameCache[deviceId]) {
  437. this._deviceNameCache[deviceId] = this.selectedDevices.find(device => device.id === deviceId)?.name || '-'
  438. }
  439. return this._deviceNameCache[deviceId]
  440. },
  441. onViewPriorityConflicts (conflicts) {
  442. this.priorityConflicts = conflicts.map(item => {
  443. const { deviceId, name, priority, start, until } = item
  444. return {
  445. deviceName: this.getDeviceName(deviceId),
  446. name, priority, start, until
  447. }
  448. })
  449. this.$refs.priorityConflictDialog.show()
  450. },
  451. onAdded (eventList, done) {
  452. this.events = [
  453. ...eventList.map(event => {
  454. return {
  455. key: `${Date.now()}_${Math.random()
  456. .toString(16)
  457. .slice(2)}`,
  458. origin: event,
  459. time: getEventDescription(event)
  460. }
  461. }),
  462. ...this.events
  463. ]
  464. this.$refs.timeTable?.pageTo()
  465. done()
  466. },
  467. removeEventProxy (eventProxy) {
  468. if (eventProxy) {
  469. const { key } = eventProxy
  470. const index = this.events.findIndex(event => event.key === key)
  471. if (~index) {
  472. this.events.splice(index, 1)
  473. return index
  474. }
  475. }
  476. return -1
  477. },
  478. onViewWorkflow ({ id, type }) {
  479. if (type === WorkflowType.INTERCUT) {
  480. this.$refs.intercutWorkflowDialog.show(id)
  481. } else {
  482. this.$refs.workflowDialog.show(id)
  483. }
  484. },
  485. onChooseWorkflow ({ value: { id, type }, done }) {
  486. getWorkflowDetail(id, { loading: true }).then(({ data }) => {
  487. let devices = []
  488. if (type === WorkflowType.INTERCUT) {
  489. this.eventType = PublishDataType.INTERCUT
  490. const today = toDateStr(Date.now())
  491. this.intercutFinishDate = today <= data.endDate
  492. ? data.endDate
  493. : null
  494. this.eventTarget = this.createEventTarget({
  495. name: data.name,
  496. sources: data.deviceCalendarAdditionMediaDtoList.map(media => {
  497. return {
  498. md5: media.md5,
  499. tag: media.tag,
  500. name: media.originalName,
  501. size: media.size,
  502. type: media.type,
  503. keyName: media.keyName,
  504. duration: media.addDuration
  505. }
  506. })
  507. })
  508. devices = data.deviceIdList.map((deviceId, index) => {
  509. return {
  510. deviceId,
  511. deviceName: data.deviceNameList[index]
  512. }
  513. })
  514. } else {
  515. const {
  516. programCalendarName,
  517. calendarReleaseDeviceList,
  518. targetList
  519. } = data
  520. const targets = targetList.map(JSON.parse)
  521. const { detail: { priority, target } } = targets[0]
  522. this.eventType = priority === PlayPriority.FIRST
  523. ? PublishDataType.DEFAULT_PLAYBACK
  524. : PublishDataType.NORMAL
  525. this.priority = priority
  526. this.events = targets.map(
  527. ({ detail: { priority, target, ...event } }) => {
  528. return {
  529. key: `${Date.now()}_${Math.random()
  530. .toString(16)
  531. .slice(2)}`,
  532. origin: event,
  533. time: getEventDescription(event)
  534. }
  535. }
  536. )
  537. this.$refs.timeTable?.pageTo(1)
  538. this.eventTarget = target.type === EventTarget.ASSETS
  539. ? {
  540. name: programCalendarName,
  541. ...this.createEventTarget(target)
  542. }
  543. : this.createEventTarget(target)
  544. devices = calendarReleaseDeviceList
  545. }
  546. const deviceCount = devices.length
  547. const validDevices = devices.filter(({ deviceName }) => !!deviceName)
  548. const validDeviceCount = validDevices.length
  549. const diffDeviceCount = this.$refs.tree.reset(validDevices.map(({ deviceId }) => deviceId))
  550. console.log(
  551. 'deploy import',
  552. diffDeviceCount,
  553. validDeviceCount,
  554. deviceCount
  555. )
  556. if (diffDeviceCount > 0 || validDeviceCount !== deviceCount) {
  557. this.$message({
  558. type: 'warning',
  559. message: '部分设备无操作权限或已移除,请确认设备'
  560. })
  561. }
  562. done()
  563. })
  564. },
  565. getPublishDescription (value = '', warningTip = '') {
  566. return this.$prompt(
  567. `<p>发布后需审核生效,操作完成后请通知相关人员进行审核</p>${warningTip}<br/><p class="u-color--black u-font-size--sm u-bold">编单名称</p>`,
  568. '操作确认',
  569. {
  570. dangerouslyUseHTMLString: true,
  571. closeOnClickModal: false,
  572. inputPlaceholder: '发布内容的简单描述',
  573. inputValue: value,
  574. inputPattern: /^.{1,30}$/,
  575. inputErrorMessage: '请用1~30个字符进行描述',
  576. confirmButtonText: '发布',
  577. cancelButtonText: '取消'
  578. }
  579. )
  580. },
  581. onPublishNormal () {
  582. return this.getNoramlPublishData().then(
  583. ({ publishType, targetList, name, resolutionRatio }) => {
  584. const warningTip = resolutionRatio && (!this.ratio || resolutionRatio !== this.ratio)
  585. ? '<p class="u-color--error">上播内容与设备分辨率不一致,可能无法完全适配</p>'
  586. : ''
  587. return this.getPublishDescription(name, warningTip).then(({ value }) => getPublishConflicts({
  588. deviceIdList: this.selectedDevices.map(device => device.id),
  589. conflictCheckTimeList: targetList.map(({ detail: { freq, start, until, byDay, startTime, endTime } }) => {
  590. return { freq, start, until, byDay, startTime, endTime }
  591. }),
  592. minPriority: this.priority,
  593. maxPriority: this.priority
  594. }).then(({ data }) => {
  595. const publishData = {
  596. publishType,
  597. targetList,
  598. options: {
  599. programCalendarName: value,
  600. resolutionRatio: resolutionRatio || '自适应',
  601. remark: PlayPriorityInfo[this.priority]
  602. }
  603. }
  604. if (data && data.length > 0) {
  605. this._cachePublishData = publishData
  606. this.showConflicts(data)
  607. } else {
  608. this.conflicts = []
  609. this.onSubmitPublish(publishData)
  610. }
  611. }))
  612. }
  613. )
  614. },
  615. showConflicts (data) {
  616. this.conflicts = data.map(item => {
  617. const { deviceId, name, priority, start, until } = item.deviceCalendarRecordCO
  618. return {
  619. deviceName: this.getDeviceName(deviceId),
  620. name, priority, start, until
  621. }
  622. })
  623. this.$refs.conflictDialog.show()
  624. },
  625. onCoverConfilcts (done) {
  626. this.onSubmitPublish(this._cachePublishData).then(done)
  627. },
  628. getNoramlPublishData () {
  629. if (!this.events.length) {
  630. this.$message({
  631. type: 'warning',
  632. message: '请添加上播时段'
  633. })
  634. return Promise.reject('invalid event, no time')
  635. }
  636. const eventTarget = this.$refs.eventTargetPicker.getValue()
  637. if (!eventTarget) {
  638. return Promise.reject('invalid event, no target')
  639. }
  640. const { detail } = this.$refs.eventTargetPicker.getSnapshot()
  641. const type = PublishTargetType.EVENT
  642. const priority = this.priority
  643. return Promise.resolve({
  644. publishType: eventTarget.type === EventTarget.ASSETS
  645. ? PublishType.ASSET_TO_DEVICE
  646. : PublishType.PROGRAM_TO_DEVICE,
  647. targetList: this.events.map(({ origin }) => {
  648. return {
  649. type,
  650. detail: {
  651. priority,
  652. ...origin,
  653. target: eventTarget
  654. }
  655. }
  656. }),
  657. name: detail?.name || '',
  658. resolutionRatio: detail?.resolutionRatio
  659. })
  660. },
  661. onPublishDefaultPlayback () {
  662. return this.getDefaultPlaybackPublishData().then(
  663. ({ publishType, targetList, name, resolutionRatio }) => {
  664. const warningTip = resolutionRatio && (!this.ratio || resolutionRatio !== this.ratio)
  665. ? '<p class="u-color--error">上播内容与设备分辨率不一致,可能无法完全适配</p>'
  666. : ''
  667. return this.getPublishDescription(name, warningTip).then(({ value }) => this.onSubmitPublish({
  668. publishType,
  669. targetList,
  670. options: {
  671. programCalendarName: value,
  672. resolutionRatio: resolutionRatio || '自适应',
  673. remark: PlayPriorityInfo[PlayPriority.FIRST]
  674. }
  675. }))
  676. }
  677. )
  678. },
  679. getDefaultPlaybackPublishData () {
  680. const eventTarget = this.$refs.eventTargetPicker.getValue()
  681. if (!eventTarget) {
  682. return Promise.reject('invalid event, no target')
  683. }
  684. const { detail } = this.$refs.eventTargetPicker.getSnapshot()
  685. return Promise.resolve({
  686. publishType: eventTarget.type === EventTarget.ASSETS
  687. ? PublishType.ASSET_TO_DEVICE
  688. : PublishType.PROGRAM_TO_DEVICE,
  689. targetList: [{
  690. type: PublishTargetType.EVENT,
  691. detail: {
  692. priority: PlayPriority.FIRST,
  693. freq: EventFrequency.ONCE,
  694. start: `${toDateStr(new Date())} 00:00:00`,
  695. target: eventTarget
  696. }
  697. }],
  698. name: detail?.name || '',
  699. resolutionRatio: detail?.resolutionRatio
  700. })
  701. },
  702. onSubmitPublish ({ publishType, targetList, options }) {
  703. return publish(
  704. publishType,
  705. this.selectedDevices.map(device => device.id),
  706. targetList,
  707. options
  708. ).then(() => {
  709. this.$refs.tree.reset()
  710. this.eventTarget = this.createEventTarget()
  711. })
  712. },
  713. onPublishIntercut () {
  714. return this.getIntercutPublishData().then(
  715. ({ name, ...data }) => this.getPublishDescription(name).then(
  716. ({ value }) => publishIntercut({
  717. name: value,
  718. ...data
  719. })
  720. )
  721. ).then(() => {
  722. this.$refs.tree.reset()
  723. this.eventTarget = this.createEventTarget()
  724. })
  725. },
  726. getIntercutPublishData () {
  727. if (!this.intercutFinishDate) {
  728. this.$message({
  729. type: 'warning',
  730. message: '请选择下架日期'
  731. })
  732. return Promise.reject('invalid event, no time')
  733. }
  734. const eventTarget = this.$refs.eventTargetPicker.getValue()
  735. if (!eventTarget) {
  736. return Promise.reject('invalid event, no target')
  737. }
  738. const { detail } = this.$refs.eventTargetPicker.getSnapshot()
  739. return Promise.resolve({
  740. startDate: toDateStr(Date.now()),
  741. endDate: this.intercutFinishDate,
  742. deviceIdList: this.selectedDevices.map(device => device.id),
  743. mediaInfoDtoList: eventTarget.sources.map(item => {
  744. return {
  745. keyName: item.keyName,
  746. duration: item.duration
  747. }
  748. }),
  749. name: detail?.name || ''
  750. })
  751. }
  752. }
  753. }
  754. </script>