index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="stack-container">
  3. <!-- 左侧按钮-->
  4. <el-button class="start-btn" type="primary" @click="handleStart"
  5. >开始调仓
  6. </el-button>
  7. <!-- 中间仓储变动图表-->
  8. <div>
  9. <div class="layout-top">
  10. <div class="index-box">
  11. <span class="x-label">x</span>
  12. <span class="y-label">y</span>
  13. </div>
  14. <div
  15. v-for="xIndex in stackInfo.xNum"
  16. :key="xIndex + 'x'"
  17. class="index-box"
  18. >
  19. <span class="x" v-text="xIndex"></span>
  20. </div>
  21. </div>
  22. <div class="stack-center-layout">
  23. <div class="layout-left">
  24. <div
  25. v-for="yIndex in stackInfo.yNum"
  26. :key="yIndex + 'y'"
  27. class="index-box"
  28. >
  29. <span class="y" v-text="yIndex"></span>
  30. </div>
  31. </div>
  32. <div class="stack-list-layout">
  33. <StackContainer
  34. v-for="(stack, index) in dataList"
  35. :key="index"
  36. v-bind="stack"
  37. />
  38. <Car v-if="false" />
  39. </div>
  40. </div>
  41. </div>
  42. <!-- 右侧调仓功能-->
  43. <div>youce</div>
  44. </div>
  45. </template>
  46. <script lang="ts" setup>
  47. import { getStackInfo, StacInfo, StackState } from "@/api/storage/change.js";
  48. import StackContainer from "@/views/storage-change/stackContainer.vue";
  49. import Car from "@/views/storage-change/car.vue";
  50. const stackInfo = ref<StacInfo>({}); // 不包含list的仓储信息
  51. const dataList = ref<any[]>([]);
  52. const width = ref<string>(`0px`);
  53. const height = ref<string>(`0px`);
  54. onMounted(async () => {
  55. const res: any = await getStackInfo();
  56. dataList.value = res.data.positions;
  57. Reflect.deleteProperty(res.data, "positions");
  58. stackInfo.value = res.data as StacInfo;
  59. // 用于动态设置grid的宽高
  60. width.value = `${stackInfo.value.xNum! * 96}px`;
  61. height.value = `${stackInfo.value.yNum! * 95}px`;
  62. });
  63. // ======================== 左侧按钮事件 ==========
  64. const changeState = ref<StackState>(StackState.NORMALE);
  65. const handleStart = () => {
  66. console.log("开始调仓");
  67. changeState.value = StackState.SELECT_OUT;
  68. setTimeout(() => {
  69. changeState.value = StackState.SELECT_IN;
  70. }, 2000);
  71. };
  72. provide("changeState", changeState);
  73. // ========== 右侧调仓功能 ==========
  74. </script>
  75. <style lang="scss" scoped>
  76. .stack-container {
  77. border: 1px solid #ccc;
  78. width: 100%;
  79. height: 100%;
  80. display: flex;
  81. justify-content: space-between;
  82. overflow: hidden;
  83. }
  84. .stack-center-layout {
  85. display: flex;
  86. justify-content: center;
  87. align-items: center;
  88. }
  89. .layout-left {
  90. display: flex;
  91. flex-direction: column;
  92. justify-content: center;
  93. }
  94. .layout-top {
  95. display: flex;
  96. justify-content: end;
  97. align-items: end;
  98. }
  99. .index-box {
  100. width: 96px;
  101. height: 95px;
  102. font-weight: 500;
  103. font-size: 24px;
  104. color: rgba(0, 0, 0, 0.2);
  105. position: relative;
  106. .y {
  107. position: absolute;
  108. top: 5px;
  109. right: 5px;
  110. }
  111. .x {
  112. position: absolute;
  113. bottom: 5px;
  114. left: 5px;
  115. }
  116. .x-label {
  117. position: absolute;
  118. bottom: 19px;
  119. right: 5px;
  120. }
  121. .y-label {
  122. position: absolute;
  123. right: 20px;
  124. bottom: 5px;
  125. }
  126. }
  127. .stack-list-layout {
  128. width: v-bind("width");
  129. height: v-bind("height");
  130. display: grid;
  131. grid-template-columns: repeat(auto-fit, 95px);
  132. grid-auto-rows: 95px;
  133. grid-gap: 0; /* 设置元素之间的间距 */
  134. position: relative;
  135. }
  136. .start-btn {
  137. width: 292px;
  138. height: 80px;
  139. background: #0a59f7;
  140. border-radius: 40px;
  141. font-weight: 500;
  142. font-size: 24px;
  143. color: #ffffff;
  144. }
  145. </style>