Merge pull request #601 from veops/dev_ui_240826

fix(ui): some bugs
This commit is contained in:
Leo Song 2024-08-26 18:35:44 +08:00 committed by GitHub
commit 8a91ec7b11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 42 additions and 37 deletions

View File

@ -139,9 +139,9 @@
:normalizer=" :normalizer="
(node) => { (node) => {
return { return {
id: String(node[0]), id: String(node[0] || ''),
label: node[1].label || node[0], label: node[1] ? node[1].label || node[0] : node[0],
children: node.children, children: node.children && node.children.length ? node.children : undefined,
} }
} }
" "

View File

@ -118,6 +118,8 @@ export default {
.locale { .locale {
cursor: pointer; cursor: pointer;
padding: 0 8px;
&:hover { &:hover {
color: @primary-color; color: @primary-color;
} }
@ -135,6 +137,7 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: 0 8px;
&-icon { &-icon {
font-size: 12px; font-size: 12px;

View File

@ -102,7 +102,7 @@ const genCmdbRoutes = async () => {
name: 'cmdb_ci_type', name: 'cmdb_ci_type',
component: RouteView, component: RouteView,
redirect: '/cmdb/ci_type', redirect: '/cmdb/ci_type',
meta: { title: 'cmdb.menu.backendManage', icon: 'veops-setting2', permission: ['cmdb_admin', 'OneOPS_Application_Admin', 'admin'], }, meta: { title: 'cmdb.menu.backendManage', icon: 'veops-setting2', selectedIcon: 'veops-setting2', permission: ['cmdb_admin', 'OneOPS_Application_Admin', 'admin'], },
children: [ children: [
{ {
path: '/cmdb/customdashboard', path: '/cmdb/customdashboard',

View File

@ -45,14 +45,7 @@
attr.name, attr.name,
{ {
rules: [{ required: attr.is_required, message: $t('placeholder2') + `${attr.alias || attr.name}` }], rules: [{ required: attr.is_required, message: $t('placeholder2') + `${attr.alias || attr.name}` }],
initialValue: initialValue: getChoiceDefault(attr),
attr.default && attr.default.default
? attr.is_list
? Array.isArray(attr.default.default)
? attr.default.default
: attr.default.default.split(',')
: attr.default.default
: attr.is_list ? [] : null,
}, },
]" ]"
:placeholder="$t('placeholder2')" :placeholder="$t('placeholder2')"
@ -216,6 +209,35 @@ export default {
jsonEditorOk(jsonData) { jsonEditorOk(jsonData) {
this.form.setFieldsValue({ [this.editAttr.name]: JSON.stringify(jsonData) }) this.form.setFieldsValue({ [this.editAttr.name]: JSON.stringify(jsonData) })
}, },
getChoiceDefault(attr) {
if (!attr?.default?.default) {
return attr.is_list ? [] : null
}
if (attr.is_list) {
let defaultValue = []
if (Array.isArray(attr.default.default)) {
defaultValue = attr.default.default
} else {
defaultValue = String(attr.default.default).split(',')
}
if (['0', '1', '11'].includes(attr.value_type)) {
defaultValue = defaultValue?.map((item) => {
const numberValue = Number(item)
return Number.isNaN(numberValue) ? item : numberValue
})
}
return defaultValue
}
let defaultValue = attr.default.default
if (['0', '1', '11'].includes(attr.value_type)) {
const numberValue = Number(defaultValue)
defaultValue = Number.isNaN(numberValue) ? attr.default.default : numberValue
}
return defaultValue
}
}, },
} }
</script> </script>

View File

@ -62,11 +62,8 @@ export default {
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
switch (this.activeKey) { switch (this.activeKey) {
case '6':
this.$refs.triggerTable.getTableData()
break
case '5': case '5':
this.$refs.reconciliationTable.getTableData() this.$refs.triggerTable.getTableData()
break break
default: default:
break break
@ -87,11 +84,8 @@ export default {
case '1': case '1':
this.$refs.attributesTable.getCITypeGroupData() this.$refs.attributesTable.getCITypeGroupData()
break break
case '6':
this.$refs.triggerTable.getTableData()
break
case '5': case '5':
this.$refs.reconciliationTable.getTableData() this.$refs.triggerTable.getTableData()
break break
default: default:
break break

View File

@ -87,9 +87,9 @@
:normalizer=" :normalizer="
(node) => { (node) => {
return { return {
id: node[0], id: String(node[0] || ''),
label: node[1].label || node[0], label: node[1] ? node[1].label || node[0] : node[0],
children: node.children, children: node.children && node.children.length ? node.children : undefined,
} }
} }
" "

View File

@ -166,7 +166,6 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex'
import _ from 'lodash' import _ from 'lodash'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
@ -191,20 +190,7 @@ export default {
userFilterSelect: [], userFilterSelect: [],
} }
}, },
computed: {
...mapState(['user'])
},
created() {
this.initUserFilterSelect()
},
methods: { methods: {
initUserFilterSelect() {
const permissions = this.user?.detailPermissions?.backend?.find((item) => item.name === 'Employee_Fields')?.permissions
const userFilterSelect = USER_FILTER_SELECT.filter((item) => {
return permissions.includes(item.value)
})
this.userFilterSelect = userFilterSelect
},
async setRuleList(ruleList) { async setRuleList(ruleList) {
this.ruleList = ruleList?.length ? ruleList : [] this.ruleList = ruleList?.length ? ruleList : []
}, },