HeaderCom.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="header">
  3. <div class="header-logo">
  4. <!-- <img src="@/assets/datang.png" slot="reference" />
  5. <h2 class="conversion">中国大唐集团公司</h2> -->
  6. </div>
  7. <div class="personalCenter">
  8. <div id="header-page-tools" class="header-page-tools"></div>
  9. <!-- <p class="current-time">{{ currentDate }}</p> -->
  10. <el-popover
  11. placement="bottom"
  12. width="220"
  13. trigger="click"
  14. style="cursor: pointer"
  15. >
  16. <img src="@/assets/portrait.png" slot="reference" />
  17. <div>
  18. <div class="cursor-pointer boxmini">
  19. <p>
  20. 账号:{{
  21. ($store.state.auth &&
  22. $store.state.auth.userInfo &&
  23. $store.state.auth.userInfo.userInfo &&
  24. $store.state.auth.userInfo.userInfo.loginName) ||
  25. ""
  26. }}
  27. </p>
  28. </div>
  29. <el-divider></el-divider>
  30. <div class="cursor-pointer boxmini">
  31. <p>
  32. 角色:{{
  33. ($store.state.auth &&
  34. $store.state.auth.userInfo &&
  35. $store.state.auth.userInfo.role &&
  36. $store.state.auth.userInfo.role.roleDescription) ||
  37. ""
  38. }}
  39. </p>
  40. </div>
  41. <el-divider></el-divider>
  42. <div class="cursor-pointer boxmini">
  43. <p>主题切换:</p>
  44. <el-select
  45. v-model="currentTheme"
  46. placeholder="Select theme"
  47. @change="changeTheme"
  48. size="mini"
  49. >
  50. <el-option
  51. v-for="(item, index) in colorData"
  52. :key="index"
  53. :label="item.lable"
  54. :value="item.value"
  55. >
  56. <span style="float: left">{{ item.lable }}</span>
  57. <el-color-picker
  58. disabled
  59. v-model="item.color"
  60. size="mini"
  61. style="float: right"
  62. >
  63. </el-color-picker>
  64. </el-option>
  65. </el-select>
  66. </div>
  67. <el-divider></el-divider>
  68. <div class="cursor-pointer boxmini">
  69. <p>图表主题:</p>
  70. <el-select
  71. size="mini"
  72. v-model="color1"
  73. @change="updateChartColor"
  74. placeholder="选择配色方案"
  75. style="width: 200px"
  76. >
  77. <el-option
  78. v-for="(scheme, index) in colorSchemes"
  79. :key="index"
  80. :label="scheme.label"
  81. :value="scheme.colors"
  82. >
  83. <!-- :style="getOptionStyle(scheme.colors)" -->
  84. <span
  85. v-for="color in scheme.colors.slice(0, 8)"
  86. :style="{
  87. background: color,
  88. width: '20px',
  89. height: '20px',
  90. display: 'inline-block',
  91. }"
  92. ></span>
  93. </el-option>
  94. </el-select>
  95. </div>
  96. <el-divider></el-divider>
  97. <div class="cursor-pointer boxmini" @click="skip(1)">
  98. <p class="logout">退出登录</p>
  99. </div>
  100. </div>
  101. </el-popover>
  102. </div>
  103. </div>
  104. </template>
  105. <script>
  106. import { userLogout } from "@/api/system";
  107. import { mapActions } from "vuex";
  108. import { colorSchemes } from "@/views/overview/js/colors";
  109. export default {
  110. data() {
  111. return {
  112. color1: [], // 默认颜色
  113. // 配色方案列表(每个方案是一个颜色数组)
  114. colorSchemes: [...colorSchemes],
  115. currentDate: "",
  116. currentTheme: this.$store.state.themes.theme,
  117. colorData: [
  118. // { lable: "科技蓝", value: "tech-blue", color: "#1890ff" },
  119. { lable: "黄色", value: "light", color: "#82780ccf" },
  120. { lable: "深色", value: "dark", color: "#607d8b" },
  121. { lable: "绿色", value: "green", color: "#008080" },
  122. { lable: "蓝色", value: "blue", color: "#1B3B7F" },
  123. ],
  124. };
  125. },
  126. components: {},
  127. watch: {
  128. "$store.state.themes.theme": {
  129. handler(newTheme) {
  130. this.currentTheme = newTheme;
  131. },
  132. immediate: true,
  133. },
  134. },
  135. mounted() {
  136. this.updateCurrentDateTime();
  137. setInterval(this.updateCurrentDateTime, 1000);
  138. },
  139. methods: {
  140. ...mapActions("themes", ["themeChange", "switchTheme"]),
  141. updateChartColor() {
  142. // console.log("this.color1", this.color1);
  143. this.themeChange(this.color1);
  144. },
  145. // 根据配色方案设置每个选项的样式
  146. getOptionStyle(scheme) {
  147. return {
  148. background: `linear-gradient(to right, ${scheme
  149. .slice(0, 8)
  150. .join(", ")})`,
  151. color: "#fff",
  152. height: "30px",
  153. lineHeight: "30px",
  154. borderRadius: "0px",
  155. };
  156. },
  157. changeTheme(theme) {
  158. this.$store.dispatch("themes/switchTheme", theme);
  159. },
  160. updateCurrentDateTime() {
  161. const now = new Date();
  162. const year = now.getFullYear();
  163. const month = (now.getMonth() + 1).toString().padStart(2, "0");
  164. const day = now.getDate().toString().padStart(2, "0");
  165. const hours = now.getHours().toString().padStart(2, "0");
  166. const minutes = now.getMinutes().toString().padStart(2, "0");
  167. const seconds = now.getSeconds().toString().padStart(2, "0");
  168. // 设置当前时间数据
  169. this.currentDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  170. },
  171. skip() {
  172. this.$emit("setLoding", true);
  173. userLogout({
  174. phone: this.$store.state.auth.userInfo.userInfo.userPhone,
  175. })
  176. .then((res) => {
  177. this.$router.push("/login");
  178. this.$store.commit("auth/RESET_USER_STATE");
  179. })
  180. .catch(() => {
  181. this.$emit("setLoding", false);
  182. });
  183. },
  184. },
  185. };
  186. </script>
  187. <style lang="scss" scoped>
  188. .header {
  189. display: flex;
  190. justify-content: space-between;
  191. align-items: center;
  192. height: 60px;
  193. padding: 0 10px;
  194. .header-logo {
  195. display: flex;
  196. justify-content: space-between;
  197. align-items: center;
  198. h2 {
  199. padding-left: 10px;
  200. font-weight: 600;
  201. }
  202. img {
  203. width: 30px;
  204. height: 30px;
  205. }
  206. }
  207. .el-breadcrumb {
  208. font-size: 16px;
  209. font-weight: 600;
  210. color: rgb(143, 143, 143);
  211. flex: 1;
  212. }
  213. .personalCenter {
  214. display: flex;
  215. align-items: center;
  216. color: var(--text-cyan, #52c8f2);
  217. .header-page-tools {
  218. display: flex;
  219. align-items: center;
  220. margin-right: 16px;
  221. &:empty {
  222. display: none;
  223. margin-right: 0;
  224. }
  225. }
  226. .current-time {
  227. font-size: 12px;
  228. padding-right: 10px;
  229. }
  230. .remind {
  231. cursor: pointer;
  232. margin-right: 24px;
  233. }
  234. }
  235. }
  236. .boxmini {
  237. display: flex;
  238. p {
  239. font-size: 14px;
  240. font-weight: 600;
  241. width: 120px !important;
  242. }
  243. .logout {
  244. color: #ff0000;
  245. text-align: center;
  246. width: 100%;
  247. }
  248. }
  249. .el-divider--horizontal {
  250. margin: 5px 0;
  251. }
  252. ::v-deep .el-color-picker__mask {
  253. background-color: rgba(255, 255, 255, 0) !important;
  254. }
  255. </style>