You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

422 lines
13 KiB

3 years ago
2 years ago
3 years ago
  1. <template>
  2. <nav class="site-navbar" :class="'site-navbar--' + navbarLayoutType">
  3. <div class="site-navbar__header">
  4. <!-- @click="$router.push({ name: 'home' })"-->
  5. <h1 class="site-navbar__brand">
  6. <el-menu
  7. class="site-navbar__menu"
  8. mode="horizontal">
  9. <el-menu-item class="site-navbar__switch" index="0" @click="sidebarFold = !sidebarFold">
  10. <icon-svg name="zhedie"></icon-svg>
  11. </el-menu-item>
  12. </el-menu>
  13. <a class="site-navbar__brand-lg" href="javascript:;">旭捷-MES</a>
  14. <a class="site-navbar__brand-mini" href="javascript:;">{{pageLanguage.abbreviation}}</a>
  15. </h1>
  16. </div>
  17. <div class="site-navbar__body clearfix">
  18. <el-menu
  19. class="site-navbar__menu site-navbar__menu--right"
  20. mode="horizontal">
  21. <el-menu-item class="site-navbar__avatar" index="2">
  22. <span>{{siteNow}}</span>
  23. </el-menu-item>
  24. <!-- <el-menu-item class="site-navbar__avatar" index="2">-->
  25. <!-- <span @click="favoriteFunction()">-->
  26. <!-- <icon-svg :name="favorite?'xiangqufill':'xiangqu'"></icon-svg>-->
  27. <!-- </span>-->
  28. <!-- </el-menu-item>-->
  29. <!-- <el-menu-item class="site-navbar__avatar" index="2">-->
  30. <!-- <span style=" color: #909399;" @click="helpFileList()">-->
  31. <!-- 帮助-->
  32. <!-- &lt;!&ndash; <icon-svg name="help" style="width: 25px;height: 25px;margin-top: 5px"></icon-svg>&ndash;&gt;-->
  33. <!-- </span>-->
  34. <!-- </el-menu-item>-->
  35. <el-submenu index="3">
  36. <template slot="title">{{ pageLanguage.setting }}</template>
  37. <!-- <el-submenu index="2-1">-->
  38. <!-- <template slot="title">{{pageLanguage.languageSetting}}</template>-->
  39. <!-- <el-menu-item index="2-1-1" :key="index" :value="item.languageCode" v-for="(item,index) in languageList "-->
  40. <!-- @click.native="switch_the_language(item.languageCode)">{{item.languageName}}-->
  41. <!-- </el-menu-item>-->
  42. <!-- </el-submenu>-->
  43. <el-submenu index="2-2">
  44. <template slot="title">{{ pageLanguage.userSetting }}</template>
  45. <el-menu-item index="2-2-1" @click.native="updatePasswordHandle()">{{ pageLanguage.updatePassword }}
  46. </el-menu-item>
  47. <!-- <el-menu-item index="2-2-2" @click.native="updateLanguageHandle()">{{pageLanguage.updateDefaultLanguage}}-->
  48. <!-- </el-menu-item>-->
  49. </el-submenu>
  50. <el-menu-item index="2-3" @click="$router.push({ name: 'theme' })">{{ pageLanguage.cssSetting }}
  51. </el-menu-item>
  52. <!-- <el-menu-item index="2-4" @click="printList()">{{ pageLanguage.printSetting }}</el-menu-item>-->
  53. </el-submenu>
  54. <el-menu-item class="site-navbar__avatar" index="4">
  55. <el-dropdown :show-timeout="0" placement="bottom">
  56. <span class="el-dropdown-link">
  57. <img src="~@/assets/img/avatar.png" :alt="userName">{{ userName }}
  58. </span>
  59. <el-dropdown-menu slot="dropdown">
  60. <el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item>
  61. </el-dropdown-menu>
  62. </el-dropdown>
  63. </el-menu-item>
  64. </el-menu>
  65. </div>
  66. <!-- 弹窗, 修改密码 -->
  67. <update-password v-if="updatePassowrdVisible" ref="updatePassowrd"></update-password>
  68. <!-- 弹窗, 修改默认语言 -->
  69. <update-language v-if="updateLanguageVisible" ref="updateLanguage"></update-language>
  70. <!-- 文件列表 -->
  71. <FileListView ref="fileListView" v-if="helpFileVisible"></FileListView>
  72. </nav>
  73. </template>
  74. <script>
  75. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  76. import UpdatePassword from './main-navbar-update-password'
  77. import UpdateLanguage from './main-navbar-update-language'
  78. import {clearLoginInfo} from '@/utils'
  79. import FileListView from './modules/common/file-list-view'
  80. import {
  81. searchFunctionButtonList,
  82. saveButtonList,
  83. searchSysLanguage,
  84. } from "@/api/sysLanguage.js"
  85. import pubsub from 'pubsub-js'
  86. import {
  87. getSiteData,
  88. } from "@/api/base/site.js"
  89. export default {
  90. data() {
  91. return {
  92. siteNow:'',
  93. updatePassowrdVisible: false,
  94. updateLanguageVisible: false,
  95. helpFileVisible: false,
  96. favorite: false, // 是否收藏
  97. printListVisible: false,
  98. message: this.$t('language.name'),
  99. languageList: [],
  100. pageLanguage: {
  101. XjSysManage: '旭捷管理系统',
  102. abbreviation: '旭捷',
  103. setting: '设置',
  104. languageSetting: '语言设置',
  105. userSetting: '用户设置',
  106. updatePassword: '修改密码',
  107. updateDefaultLanguage: '修改默认语言',
  108. cssSetting: '主提设置',
  109. printSetting: '打印设置',
  110. },
  111. // 导出 end
  112. pageLanguageList: [
  113. {
  114. functionId: "systemInformation",
  115. languageValue: '旭捷管理系统',
  116. objectId: 'XjSysManage',
  117. objectType: "label",
  118. tableId: "systemInformation"
  119. },
  120. {
  121. functionId: "systemInformation",
  122. languageValue: '首页',
  123. objectId: 'homePage',
  124. objectType: "label",
  125. tableId: "systemInformation"
  126. },
  127. {
  128. functionId: "systemInformation",
  129. languageValue: '旭捷',
  130. objectId: 'abbreviation',
  131. objectType: "label",
  132. tableId: "systemInformation"
  133. },
  134. {
  135. functionId: "systemInformation",
  136. languageValue: '设置',
  137. objectId: 'setting',
  138. objectType: "label",
  139. tableId: "systemInformation"
  140. },
  141. {
  142. functionId: "systemInformation",
  143. languageValue: '语言设置',
  144. objectId: 'languageSetting',
  145. objectType: "label",
  146. tableId: "systemInformation"
  147. },
  148. {
  149. functionId: "systemInformation",
  150. languageValue: '用户设置',
  151. objectId: 'userSetting',
  152. objectType: "label",
  153. tableId: "systemInformation"
  154. },
  155. {
  156. functionId: "systemInformation",
  157. languageValue: '修改密码',
  158. objectId: 'updatePassword',
  159. objectType: "label",
  160. tableId: "systemInformation"
  161. },
  162. {
  163. functionId: "systemInformation",
  164. languageValue: '修改用户语言',
  165. objectId: 'updateDefaultLanguage',
  166. objectType: "label",
  167. tableId: "systemInformation"
  168. },
  169. {
  170. functionId: "systemInformation",
  171. languageValue: '主题设置',
  172. objectId: 'cssSetting',
  173. objectType: "label",
  174. tableId: "systemInformation"
  175. },
  176. {
  177. functionId: "systemInformation",
  178. languageValue: '打印设置',
  179. objectId: 'printSetting',
  180. objectType: "label",
  181. tableId: "systemInformation"
  182. }
  183. ],
  184. pending: {
  185. pendingReview: 0,
  186. pendingSum: 0,
  187. },
  188. queryToolReview: {
  189. site: this.$store.state.user.site,
  190. userId: this.$store.state.user.name,
  191. strUserId: this.$store.state.user.id,
  192. },
  193. toolReviewTimer: null,
  194. }
  195. },
  196. watch: {
  197. pending: {
  198. deep: true,
  199. handler: function (newV, oldV) {
  200. this.pending.pendingSum = this.pending.pendingReview
  201. }
  202. },
  203. },
  204. components: {
  205. UpdatePassword,
  206. UpdateLanguage,
  207. FileListView,
  208. },
  209. computed: {
  210. navbarLayoutType: {
  211. get() {
  212. return this.$store.state.common.navbarLayoutType
  213. }
  214. },
  215. sidebarFold: {
  216. get() {
  217. return this.$store.state.common.sidebarFold
  218. },
  219. set(val) {
  220. this.$store.commit('common/updateSidebarFold', val)
  221. }
  222. },
  223. mainTabs: {
  224. get() {
  225. return this.$store.state.common.mainTabs
  226. },
  227. set(val) {
  228. this.$store.commit('common/updateMainTabs', val)
  229. }
  230. },
  231. userName: {
  232. get() {
  233. return this.$store.state.user.userDisplay
  234. }
  235. }
  236. },
  237. activated() {
  238. },
  239. mounted() {
  240. pubsub.subscribe('favorite', (msgName, data) => {
  241. this.favoriteIsOk()
  242. })
  243. },
  244. beforeDestroy() {
  245. },
  246. methods: {
  247. // 打印机列表
  248. printList() {
  249. this.printListVisible = true;
  250. this.$nextTick(() => {
  251. this.$refs.userPrintList.init()
  252. })
  253. },
  254. // 帮助文档列表
  255. helpFileList() {
  256. let fileMappingDto = {
  257. fileId: '',
  258. fileType: '功能帮助文档',
  259. orderRef1: this.$route.meta.menuId,
  260. orderRef2: '',
  261. orderRef3: '',
  262. }
  263. this.helpFileVisible = true;
  264. this.$nextTick(() => {
  265. this.$refs.fileListView.init(fileMappingDto)
  266. })
  267. },
  268. // 获取多语言列表
  269. getLanguageList() {
  270. searchSysLanguage({languageCode: this.$i18n.locale}).then(({data}) => {
  271. this.languageList = data.rows
  272. })
  273. },
  274. // 获取页面多语言数据
  275. getFunctionButtonList() {
  276. let queryButton = {
  277. functionId: 'systemInformation',
  278. tableId: 'systemInformation',
  279. languageCode: this.$i18n.locale,
  280. objectType: 'label'
  281. }
  282. searchFunctionButtonList(queryButton).then(({data}) => {
  283. if (data.code === 0) {
  284. this.pageLanguage = data.data
  285. } else {
  286. saveButtonList(this.pageLanguageList).then(({data}) => {
  287. this.getFunctionButtonList()
  288. })
  289. }
  290. })
  291. },
  292. // 注3:增加语言切换函数
  293. switch_the_language(val) {
  294. localStorage.setItem('locale', val)
  295. location.reload()
  296. },
  297. // 修改密码
  298. updatePasswordHandle() {
  299. this.updatePassowrdVisible = true
  300. this.$nextTick(() => {
  301. this.$refs.updatePassowrd.init()
  302. })
  303. },
  304. // 修改用户默认语言
  305. updateLanguageHandle() {
  306. this.updateLanguageVisible = true
  307. this.$nextTick(() => {
  308. this.$refs.updateLanguage.init()
  309. })
  310. },
  311. // 退出
  312. logoutHandle() {
  313. this.$confirm(`确定进行[退出]操作?`, '提示', {
  314. confirmButtonText: '确定',
  315. cancelButtonText: '取消',
  316. type: 'warning'
  317. }).then(() => {
  318. this.$http({
  319. url: this.$http.adornUrl('/sys/logout'),
  320. method: 'post',
  321. data: this.$http.adornData()
  322. }).then(({data}) => {
  323. if (data && data.code === 0) {
  324. clearLoginInfo()
  325. this.$router.push({name: 'login'})
  326. }
  327. })
  328. }).catch(() => {
  329. })
  330. },
  331. // 校验用户是否收藏
  332. favoriteIsOk() {
  333. let userFavorite = {
  334. userId: this.$store.state.user.id,
  335. languageCode: this.$i18n.locale
  336. }
  337. userFavoriteList(userFavorite).then(({data}) => {
  338. let size = data.list.filter(item => item.menuId == this.$route.meta.menuId).length;
  339. if (size > 0) {
  340. this.favorite = true
  341. } else {
  342. this.favorite = false
  343. }
  344. })
  345. },
  346. // 收藏 OR 取消收藏
  347. async favoriteFunction() {
  348. let userFavorite = {
  349. userId: this.$store.state.user.id,
  350. functionId: this.$route.meta.menuId,
  351. }
  352. if (this.favorite) {
  353. // 取消收藏
  354. await this.$confirm(`确定取消收藏`, '提示', {
  355. confirmButtonText: '确定',
  356. cancelButtonText: '取消',
  357. type: 'warning'
  358. }).then(() => {
  359. removeUserFavorite(userFavorite).then(({data}) => {
  360. this.$message.success(data.msg)
  361. this.favorite = false
  362. pubsub.publish('userFavorite')
  363. })
  364. })
  365. } else {
  366. // 收藏
  367. await saveUserFavorite(userFavorite).then(({data}) => {
  368. this.$message.success(data.msg)
  369. this.favorite = true
  370. pubsub.publish('userFavorite')
  371. })
  372. }
  373. },
  374. getNowSite(){
  375. let data={};
  376. getSiteData(data).then(({data}) => {
  377. if(data.rows.length>0){
  378. for (let i = 0; i <data.rows.length ; i++) {
  379. if(data.rows[i].siteID==this.$store.state.user.site){
  380. this.siteNow="当前工厂:"+data.rows[i].siteID+" - "+data.rows[i].siteName
  381. }
  382. }
  383. }
  384. })
  385. }
  386. },
  387. created() {
  388. this.getLanguageList()
  389. this.getFunctionButtonList()
  390. this. getNowSite()
  391. }
  392. }
  393. </script>
  394. <style lang="scss">
  395. .icon-svg {
  396. width: 2em;
  397. }
  398. .el-menu--collapse .el-menu .el-submenu, .el-menu--popup, .el-menu-item {
  399. min-width: 50px !important;
  400. }
  401. .site-navbar__brand-lg, .site-navbar__brand-mini {
  402. margin: 0 5px;
  403. color: #fff;
  404. margin-left: -45px;
  405. }
  406. .el-menu--horizontal > .el-menu-item {
  407. color: #3b4249;
  408. }
  409. </style>