![]()
@@ -11,11 +27,11 @@
- 主页
+ {{ $t('common.home') }}
- 退出
+ {{ $t('common.logout') }}
@@ -41,6 +57,7 @@
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
+import { setLocale, SUPPORT_LOCALES } from '@/lang'
// import { initApproval, initApprovalOffline } from '@/api/PurchasingCenter/FundApproval'
// import { searchUrgentItem } from '@/api/ManufacturingCenter/InitialProduction'
// import { searchTable1 as searchTableInvoice } from '@/api/PurchasingCenter/InvoiceSettlementApprove'
@@ -92,7 +109,11 @@ export default {
PurchaseContractSearch: null,
DeliveryNotice: null,
ScrapReplenishment: null,
- OrderConfirmationShipment: null
+ OrderConfirmationShipment: null,
+ localeOptions: [
+ { value: 'zh-CN', label: '中文' },
+ { value: 'en-US', label: 'English' }
+ ]
}
},
computed: {
@@ -103,7 +124,14 @@ export default {
'id',
'token',
'token'
- ])
+ ]),
+ currentLocale() {
+ return this.$i18n.locale
+ },
+ currentLocaleLabel() {
+ const current = this.localeOptions.find(item => item.value === this.currentLocale)
+ return current ? current.label : this.$t('common.language')
+ }
},
created() {
// this.showOrder()
@@ -433,6 +461,11 @@ export default {
toggleSideBar() {
this.$store.dispatch('ToggleSideBar')
},
+ changeLanguage(locale) {
+ if (SUPPORT_LOCALES.indexOf(locale) === -1 || locale === this.currentLocale) return
+ setLocale(locale)
+ this.$message.success(this.$t('common.language') + ': ' + this.currentLocaleLabel)
+ },
logout() {
this.$store.dispatch('FedLogOut').then(() => {
location.reload() // 为了重新实例化vue-router对象 避免bug
@@ -459,6 +492,26 @@ export default {
top: 16px;
color: red;
}
+ .language-container {
+ height: 50px;
+ display: inline-block;
+ position: absolute;
+ right: 95px;
+ top: 0;
+ .language-button {
+ height: 50px;
+ min-width: 76px;
+ padding: 0 8px;
+ color: #fff;
+ font-size: 13px;
+ line-height: 50px;
+ cursor: pointer;
+ }
+ .language-button:hover,
+ .language-button:focus {
+ color: #f2f6fc;
+ }
+ }
.avatar-container {
height: 50px;
display: inline-block;