mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:02:46 +00:00
feat: 增加函数库删除功能
This commit is contained in:
parent
7c5957e0a3
commit
fa463231c5
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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', {
|
||||
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@
|
|||
</InfiniteScroll>
|
||||
</div>
|
||||
<CreateApplicationDialog ref="CreateApplicationDialogRef" />
|
||||
<CopyApplicationDialog ref="CopyApplicationDialogRef" @refresh="refresh" />
|
||||
<CopyApplicationDialog ref="CopyApplicationDialogRef" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
|
@ -205,13 +205,6 @@ function getList() {
|
|||
})
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
paginationConfig.total = 0
|
||||
paginationConfig.current_page = 1
|
||||
applicationList.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue