From 9561961d0fa9ebec3e9cbb7cf49790bbc0ca8562 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 18 Sep 2024 10:34:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=87=BD=E6=95=B0=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=9D=83=E9=99=90=E5=92=8C=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/api/type/function-lib.ts | 7 +- ui/src/views/application/index.vue | 2 +- ui/src/views/dataset/index.vue | 2 +- .../component/FunctionFormDrawer.vue | 9 +- ui/src/views/function-lib/index.vue | 85 +++++++++++++++---- 5 files changed, 81 insertions(+), 24 deletions(-) diff --git a/ui/src/api/type/function-lib.ts b/ui/src/api/type/function-lib.ts index fcc660368..2c5efe254 100644 --- a/ui/src/api/type/function-lib.ts +++ b/ui/src/api/type/function-lib.ts @@ -1,10 +1,11 @@ interface functionLibData { id?: String - name: String - desc: String + name?: String + desc?: String code?: String - permission_type: 'PRIVATE' | 'PUBLIC' + permission_type?: 'PRIVATE' | 'PUBLIC' input_field_list?: Array + is_active?: Boolean } export type { functionLibData } diff --git a/ui/src/views/application/index.vue b/ui/src/views/application/index.vue index 913a4836d..839f9b81b 100644 --- a/ui/src/views/application/index.vue +++ b/ui/src/views/application/index.vue @@ -222,7 +222,7 @@ onMounted(() => { .status-tag { position: absolute; right: 16px; - top: 20px; + top: 13px; } } .dropdown-custom-switch { diff --git a/ui/src/views/dataset/index.vue b/ui/src/views/dataset/index.vue index 4cc161389..001a1eca4 100644 --- a/ui/src/views/dataset/index.vue +++ b/ui/src/views/dataset/index.vue @@ -198,7 +198,7 @@ onMounted(() => { .delete-button { position: absolute; right: 12px; - top: 18px; + top: 13px; height: auto; } .footer-content { diff --git a/ui/src/views/function-lib/component/FunctionFormDrawer.vue b/ui/src/views/function-lib/component/FunctionFormDrawer.vue index 15d49c52f..92da6eeb9 100644 --- a/ui/src/views/function-lib/component/FunctionFormDrawer.vue +++ b/ui/src/views/function-lib/component/FunctionFormDrawer.vue @@ -19,7 +19,7 @@ placeholder="请输入函数名称" maxlength="64" show-word-limit - @blur="form.name = form.name.trim()" + @blur="form.name = form.name?.trim()" /> @@ -30,10 +30,10 @@ maxlength="128" show-word-limit :autosize="{ minRows: 3 }" - @blur="form.desc = form.desc.trim()" + @blur="form.desc = form.desc?.trim()" /> - + @@ -207,7 +207,8 @@ watch(visible, (bool) => { }) const rules = reactive({ - name: [{ required: true, message: '请输入函数名称', trigger: 'blur' }] + name: [{ required: true, message: '请输入函数名称', trigger: 'blur' }], + permission_type: [{ required: true, message: '请选择', trigger: 'change' }] }) function openCodemirrorDialog() { diff --git a/ui/src/views/function-lib/index.vue b/ui/src/views/function-lib/index.vue index 636a84334..8f1cee664 100644 --- a/ui/src/views/function-lib/index.vue +++ b/ui/src/views/function-lib/index.vue @@ -11,7 +11,11 @@ clearable /> -
+
- +
+ 公用 + 私有 +
@@ -89,6 +107,7 @@ const paginationConfig = reactive({ const searchValue = ref('') const title = ref('') +const changeStateloading = ref(false) function openCreateDialog(data?: any) { title.value = data ? '编辑函数' : '创建函数' @@ -102,6 +121,33 @@ function searchHandle() { getList() } +function changeState(bool: Boolean, row: any) { + if (!bool) { + MsgConfirm( + `是否禁用函数:${row.name} ?`, + `禁用后,引用了该函数的应用提问时会报错 ,请谨慎操作。`, + { + confirmButtonText: '禁用', + confirmButtonClass: 'danger' + } + ) + .then(() => { + const obj = { + is_active: bool + } + functionLibApi.putFunctionLib(row.id, obj, changeStateloading).then((res) => {}) + }) + .catch(() => { + row.is_active = true + }) + } else { + const obj = { + is_active: bool + } + functionLibApi.putFunctionLib(row.id, obj, changeStateloading).then((res) => {}) + } +} + function deleteFunctionLib(row: any) { MsgConfirm( `是否删除函数:${row.name} ?`, @@ -155,4 +201,13 @@ onMounted(() => { getList() }) - +