ChartWrap.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <script setup>
  2. import { watch, nextTick, ref } from "vue"
  3. import { apiETAChart } from '@/api/etaChart'
  4. import { useChartRender } from '@/hooks/chart/render'
  5. import { useRouter } from "vue-router"
  6. const router = useRouter()
  7. const { options, axisLimitState, chartRender, setLimitData, isUseSelfLimit } = useChartRender()
  8. const props = defineProps({
  9. chartInfoId: {
  10. type: [Number, String],
  11. default: ''
  12. }
  13. })
  14. watch(
  15. () => props.chartInfoId,
  16. (n) => {
  17. if (!n) {
  18. tableData.value = []
  19. intro.value = ''
  20. chartInfo.value = null
  21. return
  22. }
  23. getChartDetail()
  24. }
  25. )
  26. const columns = [
  27. {
  28. colKey: 'EdbName',
  29. title: '指标名称',
  30. align: 'center'
  31. },
  32. {
  33. colKey: 'Frequency',
  34. title: '更新频度',
  35. width: '100',
  36. align: 'center'
  37. },
  38. {
  39. colKey: 'LatestDate',
  40. title: '最新日期',
  41. width: '120',
  42. align: 'center'
  43. },
  44. {
  45. colKey: 'LatestValue',
  46. title: '最新值',
  47. width: '100',
  48. align: 'center'
  49. },
  50. {
  51. colKey: 'SourceName',
  52. title: '数据来源',
  53. width: '150',
  54. align: 'center'
  55. }
  56. ]
  57. const tableData = ref([])
  58. const intro = ref('')
  59. const chartInfo = ref(null)
  60. const calendarType = ref('公历')
  61. async function getChartDetail() {
  62. const res = await apiETAChart.chartDetail({
  63. ChartInfoId: props.chartInfoId,
  64. Calendar: calendarType.value,
  65. })
  66. if (res.Ret === 200) {
  67. tableData.value = res.Data.EdbInfoList || []
  68. intro.value = res.Data.ChartInfo.Description
  69. chartInfo.value = res.Data.ChartInfo
  70. //初始化上下限
  71. isUseSelfLimit.value = true
  72. setLimitData(res.Data)
  73. nextTick(() => {
  74. chartRender({
  75. data: {
  76. ...res.Data,
  77. ChartInfo: {
  78. ...res.Data.ChartInfo,
  79. Calendar: calendarType.value||'公历'
  80. },
  81. },
  82. renderId: 'chart-box',
  83. // lang:currentLang.value,
  84. changeLangIsCheck: false,
  85. showChartTitle: true,
  86. shouldUseSelfLimit:true,
  87. })
  88. })
  89. }
  90. }
  91. // 跳转指标溯源
  92. function handleGoEdbSource(data) {
  93. const href = router.resolve({
  94. path: '/EDBSource',
  95. query: {
  96. code: data.UniqueCode
  97. }
  98. }).href
  99. window.open(href, "_blank")
  100. }
  101. </script>
  102. <template>
  103. <div class="bg-white chart-wrap">
  104. <template v-if="props.chartInfoId">
  105. <div class="chart-render-wrap">
  106. <div class="chart-box" id="chart-box"></div>
  107. <div style="text-align: center">
  108. <!-- 季节图 公历农历切换 -->
  109. <t-radio-group
  110. variant="primary-filled"
  111. v-model="calendarType"
  112. @change="getChartDetail"
  113. v-if="chartInfo?.ChartType === 2"
  114. >
  115. <t-radio-button value="公历">公历</t-radio-button>
  116. <t-radio-button value="农历">农历</t-radio-button>
  117. </t-radio-group>
  118. </div>
  119. <div class="chart-source" v-if="chartInfo">
  120. <span
  121. v-if="
  122. chartInfo.SourcesFrom && JSON.parse(chartInfo.SourcesFrom).isShow
  123. "
  124. :style="`color: ${
  125. JSON.parse(chartInfo.SourcesFrom).color
  126. };fontSize: ${JSON.parse(chartInfo.SourcesFrom).fontSize}px;
  127. `"
  128. >来源:{{ JSON.parse(chartInfo.SourcesFrom).text }}</span
  129. >
  130. </div>
  131. </div>
  132. <div class="table-wrap">
  133. <t-table
  134. row-key="index"
  135. :data="tableData"
  136. :columns="columns"
  137. bordered
  138. hover
  139. max-height="300"
  140. cell-empty-content="-"
  141. resizable
  142. >
  143. <template #SourceName="{ row }">
  144. <span>{{ row.SourceName }}</span>
  145. <!-- 指标溯源 -->
  146. <svg-icon
  147. v-if="row.EdbType === 2"
  148. style="
  149. font-size: 20px;
  150. cursor: pointer;
  151. position: relative;
  152. top: 5px;
  153. color:#0052D9
  154. "
  155. name="edb_source"
  156. @click="handleGoEdbSource(row)"
  157. ></svg-icon>
  158. </template>
  159. </t-table>
  160. </div>
  161. <div class="instructions-wrap" v-if="intro">
  162. <p>逻辑简述:</p>
  163. <p>{{ intro }}</p>
  164. </div>
  165. </template>
  166. </div>
  167. </template>
  168. <style lang="scss" scoped>
  169. .chart-wrap {
  170. flex: 1;
  171. min-width: 600px;
  172. border: 1px solid #dcdfe6;
  173. padding: 30px;
  174. .chart-render-wrap {
  175. margin-bottom: 20px;
  176. .chart-box {
  177. height: 600px;
  178. }
  179. }
  180. .instructions-wrap {
  181. margin-top: 20px;
  182. line-height: 1.7;
  183. }
  184. }
  185. </style>