Forráskód Böngészése

客户编辑页面提交

shengxuefei 4 éve
szülő
commit
e4070c2b79
1 módosított fájl, 254 hozzáadás és 236 törlés
  1. 254 236
      src/components/saclientmodify.vue

+ 254 - 236
src/components/saclientmodify.vue

@@ -38,11 +38,10 @@
         is-link
         title-class="title1"
         value-class="value1"
-        @click="showSex=true"
-        
+        @click="showSex = true"
       ></van-cell>
       <van-popup v-model="showSex" round position="bottom">
-         <van-picker
+        <van-picker
           show-toolbar
           title="请选择"
           :columns="sexData"
@@ -91,7 +90,7 @@
         v-model="credentialsId"
         name="证件号"
         label="证件号"
-        placeholder="请输入"       
+        placeholder="请输入"
         input-align="right"
       />
       <van-cell
@@ -111,7 +110,6 @@
           :max-date="maxDate"
           @cancel="showBirth = false"
           @confirm="onConfirmBirth"
-          
         />
       </van-popup>
       <van-cell
@@ -136,7 +134,7 @@
         v-model="household"
         name="户籍"
         label="户籍"
-        placeholder="请输入"       
+        placeholder="请输入"
         input-align="right"
       />
       <van-field
@@ -151,21 +149,21 @@
         v-model="post"
         name="邮编"
         label="邮编"
-        placeholder="请输入"       
+        placeholder="请输入"
         input-align="right"
       />
       <van-field
         v-model="fax"
         name="传真"
         label="传真"
-        placeholder="请输入"       
+        placeholder="请输入"
         input-align="right"
       />
       <van-field
         v-model="email"
         name="电子邮箱"
         label="电子邮箱"
-        placeholder="请输入"       
+        placeholder="请输入"
         input-align="right"
       />
       <van-cell
@@ -195,12 +193,12 @@
         placeholder="请输入"
         class="remarkBottom"
       />
-       
+
       <van-row class="bottom">
-        <van-col span="12" class="bgGrey"  @click="cancel">
+        <van-col span="12" class="bgGrey" @click="cancel">
           <van-icon name="close" />取消
         </van-col>
-        <van-col span="12" class="bgRed"  @click="save"
+        <van-col span="12" class="bgRed" @click="save"
           ><van-icon name="passed" />保存
         </van-col>
       </van-row>
@@ -211,52 +209,57 @@
 <script>
 import {
   GetSaClientInfo,
-  ModifySaClient ,GetNationalityList,GetCredentialsTypeList,GetCognizeWayList
+  ModifySaClient,
+  GetNationalityList,
+  GetCredentialsTypeList,
+  GetCognizeWayList,
 } from "@/common/api/loginApi.js";
 import Decimal from "decimal.js";
