DeviceAdDialog.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <confirm-dialog
  3. ref="dialog"
  4. size="lg fixed"
  5. title="设备广告播放"
  6. @confirm="onConfirm"
  7. >
  8. <template #default>
  9. <div class="l-flex__fill l-flex">
  10. <device-tree-single
  11. class="c-sibling-item c-sidebar u-font-size--sm u-width--xl"
  12. @change="onDeviceChange"
  13. />
  14. <div class="c-sibling-item far">
  15. <div class="c-sibling-item--v u-required">日期</div>
  16. <el-date-picker
  17. v-model="date"
  18. class="c-sibling-item--v"
  19. type="date"
  20. value-format="yyyy-MM-dd"
  21. :picker-options="pickerOptions"
  22. :editable="false"
  23. :clearable="false"
  24. />
  25. </div>
  26. </div>
  27. </template>
  28. </confirm-dialog>
  29. </template>
  30. <script>
  31. import { parseTime } from '@/utils'
  32. import { getDeviceAdExcel } from '../api'
  33. export default {
  34. name: 'DeviceAdDialog',
  35. data () {
  36. return {
  37. date: null
  38. }
  39. },
  40. computed: {
  41. pickerOptions () {
  42. return {
  43. disabledDate: this.isDisableDate
  44. }
  45. }
  46. },
  47. methods: {
  48. show () {
  49. this.$device = null
  50. this.date = parseTime(new Date(), '{y}-{m}-{d}')
  51. this.$refs.dialog.show()
  52. },
  53. onDeviceChange (device) {
  54. this.$device = device
  55. },
  56. isDisableDate (date) {
  57. return date > Date.now()
  58. },
  59. onConfirm (done) {
  60. if (!this.$device) {
  61. this.$message({
  62. type: 'warning',
  63. message: '请选择设备'
  64. })
  65. return
  66. }
  67. getDeviceAdExcel({
  68. deviceId: this.$device.id,
  69. date: this.date
  70. }, `${this.$device.name}_${this.date}`).then(done)
  71. }
  72. }
  73. }
  74. </script>