NEZ-3114 feat:列表页面个性化设置实现后台存储

This commit is contained in:
zyh
2023-08-30 17:30:36 +08:00
parent 2d5aa25f2a
commit 0ad7d7e295
41 changed files with 401 additions and 194 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -5,6 +5,20 @@
"css_prefix_text": "nz-icon-", "css_prefix_text": "nz-icon-",
"description": "", "description": "",
"glyphs": [ "glyphs": [
{
"icon_id": "37041244",
"name": "Show all series",
"font_class": "a-Showallseries",
"unicode": "e7f0",
"unicode_decimal": 59376
},
{
"icon_id": "37041245",
"name": "Show seleted series",
"font_class": "a-Showseletedseries",
"unicode": "e7ef",
"unicode_decimal": 59375
},
{ {
"icon_id": "680107", "icon_id": "680107",
"name": "展开", "name": "展开",

File diff suppressed because one or more lines are too long

View File

@@ -175,7 +175,7 @@ export default {
}, },
methods: { methods: {
updateCustomTableTitle (custom) { updateCustomTableTitle (custom) {
this.$emit('update:customTableTitle', custom) this.$parent.updateCustomTableTitle(custom)
}, },
search (searchObj) { search (searchObj) {
this.$emit('search', searchObj) this.$emit('search', searchObj)

View File

@@ -138,7 +138,8 @@ export default {
readonly: true, readonly: true,
disabled: false disabled: false
}] }]
} },
fromBottom: true
} }
}, },
methods: { methods: {
@@ -179,9 +180,10 @@ export default {
obj: { obj: {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { async handler (n, o) {
if (n) { if (n) {
this.searchLabel = {} this.searchLabel = {}
await this.getPreference()
this.getTableData() this.getTableData()
} }
} }

View File

@@ -158,12 +158,13 @@ export default {
watch: { watch: {
obj: { obj: {
immediate: true, immediate: true,
handler (n) { async handler (n) {
if (n) { if (n) {
this.searchLabel = {} this.searchLabel = {}
if (this.from === fromRoute.alertSilence) { if (this.from === fromRoute.alertSilence) {
this.state = '2' this.state = '2'
} }
await this.getPreference()
this.searchLabel = {} this.searchLabel = {}
// this.getTableData() // this.getTableData()
setTimeout(() => { setTimeout(() => {
@@ -187,7 +188,7 @@ export default {
url: 'alert/message', url: 'alert/message',
urlNew: 'alert/message/query', urlNew: 'alert/message/query',
alertSilenceUrl: '', alertSilenceUrl: '',
tableId: 'alertMessageModule', // 需要分页的table的id用于记录每页数量 tableId: 'alertMessageTab', // 需要分页的table的id用于记录每页数量
state: '1', state: '1',
blankSilenceObject: { blankSilenceObject: {
id: '', id: '',

View File

@@ -132,7 +132,8 @@ export default {
snmpCredentialData: [], snmpCredentialData: [],
fieldGroupData: [], fieldGroupData: [],
needAlertDaysData: true, needAlertDaysData: true,
trendKey: 'assetId' trendKey: 'assetId',
fromBottom: true
} }
}, },
methods: { methods: {
@@ -294,7 +295,7 @@ export default {
obj: { obj: {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { async handler (n, o) {
this.searchLabel = {} this.searchLabel = {}
this.searchLabel.dcIds = n.id this.searchLabel.dcIds = n.id
if (this.from === fromRoute.model) { if (this.from === fromRoute.model) {
@@ -305,6 +306,7 @@ export default {
delete this.searchLabel.dcIds delete this.searchLabel.dcIds
this.searchLabel.pids = n.id this.searchLabel.pids = n.id
} }
await this.getPreference()
this.getTableData() this.getTableData()
} }
} }

View File

@@ -132,7 +132,8 @@ export default {
disabled: false disabled: false
} }
] ]
} },
fromBottom: true
} }
}, },
created () { created () {
@@ -234,10 +235,11 @@ export default {
obj: { obj: {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n) { async handler (n) {
if (n) { if (n) {
this.currentDc = JSON.parse(JSON.stringify(n)) this.currentDc = JSON.parse(JSON.stringify(n))
this.searchLabel = { dcIds: this.currentDc.id } this.searchLabel = { dcIds: this.currentDc.id }
await this.getPreference()
this.getTableData() this.getTableData()
} }
} }

View File

@@ -75,9 +75,10 @@ export default {
watch: { watch: {
obj: { obj: {
immediate: true, immediate: true,
handler (n) { async handler (n) {
if (n) { if (n) {
this.searchLabel = {} this.searchLabel = {}
await this.getPreference()
this.getTableData() this.getTableData()
} }
} }
@@ -122,6 +123,7 @@ export default {
}, },
methods: { methods: {
getTableData () { getTableData () {
this.tools.loading = true
if (this.orderBy) { if (this.orderBy) {
this.$set(this.searchLabel, 'orderBy', this.orderBy) this.$set(this.searchLabel, 'orderBy', this.orderBy)
} else { } else {

View File

@@ -80,9 +80,15 @@ export default {
} }
}, },
watch: { watch: {
obj (n) { obj: {
this.searchLabel = { id: n.id } immediate: true,
this.getTableData() async handler (n) {
if (n) {
this.searchLabel = { id: n.id }
await this.getPreference()
this.getTableData()
}
}
}, },
queryExpression (n) { queryExpression (n) {
const temp = this const temp = this
@@ -109,7 +115,8 @@ export default {
filterTime: [ filterTime: [
bus.timeFormate(bus.getOffsetTimezoneData(-1), 'YYYY-MM-DD HH:mm:ss'), bus.timeFormate(bus.getOffsetTimezoneData(-1), 'YYYY-MM-DD HH:mm:ss'),
bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss')
] ],
fromBottom: true
} }
}, },
methods: { methods: {

View File

@@ -53,9 +53,15 @@ export default {
obj: Object obj: Object
}, },
watch: { watch: {
obj (n) { obj: {
this.searchLabel = { userId: n.id } immediate: true,
this.getTableData() async handler (n) {
if (n) {
this.searchLabel = { userId: n.id }
await this.getPreference()
this.getTableData()
}
}
} }
}, },
data () { data () {
@@ -106,7 +112,8 @@ export default {
} }
] ]
}, },
searchLabel: { userId: this.obj.id } searchLabel: { userId: this.obj.id },
fromBottom: true
} }
}, },
methods: { methods: {

View File

@@ -80,9 +80,15 @@ export default {
} }
}, },
watch: { watch: {
obj (n) { obj: {
this.searchLabel = { id: n.id } immediate: true,
this.getTableData() async handler (n) {
if (n) {
this.searchLabel = { id: n.id }
await this.getPreference()
this.getTableData()
}
}
}, },
queryExpression (n) { queryExpression (n) {
const temp = this const temp = this
@@ -109,7 +115,8 @@ export default {
filterTime: [ filterTime: [
bus.timeFormate(bus.getOffsetTimezoneData(-1), 'YYYY-MM-DD HH:mm:ss'), bus.timeFormate(bus.getOffsetTimezoneData(-1), 'YYYY-MM-DD HH:mm:ss'),
bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss')
] ],
fromBottom: true
} }
}, },
methods: { methods: {

View File

@@ -60,9 +60,15 @@ export default {
} }
}, },
watch: { watch: {
obj (n) { obj: {
this.searchLabel = { id: n.id } immediate: true,
this.getTableData() async handler (n) {
if (n) {
this.searchLabel = { id: n.id }
await this.getPreference()
this.getTableData()
}
}
} }
}, },
data () { data () {
@@ -82,7 +88,8 @@ export default {
] ]
}, },
nowTime: '', nowTime: '',
searchLabel: { id: this.obj.id } searchLabel: { id: this.obj.id },
fromBottom: true
} }
}, },
methods: { methods: {

View File

@@ -92,7 +92,8 @@ export default {
} }
] ]
}, },
searchLabel: { roleId: this.obj.id } searchLabel: { roleId: this.obj.id },
fromBottom: true
} }
}, },
watch: { watch: {
@@ -119,9 +120,15 @@ export default {
} }
} }
}, },
obj (n) { obj: {
this.searchLabel = { roleId: this.obj.id } immediate: true,
this.getTableData() async handler (n) {
if (n) {
this.searchLabel = { roleId: this.obj.id }
await this.getPreference()
this.getTableData()
}
}
} }
}, },
methods: { methods: {

View File

@@ -75,7 +75,8 @@ export default {
}, },
timer: null, timer: null,
sameLabels: ['endpointLabels', 'labelsType', 'lastScrape', 'lastScrapeDuration', 'health', 'lastError', 'str'], sameLabels: ['endpointLabels', 'labelsType', 'lastScrape', 'lastScrapeDuration', 'health', 'lastError', 'str'],
orderBy: {} orderBy: {},
fromBottom: true
} }
}, },
watch: { watch: {
@@ -86,12 +87,13 @@ export default {
}, 500) }, 500)
}, },
obj: { obj: {
// immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { async handler (n, o) {
if (n) { if (n) {
this.searchLabel = {} this.searchLabel = {}
this.inputDateSearch = '' this.inputDateSearch = ''
await this.getPreference()
this.getTableData() this.getTableData()
} }
} }
@@ -245,7 +247,7 @@ export default {
}, },
pageSize (val) { pageSize (val) {
this.pageObj.pageSize = val this.pageObj.pageSize = val
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val) this.setPreference()
this.handleCurrentChange() this.handleCurrentChange()
}, },
// 计算当前分页需要返回数据的条数 // 计算当前分页需要返回数据的条数
@@ -314,8 +316,7 @@ export default {
clearInterval(this.timer) clearInterval(this.timer)
}, },
created () { created () {
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
this.pageObj.pageSize = pageSize || 20
} }
} }
</script> </script>

View File

@@ -66,14 +66,17 @@ export default {
}, },
searchLabel: {}, searchLabel: {},
tableData: [], tableData: [],
orderBy: { order: 'ascending', prop: 'id' } orderBy: { order: 'ascending', prop: 'id' },
fromBottom: true
} }
}, },
watch: { watch: {
obj: { obj: {
deep: true, deep: true,
handler (n) { immediate: true,
async handler (n) {
if (n) { if (n) {
await this.getPreference()
this.getTableData() this.getTableData()
} }
} }

View File

@@ -60,9 +60,15 @@ export default {
} }
}, },
watch: { watch: {
obj (n) { obj: {
this.searchLabel = { userId: n.id } immediate: true,
this.getTableData() async handler (n) {
if (n) {
this.searchLabel = { userId: n.id }
await this.getPreference()
this.getTableData()
}
}
} }
}, },
data () { data () {
@@ -124,7 +130,8 @@ export default {
] ]
}, },
nowTime: '', nowTime: '',
searchLabel: { userId: this.obj.id } searchLabel: { userId: this.obj.id },
fromBottom: true
} }
}, },
methods: { methods: {

View File

@@ -66,8 +66,20 @@ export default {
}, },
searchLabel: {}, searchLabel: {},
tableData: [], tableData: [],
orderBy: { order: 'ascending', prop: 'id' } orderBy: { order: 'ascending', prop: 'id' },
fromBottom: true
}
},
watch: {
obj: {
deep: true,
immediate: true,
async handler (n) {
if (n) {
await this.getPreference()
this.getTableData()
}
}
} }
}, },
methods: { methods: {

View File

@@ -209,9 +209,6 @@ export default {
} }
}, },
methods: { methods: {
updateCustomTableTitle (custom) {
this.$emit('update:customTableTitle', custom)
},
// 全屏 // 全屏
fullScreen () { fullScreen () {
const vm = this const vm = this

View File

@@ -84,7 +84,7 @@
<button :id="tableId+'-element-set-esc'" class="nz-btn nz-btn-size-small nz-btn-style-light" type="button" @click.stop="esc"> <button :id="tableId+'-element-set-esc'" class="nz-btn nz-btn-size-small nz-btn-style-light" type="button" @click.stop="esc">
<span class="top-tool-btn-txt">{{$t('overall.cancel')}}</span> <span class="top-tool-btn-txt">{{$t('overall.cancel')}}</span>
</button> </button>
<button :id="tableId+'-element-set-save'" class="nz-btn nz-btn-size-small nz-btn-style-normal" type="button" @click.stop="save"> <button :id="tableId+'-element-set-save'" class="nz-btn nz-btn-size-small nz-btn-style-normal" :class="{'nz-btn-disabled': !custom.length}" :disabled="!custom.length" type="button" @click.stop="save">
<span class="top-tool-btn-txt">{{$t('overall.save')}}</span> <span class="top-tool-btn-txt">{{$t('overall.save')}}</span>
</button> </button>
</div> </div>
@@ -112,10 +112,6 @@ export default {
} }
}, },
created () { created () {
const localStorageTitle = JSON.parse(localStorage.getItem('nz-tableTitle-' + localStorage.getItem('nz-username') + '-' + this.tableId))
if (localStorageTitle) {
localStorage.setItem('nz-tableTitle-' + localStorage.getItem('nz-username') + '-' + this.tableId, JSON.stringify(localStorageTitle))
}
}, },
watch: { watch: {
customTableTitle: { customTableTitle: {
@@ -166,10 +162,6 @@ export default {
}) })
} }
this.$emit('update', this.custom) this.$emit('update', this.custom)
localStorage.setItem(
'nz-tableTitle-' + localStorage.getItem('nz-username') + '-' + this.tableId,
JSON.stringify(this.custom)
)
this.esc() this.esc()
}, },
// 禁止拖动的对象 // 禁止拖动的对象

