mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: Internal function can modify names
This commit is contained in:
parent
e7e4570aeb
commit
5ceb8a7ff9
|
|
@ -33,6 +33,7 @@ export default {
|
|||
form: {
|
||||
functionName: {
|
||||
label: 'Name',
|
||||
name: 'Function Name',
|
||||
placeholder: 'Please enter the function name',
|
||||
requiredMessage: 'Please enter the function name'
|
||||
},
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ export default {
|
|||
form: {
|
||||
functionName: {
|
||||
label: '名称',
|
||||
name: '函数名称',
|
||||
placeholder: '请输入函数名称',
|
||||
requiredMessage: '请输入函数名称'
|
||||
},
|
||||
|
|
@ -63,7 +64,7 @@ export default {
|
|||
paramInfo2: '使用函数时不显示',
|
||||
code: '函数内容(Python)',
|
||||
selectPlaceholder: '请选择参数',
|
||||
inputPlaceholder: '请输入参数值',
|
||||
inputPlaceholder: '请输入参数值'
|
||||
},
|
||||
debug: {
|
||||
run: '运行',
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ export default {
|
|||
form: {
|
||||
functionName: {
|
||||
label: '名稱',
|
||||
name: '函數名稱',
|
||||
placeholder: '請輸入函數名稱',
|
||||
requiredMessage: '請輸入函數名稱'
|
||||
},
|
||||
|
|
@ -63,7 +64,7 @@ export default {
|
|||
paramInfo2: '使用函數時不顯示',
|
||||
code: '函数内容(Python)',
|
||||
selectPlaceholder: '請选择參數',
|
||||
inputPlaceholder: '請輸入參數值',
|
||||
inputPlaceholder: '請輸入參數值'
|
||||
},
|
||||
debug: {
|
||||
run: '運行',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
:title="$t('views.functionLib.functionForm.form.functionName.placeholder')"
|
||||
:title="$t('views.functionLib.functionForm.form.functionName.name')"
|
||||
v-model="dialogVisible"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
<span class="dialog-footer">
|
||||
<el-button @click.prevent="dialogVisible = false"> {{ $t('common.cancel') }} </el-button>
|
||||
<el-button type="primary" @click="submit(fieldFormRef)" :loading="loading">
|
||||
{{ $t('common.add') }}
|
||||
{{ isEdit ? $t('common.save') : $t('common.add') }}
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
|
|
@ -39,6 +39,7 @@ const emit = defineEmits(['refresh'])
|
|||
|
||||
const fieldFormRef = ref()
|
||||
const loading = ref<boolean>(false)
|
||||
const isEdit = ref<boolean>(false)
|
||||
|
||||
const form = ref<any>({
|
||||
name: ''
|
||||
|
|
@ -64,11 +65,11 @@ watch(dialogVisible, (bool) => {
|
|||
}
|
||||
})
|
||||
|
||||
const open = (row: any) => {
|
||||
const open = (row: any, edit: boolean) => {
|
||||
if (row) {
|
||||
form.value = cloneDeep(row)
|
||||
}
|
||||
|
||||
isEdit.value = edit || false
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +77,7 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||
if (!formEl) return
|
||||
await formEl.validate((valid) => {
|
||||
if (valid) {
|
||||
emit('refresh', form.value)
|
||||
emit('refresh', form.value, isEdit.value)
|
||||
dialogVisible.value = false
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
<template>
|
||||
<div class="function-lib-list-container p-24" style="padding-top: 16px">
|
||||
<el-tabs
|
||||
v-model="functionType"
|
||||
@tab-change="
|
||||
tabChangeHandle
|
||||
|
||||
"
|
||||
>
|
||||
<el-tabs v-model="functionType" @tab-change="tabChangeHandle">
|
||||
<el-tab-pane :label="$t('views.functionLib.title')" name="PUBLIC"></el-tab-pane>
|
||||
<el-tab-pane :label="$t('views.functionLib.internalTitle')" name="INTERNAL"></el-tab-pane>
|
||||
</el-tabs>
|
||||
|
|
@ -165,6 +159,14 @@
|
|||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-if="item.template_id"
|
||||
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
|
||||
@click.stop="addInternalFunction(item, true)"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>
|
||||
{{ $t('common.edit') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="!item.template_id"
|
||||
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
|
||||
|
|
@ -366,17 +368,24 @@ async function openDescDrawer(row: any) {
|
|||
InternalDescDrawerRef.value.open(content, row)
|
||||
}
|
||||
|
||||
function addInternalFunction(data?: any) {
|
||||
AddInternalFunctionDialogRef.value.open(data)
|
||||
function addInternalFunction(data?: any, isEdit?: boolean) {
|
||||
AddInternalFunctionDialogRef.value.open(data, isEdit)
|
||||
}
|
||||
|
||||
function confirmAddInternalFunction(data?: any) {
|
||||
functionLibApi
|
||||
.addInternalFunction(data.id, { name: data.name }, changeStateloading)
|
||||
.then((res) => {
|
||||
MsgSuccess(t('common.submitSuccess'))
|
||||
function confirmAddInternalFunction(data?: any, isEdit?: boolean) {
|
||||
if (isEdit) {
|
||||
functionLibApi.putFunctionLib(data?.id as string, data, loading).then((res) => {
|
||||
MsgSuccess(t('common.saveSuccess'))
|
||||
searchHandle()
|
||||
})
|
||||
} else {
|
||||
functionLibApi
|
||||
.addInternalFunction(data.id, { name: data.name }, changeStateloading)
|
||||
.then((res) => {
|
||||
MsgSuccess(t('common.addSuccess'))
|
||||
searchHandle()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function searchHandle() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue