ScreenOnlineDialog.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <confirm-dialog
  3. ref="dialog"
  4. size="lg fixed"
  5. title="大屏上下线记录"
  6. confirm-text="下载"
  7. @confirm="onConfirm"
  8. >
  9. <template #default>
  10. <div class="l-flex__fill l-flex">
  11. <device-tree
  12. class="c-sibling-item c-sidebar u-width--xl"
  13. checkbox
  14. @change="onChange"
  15. />
  16. <div class="c-sibling-item far">
  17. <div class="c-sibling-item--v u-required">
  18. 日期范围
  19. </div>
  20. <el-date-picker
  21. v-model="dateRange"
  22. class="c-sibling-item--v"
  23. type="daterange"
  24. value-format="yyyy-MM-dd"
  25. range-separator="至"
  26. :picker-options="pickerOptions"
  27. :editable="false"
  28. :clearable="false"
  29. />
  30. </div>
  31. </div>
  32. </template>
  33. </confirm-dialog>
  34. </template>
  35. <script>
  36. import { parseTime } from '@/utils'
  37. import { getScreenOnlineExcel } from '../api.js'
  38. export default {
  39. name: 'ScreenOnlineDialog',
  40. data () {
  41. return {
  42. dateRange: null,
  43. devices: []
  44. }
  45. },
  46. computed: {
  47. pickerOptions () {
  48. return {
  49. disabledDate: date => date > Date.now()
  50. }
  51. }
  52. },
  53. methods: {
  54. show () {
  55. this.devices = null
  56. const date = parseTime(new Date(), '{y}-{m}-{d}')
  57. this.dateRange = [date, date]
  58. this.$refs.dialog.show()
  59. },
  60. onChange (devices) {
  61. this.devices = devices.map(device => device.id)
  62. },
  63. onConfirm (done) {
  64. if (!this.devices || !this.devices.length) {
  65. this.$message({
  66. type: 'warning',
  67. message: '请选择设备'
  68. })
  69. return
  70. }
  71. getScreenOnlineExcel({
  72. deviceIdList: this.devices,
  73. startDate: this.dateRange[0],
  74. endDate: this.dateRange[1]
  75. }).then(done)
  76. }
  77. }
  78. }
  79. </script>