Skip to content

feat: 增加函数库删除功能 #1002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ui/src/api/function-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,22 @@ const postFunctionLibDebug: (data: any, loading?: Ref<boolean>) => Promise<Resul
return post(`${prefix}/debug`, data, undefined, loading)
}

/**
* 删除函数
* @param 参数 function_lib_id
*/
const delFunctionLib: (
function_lib_id: String,
loading?: Ref<boolean>
) => Promise<Result<boolean>> = (function_lib_id, loading) => {
return del(`${prefix}/${function_lib_id}`, undefined, {}, loading)
}

export default {
getFunctionLib,
postFunctionLib,
putFunctionLib,
postFunctionLibDebug,
getAllFunctionLib
getAllFunctionLib,
delFunctionLib
}
13 changes: 8 additions & 5 deletions ui/src/views/application/component/CopyApplicationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,18 @@
</template>
<script setup lang="ts">
import { ref, watch, reactive } from 'vue'

import { useRouter, useRoute } from 'vue-router'
import { cloneDeep } from 'lodash'
import type { ApplicationFormType } from '@/api/type/application'
import type { FormInstance, FormRules } from 'element-plus'
import applicationApi from '@/api/application'
import { MsgSuccess, MsgAlert } from '@/utils/message'

import { isWorkFlow } from '@/utils/application'
import { t } from '@/locales'
import useStore from '@/stores'
import { ValidType, ValidCount } from '@/enums/common'

const router = useRouter()
const { common, user } = useStore()
const emit = defineEmits(['refresh'])

// @ts-ignore
const defaultPrompt = t('views.application.prompt.defaultPrompt', {
Expand Down Expand Up @@ -159,7 +158,11 @@ const submitHandle = async (formEl: FormInstance | undefined) => {
if (valid) {
applicationApi.postApplication(applicationForm.value, loading).then((res) => {
MsgSuccess(t('views.application.applicationForm.buttons.createSuccess'))
emit('refresh')
if (isWorkFlow(applicationForm.value.type)) {
router.push({ path: `/application/${res.data.id}/workflow` })
} else {
router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` })
}
dialogVisible.value = false
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ const submitHandle = async (formEl: FormInstance | undefined) => {
} else {
router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` })
}
emit('refresh')
dialogVisible.value = false
})
}
Expand Down
9 changes: 1 addition & 8 deletions ui/src/views/application/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</InfiniteScroll>
</div>
<CreateApplicationDialog ref="CreateApplicationDialogRef" />
<CopyApplicationDialog ref="CopyApplicationDialogRef" @refresh="refresh" />
<CopyApplicationDialog ref="CopyApplicationDialogRef" />
</div>
</template>
<script setup lang="ts">
Expand Down Expand Up @@ -205,13 +205,6 @@ function getList() {
})
}

function refresh() {
paginationConfig.total = 0
paginationConfig.current_page = 1
applicationList.value = []
getList()
}

onMounted(() => {
getList()
})
Expand Down
31 changes: 18 additions & 13 deletions ui/src/views/function-lib/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
import { ref, onMounted, reactive } from 'vue'
import functionLibApi from '@/api/function-lib'
import FunctionFormDrawer from './component/FunctionFormDrawer.vue'
import { MsgSuccess, MsgError } from '@/utils/message'
import { MsgSuccess, MsgConfirm } from '@/utils/message'
const loading = ref(false)

const FunctionFormDrawerRef = ref()
Expand All @@ -100,18 +100,23 @@ function searchHandle() {
}

function deleteFunctionLib(row: any) {
// MsgConfirm(
// // @ts-ignore
// `${t('views.function-lib.function-libList.card.delete.confirmTitle')}${row.name} ?`,
// t('views.function-lib.function-libList.card.delete.confirmMessage'),
// {
// confirmButtonText: t('views.function-lib.function-libList.card.delete.confirmButton'),
// cancelButtonText: t('views.function-lib.function-libList.card.delete.cancelButton'),
// confirmButtonClass: 'danger'
// }
// )
// .then(() => {})
// .catch(() => {})
MsgConfirm(
`是否删除函数:${row.name} ?`,
'删除后,引用了该函数的应用提问时会报错 ,请谨慎操作。',
{
confirmButtonText: '删除',
cancelButtonText: '取消',
confirmButtonClass: 'danger'
}
)
.then(() => {
functionLibApi.delFunctionLib(row.id, loading).then(() => {
const index = functionLibList.value.findIndex((v) => v.id === row.id)
functionLibList.value.splice(index, 1)
MsgSuccess('删除成功')
})
})
.catch(() => {})
}

function copyFunctionLib(row: any) {
Expand Down
Loading