Skip to content

Commit 50d12b1

Browse files
committed
feat: Supports specified user input title
--story=1017888 --user=刘瑞斌 【高级编排应用】“用户输入”可以自定义。 #2288 https://www.tapd.cn/57709429/s/1655214
1 parent f00c9ca commit 50d12b1

File tree

3 files changed

+123
-7
lines changed

3 files changed

+123
-7
lines changed

ui/src/components/ai-chat/component/user-form/index.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<el-icon class="mr-8 arrow-icon" :class="showUserInput ? 'rotate-90' : ''"
1717
><CaretRight
1818
/></el-icon>
19-
{{ $t('chat.userInput') }}
19+
{{ inputFieldConfig.title }}
2020
</div>
2121
<el-scrollbar max-height="160">
2222
<el-collapse-transition>
@@ -63,6 +63,7 @@ const props = defineProps<{
6363
const dynamicsFormRefresh = ref(0)
6464
const inputFieldList = ref<FormField[]>([])
6565
const apiInputFieldList = ref<FormField[]>([])
66+
const inputFieldConfig = ref({ title: t('chat.userInput') })
6667
const showUserInput = ref(true)
6768
const emit = defineEmits(['update:api_form_data', 'update:form_data'])
6869
@@ -260,6 +261,11 @@ function handleInputFieldList() {
260261
}
261262
})
262263
: []
264+
265+
//
266+
inputFieldConfig.value = v.properties.user_input_config?.title
267+
? v.properties.user_input_config
268+
: { title: t('chat.userInput') }
263269
})
264270
}
265271
/**

ui/src/workflow/nodes/base-node/component/UserInputFieldTable.vue

+33-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
<template>
22
<div class="flex-between mb-16">
33
<h5 class="lighter">{{ $t('chat.userInput') }}</h5>
4-
<el-button link type="primary" @click="openAddDialog()">
5-
<el-icon class="mr-4">
6-
<Plus />
7-
</el-icon>
8-
{{ $t('common.add') }}
9-
</el-button>
4+
<div>
5+
<el-button
6+
type="primary"
7+
link
8+
@click="openChangeTitleDialog"
9+
>
10+
<el-icon>
11+
<Setting />
12+
</el-icon>
13+
</el-button>
14+
<el-button link type="primary" @click="openAddDialog()">
15+
<el-icon class="mr-4">
16+
<Plus />
17+
</el-icon>
18+
{{ $t('common.add') }}
19+
</el-button>
20+
</div>
1021
</div>
1122
<el-table
1223
v-if="props.nodeModel.properties.user_input_field_list?.length > 0"
@@ -92,6 +103,7 @@
92103
</el-table>
93104

94105
<UserFieldFormDialog ref="UserFieldFormDialogRef" @refresh="refreshFieldList" />
106+
<UserInputTitleDialog ref="UserInputTitleDialogRef" @refresh="refreshFieldTitle"/>
95107
</template>
96108

97109
<script setup lang="ts">
@@ -100,15 +112,22 @@ import { set } from 'lodash'
100112
import UserFieldFormDialog from './UserFieldFormDialog.vue'
101113
import { MsgError } from '@/utils/message'
102114
import { t } from '@/locales'
115+
import UserInputTitleDialog from '@/workflow/nodes/base-node/component/UserInputTitleDialog.vue'
103116
const props = defineProps<{ nodeModel: any }>()
104117
105118
const UserFieldFormDialogRef = ref()
119+
const UserInputTitleDialogRef = ref()
106120
const inputFieldList = ref<any[]>([])
121+
const inputFieldConfig = ref({ title: t('chat.userInput') })
107122
108123
function openAddDialog(data?: any, index?: any) {
109124
UserFieldFormDialogRef.value.open(data, index)
110125
}
111126
127+
function openChangeTitleDialog() {
128+
UserInputTitleDialogRef.value.open(inputFieldConfig.value)
129+
}
130+
112131
function deleteField(index: any) {
113132
inputFieldList.value.splice(index, 1)
114133
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
@@ -138,6 +157,13 @@ function refreshFieldList(data: any, index: any) {
138157
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
139158
}
140159
160+
function refreshFieldTitle(data: any) {
161+
inputFieldConfig.value = data
162+
UserInputTitleDialogRef.value.close()
163+
164+
console.log('inputFieldConfig', inputFieldConfig.value)
165+
}
166+
141167
const getDefaultValue = (row: any) => {
142168
if (row.default_value) {
143169
const default_value = row.option_list
@@ -186,6 +212,7 @@ onMounted(() => {
186212
}
187213
})
188214
set(props.nodeModel.properties, 'user_input_field_list', inputFieldList)
215+
set(props.nodeModel.properties, 'user_input_config', inputFieldConfig)
189216
})
190217
</script>
191218

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<template>
2+
<el-dialog
3+
:title="$t('common.setting')"
4+
v-model="dialogVisible"
5+
:close-on-click-modal="false"
6+
:close-on-press-escape="false"
7+
:destroy-on-close="true"
8+
:before-close="close"
9+
append-to-body
10+
>
11+
<el-form
12+
label-position="top"
13+
ref="fieldFormRef"
14+
:rules="rules"
15+
:model="form"
16+
require-asterisk-position="right"
17+
>
18+
<el-form-item :label="$t('common.title')" prop="title">
19+
<el-input
20+
v-model="form.title"
21+
maxlength="64"
22+
show-word-limit
23+
@blur="form.title = form.title.trim()"
24+
/>
25+
</el-form-item>
26+
</el-form>
27+
<template #footer>
28+
<span class="dialog-footer">
29+
<el-button @click.prevent="dialogVisible = false"> {{ $t('common.cancel') }} </el-button>
30+
<el-button type="primary" @click="submit(fieldFormRef)" :loading="loading">
31+
{{ isEdit ? $t('common.save') : $t('common.add') }}
32+
</el-button>
33+
</span>
34+
</template>
35+
</el-dialog>
36+
</template>
37+
<script setup lang="ts">
38+
import { reactive, ref, watch } from 'vue'
39+
import type { FormInstance } from 'element-plus'
40+
import { cloneDeep } from 'lodash'
41+
import { t } from '@/locales'
42+
const emit = defineEmits(['refresh'])
43+
44+
const fieldFormRef = ref()
45+
const loading = ref<boolean>(false)
46+
const isEdit = ref(false)
47+
48+
const form = ref<any>({
49+
title: t('chat.userInput') ,
50+
})
51+
52+
const rules = reactive({
53+
title: [{ required: true, message: t('dynamicsForm.paramForm.name.requiredMessage'), trigger: 'blur' }],
54+
})
55+
56+
const dialogVisible = ref<boolean>(false)
57+
58+
const open = (row: any) => {
59+
if (row) {
60+
form.value = cloneDeep(row)
61+
isEdit.value = true
62+
}
63+
64+
dialogVisible.value = true
65+
}
66+
67+
const close = () => {
68+
dialogVisible.value = false
69+
isEdit.value = false
70+
}
71+
72+
const submit = async (formEl: FormInstance | undefined) => {
73+
if (!formEl) return
74+
await formEl.validate((valid) => {
75+
if (valid) {
76+
emit('refresh', form.value)
77+
}
78+
})
79+
}
80+
81+
defineExpose({ open, close })
82+
</script>
83+
<style lang="scss" scoped></style>

0 commit comments

Comments
 (0)