|
|
|
@ -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('保存失败')
|
|
|
|
|