Skip to content

Commit

Permalink
feat linkage config
Browse files Browse the repository at this point in the history
  • Loading branch information
hyl committed Dec 3, 2024
1 parent 566d508 commit ac50451
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<el-dialog destroy-on-close v-model="visible" top="3vh" title="值联动">
<FormRender v-model="designInstance.current!" :schema="linkageSchema(designInstance.schema)" />
<FormRender v-model="designInstance.current!" :schema="linkageSchema()" />
</el-dialog>
</template>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<el-dialog destroy-on-close v-model="visible" top="3vh" title="配置级联动">
<el-dialog destroy-on-close v-model="visible" top="3vh" title="配置级联动" width="70vw">
<FormRender v-model="designInstance.current!" :schema="configSchema" />
</el-dialog>
</template>
Expand Down
57 changes: 57 additions & 0 deletions packages/form-design/Right/AttrEdit/LinkageConfig/changeSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type { FormSchema } from '@vue-form-craft/types'

const schema = (): FormSchema => {
// const targetOptions = build(schema.items).filter((item) => item.value !== current.name)

return {
labelWidth: 100,
labelAlign: 'top',
items: [
{
// label: '值联动',
// help: '本字段值改变时触发,修改其他字段的值',
hideLabel: true,
name: 'change',
component: 'FormList',
children: [
// {
// label: '目标字段',
// name: 'target',
// component: 'Select',
// props: {
// mode: 'static',
// options: targetOptions,
// placeholder: '请选择目标字段',
// labelKey: 'label',
// valueKey: 'value'
// }
// },
{
label: '目标字段',
name: 'target',
component: 'Input',
help: '如果是自增组件内部联动,直接输入子组件的name。如果是外部联动自增组件,就是formlist.*.key'
},
{
label: '触发条件',
name: 'condition',
component: 'Input',
help: '必须输入一个模板表达式,当表达式结果为true时才触发联动。如果不设置,默认会一直触发'
},
{
label: '值',
name: 'value',
component: 'Input',
help: '支持模板表达式'
}
],
props: {
mode: 'card',
title: '联动字段'
}
}
]
}
}

export default schema
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,61 @@ export default {
labelAlign: 'top',
items: [
{
label: '自定义',
label: '快速配置',
children: [
{
component: 'Input',
designKey: 'design-B5fm',
name: 'name',
label: '联动项',
props: {
placeholder: '请输入文本'
}
},
{
label: '方式',
props: {
mode: 'static',
options: [
{
label: '强制赋值',
value: 'equal'
},
{
label: '条件赋值',
value: 'if'
}
],
placeholder: '请选择...'
},
component: 'Select',
designKey: 'design-icI8',
name: 'type'
},
{
component: 'Input',
designKey: 'design-POft',
name: 'form-P2qc',
label: '赋值为',
props: {
placeholder: '请输入文本'
}
}
],
props: {
mode: 'table',
title: '数据',
minLines: 0,
maxLines: 999,
allowAdd: true,
allowReduce: true
},
component: 'FormList',
designKey: 'design-NyLz',
name: 'quick'
},
{
label: '手动配置',
component: 'JsonEdit',
designKey: 'design-A2bj',
name: '.'
Expand Down
2 changes: 1 addition & 1 deletion packages/form-design/Right/AttrEdit/StyleConfig/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>

<el-drawer v-model="visible" title="组件样式">
<FormRender v-model="currentProps" :schema="schema" ref="formRef" />
<FormRender v-model="currentProps" :schema="schema" ref="formRef" style="padding: 0 15px;" />
</el-drawer>
</div>
</template>
Expand Down

0 comments on commit ac50451

Please sign in to comment.