View File

@@ -46,7 +46,9 @@ export default {
delFlag: false, delFlag: false,
fromBottom: false, fromBottom: false,
operationWidth: '165', // 操作列宽 operationWidth: '165', // 操作列宽
searchCheckBox: {} searchCheckBox: {},
detailType: 'list',
preferenceLoading: true
} }
}, },
provide () { provide () {
@@ -203,9 +205,9 @@ export default {
this.pageObj.pageNo = val this.pageObj.pageNo = val
this.getTableData() this.getTableData()
}, },
pageSize (val) { async pageSize (val) {
this.pageObj.pageSize = val this.pageObj.pageSize = val
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val) this.setPreference()
this.getTableData() this.getTableData()
}, },
add () { add () {
@@ -305,7 +307,7 @@ export default {
} else { } else {
this.dataListLayout.push('clickSearch') this.dataListLayout.push('clickSearch')
} }
localStorage.setItem('dataList-layout' + this.tableId, JSON.stringify(this.dataListLayout)) this.setPreference()
}, },
addSilence (row, type) { addSilence (row, type) {
this.blankSilenceObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') this.blankSilenceObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss')
@@ -376,6 +378,92 @@ export default {
showText (row) { showText (row) {
this.dialogShowText = true this.dialogShowText = true
this.dialogText = row.alertRule.trbShot this.dialogText = row.alertRule.trbShot
},
// 获取用户偏好
async getPreference () {
this.preferenceLoading = true
const res = await this.$get('/sys/user/preference', { key: this.tableId })
let tableHeaders
if (res.data[this.tableId]) {
const data = JSON.parse(res.data[this.tableId])
this.pageObj.pageSize = data.pageSize
this.detailType = data.view
this.dataListLayout = data.layout
tableHeaders = data.tableHeaders
}
this.preferenceLoading = false
this.$nextTick(() => {
this.setCustomTableTitle(tableHeaders)
})
// 请求完用户偏好 打开底部弹窗
if (this.fromBottom || this.projectPopTable) { return }
const q = this.$route.query
if (q.bottomBox && JSON.parse(q.bottomBox)) {
this.$nextTick(() => {
this.detailType = q.detailType
const detailType = this.detailType === 'list' ? 'dataList' : 'detailList'
this.$refs[detailType].bottomBox.showSubList = JSON.parse(q.bottomBox)
this.$refs[detailType].bottomBox.targetTab = q.targetTab
this.$refs[detailType].bottomBox.object = JSON.parse(q.selectObj)
})
} else if (this.detailType === 'view' && q.detailType && q.selectObj) {
this.detailType = q.detailType
this.detailViewRightObj = JSON.parse(q.selectObj)
this.$store.commit('setGlobalSearchId', this.detailViewRightObj.id)
}
},
// 设置用户偏好
setPreference () {
const params = {
pageSize: this.pageObj.pageSize,
view: this.detailType || 'list',
tableHeaders: this.tools.customTableTitle
}
if (this.dataListLayout) {
params.layout = this.dataListLayout
}
this.$put('/sys/user/preference', { [this.tableId]: JSON.stringify(params) }).then(res => {
if (res.code !== 200) {
this.$message.error(res.msg || res.error)
}
})
},
setCustomTableTitle (tableHeaders) {
let tableTitle = ''
if (this.$refs.dataTable) {
tableTitle = this.$refs.dataTable.tableTitle
} else if (this.$refs.dataDetail) {
tableTitle = this.$refs.dataDetail.tableTitle
}
if (!tableTitle || !this.tableId) {
return
}
const preferenceTableTitle = tableHeaders || tableTitle
if (tableTitle) {
// 先根据本地缓存中的prop进行排序
tableTitle.sort(function (a, b) {
return preferenceTableTitle.findIndex(function (c) {
return c.prop === a.prop
}) - preferenceTableTitle.findIndex(function (c) {
return c.prop === b.prop
})
})
this.tools.customTableTitle = tableTitle.map((item, index) => { // 修复切换中英文的问题
item.show = preferenceTableTitle[index].show
return item
})
}
if (preferenceTableTitle && (preferenceTableTitle.length > tableTitle.length)) {
const arr = preferenceTableTitle.splice(tableTitle.length, preferenceTableTitle.length)
arr.forEach(item => {
item.minWidth = item.label.length * 16 + 20
})
this.tools.customTableTitle = this.tools.customTableTitle.concat(arr)
}
},
updateCustomTableTitle (custom) {
this.tools.customTableTitle = custom
this.setPreference()
} }
}, },
watch: { watch: {
@@ -1336,50 +1424,20 @@ export default {
} }
this.initQueryFromPath(searchKeys) this.initQueryFromPath(searchKeys)
}, },
mounted () { async mounted () {
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId) // 先设置默认的表头
if (pageSize && pageSize !== 'undefined') {
this.pageObj.pageSize = pageSize
}
let tableTitle = '' let tableTitle = ''
if (this.$refs.dataTable) { if (this.$refs.dataTable) {
tableTitle = this.$refs.dataTable.tableTitle tableTitle = this.$refs.dataTable.tableTitle
} else if (this.$refs.dataDetail) { } else if (this.$refs.dataDetail) {
tableTitle = this.$refs.dataDetail.tableTitle tableTitle = this.$refs.dataDetail.tableTitle
} }
if (!tableTitle || !this.tableId) { if (tableTitle && this.tableId) {
return this.tools.customTableTitle = tableTitle
} }
let localStorageTableTitle = localStorage.getItem('nz-tableTitle-' + localStorage.getItem('nz-username') + '-' + this.tableId) if (!this.fromBottom && !this.projectPopTable) {
localStorageTableTitle = localStorageTableTitle ? JSON.parse(localStorageTableTitle) : tableTitle await this.getPreference()
if (tableTitle) {
// 先根据本地缓存中的prop进行排序
tableTitle.sort(function (a, b) {
return localStorageTableTitle.findIndex(function (c) {
return c.prop === a.prop
}) - localStorageTableTitle.findIndex(function (c) {
return c.prop === b.prop
})
})
this.tools.customTableTitle = tableTitle.map((item, index) => { // 修复切换中英文的问题
item.show = localStorageTableTitle[index].show
return item
})
}
if (localStorageTableTitle && (localStorageTableTitle.length > tableTitle.length)) {
const arr = localStorageTableTitle.splice(tableTitle.length, localStorageTableTitle.length)
arr.forEach(item => {
item.minWidth = item.label.length * 16 + 20
})
this.tools.customTableTitle = this.tools.customTableTitle.concat(arr)
}
if (!this.fromBottom) {
this.getTableData() this.getTableData()
this.$nextTick(() => {
if (this.$refs.dataTable) {
this.$refs.dataTable.$refs.dataTable && this.$refs.dataTable.$refs.dataTable.doLayout()
}
})
} }
}, },
beforeDestroy () { beforeDestroy () {

View File

@@ -14,7 +14,6 @@ export default {
}, },
data () { data () {
return { return {
detailType: localStorage.getItem('detail-view-' + this.tableId) || 'list',
detailViewRightObj: '', detailViewRightObj: '',
detailViewLoading: false, detailViewLoading: false,
detailTimer: '', detailTimer: '',
@@ -22,7 +21,6 @@ export default {
} }
}, },
created () { created () {
this.detailType = localStorage.getItem('detail-view-' + this.tableId) || 'list'
}, },
mounted () { mounted () {
setTimeout(() => { setTimeout(() => {
@@ -43,12 +41,12 @@ export default {
return return
} }
this.detailType = flag this.detailType = flag
this.setPreference()
// this.$refs.dataList.bottomBox.showSubList = false // this.$refs.dataList.bottomBox.showSubList = false
// if (this.orderBy) { // if (this.orderBy) {
// this.detailViewRightObj = '' // this.detailViewRightObj = ''
// } // }
let dataList = '' let dataList = ''
localStorage.setItem('detail-view-' + this.tableId, this.detailType)
if (this.detailType === 'view') { if (this.detailType === 'view') {
dataList = 'detailList' dataList = 'detailList'
if (this.from === this.fromRoute.asset) { if (this.from === this.fromRoute.asset) {

View File

@@ -33,19 +33,19 @@ export default {
cb() cb()
} }
} }
if (q.bottomBox && JSON.parse(q.bottomBox)) { // if (q.bottomBox && JSON.parse(q.bottomBox)) {
this.$nextTick(() => { // this.$nextTick(() => {
this.detailType = q.detailType // this.detailType = q.detailType
const detailType = this.detailType === 'list' ? 'dataList' : 'detailList' // const detailType = this.detailType === 'list' ? 'dataList' : 'detailList'
this.$refs[detailType].bottomBox.showSubList = JSON.parse(q.bottomBox) // this.$refs[detailType].bottomBox.showSubList = JSON.parse(q.bottomBox)
this.$refs[detailType].bottomBox.targetTab = q.targetTab // this.$refs[detailType].bottomBox.targetTab = q.targetTab
this.$refs[detailType].bottomBox.object = JSON.parse(q.selectObj) // this.$refs[detailType].bottomBox.object = JSON.parse(q.selectObj)
}) // })
} else if (this.detailType === 'view' && q.detailType && q.selectObj) { // } else if (this.detailType === 'view' && q.detailType && q.selectObj) {
this.detailType = q.detailType // this.detailType = q.detailType
this.detailViewRightObj = JSON.parse(q.selectObj) // this.detailViewRightObj = JSON.parse(q.selectObj)
this.$store.commit('setGlobalSearchId', this.detailViewRightObj.id) // this.$store.commit('setGlobalSearchId', this.detailViewRightObj.id)
} // }
}, },
// 更新path包含请求参数 // 更新path包含请求参数
updatePath (param, path, from) { updatePath (param, path, from) {
@@ -58,7 +58,6 @@ export default {
}) })
if (!from) { if (!from) {
const detailType = this.detailType === 'list' ? 'dataList' : 'detailList' const detailType = this.detailType === 'list' ? 'dataList' : 'detailList'
localStorage.setItem('detail-view-' + this.tableId, this.detailType)
if (this.detailType) { if (this.detailType) {
params.detailType = this.detailType params.detailType = this.detailType
} }

View File

@@ -125,11 +125,6 @@ export default {
if (this.postPageSizes && this.postPageSizes.length > 0) { if (this.postPageSizes && this.postPageSizes.length > 0) {
this.pageSize = this.postPageSizes[0] this.pageSize = this.postPageSizes[0]
this.resetPageSizes() this.resetPageSizes()
} else {
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
if (pageSize != 'undefined' && pageSize != null) {
this.pageSize = parseInt(pageSize)
}
} }
}, },
watch: { watch: {
@@ -149,6 +144,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { handler (n, o) {
this.pageSize = this.pageObj.pageSize
} }
} }
} }

View File

@@ -96,7 +96,7 @@ export default {
url: 'alert/message', url: 'alert/message',
mainTableHeight: 'calc(100% - 64px)', mainTableHeight: 'calc(100% - 64px)',
state: '1', state: '1',
tableId: '', tableId: 'projectAlert',
stateOptions: alertMessageConstant.states, stateOptions: alertMessageConstant.states,
pageObj: { pageObj: {
pageNo: 1, pageNo: 1,
@@ -175,20 +175,36 @@ export default {
}, },
deleteBox: {}, deleteBox: {},
nowTime: '' nowTime: '',
projectPopTable: true
} }
}, },
created () { created () {
// 是否存在分页缓存
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
if (pageSize != 'undefined' && pageSize != null) {
this.pageObj.pageSize = pageSize
}
}, },
mounted () { async mounted () {
await this.getPreference()
this.getTableData() this.getTableData()
}, },
methods: { methods: {
// 获取用户偏好
async getPreference () {
const res = await this.$get('/sys/user/preference', { key: this.tableId })
if (res.data[this.tableId]) {
const data = JSON.parse(res.data[this.tableId])
this.pageObj.pageSize = data.pageSize
}
},
// 设置用户偏好
setPreference () {
const params = {
pageSize: this.pageObj.pageSize
}
this.$put('/sys/user/preference', { [this.tableId]: JSON.stringify(params) }).then(res => {
if (res.code !== 200) {
this.$message.error(res.msg || res.error)
}
})
},
getTableData: function () { getTableData: function () {
this.tools.loading = true this.tools.loading = true
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo) this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
@@ -242,7 +258,7 @@ export default {
}, },
pageSize (val) { pageSize (val) {
this.pageObj.pageSize = val this.pageObj.pageSize = val
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val) this.setPreference()
this.getTableData() this.getTableData()
}, },
selectChange (s) { selectChange (s) {

View File

@@ -7,7 +7,7 @@
:api="url" :api="url"
:custom-table-title.sync="tableTitle" :custom-table-title.sync="tableTitle"
:from="fromRoute.asset" :from="fromRoute.asset"
:layout="dataListLayout" :layout="['searchInput', 'pagination']"
:search-msg="searchMsg" :search-msg="searchMsg"
@search="search" @search="search"
:search-right="true" :search-right="true"
@@ -80,7 +80,6 @@ export default {
return { return {
url: 'asset/asset', url: 'asset/asset',
tableId: 'projectAsset', tableId: 'projectAsset',
dataListLayout: ['searchInput', 'pagination'],
pageObj: { pageObj: {
pageNo: 1, pageNo: 1,
pageSize: this.$CONSTANTS.defaultPageSize, pageSize: this.$CONSTANTS.defaultPageSize,
@@ -145,21 +144,37 @@ export default {
searchLabel: {}, searchLabel: {},
deleteBox: {}, deleteBox: {},
needAlertDaysData: true, needAlertDaysData: true,
trendKey: 'assetId' trendKey: 'assetId',
projectPopTable: true
} }
}, },
created () { created () {
// 是否存在分页缓存
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
if (pageSize != 'undefined' && pageSize != null) {
this.pageObj.pageSize = pageSize
}
}, },
mounted () { async mounted () {
await this.getPreference()
this.getTableTitle() this.getTableTitle()
this.getTableData() this.getTableData()
}, },
methods: { methods: {
// 获取用户偏好
async getPreference () {
const res = await this.$get('/sys/user/preference', { key: this.tableId })
if (res.data[this.tableId]) {
const data = JSON.parse(res.data[this.tableId])
this.pageObj.pageSize = data.pageSize
}
},
// 设置用户偏好
setPreference () {
const params = {
pageSize: this.pageObj.pageSize
}
this.$put('/sys/user/preference', { [this.tableId]: JSON.stringify(params) }).then(res => {
if (res.code !== 200) {
this.$message.error(res.msg || res.error)
}
})
},
getTableData: function () { getTableData: function () {
this.tools.loading = true this.tools.loading = true
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo) this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
@@ -202,7 +217,7 @@ export default {
}, },
pageSize (val) { pageSize (val) {
this.pageObj.pageSize = val this.pageObj.pageSize = val
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val) this.setPreference()
this.getTableData() this.getTableData()
}, },
selectChange (s) { selectChange (s) {

View File

@@ -84,7 +84,7 @@ export default {
data () { data () {
return { return {
url: 'monitor/endpoint', url: 'monitor/endpoint',
tableId: 'endpointTableProject', tableId: 'projectEndpoint',
pageObj: { pageObj: {
pageNo: 1, pageNo: 1,
pageSize: this.$CONSTANTS.defaultPageSize, pageSize: this.$CONSTANTS.defaultPageSize,
@@ -138,20 +138,36 @@ export default {
}, },
deleteBox: {}, deleteBox: {},
needAlertDaysData: true, needAlertDaysData: true,
trendKey: 'endpointId' trendKey: 'endpointId',
projectPopTable: true
} }
}, },
created () { created () {
// 是否存在分页缓存
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
if (pageSize != 'undefined' && pageSize != null) {
this.pageObj.pageSize = pageSize
}
}, },
mounted () { async mounted () {
await this.getPreference()
this.getTableData() this.getTableData()
}, },
methods: { methods: {
// 获取用户偏好
async getPreference () {
const res = await this.$get('/sys/user/preference', { key: this.tableId })
if (res.data[this.tableId]) {
const data = JSON.parse(res.data[this.tableId])
this.pageObj.pageSize = data.pageSize
}
},
// 设置用户偏好
setPreference () {
const params = {
pageSize: this.pageObj.pageSize
}
this.$put('/sys/user/preference', { [this.tableId]: JSON.stringify(params) }).then(res => {
if (res.code !== 200) {
this.$message.error(res.msg || res.error)
}
})
},
getTableData: function () { getTableData: function () {
this.tools.loading = true this.tools.loading = true
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo) this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
@@ -208,7 +224,7 @@ export default {
}, },
pageSize (val) { pageSize (val) {
this.pageObj.pageSize = val this.pageObj.pageSize = val
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val) this.setPreference()
this.getTableData() this.getTableData()
}, },
selectChange (s) { selectChange (s) {

View File

@@ -267,7 +267,7 @@ export default {
} }
}, },
updateCustomTableTitle (custom) { updateCustomTableTitle (custom) {
this.$emit('update:customTableTitle', custom) this.$parent.updateCustomTableTitle(custom)
}, },
// 全屏 // 全屏
fullScreen () { fullScreen () {

View File

@@ -113,9 +113,10 @@ export default {
obj: { obj: {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n) { async handler (n) {
if (n) { if (n) {
this.currentEndpoint = JSON.parse(JSON.stringify(n)) this.currentEndpoint = JSON.parse(JSON.stringify(n))
await this.getPreference()
this.queryEndpoint() this.queryEndpoint()
} }
} }
@@ -173,6 +174,25 @@ export default {
} }
}, },
methods: { methods: {
// 获取用户偏好
async getPreference () {
const res = await this.$get('/sys/user/preference', { key: this.tableId })
if (res.data[this.tableId]) {
const data = JSON.parse(res.data[this.tableId])
this.pageObj.pageSize = data.pageSize
}
},
// 设置用户偏好
setPreference () {
const params = {
pageSize: this.pageObj.pageSize
}
this.$put('/sys/user/preference', { [this.tableId]: JSON.stringify(params) }).then(res => {
if (res.code !== 200) {
this.$message.error(res.msg || res.error)
}
})
},
selectChange (selection) { // selection 选中的row的数组 selectChange (selection) { // selection 选中的row的数组
this.batchDeleteObjs = selection this.batchDeleteObjs = selection
this.$emit('changSelection', selection) this.$emit('changSelection', selection)
@@ -408,7 +428,7 @@ export default {
}, },
pageSize (val) { pageSize (val) {
this.pageObj.pageSize = val this.pageObj.pageSize = val
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val) this.setPreference()
this.handleCurrentChange() this.handleCurrentChange()
}, },
handleCurrentChange () { handleCurrentChange () {
@@ -454,9 +474,6 @@ export default {
} }
}, },
created () { created () {
// this.getPanelData()
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
this.pageObj.pageSize = pageSize || 20
} }
} }
</script> </script>

View File

@@ -113,9 +113,10 @@ export default {
obj: { obj: {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n) { async handler (n) {
if (n) { if (n) {
this.currentRecordRules = JSON.parse(JSON.stringify(n)) this.currentRecordRules = JSON.parse(JSON.stringify(n))
await this.getPreference()
this.queryRecordRules() this.queryRecordRules()
} }
} }
@@ -167,6 +168,25 @@ export default {
} }
}, },
methods: { methods: {
// 获取用户偏好
async getPreference () {
const res = await this.$get('/sys/user/preference', { key: this.tableId })
if (res.data[this.tableId]) {
const data = JSON.parse(res.data[this.tableId])
this.pageObj.pageSize = data.pageSize
}
},
// 设置用户偏好
setPreference () {
const params = {
pageSize: this.pageObj.pageSize
}
this.$put('/sys/user/preference', { [this.tableId]: JSON.stringify(params) }).then(res => {
if (res.code !== 200) {
this.$message.error(res.msg || res.error)
}
})
},
selectChange (selection) { // selection 选中的row的数组 selectChange (selection) { // selection 选中的row的数组
this.batchDeleteObjs = selection this.batchDeleteObjs = selection
this.$emit('changSelection', selection) this.$emit('changSelection', selection)
@@ -396,7 +416,7 @@ export default {
}, },
pageSize (val) { pageSize (val) {
this.pageObj.pageSize = val this.pageObj.pageSize = val
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val) this.setPreference()
this.handleCurrentChange() this.handleCurrentChange()
}, },
handleCurrentChange () { handleCurrentChange () {
@@ -432,9 +452,6 @@ export default {
} }
}, },
created () { created () {
// this.getPanelData()
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
this.pageObj.pageSize = pageSize || 20
} }
} }
</script> </script>

View File

@@ -6,7 +6,7 @@
:custom-table-title.sync="tools.customTableTitle" :custom-table-title.sync="tools.customTableTitle"
:from="fromRoute.alertMessage" :from="fromRoute.alertMessage"
:nz-table-height-offset="alertMessageNzTableHeightOffset" :nz-table-height-offset="alertMessageNzTableHeightOffset"
:layout="dataListLayout" :layout="['searchInput', 'elementSet', 'pagination']"
:search-msg="searchMsg" :search-msg="searchMsg"
@search="search" @search="search"
v-my-loading="tools.loading" v-my-loading="tools.loading"
@@ -15,9 +15,6 @@
<el-select v-model="state" class="margin-r-10" size="small" value-key="value" @change="getTableData" popper-class="right-box-select-top right-public-box-dropdown-top" style="width: 100px"> <el-select v-model="state" class="margin-r-10" size="small" value-key="value" @change="getTableData" popper-class="right-box-select-top right-public-box-dropdown-top" style="width: 100px">
<el-option v-for="item in stateOptions" :key="item.value" :label="$t(item.label)" :value="item.value"></el-option> <el-option v-for="item in stateOptions" :key="item.value" :label="$t(item.label)" :value="item.value"></el-option>
</el-select> </el-select>
<!-- <button id="asset-filter" :class="[dataListLayout.indexOf('clickSearch') > -1?'is-focus':'' ]" class="top-tool-btn margin-r-10" @click.stop="showClickSearch" :title="$t('dashboard.dashboard.chartForm.filter')">-->
<!-- <i class="nz-icon nz-icon-funnel"></i>-->
<!-- </button>-->
<pick-time ref="pickTime" v-model="searchTime" sign="message" :default-pick="defaultPick" :refresh-data-func="dateChange" :show-empty="true" :use-chart-unit="false" :use-refresh="false"></pick-time> <pick-time ref="pickTime" v-model="searchTime" sign="message" :default-pick="defaultPick" :refresh-data-func="dateChange" :show-empty="true" :use-chart-unit="false" :use-refresh="false"></pick-time>
<button id="roles-add" v-has="'alertMessage_view'" :title="$t('overall.exportExcel')" class="top-tool-btn margin-r-10" type="button" @click="showExportDialog"> <button id="roles-add" v-has="'alertMessage_view'" :title="$t('overall.exportExcel')" class="top-tool-btn margin-r-10" type="button" @click="showExportDialog">
<i class="nz-icon-download1 nz-icon"></i> <i class="nz-icon-download1 nz-icon"></i>
@@ -218,8 +215,6 @@ export default {
chartInfo: {}, chartInfo: {},
alertMessageNzTableHeightOffset: 242, alertMessageNzTableHeightOffset: 242,
stateOptions: alertMessageConstant.states, stateOptions: alertMessageConstant.states,
// dataListLayout: localStorage.getItem('dataList-layout' + 'alertMessageTable') ? JSON.parse(localStorage.getItem('dataList-layout' + 'alertMessageTable')) : ['searchInput', 'elementSet', 'clickSearch', 'pagination'],
dataListLayout: localStorage.getItem('dataList-layout' + 'alertMessageTable') ? JSON.parse(localStorage.getItem('dataList-layout' + 'alertMessageTable')) : ['searchInput', 'elementSet', 'pagination'],
state: '1', state: '1',
dialogShowText: false, dialogShowText: false,
dialogText: '', dialogText: '',

View File

@@ -1,8 +1,8 @@
<template> <template>
<div style="height: 100%" id="asset-batch-table"> <div style="height: 100%" id="asset-batch-table" v-my-loading="preferenceLoading">
<nzDetailView <nzDetailView
v-my-loading="detailViewLoading || tools.loading" v-my-loading="detailViewLoading || tools.loading"
v-if="detailType !== 'list'" v-if="detailType !== 'list'&&!preferenceLoading"
:api="url" :api="url"
ref="detailList" ref="detailList"
:layout="dataListLayout" :layout="dataListLayout"
@@ -74,7 +74,7 @@
</nzDetailView> </nzDetailView>
<nz-data-list <nz-data-list
v-my-loading="detailViewLoading" v-my-loading="detailViewLoading"
v-if="detailType === 'list'" v-if="detailType === 'list'&&!preferenceLoading"
ref="dataList" ref="dataList"
:api="url" :api="url"
:custom-table-title.sync="tools.customTableTitle" :custom-table-title.sync="tools.customTableTitle"
@@ -247,7 +247,7 @@ export default {
batchShow: false batchShow: false
}, },
silenceBoxShow: false, silenceBoxShow: false,
dataListLayout: localStorage.getItem('dataList-layoutassetNzTableHeightOffset' + 'assetTable') ? JSON.parse(localStorage.getItem('dataList-layout' + 'assetTable')) : ['searchInput', 'elementSet', 'clickSearch', 'pagination', 'detailViewSet'], dataListLayout: ['searchInput', 'elementSet', 'clickSearch', 'pagination', 'detailViewSet'],
assetNzTableHeightOffset: 287, // 包含click-search时nz-table的高度 assetNzTableHeightOffset: 287, // 包含click-search时nz-table的高度
blankObject: { blankObject: {
id: '', id: '',

View File

@@ -1,8 +1,8 @@
<template> <template>
<div> <div v-my-loading="preferenceLoading">
<nzDetailView <nzDetailView
v-my-loading="detailViewLoading || tools.loading" v-my-loading="detailViewLoading || tools.loading"
v-if="detailType !== 'list'" v-if="detailType !== 'list'&&!preferenceLoading"
:api="url" :api="url"
ref="detailList" ref="detailList"
:layout="['searchInput', 'elementSet', 'pagination','detailViewSet']" :layout="['searchInput', 'elementSet', 'pagination','detailViewSet']"
@@ -74,7 +74,7 @@
<nz-data-list <nz-data-list
ref="dataList" ref="dataList"
:api="url" :api="url"
v-if="detailType === 'list'" v-if="detailType === 'list'&&!preferenceLoading"
:layout="['searchInput', 'elementSet', 'pagination','detailViewSet']" :layout="['searchInput', 'elementSet', 'pagination','detailViewSet']"
:custom-table-title.sync="tools.customTableTitle" :custom-table-title.sync="tools.customTableTitle"
:from="fromRoute.dc" :from="fromRoute.dc"

View File

@@ -1,8 +1,8 @@
<template> <template>
<div> <div v-my-loading="preferenceLoading">
<nzDetailView <nzDetailView
v-my-loading="detailViewLoading || tools.loading" v-my-loading="detailViewLoading || tools.loading"
v-if="detailType !== 'list'" v-if="detailType !== 'list'&&!preferenceLoading"
:api="url" :api="url"
ref="detailList" ref="detailList"
:layout="['searchInput', 'elementSet', 'pagination','detailViewSet']" :layout="['searchInput', 'elementSet', 'pagination','detailViewSet']"
@@ -54,7 +54,7 @@
<nz-data-list <nz-data-list
ref="dataList" ref="dataList"
:api="url" :api="url"
v-if="detailType === 'list'" v-if="detailType === 'list'&&!preferenceLoading"
:layout="['searchInput', 'elementSet', 'pagination','detailViewSet']" :layout="['searchInput', 'elementSet', 'pagination','detailViewSet']"
:custom-table-title.sync="tools.customTableTitle" :custom-table-title.sync="tools.customTableTitle"
:from="fromRoute.terminalLog" :from="fromRoute.terminalLog"

View File

@@ -1,8 +1,8 @@
<template> <template>
<div id="endpoint-list"> <div id="endpoint-list" v-my-loading="preferenceLoading">
<nzDetailView <nzDetailView
v-my-loading="detailViewLoading || tools.loading" v-my-loading="detailViewLoading || tools.loading"
v-if="detailType !== 'list'" v-if="detailType !== 'list'&&!preferenceLoading"
:api="url" :api="url"
ref="detailList" ref="detailList"
:layout="dataListLayout" :layout="dataListLayout"
@@ -71,7 +71,7 @@
<nz-data-list <nz-data-list
v-my-loading="detailViewLoading" v-my-loading="detailViewLoading"
ref="dataList" ref="dataList"
v-if="detailType === 'list'" v-if="detailType === 'list'&&!preferenceLoading"
:api="url" :api="url"
:custom-table-title.sync="tools.customTableTitle" :custom-table-title.sync="tools.customTableTitle"
:from="fromRoute.endpoint" :from="fromRoute.endpoint"
@@ -385,7 +385,7 @@ export default {
tableId: 'endpointTable', tableId: 'endpointTable',
queryPermission: 'account_view', queryPermission: 'account_view',
endpointTableHeight: 'calc(100% - 244px)', // 主列表table高度 endpointTableHeight: 'calc(100% - 244px)', // 主列表table高度
dataListLayout: localStorage.getItem('dataList-layout' + 'endpointTable') ? JSON.parse(localStorage.getItem('dataList-layout' + 'endpointTable')) : ['searchInput', 'elementSet', 'clickSearch', 'pagination', 'detailViewSet'], dataListLayout: ['searchInput', 'elementSet', 'clickSearch', 'pagination', 'detailViewSet'],
searchMsg: { // 给搜索框子组件传递的信息 searchMsg: { // 给搜索框子组件传递的信息
zheze_none: true, zheze_none: true,
searchLabelList: [ searchLabelList: [

View File

@@ -1,8 +1,8 @@
<template> <template>
<div class="module-list"> <div class="module-list" v-my-loading="preferenceLoading">
<nzDetailView <nzDetailView
v-my-loading="detailViewLoading || tools.loading" v-my-loading="detailViewLoading || tools.loading"
v-if="detailType !== 'list'" v-if="detailType !== 'list'&&!preferenceLoading"
:api="url" :api="url"
ref="detailList" ref="detailList"
:layout="['searchInput', 'elementSet', 'pagination','detailViewSet']" :layout="['searchInput', 'elementSet', 'pagination','detailViewSet']"
@@ -72,7 +72,7 @@
ref="dataList" ref="dataList"
:api="url" :api="url"
:tableId="tableId" :tableId="tableId"
v-if="detailType === 'list'" v-if="detailType === 'list'&&!preferenceLoading"
:custom-table-title.sync="tools.customTableTitle" :custom-table-title.sync="tools.customTableTitle"
:from="fromRoute.module" :from="fromRoute.module"
:layout="['searchInput', 'elementSet', 'pagination','detailViewSet']" :layout="['searchInput', 'elementSet', 'pagination','detailViewSet']"

View File

@@ -92,7 +92,7 @@ export default {
topoData: {}, topoData: {},
querysArray: {}, querysArray: {},
currentProject: {}, currentProject: {},
params: {}, params: {}
}, },
/* 二级页面相关 */ /* 二级页面相关 */
bottomBox: { bottomBox: {
@@ -311,7 +311,6 @@ export default {
}, },
endpointPageSize (val) { endpointPageSize (val) {
this.endpointPageObj.pageSize = val this.endpointPageObj.pageSize = val
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val)
this.getEndpointTableData() this.getEndpointTableData()
}, },
@@ -608,11 +607,6 @@ export default {
}, },
created () { created () {
this.currentProject = this.$store.state.currentProject this.currentProject = this.$store.state.currentProject
// 是否存在分页缓存
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
if (pageSize) {
this.endpointPageObj.pageSize = pageSize
}
}, },
mounted () { mounted () {
// 初始化表头 // 初始化表头