index.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div class="layout-padding">
  3. <div class="engagement-time">
  4. <el-row :gutter="12" style="padding: 0 12px 12px; row-gap: 12px;">
  5. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  6. <SelectForm :type="type" :form="form" :title="'使用间隔'" />
  7. </el-col>
  8. </el-row>
  9. <el-row :gutter="12" style="padding: 0 12px 12px; row-gap: 12px;">
  10. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  11. <Interval :type="type" :form="form" ref="intervalRef" />
  12. </el-col>
  13. </el-row>
  14. </div>
  15. </div>
  16. </template>
  17. <script lang="ts" name="engagementTime" setup>
  18. import { reactive } from 'vue'
  19. import Interval from './Interval.vue';
  20. import SelectForm from '../components/SelectForm.vue';
  21. import { formatDate } from '/@/utils/formatTime';
  22. const type = ref('daterange');
  23. const form = reactive({
  24. dateArray: [new Date().getTime() - 1000 * 60 * 60 * 24 * 7, new Date().getTime()],
  25. date: new Date().getTime(),
  26. selectedDates: [] as string[], // 存储多个选中的日期
  27. timeCompare: 'time1',
  28. channel: 'all',
  29. version: 'all'
  30. })
  31. const intervalRef = ref<InstanceType<typeof Interval>>();
  32. watch(form, (newVal) => {
  33. console.log([`${formatDate(new Date(newVal.dateArray[0]), 'YYYY-mm-dd')} - ${formatDate(new Date(newVal.dateArray[1]), 'YYYY-mm-dd')}`]);
  34. nextTick(() => {
  35. intervalRef.value?.handleDateChange([`${formatDate(new Date(newVal.dateArray[0]), 'YYYY-mm-dd')} - ${formatDate(new Date(newVal.dateArray[1]), 'YYYY-mm-dd')}`]);
  36. })
  37. }, { deep: true, immediate: true })
  38. onMounted(() => {
  39. nextTick(() => {
  40. intervalRef.value?.handleDateChange([`${formatDate(new Date(form.dateArray[0]), 'YYYY-mm-dd')} - ${formatDate(new Date(form.dateArray[1]), 'YYYY-mm-dd')}`]);
  41. })
  42. })
  43. </script>
  44. <style scoped lang="scss">
  45. @import '/@/views/count/styles/common.scss';
  46. svg {
  47. vertical-align: middle;
  48. margin: 0 0 0 12px;
  49. }
  50. .engagement-time {
  51. .select-form {
  52. margin-top: 20px;
  53. form {
  54. // height: 30px;
  55. }
  56. .el-form-item__content {
  57. .el-select {
  58. width: 147px !important;
  59. min-width: 147px !important;
  60. }
  61. }
  62. }
  63. }
  64. </style>