mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-30 04:03:49 +00:00
fix: select2添加axios参数无权限时不弹出提示
This commit is contained in:
parent
2b984cb456
commit
1bf3371a00
@ -88,6 +88,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
const vm = this
|
||||||
const defaultPageSize = 10
|
const defaultPageSize = 10
|
||||||
const defaultParams = {
|
const defaultParams = {
|
||||||
search: '',
|
search: '',
|
||||||
@ -95,7 +96,18 @@ export default {
|
|||||||
hasMore: true,
|
hasMore: true,
|
||||||
pageSize: defaultPageSize
|
pageSize: defaultPageSize
|
||||||
}
|
}
|
||||||
|
// 设置axios全局报错提示不显示
|
||||||
|
const validateStatus = (status) => {
|
||||||
|
if (status === 403) {
|
||||||
|
setTimeout(() => {
|
||||||
|
vm.initialized = true
|
||||||
|
}, 300)
|
||||||
|
return 200
|
||||||
|
}
|
||||||
|
return status
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
|
validateStatus,
|
||||||
loading: false,
|
loading: false,
|
||||||
initialized: false,
|
initialized: false,
|
||||||
defaultParams: _.cloneDeep(defaultParams),
|
defaultParams: _.cloneDeep(defaultParams),
|
||||||
@ -150,7 +162,7 @@ export default {
|
|||||||
results = data
|
results = data
|
||||||
total = data.length
|
total = data.length
|
||||||
} else if (typeof data === 'object') {
|
} else if (typeof data === 'object') {
|
||||||
results = data.results
|
results = data?.results || []
|
||||||
more = !!data.next
|
more = !!data.next
|
||||||
total = data.count
|
total = data.count
|
||||||
}
|
}
|
||||||
@ -163,7 +175,8 @@ export default {
|
|||||||
pageSize: defaultPageSize,
|
pageSize: defaultPageSize,
|
||||||
makeParams: defaultMakeParams,
|
makeParams: defaultMakeParams,
|
||||||
transformOption: defaultTransformOption,
|
transformOption: defaultTransformOption,
|
||||||
processResults: defaultProcessResults
|
processResults: defaultProcessResults,
|
||||||
|
validateStatus: this.validateStatus
|
||||||
}
|
}
|
||||||
return Object.assign(defaultAjax, this.ajax, this.url ? { url: this.url } : {})
|
return Object.assign(defaultAjax, this.ajax, this.url ? { url: this.url } : {})
|
||||||
}
|
}
|
||||||
@ -231,9 +244,13 @@ export default {
|
|||||||
this.getOptions()
|
this.getOptions()
|
||||||
},
|
},
|
||||||
async getInitialOptions() {
|
async getInitialOptions() {
|
||||||
|
const { url, processResults, validateStatus } = this.iAjax
|
||||||
const params = this.safeMakeParams(this.params)
|
const params = this.safeMakeParams(this.params)
|
||||||
let data = await this.$axios.get(this.iAjax.url, { params: params })
|
let data = await this.$axios.get(url, {
|
||||||
data = this.iAjax.processResults.bind(this)(data)
|
params,
|
||||||
|
validateStatus
|
||||||
|
})
|
||||||
|
data = processResults.bind(this)(data)
|
||||||
data.results.forEach((v) => {
|
data.results.forEach((v) => {
|
||||||
this.initialOptions.push(v)
|
this.initialOptions.push(v)
|
||||||
if (this.optionsValues.indexOf(v.value) === -1) {
|
if (this.optionsValues.indexOf(v.value) === -1) {
|
||||||
@ -251,9 +268,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getOptions() {
|
async getOptions() {
|
||||||
|
const { url, processResults, validateStatus } = this.iAjax
|
||||||
const params = this.safeMakeParams(this.params)
|
const params = this.safeMakeParams(this.params)
|
||||||
const resp = await this.$axios.get(this.iAjax.url, { params: params })
|
const resp = await this.$axios.get(url, {
|
||||||
const data = this.iAjax.processResults.bind(this)(resp)
|
params,
|
||||||
|
validateStatus
|
||||||
|
})
|
||||||
|
const data = processResults.bind(this)(resp)
|
||||||
if (!data.pagination) {
|
if (!data.pagination) {
|
||||||
this.params.hasMore = false
|
this.params.hasMore = false
|
||||||
}
|
}
|
||||||
|
@ -217,9 +217,17 @@ export default {
|
|||||||
async loadHasObjects() {
|
async loadHasObjects() {
|
||||||
this.$log.debug('Start loadHasObject: ', this.params)
|
this.$log.debug('Start loadHasObject: ', this.params)
|
||||||
const params = this.safeMakeParams(this.params)
|
const params = this.safeMakeParams(this.params)
|
||||||
let data = await this.$axios.get(this.iAjax.url, { params: params })
|
let data = await this.$axios.get(this.iAjax.url, {
|
||||||
|
params: params,
|
||||||
|
validateStatus: (status) => {
|
||||||
|
if (status === 403) {
|
||||||
|
return 200
|
||||||
|
}
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
})
|
||||||
data = this.iAjax.processResults.bind(this)(data)
|
data = this.iAjax.processResults.bind(this)(data)
|
||||||
data.results.forEach((v) => {
|
data.results && data.results.forEach((v) => {
|
||||||
if (!this.hasObjects.find((item) => item.value === v.value)) {
|
if (!this.hasObjects.find((item) => item.value === v.value)) {
|
||||||
this.iHasObjects.push(v)
|
this.iHasObjects.push(v)
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,10 @@ export default {
|
|||||||
hasRefresh: true,
|
hasRefresh: true,
|
||||||
hasSearch: true,
|
hasSearch: true,
|
||||||
hasMoreActions: false,
|
hasMoreActions: false,
|
||||||
createRoute: 'CommandFilterCreate'
|
createRoute: 'CommandFilterCreate',
|
||||||
|
canCreate: () => {
|
||||||
|
return this.$hasPerm('assets.add_commandfilter')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user