MissionVue.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div>
  3. <div class="bigBox">
  4. <!-- 三按钮盒子 -->
  5. <div class="btnBox">
  6. <template v-for="(item, index) in btnList">
  7. <span :class="btnSelect == index ? 'result' : 'nowMission'" @click="misChange(item, index)">{{ item.name
  8. }}</span>
  9. </template>
  10. <!-- <router-link to="/home/int">测试</router-link> -->
  11. </div>
  12. <!-- 功能盒子 -->
  13. <div class="settingBox">
  14. <!-- 无检测任务时显示的盒子 -->
  15. <NoBox v-if="btnSelect == 0 && taskList.length == 0 && sizeNum == 0" :btnSelect="btnSelect"
  16. :taskList="taskList" @backToMission="backToMission"></NoBox>
  17. <!-- 有检测任务的盒子 -->
  18. <HaveMis v-if="btnSelect == 0 && taskList.length != 0 && sizeNum == 0" @hmBack="hmBack"
  19. @haveBack="haveBack"></HaveMis>
  20. <!-- 新建任务盒子 -->
  21. <CreateNew v-if="btnSelect == 1" :btnSelect="btnSelect" :taskList="taskList" @createBack="createBack">
  22. </CreateNew>
  23. <!-- 正在检测盒子 -->
  24. <StartMission v-if="btnSelect == 0 && sizeNum == 1" @smBack="smBack" :startMis="startMis"></StartMission>
  25. <HistoryMis v-if="btnSelect == 2"></HistoryMis>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import { ref, onMounted } from 'vue';
  32. import NoBox from './components/NoMisBox'
  33. import CreateNew from './components/CreateMis'
  34. import HaveMis from './components/HaveMis.vue';
  35. import StartMission from './components/StartMission.vue';
  36. import HistoryMis from './components/HistoryMis.vue';
  37. import task from '@/api/task';
  38. export default {
  39. setup() {
  40. document.documentElement.style.fontSize = (window.innerWidth / 1920 * 12) + "px"
  41. let sizeNum = ref(0)//判断是否开始检测。0为未开始,1为开始
  42. let btnList = ref([
  43. {
  44. name: "当前检测任务",
  45. value: "1"
  46. },
  47. {
  48. name: "新建检测任务",
  49. value: "2",
  50. },
  51. {
  52. name: "历史任务",
  53. value: "3"
  54. }
  55. ])//按钮列表
  56. let taskList = ref([])//任务表单
  57. let btnSelect = ref(0)//选择的菜单
  58. let startMis = ref({})//开始检测
  59. function searchAllTask() {
  60. task.getTask({}).then(res => {
  61. if (res.data) {
  62. taskList.value = res.data
  63. }
  64. })
  65. }
  66. function misChange(row, num) {
  67. btnSelect.value = num
  68. console.log(num,'num');
  69. }
  70. function createMis() {
  71. btnSelect.value = 1
  72. }
  73. function backToMission(data) {
  74. btnSelect.value = data
  75. }
  76. function hmBack(data, obj) {
  77. startMis.value = obj
  78. sizeNum.value = data
  79. }
  80. function smBack(data) {
  81. sizeNum.value = data
  82. }
  83. function createBack(data) {
  84. btnSelect.value = data
  85. }
  86. function haveBack(data) {
  87. if (data == null) {
  88. taskList.value = []
  89. } else {
  90. taskList.value = data
  91. }
  92. }
  93. onMounted(() => {
  94. searchAllTask()
  95. })
  96. return {
  97. btnList,//按钮列表
  98. btnSelect,//按钮切换class
  99. misChange,//按钮切换点击事件
  100. createMis,//点击创建新任务
  101. searchAllTask,//获取所有检测任务
  102. taskList,//选择的菜单
  103. backToMission,//返回的菜单数据
  104. sizeNum,//判断是否开始检测
  105. hmBack,//开始检测子组件返回
  106. smBack,//
  107. haveBack,
  108. createBack,//createMix.vue返回的菜单栏
  109. startMis,//需要检测的任务名称
  110. }
  111. },
  112. components: {
  113. NoBox,
  114. CreateNew,
  115. HaveMis,
  116. StartMission,
  117. HistoryMis,
  118. }
  119. }
  120. </script>
  121. <style scoped>
  122. .bigBox {
  123. width: 99%;
  124. height: calc(100vh - 100px);
  125. /* border: 1px solid salmon; */
  126. /* overflow: hidden; */
  127. }
  128. .btnBox {
  129. width: 99%;
  130. height: 50px;
  131. /* border: 1px solid rebeccapurple; */
  132. }
  133. .settingBox {
  134. width: 100%;
  135. height: calc(100vh - 220px);
  136. /* margin-top: -65px; */
  137. margin-left: 10px;
  138. }
  139. .nowMission {
  140. display: inline-block;
  141. width: 110px;
  142. height: 40px;
  143. margin-left: 10px;
  144. margin-top: 5px;
  145. cursor: pointer;
  146. background-color: gray;
  147. text-align: center;
  148. line-height: 40px;
  149. font-size: 14px;
  150. color: white;
  151. border-radius: 8px;
  152. }
  153. .result {
  154. display: inline-block;
  155. width: 110px;
  156. height: 40px;
  157. margin-left: 10px;
  158. margin-top: 5px;
  159. cursor: pointer;
  160. background: linear-gradient(to bottom, #ADD8F9, #5779D7);
  161. text-align: center;
  162. line-height: 40px;
  163. font-size: 14px;
  164. color: white;
  165. border-radius: 8px;
  166. }
  167. .noMisBox {
  168. width: 200px;
  169. height: 200px;
  170. margin: 80px auto;
  171. text-align: center;
  172. line-height: 20px;
  173. }
  174. .createMisp {
  175. width: 240px;
  176. height: 30px;
  177. text-align: center;
  178. line-height: 30px;
  179. cursor: pointer;
  180. }
  181. .bestInput {
  182. width: 550px;
  183. height: 40px;
  184. border-radius: 2px 2px 2px 2px;
  185. }
  186. </style>