CN-936 开发appearance页面:保存逻辑调整,及timezoneOffset设置方式修改
This commit is contained in:
@@ -129,7 +129,7 @@ export default {
|
||||
})
|
||||
},
|
||||
delBatch () {
|
||||
let ids = []
|
||||
const ids = []
|
||||
if (this.batchDeleteObjs && this.batchDeleteObjs.length > 0) {
|
||||
this.batchDeleteObjs.forEach(item => {
|
||||
ids.push(item.id)
|
||||
|
||||
@@ -57,10 +57,9 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { api,getDictList } from '@/utils/api'
|
||||
import { get, put } from '@/utils/http'
|
||||
import { api } from '@/utils/api'
|
||||
import { storageKey } from '@/utils/constants'
|
||||
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
name: 'Appearance',
|
||||
@@ -111,22 +110,20 @@
|
||||
this.initData()
|
||||
},
|
||||
methods: {
|
||||
async initData () {
|
||||
initData () {
|
||||
this.dateFormatList.forEach(date => {
|
||||
date.example = window.$dayJs(new Date()).tz().format(date.value)
|
||||
})
|
||||
await get(api.timezone).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.timezoneList = response.data
|
||||
}
|
||||
})
|
||||
|
||||
axios.get(api.timezone).then(response => {
|
||||
if (response.data.code === 200) {
|
||||
this.timezoneList = response.data.data
|
||||
if (this.timezoneList && this.timezoneList.length > 0) {
|
||||
this.timezoneList.forEach(mapData => {
|
||||
let offset = Number(mapData.offset)/3600000 //转换为小
|
||||
const offset = Number(mapData.offset) / 3600000 // 转换为小
|
||||
mapData.timezoneOffset = offset
|
||||
let hour = Math.abs(parseInt(offset))
|
||||
let offsetStr = offset.toString()
|
||||
const hour = Math.abs(parseInt(offset))
|
||||
const offsetStr = offset.toString()
|
||||
let minute = 0
|
||||
if (offsetStr.indexOf('.') > -1) {
|
||||
minute = Math.abs(Number(offsetStr.substring(offsetStr.indexOf('.'))) * 60)
|
||||
@@ -152,18 +149,30 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
get(this.url, { pageSize: -1 }).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.appearanceObject = response.data
|
||||
}
|
||||
})
|
||||
|
||||
axios.get(this.url, { pageSize: -1 }).then(response => {
|
||||
if (response.data.code === 200) {
|
||||
this.appearanceObject = response.data.data
|
||||
}
|
||||
})
|
||||
},
|
||||
save () {
|
||||
if (this.blockOperation.save) { return }
|
||||
this.blockOperation.save = true
|
||||
put(this.url, this.appearanceObject).then(response => {
|
||||
if (response.code === 200) {
|
||||
axios.put(this.url, this.appearanceObject).then(response => {
|
||||
if (response.data.code === 200) {
|
||||
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||
if (this.appearanceObject.date_format !== localStorage.getItem(storageKey.dateFormat)) {
|
||||
localStorage.setItem(storageKey.dateFormat, this.appearanceObject.date_format)
|
||||
}
|
||||
if (this.appearanceObject.timezone !== localStorage.getItem(storageKey.sysTimezone)) {
|
||||
localStorage.setItem(storageKey.sysTimezone, this.appearanceObject.timezone)
|
||||
window.$dayJs.tz.setDefault(this.appearanceObject.timezone)
|
||||
localStorage.setItem(storageKey.timezoneOffset, window.$dayJs.tz().utcOffset() / 60)
|
||||
localStorage.setItem(storageKey.timezoneLocalOffset, dayjs().utcOffset() / 60)
|
||||
}
|
||||
} else {
|
||||
this.$message.error(response.message)
|
||||
}
|
||||
@@ -176,16 +185,6 @@
|
||||
}
|
||||
}).finally(() => {
|
||||
this.blockOperation.save = false
|
||||
if (this.appearanceObject.date_format !== localStorage.getItem(storageKey.dateFormat)) {
|
||||
localStorage.setItem(storageKey.dateFormat, this.appearanceObject.date_format)
|
||||
}
|
||||
if (this.appearanceObject.timezone !== localStorage.getItem(storageKey.sysTimezone)) {
|
||||
localStorage.setItem(storageKey.sysTimezone, this.appearanceObject.timezone)
|
||||
}
|
||||
let timezone = this.timezoneList.find(mapData => mapData.name === this.appearanceObject.timezone)
|
||||
if (timezone.timezoneOffset !== localStorage.getItem(storageKey.timezoneOffset)) {
|
||||
localStorage.setItem(storageKey.timezoneOffset, timezone.timezoneOffset)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ export default {
|
||||
type: 'warning'
|
||||
})
|
||||
} else {
|
||||
let curRecord = this.batchDeleteObjs[0]
|
||||
const curRecord = this.batchDeleteObjs[0]
|
||||
this.initConfig(curRecord)
|
||||
this.object = curRecord
|
||||
this.rightBox.show = true
|
||||
|
||||
Reference in New Issue
Block a user