Browse Source

客户修改

shengxuefei 4 years ago
parent
commit
be2c1ea086

+ 27 - 0
src/common/api/loginApi.js

@@ -202,4 +202,31 @@ export function ModifySaClient(data) {
     method: 'post',
     data
   })
+}
+
+/* 获取国籍 */
+export function GetNationalityList(data) {
+  return request({
+    url: '/GetNationalityList',
+    method: 'post',
+    data
+  })
+}
+
+/* 获取证件类型 */
+export function GetCredentialsTypeList(data) {
+  return request({
+    url: '/GetCredentialsTypeList',
+    method: 'post',
+    data
+  })
+}
+
+/* 获取认知途径*/
+export function GetCognizeWayList(data) {
+  return request({
+    url: '/GetCognizeWayList',
+    method: 'post',
+    data
+  })
 }

+ 1 - 0
src/components/addsaclientcontact.vue

@@ -294,6 +294,7 @@ export default {
          jsonData:JSON.stringify(jsonData)
       };
       console.info('save',data);
+      //return;
       AddSaClientContact(data).then((res)=>{
          console.info('AddSaClientContact',res);
          that.$dialog.alert({

+ 9 - 3
src/components/clientdetail.vue

@@ -22,8 +22,7 @@
     <van-row class="header">
       <van-col span="14">
         <van-row>
-          <van-col span="12">
-            <!-- <van-image :src="require('@/assets/img/header.png')" width="60" height="60" /> -->
+          <van-col span="12">         
             <van-image
               :src="require('@/assets/img/header.png')"
               width="60"
@@ -167,7 +166,7 @@
     </van-tabs>
 
     <van-row class="bottom">
-      <van-col span="12" class="bgGrey">
+      <van-col span="12" class="bgGrey"   @click="editClientInfo">
         <van-icon name="edit" />{{ completion }}
       </van-col>
       <van-col span="12" class="bgRed" @click="AddSaClientContact">
@@ -289,6 +288,13 @@ export default {
         query: { id: that.id, name: that.name },
       });
     },
+    editClientInfo:function(){    //编辑客户信息
+      var that = this;
+      this.$router.push({
+        path: "/saclientmodify",
+        query: { id: that.id, name: that.name },
+      });
+    },
     onClickLeft() {
       // this.$toast('返回')
       console.info("left");

+ 243 - 104
src/components/saclientmodify.vue

@@ -23,25 +23,23 @@
         name="姓名"
         label="姓名"
         placeholder="请输入"
-        readonly
         input-align="right"
       />
-      <van-cell
-        title="手机"
-        :value="phone"
-        is-link
-        title-class="title1"
-        value-class="value1"
-      ></van-cell>
-      
-
+      <van-field
+        v-model="phone"
+        name="手机"
+        label="手机"
+        placeholder="请输入"
+        input-align="right"
+      ></van-field>
       <van-cell
         title="性别"
-        :value="sex"
+        :value="sexName"
         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
@@ -50,6 +48,7 @@
           :columns="sexData"
           @cancel="showSex = false"
           @confirm="onConfirmSex"
+          :default-index="sexIndex"
         />
       </van-popup>
       <van-cell
@@ -58,7 +57,7 @@
         is-link
         title-class="title1"
         value-class="value1"
-        @click="showTime = true"
+        @click="showNationality = true"
       ></van-cell>
       <van-popup v-model="showNationality" round position="bottom">
         <van-picker
@@ -67,6 +66,7 @@
           :columns="nationalityData"
           @cancel="showNationality = false"
           @confirm="onConfirmNationality"
+          :default-index="nationalityIndex"
         />
       </van-popup>
       <van-cell
@@ -84,10 +84,11 @@
           :columns="credentialsTypeData"
           @cancel="showCredentialsType = false"
           @confirm="onConfirmCredentialsType"
+          :default-index="credentialsTypeIndex"
         />
       </van-popup>
       <van-field
-        v-model="CredentialsId"
+        v-model="credentialsId"
         name="证件号"
         label="证件号"
         placeholder="请输入"       
@@ -110,6 +111,7 @@
           :max-date="maxDate"
           @cancel="showBirth = false"
           @confirm="onConfirmBirth"
+          
         />
       </van-popup>
       <van-cell
@@ -127,6 +129,7 @@
           :columns="marryData"
           @cancel="showMarry = false"
           @confirm="onConfirmMarry"
+          :default-index="marryIndex"
         />
       </van-popup>
       <van-field
@@ -180,6 +183,7 @@
           :columns="cognizeWayData"
           @cancel="showCognizeWay = false"
           @confirm="onConfirmCognizeWay"
+          :default-index="cognizeWayIndex"
         />
       </van-popup>
       <van-field
@@ -189,8 +193,9 @@
         label="备注"
         type="textarea"
         placeholder="请输入"
+        class="remarkBottom"
       />
-
+       
       <van-row class="bottom">
         <van-col span="12" class="bgGrey"  @click="cancel">
           <van-icon name="close" />取消
@@ -205,8 +210,8 @@
 
 <script>
 import {
-  GetVisitTypeList,
-  AddSaClientContact 
+  GetSaClientInfo,
+  ModifySaClient ,GetNationalityList,GetCredentialsTypeList,GetCognizeWayList
 } from "@/common/api/loginApi.js";
 import Decimal from "decimal.js";
 import '../assets/css/resetvant.css';
@@ -216,29 +221,42 @@ export default {
     return {
       id: "",
       name: "",
-      visitType: "", //访问类型
-      showVisitType: false,
-      remark: "", //接待信息
-      intention: "", //意向强度
-      planVisitDate: "", //来访计划日期
-      nextReceiveDate: "", //下次接待日期
-      visitDate: "", //接待日期
-      visitTime: "", //接待时间
-      actionType: "",
-
-      visitTypeData: [], //访问类型数组
-      minDate: new Date(2005, 0, 1),
+      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),
-      currentDate: new Date(),
-      currentTime: '',
-      showTime: false,
-      intentionData: [0,1,2,3,4,5],
-      showPlanVisitDate: false,
-      planVisitDateSel: new Date(),
-      showNextReceiveDate: false,
-      nextReceiveDateSel: new Date(),
-      showVisitDate: false,
-      showintention: false,
+      phoneList:[]
+     
     };
   },
   created: function () {
@@ -247,89 +265,204 @@ export default {
     this.$util.persistLogin(this);
     this.id = this.$route.query.id;
     this.name = this.$route.query.name;
-    let date=new Date();
-    this.visitDate=this.$util.getCurrentDate();
-    this.currentTime="10:11";
-    console.info('created currentTime',this.currentTime);
-    this.GetVisitTypeList();
+    //顺序加载数据
+    this.GetNationalityList();
+    
   },
   computed: {
     //计算属性
     completion: function () {},
   },
   methods: {
-    onConfirm: function (item,index) {
-       console.info('onConfirm',item);
-       this.visitType=item.name;
-       this.showVisitType=false;
-    },
-    onConfirmVisitTime:function (time,index) {   //接待时间
-       console.info('onConfirmVisitTime',time);
-       this.visitTime=time;
-       console.info('onConfirmVisitTime visitTime',this.visitTime);
-       this.showTime=false;
-    },
-    onConfirmVisitDate: function (date,index) {  //接待日期
-        console.info('onConfirmVisitDate',date);
-        this.visitDate=this.$util.getDate(date);
-        console.info('onConfirmVisitDate visitDate',this.visitDate);
-        this.showTime=false;
-    },
-    onConfirmIntention:function (value,index) {  //意向强度
-        console.info('onConfirmIntention',value);
-        this.intention=value;
-        console.info('onConfirmIntention intention',this.intention);
-        this.showintention=false;
-    },
-    onConfirmPlanVisitDate:function (date,index) {  //来访计划日期
-        console.info('onConfirmPlanVisitDate',date);
-        this.planVisitDate=this.$util.getDate(date);
-        console.info('onConfirmPlanVisitDate visitDate',this.planVisitDate);
-        this.showPlanVisitDate=false;
-    },
-    onConfirmNextReceiveDate:function (date,index) {  //下次接待日期
-        console.info('onConfirmNextReceiveDate',date);
-        this.nextReceiveDate=this.$util.getDate(date);
-        console.info('onConfirmNextReceiveDate nextReceiveDate',this.nextReceiveDate);
-        this.showNextReceiveDate=false;
-    },
-    onSubmit(values) {
-      //提交表单
-      console.log("submit", values);
-      
-    },
-    GetVisitTypeList:function(){   //取访问类型
-     var that = this;
+    //获取客户信息
+    GetSaClientInfo: function () {
+      var that = this;
       var data = {
-        projectId: that.$store.state.projectId
+        userCode: that.$store.state.data.userCode,
+        projectId: that.$store.state.projectId,
+        clientId: that.id,
       };
-      console.info("data", data);
-      GetVisitTypeList(data).then((res)=>{
-         console.info("GetVisitTypeList", res);
+      console.info("GetSaClientInfo data", data);
+      GetSaClientInfo(data).then((res) => {
+        console.info("GetSaClientInfo", res);
         if (!res.result) {
           that.$toast(res.msg);
           return;
         }
-        res.data.forEach(function(item,index,array) {
-          that.visitTypeData.push(item);
+        that.phone = res.data.Phone;
+        that.sex=res.data.Sex;
+        if(that.sex==0){
+          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.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.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.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();
+        });
+    },
+     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();
+        });
+    },    
+    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;
+    },
+     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;
+    },
+    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;
+    },
     cancel:function(){
       this.$router.go(-1);
     },
     save:function(){
       let that=this;
       let jsonData={
-        visitType:that.visitType,
-        intention:that.intention,
+        name:that.name,
+        phone:that.phone,
+        sex:that.sex,
         remark:that.remark,
-        planVisitDate:that.planVisitDate,
-        nextReceiveDate:that.nextReceiveDate,
-        visitDate:that.visitDate,
-        visitTime:that.visitTime,
-        actionType:''
+        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
       };
+      console.info('save jsonData',JSON.stringify(jsonData));
       let data={
          userCode:that.$store.state.data.userCode,
          projectId: that.$store.state.projectId,
@@ -337,13 +470,17 @@ export default {
          jsonData:JSON.stringify(jsonData)
       };
       console.info('save',data);
-      AddSaClientContact(data).then((res)=>{
-         console.info('AddSaClientContact',res);
+      //return;
+      ModifySaClient(data).then((res)=>{
+         console.info('ModifySaClient',res);
+         
          that.$dialog.alert({
             message: res.msg,
           }).then(() => {
             // on close
-            that.$router.go(-1);
+            if(res.result){
+              that.$router.go(-1);
+            }
           });
 
       }); 
@@ -417,7 +554,7 @@ export default {
 .bottom{
   /* left:0; */
   bottom: 0px;
-  position: absolute;
+  position: fixed;
   width: 100%;
 }
 .bgGrey{
@@ -434,7 +571,9 @@ export default {
   font-weight: 900;
   padding-top: 5px;
 }
- 
+ .remarkBottom{
+   margin-bottom:40px;
+ }
 </style>