From e1e694369dabf557615669ce2f71e9af70277ff6 Mon Sep 17 00:00:00 2001
From: admin <344137771@qq.com>
Date: Wed, 07 Jan 2026 13:56:32 +0800
Subject: [PATCH] 1

---
 src/views/modules/user-relation/basics-variety-add-or-update.vue |  161 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 123 insertions(+), 38 deletions(-)

diff --git a/src/views/modules/user-relation/basics-variety-add-or-update.vue b/src/views/modules/user-relation/basics-variety-add-or-update.vue
index 0b0989c..cf74603 100644
--- a/src/views/modules/user-relation/basics-variety-add-or-update.vue
+++ b/src/views/modules/user-relation/basics-variety-add-or-update.vue
@@ -19,38 +19,58 @@
       <span>详细信息</span>
       <el-divider></el-divider>
 
-      <el-form-item label="实名姓名" prop="name" style="width: auto">
+      <el-form-item v-if="!dataForm.uuid" label="用户UID" prop="userCode" style="width: auto">
         <el-input
-          v-model="dataForm.name"
-          placeholder=""
-          disabled
+          v-model="dataForm.userCode"
+          placeholder="请输入用户UID"
           style="width: 510px"
         ></el-input>
       </el-form-item>
 
-      <el-form-item label="证件名称" prop="idName" style="width: auto">
+      <el-form-item label="实名姓名" prop="name" style="width: auto">
         <el-input
-          v-model="dataForm.idName"
-          placeholder=""
-          disabled
+          v-model="dataForm.name"
+          placeholder="请输入实名姓名"
           style="width: 510px"
         ></el-input>
       </el-form-item>
+
+      <!-- <el-form-item label="证件名称" prop="idName" style="width: auto">
+        <el-input
+          v-model="dataForm.idName"
+          placeholder="请输入证件名称"
+          style="width: 510px"
+        ></el-input>
+      </el-form-item> -->
 
       <el-form-item label="证件号码" prop="idNumber" style="width: auto">
         <el-input
           v-model="dataForm.idNumber"
-          placeholder=""
-          disabled
+          placeholder="请输入证件号码"
           style="width: 510px"
         ></el-input>
       </el-form-item>
 
       <el-form-item label="国籍" prop="nationality" style="width: auto">
+        <el-select
+          v-model="dataForm.nationality"
+          placeholder="请选择国籍"
+          style="width: 510px"
+          filterable
+        >
+          <el-option
+            v-for="item in countryOptions"
+            :key="item.code"
+            :label="item.name"
+            :value="item.code"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+
+      <el-form-item label="认证手机号" prop="phone" style="width: auto">
         <el-input
-          v-model="dataForm.natialName"
-          placeholder=""
-          disabled
+          v-model="dataForm.phone"
+          placeholder="请输入认证手机号"
           style="width: 510px"
         ></el-input>
       </el-form-item>
@@ -106,7 +126,7 @@
             </el-button>
           </el-form-item>
         </el-col>
-        <el-col :span="8">
+        <!-- <el-col :span="8">
           <el-form-item label="手持正面照" prop="methodImg">
             <el-upload
               class="avatar-uploader"
@@ -129,7 +149,7 @@
               查看
             </el-button>
           </el-form-item>
-        </el-col>
+        </el-col> -->
       </el-row>
       <div class="mainCant" v-if="imgViewerVisible">
         <div>
@@ -153,6 +173,7 @@
 <script>
 import { Debounce } from "@/utils/debounce";
 import { countries } from "@/utils/countryList";
+import { isMobile } from "@/utils/validate";
 export default {
   data() {
     return {
@@ -163,7 +184,7 @@
       handheldPhoto1: "",
       idFrontImg: "",
       idBackImg: "",
-      handheldPhoto: "",
+      // handheldPhoto: "",
       visible: false,
       dialogFormVisible: true,
       formLabelWidth: "120px",
@@ -190,10 +211,39 @@
         relatedStockName: [],
         name: "",
         natialName: "",
+        nationality: "",
+        phone: "",
+        userCode: "",
       },
+      countryOptions: [],
       fixstork: [], //返回的相关股票品种
       stocks: [],
       dataRule: {
+        userCode: [
+          { required: true, message: "用户UID不能为空", trigger: "blur" },
+        ],
+        name: [
+          { required: true, message: "实名姓名不能为空", trigger: "blur" },
+        ],
+        // idName: [
+        //   { required: true, message: "证件名称不能为空", trigger: "blur" },
+        // ],
+        idNumber: [
+          { required: true, message: "证件号码不能为空", trigger: "blur" },
+        ],
+        nationality: [
+          { required: true, message: "国籍不能为空", trigger: "change" },
+        ],
+        phone: [
+          { required: true, message: "认证手机号不能为空", trigger: "blur" },
+          // { validator: (rule, value, callback) => {
+          //     if (value && !isMobile(value)) {
+          //       callback(new Error("手机号格式错误"));
+          //     } else {
+          //       callback();
+          //     }
+          //   }, trigger: "blur" },
+        ],
         relatedStockName: [
           { required: true, message: "成分股不能为空", trigger: "blur" },
         ],
@@ -223,7 +273,9 @@
       },
     };
   },
