1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2025-04-30 22:29:01 +08:00

fix(crud): 浅拷贝 -> 深拷贝

This commit is contained in:
zclzone 2025-01-21 14:37:16 +08:00
parent 26ce0bd551
commit 0733b81f82
2 changed files with 5 additions and 2 deletions

View File

@ -6,6 +6,7 @@
* Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top
**********************************/
import { cloneDeep } from 'lodash-es'
import { useForm, useModal } from '.'
const ACTIONS = {
@ -21,7 +22,7 @@ export function useCrud({ name, initForm = {}, doCreate, doDelete, doUpdate, ref
/** 新增 */
function handleAdd(row = {}, title) {
handleOpen({ action: 'add', title, row: { ...initForm, ...row } })
handleOpen({ action: 'add', title, row: Object.assign({}, cloneDeep(initForm), cloneDeep(row)) })
}
/** 修改 */

View File

@ -6,9 +6,11 @@
* Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top
**********************************/
import { cloneDeep } from 'lodash-es'
export function useForm(initFormData = {}) {
const formRef = ref(null)
const formModel = ref({ ...initFormData })
const formModel = ref(cloneDeep(initFormData))
const rules = {
required: {
required: true,