index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="o-draggable-item">
  3. <div class="l-flex__fill l-flex--row c-sibling-item mover">
  4. <i class="l-flex__none o-draggable-item__mover el-icon-sort u-color--info u-font-size--md has-active" />
  5. <auto-text
  6. class="l-flex__auto has-active"
  7. :text="label"
  8. @click.native="onView"
  9. />
  10. </div>
  11. <div
  12. v-if="item.disabled"
  13. class="l-flex__none c-sibling-item near u-color--info u-font-size--xs"
  14. >
  15. {{ duration }}
  16. </div>
  17. <el-input-number
  18. v-else
  19. v-model="item.duration"
  20. class="l-flex__none c-sibling-item near o-draggable-item__seconds"
  21. size="small"
  22. title="上播时长(s)"
  23. :disabled="item.disabled"
  24. controls-position="right"
  25. :min="1"
  26. :max="86400"
  27. step-strictly
  28. />
  29. <i
  30. class="l-flex__none el-icon-delete has-padding--h u-color--info u-font-size--md has-active"
  31. @click="onDel"
  32. />
  33. </div>
  34. </template>
  35. <script>
  36. import { parseDuration } from '@/utils'
  37. export default {
  38. name: 'DraggableItem',
  39. props: {
  40. item: {
  41. type: Object,
  42. required: true
  43. }
  44. },
  45. computed: {
  46. label () {
  47. const { info, name } = this.item
  48. return info ? `${info} ${name}` : name
  49. },
  50. duration () {
  51. return parseDuration(this.item.duration)
  52. }
  53. },
  54. methods: {
  55. onView () {
  56. this.$emit('view', this.item)
  57. },
  58. onDel () {
  59. this.$emit('del', this.item)
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .o-draggable-item {
  66. &__seconds {
  67. width: 92px;
  68. }
  69. ::v-deep {
  70. .el-input-number.is-controls-right .el-input__inner {
  71. padding-left: 4px;
  72. padding-right: 36px;
  73. }
  74. }
  75. }
  76. </style>