perf: 优化函数复制功能

This commit is contained in:
wangdan-fit2cloud 2024-08-21 17:25:16 +08:00 committed by wangdan-fit2cloud
parent 9ac6c84b01
commit c3b2838955
3 changed files with 13 additions and 14 deletions

View File

@ -134,6 +134,7 @@ watch(dialogVisible, (bool) => {
const open = (data: any) => {
const obj = cloneDeep(data)
delete obj['id']
obj['name'] = obj['name'] + ' 副本'
applicationForm.value = obj
dialogVisible.value = true
}

View File

@ -1,7 +1,7 @@
<template>
<el-drawer v-model="visible" size="60%">
<template #header>
<h4>{{ isEdit ? '编辑函数' : '创建函数' }}</h4>
<h4>{{ title }}</h4>
</template>
<div>
<h4 class="title-decoration-1 mb-16">基础信息</h4>
@ -120,6 +120,10 @@ import type { FormInstance } from 'element-plus'
import { MsgSuccess, MsgError } from '@/utils/message'
import { cloneDeep } from 'lodash'
const props = defineProps({
title: String
})
const emit = defineEmits(['refresh'])
const FieldFormDialogRef = ref()
const FunctionDebugDrawerRef = ref()
@ -182,10 +186,6 @@ function refreshFieldList(data: any) {
currentIndex.value = null
}
// function changeCode(value: string) {
// form.value.code = value
// }
const submit = async (formEl: FormInstance | undefined) => {
if (!formEl) return
await formEl.validate((valid: any) => {
@ -209,7 +209,7 @@ const submit = async (formEl: FormInstance | undefined) => {
const open = (data: any) => {
if (data) {
isEdit.value = true
isEdit.value = data?.id ? true : false
form.value = cloneDeep(data)
}
visible.value = true

View File

@ -66,7 +66,7 @@
</el-row>
</InfiniteScroll>
</div>
<FunctionFormDrawer ref="FunctionFormDrawerRef" @refresh="refresh" />
<FunctionFormDrawer ref="FunctionFormDrawerRef" @refresh="refresh" :title="title" />
</div>
</template>
<script setup lang="ts">
@ -88,8 +88,10 @@ const paginationConfig = reactive({
})
const searchValue = ref('')
const title = ref('')
function openCreateDialog(data?: any) {
title.value = data ? '编辑函数' : '创建函数'
FunctionFormDrawerRef.value.open(data)
}
@ -121,15 +123,11 @@ function deleteFunctionLib(row: any) {
}
function copyFunctionLib(row: any) {
title.value = '复制函数'
const obj = cloneDeep(row)
delete obj['id']
functionLibApi.postFunctionLib(obj, loading).then((res) => {
MsgSuccess('复制成功')
paginationConfig.total = 0
paginationConfig.current_page = 1
functionLibList.value = []
getList()
})
obj['name'] = obj['name'] + ' 副本'
FunctionFormDrawerRef.value.open(obj)
}
function getList() {