healthDrank.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <script setup lang="ts">
  2. defineOptions({
  3. name: "headDrank"
  4. });
  5. import { ref, reactive, nextTick } from "vue";
  6. import { useRouter } from "vue-router";
  7. import radar from "@/components/echarts/radar.vue";
  8. import barEcharts from "@/components/echarts/bar.vue";
  9. import rankTable from "@/components/rankTable/draw.vue";
  10. import personList from "@/components/personList/index.vue";
  11. import qvanping from "@/assets/rank/qvanping@2x.png";
  12. import seachData from "./componements/seach.vue";
  13. import {
  14. getPersonDimensionChartsList,
  15. getPersonDimensionChartsRanking,
  16. getChartsList
  17. } from "@/api/draw";
  18. import type { TabsPaneContext } from "element-plus";
  19. const router = useRouter();
  20. const value = ref("");
  21. const radarRef = ref();
  22. const rankTableRef = ref();
  23. const activeName = ref("1");
  24. const barEchartsRef = ref();
  25. const barDimEchartsRef = ref();
  26. const seachParams = ref();
  27. // 排行榜
  28. const showLength = ref(0);
  29. const chartList = ref([]);
  30. const getChartsListApi = async () => {
  31. const { code, data } = await getChartsList({
  32. ...seachParams.value,
  33. type: 2
  34. });
  35. if (code == 200) {
  36. showLength.value = data.length;
  37. setTimeout(() => {
  38. nextTick(() => {
  39. if (rankTableRef.value) {
  40. rankTableRef.value.init(data, "医疗组");
  41. }
  42. });
  43. }, 500);
  44. }
  45. };
  46. // 雷达图
  47. const dataList = reactive({
  48. dimName: []
  49. });
  50. const getPersonDimensionChartsListApiDimList = async () => {
  51. const { code, data } = await getPersonDimensionChartsList({
  52. ...seachParams.value,
  53. type: 2
  54. });
  55. if (code == 200) {
  56. dataList.dimName = [];
  57. if (data.length > 0) {
  58. data.map(it => {
  59. it.dimensionList.map(item => {
  60. dataList.dimName.push({
  61. name: item.dimName,
  62. id: item.dimId
  63. });
  64. });
  65. });
  66. console.log("data", data);
  67. console.log("data", dataList.dimName);
  68. }
  69. }
  70. };
  71. const getPersonDimensionChartsListApi = async (
  72. dimensionName?: string,
  73. dimId?: number | string,
  74. index?: any
  75. ) => {
  76. let tabIndex = Number(index);
  77. const { code, data } = await getPersonDimensionChartsList({
  78. ...seachParams.value,
  79. dimId,
  80. dimensionName,
  81. type: 2
  82. });
  83. if (code == 200) {
  84. if (data.length > 0) {
  85. if (dimensionName && dimId) {
  86. setTimeout(() => {
  87. nextTick(() => {
  88. personListRef.value[tabIndex - 1].init(data);
  89. });
  90. }, 500);
  91. } else {
  92. setTimeout(() => {
  93. nextTick(() => {
  94. radarRef.value.initChart(data);
  95. });
  96. }, 500);
  97. // rankTableRef.value.init(data, "医疗组");
  98. }
  99. }
  100. }
  101. // console.log(res);
  102. };
  103. // 柱状图
  104. const getPersonDimensionChartsRankingApi = async (
  105. dimensionName?: string,
  106. dimId?: number | string
  107. ) => {
  108. const { code, data } = await getPersonDimensionChartsRanking({
  109. ...seachParams.value,
  110. dimId,
  111. dimensionName,
  112. type: 2
  113. });
  114. if (code == 200) {
  115. if (data.length > 0) {
  116. barEchartsRef.value.init(data);
  117. }
  118. }
  119. };
  120. const init = (item, type) => {
  121. seachParams.value = item;
  122. if (Number(type)) {
  123. getPersonDimensionChartsListApi();
  124. getPersonDimensionChartsRankingApi();
  125. getPersonDimensionChartsListApiDimList();
  126. getChartsListApi();
  127. }
  128. setTimeout(() => {
  129. nextTick(() => {
  130. if (barDimEchartsRef.value) {
  131. // barDimEchartsRef.value[0].init(seachParams.value, 0);
  132. if (Array.isArray(barDimEchartsRef.value)) {
  133. dataList.dimName.map((it, id) => {
  134. barDimEchartsRef.value[id - 1].init(seachParams.value, 0);
  135. });
  136. } else {
  137. barDimEchartsRef.value.init(seachParams.value, 0);
  138. }
  139. }
  140. });
  141. }, 500);
  142. };
  143. // 维度表格
  144. const personListRef = ref();
  145. const handleClick = (tab: TabsPaneContext, event: Event) => {
  146. if (tab.props.label == "总览") {
  147. getPersonDimensionChartsListApi();
  148. getPersonDimensionChartsRankingApi();
  149. getChartsListApi();
  150. } else {
  151. getPersonDimensionChartsListApi(tab.props.label, tab.props.name, tab.index);
  152. getPersonDimensionChartsRankingApi(tab.props.label, tab.props.name);
  153. }
  154. // barEchartsRef.value.init(tab.props);
  155. };
  156. const fullBig = (item: any) => {
  157. router.push({
  158. path: "/fullBig",
  159. query: { title: item, ...seachParams.value, type: 2 }
  160. });
  161. };
  162. </script>
  163. <template>
  164. <div class="w-[100%]">
  165. <div class="w-[100%]">
  166. <seachData @handClick="init" />
  167. <div v-if="showLength > 0">
  168. <div class="flex mr-2">
  169. <radar ref="radarRef" />
  170. </div>
  171. <el-tabs
  172. v-model="activeName"
  173. class="demo-tabs"
  174. :lazy="true"
  175. @tab-click="handleClick"
  176. >
  177. <el-tab-pane label="总览" name="1">
  178. <div class="flex mr-8">
  179. <rankTable ref="rankTableRef" />
  180. </div>
  181. <!-- 总得分 -->
  182. <div class="mt-5 pr-8 w-full h-60">
  183. <barEcharts ref="barEchartsRef" :title="'总得分'" />
  184. </div>
  185. <!-- 维度得分 -->
  186. <div
  187. v-for="(item, index) in dataList.dimName"
  188. :key="index"
  189. class="flex justify-between flex-wrap items-center"
  190. >
  191. <div class="mt-5 pr-8 w-1/2 h-60">
  192. <barDimEcharts ref="barDimEchartsRef" :title="item.name" />
  193. </div>
  194. </div>
  195. </el-tab-pane>
  196. <el-tab-pane
  197. v-for="(item, index) in dataList.dimName"
  198. :key="index"
  199. :label="item.name"
  200. :name="item.id"
  201. :lazy="true"
  202. >
  203. <div class="w-full">
  204. <div class="flex justify-between">
  205. <personList ref="personListRef" class="w-11/12" />
  206. <div
  207. class="w-[30px] h-[30px] mr-10 cursor-pointer"
  208. @click="fullBig(item.name)"
  209. >
  210. <img class="w-full h-full" :src="qvanping" alt="" />
  211. </div>
  212. </div>
  213. <div class="w-full h-60 mt-5 pr-8">
  214. <barEcharts ref="barEchartsRef" :title="item.name" />
  215. </div>
  216. </div>
  217. </el-tab-pane>
  218. </el-tabs>
  219. </div>
  220. </div>
  221. </div>
  222. </template>