Skip to content

Commit c84a9c6

Browse files
perf: User input/form collection parameters support visibility settings
1 parent c65c32e commit c84a9c6

6 files changed

Lines changed: 67 additions & 32 deletions

File tree

ui/src/components/dynamics-form/constructor/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<el-tabs v-model="activeTab">
3-
<el-tab-pane :label="$t('dynamicsForm.paramForm.basicInfo', '基本信息')" name="basic">
3+
<el-tab-pane :label="$t('common.info')" name="basic">
44
<el-form
55
@submit.prevent
66
ref="ruleFormRef"
@@ -79,7 +79,7 @@
7979
</el-form>
8080
</el-tab-pane>
8181

82-
<el-tab-pane label="显隐设置" name="visibility">
82+
<el-tab-pane :label="$t('workflow.nodes.baseNode.visibilitySetting.label')" name="visibility">
8383
<VisibilityConstructor
8484
ref="visibilityRef"
8585
:initialValue="visibility_rules"

ui/src/components/dynamics-form/visibility/ConditionRow.vue

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
2-
<el-row :gutter="8">
3-
<el-col :span="8">
2+
<el-row :gutter="8" class="w-full">
3+
<el-col :span="10">
44
<el-form-item :error="cond._fieldError">
55
<FieldSelector
66
:nodeModel="nodeModel"
@@ -9,12 +9,18 @@
99
:currentNodeFields="currentNodeFields"
1010
:currentEditingIndex="currentEditingIndex"
1111
class="w-full"
12+
:placeholder="$t('workflow.variable.placeholder')"
1213
/>
1314
</el-form-item>
1415
</el-col>
1516
<el-col :span="6">
1617
<el-form-item :error="cond._compareError">
17-
<el-select v-model="cond.compare" @change="cond._compareError = ''" clearable>
18+
<el-select
19+
v-model="cond.compare"
20+
@change="cond._compareError = ''"
21+
clearable
22+
:placeholder="$t('workflow.nodes.conditionNode.conditions.requiredMessage')"
23+
>
1824
<el-option
1925
v-for="op in cond._ops || compareList"
2026
:key="op.value"
@@ -24,13 +30,14 @@
2430
</el-select>
2531
</el-form-item>
2632
</el-col>
27-
<el-col :span="8" v-if="!['is_true', 'is_not_true'].includes(cond.compare)">
33+
<el-col :span="6" v-if="!['is_true', 'is_not_true'].includes(cond.compare)">
2834
<el-form-item :error="cond._valueError">
2935
<el-select
3036
v-if="['SingleSelect', 'RadioCard', 'RadioRow'].includes(cond._fieldType || '')"
3137
v-model="cond.value"
3238
@change="cond._valueError = ''"
3339
clearable
40+
:placeholder="$t('workflow.nodes.conditionNode.valueMessage')"
3441
>
3542
<el-option
3643
v-for="o in cond._options || []"
@@ -46,6 +53,7 @@
4653
@change="cond._valueError = ''"
4754
multiple
4855
clearable
56+
:placeholder="$t('workflow.nodes.conditionNode.valueMessage')"
4957
>
5058
<el-option
5159
v-for="o in cond._options || []"
@@ -63,13 +71,19 @@
6371
:multiple="cond._treeMultiple"
6472
:render-after-expand="false"
6573
clearable
74+
:placeholder="$t('workflow.nodes.conditionNode.valueMessage')"
6675
/>
6776

