Skip to content

Commit

Permalink
fix(mqtt): optimising the width of table column
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinplemelon committed May 11, 2024
1 parent a910203 commit db212a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/components/ObjectArrayEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
ref="TableCom"
:data="arr"
>
<el-table-column v-for="(value, key) in properties" :key="key" :width="getColumnWidth(value)">
<el-table-column v-for="(value, key) in properties" :key="key" v-bind="getColumnProps(value)">
<template #header>
<label :class="getFormItemRules(key) && 'is-required'">
{{ value.label }}
Expand All @@ -31,7 +31,7 @@
</template>
</template>
</el-table-column>
<el-table-column width="100px" v-if="!disabled">
<el-table-column width="80px" v-if="!disabled">
<template #header>
<a href="javascript:;" @click="addItem">
{{ $t('Base.add') }}
Expand Down Expand Up @@ -127,7 +127,7 @@ const props = defineProps({
type: Boolean,
default: false,
},
columnsWidth: {
columnsProps: {
type: Object,
},
})
Expand Down Expand Up @@ -156,12 +156,12 @@ const initRecordByPluginForm = (data: Properties) => {
const keyArr = computed(() => Array.from({ length: arr.value.length }, () => createRandomString()))
const getColumnWidth = (property: Property) => {
const getColumnProps = (property: Property) => {
const { key, type } = property
if (key && props.columnsWidth && props.columnsWidth[key] !== undefined) {
return props.columnsWidth[key]
if (key && props.columnsProps && props.columnsProps[key] !== undefined) {
return props.columnsProps[key]
}
return type === 'object' ? 300 : undefined
return type === 'object' ? { width: 300 } : {}
}
const addItem = () => {
Expand Down
5 changes: 4 additions & 1 deletion src/views/Config/BasicConfig/Mqtt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export default defineComponent({
if (!client_attrs_init.componentProps) {
client_attrs_init.componentProps = {}
}
client_attrs_init.componentProps.columnsWidth = { expression: 260 }
client_attrs_init.componentProps.columnsProps = {
set_as_attr: { minWidth: 140 },
expression: { minWidth: 200 },
}
}
const { items } = client_attrs_init || {}
Expand Down

0 comments on commit db212a5

Please sign in to comment.