search.vue 3.3 KB

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