diff --git a/src/components/AutoDataForm/utils.js b/src/components/AutoDataForm/utils.js
index 9cd971771..ff7289cda 100644
--- a/src/components/AutoDataForm/utils.js
+++ b/src/components/AutoDataForm/utils.js
@@ -2,6 +2,7 @@ import Vue from 'vue'
import Select2 from '@/components/Select2'
import NestedField from '@/components/AutoDataForm/components/NestedField'
import rules from '@/components/DataForm/rules'
+import { assignIfNot } from '@/utils/common'
export class FormFieldGenerator {
constructor() {
@@ -109,19 +110,21 @@ export class FormFieldGenerator {
return field
}
generateField(name, fieldsMeta, remoteFieldsMeta) {
- let field = { id: name, prop: name, el: {}, attrs: {}}
+ let field = { id: name, prop: name, el: {}, attrs: {}, rules: [] }
const remoteFieldMeta = remoteFieldsMeta[name] || {}
- Vue.$log.debug('FieldsMeta: ', fieldsMeta, name)
const fieldMeta = fieldsMeta[name] || {}
- Vue.$log.debug('FieldMeta is: ', fieldMeta)
field.label = remoteFieldMeta.label
field.helpText = remoteFieldMeta.help_text
field = this.generateFieldByType(remoteFieldMeta.type, field, fieldMeta, remoteFieldMeta)
field = this.generateFieldByName(name, field)
field = this.generateFieldByOther(field, fieldMeta, remoteFieldMeta)
- const el = Object.assign(field.el || {}, fieldMeta.el || {})
- field = Object.assign(field, fieldMeta || {}, { el: el })
+ const el = assignIfNot(fieldMeta.el || {}, field.el)
+ const rules = fieldMeta.rules || field.rules
+ field = Object.assign(field, fieldMeta)
+ field.el = el
+ field.rules = rules
_.set(field, 'attrs.error', '')
+ Vue.$log.debug('Generate field: ', name, field)
return field
}
generateFieldGroup(field, fieldsMeta, remoteFieldsMeta) {
diff --git a/src/components/AutoDataZTree/index.vue b/src/components/AutoDataZTree/index.vue
index b11b11602..567c52753 100644
--- a/src/components/AutoDataZTree/index.vue
+++ b/src/components/AutoDataZTree/index.vue
@@ -78,6 +78,10 @@ export default {
$('body').unbind('mousedown')
},
methods: {
+ refreshTree: function() {
+ const refreshIconRef = $('#tree-refresh')
+ refreshIconRef.click()
+ },
editTreeNode: function() {
this.hideRMenu()
const currentNode = this.zTree.getSelectedNodes()[0]
@@ -100,15 +104,19 @@ export default {
if (this.setting.url.indexOf('?') !== -1) {
combinator = '&'
}
+ let url = ''
+ const query = Object.assign({}, this.$route.query)
if (treeNode.meta.type === 'node') {
this.currentNode = treeNode
this.currentNodeId = treeNode.meta.node.id
- this.$route.query['node'] = this.currentNodeId
- this.$emit('urlChange', `${this.setting.url}${combinator}node_id=${treeNode.meta.node.id}&show_current_asset=${show_current_asset}`)
+ query['node'] = this.currentNodeId
+ url = `${this.setting.url}${combinator}node_id=${treeNode.meta.node.id}&show_current_asset=${show_current_asset}`
} else if (treeNode.meta.type === 'asset') {
- this.$route.query['asset'] = treeNode.meta.asset.id
- this.$emit('urlChange', `${this.setting.url}${combinator}asset_id=${treeNode.meta.asset.id}&show_current_asset=${show_current_asset}`)
+ query['asset'] = treeNode.meta.asset.id
+ url = `${this.setting.url}${combinator}asset_id=${treeNode.meta.asset.id}&show_current_asset=${show_current_asset}`
}
+ this.$router.push({ query })
+ this.$emit('urlChange', url)
},
removeTreeNode: function() {
this.hideRMenu()
@@ -121,6 +129,7 @@ export default {
).then(() => {
this.$message.success(this.$t('common.deleteSuccessMsg'))
this.zTree.removeNode(currentNode)
+ this.refreshTree()
}).catch(() => {
// this.$message.error(this.$t('common.deleteErrorMsg') + ' ' + error)
})
@@ -141,7 +150,7 @@ export default {
treeNode.name = treeNode.name + ' (' + assetsAmount + ')'
this.zTree.updateNode(treeNode)
this.$message.success(this.$t('common.updateSuccessMsg'))
- })
+ }).finally(() => { this.refreshTree() })
},
onBodyMouseDown: function(event) {
const rMenuID = this.$refs.dataztree.$refs.ztree.iRMenuID
@@ -210,7 +219,7 @@ export default {
this.$message.success(this.$t('common.updateSuccessMsg'))
}).catch(error => {
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + error))
- })
+ }).finally(() => this.refreshTree())
},
createTreeNode: function() {
this.hideRMenu()
@@ -242,7 +251,6 @@ export default {
})
},
refresh: function() {
-
},
getSelectedNodes: function() {
return this.zTree.getSelectedNodes()
diff --git a/src/components/TreeTable/index.vue b/src/components/TreeTable/index.vue
index 082c5609e..974b0bf83 100644
--- a/src/components/TreeTable/index.vue
+++ b/src/components/TreeTable/index.vue
@@ -72,7 +72,6 @@ export default {
watch: {
treeConfig: {
handler(val) {
-
},
deep: true
}
diff --git a/src/utils/common.js b/src/utils/common.js
index 4811b9863..7cfd1a3ec 100644
--- a/src/utils/common.js
+++ b/src/utils/common.js
@@ -1,3 +1,5 @@
+const _ = require('lodash')
+
function getTimeUnits(u) {
const units = {
'd': '天',
@@ -200,6 +202,12 @@ export function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
+function customizer(objValue, srcValue) {
+ return _.isUndefined(objValue) ? srcValue : objValue
+}
+
+export const assignIfNot = _.partialRight(_.assignInWith, customizer)
+
const scheme = document.location.protocol
const port = document.location.port ? ':' + document.location.port : ''
const BASE_URL = scheme + '//' + document.location.hostname + port
diff --git a/src/views/assets/SystemUser/SystemUserCreate/database.vue b/src/views/assets/SystemUser/SystemUserCreate/database.vue
index 8231b64c6..b76b1040c 100644
--- a/src/views/assets/SystemUser/SystemUserCreate/database.vue
+++ b/src/views/assets/SystemUser/SystemUserCreate/database.vue
@@ -4,13 +4,13 @@
diff --git a/src/views/assets/SystemUser/SystemUserCreate/ssh.vue b/src/views/assets/SystemUser/SystemUserCreate/ssh.vue
index f3f90a591..fd184e195 100644
--- a/src/views/assets/SystemUser/SystemUserCreate/ssh.vue
+++ b/src/views/assets/SystemUser/SystemUserCreate/ssh.vue
@@ -4,17 +4,14 @@
diff --git a/src/views/assets/SystemUser/SystemUserCreate/vncAndTelnet.vue b/src/views/assets/SystemUser/SystemUserCreate/vncAndTelnet.vue
index 42bb0a5cb..ef0aa7f36 100644
--- a/src/views/assets/SystemUser/SystemUserCreate/vncAndTelnet.vue
+++ b/src/views/assets/SystemUser/SystemUserCreate/vncAndTelnet.vue
@@ -4,7 +4,7 @@
diff --git a/src/views/settings/Email.vue b/src/views/settings/Email.vue
index dab192527..41fad0cc5 100644
--- a/src/views/settings/Email.vue
+++ b/src/views/settings/Email.vue
@@ -3,6 +3,7 @@
selectedRows.length > 0 && vm.currentOrgIsRoot,
+ can: ({ selectedRows }) => selectedRows.length > 0 && !vm.currentOrgIsRoot,
callback: ({ selectedRows, reloadTable }) => {
vm.updateSelectedDialogSetting.dialogSetting.dialogVisible = true
vm.updateSelectedDialogSetting.selectedRows = selectedRows
diff --git a/src/views/xpack/Cloud/SyncInstanceTask/SyncInstanceTaskCreateUpdate.vue b/src/views/xpack/Cloud/SyncInstanceTask/SyncInstanceTaskCreateUpdate.vue
index 879142fd1..f213c2ada 100644
--- a/src/views/xpack/Cloud/SyncInstanceTask/SyncInstanceTaskCreateUpdate.vue
+++ b/src/views/xpack/Cloud/SyncInstanceTask/SyncInstanceTaskCreateUpdate.vue
@@ -119,7 +119,7 @@ export default {
// 更新获取链接
if (params.id) {
const form = await this.$refs.createUpdatePage.$refs.createUpdateForm.getFormValue()
- this.fieldsMeta.regions.el.ajax.url = `/api/v1/xpack/cloud/regions/?account_id=${form.account}`
+ this.fieldsMeta.regions.el.ajax.url = form.account ? `/api/v1/xpack/cloud/regions/?account_id=${form.account}` : `/api/v1/xpack/cloud/regions/`
}
}
}