fix : 国际化修改

This commit is contained in:
zhangyu
2022-07-05 17:57:15 +08:00
parent 74283612a7
commit 543f6efda8
4 changed files with 115 additions and 115 deletions

View File

@@ -75,13 +75,13 @@ export default {
}], }],
sysArr: [{ sysArr: [{
key: 'alertRule', key: 'alertRule',
label: this.$t('alert.alertRule') label: this.$t('alert.rule')
}, { }, {
key: 'dc', key: 'dc',
label: this.$t('overall.dc') label: this.$t('overall.dc')
}, { }, {
key: 'asset', key: 'asset',
label: this.$t('overall.asset') label: this.$t('asset.asset')
}, { }, {
key: 'endpoint', key: 'endpoint',
label: this.$t('asset.endpoint') label: this.$t('asset.endpoint')
@@ -90,7 +90,7 @@ export default {
label: this.$t('overall.module') label: this.$t('overall.module')
}, { }, {
key: 'project', key: 'project',
label: this.$t('overall.project') label: this.$t('project.project.projectName')
}] }]
} }
}, },

View File

@@ -110,22 +110,22 @@
</template> </template>
<script> <script>
import { alertMessage as alertMessageConstant } from "@/components/common/js/constants"; import { alertMessage as alertMessageConstant } from '@/components/common/js/constants'
import alertMessageLabelMixin from "@/components/common/alert/alertMessageLabelMixin"; import alertMessageLabelMixin from '@/components/common/alert/alertMessageLabelMixin'
import alertLabelMixin from "@/components/common/mixin/alertLabelMixin"; import alertLabelMixin from '@/components/common/mixin/alertLabelMixin'
import { calcDurationByStringTimeB } from '@/components/common/js/tools.js' import { calcDurationByStringTimeB } from '@/components/common/js/tools.js'
export default { export default {
name: "alertMessageInfoTimeLine", name: 'alertMessageInfoTimeLine',
props: { props: {
infoData: { infoData: {
type: Object, type: Object
}, },
time: {}, time: {}
}, },
mixins: [alertMessageLabelMixin, alertLabelMixin], mixins: [alertMessageLabelMixin, alertLabelMixin],
computed: { computed: {
severityData() { severityData () {
return this.$store.getters.severityData; return this.$store.getters.severityData
}, },
getDuration () { getDuration () {
return function (record) { return function (record) {
@@ -140,194 +140,194 @@ export default {
time: { time: {
immediate: true, immediate: true,
deep: true, deep: true,
handler(n) { handler (n) {
if (n && n.length) { if (n && n.length) {
this.pageNo = 1; this.pageNo = 1
this.lastDataTime = '' this.lastDataTime = ''
this.getTimeLineData(); this.getTimeLineData()
}
}
} }
}, },
}, data () {
},
data() {
return { return {
pageNo: 1, pageNo: 1,
pageSize: 20, pageSize: 20,
scope: [ scope: [
"asset", 'asset',
"datacenter", 'datacenter',
"project", 'project',
"module", 'module',
"endpoint", 'endpoint',
"alertrule", 'alertrule',
"hash", 'hash'
], ],
timeLineData: [], timeLineData: [],
lastDataTime: "", lastDataTime: '',
loading: false, loading: false,
dateFormatStr: localStorage.getItem("nz-default-dateFormat") dateFormatStr: localStorage.getItem('nz-default-dateFormat')
? localStorage.getItem("nz-default-dateFormat") ? localStorage.getItem('nz-default-dateFormat')
: "YYYY-MM-DD HH:ss:mm", : 'YYYY-MM-DD HH:ss:mm',
noData: false, noData: false,
stateOptions: alertMessageConstant.states, stateOptions: alertMessageConstant.states,
scopeList: [ scopeList: [
{ {
key: "asset", key: 'asset',
isSelect: true, isSelect: true,
label: this.$t("overall.asset"), label: this.$t('asset.asset')
}, },
{ {
key: "datacenter", key: 'datacenter',
isSelect: true, isSelect: true,
label: this.$t("overall.dc"), label: this.$t('overall.dc')
}, },
{ {
key: "project", key: 'project',
isSelect: true, isSelect: true,
label: this.$t("overall.project"), label: this.$t('project.project.projectName')
}, },
{ {
key: "module", key: 'module',
isSelect: true, isSelect: true,
label: this.$t("overall.module"), label: this.$t('overall.module')
}, },
{ {
key: "endpoint", key: 'endpoint',
isSelect: true, isSelect: true,
label: this.$t("asset.endpoint"), label: this.$t('asset.endpoint')
}, },
{ {
key: "alertrule", key: 'alertrule',
isSelect: true, isSelect: true,
label: this.$t("alert.alertRule"), label: this.$t('alert.rule')
}, },
{ {
key: "hash", key: 'hash',
isSelect: true, isSelect: true,
label: this.$t("overall.hash"), label: this.$t('overall.hash')
}, }
], ],
total: 20, total: 20,
scopeChangeTimer: null, scopeChangeTimer: null
}; }
}, },
mounted() { mounted () {
// this.getTimeLineData(1) // this.getTimeLineData(1)
const dateFormatStr = localStorage.getItem("nz-default-dateFormat"); const dateFormatStr = localStorage.getItem('nz-default-dateFormat')
if (dateFormatStr) { if (dateFormatStr) {
this.dateFormatStr = dateFormatStr.split(" ")[0]; this.dateFormatStr = dateFormatStr.split(' ')[0]
} else { } else {
this.dateFormatStr = "YYYY-MM-DD"; this.dateFormatStr = 'YYYY-MM-DD'
} }
}, },
methods: { methods: {
getTimeLineData() { getTimeLineData () {
this.noData = false; this.noData = false
this.loading = true; this.loading = true
const params = { const params = {
pageNo: this.pageNo, pageNo: this.pageNo,
pageSize: this.pageSize, pageSize: this.pageSize,
scope: this.scopeList scope: this.scopeList
.filter((item) => item.isSelect) .filter((item) => item.isSelect)
.map((item) => item.key) .map((item) => item.key)
.join(","), .join(','),
id: this.infoData.id, id: this.infoData.id,
state: "", state: '',
startAt: this.timezoneToUtcTimeStr( startAt: this.timezoneToUtcTimeStr(
this.time[0] * 1000, this.time[0] * 1000,
"YYYY-MM-DD HH:mm:ss" 'YYYY-MM-DD HH:mm:ss'
), ),
endAt: this.timezoneToUtcTimeStr( endAt: this.timezoneToUtcTimeStr(
this.time[1] * 1000, this.time[1] * 1000,
"YYYY-MM-DD HH:mm:ss" 'YYYY-MM-DD HH:mm:ss'
), ),
orderBy: "-startAt", orderBy: '-startAt'
};
this.$get("/alert/message/rel", params)
.then((res) => {
this.loading = false;
if (res.code === 200) {
this.total = res.data.total;
if (this.pageNo == 1) {
this.timeLineData = res.data.list;
} else {
this.timeLineData.push(...res.data.list);
} }
this.disposeTime(this.pageNo); this.$get('/alert/message/rel', params)
this.noData = false; .then((res) => {
this.pageNo++; this.loading = false
if (res.code === 200) {
this.total = res.data.total
if (this.pageNo == 1) {
this.timeLineData = res.data.list
} else { } else {
this.noData = true; this.timeLineData.push(...res.data.list)
}
this.disposeTime(this.pageNo)
this.noData = false
this.pageNo++
} else {
this.noData = true
} }
}) })
.catch(() => { .catch(() => {
this.loading = false; this.loading = false
this.noData = true; this.noData = true
}); })
}, },
disposeTime(pageNo) { disposeTime (pageNo) {
let i = (pageNo - 1) * this.pageSize; let i = (pageNo - 1) * this.pageSize
for (i; i < this.timeLineData.length; i++) { for (i; i < this.timeLineData.length; i++) {
const lastDataTime = this.utcTimeToTimezoneStr( const lastDataTime = this.utcTimeToTimezoneStr(
this.timeLineData[i].startAt, this.timeLineData[i].startAt,
this.dateFormatStr this.dateFormatStr
); )
this.timeLineData[i].color = "#fa8"; this.timeLineData[i].color = '#fa8'
this.timeLineData[i].startTime = this.timeLineData[i].startAt; this.timeLineData[i].startTime = this.timeLineData[i].startAt
if (this.lastDataTime !== lastDataTime) { if (this.lastDataTime !== lastDataTime) {
this.lastDataTime = lastDataTime; this.lastDataTime = lastDataTime
this.timeLineData[i].startAt = lastDataTime; this.timeLineData[i].startAt = lastDataTime
} else { } else {
this.timeLineData[i].startAt = ""; this.timeLineData[i].startAt = ''
} }
} }
}, },
selectIcon(item) { selectIcon (item) {
switch (item.key) { switch (item.key) {
case "asset": case 'asset':
return "nz-icon-overview-project"; return 'nz-icon-overview-project'
case "datacenter": case 'datacenter':
return "nz-icon-Datacenter2"; return 'nz-icon-Datacenter2'
case "project": case 'project':
return "nz-icon-project"; return 'nz-icon-project'
case "module": case 'module':
return "nz-icon-overview-module"; return 'nz-icon-overview-module'
case "endpoint": case 'endpoint':
return "nz-icon-overview-endpoint"; return 'nz-icon-overview-endpoint'
case "alertrule": case 'alertrule':
return "nz-icon-Alertrule"; return 'nz-icon-Alertrule'
case "hash": case 'hash':
return "nz-icon-module5"; return 'nz-icon-module5'
} }
return "nz-icon-module5"; return 'nz-icon-module5'
}, },
scopeChange(scope) { scopeChange (scope) {
if (this.scopeChangeTimer) { if (this.scopeChangeTimer) {
clearInterval(this.scopeChangeTimer); clearInterval(this.scopeChangeTimer)
this.scopeChangeTimer = null; this.scopeChangeTimer = null
} }
this.loading = true; this.loading = true
const isSelectArr = this.scopeList.filter((item) => item.isSelect); const isSelectArr = this.scopeList.filter((item) => item.isSelect)
if (isSelectArr.length === this.scopeList.length) { if (isSelectArr.length === this.scopeList.length) {
this.scopeList.forEach((item) => { this.scopeList.forEach((item) => {
item.isSelect = false; item.isSelect = false
}); })
scope.isSelect = !scope.isSelect; scope.isSelect = !scope.isSelect
} else if (isSelectArr.length === 1 && isSelectArr[0].key === scope.key) { } else if (isSelectArr.length === 1 && isSelectArr[0].key === scope.key) {
this.scopeList.forEach((item) => { this.scopeList.forEach((item) => {
item.isSelect = true; item.isSelect = true
}); })
} else { } else {
scope.isSelect = !scope.isSelect; scope.isSelect = !scope.isSelect
} }
this.scopeChangeTimer = setTimeout(() => { this.scopeChangeTimer = setTimeout(() => {
this.pageNo = 1; this.pageNo = 1
this.lastDataTime = '' this.lastDataTime = ''
this.getTimeLineData(); this.getTimeLineData()
}, 100); }, 100)
}, }
}, }
}; }
</script> </script>
<style scoped> <style scoped>

View File

@@ -151,11 +151,11 @@ export default {
}, { }, {
type: 'asset', type: 'asset',
isSelect: true, isSelect: true,
title: this.$t('overall.asset') title: this.$t('asset.asset')
}, { }, {
type: 'project', type: 'project',
isSelect: true, isSelect: true,
title: this.$t('overall.project') title: this.$t('project.project.projectName')
}, { }, {
type: 'module', type: 'module',
isSelect: true, isSelect: true,
@@ -167,7 +167,7 @@ export default {
}, { }, {
type: 'alertrule', type: 'alertrule',
isSelect: true, isSelect: true,
title: this.$t('alert.alertRule') title: this.$t('alert.rule')
} }
], ],
skeletonArr: 20, skeletonArr: 20,

View File

@@ -103,7 +103,7 @@ export default {
minWidth: 100, minWidth: 100,
show: true show: true
}, { }, {
label: this.$t('asset.key'), label: this.$t('apiKey.key'),
prop: 'token', prop: 'token',
minWidth: 180, minWidth: 180,
show: true show: true