ProductionCapacitySituation.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div class="screen-common-component">
  3. <ScreenComHeader :module-id="moduleId" align="start" title="生产量情况" />
  4. <div class="container">
  5. <div ref="chartRef" class="charts-container"></div>
  6. <div class="describe-container">
  7. <div>
  8. <span class="typeText">生产目标</span>
  9. <span class="valueText">{{ progressOption.orderNum }}</span>
  10. <span class="unitText">件</span>
  11. </div>
  12. <div>
  13. <span class="typeText">实际生产量</span>
  14. <span class="valueText">{{ progressOption.comNum }}</span>
  15. <span class="unitText">件</span>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="bottom-progress">
  20. <div class="titleText">月进度</div>
  21. <dv-percent-pond
  22. :config="progressOption"
  23. style="width: 100%; height: 20px"
  24. />
  25. </div>
  26. </div>
  27. </template>
  28. <script lang="ts" setup>
  29. import ScreenComHeader from "@/views/screens/configs/screenComHeader.vue";
  30. import * as echarts from "echarts";
  31. import { productionQuantity } from "@/api/screens";
  32. const chartRef = ref(null);
  33. const generateOption = (c: string, o: string) => {
  34. const option = {
  35. series: [
  36. {
  37. type: "gauge",
  38. progress: {
  39. show: true,
  40. width: 12,
  41. },
  42. axisLine: {
  43. lineStyle: {
  44. width: 12,
  45. },
  46. },
  47. axisTick: {
  48. show: false,
  49. },
  50. splitLine: {
  51. distance: 2,
  52. length: 4,
  53. lineStyle: {
  54. width: 2,
  55. color: "#999",
  56. },
  57. },
  58. axisLabel: {
  59. distance: 12,
  60. color: "#999",
  61. fontSize: 14,
  62. },
  63. anchor: {
  64. show: true,
  65. showAbove: true,
  66. size: 16,
  67. itemStyle: {
  68. borderWidth: 10,
  69. },
  70. },
  71. title: {
  72. show: false,
  73. },
  74. detail: {
  75. valueAnimation: true,
  76. fontSize: 16,
  77. offsetCenter: [0, "70%"],
  78. formatter: "{value}%",
  79. textStyle: {
  80. color: "#fff",
  81. },
  82. },
  83. data: [
  84. {
  85. value: Number((Number(c) / Number(o)) * 100).toFixed(0),
  86. },
  87. ],
  88. },
  89. ],
  90. };
  91. return option;
  92. };
  93. const progressOption = ref({
  94. value: 66,
  95. localGradient: true,
  96. orderNum: 0,
  97. comNum: 0,
  98. });
  99. onMounted(async () => {
  100. const chart = echarts.init(chartRef.value);
  101. let res: any = await productionQuantity();
  102. let { data } = res;
  103. progressOption.value = {
  104. value: Number(data.rate) * 100,
  105. localGradient: true,
  106. orderNum: Number(data.orderNum),
  107. comNum: Number(data.completeNum),
  108. };
  109. chart.setOption(generateOption(data.completeNum, data.orderNum));
  110. });
  111. const props = defineProps({
  112. moduleId: {
  113. type: String,
  114. required: true,
  115. },
  116. });
  117. </script>
  118. <style lang="scss" scoped>
  119. .container {
  120. display: flex;
  121. justify-content: center;
  122. align-items: center;
  123. height: calc(100% - 60px);
  124. //border: 1px solid red;
  125. }
  126. .bottom-progress {
  127. height: 30px;
  128. display: flex;
  129. padding: 0 20px;
  130. width: calc(100% - 60px);
  131. .titleText {
  132. color: white;
  133. font-size: 14px;
  134. width: 60px;
  135. margin-right: 10px;
  136. }
  137. }
  138. .charts-container {
  139. width: 60%;
  140. height: 100%;
  141. //border: 1px solid blue;
  142. }
  143. .describe-container {
  144. display: flex;
  145. flex-direction: column;
  146. align-items: start;
  147. justify-content: center;
  148. width: 40%;
  149. }
  150. .typeText {
  151. font-size: 14px;
  152. color: #009688;
  153. }
  154. .valueText {
  155. font-size: 16px;
  156. color: #4caf50;
  157. margin-right: 10px;
  158. margin-left: 10px;
  159. }
  160. .unitText {
  161. font-size: 12px;
  162. color: #009688;
  163. }
  164. </style>