fix(ui): some bugs

This commit is contained in:
songlh 2024-08-26 18:34:42 +08:00
parent dec7435e9b
commit b417d98469
7 changed files with 42 additions and 37 deletions

View File

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

View File

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

View File

@ -102,7 +102,7 @@ const genCmdbRoutes = async () => {
name: 'cmdb_ci_type',
component: RouteView,
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: [
{
path: '/cmdb/customdashboard',

View File

@ -45,14 +45,7 @@
attr.name,
{
rules: [{ required: attr.is_required, message: $t('placeholder2') + `${attr.alias || attr.name}` }],
initialValue:
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,
initialValue: getChoiceDefault(attr),
},
]"
:placeholder="$t('placeholder2')"
@ -216,6 +209,35 @@ export default {
jsonEditorOk(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>

View File

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

View File

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

View File

@ -166,7 +166,6 @@
</template>
<script>
import { mapState } from 'vuex'
import _ from 'lodash'
import { v4 as uuidv4 } from 'uuid'
import Treeselect from '@riophae/vue-treeselect'
@ -191,20 +190,7 @@ export default {
userFilterSelect: [],
}
},
computed: {
...mapState(['user'])
},
created() {
this.initUserFilterSelect()
},
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) {
this.ruleList = ruleList?.length ? ruleList : []
},