mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-19 17:54:37 +00:00
fix: 修改终端列表批量更新的问题
This commit is contained in:
@@ -1,19 +1,99 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<ListTable :table-config="tableConfig" :header-actions="headerActions" />
|
<ListTable :table-config="tableConfig" :header-actions="headerActions" />
|
||||||
|
<Dialog
|
||||||
|
:visible.sync="dialogSettings.visible"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
:show-cancel="false"
|
||||||
|
:title="$tc('sessions.terminalUpdateStorage')"
|
||||||
|
:show-confirm="false"
|
||||||
|
>
|
||||||
|
<GenericCreateUpdateForm v-bind="dialogSettings.iFormSetting" />
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ListTable from '@/components/ListTable'
|
import ListTable from '@/components/ListTable'
|
||||||
|
import { GenericCreateUpdateForm } from '@/layout/components'
|
||||||
|
import Dialog from '@/components/Dialog'
|
||||||
|
import Select2 from '@/components/FormFields/Select2'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ListTable
|
ListTable,
|
||||||
|
Dialog,
|
||||||
|
GenericCreateUpdateForm
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const vm = this
|
const vm = this
|
||||||
return {
|
return {
|
||||||
|
dialogSettings: {
|
||||||
|
selectedRows: [],
|
||||||
|
visible: false,
|
||||||
|
iFormSetting: {
|
||||||
|
url: '/api/v1/terminal/terminals/',
|
||||||
|
getUrl: () => '/api/v1/terminal/terminals/',
|
||||||
|
fields: [
|
||||||
|
['', ['command_storage', 'replay_storage']]
|
||||||
|
],
|
||||||
|
fieldsMeta: {
|
||||||
|
command_storage: {
|
||||||
|
label: this.$t('sessions.commandStorage'),
|
||||||
|
component: Select2,
|
||||||
|
el: {
|
||||||
|
ajax: {
|
||||||
|
url: `/api/v1/terminal/command-storages/`
|
||||||
|
},
|
||||||
|
multiple: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
replay_storage: {
|
||||||
|
label: this.$t('sessions.replayStorage'),
|
||||||
|
component: Select2,
|
||||||
|
el: {
|
||||||
|
ajax: {
|
||||||
|
url: `/api/v1/terminal/replay-storages/`
|
||||||
|
},
|
||||||
|
multiple: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
submitMethod: () => 'post',
|
||||||
|
cleanFormValue: (value) => {
|
||||||
|
const formValue = []
|
||||||
|
let object = {}
|
||||||
|
for (const row of this.dialogSettings.selectedRows) {
|
||||||
|
object = Object.assign({}, value, { id: row.id })
|
||||||
|
formValue.push(object)
|
||||||
|
}
|
||||||
|
return formValue
|
||||||
|
},
|
||||||
|
onSubmit: (validValues) => {
|
||||||
|
const url = '/api/v1/terminal/terminals/'
|
||||||
|
const msg = this.$t('common.updateSuccessMsg')
|
||||||
|
validValues = Object.values(validValues)
|
||||||
|
this.$axios.patch(url, validValues).then((res) => {
|
||||||
|
this.$message.success(msg)
|
||||||
|
this.dialogSettings.visible = false
|
||||||
|
}).catch(error => {
|
||||||
|
this.$emit('submitError', error)
|
||||||
|
const response = error.response
|
||||||
|
const data = response.data
|
||||||
|
if (response.status === 400) {
|
||||||
|
for (const key of Object.keys(data)) {
|
||||||
|
let value = data[key]
|
||||||
|
if (value instanceof Array) {
|
||||||
|
value = value.join(';')
|
||||||
|
}
|
||||||
|
this.$refs.form.setFieldError(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
hasSaveContinue: false
|
||||||
|
}
|
||||||
|
},
|
||||||
tableConfig: {
|
tableConfig: {
|
||||||
url: '/api/v1/terminal/terminals/',
|
url: '/api/v1/terminal/terminals/',
|
||||||
permissions: {
|
permissions: {
|
||||||
|
Reference in New Issue
Block a user