search.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div class="search_box">
  3. <div class="left">
  4. <div class="back" @click="back()">
  5. <i class="el-icon-back"></i>
  6. 返回
  7. </div>
  8. <el-form
  9. class="search_form"
  10. label-width="90px"
  11. @keyup.enter.native="search"
  12. @submit.native.prevent
  13. >
  14. <el-form-item label="工序名称:">
  15. <el-select v-model="search.taskId" @change="changeSelect" filterable
  16. >
  17. <el-option
  18. v-for="(item, index) in produceTaskList"
  19. :key="index"
  20. :label="item.name"
  21. :value="item.id"
  22. ></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="设备名称:">
  26. <el-input
  27. clearable
  28. v-model="search.deviceName"
  29. placeholder="请输入"
  30. />
  31. </el-form-item>
  32. </el-form>
  33. </div>
  34. <div class="right">
  35. <div class="lab">操作员:{{ userName }}</div>
  36. <div class="lab">{{ currentTime }}</div>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import { listTask } from '@/api/produce/index';
  42. export default {
  43. data() {
  44. return {
  45. currentTime: '',
  46. userName: JSON.parse(localStorage.getItem('info'))?.name,
  47. produceTaskList: [],
  48. search: {
  49. taskId: null,
  50. deviceName: null
  51. }
  52. };
  53. },
  54. created() {
  55. this.getTaskList();
  56. this.updateCurrentTime();
  57. setInterval(this.updateCurrentTime, 1000); // 每秒更新一次时间
  58. },
  59. watch: {
  60. 'search.taskId': {
  61. handler(val) {
  62. if(val) {
  63. this.changeSelect(val)
  64. } else {
  65. this.$store.commit('user/setTaskObj', {});
  66. }
  67. },
  68. immediate: true,
  69. }
  70. },
  71. methods: {
  72. getTaskList() {
  73. listTask().then((res) => {
  74. this.produceTaskList = res;
  75. });
  76. },
  77. changeSelect(e) {
  78. let taskObj = {};
  79. taskObj = this.produceTaskList.find((item) => item.id === e);
  80. this.$store.commit('user/setTaskObj', taskObj);
  81. },
  82. back() {
  83. this.$router.go(-1);
  84. },
  85. updateCurrentTime() {
  86. const now = new Date();
  87. const year = now.getFullYear();
  88. const month = (now.getMonth() + 1).toString().padStart(2, '0'); // 月份是从0开始的
  89. const day = now.getDate().toString().padStart(2, '0');
  90. const hours = now.getHours().toString().padStart(2, '0');
  91. const minutes = now.getMinutes().toString().padStart(2, '0');
  92. const seconds = now.getSeconds().toString().padStart(2, '0');
  93. this.currentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  94. }
  95. }
  96. };
  97. </script>
  98. <style lang="scss" scoped>
  99. .search_box {
  100. min-width: 1280px;
  101. width: 100%;
  102. height: 50px;
  103. background: #157a2c;
  104. padding: 0 16px;
  105. display: flex;
  106. align-items: center;
  107. justify-content: space-between;
  108. font-size: 20px;
  109. .left {
  110. display: flex;
  111. align-items: center;
  112. font-size: 16px;
  113. color: #fff;
  114. .back {
  115. margin-right: 40px;
  116. cursor: pointer;
  117. }
  118. }
  119. .right {
  120. display: flex;
  121. align-items: center;
  122. font-size: 16px;
  123. color: #fff;
  124. .lab {
  125. line-height: 50px;
  126. margin-left: 60px;
  127. }
  128. }
  129. }
  130. .search_form {
  131. display: flex !important;
  132. height: 50px;
  133. align-items: center;
  134. }
  135. .el-form-item {
  136. margin-bottom: 0px !important;
  137. }
  138. </style>
  139. <style>
  140. .search_box {
  141. .el-form-item__label {
  142. color: #fff !important;
  143. }
  144. }
  145. </style>