mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-15 14:24:39 +00:00
[Update] 修改详情页
This commit is contained in:
@@ -10,7 +10,6 @@ import FormGroupHeader from '@/components/formGroupHeader'
|
||||
import { optionUrlMeta } from '@/api/common'
|
||||
import rules from '@/components/DataForm/rules'
|
||||
import Select2 from '@/components/Select2'
|
||||
import _ from 'lodash'
|
||||
export default {
|
||||
name: 'AutoDataForm',
|
||||
components: {
|
||||
@@ -79,6 +78,7 @@ export default {
|
||||
type = 'input'
|
||||
if (!fieldMeta.max_length) {
|
||||
field.el.type = 'textarea'
|
||||
field.el.rows = 3
|
||||
}
|
||||
break
|
||||
default:
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
<script>
|
||||
import Page from '../Page/'
|
||||
import { getApiPath } from '@/utils/common'
|
||||
import ActionsGroup from '@/components/ActionsGroup'
|
||||
export default {
|
||||
name: 'GenericDetailPage',
|
||||
@@ -60,9 +61,17 @@ export default {
|
||||
return this.defaultDelete(item)
|
||||
}
|
||||
},
|
||||
deleteRoute: {
|
||||
deleteUrl: {
|
||||
type: String,
|
||||
default: null
|
||||
default: function() {
|
||||
return getApiPath(this)
|
||||
}
|
||||
},
|
||||
deleteSuccessRoute: {
|
||||
type: String,
|
||||
default: function() {
|
||||
return this.$route.name.replace('Detail', 'List')
|
||||
}
|
||||
},
|
||||
canUpdate: {
|
||||
type: [Boolean, Function],
|
||||
@@ -76,7 +85,9 @@ export default {
|
||||
},
|
||||
updateRoute: {
|
||||
type: String,
|
||||
default: null
|
||||
default: function() {
|
||||
return this.$route.name.replace('Detail', 'Update')
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -100,13 +111,39 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
defaultDelete() {
|
||||
|
||||
const msg = this.$tc('Are you sure to delete') + ' ?'
|
||||
const title = this.$tc('Info')
|
||||
const performDelete = async function() {
|
||||
this.$log.debug('Start perform delete: ', this.deleteUrl)
|
||||
return this.$axios.delete(this.deleteUrl)
|
||||
}
|
||||
this.$alert(msg, title, {
|
||||
type: 'warning',
|
||||
confirmButtonClass: 'el-button--danger',
|
||||
showCancelButton: true,
|
||||
beforeClose: async(action, instance, done) => {
|
||||
if (action !== 'confirm') return done()
|
||||
instance.confirmButtonLoading = true
|
||||
try {
|
||||
await performDelete.bind(this)()
|
||||
done()
|
||||
this.$message.success(this.$tc('Delete success'))
|
||||
this.$router.push({ name: this.deleteSuccessRoute })
|
||||
} catch (error) {
|
||||
this.$message.error(this.$tc('Delete failed' + ' ' + error))
|
||||
} finally {
|
||||
instance.confirmButtonLoading = false
|
||||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
/* 取消*/
|
||||
})
|
||||
},
|
||||
defaultUpdate() {
|
||||
const id = this.$route.params.id
|
||||
const defaultUpdateRoute = this.$route.name.replace('Detail', 'Update')
|
||||
const routeName = this.updateRoute || defaultUpdateRoute
|
||||
this.$router.push({ name: routeName, params: { id: id }})
|
||||
this.$router.push({ name: this.updateRoute, params: { id: id }})
|
||||
},
|
||||
getObject() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,3 +76,8 @@ export function toSafeLocalDateStr(d) {
|
||||
const date_s = date.toLocaleString(getUserLang(), { hourCycle: 'h23' })
|
||||
return date_s.split('/').join('-')
|
||||
}
|
||||
|
||||
export function getApiPath(that) {
|
||||
const pagePath = that.$route.path
|
||||
return `/api/v1${pagePath}/`
|
||||
}
|
||||
|
||||
@@ -12,11 +12,6 @@ export default {
|
||||
return {
|
||||
config: {
|
||||
initial: {
|
||||
password_strategy: 0,
|
||||
mfa_level: 0,
|
||||
source: 'local',
|
||||
role: 'Admin',
|
||||
date_expired: '2099-12-31 00:00:00 +0800'
|
||||
},
|
||||
url: '/api/v1/users/groups/',
|
||||
fields: ['name', 'users', 'comment'],
|
||||
|
||||
@@ -51,7 +51,7 @@ export default {
|
||||
name: 'assetPermissions'
|
||||
}
|
||||
],
|
||||
canDelete: this.canDelete,
|
||||
canDelete: true,
|
||||
canUpdate: true
|
||||
},
|
||||
groupMembers: [],
|
||||
|
||||
Reference in New Issue
Block a user