lineChart.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="dashboard-content-top-left-item">
  3. <div class="dashboard-content-top-left-item-top">
  4. <div class="dashboard-content-top-left-item-top-title">{{ title }}</div>
  5. <div
  6. class="dashboard-content-top-left-item-top-time"
  7. @click="showDatePicker"
  8. >
  9. <el-icon color="#ffffff" size="18">
  10. <Calendar />
  11. </el-icon>
  12. <el-icon color="#ffffff">
  13. <CaretBottom />
  14. </el-icon>
  15. </div>
  16. </div>
  17. <div class="dashboard-content-top-left-item-bottom">
  18. <Echarts :id="id" :option="options" />
  19. </div>
  20. </div>
  21. </template>
  22. <script setup lang="ts">
  23. import { ref, onMounted } from "vue";
  24. import Echarts from "@/components/Echarts/commonChartsBar.vue";
  25. import { Calendar, CaretBottom } from "@element-plus/icons-vue";
  26. import Dialog from "@/components/dialog/index.vue";
  27. import axios from "axios";
  28. const props = defineProps({
  29. title: {
  30. type: String,
  31. default: "",
  32. },
  33. id: {
  34. type: String,
  35. default: "w" + Math.random(),
  36. },
  37. });
  38. const { title, id } = props;
  39. const options = ref({
  40. tooltip: {
  41. trigger: "axis",
  42. },
  43. legend: {
  44. show: true,
  45. top: 0,
  46. left: "30%",
  47. icon: "roundRect",
  48. },
  49. grid: {
  50. left: "0%",
  51. right: "5%",
  52. bottom: "0%",
  53. top: "15%",
  54. containLabel: true,
  55. },
  56. color: ["#F5BB3D", "#73D970", "#6A9DD9"],
  57. xAxis: {
  58. type: "category",
  59. boundaryGap: true,
  60. data: [
  61. "0:00",
  62. "2:00",
  63. "4:00",
  64. "6:00",
  65. "8:00",
  66. "10:00",
  67. "12:00",
  68. "14:00",
  69. "16:00",
  70. "18:00",
  71. "20:00",
  72. "22:00",
  73. ],
  74. axisLine: {
  75. show: true,
  76. lineStyle: {
  77. color: "#8897BC",
  78. },
  79. },
  80. axisTick: {
  81. show: false,
  82. },
  83. axisLabel: {
  84. color: "#8897BC",
  85. },
  86. },
  87. yAxis: [
  88. {
  89. type: "value",
  90. axisLabel: {
  91. color: "#8897BC",
  92. formatter: function (item) {
  93. return item / 10000 + "万";
  94. },
  95. },
  96. splitLine: {
  97. lineStyle: {
  98. type: "dashed",
  99. color: "rgba(196,194,225, 0.54)",
  100. },
  101. },
  102. name: "单",
  103. },
  104. {
  105. type: "value",
  106. axisLabel: {
  107. color: "#8897BC",
  108. },
  109. splitLine: {
  110. lineStyle: {
  111. type: "dashed",
  112. color: "rgba(196,194,225, 0.54)",
  113. },
  114. },
  115. name: "吨",
  116. },
  117. ],
  118. series: [
  119. {
  120. name: "运单/单",
  121. type: "line",
  122. symbol: "none",
  123. key: "bagsnum",
  124. yAxisIndex: 0,
  125. data: [120, 132, 101, 134, 90, 230, 210, 132, 101, 134, 90, 230],
  126. areaStyle: {
  127. color: {
  128. type: "linear",
  129. x: 0,
  130. y: 0,
  131. x2: 0,
  132. y2: 1,
  133. colorStops: [
  134. {
  135. offset: 0,
  136. color: "rgba(125,72,255,0.5)",
  137. },
  138. {
  139. offset: 1,
  140. color: "rgba(0,180,255,0.01)",
  141. },
  142. ],
  143. global: false,
  144. },
  145. },
  146. },
  147. {
  148. name: "重量/吨",
  149. type: "line",
  150. symbol: "none",
  151. yAxisIndex: 1,
  152. key: "passengers",
  153. data: [220, 182, 191, 234, 290, 330, 310, 132, 101, 134, 90, 230],
  154. areaStyle: {
  155. color: {
  156. type: "linear",
  157. x: 0,
  158. y: 0,
  159. x2: 0,
  160. y2: 1,
  161. colorStops: [
  162. {
  163. offset: 0,
  164. color: "rgba(125,72,255,0.5)",
  165. },
  166. {
  167. offset: 1,
  168. color: "rgba(0,180,255,0.01)",
  169. },
  170. ],
  171. global: false,
  172. },
  173. },
  174. },
  175. ],
  176. });
  177. const form = ref({
  178. startDate: Date.now(),
  179. endDate: Date.now(),
  180. });
  181. const disabledStartDate = (time: Date) => {
  182. let data = new Date(form.value.endDate);
  183. return time.getTime() > data.getTime();
  184. };
  185. const disabledEndDate = (time: Date) => {
  186. let data = new Date(form.value.startDate);
  187. return data.getTime() > time.getTime();
  188. };
  189. const flag = ref(false);
  190. const resetForm = () => {
  191. flag.value = false;
  192. };
  193. const submitForm = () => {
  194. flag.value = false;
  195. };
  196. const showDatePicker = () => {
  197. flag.value = true;
  198. };
  199. </script>
  200. <style lang="scss" scoped>
  201. .dashboard-content-top-left-item {
  202. &-top {
  203. width: 100%;
  204. height: 45px;
  205. display: flex;
  206. padding-top: 15px;
  207. box-sizing: border-box;
  208. &-title {
  209. font-size: 16px;
  210. font-weight: bold;
  211. color: #75cee1;
  212. line-height: 1.8;
  213. margin-right: 10px;
  214. }
  215. &-time {
  216. display: flex;
  217. justify-content: flex-start;
  218. align-items: center;
  219. cursor: pointer;
  220. }
  221. }
  222. &-bottom {
  223. width: 100%;
  224. flex: 1;
  225. position: relative;
  226. // margin-top: 10px;
  227. }
  228. }
  229. </style>