-import '../assets/css/resetvant.css';
+import "../assets/css/resetvant.css";
 export default {
   name: "login",
   data() {
     return {
       id: "",
       name: "",
-      phone:'',
-      sex:0,
-      sexName:'',
-      showSex:false,
-      sexData:[{id:0,text:'男'},{id:1,text:'女'}],
-      sexIndex:0,
-      nationality:'',
-      showNationality:false,
-      nationalityData:[],
-      nationalityIndex:0,
-      credentialsType:'',
-      showCredentialsType:false,
-      credentialsTypeData:[],
-      credentialsTypeIndex:0,
-      credentialsId:'',
-      birth:'',
-      birthSel:'',
-      showBirth:false,
-      marry:'',
-      showMarry:false,
-      marryData:['已婚','未婚','未知'],
-      marryIndex:0,
-      household:'',
-      address:'',
-      post:'',
-      fax:'',
-      email:'',
-      remark:'',
-      cognizeWay:'',
-      showCognizeWay:false,
-      cognizeWayData:[],    
-      cognizeWayIndex:0,  
+      phone: "",
+      sex: 0,
+      sexName: "",
+      showSex: false,
+      sexData: [
+        { id: 0, text: "男" },
+        { id: 1, text: "女" },
+      ],
+      sexIndex: 0,
+      nationality: "",
+      showNationality: false,
+      nationalityData: [],
+      nationalityIndex: 0,
+      credentialsType: "",
+      showCredentialsType: false,
+      credentialsTypeData: [],
+      credentialsTypeIndex: 0,
+      credentialsId: "",
+      birth: "",
+      birthSel: "",
+      showBirth: false,
+      marry: "",
+      showMarry: false,
+      marryData: ["已婚", "未婚", "未知"],
+      marryIndex: 0,
+      household: "",
+      address: "",
+      post: "",
+      fax: "",
+      email: "",
+      remark: "",
+      cognizeWay: "",
+      showCognizeWay: false,
+      cognizeWayData: [],
+      cognizeWayIndex: 0,
       minDate: new Date(1900, 0, 1),
       maxDate: new Date(2025, 10, 1),
-      phoneList:[]
-     
+      phoneList: [],
     };
   },
   created: function () {
@@ -267,7 +270,6 @@ export default {
     this.name = this.$route.query.name;
     //顺序加载数据
     this.GetNationalityList();
-    
   },
   computed: {
     //计算属性
@@ -290,200 +292,217 @@ export default {
           return;
         }
         that.phone = res.data.Phone;
-        that.sex=res.data.Sex;
-        if(that.sex==0){
-          that.sexName='男';
+        that.sex = res.data.Sex;
+        if (that.sex == 0) {
+          that.sexName = "男";
+        } else {
+          that.sexName = "女";
         }
-        else{
-          that.sexName='女';
-        }
-        that.remark=res.data.Remark;
-        that.credentialsType=res.data.CredentialsType;
-        that.credentialsId=res.data.CredentialsId;
-        that.nationality=res.data.Nationality;
-        that.birth=res.data.Birth;
-        var arr=res.data.Birth.split("-");
-        console.info('arr',arr);
-        that.birthSel=new Date(arr[0],Decimal(arr[1]).sub(1),arr[2]);
-        console.info('birthSel',that.birthSel);
-        that.marry=res.data.Marry;
-        that.household=res.data.Household;
-        that.post=res.data.Post;
-        that.fax=res.data.Fax;
-        that.email=res.data.Email;
-        that.address=res.data.Address;
-        that.cognizeWay=res.data.CognizeWay;
-        res.data.PhoneNumbers.forEach(function(item,index,arr){
-            that.phoneList.push(item);
+        that.remark = res.data.Remark;
+        that.credentialsType = res.data.CredentialsType;
+        that.credentialsId = res.data.CredentialsId;
+        that.nationality = res.data.Nationality;
+        that.birth = res.data.Birth;
+        var arr = res.data.Birth.split("-");
+        console.info("arr", arr);
+        that.birthSel = new Date(arr[0], Decimal(arr[1]).sub(1), arr[2]);
+        console.info("birthSel", that.birthSel);
+        that.marry = res.data.Marry;
+        that.household = res.data.Household;
+        that.post = res.data.Post;
+        that.fax = res.data.Fax;
+        that.email = res.data.Email;
+        that.address = res.data.Address;
+        that.cognizeWay = res.data.CognizeWay;
+        res.data.PhoneNumbers.forEach(function (item, index, arr) {
+          that.phoneList.push(item);
         });
         //性别赋初始值
-        that.sexData.forEach(function(item,index,arr){
-            if(item.id==that.sex){
-              that.sexIndex=index;
-              return;
-            }
+        that.sexData.forEach(function (item, index, arr) {
+          if (item.id == that.sex) {
+            that.sexIndex = index;
+            return;
+          }
         });
         //国籍赋初始值
-        that.nationalityData.forEach(function(value,index,arr){
-            if(value==that.nationality){
-              that.nationalityIndex=index;
-              return;
-            }
+        that.nationalityData.forEach(function (value, index, arr) {
+          if (value == that.nationality) {
+            that.nationalityIndex = index;
+            return;
+          }
         });
         //证件类型赋初始值
-        that.credentialsTypeData.forEach(function(value,index,arr){
-            if(value==that.credentialsType){
-              that.credentialsTypeIndex=index;
-              return;
-            }
+        that.credentialsTypeData.forEach(function (value, index, arr) {
+          if (value == that.credentialsType) {
+            that.credentialsTypeIndex = index;
+            return;
+          }
         });
-         //婚姻状况赋初始值
-        that.marryData.forEach(function(value,index,arr){
-            if(value==that.marry){
-              that.marryIndex=index;
-              return;
-            }
+        //婚姻状况赋初始值
+        that.marryData.forEach(function (value, index, arr) {
+          if (value == that.marry) {
+            that.marryIndex = index;
+            return;
+          }
         });
-         //认知途径赋初始值
-        that.cognizeWayData.forEach(function(value,index,arr){
-            if(value==that.cognizeWay){
-              that.cognizeWayIndex=index;
-              return;
-            }
+        //认知途径赋初始值
+        that.cognizeWayData.forEach(function (value, index, arr) {
+          if (value == that.cognizeWay) {
+            that.cognizeWayIndex = index;
+            return;
+          }
         });
       });
     },
-    GetNationalityList:function(){     //获取国籍
-       var that = this;  
-        var data = {
-          projectId: that.$store.state.projectId
-        };
-        console.info("GetNationalityList data", data);
-        GetNationalityList(data).then((res) => {
-          console.info("GetNationalityList", res);
-          if (!res.result) {
-            that.$toast(res.msg);
-            return;
-          }
-           res.data.forEach(function(item,index,array){
-             that.nationalityData.push(item.name);
-           });
-           that.GetCredentialsTypeList();
+    GetNationalityList: function () {
+      //获取国籍
+      var that = this;
+      var data = {
+        projectId: that.$store.state.projectId,
+      };
+      console.info("GetNationalityList data", data);
+      GetNationalityList(data).then((res) => {
+        console.info("GetNationalityList", res);
+        if (!res.result) {
+          that.$toast(res.msg);
+          return;
+        }
+        res.data.forEach(function (item, index, array) {
+          that.nationalityData.push(item.name);
         });
+        that.GetCredentialsTypeList();
+      });
     },
-     GetCredentialsTypeList:function(){     //获取证件类型
-       var that = this;  
-        var data = {
-          projectId: that.$store.state.projectId
-        };
-        console.info("GetCredentialsTypeList data", data);
-        GetCredentialsTypeList(data).then((res) => {
-          console.info("GetCredentialsTypeList", res);
-          if (!res.result) {
-            that.$toast(res.msg);
-            return;
-          }
-           res.data.forEach(function(item,index,array){
-             that.credentialsTypeData.push(item.name);
-           });
-           that.GetCognizeWayList();
+    GetCredentialsTypeList: function () {
+      //获取证件类型
+      var that = this;
+      var data = {
+        projectId: that.$store.state.projectId,
+      };
+      console.info("GetCredentialsTypeList data", data);
+      GetCredentialsTypeList(data).then((res) => {
+        console.info("GetCredentialsTypeList", res);
+        if (!res.result) {
+          that.$toast(res.msg);
+          return;
+        }
+        res.data.forEach(function (item, index, array) {
+          that.credentialsTypeData.push(item.name);
         });
+        that.GetCognizeWayList();
+      });
     },
-    GetCognizeWayList:function(){     //获取认知途径
-       var that = this;  
-        var data = {
-          projectId: that.$store.state.projectId,
-          clientId:that.id
-        };
-        console.info("GetCognizeWayList data", data);
-        GetCognizeWayList(data).then((res) => {
-          console.info("GetCognizeWayList", res);
-          if (!res.result) {
-            that.$toast(res.msg);
-            return;
-          }
-           res.data.forEach(function(item,index,array){
-             that.cognizeWayData.push(item.name);
-           });
-           that.GetSaClientInfo();
+    GetCognizeWayList: function () {
+      //获取认知途径
+      var that = this;
+      var data = {
+        projectId: that.$store.state.projectId,
+        clientId: that.id,
+      };
+      console.info("GetCognizeWayList data", data);
+      GetCognizeWayList(data).then((res) => {
+        console.info("GetCognizeWayList", res);
+        if (!res.result) {
+          that.$toast(res.msg);
+          return;
+        }
+        res.data.forEach(function (item, index, array) {
+          that.cognizeWayData.push(item.name);
         });
-    },    
-    onConfirmSex: function (item,index) {
-       console.info('onConfirmSex',item);
-       this.sex=item.id;
-       this.sexName=item.text;
-       this.showSex=false;
+        that.GetSaClientInfo();
+      });
+    },
+    onConfirmSex: function (item, index) {
+      console.info("onConfirmSex", item);
+      this.sex = item.id;
+      this.sexName = item.text;
+      this.showSex = false;
     },
-    onConfirmNationality:function (value,index) {   //国籍
-       console.info('onConfirmNationality',value);
-       this.nationality=value;
-       this.showNationality=false;
+    onConfirmNationality: function (value, index) {
+      //国籍
+      console.info("onConfirmNationality", value);
+      this.nationality = value;
+      this.showNationality = false;
     },
-     onConfirmCredentialsType:function (value,index) {   //证件类型
-       console.info('onConfirmCredentialsType',value);
-       this.credentialsType=value;
-       this.showCredentialsType=false;
+    onConfirmCredentialsType: function (value, index) {
+      //证件类型
+      console.info("onConfirmCredentialsType", value);
+      this.credentialsType = value;
+      this.showCredentialsType = false;
     },
-    onConfirmBirth:function (value,index) {   //出生日期
-       console.info('onConfirmBirth',value);
-       this.birth=this.$util.getDate(value);
-       this.showBirth=false;
+    onConfirmBirth: function (value, index) {
+      //出生日期
+      console.info("onConfirmBirth", value);
+      this.birth = this.$util.getDate(value);
+      this.showBirth = false;
     },
-    onConfirmMarry:function (value,index) {   //婚姻状况
-       console.info('onConfirmMarry',value);
-       this.marry=value;
-       this.showMarry=false;
+    onConfirmMarry: function (value, index) {
+      //婚姻状况
+      console.info("onConfirmMarry", value);
+      this.marry = value;
+      this.showMarry = false;
     },
-    onConfirmCognizeWay:function (value,index) {   //认知途径
-       console.info('onConfirmCognizeWay',value);
-       this.cognizeWay=value;
-       this.showCognizeWay=false;
+    onConfirmCognizeWay: function (value, index) {
+      //认知途径
+      console.info("onConfirmCognizeWay", value);
+      this.cognizeWay = value;
+      this.showCognizeWay = false;
     },
-    cancel:function(){
+    cancel: function () {
       this.$router.go(-1);
     },
-    save:function(){
-      let that=this;
-      let jsonData={
-        name:that.name,
-        phone:that.phone,
-        sex:that.sex,
-        remark:that.remark,
-        credentialsType:that.credentialsType,
-        credentialsId:that.credentialsId,
-        nationality:that.nationality,
-        birth:that.birth,
-        marry:that.marry,
-        household:that.household,
-        post:that.post,
-        fax:that.fax,
-        email:that.email,
-        address:that.address,
-        cognizeWay:that.cognizeWay,
-        phoneList:null
+    save: function () {
+      let that = this;
+      let jsonData = {
+        name: that.name,
+        phone: that.phone,
+        sex: that.sex,
+        remark: that.remark,
+        credentialsType: that.credentialsType,
+        credentialsId: that.credentialsId,
+        nationality: that.nationality,
+        birth: that.birth,
+        marry: that.marry,
+        household: that.household,
+        post: that.post,
+        fax: that.fax,
+        email: that.email,
+        address: that.address,
+        cognizeWay: that.cognizeWay,
+        phoneList: that.phoneList,
       };
-      console.info('save jsonData',JSON.stringify(jsonData));
-      let data={
-         userCode:that.$store.state.data.userCode,
-         projectId: that.$store.state.projectId,
-         clientId:that.id,
-         jsonData:JSON.stringify(jsonData)
+      //console.info("save jsonData", JSON.stringify(jsonData));
+      let data = {
+        userCode: that.$store.state.data.userCode,
+        projectId: that.$store.state.projectId,
+        clientId: that.id,
+        jsonData: JSON.stringify(jsonData),
       };
-      console.info('save',data);
+      console.info("save", data);
       //return;
-      ModifySaClient(data).then((res)=>{
-         console.info('ModifySaClient',res);
-         
-         that.$dialog.alert({
+      ModifySaClient(data).then((res) => {
+        console.info("ModifySaClient", res);
+        if (res.result) {
+          if (res.msg == null) {
+            that.$router.go(-1);
+          } else {
+            that.$dialog
+              .alert({
+                message: res.msg,
+              })
+              .then(() => {
+                // on close
+                if (res.result) {
+                  that.$router.go(-1);
+                }
+              });
+          }
+        } else {
+          that.$dialog.alert({
             message: res.msg,
-          }).then(() => {
-            // on close
-            if(res.result){
-              that.$router.go(-1);
-            }
           });
-
-      }); 
+        }
+      });
     },
     onClickLeft() {
       // this.$toast('返回')
@@ -499,71 +518,70 @@ export default {
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->
 <style scoped >
-
-.title1{
+.title1 {
   color: #aaa;
-  font-size:15px;
+  font-size: 15px;
 
-  text-align:left;
-  height:30px;
+  text-align: left;
+  height: 30px;
 }
-.title2{
+.title2 {
   color: #ff0000;
-  text-align:left;
+  text-align: left;
   font-size: 13px;
 }
-.infoTitle{
+.infoTitle {
   color: #aaa;
   text-align: left;
 }
-.value1{
+.value1 {
   color: #000;
   font-size: 13px;
 }
-.infoValue{
+.infoValue {
   color: #0606af;
 }
-.size{
+.size {
   font-size: 16px;
 }
-.header{
+.header {
   margin-top: 10px;
   height: 70px;
   border-bottom: #cfcfcf solid 3px;
 }
-.titleClass{
+.titleClass {
   border-bottom: #000 solid 1px;
 }
-.van-tab{
+.van-tab {
   color: #ff0000;
 }
-.redColor{
+.redColor {
   color: #ff0000;
 }
-.bgBlue{
+.bgBlue {
   background: #a0a0f7;
   height: 30px;
   margin-top: 5px;
   padding-top: 5px;
 }
-.bgBill{
+.bgBill {
   height: 30px;
   border-bottom: #aaa solid 1px;
   padding-top: 5px;
 }
-.bottom{
+.bottom {
   /* left:0; */
   bottom: 0px;
   position: fixed;
   width: 100%;
 }
-.bgGrey{
+.bgGrey {
   background: #999999;
   height: 35px;
   justify-content: center;
   padding-top: 5px;
 }
-.bgRed{
+.bgRed {
   background: #ff0000;
   height: 35px;
   justify-content: center;
@@ -571,9 +589,9 @@ export default {
   font-weight: 900;
   padding-top: 5px;
 }
- .remarkBottom{
-   margin-bottom:40px;
- }
+.remarkBottom {
+  margin-bottom: 40px;
+}
 </style>