68-
<el-input v-else v-model="cond.value" @input="cond._valueError = ''" />
77+
<el-input
78+
v-else
79+
v-model="cond.value"
80+
@input="cond._valueError = ''"
81+
:placeholder="$t('workflow.nodes.conditionNode.valueMessage')"
82+
/>
6983
</el-form-item>
7084
</el-col>
71-
<el-col :span="2">
72-
<el-button link type="info" @click="$emit('delete')">
85+
<el-col :span="1">
86+
<el-button link type="info" @click="$emit('delete')" class="mt-4">
7387
<AppIcon iconName="app-delete" />
7488
</el-button>
7589
</el-col>
@@ -79,7 +93,6 @@
7993
import { compareList } from '@/workflow/common/data'
8094
import FieldSelector from './FieldSelector.vue'
8195
import { inferFieldType, getAllowedOps, getFieldConfig } from './field-type'
82-
import type { CompareOptions } from './'
8396
8497
const props = defineProps<{
8598
cond: any

ui/src/components/dynamics-form/visibility/Constructor.vue

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
11
<template>
22
<div>
33
<el-radio-group v-model="formData.action" class="mb-8">
4-
<el-radio value="show">显示条件</el-radio>
5-
<el-radio value="hide">隐藏条件</el-radio>
4+
<el-radio value="show">{{
5+
$t('workflow.nodes.baseNode.visibilitySetting.showCondition‌')
6+
}}</el-radio>
7+
<el-radio value="hide">{{
8+
$t('workflow.nodes.baseNode.visibilitySetting.hideCondition‌')
9+
}}</el-radio>
610
</el-radio-group>
711

812
<div class="flex align-center mb-8">
9-
<span>符合以下</span>
13+
<span class="lighter">{{ $t('workflow.nodes.conditionNode.conditions.info') }}</span>
1014
<el-select v-model="formData.condition" size="small" style="width: 60px; margin: 0 8px">
11-
<el-option label="所有" value="and" />
12-
<el-option label="任意" value="or" />
15+
<el-option :label="$t('workflow.condition.AND')" value="and" />
16+
<el-option :label="$t('workflow.condition.OR')" value="or" />
1317
</el-select>
14-
<span>条件</span>
18+
<span class="lighter">{{ $t('workflow.nodes.conditionNode.conditions.label') }}</span>
1519
</div>
1620

17-
<ConditionRow
18-
v-for="(cond, idx) in formData.conditions"
19-
:key="cond.id"
20-
:cond="cond"
21-
:index="idx"
22-
:nodeModel="nodeModel"
23-
:currentNodeFields="currentNodeFields"
24-
:currentEditingIndex="currentEditingIndex"
25-
@delete="removeCondition(idx)"
26-
class="mb-8"
27-
/>
21+
<el-scrollbar>
22+
<div style="max-height: calc(100vh - 319px)">
23+
<ConditionRow
24+
v-for="(cond, idx) in formData.conditions"
25+
:key="cond.id"
26+
:cond="cond"
27+
:index="idx"
28+
:nodeModel="nodeModel"
29+
:currentNodeFields="currentNodeFields"
30+
:currentEditingIndex="currentEditingIndex"
31+
@delete="removeCondition(idx)"
32+
/>
33+
</div>
34+
</el-scrollbar>
2835

2936
<el-button link type="primary" @click="addCondition">
3037
<AppIcon iconName="app-add-outlined" class="mr-4" />
31-
添加
38+
{{ $t('common.add') }}
3239
</el-button>
3340
</div>
3441
</template>
@@ -39,7 +46,7 @@ import type { CompareOptions, VisibilityRules } from './index'
3946
import { inferFieldType, getAllowedOps, getFieldConfig } from './field-type'
4047
import { compareList } from '@/workflow/common/data'
4148
import ConditionRow from './ConditionRow.vue'
42-
49+
import { t } from '@/locales'
4350
const props = defineProps<{
4451
initialValue?: VisibilityRules | null
4552
nodeModel?: any
@@ -77,18 +84,18 @@ function validate(): Promise<void> {
7784
const hasAny = cond.field[0] || cond.field[1] || cond.compare
7885
if (!hasAny) continue
7986
if (!cond.field[0] || !cond.field[1]) {
80-
cond._fieldError = '请选择变量'
87+
cond._fieldError = t('workflow.variable.placeholder')
8188
hasError = true
8289
}
8390
if (!cond.compare) {
84-
cond._compareError = '请选择运算符'
91+
cond._compareError = t('workflow.nodes.conditionNode.conditions.requiredMessage')
8592
hasError = true
8693
}
8794
const isEmpty = Array.isArray(cond.value)
8895
? cond.value.length === 0
8996
: !cond.value && cond.value !== 0
9097
if (!['is_true', 'is_not_true'].includes(cond.compare) && isEmpty) {
91-
cond._valueError = '请填写匹配值'
98+
cond._valueError = t('workflow.nodes.conditionNode.valueMessage')
9299
hasError = true
93100
}
94101
}

ui/src/locales/lang/en-US/workflow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ export default {
127127
currentTime: 'Current Time',
128128
},
129129
baseNode: {
130+
visibilitySetting: {
131+
label: 'Visibility Setting',
132+
showCondition‌: 'Show Condition',
133+
hideCondition‌: 'Hide Condition',
134+
},
130135
fileUpload: {
131136
label: 'File Upload',
132137
tooltip: 'When enabled, the Q&A page will display a file upload button.',

ui/src/locales/lang/zh-CN/workflow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ export default {
127127
currentTime: '当前时间',
128128
},
129129
baseNode: {
130+
visibilitySetting: {
131+
label: '显隐设置',
132+
showCondition‌: '显示条件',
133+
hideCondition‌: '隐藏条件',
134+
},
130135
fileUpload: {
131136
label: '文件上传',
132137
tooltip: '开启后,问答页面会显示上传文件的按钮。',

ui/src/locales/lang/zh-Hant/workflow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ export default {
127127
currentTime: '當前時間',
128128
},
129129
baseNode: {
130+
visibilitySetting: {
131+
label: '顯隱設置',
132+
showCondition‌: '顯示條件',
133+
hideCondition‌: '隱藏條件',
134+
},
130135
fileUpload: {
131136
label: '文件上傳',
132137
tooltip: '開啟後,問答頁面會顯示上傳文件的按鈕。',

0 commit comments

Comments
 (0)