index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div v-if="refresh">
  3. <component :is="chartType.component" :myId="myId" :formData="formData" :formCount="formCount" :selectedData="selectedData" :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. },
  20. data() {
  21. return {
  22. refresh: false,
  23. chartType: {},
  24. }
  25. },
  26. mounted() {
  27. this.refreshChart()
  28. },
  29. methods: {
  30. initData() {
  31. if (!this.form.setting.type) {
  32. return false
  33. }
  34. this.chartType = this.$constants.chartType.find(item => item.value === this.form.setting.type)
  35. if (this.chartType.type === 1 && this.form.schema.y.field) {
  36. return false
  37. }
  38. this.$store.commit('SET_MY_CHART', null)
  39. return true
  40. },
  41. refreshChart() {
  42. this.refresh = false
  43. const ret = this.initData()
  44. this.$nextTick(() => {
  45. this.refresh = ret
  46. })
  47. },
  48. }
  49. }
  50. </script>
  51. <style lang="less">
  52. </style>