Skip to content

Commit

Permalink
bugfix: 插件自定义变量渲染问题(closed TencentBlueKing#2134)
Browse files Browse the repository at this point in the history
  • Loading branch information
HubuHito authored and ZhuoZhuoCrayon committed Apr 9, 2024
1 parent e0f30b9 commit fa53792
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/RussianDolls/DollForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
}
.array-child {
display: flex;
align-items: center;
flex: 1;
padding-right: 16px;
background: #f5f7fa;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/RussianDolls/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function getDefaultComponent(params: IItem) {
realComponent = 'bfArray';
}
} else {
realComponent = type === 'boolean' ? 'bk-radio' : 'bk-input';
realComponent = type === 'boolean' ? 'bk-checkbox' : 'bk-input';
}
return realComponent;
};
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/RussianDolls/item/DollArray.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
:item="child"
:item-index="value[idx]"
:value="option"
:value-prop="getRealProp(valueProp, index)" />
:value-prop="getRealProp(valueProp, index)"
:label-width="110" />
<i class="array-content-delete nodeman-icon nc-delete-2 ml10" @click.stop="() => deleteItem(index)" />
</div>
<div class="array-content-add" @click.stop="() => addItem(value.length - 1)">
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/RussianDolls/item/DollBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
:required="item.required"
:property="valueProp"
:desc="item.description"
:rules="item.rules">
:rules="item.rules"
:label-width="labelWidth">
<component
:is="item.component"
v-bind="item.props"
Expand All @@ -26,19 +27,20 @@ export default defineComponent({
itemIndex: -1,
value: '',
valueProp: '',
labelWidth: 110,
},
setup(props) {
const updateFormData = inject('updateFormData');
const inputFocus = inject('inputFocus');
const inputBlur = inject('inputBlur');
const baseValueChange = (val) => {
const value = val.trim();
const value = props.schema.type === 'string' ? val.trim() : val;
const isNumber = props.schema.type === 'number';
let formatValue = isNumber ? parseFloat(value) || 0 : value;
// 调过bia 以单引号开头、结尾的值直接用作字符串
if (!isNumber || !/^'.*'$/.test(value)) {
if ((!isNumber || !/^'.*'$/.test(value)) && !['true', 'false'].includes(value) && isNaN(value)) {
try {
formatValue = JSON.parse(value);
} catch (err) {}
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/components/RussianDolls/item/DollIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,32 @@
:schema="item.schema"
:item-index="itemIndex"
:value="value"
:value-prop="valueProp" />
:value-prop="valueProp"
:label-width="labelWidth" />
<DollObject
v-else-if="item.type === 'object'"
:item="item"
:schema="item.schema"
:item-index="itemIndex"
:value="value"
:value-prop="valueProp" />
:value-prop="valueProp"
:label-width="labelWidth" />
<DollArray
v-else-if="item.type === 'array'"
:item="item"
:schema="item.schema"
:item-index="itemIndex"
:value="value"
:value-prop="valueProp" />
:value-prop="valueProp"
:label-width="labelWidth" />
<DollBase
v-else
:item="item"
:schema="item.schema"
:item-index="itemIndex"
:value="value"
:value-prop="valueProp" />
:value-prop="valueProp"
:label-width="labelWidth" />
</template>

<script>
Expand All @@ -38,6 +42,7 @@ export default defineComponent({
itemIndex: -1,
value: () => ({}),
valueProp: '',
labelWidth: 110,
},
setup(props) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
v-if="!isPluginType && mainItem.variables?.properties"
:ref="`form${mainItem.name}`"
:data="mainItem.variables"
:label-width="110"
:label-width="150"
:value="mainItem.form"
@change="formChange" />
<!-- @focus="handleOperate(arguments, mainItem, 'focus')"
Expand Down
5 changes: 3 additions & 2 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"node_modules"
],
"vueCompilerOptions": {
"target": 2.7
"target": 2.7,
"experimentalUseElementAccessInTemplate": true
},
"compilerOptions": {
"outDir": "./dist",
Expand Down Expand Up @@ -47,6 +48,6 @@
"pretty": true,
"strict": true,
"noImplicitThis": false,
"resolveJsonModule": true
"resolveJsonModule": true,
}
}

0 comments on commit fa53792

Please sign in to comment.