mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2025-02-07 20:32:49 +08:00
配置 add.formData 修复 Object.assign 把个别属性去掉的问题
This commit is contained in:
parent
7554372850
commit
9478c2e960
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, getCurrentInstance, watch } from 'vue'
|
import { ref, reactive, getCurrentInstance, watch } from 'vue'
|
||||||
|
import common from '@/scripts/common'
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
const rules = reactive(getRules())
|
const rules = reactive(getRules())
|
||||||
const formData = ref(initFormData())
|
const formData = ref(initFormData())
|
||||||
@ -51,7 +52,7 @@
|
|||||||
watch(() => [props.detail && props.detail.formData, props.add && props.add.formData], (value) => {
|
watch(() => [props.detail && props.detail.formData, props.add && props.add.formData], (value) => {
|
||||||
value.forEach(it => {
|
value.forEach(it => {
|
||||||
if(it){
|
if(it){
|
||||||
Object.assign(formData.value, it)
|
formData.value = common.objectAssign(formData.value, it)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},{ deep: true })
|
},{ deep: true })
|
||||||
@ -61,7 +62,7 @@
|
|||||||
proxy.$common.setDefaultValue(props.form.props, 'labelWidth', '120px')
|
proxy.$common.setDefaultValue(props.form.props, 'labelWidth', '120px')
|
||||||
|
|
||||||
if(props.add && props.add.formData){
|
if(props.add && props.add.formData){
|
||||||
Object.assign(formData.value, props.add.formData)
|
formData.value = common.objectAssign(formData.value, props.add.formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRules(){
|
function getRules(){
|
||||||
@ -122,7 +123,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(formData.value){
|
if(formData.value){
|
||||||
formData.value = Object.assign(_formData, formData.value)
|
formData.value = common.objectAssign(_formData, formData.value)
|
||||||
} else {
|
} else {
|
||||||
formData.value = _formData
|
formData.value = _formData
|
||||||
}
|
}
|
||||||
|
@ -229,4 +229,8 @@ common.exportExcel = (options) => {
|
|||||||
writeFile(wb, `${options.fileName}.${options.suffix || 'xlsx'}`);
|
writeFile(wb, `${options.fileName}.${options.suffix || 'xlsx'}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.objectAssign = (target, source) => {
|
||||||
|
return Object.assign({}, JSON.parse(JSON.stringify(target)), JSON.parse(JSON.stringify(source)))
|
||||||
|
}
|
||||||
|
|
||||||
export default common
|
export default common
|
||||||
|
Loading…
Reference in New Issue
Block a user