Browse Source

Merge branch 'CD_techPool_324'

hbchen 2 years ago
parent
commit
43e7017bc5
1 changed files with 120 additions and 46 deletions
  1. 120 46
      src/views/financialManagement/contractProgress.vue

+ 120 - 46
src/views/financialManagement/contractProgress.vue

@@ -237,65 +237,75 @@
     waitPlacement:false
     waitPlacement:false
   })
   })
 
 
-  //---------------货币列表
+  //---------------------------货币列表
   const currencyList=ref([])
   const currencyList=ref([])
   const haveGetCurrencyList=ref(false)
   const haveGetCurrencyList=ref(false)
   const rmbRate=ref(1)
   const rmbRate=ref(1)
 
 
-  //所有的销售列表包括ficc和权益
-  let allSellerArray=[]
+  //---------------------------所有的销售列表包括ficc和权益
+  let allSellerArray={}
 
 
   // 销售列表
   // 销售列表
   const sellerArray=ref([])
   const sellerArray=ref([])
   // 选中的销售数组
   // 选中的销售数组
   const cascaderSelectSeller=ref([])
   const cascaderSelectSeller=ref([])
 
 
+  // 标识合规原本的销售是否已离职
+  let isLeave=false
+
   const sellerChange=(value)=>{
   const sellerChange=(value)=>{
-    let ficcSeller,qySeller;
+    let ficcSeller,qySeller
+    let isLeaveSeller=false
     if(value?.length>0){
     if(value?.length>0){
       for (let i = 0; i < value.length; i++) {
       for (let i = 0; i < value.length; i++) {
         const element = value[i];
         const element = value[i];
         if(element[0]==2){
         if(element[0]==2){
           // ficc
           // ficc
           ficcSeller = element[2]
           ficcSeller = element[2]
-        }else{
+        }else if(element[0]==5){
           //权益
           //权益
           qySeller = element[2]
           qySeller = element[2]
+        }else{
+          // 离职的销售
+          isLeaveSeller=true
         }
         }
       }
       }
       // 编辑,不允许修改销售数量
       // 编辑,不允许修改销售数量
       if(contractInfo.form.contract_register_id){
       if(contractInfo.form.contract_register_id){
-        if(!(ficcSeller&&qySeller)){
+        // !(ficcSeller&&qySeller) 
+        if(cascaderSelectSeller.value.length<2 && !isLeaveSeller || !(qySeller||ficcSeller)){
           ElMessage.warning('合规套餐类型已定,不允许修改销售数量')
           ElMessage.warning('合规套餐类型已定,不允许修改销售数量')
           cascaderSelectSeller.value = contractInfo.form.seller_ids.split(',').map(item => +item)
           cascaderSelectSeller.value = contractInfo.form.seller_ids.split(',').map(item => +item)
           return 
           return 
         }
         }
       }
       }
-      console.log(contractInfo.form.seller_ids);
       cascaderSelectSeller.value=[ficcSeller,qySeller]
       cascaderSelectSeller.value=[ficcSeller,qySeller]
       contractInfo.form.seller_ids= cascaderSelectSeller.value.join(',')
       contractInfo.form.seller_ids= cascaderSelectSeller.value.join(',')
-      // 根据销售选择是否显示套餐
-      if(ficcSeller && qySeller){
-        // 都有
-        contractInfo.showServiceFicc=true
-        contractInfo.showServiceQy=true
-        if(!contractInfo.form.contract_register_id){
-          // 新增的情况才置空
-          contractInfo.form.services_amount = contractInfo.form.services_Qy_amount = ''
+      if(!contractInfo.form.contract_register_id){
+        // 新增的时候根据销售选择是否显示套餐
+        if(ficcSeller && qySeller){
+          // 都有
+          contractInfo.showServiceFicc=true
+          contractInfo.showServiceQy=true
+          if(!contractInfo.form.contract_register_id){
+            // 新增的情况才置空
+            contractInfo.form.services_amount = contractInfo.form.services_Qy_amount = ''
+          }
+        }else if(!ficcSeller){
+          // 没有ficc销售
+          contractInfo.showServiceFicc=false
+          contractInfo.showServiceQy=true
+          contractInfo.form.services_Qy_amount = contractInfo.form.contract_amount
+          contractInfo.form.services_amount =''
+        }else{
+          // 没有权益销售
+          contractInfo.showServiceFicc=true
+          contractInfo.showServiceQy=false
+          contractInfo.form.services_amount = contractInfo.form.contract_amount
+          contractInfo.form.services_Qy_amount =''
         }
         }
-      }else if(!ficcSeller){
-        // 没有ficc销售
-        contractInfo.showServiceFicc=false
-        contractInfo.showServiceQy=true
-        contractInfo.form.services_Qy_amount = contractInfo.form.contract_amount
-        contractInfo.form.services_amount =''
-      }else{
-        // 没有权益销售
-        contractInfo.showServiceFicc=true
-        contractInfo.showServiceQy=false
-        contractInfo.form.services_amount = contractInfo.form.contract_amount
-        contractInfo.form.services_Qy_amount =''
       }
       }
+
     }else{
     }else{
       if(contractInfo.form.contract_register_id){
       if(contractInfo.form.contract_register_id){
         ElMessage.warning('合规套餐类型已定,不允许修改销售数量')
         ElMessage.warning('合规套餐类型已定,不允许修改销售数量')
@@ -307,6 +317,48 @@
       cascaderSelectSeller.value=[]
       cascaderSelectSeller.value=[]
     }
     }
   }
   }
+  // 对于销售的处理
+  const sellerOperation=({seller_id,rai_seller_id,seller_ids,seller_name,rai_seller_name})=>{
+    if(seller_id && rai_seller_id){
+        contractInfo.showServiceFicc = contractInfo.showServiceQy=true
+        sellerArray.value = allSellerArray.all_list
+        cascaderSelectSeller.value = seller_ids.split(',').map(item => +item) 
+        if(allSellerArray.ficc_list.findIndex(item => item.seller_id == seller_id)==-1){
+          sellerArray.value.push({
+            seller_id:seller_id,
+            seller_name:seller_name+'-已离职',
+            disabled:true,
+            child:null
+          })
+          isLeave=true
+        }
+        if(allSellerArray.rai_list.findIndex(item => item.seller_id == rai_seller_id)==-1){
+          sellerArray.value.push({
+            seller_id:rai_seller_id,
+            seller_name:rai_seller_name+'-已离职',
+            disabled:true,
+            child:null
+          })
+          isLeave=true
+        }
+      }else if(!seller_id){
+        sellerArray.value=allSellerArray.rai_list
+        if(sellerArray.value.findIndex(item => item.seller_id == rai_seller_id)==-1){
+          // 为-1表示原本的销售已离职
+          contractInfo.form.seller_id = rai_seller_name
+          isLeave=true
+        }
+        contractInfo.showServiceQy=true
+      }else{
+        sellerArray.value=allSellerArray.ficc_list
+        if(sellerArray.value.findIndex(item => item.seller_id == seller_id)==-1){
+          // 为-1表示原本的销售已离职
+          contractInfo.form.seller_id = seller_name
+          isLeave=true
+        }
+        contractInfo.showServiceFicc=true
+      }
+  }
 
 
   let elMessageDom=null
   let elMessageDom=null
 
 
@@ -673,6 +725,11 @@
     contractInfo.form.contract_type=selectItem.contract_type_key
     contractInfo.form.contract_type=selectItem.contract_type_key
     contractInfo.form.relate_contract_code=contractInfo.form.contract_type==3 || contractInfo.form.contract_type==4?selectItem.relate_contract_code:''
     contractInfo.form.relate_contract_code=contractInfo.form.contract_type==3 || contractInfo.form.contract_type==4?selectItem.relate_contract_code:''
     contractInfo.form.actual_company_name=contractInfo.form.contract_type==3?selectItem.actual_company_name:''
     contractInfo.form.actual_company_name=contractInfo.form.contract_type==3?selectItem.actual_company_name:''
+    if(sellerArray.value.findIndex(item => item.seller_id == selectItem.seller_id)==-1){
+      // 为-1表示原本的销售已离职
+      contractInfo.form.seller_id = selectItem.seller_name
+      isLeave=true
+    }
     if(contractInfo.form.contract_type==3){
     if(contractInfo.form.contract_type==3){
       // 代付
       // 代付
       contractInfo.form.has_payment=''
       contractInfo.form.has_payment=''
@@ -717,7 +774,6 @@
 
 
   // 表格添加行
   // 表格添加行
   const addRow=(type,row,index)=>{
   const addRow=(type,row,index)=>{
-    console.log(type,row,index);
     if(!(row.amount && row.invoice_date && row.service_product_id)){
     if(!(row.amount && row.invoice_date && row.service_product_id)){
       ElMessage.error('请填写完整信息')
       ElMessage.error('请填写完整信息')
       return
       return
@@ -781,7 +837,6 @@
       if(tempArr[index].seller_id) haveSalesman=true
       if(tempArr[index].seller_id) haveSalesman=true
       word='开票'
       word='开票'
     }else{
     }else{
-      console.log(row);
       if(row.is_pre_pay==1){
       if(row.is_pre_pay==1){
         // 预到款登记
         // 预到款登记
         ElMessage.error('该笔到款是预到款,不允许删除!')
         ElMessage.error('该笔到款是预到款,不允许删除!')
@@ -898,6 +953,29 @@
     // console.log(contractInfo.checkedService);
     // console.log(contractInfo.checkedService);
     contractInfoForm.value.validate(valid=>{
     contractInfoForm.value.validate(valid=>{
       if(valid){
       if(valid){
+        if(isLeave){
+          // 判断原本销售已离职
+          if(sellerListType.value==3){
+            if(!cascaderSelectSeller.value[0]){
+              ElMessage.error('请选择FICC销售')
+              return 
+            }
+            if(!cascaderSelectSeller.value[1]){
+              ElMessage.error('请选择权益销售')
+              return 
+            }
+            if(allSellerArray.ficc_list.findIndex(item => item.seller_id == cascaderSelectSeller.value[0])==-1||
+            allSellerArray.rai_list.findIndex(item => item.seller_id == cascaderSelectSeller.value[1])==-1){
+              ElMessage.error('选择的销售不存在或已离职')
+              return 
+            }
+          }else{
+            if(!Number(contractInfo.form.seller_id)){
+              ElMessage.error('选择的销售不存在或已离职')
+              return 
+            }
+          }
+        }
         contractInfo.form.services=[]
         contractInfo.form.services=[]
         contractInfo.form.service_amount=[]
         contractInfo.form.service_amount=[]
         // FICC
         // FICC
@@ -963,7 +1041,7 @@
             return 
             return 
           }
           }
           contractInfo.checkedServiceQy.map(serviceId=>{
           contractInfo.checkedServiceQy.map(serviceId=>{
-            console.log(contractInfo.serviceArrayQy);
+            // console.log(contractInfo.serviceArrayQy);
             let serviceItem = contractInfo.serviceArrayQy.find(it=> it.service_template_id==serviceId)
             let serviceItem = contractInfo.serviceArrayQy.find(it=> it.service_template_id==serviceId)
             if(serviceItem)
             if(serviceItem)
             contractInfo.form.services.push({service_template_id:serviceItem.service_template_id,title:serviceItem.title})
             contractInfo.form.services.push({service_template_id:serviceItem.service_template_id,title:serviceItem.title})
@@ -1010,7 +1088,7 @@
         contractInfo.form.contract_amount = +parseFloat(contractInfo.form.contract_amount).toFixed(2)
         contractInfo.form.contract_amount = +parseFloat(contractInfo.form.contract_amount).toFixed(2)
         contractInfo.form.services_amount = +parseFloat(contractInfo.form.services_amount).toFixed(2) || 0
         contractInfo.form.services_amount = +parseFloat(contractInfo.form.services_amount).toFixed(2) || 0
         contractInfo.form.services_Qy_amount = +parseFloat(contractInfo.form.services_Qy_amount).toFixed(2) || 0
         contractInfo.form.services_Qy_amount = +parseFloat(contractInfo.form.services_Qy_amount).toFixed(2) || 0
-        console.log(contractInfo.form.services_amount,contractInfo.form.services_Qy_amount);
+        // console.log(contractInfo.form.services_amount,contractInfo.form.services_Qy_amount);
         let servicesAll = Math.round((contractInfo.form.services_Qy_amount+contractInfo.form.services_amount)*100)/100
         let servicesAll = Math.round((contractInfo.form.services_Qy_amount+contractInfo.form.services_amount)*100)/100
         if(servicesAll!=contractInfo.form.contract_amount){
         if(servicesAll!=contractInfo.form.contract_amount){
           ElMessage.error('套餐总金额不等于合同金额')
           ElMessage.error('套餐总金额不等于合同金额')
@@ -1019,7 +1097,7 @@
         // contractInfo.form.service_amount = [{product_id:1,service_amount:contractInfo.form.services_amount},
         // contractInfo.form.service_amount = [{product_id:1,service_amount:contractInfo.form.services_amount},
         // {product_id:2,service_amount:contractInfo.form.services_Qy_amount}]
         // {product_id:2,service_amount:contractInfo.form.services_Qy_amount}]
         if(!contractInfo.form.has_payment) contractInfo.form.has_payment=0
         if(!contractInfo.form.has_payment) contractInfo.form.has_payment=0
-        console.log(contractInfo.form);
+        // console.log(contractInfo.form);
         // 检验合同名称或者合同有效期是否重复
         // 检验合同名称或者合同有效期是否重复
         if(contractInfo.form.contract_register_id){
         if(contractInfo.form.contract_register_id){
           // 编辑
           // 编辑
@@ -1254,24 +1332,20 @@
         contract_source:res.data.contract_source,
         contract_source:res.data.contract_source,
       }
       }
       // 销售
       // 销售
-      if(res.data.seller_id && res.data.rai_seller_id){
-        contractInfo.showServiceFicc = contractInfo.showServiceQy=true
-        sellerArray.value = allSellerArray.all_list
-        cascaderSelectSeller.value = res.data.seller_ids.split(',').map(item => +item) 
-      }else if(!res.data.seller_id){
-        sellerArray.value=allSellerArray.rai_list
-        contractInfo.showServiceQy=true
+      if(allSellerArray.all_list){
+        // 拿到销售列表后才去做处理
+        sellerOperation(res.data)
       }else{
       }else{
-        sellerArray.value=allSellerArray.ficc_list
-        contractInfo.showServiceFicc=true
+        // 轮询等拿到销售列表后才去做处理,并清除轮询定时器
+        const timer = setInterval(()=>{
+          if(allSellerArray.all_list){
+            sellerOperation(res.data)
+            clearInterval(timer)
+          }
+        },10)
       }
       }
-      // if(res.data.contract_source == 0){
-      //   sellerArray.value = allSellerArray.all_list
-      //   cascaderSelectSeller.value = res.data.seller_ids.split(',').map(item => +item) 
-      // }
 
 
       rmbRate.value=res.data.rmb_rate
       rmbRate.value=res.data.rmb_rate
-      console.log(rmbRate.value,res.data.rmb_rate);
       if(haveGetCurrencyList.value){
       if(haveGetCurrencyList.value){
         // 拿到货币列表后才去取单位
         // 拿到货币列表后才去取单位
         contractInfo.currencyUnit=currencyList.value.find(item => item.code==res.data.currency_unit)?.unit_name
         contractInfo.currencyUnit=currencyList.value.find(item => item.code==res.data.currency_unit)?.unit_name