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 open = (data: any) => {
const obj = cloneDeep(data) const obj = cloneDeep(data)
delete obj['id'] delete obj['id']
obj['name'] = obj['name'] + ' 副本'
applicationForm.value = obj applicationForm.value = obj
dialogVisible.value = true dialogVisible.value = true
} }

View File

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

View File

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