index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div style="height: 100vh; background: #eeeeee">
  3. <m-nav-bar title="灯光模拟"></m-nav-bar>
  4. <div class="header-border"></div>
  5. <lightConfig
  6. @close="
  7. () => {
  8. lightConfigVisible = false;
  9. }
  10. "
  11. v-if="lightConfigVisible"></lightConfig>
  12. <composeTopicsMask
  13. v-if="singleTopicsVisible"
  14. @close="
  15. () => {
  16. singleTopicsVisible = false;
  17. }
  18. "
  19. @before="selectBeforeCom"
  20. @after="selectAfterCom"
  21. :title="singleTopicTitle"
  22. :list="listItem"
  23. :show="true"></composeTopicsMask>
  24. <van-cell
  25. @click="
  26. () => {
  27. lightConfigVisible = true;
  28. }
  29. "
  30. class="custom-cell"
  31. title="考试要求:随机抽取一组灯光进行考试"
  32. value="设置"
  33. is-link />
  34. <div class="gray-space-12"></div>
  35. <van-tabs class="custom-tabs" v-model:active="active">
  36. <van-tab title="组合">
  37. <composeTopicList @select="selectCom" :list="list1"></composeTopicList>
  38. </van-tab>
  39. <van-tab title="单项">
  40. <singleTopicList :list="list2"></singleTopicList>
  41. </van-tab>
  42. </van-tabs>
  43. <examTopicList
  44. @close="
  45. () => {
  46. examTopicListVisible = false;
  47. }
  48. "
  49. :comList="list1"
  50. :singleList="list2"
  51. v-if="examTopicListVisible"></examTopicList>
  52. <div
  53. @click="
  54. () => {
  55. examTopicListVisible = true;
  56. }
  57. "
  58. class="fixBottom">
  59. <div class="button-halo">
  60. <button>开始考试</button>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <script setup lang="ts">
  66. import { reactive, ref } from "vue";
  67. import composeTopicList from "./components/composeTopicList.vue";
  68. import composeTopicsMask from "./components/composeTopicsMask.vue";
  69. import singleTopicList from "./components/singleTopicList.vue";
  70. import lightConfig from "./components/lightConfig.vue";
  71. import examTopicList from "./components/examTopicList.vue";
  72. import { lightingCombinationList, lightingItemList, lightingCombinationId } from "@/api/";
  73. import { Toast } from "vant";
  74. const active = 0;
  75. let examTopicListVisible = ref(false);
  76. let lightConfigVisible = ref(false);
  77. let list1Index = ref(-1);
  78. let list1Ids = ref<Number[]>([])
  79. let list1 = ref([
  80. {
  81. createTime: "2022-03-21 16:40:22",
  82. updateTime: "2022-03-21 16:51:11",
  83. id: 18,
  84. title: "新灯光01",
  85. operation: "开始-远近光交替-远近光交替-远光灯-近光灯-示廓灯/危险警示灯-结束",
  86. icon: "https://t1-1305573081.file.myqcloud.com/lighting/icon/6.png",
  87. itemId: "3,10,12,5,7,15,17",
  88. },
  89. ]);
  90. let list2 = ref([
  91. {
  92. createTime: "2022-03-21 14:35:59",
  93. updateTime: "2022-03-21 15:54:27",
  94. id: 3,
  95. title: "下面将进行模拟夜间行驶灯光的考试,请在5秒内做出相应的灯光操作。【停顿】【停顿】【停顿】请开启前照灯",
  96. operation: "开始(准备)",
  97. icon: "https://t1-1305573081.file.myqcloud.com/lighting/icon/1.png",
  98. voice: "https://t1-1305573081.file.myqcloud.com/lighting/voice/common3.mp3",
  99. process: 1,
  100. },
  101. ]);
  102. let listItem = ref([]);
  103. let singleTopicsVisible = ref(false);
  104. let singleTopicTitle = ref("");
  105. lightingCombinationList().then((res) => {
  106. list1.value = res.rows;
  107. // console.log(list1);
  108. });
  109. lightingItemList().then((res) => {
  110. res.rows.forEach((item) => {
  111. item.operation = "灯光操作:" + item.operation;
  112. });
  113. list2.value = res.rows;
  114. });
  115. let selectCom = (item: any, index: number) => {
  116. list1Index.value = index;
  117. singleTopicsVisible.value = true;
  118. singleTopicTitle.value = item.titile;
  119. lightingCombinationId(item.id).then((res) => {
  120. listItem.value = res.data;
  121. });
  122. };
  123. let selectBeforeCom = () => {
  124. if (list1Index.value == 0) {
  125. Toast("已经到底了");
  126. } else {
  127. list1Index.value = list1Index.value - 1;
  128. let item = list1.value[list1Index.value];
  129. singleTopicTitle.value = item.titile;
  130. lightingCombinationId(item.id).then((res) => {
  131. listItem.value = res.data;
  132. });
  133. }
  134. };
  135. let selectAfterCom = () => {
  136. if (list1Index.value == list1.value.length - 1) {
  137. Toast("已经到底了");
  138. } else {
  139. list1Index.value = list1Index.value + 1;
  140. let item = list1.value[list1Index.value];
  141. singleTopicTitle.value = item.titile;
  142. console.log(list1, item);
  143. lightingCombinationId(item.id).then((res) => {
  144. listItem.value = res.data;
  145. });
  146. }
  147. };
  148. </script>
  149. <style lang="scss" scoped>
  150. .header-border {
  151. width: 100%;
  152. height: 2px;
  153. background: rgb(231, 231, 231);
  154. }
  155. .gray-space-12 {
  156. width: 100%;
  157. height: 12px;
  158. background: rgb(238, 238, 238);
  159. }
  160. .custom-cell {
  161. :deep .van-cell__title {
  162. white-space: nowrap;
  163. }
  164. }
  165. .custom-tabs {
  166. height: 440px;
  167. overflow-y: scroll;
  168. background: #fff;
  169. :deep .van-tabs__wrap {
  170. border-bottom: 1px solid rgb(238, 238, 238);
  171. }
  172. :deep .van-tabs__line {
  173. width: 30px;
  174. background: #01c18d;
  175. }
  176. }
  177. .fixBottom {
  178. position: fixed;
  179. bottom: 0;
  180. font-size: 14px;
  181. width: 100%;
  182. display: flex;
  183. justify-content: center;
  184. font-size: 16px;
  185. .button-halo{
  186. width: 80px;
  187. height: 80px;
  188. display: flex;
  189. justify-content: center;
  190. align-content: center;
  191. align-items: center;
  192. background: rgb(255, 255, 255);
  193. border-radius: 50%;
  194. box-shadow: 0px 0px 3px rgb(121, 121, 121);
  195. }
  196. button {
  197. border: none;
  198. width: 60px;
  199. height: 60px;
  200. color: white;
  201. background: #01c18d;
  202. padding: 0 10px;
  203. border-radius: 50%;
  204. }
  205. }
  206. </style>