index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div v-if="refresh">
  3. <component :is="chartType.component" :width="width" :height="height"></component>
  4. </div>
  5. </template>
  6. <script>
  7. import { customPage } from "../../mixins";
  8. export default {
  9. mixins: [customPage],
  10. props: {
  11. width: {
  12. type: String,
  13. default: '100%'
  14. },
  15. height: {
  16. type: String,
  17. default: '500px'
  18. },
  19. form: Object
  20. },
  21. data() {
  22. return {
  23. refresh: false,
  24. chartType: {},
  25. }
  26. },
  27. mounted() {
  28. this.refreshChart()
  29. },
  30. methods: {
  31. initData() {
  32. if (!this.form.setting.type) {
  33. return false
  34. }
  35. this.chartType = this.$constants.chartType.find(item => item.value === this.form.setting.type)
  36. if (this.chartType.type === 1 && this.form.schema.y.field) {
  37. return false
  38. }
  39. this.$store.commit('SET_MY_CHART', null)
  40. return true
  41. },
  42. refreshChart() {
  43. this.refresh = false
  44. const ret = this.initData()
  45. this.$nextTick(() => {
  46. this.refresh = ret
  47. })
  48. },
  49. }
  50. }
  51. </script>
  52. <style lang="less">
  53. </style>