UnisKB/ui/src/views/application/component/AIModeParamSettingDialog.vue

94 lines
2.4 KiB
Vue
Raw Normal View History

2024-08-12 03:46:19 +00:00
<template>
<el-dialog
align-center
:title="$t('views.application.applicationForm.dialogues.paramSettings')"
class="aiMode-param-dialog"
v-model="dialogVisible"
style="width: 550px"
append-to-body
>
2024-08-23 09:46:05 +00:00
<DynamicsForm
v-model="form_data"
:model="form_data"
label-position="top"
require-asterisk-position="right"
:render_data="model_form_field"
ref="dynamicsFormRef"
>
</DynamicsForm>
2024-08-12 03:46:19 +00:00
<template #footer>
<span class="dialog-footer p-16">
2024-08-14 10:54:32 +00:00
<el-button @click.prevent="dialogVisible = false">
{{ $t('views.application.applicationForm.buttons.cancel') }}
</el-button>
<el-button type="primary" @click="submit" :loading="loading">
2024-08-12 03:46:19 +00:00
{{ $t('views.application.applicationForm.buttons.confirm') }}
</el-button>
</span>
</template>
</el-dialog>
</template>
2024-08-14 10:54:32 +00:00
<script setup lang="ts">
2024-08-23 09:46:05 +00:00
import { ref } from 'vue'
2024-08-12 03:46:19 +00:00
2024-08-23 09:46:05 +00:00
import type { FormInstance } from 'element-plus'
import type { FormField } from '@/components/dynamics-form/type'
import modelAPi from '@/api/model'
import DynamicsForm from '@/components/dynamics-form/index.vue'
import { keys } from 'lodash'
const model_form_field = ref<Array<FormField>>([])
2024-08-14 10:54:32 +00:00
const emit = defineEmits(['refresh'])
2024-08-23 09:46:05 +00:00
const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>()
const form_data = ref<any>({})
2024-08-14 10:54:32 +00:00
const dialogVisible = ref(false)
2024-08-12 03:46:19 +00:00
const loading = ref(false)
2024-08-23 09:46:05 +00:00
const open = (model_id: string, model_setting_data?: any) => {
modelAPi.getModelParamsForm(model_id, loading).then((ok) => {
model_form_field.value = ok.data
model_setting_data =
model_setting_data && keys(model_setting_data).length > 0
? model_setting_data
: ok.data
.map((item) => ({ [item.field]: item.default_value }))
.reduce((x, y) => ({ ...x, ...y }), {})
// 渲染动态表单
dynamicsFormRef.value?.render(model_form_field.value, model_setting_data)
2024-08-14 10:54:32 +00:00
})
2024-08-12 03:46:19 +00:00
dialogVisible.value = true
}
2024-08-14 10:54:32 +00:00
const submit = async () => {
2024-08-23 09:46:05 +00:00
emit('refresh', form_data.value)
dialogVisible.value = false
2024-08-12 03:46:19 +00:00
}
defineExpose({ open })
</script>
2024-08-14 10:54:32 +00:00
<style lang="scss" scoped>
2024-08-12 03:46:19 +00:00
.aiMode-param-dialog {
padding: 8px 8px 24px 8px;
2024-08-14 10:54:32 +00:00
2024-08-12 03:46:19 +00:00
.el-dialog__header {
padding: 16px 16px 0 16px;
}
2024-08-14 10:54:32 +00:00
2024-08-12 03:46:19 +00:00
.el-dialog__body {
padding: 16px !important;
}
2024-08-14 10:54:32 +00:00
2024-08-12 03:46:19 +00:00
.dialog-max-height {
height: 550px;
}
2024-08-14 10:54:32 +00:00
2024-08-12 03:46:19 +00:00
.custom-slider {
.el-input-number.is-without-controls .el-input__wrapper {
padding: 0 !important;
}
}
}
</style>