mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-25 22:44:13 +00:00
fix: 修复工单动作组件不回显问题
This commit is contained in:
@@ -1,129 +0,0 @@
|
||||
<template>
|
||||
<el-tree
|
||||
:data="iData"
|
||||
show-checkbox
|
||||
node-key="id"
|
||||
:default-expand-all="true"
|
||||
:default-checked-keys="value"
|
||||
:props="defaultProps"
|
||||
v-bind="$attrs"
|
||||
@check="handleCheckChange"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'PermissionFormActionField',
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
choices: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
actions: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
},
|
||||
fullChoicesTreeNodes: [
|
||||
{
|
||||
id: 'all',
|
||||
label: this.$t('perms.all'),
|
||||
children: [
|
||||
{
|
||||
id: 'connect',
|
||||
label: this.$t('perms.connect')
|
||||
},
|
||||
{
|
||||
id: 'updownload',
|
||||
label: this.$t('perms.upDownload'),
|
||||
children: [
|
||||
{
|
||||
id: 'upload_file',
|
||||
label: this.$t('perms.uploadFile')
|
||||
},
|
||||
{
|
||||
id: 'download_file',
|
||||
label: this.$t('perms.downloadFile')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'clipboard_copy_paste',
|
||||
label: this.$t('perms.clipboardCopyPaste'),
|
||||
children: [
|
||||
{
|
||||
id: 'clipboard_copy',
|
||||
label: this.$t('perms.clipboardCopy')
|
||||
},
|
||||
{
|
||||
id: 'clipboard_paste',
|
||||
label: this.$t('perms.clipboardPaste')
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
choicesIDs() {
|
||||
if (this.actions.length !== 0) {
|
||||
return this.actions
|
||||
}
|
||||
if (this.choices.length === 0) {
|
||||
return [
|
||||
'all', 'connect', 'upload_file', 'download_file', 'updownload',
|
||||
'clipboard_copy_paste', 'clipboard_copy', 'clipboard_paste'
|
||||
]
|
||||
}
|
||||
return this.choices.map((v) => v.value)
|
||||
},
|
||||
iData() {
|
||||
this.$log.debug('choices: ', this.choicesIDs)
|
||||
const fullTreeNodes = _.cloneDeep(this.fullChoicesTreeNodes)
|
||||
const treeNodes = this.trimChoicesTreeNodes(fullTreeNodes)
|
||||
this.$log.debug('choicesTreeNodes: ', treeNodes)
|
||||
return treeNodes
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
trimChoicesTreeNodes(treeNodes) {
|
||||
const newTreeNodes = []
|
||||
for (const treeNode of treeNodes) {
|
||||
if (!this.choicesIDs.includes(treeNode.id)) {
|
||||
continue
|
||||
}
|
||||
let children = treeNode.children || []
|
||||
if (children.length !== 0) {
|
||||
children = this.trimChoicesTreeNodes(children)
|
||||
treeNode.children = children
|
||||
}
|
||||
newTreeNodes.push(treeNode)
|
||||
}
|
||||
return newTreeNodes
|
||||
},
|
||||
handleCheckChange(data, obj) {
|
||||
const checkedKeys = obj.checkedKeys
|
||||
if (checkedKeys.length !== 0) {
|
||||
checkedKeys.push('connect')
|
||||
}
|
||||
this.$emit('input', checkedKeys)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -12,7 +12,6 @@ import PasswordInput from './PasswordInput'
|
||||
import WeekCronSelect from './WeekCronSelect'
|
||||
import NestedObjectSelect2 from './NestedObjectSelect2'
|
||||
import DatetimeRangePicker from './DatetimeRangePicker'
|
||||
import PermissionFormActionField from './PermissionFormActionField'
|
||||
|
||||
export default {
|
||||
Text,
|
||||
@@ -28,8 +27,7 @@ export default {
|
||||
PasswordInput,
|
||||
WeekCronSelect,
|
||||
NestedObjectSelect2,
|
||||
DatetimeRangePicker,
|
||||
PermissionFormActionField
|
||||
DatetimeRangePicker
|
||||
}
|
||||
|
||||
export {
|
||||
@@ -46,6 +44,5 @@ export {
|
||||
PasswordInput,
|
||||
WeekCronSelect,
|
||||
NestedObjectSelect2,
|
||||
DatetimeRangePicker,
|
||||
PermissionFormActionField
|
||||
DatetimeRangePicker
|
||||
}
|
||||
|
||||
@@ -410,6 +410,8 @@
|
||||
"Delete": "Delete",
|
||||
"Disable": "Disable",
|
||||
"Download": "Download",
|
||||
"ClipBoard": "ClipBoard",
|
||||
"Paste": "Paste",
|
||||
"Copy": "Copy",
|
||||
"CopySuccess": "Copy success",
|
||||
"Enable": "Enable",
|
||||
|
||||
@@ -416,6 +416,8 @@
|
||||
"Delete": "削除",
|
||||
"Disable": "無効",
|
||||
"Download": "ダウンロード",
|
||||
"ClipBoard": "クリップボード",
|
||||
"Paste": "貼り付け",
|
||||
"Copy": "コピー",
|
||||
"CopySuccess": "コピー成功",
|
||||
"Enable": "有効化",
|
||||
|
||||
@@ -529,6 +529,8 @@
|
||||
"Delete": "删除",
|
||||
"Disable": "禁用",
|
||||
"Download": "下载",
|
||||
"ClipBoard": "剪切板",
|
||||
"Paste": "粘贴",
|
||||
"Copy": "复制",
|
||||
"CopySuccess": "复制成功",
|
||||
"Enable": "启用",
|
||||
|
||||
@@ -35,8 +35,9 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$tc('assets.Action')" required>
|
||||
<PermissionFormActionField
|
||||
<BasicTree
|
||||
v-model="requestForm.actions"
|
||||
:tree="treeNodes"
|
||||
style="width: 30% !important"
|
||||
/>
|
||||
|
||||
@@ -50,16 +51,16 @@
|
||||
<script>
|
||||
import { formatTime, getDateTimeStamp } from '@/utils/index'
|
||||
import { toSafeLocalDateStr } from '@/utils/common'
|
||||
import { STATUS_MAP } from '../../const'
|
||||
import { STATUS_MAP, treeNodes } from '../../const'
|
||||
import GenericTicketDetail from '@/views/tickets/components/GenericTicketDetail'
|
||||
import AccountFormatter from '@/views/perms/AssetPermission/components/AccountFormatter'
|
||||
import Select2 from '@/components/FormFields/Select2'
|
||||
import PermissionFormActionField from '@/components/FormFields/PermissionFormActionField'
|
||||
import BasicTree from '@/components/FormFields/BasicTree'
|
||||
import IBox from '@/components/IBox'
|
||||
|
||||
export default {
|
||||
name: '',
|
||||
components: { GenericTicketDetail, IBox, Select2, AccountFormatter, PermissionFormActionField },
|
||||
components: { GenericTicketDetail, IBox, Select2, AccountFormatter, BasicTree },
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
@@ -68,6 +69,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
treeNodes,
|
||||
statusMap: this.object.status.value === 'open' ? STATUS_MAP['pending'] : STATUS_MAP[this.object.state.value],
|
||||
requestForm: {
|
||||
nodes: this.object.apply_nodes,
|
||||
@@ -168,7 +170,7 @@ export default {
|
||||
},
|
||||
{
|
||||
key: this.$tc('perms.Accounts'),
|
||||
value: (rel_snapshot.apply_accounts || []).join(', ')
|
||||
value: (object.apply_accounts || []).join(', ')
|
||||
},
|
||||
{
|
||||
key: this.$tc('assets.Action'),
|
||||
@@ -190,9 +192,6 @@ export default {
|
||||
return this.object.process_map[approval_step - 1].assignees.indexOf(current_user_id) !== -1
|
||||
}
|
||||
},
|
||||
created() {
|
||||
console.log(this.object, 'this.object-------------------------===============================')
|
||||
},
|
||||
methods: {
|
||||
formatTime(dateStr) {
|
||||
return formatTime(getDateTimeStamp(dateStr))
|
||||
@@ -207,8 +206,6 @@ export default {
|
||||
const nodes = this.requestForm.nodes
|
||||
const assets = this.requestForm.assets
|
||||
const accounts = this.requestForm.accounts
|
||||
console.log(this.object, '------------------------------------------this.object')
|
||||
console.log('this.requestForm: ===========================================', this.requestForm)
|
||||
if (this.object.approval_step.value === this.object.process_map.length) {
|
||||
if (assets.length === 0 && nodes.length === 0) {
|
||||
return this.$message.error(this.$tc('common.SelectAtLeastOneAssetOrNodeErrMsg'))
|
||||
|
||||
@@ -34,3 +34,44 @@ export const STATE_MAP = {
|
||||
type: 'warning', title: i18n.t('tickets.StateClosed')
|
||||
}
|
||||
}
|
||||
|
||||
export const treeNodes = [
|
||||
{
|
||||
value: 'all',
|
||||
label: i18n.t('perms.all'),
|
||||
children: [
|
||||
{
|
||||
value: 'connect',
|
||||
label: i18n.t('perms.connect')
|
||||
},
|
||||
{
|
||||
value: 'updownload',
|
||||
label: i18n.t('route.FileTransfer'),
|
||||
children: [
|
||||
{
|
||||
value: 'upload',
|
||||
label: i18n.t('perms.uploadFile')
|
||||
},
|
||||
{
|
||||
value: 'download',
|
||||
label: i18n.t('perms.downloadFile')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
value: 'copy_paste',
|
||||
label: i18n.t('perms.clipboardCopyPaste'),
|
||||
children: [
|
||||
{
|
||||
value: 'copy',
|
||||
label: i18n.t('common.Copy')
|
||||
},
|
||||
{
|
||||
value: 'paste',
|
||||
label: i18n.t('common.Paste')
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user