helloworld180 1 month ago
parent 7808e0d3d3
commit 8efd2b19e6

@ -77,7 +77,7 @@
</el-select>
</el-form-item>
<el-form-item label="出生日期">
<el-form-item label="出生日期" prop="birthDate">
<el-date-picker
v-model="currentMember.birthDate"
type="date"
@ -154,6 +154,9 @@ export default {
],
relation: [
{ required: true, message: '请选择关系', trigger: 'change' }
],
birthDate: [
{ required: true, message: '请选择出生日期', trigger: 'change' }
]
},
treeData :{
@ -380,12 +383,13 @@ export default {
this.currentMember.image_url = e.target.result
}
reader.readAsDataURL(file)
this.currentMember.file = file;
//
// const formData = new FormData()
// formData.append('file', file)
// API...
},
//
async saveMember() {
const isValid = await new Promise((resolve) => {
@ -399,49 +403,18 @@ export default {
}
try {
const formData = new FormData();
// FormData
formData.append('name', this.currentMember.name);
formData.append('parentId', this.currentMember.parentId);
formData.append('relation', this.currentMember.relation);
formData.append('birthDate', this.currentMember.birthDate);
formData.append('phone', this.currentMember.phone);
formData.append('isCurrentUser', this.currentMember.isCurrentUser);
// FormData
if (this.currentMember.file) {
formData.append('file', this.currentMember.file);
}
const url = this.currentMember.id ?
`/family-tree/${this.currentMember.id}` :
'/family-tree';
'/family-tree'
await request({
url,
method: this.currentMember.id ? 'put' : 'post',
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
}
});
ElMessage.success('保存成功');
this.dialogVisible = false;
this.fetchTreeData();
// const url = this.currentMember.id ?
// `/family-tree/${this.currentMember.id}` :
// '/family-tree'
// await request({
// url,
// method: this.currentMember.id ? 'put' : 'post',
// data: this.currentMember
// })
data: this.currentMember
})
// console.log(':',response) response
// ElMessage.success('')
// this.dialogVisible = false
// this.fetchTreeData()
ElMessage.success('保存成功')
this.dialogVisible = false
this.fetchTreeData()
} catch (error) {
console.log('新增成员失败', this.currentMember)
ElMessage.error('保存失败')

Loading…
Cancel
Save