index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <p>{{ props.value === null || props.value === 0 ? '--' : props.value }}</p>
  3. <el-popover
  4. effect="dark"
  5. :width="260">
  6. <template #reference>
  7. <p :class="colorClass" v-show="props.showCompare">
  8. <template v-if="props.gapVal">
  9. <el-icon style="display: inline-block; padding-top: 2px">
  10. <Top v-if="props.gapVal > 0"/>
  11. <Bottom v-if="props.gapVal < 0"/>
  12. </el-icon>
  13. </template>
  14. <span>{{ props.gapVal ? props.gapVal.toFixed(2) + '%' : '--'}}</span>
  15. </p>
  16. </template>
  17. <p>对比周期:{{ compareDate[0] }} ~ {{ compareDate[1] }}</p>
  18. <p>对比值:{{ props.prevVal }}</p>
  19. </el-popover>
  20. </template>
  21. <script lang="ts" setup>
  22. import { ref, computed, Prop } from 'vue'
  23. import { getCompareDate } from '/@/views/adManage/utils/tools.js'
  24. interface Props {
  25. field: string,
  26. value: number,
  27. prevVal: number,
  28. gapVal: number,
  29. dateRange: string[],
  30. showCompare: boolean
  31. }
  32. const props = defineProps<Props>()
  33. const compareDate = computed(() => {
  34. return getCompareDate(props.dateRange)
  35. })
  36. const colorClass = computed(() => {
  37. if (props.gapVal) {
  38. return props.gapVal > 0 ? 'green' :'red'
  39. }
  40. return ''
  41. })
  42. </script>
  43. <style scoped>
  44. .green {
  45. color: rgb(24, 172, 54)
  46. }
  47. .red {
  48. color: red;
  49. }
  50. </style>