header.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <div class="flex">
  3. <el-popover placement="top" width="300">
  4. <div class="app-flex">
  5. <p
  6. class="appLink"
  7. v-for="app in menuApp"
  8. :key="app.index"
  9. @click="handelMenuAppClick(app, 'app')"
  10. >
  11. {{ app.systemappname }}
  12. </p>
  13. </div>
  14. <div slot="reference" class="search_panel">
  15. <input
  16. @focus="colorWhite = false"
  17. @blur="colorWhite = true"
  18. :placeholder="$t('输入搜索内容')"
  19. v-model="searchValue"
  20. />
  21. <i
  22. class="el-icon-search"
  23. :style="colorWhite ? 'color:#fff' : 'color:#000'"
  24. ></i>
  25. </div>
  26. </el-popover>
  27. <div class="right-operation flex-align-center">
  28. <!-- <div class="weather">
  29. <p>今日天气:{{weather.daily?weather.daily[0].dayText:""}}</p>
  30. <p>{{weather.daily?weather.daily[0].low:""}}℃ ~ {{weather.daily?weather.daily[0].high:""}}℃</p>
  31. </div> -->
  32. <!-- 语言 -->
  33. <!-- <el-dropdown @command="handleCommand">
  34. <span class="el-dropdown-link" style="color: #FFF;">
  35. 语言<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>
  36. </span>
  37. <el-dropdown-menu slot="dropdown">
  38. <el-dropdown-item v-for="item in langusge" :key="item.index" :command="item.languagecode">{{item.languagename}}</el-dropdown-item>
  39. </el-dropdown-menu>
  40. </el-dropdown>-->
  41. <!-- <el-divider direction="vertical"></el-divider>-->
  42. <!-- <el-button size="mint" type="primary" style="background-color:rgb(52 106 145);margin-right: 20px;color: #FFFFFF" v-if="usertype == 1 || usertype == 0" @click="$router.push('/serviceDataScreen')">{{$t(`业务数据大屏`)}}</el-button>-->
  43. <svg
  44. t="1725853431060"
  45. class="icon"
  46. viewBox="0 0 1024 1024"
  47. version="1.1"
  48. xmlns="http://www.w3.org/2000/svg"
  49. p-id="9958"
  50. width="16"
  51. height="16"
  52. >
  53. <path
  54. d="M512 0a512 512 0 1 0 512 512A513.4848 513.4848 0 0 0 512 0z m371.2 262.4a467.968 467.968 0 0 1 76.8 217.6h-256A990.464 990.464 0 0 0 688.0256 307.2a1241.0368 1241.0368 0 0 0 195.1744-44.8zM838.4 204.8a1267.456 1267.456 0 0 1-166.4 38.4 1264.128 1264.128 0 0 0-51.2-166.4 454.1952 454.1952 0 0 1 217.6 128zM384 480a1396.1728 1396.1728 0 0 1 16.0256-166.4c35.2256 3.2256 73.6256 6.4 108.8 6.4 38.4 0 73.6256-3.1744 108.8-6.4a946.2784 946.2784 0 0 1 15.9744 166.4z m256 64a1396.1728 1396.1728 0 0 1-15.9744 166.4c-38.4-3.1744-73.5744-6.4-111.9744-6.4s-73.6256 3.2256-108.8 6.4a946.2784 946.2784 0 0 1-15.9744-166.4zM480 64h64a1058.1504 1058.1504 0 0 1 67.2256 185.6A533.7088 533.7088 0 0 1 512 256c-32 0-64-3.1744-96-3.1744a1089.8944 1089.8944 0 0 1 64-188.8256z m-76.8 12.8a843.6736 843.6736 0 0 0-51.2 166.4A1398.8352 1398.8352 0 0 1 185.6 204.8a454.1952 454.1952 0 0 1 217.6-128zM140.8 262.4A1241.0368 1241.0368 0 0 0 336.0256 307.2a990.464 990.464 0 0 0-15.9744 172.8h-256a455.68 455.68 0 0 1 76.8-217.6z m0 499.2a467.968 467.968 0 0 1-76.8-217.6h256A990.464 990.464 0 0 0 336.0256 716.8a1241.0368 1241.0368 0 0 0-195.2256 44.8zM185.6 819.2a1267.456 1267.456 0 0 1 166.4-38.4 1264.128 1264.128 0 0 0 51.2 166.4 454.1952 454.1952 0 0 1-217.6-128z m358.4 140.8h-64a1058.1504 1058.1504 0 0 1-67.1744-185.6c32-3.1744 64-3.1744 96-3.1744s64 3.2256 96 3.2256a900.7616 900.7616 0 0 1-60.7744 185.6z m76.8-12.8a843.6736 843.6736 0 0 0 51.2-166.4 1398.8352 1398.8352 0 0 1 166.4 38.4 454.1952 454.1952 0 0 1-217.6 128z m262.4-185.6A1241.0368 1241.0368 0 0 0 687.9744 716.8a990.464 990.464 0 0 0 16.0256-172.8h256a455.68 455.68 0 0 1-76.8 217.6z"
  55. fill="#FFFFFF"
  56. p-id="9959"
  57. ></path>
  58. </svg>
  59. <el-dropdown style="margin-left: 5px; margin-right: 30px">
  60. <!-- <el-button type="default" size="small" style="margin-right: 10px;">
  61. {{languagename}}<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>
  62. </el-button>-->
  63. <span class="el-dropdown-link">
  64. <div class="flex">
  65. {{ languagename }}<i class="el-icon-arrow-down el-icon--right"></i>
  66. </div>
  67. </span>
  68. <el-dropdown-menu slot="dropdown">
  69. <el-dropdown-item
  70. v-for="item in langusge"
  71. :key="item.index"
  72. @click.native="i18nChangeLanguage(item.languagecode)"
  73. >{{ item.languagename }}</el-dropdown-item
  74. >
  75. <!-- <el-dropdown-item @click.native="i18nChangeLanguage('EN')">English</el-dropdown-item> -->
  76. </el-dropdown-menu>
  77. </el-dropdown>
  78. <el-dropdown>
  79. <span class="el-dropdown-link">
  80. <div class="flex">
  81. {{ accountInfo.name }}-{{ accountInfo.sitename
  82. }}<i class="el-icon-arrow-down el-icon--right"></i>
  83. </div>
  84. </span>
  85. <el-dropdown-menu
  86. style="width: 200px; text-align: center"
  87. slot="dropdown"
  88. >
  89. <el-dropdown-item
  90. @click.native="$router.push({ path: '/user_center' })"
  91. >{{ $t("个人中心") }}</el-dropdown-item
  92. >
  93. <!-- <el-dropdown-item v-if="canChangeSite" @click.native="$router.replace({path:'/accounts'})">切换账号</el-dropdown-item> -->
  94. <el-dropdown-item
  95. v-for="item in accountList"
  96. :key="item.index"
  97. divided
  98. @click.native="selectAccount(item)"
  99. >
  100. <div class="flex-align-center flex-between">
  101. <p>
  102. <span class="avatar-mini">{{
  103. item.enterprisename
  104. ? item.enterprisename.substr(0, 1)
  105. : item.sitename.substr(0, 1)
  106. }}</span
  107. ><span>{{
  108. item.enterprisename ? item.enterprisename : item.sitename
  109. }}</span>
  110. </p>
  111. <small>{{ item.name }}</small>
  112. </div>
  113. </el-dropdown-item>
  114. <el-dropdown-item divided @click.native="loginOut()">{{
  115. $t("退出登录")
  116. }}</el-dropdown-item>
  117. </el-dropdown-menu>
  118. </el-dropdown>
  119. </div>
  120. </div>
  121. </template>
  122. <script>
  123. import { mapGetters } from "vuex";
  124. import axios from "axios";
  125. import Vue from "vue";
  126. import enLocale from "element-ui/lib/locale/lang/en";
  127. import zhLocale from "element-ui/lib/locale/lang/zh-CN";
  128. import ruLocale from "element-ui/lib/locale/lang/ru-RU";
  129. export default {
  130. data() {
  131. return {
  132. accountInfo: {},
  133. url: "",
  134. weather: {},
  135. searchValue: "",
  136. accountList: [],
  137. colorWhite: true,
  138. langusge: [],
  139. nowType: "ZH",
  140. languagename: "",
  141. usertype : JSON.parse(sessionStorage.getItem('active_account')).usertype
  142. };
  143. },
  144. computed: {
  145. ...mapGetters({
  146. siteinfo: "siteinfo",
  147. menuApp: "menuApp",
  148. }),
  149. canChangeSite() {
  150. let accounts = JSON.parse(sessionStorage.getItem("account_list"));
  151. if (accounts.length > 1) return true;
  152. },
  153. },
  154. methods: {
  155. // 选择登录账号
  156. async selectAccount(item) {
  157. let arr = ["module_info", "active_modules", "folderid"];
  158. arr.forEach((key) => {
  159. sessionStorage.removeItem(key);
  160. });
  161. sessionStorage.setItem("active_account", JSON.stringify(item));
  162. await this.basicData.query_userauth(()=>{
  163. setTimeout(() => {
  164. console.log('33333')
  165. this.$router.go(0);
  166. },1000);
  167. })
  168. this.siteInfos();
  169. this.accountInfo = JSON.parse(sessionStorage.getItem("active_account"));
  170. this.accountList = JSON.parse(
  171. sessionStorage.getItem("account_list")
  172. ).filter((e) => {
  173. return e.siteid !== this.accountInfo.siteid;
  174. });
  175. },
  176. async getWeather() {
  177. const res = await axios.get(this.url);
  178. this.weather = res.data.data;
  179. },
  180. siteInfos() {
  181. this.$store.dispatch("querySiteInfo", {
  182. classname: "webmanage.site.site",
  183. method: "querySite",
  184. content: {},
  185. });
  186. },
  187. loginOut() {
  188. let lang = sessionStorage.getItem("lang");
  189. this.$confirm(this.$t("是否要退出当前账号") + "?", this.$t("提示"), {
  190. confirmButtonText: this.$t("确定"),
  191. cancelButtonText: this.$t("取消"),
  192. type: "warning",
  193. })
  194. .then(() => {
  195. sessionStorage.clear();
  196. sessionStorage.setItem("lang", lang);
  197. this.$router.push("/");
  198. location.reload();
  199. })
  200. .catch((err) => {
  201. console.log(err);
  202. this.$message({
  203. type: "info",
  204. message: this.$t("已取消"),
  205. });
  206. });
  207. },
  208. changeAccount() {
  209. this.$router.push("/accounts");
  210. },
  211. handleCommand(command) {
  212. sessionStorage.setItem("lang", command);
  213. this.basicData.query_userauth().then(() => {
  214. this.$router.go(0);
  215. });
  216. },
  217. //跳转到应用,并设设置激活模块
  218. handelMenuAppClick(app, type) {
  219. let system = JSON.parse(sessionStorage.getItem("module_info"));
  220. let mod = system
  221. .filter((e) => {
  222. return e.systemid === app.systemid;
  223. })[0]
  224. .modules.filter((e) => {
  225. return e.systemmoduleid === app.systemmoduleid;
  226. })[0];
  227. let clickApp = mod.apps.filter((e) => {
  228. return e.systemappid === app.systemappid;
  229. });
  230. sessionStorage.setItem("active_modules", JSON.stringify(mod));
  231. this.$emit(
  232. "getModules",
  233. system.filter((e) => {
  234. return e.systemid === app.systemid;
  235. })[0].modules,
  236. type
  237. );
  238. this.$store.dispatch("setActiveApp", {
  239. name: app.systemappname,
  240. app: clickApp[0],
  241. val: this.searchValue,
  242. });
  243. this.$router.push({ path: clickApp[0].path });
  244. },
  245. async languagelist() {
  246. const res = await this.$api.requested({
  247. id: 10026401,
  248. });
  249. this.langusge = res.data;
  250. this.nowType = sessionStorage.getItem("lang")
  251. ? sessionStorage.getItem("lang")
  252. : "ZH";
  253. },
  254. async i18nChangeLanguage(type) {
  255. sessionStorage.setItem("lang", type);
  256. await this.basicData.query_userauth();
  257. this.$router.go(0);
  258. },
  259. async qusetLanguage() {
  260. this.nowType = sessionStorage.getItem('lang').toUpperCase()
  261. const res = await this.$api.requested({
  262. id: 2024062809072801,
  263. content: {
  264. languagecode: this.nowType,
  265. },
  266. });
  267. switch (this.nowType) {
  268. case "EN":
  269. Vue.config.lang = "en";
  270. Vue.locale("en", Object.assign(enLocale, res.data.EN));
  271. break;
  272. case "RU":
  273. Vue.config.lang = "ru-RU";
  274. Vue.locale("ru-RU", Object.assign(ruLocale, res.data.RU));
  275. break;
  276. default:
  277. Vue.config.lang = "zh-cn";
  278. Vue.locale("zh-cn", Object.assign(zhLocale));
  279. break;
  280. }
  281. this.languagename = this.langusge.filter(
  282. (e) => e.languagecode == this.nowType
  283. )[0].languagename;
  284. console.log(this.languagename,'语言名称')
  285. },
  286. },
  287. mounted() {
  288. this.siteInfos();
  289. this.languagelist();
  290. this.accountInfo = JSON.parse(sessionStorage.getItem("active_account"));
  291. this.accountList = JSON.parse(
  292. sessionStorage.getItem("account_list")
  293. ).filter((e) => {
  294. return e.siteid !== this.accountInfo.siteid;
  295. });
  296. this.basicData.querySite_Parameter();
  297. this.qusetLanguage();
  298. },
  299. };
  300. </script>
  301. <style>
  302. .el-header {
  303. height: 50px !important;
  304. }
  305. .search_panel {
  306. position: relative;
  307. }
  308. .search_panel i {
  309. position: absolute;
  310. right: 0px;
  311. height: 30px;
  312. width: 30px;
  313. text-align: center;
  314. line-height: 30px;
  315. color: #333;
  316. }
  317. .search_panel input {
  318. background: rgba(255, 255, 255, 0.2);
  319. height: 30px;
  320. line-height: 30px;
  321. width: 300px;
  322. padding: 0 30px 0 20px;
  323. border: none;
  324. border-radius: 30px;
  325. color: #fff;
  326. outline: none;
  327. }
  328. .search_panel input::placeholder {
  329. color: #fff;
  330. }
  331. .search_panel input:focus {
  332. background: #fff;
  333. color: #333;
  334. }
  335. .search_panel input:focus::placeholder {
  336. color: #333;
  337. }
  338. </style>
  339. <style scoped>
  340. .flex {
  341. display: flex;
  342. align-items: center;
  343. justify-content: space-between;
  344. background: none;
  345. color: #fff;
  346. }
  347. .right-operation {
  348. padding: 0 20px;
  349. }
  350. .search_panel {
  351. margin: 16px 0;
  352. }
  353. .weather {
  354. font-size: 12px;
  355. margin-right: 16px;
  356. color: #f1f2f3;
  357. transition: 0.2s linear;
  358. border-radius: 4px;
  359. padding: 5px 40px;
  360. }
  361. .weather:hover {
  362. background-color: rgba(255, 255, 255, 0.2) !important;
  363. }
  364. .appLink {
  365. padding: 2px 5px;
  366. border: 1px solid #f1f2f3;
  367. border-radius: 5px;
  368. margin-bottom: 10px;
  369. margin-left: 5px;
  370. cursor: pointer;
  371. font-size: 12px;
  372. }
  373. .app-flex {
  374. display: flex;
  375. align-items: center;
  376. flex-wrap: wrap;
  377. }
  378. .avatar-mini {
  379. display: inline-block;
  380. position: relative;
  381. height: 20px;
  382. width: 20px;
  383. line-height: 20px;
  384. text-align: center;
  385. margin-right: 5px;
  386. color: #fff;
  387. font-size: 12px;
  388. font-weight: 500;
  389. border-radius: 100%;
  390. background: #3874f6;
  391. }
  392. .inactive {
  393. background: red !important;
  394. }
  395. </style>