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)
|
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 {
|
export default {
|
||||||
getFunctionLib,
|
getFunctionLib,
|
||||||
postFunctionLib,
|
postFunctionLib,
|
||||||
putFunctionLib,
|
putFunctionLib,
|
||||||
postFunctionLibDebug,
|
postFunctionLibDebug,
|
||||||
getAllFunctionLib
|
getAllFunctionLib,
|
||||||
|
delFunctionLib
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,19 +45,18 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch, reactive } from 'vue'
|
import { ref, watch, reactive } from 'vue'
|
||||||
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
import type { ApplicationFormType } from '@/api/type/application'
|
import type { ApplicationFormType } from '@/api/type/application'
|
||||||
import type { FormInstance, FormRules } from 'element-plus'
|
import type { FormInstance, FormRules } from 'element-plus'
|
||||||
import applicationApi from '@/api/application'
|
import applicationApi from '@/api/application'
|
||||||
import { MsgSuccess, MsgAlert } from '@/utils/message'
|
import { MsgSuccess, MsgAlert } from '@/utils/message'
|
||||||
|
import { isWorkFlow } from '@/utils/application'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
import { ValidType, ValidCount } from '@/enums/common'
|
import { ValidType, ValidCount } from '@/enums/common'
|
||||||
|
const router = useRouter()
|
||||||
const { common, user } = useStore()
|
const { common, user } = useStore()
|
||||||
const emit = defineEmits(['refresh'])
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const defaultPrompt = t('views.application.prompt.defaultPrompt', {
|
const defaultPrompt = t('views.application.prompt.defaultPrompt', {
|
||||||
@ -159,7 +158,11 @@ const submitHandle = async (formEl: FormInstance | undefined) => {
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
applicationApi.postApplication(applicationForm.value, loading).then((res) => {
|
applicationApi.postApplication(applicationForm.value, loading).then((res) => {
|
||||||
MsgSuccess(t('views.application.applicationForm.buttons.createSuccess'))
|
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
|
dialogVisible.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -199,7 +199,6 @@ const submitHandle = async (formEl: FormInstance | undefined) => {
|
|||||||
} else {
|
} else {
|
||||||
router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` })
|
router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` })
|
||||||
}
|
}
|
||||||
emit('refresh')
|
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,7 +116,7 @@
|
|||||||
</InfiniteScroll>
|
</InfiniteScroll>
|
||||||
</div>
|
</div>
|
||||||
<CreateApplicationDialog ref="CreateApplicationDialogRef" />
|
<CreateApplicationDialog ref="CreateApplicationDialogRef" />
|
||||||
<CopyApplicationDialog ref="CopyApplicationDialogRef" @refresh="refresh" />
|
<CopyApplicationDialog ref="CopyApplicationDialogRef" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -205,13 +205,6 @@ function getList() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function refresh() {
|
|
||||||
paginationConfig.total = 0
|
|
||||||
paginationConfig.current_page = 1
|
|
||||||
applicationList.value = []
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList()
|
getList()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -73,7 +73,7 @@
|
|||||||
import { ref, onMounted, reactive } from 'vue'
|
import { ref, onMounted, reactive } from 'vue'
|
||||||
import functionLibApi from '@/api/function-lib'
|
import functionLibApi from '@/api/function-lib'
|
||||||
import FunctionFormDrawer from './component/FunctionFormDrawer.vue'
|
import FunctionFormDrawer from './component/FunctionFormDrawer.vue'
|
||||||
import { MsgSuccess, MsgError } from '@/utils/message'
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
const FunctionFormDrawerRef = ref()
|
const FunctionFormDrawerRef = ref()
|
||||||
@ -100,18 +100,23 @@ function searchHandle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deleteFunctionLib(row: any) {
|
function deleteFunctionLib(row: any) {
|
||||||
// MsgConfirm(
|
MsgConfirm(
|
||||||
// // @ts-ignore
|
`是否删除函数:${row.name} ?`,
|
||||||
// `${t('views.function-lib.function-libList.card.delete.confirmTitle')}${row.name} ?`,
|
'删除后,引用了该函数的应用提问时会报错 ,请谨慎操作。',
|
||||||
// t('views.function-lib.function-libList.card.delete.confirmMessage'),
|
{
|
||||||
// {
|
confirmButtonText: '删除',
|
||||||
// confirmButtonText: t('views.function-lib.function-libList.card.delete.confirmButton'),
|
cancelButtonText: '取消',
|
||||||
// cancelButtonText: t('views.function-lib.function-libList.card.delete.cancelButton'),
|
confirmButtonClass: 'danger'
|
||||||
// confirmButtonClass: 'danger'
|
}
|
||||||
// }
|
)
|
||||||
// )
|
.then(() => {
|
||||||
// .then(() => {})
|
functionLibApi.delFunctionLib(row.id, loading).then(() => {
|
||||||
// .catch(() => {})
|
const index = functionLibList.value.findIndex((v) => v.id === row.id)
|
||||||
|
functionLibList.value.splice(index, 1)
|
||||||
|
MsgSuccess('删除成功')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyFunctionLib(row: any) {
|
function copyFunctionLib(row: any) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user