MissionVue.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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'" :style="{
  8. background: `url(${item.isSelected ? item.isImg : item.noImg})`,
  9. color: item.isSelected ? 'white' : 'black',
  10. }" @click="misChange(item, index)">{{ item.name }}</span>
  11. </template>
  12. </div>
  13. <!-- 功能盒子 -->
  14. <div class="settingBox">
  15. <!-- 无检测任务时显示的盒子 -->
  16. <NoBox v-if="btnSelect == 0 && taskList.length == 0 && sizeNum == 0" :btnSelect="btnSelect"
  17. :taskList="taskList" @backToMission="backToMission"></NoBox>
  18. <!-- 有检测任务的盒子 -->
  19. <HaveMis v-if="btnSelect == 0 && taskList.length != 0 && sizeNum == 0" @moreBack="moreBack" @hmBack="hmBack"
  20. @haveBack="haveBack" @haveInCreate="haveInCreate"></HaveMis>
  21. <!-- 新建任务盒子 -->
  22. <CreateNew v-if="btnSelect == 1" :btnSelect="btnSelect" :taskList="taskList" :editRow="editRow"
  23. :status="status" @createBack="createBack">
  24. </CreateNew>
  25. <!-- 正在检测盒子 -->
  26. <StartMission v-if="btnSelect == 0 && sizeNum == 1" @smBack="smBack" :startMis="startMis"></StartMission>
  27. <HistoryMis v-if="btnSelect == 2"></HistoryMis>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import { ref, onMounted } from 'vue';
  34. import NoBox from './components/NoMisBox'
  35. import CreateNew from './components/CreateMis'
  36. import HaveMis from './components/HaveMis.vue';
  37. import StartMission from './components/StartMission.vue';
  38. import HistoryMis from './components/HistoryMis.vue';
  39. import task from '@/api/task';
  40. import blueBtn from '@/assets/image/btn_blue.png'
  41. import grayBtn from '@/assets/image/btn_gray.png'
  42. export default {
  43. setup() {
  44. document.documentElement.style.fontSize = (window.innerWidth / 1920 * 12) + "px"
  45. let sizeNum = ref(0)//判断是否开始检测。0为未开始,1为开始
  46. let btnList = ref([
  47. {
  48. name: "当前检测任务",
  49. id: 1,
  50. noImg: grayBtn,
  51. isImg: blueBtn,
  52. isSelected: true, // 初始状态未选中
  53. value: "1"
  54. },
  55. {
  56. name: "新建检测任务",
  57. id: 2,
  58. noImg: grayBtn,
  59. isImg: blueBtn,
  60. isSelected: false, // 初始状态未选中
  61. value: "2"
  62. },
  63. {
  64. name: "历史任务",
  65. id: 3,
  66. noImg: grayBtn,
  67. isImg: blueBtn,
  68. isSelected: false, // 初始状态未选中
  69. value: "3"
  70. }
  71. ])//按钮列表
  72. let taskList = ref([])//任务表单
  73. let btnSelect = ref(0)//选择的菜单
  74. let startMis = ref({})//开始检测
  75. let editRow = ref({})//需要编辑的任务
  76. let status = ref(0)
  77. function searchAllTask() {
  78. // 0为待检测
  79. task.getTask({ pageno: 1, pagesize: 10, state: 0 }).then(res => {
  80. if (res.data == null) {
  81. return
  82. } else {
  83. taskList.value = res.data
  84. }
  85. })
  86. // 2为完成检测
  87. task.getTask({ pageno: 1, pagesize: 10, state: 2 }).then(res => {
  88. if (res.data == null) {
  89. return
  90. } else {
  91. taskList.value = res.data
  92. }
  93. })
  94. // 1为正在检测
  95. task.getTask({ pageno: 1, pagesize: 10, state: 1 }).then(res => {
  96. if (res.data == null) {
  97. return
  98. } else {
  99. taskList.value = res.data
  100. }
  101. })
  102. }
  103. function misChange(row, num) {
  104. btnSelect.value = num
  105. if (num == 1) {
  106. status.value = 1
  107. }
  108. // 将当前点击的标签设为选中状态,其他标签设为非选中
  109. btnList.value.forEach((tag) => {
  110. tag.isSelected = tag.id === row.id;
  111. });
  112. }
  113. function createMis() {
  114. btnSelect.value = 1
  115. }
  116. function backToMission(data) {
  117. btnSelect.value = data
  118. }
  119. function hmBack(data, obj) {
  120. startMis.value = obj
  121. sizeNum.value = data
  122. }
  123. function smBack(data) {
  124. sizeNum.value = data
  125. }
  126. function createBack(data) {
  127. btnSelect.value = data
  128. btnList.value.forEach((tag) => {
  129. tag.isSelected = tag.id === data + 1;
  130. });
  131. }
  132. function haveBack(data) {
  133. if (data == null) {
  134. taskList.value = []
  135. } else {
  136. taskList.value = data
  137. }
  138. }
  139. function moreBack(data) {
  140. btnSelect.value = data
  141. btnList.value.forEach((tag) => {
  142. tag.isSelected = tag.id === data + 1;
  143. });
  144. }
  145. function haveInCreate(data, row, num) {
  146. btnSelect.value = data
  147. editRow.value = row
  148. status.value = num
  149. btnList.value.forEach((tag) => {
  150. tag.isSelected = tag.id === data + 1;
  151. });
  152. }
  153. onMounted(() => {
  154. searchAllTask()
  155. })
  156. return {
  157. btnList,//按钮列表
  158. btnSelect,//按钮切换class
  159. misChange,//按钮切换点击事件
  160. createMis,//点击创建新任务
  161. searchAllTask,//获取所有检测任务
  162. taskList,//选择的菜单
  163. backToMission,//返回的菜单数据
  164. sizeNum,//判断是否开始检测
  165. hmBack,//开始检测子组件返回
  166. smBack,//
  167. haveBack,
  168. createBack,//createMix.vue返回的菜单栏
  169. startMis,//需要检测的任务名称
  170. haveInCreate,//havemis.vue返回的进入到创建任务vue
  171. editRow,//需要编辑的任务
  172. status,
  173. moreBack,
  174. }
  175. },
  176. components: {
  177. NoBox,
  178. CreateNew,
  179. HaveMis,
  180. StartMission,
  181. HistoryMis,
  182. }
  183. }
  184. </script>
  185. <style scoped>
  186. .bigBox {
  187. width: 99%;
  188. height: calc(100vh - 100px);
  189. /* border: 1px solid salmon; */
  190. /* overflow: hidden; */
  191. }
  192. .btnBox {
  193. width: 99%;
  194. height: 50px;
  195. /* border: 1px solid rebeccapurple; */
  196. }
  197. .settingBox {
  198. width: 100%;
  199. height: calc(100vh - 220px);
  200. /* margin-top: -65px; */
  201. margin-left: 10px;
  202. }
  203. .nowMission {
  204. display: inline-block;
  205. width: 110px;
  206. height: 40px;
  207. margin-left: 10px;
  208. margin-top: 5px;
  209. cursor: pointer;
  210. background-color: gray;
  211. text-align: center;
  212. line-height: 40px;
  213. font-size: 14px;
  214. color: white;
  215. /* border-radius: 8px; */
  216. }
  217. .result {
  218. display: inline-block;
  219. width: 110px;
  220. height: 40px;
  221. margin-left: 10px;
  222. margin-top: 5px;
  223. cursor: pointer;
  224. background: linear-gradient(to bottom, #ADD8F9, #5779D7);
  225. text-align: center;
  226. line-height: 40px;
  227. font-size: 14px;
  228. color: white;
  229. /* border-radius: 8px; */
  230. }
  231. .noMisBox {
  232. width: 200px;
  233. height: 200px;
  234. margin: 80px auto;
  235. text-align: center;
  236. line-height: 20px;
  237. }
  238. .createMisp {
  239. width: 240px;
  240. height: 30px;
  241. text-align: center;
  242. line-height: 30px;
  243. cursor: pointer;
  244. }
  245. .bestInput {
  246. width: 550px;
  247. height: 40px;
  248. border-radius: 2px 2px 2px 2px;
  249. }
  250. </style>