+
+ 在资产详情中更新账号信息
+
+
@@ -66,6 +69,12 @@ export default {
value: {
type: [Array],
default: () => []
+ },
+ isUpdate: {
+ type: Function,
+ default: (vm) => {
+ return vm.$route.params.id
+ }
}
},
data() {
diff --git a/src/components/FormFields/ProtocolSelector/index.vue b/src/components/FormFields/ProtocolSelector/index.vue
index 8599cbc29..25a6f9ec7 100644
--- a/src/components/FormFields/ProtocolSelector/index.vue
+++ b/src/components/FormFields/ProtocolSelector/index.vue
@@ -24,7 +24,7 @@
icon="el-icon-minus"
style="flex-shrink: 0;"
size="mini"
- :disabled="items.length === 1"
+ :disabled="cannotDisable(item)"
@click="handleDelete(index)"
/>
@@ -102,11 +102,6 @@ export default {
watch: {
choices: {
handler(value) {
- if (!this.settingReadonly) {
- this.value[0].primary = true
- this.value[0].default = true
- this.value[0].required = true
- }
this.setDefaultItems(value)
}
},
@@ -120,7 +115,8 @@ export default {
},
mounted() {
this.setDefaultItems(this.choices)
- console.log('CHoices: ', this.choices)
+ console.log('Choices: ', this.choices)
+ console.log('Value: ', this.value)
},
methods: {
handleDelete(index) {
@@ -128,8 +124,8 @@ export default {
return i !== index
})
},
- canDelete(item) {
- return this.item.primary || this.item.required
+ cannotDisable(item) {
+ return item.primary || item.required
},
handleAdd(index) {
this.items.push({ ...this.remainProtocols[0] })
@@ -140,11 +136,14 @@ export default {
item.port = selected.port
},
setDefaultItems(choices) {
- let defaults = this.value
- if (defaults.length === 0 && choices.length !== 0) {
- defaults = choices
- }
- this.items = defaults
+ const defaults = choices.filter(item => item.required || item.primary || item.default)
+ console.log('defaults1: ', defaults)
+ console.log('this value: ', this.value)
+ const notInDefaults = this.value.filter(item => {
+ return !defaults.find(d => d.name === item.name)
+ })
+ console.log('Not defaults: ', notInDefaults)
+ this.items = [...defaults, ...notInDefaults]
},
onSettingClick(item) {
this.settingItem = item
diff --git a/src/components/TableFormatters/index.js b/src/components/TableFormatters/index.js
index 6294270ac..023cbae4c 100644
--- a/src/components/TableFormatters/index.js
+++ b/src/components/TableFormatters/index.js
@@ -14,6 +14,7 @@ import StatusFormatter from './StatusFormatter'
import TagsFormatter from './TagsFormatter'
import ObjectRelatedFormatter from './ObjectRelatedFormatter'
import ChoicesDisplayFormatter from './ChoicesDisplayFormatter'
+import BooleanFormatter from './BooleanFormatter'
export default {
DetailFormatter,
@@ -31,7 +32,8 @@ export default {
StatusFormatter,
TagsFormatter,
ObjectRelatedFormatter,
- ChoicesDisplayFormatter
+ ChoicesDisplayFormatter,
+ BooleanFormatter
}
export {
diff --git a/src/i18n/langs/zh.json b/src/i18n/langs/zh.json
index 87da261b6..5b99f93da 100644
--- a/src/i18n/langs/zh.json
+++ b/src/i18n/langs/zh.json
@@ -109,7 +109,7 @@
"CreateDevice": "创建资产-网络设备",
"CreateCloud": "创建资产-云平台",
"CreateWeb": "创建资产-web",
- "Privileged": "有特权",
+ "Privileged": "特权账号",
"SelectPlatforms": "选择平台",
"AppList": "应用列表",
"AssociateSystemUsers": "关联系统用户",
diff --git a/src/views/assets/Asset/AssetCreateUpdate/BaseAssetCreateUpdate.vue b/src/views/assets/Asset/AssetCreateUpdate/BaseAssetCreateUpdate.vue
index 9cc4403e5..e40df47a0 100644
--- a/src/views/assets/Asset/AssetCreateUpdate/BaseAssetCreateUpdate.vue
+++ b/src/views/assets/Asset/AssetCreateUpdate/BaseAssetCreateUpdate.vue
@@ -22,6 +22,7 @@ export default {
data() {
return {
loading: true,
+ platform: {},
defaultConfig: {
initial: {},
platform: {},
@@ -33,13 +34,12 @@ export default {
[this.$t('common.Basic'), ['name', 'address', 'platform', 'domain']],
[this.$t('assets.Protocols'), ['protocols']],
[this.$t('assets.Node'), ['nodes']],
- this.$route.params.id ? null : [this.$t('assets.Account'), ['accounts']],
+ [this.$t('assets.Account'), ['accounts']],
[this.$t('assets.Label'), ['labels']],
[this.$t('common.Other'), ['is_active', 'comment']]
],
fieldsMeta: assetFieldsMeta()
- },
- platform: {}
+ }
}
},
computed: {
@@ -57,7 +57,6 @@ export default {
}
config.fields = Object.entries(defaultFields)
}
-
return config
}
},
@@ -82,7 +81,7 @@ export default {
is_active: true,
nodes: nodesInitial,
platform: parseInt(platformId),
- protocols: this.platform.protocols || []
+ protocols: []
}
this.defaultConfig.initial = Object.assign({}, initial, defaultConfig.initial)
},