From ddedba1e8eaa898ea0fae71ed594392fe7e5a213 Mon Sep 17 00:00:00 2001
From: pyt <626651354@qq.com>
Date: 星期三, 08 一月 2025 18:20:06 +0800
Subject: [PATCH] 1

---
 src/component/userInfo.vue |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/src/component/userInfo.vue b/src/component/userInfo.vue
index d16059c..6b43204 100644
--- a/src/component/userInfo.vue
+++ b/src/component/userInfo.vue
@@ -1,7 +1,8 @@
 <template>
-    <el-dialog :visible.sync="show" :show-close="false" width="80%" top="51px" :close-on-click-modal="false">
+    <el-dialog :visible.sync="show" :show-close="false" width="80%" top="51px" :close-on-click-modal="false"
+        append-to-body @open="open">
         <div class="content">
-            <el-form label-position="left" label-width="120px" :model="form" :rules="rules">
+            <el-form label-position="left" label-width="120px" ref="form" :model="form" :rules="rules">
                 <div class="title">个人信息</div>
                 <div class="company">所属公司:{{ userInfo.companyName }}</div>
                 <el-row :gutter="90" class="companyForm">
@@ -83,7 +84,7 @@
             </el-form>
             <div class="btns">
                 <el-button @click="$emit('close')">关闭</el-button>
-                <el-button type="primary">保存</el-button>
+                <el-button type="primary" @click="submit">保存</el-button>
             </div>
         </div>
     </el-dialog>
@@ -114,19 +115,35 @@
         ...mapState(['userInfo'])
     },
     watch: {
-        show(val) {
-            if (val) {
-                this.form = {
-                    userName: this.userInfo.userName,
-                    phone: this.userInfo.phone,
-                    userEmail: this.userInfo.userEmail,
-                    otherEmails: this.userInfo.otherEmails,
-                    contactInfoList: this.userInfo.contactInfoList,
+        'show': {
+            handler(val) {
+                if (val) {
+                    this.open()
                 }
-            }
+            },
+            immediate: true
         }
     },
     methods: {
+        // 提交
+        submit() {
+            this.$refs.form.validate((valid) => {
+                if (valid) {
+                    console.log(this.form);
+                }
+            })
+        },
+        // 打开
+        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,
+            }
+        },
         // 新增其他邮箱
         addEmail() {
             this.form.otherEmails.push({

--
Gitblit v1.7.1