-  mounted() {},
+  mounted() {
+    this.initCountryOptions();
+  },
   components: {
     "el-image-viewer": () =>
       import("element-ui/packages/image/src/image-viewer"),
@@ -231,10 +283,20 @@
   methods: {
     init(row) {
       //console.log(row);
-      let id = row.uuid;
       this.dataForm = {};
       this.visible = true;
-      this.getDesc(id);
+      if (row && row.uuid) {
+        // 编辑模式:获取详情
+        let id = row.uuid;
+        this.getDesc(id);
+      } else {
+        // 新增模式:初始化空表单
+        this.$nextTick(() => {
+          if (this.$refs["dataForm"]) {
+            this.$refs["dataForm"].clearValidate();
+          }
+        });
+      }
     },
     handClose() {
       this.$data.dataForm = JSON.parse(
@@ -246,6 +308,16 @@
     },
     changeVal(val) {
       this.$forceUpdate();
+    },
+    initCountryOptions() {
+      // 从国家列表中提取选项
+      const countryList = countries["zh-CN"] || countries["en"];
+      this.countryOptions = Object.keys(countryList).map((key) => ({
+        code: key,
+        name: countryList[key].name,
+      }));
+      // 按名称排序
+      this.countryOptions.sort((a, b) => a.name.localeCompare(b.name, "zh-CN"));
     },
     dataFormSubmit: Debounce(function () {
       this.UpdateProjectBreed();
@@ -344,17 +416,29 @@
     UpdateProjectBreed() {
       //start
       this.$refs["dataForm"].validate((valid) => {
-        //修改
         if (valid) {
+          const isEdit = this.dataForm.uuid;
+          const requestData = {
+            userCode: this.dataForm.userCode,
+            name: this.dataForm.name,
+            idNumber: this.dataForm.idNumber,
+            nationality: this.dataForm.nationality,
+            phone: this.dataForm.phone,
+            idFrontImg: this.idFrontImg1,
+            idBackImg: this.idBackImg1,
+            // handheldPhoto: this.handheldPhoto1,
+          };
+          
+          // 编辑模式需要传递 uuid
+          if (isEdit) {
+            requestData.uuid = this.dataForm.uuid;
+          }
+
+          // 新增和编辑的接口是一样的, 只是编辑需要多传个uuid
           this.$http({
-            url: this.$http.adornUrl(`/edit`),
+            url: this.$http.adornUrl('/edit'),
             method: "put",
-            data: this.$http.adornData({
-              uuid: this.dataForm.uuid,
-              idFrontImg: this.idFrontImg1,
-              idBackImg: this.idBackImg1,
-              handheldPhoto: this.handheldPhoto1,
-            }),
+            data: this.$http.adornData(requestData),
           }).then(({ data }) => {
             if (data.code == 0) {
               this.$message({
@@ -391,11 +475,20 @@
       }).then(({ data }) => {
         if (data.code == 0) {
           this.dataForm = data.data;
-          this.dataForm.natialName =
-            countries["zh-CN"][this.dataForm.nationality]["name"];
+          // 如果后端返回的是国家代码,直接使用;如果返回的是名称,需要找到对应的代码
+          if (this.dataForm.nationality && countries["zh-CN"] && countries["zh-CN"][this.dataForm.nationality]) {
+            this.dataForm.natialName = countries["zh-CN"][this.dataForm.nationality]["name"];
+          } else if (this.dataForm.nationality) {
+            // 如果 nationality 是代码但找不到,保持原值
+            this.dataForm.nationality = this.dataForm.nationality;
+          } else {
+            this.dataForm.nationality = "";
+          }
+          this.dataForm.phone = this.dataForm.phone || "";
+          this.dataForm.userCode = this.dataForm.userCode || "";
           this.idFrontImg = this.dataForm.idFrontImg || "";
           this.idBackImg = this.dataForm.idBackImg || "";
-          this.handheldPhoto = this.dataForm.handheldPhoto || "";
+          // this.handheldPhoto = this.dataForm.handheldPhoto || "";
         } else {
           this.$message({
             message: data.msg,
@@ -481,13 +574,5 @@
     /* margin: 0; */
     padding: 0 0 0 17px;
     border-radius: 20px;
-}
-::v-deep .el-icon-close{
-  /* position: relative;
-    left: 100%;
-    z-index: 9999;
-    top: 8%;
-    font-size: 20px;
-    color: #02a1e9; */
 }
 </style>

--
Gitblit v1.9.3