Skip to content

Commit 8b946b4

Browse files
committed
feat(curd): add function to open add modal with preset data
1 parent 4ff5e3b commit 8b946b4

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

packages/curd/src/components/StdCurd.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import type { StdCurdProps } from '../types'
33
import { Button, Card, Checkbox, Divider, Flex, message, Modal, Spin } from 'ant-design-vue'
4+
import { cloneDeep } from 'lodash-es'
45
import { computed, getCurrentInstance, reactive, ref } from 'vue'
56
import { useRoute } from 'vue-router'
67
import { useExport, useLocale } from '../composables'
@@ -141,6 +142,13 @@ async function handleEdit(row: Record<string, any>) {
141142
formVisible.value = true
142143
}
143144
145+
// 从外部打开添加弹窗并使用预设数据
146+
function add(data: Record<string, any>) {
147+
itemDetail.value = cloneDeep(data)
148+
mode.value = 'add'
149+
formVisible.value = true
150+
}
151+
144152
// 保存新增/编辑数据
145153
async function handleSave(data: Record<string, any>) {
146154
modalLoading.value = true
@@ -231,6 +239,7 @@ function onBatchEditSave() {
231239
232240
defineExpose({
233241
refresh,
242+
add,
234243
})
235244
236245
const title = computed(() => {

0 commit comments

Comments
 (0)