From d17a93905718456a7557e1bc805887eb2ad0aa5d Mon Sep 17 00:00:00 2001 From: pyt <626651354@qq.com> Date: 星期四, 09 一月 2025 14:53:26 +0800 Subject: [PATCH] fix --- src/component/userInfo.vue | 63 +++++++++++++++++++++++++------ 1 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/component/userInfo.vue b/src/component/userInfo.vue index 6b43204..f21a69f 100644 --- a/src/component/userInfo.vue +++ b/src/component/userInfo.vue @@ -34,7 +34,8 @@ <el-form-item label="备注:" label-width="120px"> <div style="display: flex;align-items: center;"><el-input v-model="item.mark"></el-input> - <img style="width: 19px;height: 21px;cursor: pointer;margin-left: 26px;" + <img @click="delEmail(item, index)" + style="width: 19px;height: 21px;cursor: pointer;margin-left: 26px;" src="@/assets/delete.png" alt=""> </div> </el-form-item> @@ -74,8 +75,9 @@ <el-col :span="20" style="padding-right: 52px;position: relative;"> <el-form-item label="备注:"> <div style="display: flex;align-items: center;"><el-input type="textarea" :rows="3" - v-model="item.mark"></el-input> - <img style="width: 19px;height: 21px;cursor: pointer;position: absolute;right: -175px;" + v-model="item.remark"></el-input> + <img @click="delContact(item, index)" + style="width: 19px;height: 21px;cursor: pointer;position: absolute;right: -175px;" src="@/assets/delete.png" alt=""> </div> </el-form-item> @@ -92,6 +94,7 @@ <script> import { mapState } from 'vuex' +import { saveUserInfo, getUserInfo } from '@/view/service' export default { props: ['show'], data() { @@ -129,28 +132,62 @@ submit() { this.$refs.form.validate((valid) => { if (valid) { - console.log(this.form); + let params = { + extra: localStorage.getItem('extra'), + info: { + name: this.form.userName, + phone: this.form.phone, + mail: this.form.userEmail, + }, + emails: this.form.otherEmails, + addressInfos: this.form.contactInfoList + } + saveUserInfo(params).then(res => { + if (res.status == 0) { + this.$message.success('保存成功') + this.$store.commit('SET_USERNAME', this.form.userName) + } + }) } }) }, // 打开 open() { - let userInfo = JSON.parse(JSON.stringify(this.userInfo)); - this.form = { - userName: userInfo.userName, - phone: userInfo.phone, - userEmail: userInfo.userEmail, - otherEmails: userInfo.otherEmails, - contactInfoList: userInfo.contactInfoList, - } + getUserInfo({ extra: localStorage.getItem('extra') }).then(res => { + if (res.data.emails) { + res.data.emails.map(item => { + item.mail = item.email + }) + } + if (res.data.addressInfo) { + res.data.addressInfo.map(item => { + item.remark = item.mark + }) + } + this.form = { + userName: res.data.name, + phone: res.data.phone, + userEmail: res.data.email, + otherEmails: res.data.emails || [], + contactInfoList: res.data.addressInfo || [], + } + }) + }, + // 删除其他邮箱 + delEmail(item, index) { + this.form.otherEmails.splice(index, 1) }, // 新增其他邮箱 addEmail() { this.form.otherEmails.push({ - email: '', + mail: '', mark: '' }) }, + // 删除收件人 + delContact(item, index) { + this.form.contactInfoList.splice(index, 1) + }, // 新增收件人 addContact() { this.form.contactInfoList.push({ -- Gitblit v1.7.1