fix: 修复应用授权远程应用以外的类型不显示字段说明

This commit is contained in:
“huailei000” 2022-08-16 12:16:17 +08:00 committed by Jiangjie.Bai
parent 2fb160b5f7
commit 4ce6f49b30
2 changed files with 11 additions and 7 deletions

View File

@ -12,19 +12,23 @@
import { GenericCreateUpdatePage } from '@/layout/components' import { GenericCreateUpdatePage } from '@/layout/components'
import { getDayFuture } from '@/utils/common' import { getDayFuture } from '@/utils/common'
import PermissionFormActionField from '../components/PermissionFormActionField' import PermissionFormActionField from '../components/PermissionFormActionField'
import { remoteApplication } from '../const.js'
export default { export default {
components: { components: {
GenericCreateUpdatePage GenericCreateUpdatePage
}, },
data() { data() {
const queryCategory = this.$route.query.category
const queryType = this.$route.query.type
const urlSearchFields = `category=${queryCategory}&type=${queryType}`
return { return {
initial: { initial: {
is_active: true, is_active: true,
date_start: new Date().toISOString(), date_start: new Date().toISOString(),
date_expired: getDayFuture(36500, new Date()).toISOString(), date_expired: getDayFuture(36500, new Date()).toISOString(),
type: this.$route.query.type, type: queryType,
category: this.$route.query.category category: queryCategory
}, },
fields: [ fields: [
[this.$t('common.Basic'), ['name']], [this.$t('common.Basic'), ['name']],
@ -33,7 +37,7 @@ export default {
[this.$t('common.action'), ['actions']], [this.$t('common.action'), ['actions']],
[this.$t('common.Other'), ['is_active', 'date_start', 'date_expired', 'comment']] [this.$t('common.Other'), ['is_active', 'date_start', 'date_expired', 'comment']]
], ],
url: `/api/v1/perms/application-permissions/?category=${this.$route.query.category}&type=${this.$route.query.type}`, url: `/api/v1/perms/application-permissions/?${urlSearchFields}`,
createSuccessNextRoute: { name: 'ApplicationPermissionDetail' }, createSuccessNextRoute: { name: 'ApplicationPermissionDetail' },
fieldsMeta: { fieldsMeta: {
users: { users: {
@ -66,7 +70,7 @@ export default {
el: { el: {
value: [], value: [],
ajax: { ajax: {
url: `/api/v1/applications/applications/?category=${this.$route.query.category}&type=${this.$route.query.type}`, url: `/api/v1/applications/applications/?${urlSearchFields}`,
transformOption: (item) => { transformOption: (item) => {
return { label: item.name + ' (' + item.type_display + ')', value: item.id } return { label: item.name + ' (' + item.type_display + ')', value: item.id }
} }
@ -79,7 +83,6 @@ export default {
ajax: { ajax: {
url: (function() { url: (function() {
let url = '/api/v1/assets/system-users/' let url = '/api/v1/assets/system-users/'
const queryType = this.$route.query.type
if (this.$route.query.category === 'remote_app') { if (this.$route.query.category === 'remote_app') {
url += `?protocol=rdp` url += `?protocol=rdp`
} else if (queryType) { } else if (queryType) {
@ -88,7 +91,7 @@ export default {
return url return url
}.bind(this)()), }.bind(this)()),
transformOption: (item) => { transformOption: (item) => {
if (this.$route.query.type === 'k8s') { if (queryType === 'k8s') {
return { label: item.name, value: item.id } return { label: item.name, value: item.id }
} }
const username = item.username || '*' const username = item.username || '*'
@ -106,7 +109,7 @@ export default {
actions: { actions: {
label: this.$t('perms.Actions'), label: this.$t('perms.Actions'),
component: PermissionFormActionField, component: PermissionFormActionField,
helpText: this.$t('common.actionsTips') helpText: remoteApplication.includes(queryType) ? this.$t('common.actionsTips') : ''
}, },
is_active: { is_active: {
type: 'checkbox' type: 'checkbox'

View File

@ -0,0 +1 @@
export const remoteApplication = ['chrome', 'mysql_workbench', 'vmware_client', 'custom']