diff --git a/ui/src/components/dynamics-form/constructor/data.ts b/ui/src/components/dynamics-form/constructor/data.ts
new file mode 100644
index 000000000..ff100fa06
--- /dev/null
+++ b/ui/src/components/dynamics-form/constructor/data.ts
@@ -0,0 +1,27 @@
+const input_type_list = [
+ {
+ label: '文本框',
+ value: 'TextInput'
+ },
+ {
+ label: '滑块',
+ value: 'Slider'
+ },
+ {
+ label: '开关',
+ value: 'SwitchInput'
+ },
+ {
+ label: '单选框',
+ value: 'SingleSelect'
+ },
+ {
+ label: '日期',
+ value: 'DatePicker'
+ },
+ {
+ label: 'JSON文本框',
+ value: 'JsonInput'
+ }
+]
+export { input_type_list }
diff --git a/ui/src/components/dynamics-form/constructor/index.vue b/ui/src/components/dynamics-form/constructor/index.vue
index 42310516a..5b1ade7dd 100644
--- a/ui/src/components/dynamics-form/constructor/index.vue
+++ b/ui/src/components/dynamics-form/constructor/index.vue
@@ -41,20 +41,15 @@
import { onMounted, ref, nextTick } from 'vue'
import type { FormInstance } from 'element-plus'
import _ from 'lodash'
+import { input_type_list as input_type_list_data } from '@/components/dynamics-form/constructor/data'
const props = withDefaults(
defineProps<{
modelValue?: any
input_type_list?: Array<{ label: string; value: string }>
}>(),
{
- input_type_list: () => [
- { label: '文本框', value: 'TextInputConstructor' },
- { label: '滑块', value: 'SliderConstructor' },
- { label: '开关', value: 'SwitchInputConstructor' },
- { label: '单选框', value: 'SingleSelectConstructor' },
- { label: '日期', value: 'DatePickerConstructor' },
- { label: 'JSON文本框', value: 'JsonInputConstructor' }
- ]
+ input_type_list: () =>
+ input_type_list_data.map((item) => ({ label: item.label, value: item.value + 'Constructor' }))
}
)
const emit = defineEmits(['update:modelValue'])
diff --git a/ui/src/components/dynamics-form/constructor/items/DatePickerConstructor.vue b/ui/src/components/dynamics-form/constructor/items/DatePickerConstructor.vue
index 44d1f91d4..e370dd6a5 100644
--- a/ui/src/components/dynamics-form/constructor/items/DatePickerConstructor.vue
+++ b/ui/src/components/dynamics-form/constructor/items/DatePickerConstructor.vue
@@ -41,7 +41,7 @@
diff --git a/ui/src/components/dynamics-form/constructor/items/SwitchInputConstructor.vue b/ui/src/components/dynamics-form/constructor/items/SwitchInputConstructor.vue
index 80ba8dbc0..92a52a021 100644
--- a/ui/src/components/dynamics-form/constructor/items/SwitchInputConstructor.vue
+++ b/ui/src/components/dynamics-form/constructor/items/SwitchInputConstructor.vue
@@ -33,7 +33,7 @@ const getData = () => {
}
const rander = (form_data: any) => {
- formValue.value.default_value = form_data.default_value
+ formValue.value.default_value = form_data.default_value || false
}
defineExpose({ getData, rander })
onMounted(() => {
diff --git a/ui/src/components/dynamics-form/constructor/items/TextInputConstructor.vue b/ui/src/components/dynamics-form/constructor/items/TextInputConstructor.vue
index 7ac8e86fd..553cb4483 100644
--- a/ui/src/components/dynamics-form/constructor/items/TextInputConstructor.vue
+++ b/ui/src/components/dynamics-form/constructor/items/TextInputConstructor.vue
@@ -1,21 +1,48 @@
-
+
-
+
+
+
-
-
+
+
@@ -23,7 +50,9 @@
label="默认值"
:required="formValue.required"
prop="default_value"
- :rules="formValue.required ? [{ required: true, message: '默认值 为必填属性' }] : []"
+ :rules="
+ formValue.required ? [{ required: true, message: '默认值 为必填属性' }, ...rules] : rules
+ "
>
-
-
\ No newline at end of file
+
diff --git a/ui/src/views/template/component/ParamSettingDialog.vue b/ui/src/views/template/component/ParamSettingDialog.vue
index ecebbc567..df60d0170 100644
--- a/ui/src/views/template/component/ParamSettingDialog.vue
+++ b/ui/src/views/template/component/ParamSettingDialog.vue
@@ -8,26 +8,22 @@
:destroy-on-close="true"
:before-close="close"
>
-
- 添加参数
-
-
+ 添加参数
+
- {{ row.label.label }}
+ {{
+ row.label.label
+ }}
{{ row.label }}
-
+
- 文本框
- 滑块
- 开关
- 单选框
+ {{
+ input_type_list.find((item) => item.value === row.input_type)?.label
+ }}
@@ -41,13 +37,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -74,7 +70,7 @@ import { ref } from 'vue'
import AddParamDrawer from './AddParamDrawer.vue'
import { MsgError, MsgSuccess } from '@/utils/message'
import ModelApi from '@/api/model'
-
+import { input_type_list } from '@/components/dynamics-form/constructor/data'
const props = defineProps<{
model: Model
@@ -88,22 +84,20 @@ const AddParamRef = ref()
const open = () => {
dialogVisible.value = true
loading.value = true
- ModelApi.getModelParamsForm(
- props.model.id,
- loading
- ).then((ok) => {
- loading.value = false
- modelParamsForm.value = ok.data
- }).catch(() => {
- loading.value = false
- })
+ ModelApi.getModelParamsForm(props.model.id, loading)
+ .then((ok) => {
+ loading.value = false
+ modelParamsForm.value = ok.data
+ })
+ .catch(() => {
+ loading.value = false
+ })
}
const close = () => {
dialogVisible.value = false
}
-
function openAddDrawer(data?: any, index?: any) {
AddParamRef.value?.open(data, index)
}
@@ -143,11 +137,7 @@ function refresh(data: any, index: any) {
function submit() {
// console.log('submit: ', modelParamsForm.value)
- ModelApi.updateModelParamsForm(
- props.model.id,
- modelParamsForm.value,
- loading
- ).then((ok) => {
+ ModelApi.updateModelParamsForm(props.model.id, modelParamsForm.value, loading).then((ok) => {
MsgSuccess('模型参数保存成功')
close()
// emit('submit')
@@ -157,6 +147,4 @@ function submit() {
defineExpose({ open, close })
-
\ No newline at end of file
+