Header.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div class="header">
  3. <div class="left">
  4. <img class="first" src="../assets/three.png" alt="" />
  5. <div class="shu"></div>
  6. <img class="logo" src="../assets/white-logo.png" alt="" />
  7. <div
  8. class="ml20"
  9. style="color: #fff; font-size: 12px; height: 60px; padding-top: 50px"
  10. >
  11. version:{{ timelineData[0].version }}
  12. </div>
  13. </div>
  14. <div class="right">
  15. <div
  16. @click="dialogVisible = true"
  17. class="pointer"
  18. style="padding-top: 6px"
  19. >
  20. <el-badge
  21. :hidden="isNewMessage.length == 0"
  22. :value="isNewMessage.length"
  23. class="mr30"
  24. >
  25. <el-icon :size="size" color="#00a9dc">
  26. <BellFilled />
  27. </el-icon>
  28. </el-badge>
  29. </div>
  30. <img class="user-icon" src="../assets/user.png" alt="" />
  31. <div class="user">{{ userName }}</div>
  32. <el-popover placement="bottom" trigger="hover" :width="160">
  33. <el-timeline>
  34. <el-timeline-item
  35. v-for="item in timelineData"
  36. center
  37. :timestamp="item.timer"
  38. placement="top"
  39. >
  40. <div class="log-card">
  41. <p style="margin-bottom: 5px">Version: {{ item.version }}</p>
  42. <p>{{ item.remark }}</p>
  43. </div>
  44. </el-timeline-item>
  45. </el-timeline>
  46. <template #reference>
  47. <div class="log">版本日志</div>
  48. </template>
  49. </el-popover>
  50. <div class="quit" @click="quit">[退出]</div>
  51. </div>
  52. <el-dialog v-model="dialogVisible" title="拍照通知" width="30%">
  53. <el-table :data="tableData[currentTableIndex - 1]" border>
  54. <el-table-column align="center" type="index" />
  55. <el-table-column align="center" property="shipName" label="船名" />
  56. <el-table-column align="center" property="status" label="状态" />
  57. </el-table>
  58. <el-pagination
  59. style="text-align: right; margin-top: 20px"
  60. @current-change="pageChange"
  61. background
  62. layout="prev, pager, next"
  63. :total="total"
  64. >
  65. </el-pagination>
  66. <template #footer>
  67. <span class="dialog-footer">
  68. <el-button type="primary" @click="dialogVisible = false">
  69. 确定
  70. </el-button>
  71. </span>
  72. </template>
  73. </el-dialog>
  74. </div>
  75. </template>
  76. <script>
  77. import store from "../store";
  78. import router from "../router";
  79. import api from "../apis/fetch";
  80. import { onMounted, ref } from "vue";
  81. import { BellFilled } from "@element-plus/icons";
  82. import _ from "lodash";
  83. export default {
  84. components: {
  85. BellFilled,
  86. },
  87. setup() {
  88. let userName = localStorage.staffName;
  89. function quit() {
  90. localStorage.removeItem("staffPhone");
  91. localStorage.removeItem("id");
  92. localStorage.removeItem("status");
  93. localStorage.removeItem("userType");
  94. localStorage.removeItem("staffName");
  95. store.commit("changeLogin", false);
  96. router.push({ path: "/login" });
  97. }
  98. let dialogVisible = ref(false);
  99. let isNewMessage = ref([]);
  100. function isWithinTime(t0 = new Date()) {
  101. let t1 = _.cloneDeep(t0);
  102. let t2 = _.cloneDeep(t0);
  103. t1.setHours(8);
  104. t1.setMinutes(30);
  105. t1.setSeconds(0);
  106. t2.setHours(9);
  107. t2.setMinutes(30);
  108. t2.setSeconds(0);
  109. let t00 = t0.getTime();
  110. let t11 = t1.getTime();
  111. let t22 = t2.getTime();
  112. return t00 > t11 && t00 < t22;
  113. }
  114. function spArr(arr, num) {
  115. //arr是你要分割的数组,num是以几个为一组
  116. let newArr = []; //首先创建一个新的空数组。用来存放分割好的数组
  117. for (let i = 0; i < arr.length; ) {
  118. //注意:这里与for循环不太一样的是,没有i++
  119. newArr.push(arr.slice(i, (i += num)));
  120. }
  121. return newArr;
  122. }
  123. let tableData = ref([]);
  124. let currentTableIndex = ref(1);
  125. let total = ref(0);
  126. function pageChange(c) {
  127. currentTableIndex.value = c;
  128. }
  129. async function getUnphotographNotice() {
  130. let { data } = await api.getUnphotographNotice();
  131. if (data.status == 0) {
  132. for (let i of data.result) {
  133. isNewMessage.value.push({
  134. shipName: i,
  135. status: "未拍照",
  136. });
  137. }
  138. total.value = isNewMessage.value.length;
  139. tableData.value = spArr(isNewMessage.value, 10);
  140. } else {
  141. isNewMessage.value = 0;
  142. }
  143. }
  144. onMounted(() => {
  145. getUnphotographNotice();
  146. setInterval(async () => {
  147. if (isWithinTime()) {
  148. getUnphotographNotice();
  149. }
  150. }, 2 * 60 * 1000);
  151. });
  152. let timelineData = ref([
  153. { timer: "2022/02/7", version: "1.2.13.1", remark: "版本日志功能更新" },
  154. {
  155. timer: "2022/01/24",
  156. version: "1.2.13.0",
  157. remark: "磅单上传;下载卸货记录",
  158. },
  159. ]);
  160. const size = 20;
  161. return {
  162. size,
  163. quit,
  164. userName,
  165. isNewMessage,
  166. tableData,
  167. dialogVisible,
  168. currentTableIndex,
  169. total,
  170. pageChange,
  171. timelineData,
  172. };
  173. },
  174. };
  175. </script>
  176. <style scoped>
  177. .header {
  178. width: 100%;
  179. height: 60px;
  180. background: #212029;
  181. display: flex;
  182. align-items: center;
  183. justify-content: space-between;
  184. }
  185. .left,
  186. .right {
  187. display: flex;
  188. align-items: center;
  189. }
  190. .first {
  191. width: 22px;
  192. height: 20px;
  193. margin: 0 22px;
  194. }
  195. .shu {
  196. width: 1px;
  197. height: 60px;
  198. background: #101015;
  199. margin-right: 22px;
  200. }
  201. .logo {
  202. width: 120px;
  203. height: 40px;
  204. }
  205. .title {
  206. font-size: 21px;
  207. font-family: PingFangSC-Regular, PingFang SC;
  208. font-weight: 400;
  209. color: #ffffff;
  210. margin-left: 26px;
  211. }
  212. .user-icon {
  213. width: 18px;
  214. height: 18px;
  215. margin-right: 16px;
  216. }
  217. .user,
  218. .quit,
  219. .log {
  220. font-size: 14px;
  221. font-family: PingFangSC-Medium, PingFang SC;
  222. font-weight: 500;
  223. color: #ffffff;
  224. cursor: pointer;
  225. margin-right: 16px;
  226. }
  227. .log-card p {
  228. font-size: 10px;
  229. }
  230. </style>