Header.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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: 18px; 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="240">
  33. <div style="width: 100%; height: 80vh; overflow-y: scroll">
  34. <el-timeline>
  35. <el-timeline-item
  36. v-for="item in timelineData"
  37. center
  38. :timestamp="item.timer"
  39. placement="top"
  40. >
  41. <div class="log-card">
  42. <p style="margin-bottom: 10px">Version: {{ item.version }}</p>
  43. <div
  44. style="margin-bottom: 5px; font-size: 12px"
  45. v-for="(item1, index) in item.remarks"
  46. >
  47. {{ index + 1 }}. {{ item1.text }}
  48. </div>
  49. </div>
  50. </el-timeline-item>
  51. </el-timeline>
  52. </div>
  53. <template #reference>
  54. <el-badge value="new">
  55. <div class="log">新功能日志</div>
  56. </el-badge>
  57. </template>
  58. </el-popover>
  59. <div class="quit" @click="quit">[退出]</div>
  60. </div>
  61. <el-dialog v-model="dialogVisible" title="拍照通知" width="30%">
  62. <el-table :data="tableData[currentTableIndex - 1]" border>
  63. <el-table-column align="center" type="index" />
  64. <el-table-column align="center" property="shipName" label="船名" />
  65. <el-table-column align="center" property="status" label="状态" />
  66. </el-table>
  67. <el-pagination
  68. style="text-align: right; margin-top: 20px"
  69. @current-change="pageChange"
  70. background
  71. layout="prev, pager, next"
  72. :total="total"
  73. >
  74. </el-pagination>
  75. <template #footer>
  76. <span class="dialog-footer">
  77. <el-button type="primary" @click="dialogVisible = false">
  78. 确定
  79. </el-button>
  80. </span>
  81. </template>
  82. </el-dialog>
  83. </div>
  84. </template>
  85. <script>
  86. import store from "../store";
  87. import router from "../router";
  88. import api from "../apis/fetch";
  89. import { onMounted, ref } from "vue";
  90. import { BellFilled } from "@element-plus/icons";
  91. import _ from "lodash";
  92. import { AnonymousLogin, tcb } from "../apis/cloudLogin";
  93. const db = tcb.database();
  94. const v = db.collection("huihenduo_versions");
  95. const __ = db.command;
  96. export default {
  97. components: {
  98. BellFilled,
  99. },
  100. setup() {
  101. let userName = localStorage.staffName;
  102. function quit() {
  103. localStorage.removeItem("staffPhone");
  104. localStorage.removeItem("id");
  105. localStorage.removeItem("status");
  106. localStorage.removeItem("userType");
  107. localStorage.removeItem("staffName");
  108. store.commit("changeLogin", false);
  109. router.push({ path: "/login" });
  110. }
  111. let dialogVisible = ref(false);
  112. let isNewMessage = ref([]);
  113. function isWithinTime(t0 = new Date()) {
  114. let t1 = _.cloneDeep(t0);
  115. let t2 = _.cloneDeep(t0);
  116. t1.setHours(8);
  117. t1.setMinutes(30);
  118. t1.setSeconds(0);
  119. t2.setHours(9);
  120. t2.setMinutes(30);
  121. t2.setSeconds(0);
  122. let t00 = t0.getTime();
  123. let t11 = t1.getTime();
  124. let t22 = t2.getTime();
  125. return t00 > t11 && t00 < t22;
  126. }
  127. function spArr(arr, num) {
  128. //arr是你要分割的数组,num是以几个为一组
  129. let newArr = []; //首先创建一个新的空数组。用来存放分割好的数组
  130. for (let i = 0; i < arr.length; ) {
  131. //注意:这里与for循环不太一样的是,没有i++
  132. newArr.push(arr.slice(i, (i += num)));
  133. }
  134. return newArr;
  135. }
  136. let tableData = ref([]);
  137. let currentTableIndex = ref(1);
  138. let total = ref(0);
  139. function pageChange(c) {
  140. currentTableIndex.value = c;
  141. }
  142. async function getUnphotographNotice() {
  143. let { data } = await api.getUnphotographNotice();
  144. if (data.status == 0) {
  145. for (let i of data.result) {
  146. isNewMessage.value.push({
  147. shipName: i,
  148. status: "未拍照",
  149. });
  150. }
  151. total.value = isNewMessage.value.length;
  152. tableData.value = spArr(isNewMessage.value, 10);
  153. } else {
  154. isNewMessage.value = 0;
  155. }
  156. }
  157. onMounted(() => {
  158. getUnphotographNotice();
  159. setInterval(async () => {
  160. if (isWithinTime()) {
  161. getUnphotographNotice();
  162. }
  163. }, 2 * 60 * 1000);
  164. cloudLogin();
  165. });
  166. let vs = [
  167. {
  168. version: "1.2.13.0",
  169. timer: " 2022/2/9",
  170. remarks: [
  171. "优化船舶轨迹测算算法",
  172. "优化船舶预计到港时间测算算法",
  173. "优化航次状态预测算法",
  174. ],
  175. },
  176. {
  177. version: "1.2.14.0",
  178. timer: " 2022/2/11",
  179. remarks: ["更新保险保单上传接口", "更新装卸单据展示方式"],
  180. },
  181. {
  182. version: "1.3.0.0 ",
  183. timer: "2022/2/11",
  184. remarks: [
  185. "发布浙江物产货主版管理平台",
  186. "发布货损数据采集接口",
  187. "发布货损智能分析报告",
  188. ],
  189. },
  190. {
  191. version: "1.3.4.0 ",
  192. timer: "2022/2/28",
  193. remarks: [
  194. "发布汽车装货记录功能",
  195. "发布单据识别算法功能",
  196. "单据车牌数据、吨位数据拆分功能、生成表报",
  197. "智能化数据自动匹配、自动修正算法",
  198. ],
  199. },
  200. ];
  201. let timelineData = ref([]);
  202. // timelineData.value = vs.reverse();
  203. async function cloudLogin() {
  204. await AnonymousLogin();
  205. getAbledVersions();
  206. }
  207. async function getAbledVersions() {
  208. let res = await v.where({ disabled: false, deleted: __.neq(true) }).get();
  209. timelineData.value = res.data.reverse();
  210. }
  211. const size = 20;
  212. return {
  213. size,
  214. quit,
  215. userName,
  216. isNewMessage,
  217. tableData,
  218. dialogVisible,
  219. currentTableIndex,
  220. total,
  221. pageChange,
  222. timelineData,
  223. };
  224. },
  225. };
  226. </script>
  227. <style scoped>
  228. .header {
  229. width: 100%;
  230. height: 60px;
  231. background: #212029;
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-between;
  235. }
  236. .left,
  237. .right {
  238. display: flex;
  239. align-items: center;
  240. }
  241. .first {
  242. width: 22px;
  243. height: 20px;
  244. margin: 0 22px;
  245. }
  246. .shu {
  247. width: 1px;
  248. height: 60px;
  249. background: #101015;
  250. margin-right: 22px;
  251. }
  252. .logo {
  253. width: 120px;
  254. height: 40px;
  255. }
  256. .title {
  257. font-size: 21px;
  258. font-family: PingFangSC-Regular, PingFang SC;
  259. font-weight: 400;
  260. color: #ffffff;
  261. margin-left: 26px;
  262. }
  263. .user-icon {
  264. width: 18px;
  265. height: 18px;
  266. margin-right: 16px;
  267. }
  268. .user,
  269. .quit,
  270. .log {
  271. font-size: 14px;
  272. font-family: PingFangSC-Medium, PingFang SC;
  273. font-weight: 500;
  274. color: #ffffff;
  275. cursor: pointer;
  276. margin-right: 16px;
  277. }
  278. .log {
  279. margin-right: 4px;
  280. }
  281. .quit {
  282. margin-left: 26px;
  283. }
  284. .log-card p {
  285. font-size: 10px;
  286. }
  287. </style>