HeaderCom.vue 6.8 KB

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