Header.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. <div class="cf fs20 mr30">
  7. 欢迎来到 {{ shippingCompany }} 智慧远程海事管理系统
  8. </div>
  9. <el-select
  10. @change="selectCompany"
  11. v-model="store.state.currentCompany"
  12. value-key="key"
  13. style="width: 240px; text-align: center"
  14. v-if="store.state.isSuperuser == 1"
  15. >
  16. <el-option
  17. v-for="item in store.state.companySelect"
  18. :key="item.key"
  19. :label="item.value"
  20. :value="item"
  21. />
  22. </el-select>
  23. <!-- <img class="logo" src="../assets/white-logo.png" alt="" />
  24. <div class="ml20" style="color: #fff; font-size: 18px">
  25. version:{{ timelineData[0]?.version }}
  26. </div> -->
  27. </div>
  28. <div class="right">
  29. <!-- <div
  30. @click="dialogVisible = true"
  31. class="pointer"
  32. style="padding-top: 6px"
  33. >
  34. <el-badge
  35. :hidden="isNewMessage.length == 0"
  36. :value="isNewMessage.length"
  37. class="mr30"
  38. >
  39. <el-icon :size="size" color="#00a9dc">
  40. <BellFilled />
  41. </el-icon>
  42. </el-badge>
  43. </div> -->
  44. <img class="user-icon" src="../assets/user.png" alt="" />
  45. <div class="user">{{ loginName }}</div>
  46. <!-- <el-popover placement="bottom" trigger="hover" :width="280">
  47. <div
  48. style="
  49. width: 100%;
  50. height: 60vh;
  51. overflow-y: auto;
  52. padding-right: 10px;
  53. margin-right: 10px;
  54. "
  55. >
  56. <el-timeline>
  57. <el-timeline-item
  58. v-for="item in timelineData"
  59. center
  60. :timestamp="item.timer"
  61. placement="top"
  62. :key="item"
  63. >
  64. <div class="log-card">
  65. <p style="margin-bottom: 10px">Version: {{ item.version }}</p>
  66. <div
  67. style="margin-bottom: 5px; font-size: 12px"
  68. v-for="(item1, index) in item.remarks"
  69. :key="item1"
  70. >
  71. {{ index + 1 }}. {{ item1.text }}
  72. </div>
  73. </div>
  74. </el-timeline-item>
  75. </el-timeline>
  76. </div>
  77. <template #reference>
  78. <el-badge value="new">
  79. <div class="log">新功能日志</div>
  80. </el-badge>
  81. </template>
  82. </el-popover> -->
  83. <div class="quit" @click="quit">[退出]</div>
  84. </div>
  85. <el-dialog v-model="dialogVisible" title="拍照通知" width="30%">
  86. <el-table :data="tableData[currentTableIndex - 1]" border>
  87. <el-table-column align="center" type="index" />
  88. <el-table-column align="center" property="shipName" label="船名" />
  89. <el-table-column align="center" property="status" label="状态" />
  90. </el-table>
  91. <el-pagination
  92. style="text-align: right; margin-top: 20px"
  93. @current-change="pageChange"
  94. background
  95. layout="prev, pager, next"
  96. :total="total"
  97. ></el-pagination>
  98. <template #footer>
  99. <span class="dialog-footer">
  100. <el-button type="primary" @click="dialogVisible = false">
  101. 确定
  102. </el-button>
  103. </span>
  104. </template>
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <script setup>
  109. import router from "../router";
  110. import store from "../store";
  111. import api from "../apis/fetch";
  112. import { onMounted, ref } from "vue";
  113. import { BellFilled } from "@element-plus/icons";
  114. import _ from "lodash";
  115. // import { AnonymousLogin, tcb } from "../apis/cloudLogin";
  116. // const db = tcb.database();
  117. // const v = db.collection("huihenduo_versions");
  118. // const __ = db.command;
  119. let userName = localStorage.staffName;
  120. function quit() {
  121. localStorage.clear();
  122. store.state.isSuperuser = 0;
  123. store.state.currentCompany = "";
  124. store.commit("changeLogin", false);
  125. router.push({ path: "/login" });
  126. }
  127. let dialogVisible = ref(false);
  128. let isNewMessage = ref([]);
  129. function isWithinTime(t0 = new Date()) {
  130. let t1 = _.cloneDeep(t0);
  131. let t2 = _.cloneDeep(t0);
  132. t1.setHours(8);
  133. t1.setMinutes(30);
  134. t1.setSeconds(0);
  135. t2.setHours(9);
  136. t2.setMinutes(30);
  137. t2.setSeconds(0);
  138. let t00 = t0.getTime();
  139. let t11 = t1.getTime();
  140. let t22 = t2.getTime();
  141. return t00 > t11 && t00 < t22;
  142. }
  143. function spArr(arr, num) {
  144. //arr是你要分割的数组,num是以几个为一组
  145. let newArr = []; //首先创建一个新的空数组。用来存放分割好的数组
  146. for (let i = 0; i < arr.length; ) {
  147. //注意:这里与for循环不太一样的是,没有i++
  148. newArr.push(arr.slice(i, (i += num)));
  149. }
  150. return newArr;
  151. }
  152. let tableData = ref([]);
  153. let currentTableIndex = ref(1);
  154. let total = ref(0);
  155. function pageChange(c) {
  156. currentTableIndex.value = c;
  157. }
  158. async function getUnphotographNotice() {
  159. let { data } = await api.getUnphotographNotice();
  160. if (data.status == 0) {
  161. for (let i of data.result) {
  162. isNewMessage.value.push({
  163. shipName: i,
  164. status: "未拍照",
  165. });
  166. }
  167. total.value = isNewMessage.value.length;
  168. tableData.value = spArr(isNewMessage.value, 10);
  169. } else {
  170. isNewMessage.value = 0;
  171. }
  172. }
  173. let shippingCompany = ref("");
  174. let loginName = ref("");
  175. onMounted(() => {
  176. // getUnphotographNotice();
  177. // setInterval(async () => {
  178. // if (isWithinTime()) {
  179. // getUnphotographNotice();
  180. // }
  181. // }, 2 * 60 * 1000);
  182. // cloudLogin();
  183. shippingCompany.value = localStorage.shippingCompany;
  184. loginName.value = localStorage.loginName;
  185. if (localStorage.isSuperuser == 1 && store.state.companySelect.length == 0) {
  186. store.dispatch("getShippingCompanySelect", localStorage.manageId);
  187. }
  188. });
  189. let timelineData = ref([]);
  190. async function cloudLogin() {
  191. await AnonymousLogin();
  192. getAbledVersions();
  193. }
  194. async function getAbledVersions() {
  195. let { data } = await v
  196. .aggregate()
  197. .match({ deleted: __.neq(true) })
  198. .sort({
  199. createTime: -1,
  200. })
  201. .limit(10)
  202. .end();
  203. timelineData.value = data;
  204. }
  205. const size = 20;
  206. function selectCompany(e) {
  207. localStorage.currentCompany = JSON.stringify(e);
  208. router.go(0);
  209. }
  210. </script>
  211. <style scoped>
  212. .header {
  213. width: 100%;
  214. height: 60px;
  215. background: #212029;
  216. display: flex;
  217. align-items: center;
  218. justify-content: space-between;
  219. }
  220. .left,
  221. .right {
  222. display: flex;
  223. align-items: center;
  224. }
  225. .first {
  226. width: 22px;
  227. height: 20px;
  228. margin: 0 22px;
  229. }
  230. .shu {
  231. width: 1px;
  232. height: 60px;
  233. background: #101015;
  234. margin-right: 22px;
  235. }
  236. .logo {
  237. width: 120px;
  238. height: 40px;
  239. }
  240. .title {
  241. font-size: 21px;
  242. font-family: PingFangSC-Regular, PingFang SC;
  243. font-weight: 400;
  244. color: #ffffff;
  245. margin-left: 26px;
  246. }
  247. .user-icon {
  248. width: 18px;
  249. height: 18px;
  250. margin-right: 16px;
  251. }
  252. .user,
  253. .quit,
  254. .log {
  255. font-size: 14px;
  256. font-family: PingFangSC-Medium, PingFang SC;
  257. font-weight: 500;
  258. color: #ffffff;
  259. cursor: pointer;
  260. margin-right: 16px;
  261. }
  262. .log {
  263. margin-right: 4px;
  264. }
  265. .quit {
  266. margin-left: 26px;
  267. }
  268. .log-card p {
  269. font-size: 10px;
  270. }
  271. </style>