Browse Source

合规登记代码整理完成

hbchen 2 years ago
parent
commit
fea76b6f3a

+ 1 - 2
src/api/financialMana.js

@@ -12,7 +12,6 @@ export function getSimpleServiceList() {
  })
 }
 
-
  // 获取套餐列表
  /**
   * 
@@ -61,7 +60,7 @@ export function registerListExport(data) {
 }
 
  /**
-  * 合同名称或者合同有效期查询校验
+  * 客户名称或者合同有效期查询校验
   * @param {
  * company_name - 客户名称 - 必填
  * start_date - 开始日期:格式2022-11-22 - 必填

+ 44 - 0
src/utils/common-methods.js

@@ -34,4 +34,48 @@ export function downloadByFlow(data,type,fileName) {
   link.click()
   document.body.removeChild(link) //下载完成移除元素
   window.URL.revokeObjectURL(blob) //释放掉 blob 对象
+}
+
+/**
+ * 定时器轮询数据请求
+ * @param {*} flag 调用callback标志,建议传入返回Boolean值的函数
+ * @param {*} callback 回调函数
+ * @param {*} timeout 轮询间隔
+ */
+export function intervalDataRequest(flag,callback,timeout){
+  if(flag()){
+    // 拿到货币列表后才去取单位
+    callback()
+  }else{
+    // 轮询等拿到货币列表后去取单位,并清除轮询定时器
+    const timer = setInterval(()=>{
+      if(flag()){
+        callback()
+        clearInterval(timer)
+      }
+    },timeout)
+  }
+}
+
+/**
+ * 金额格式化,保留小数
+ * @param {*} money 金额
+ * @param {*} digit 保留几位小数- int
+ * @returns momey-string
+ */
+export const moneyFormatter=(money,digit=2)=>{
+  let digitD = parseInt(digit)
+  let result=money+''
+  if(!digitD && digitD!=0){
+    console.error('参数错误,digit必须为整数');
+    return result
+  }
+  if(result.indexOf('.')==-1){
+    // 没有小数
+    return digitD==0?result:result+'.'+'0'.padEnd(digitD,'0')
+  }else{
+    let digitZeno = Math.round(money)+''
+    let arr = result.split('.')
+    return digitD==0?digitZeno:arr[0]+'.'+arr[1].padEnd(2,'0')
+  }
 }

+ 161 - 197
src/views/financialManagement/contractProgress-component/Compliance.vue

@@ -6,9 +6,10 @@
   import {getContractSearchList,getServiceDetail} from '@/api/crm'
   import {registerAdd,registerEdit,contractRegisterCheck} from '@/api/financialMana'
 
-
   const contractSourceArray=['非CRM合同导入','CRM合同导入']
+  // 合同状态数组
   const contractStatusArray=[{id:1,label:"已审批"},{id:2,label:"单章寄出"},{id:3,label:"已签回"},{id:4,label:"已终止"},{id:5,label:"邮件备案"}]
+  // 合同类型数组
   const contractTypeArray=[{value:0,label:"自付合同",
   children:[{value:1,label:"新签",children:null},{value:2,label:"续约",children:null},{value:4,label:"补充协议",children:null}]},
   {value:1,label:"代付合同",
@@ -20,23 +21,27 @@
       type:String,
       default:'compliance'
     },
-    // 货币列表
+    // 货币数据
     currencyList:{
       type:Array,
       default:()=>[]
     },
+    // 套餐数据
     serviceItem:{
       type:Object,
       default:()=>{}
     },
+    // 销售数据
     sellerData:{
       type:Object,
       default:()=>{}
     },
+    // 预登记数据
     supplementaryInfo:{
       type:Object,
       default:()=>{}
     },
+    // 详情数据
     detailInfo:{
       type:Object,
       default:()=>{}
@@ -45,15 +50,14 @@
 
   const emits=defineEmits(['submitSuccess'])
 
-  const rmbRate=ref(1)
-
+  const contractInfoForm=ref(null)
   // 表单相关
   const compliance=reactive({
     // 合规登记表单
     form:{
       product_ids:'1,2',
       supplement:0, // 是否是补录合同
-      contract_register_id:'',
+      contract_register_id:0,
       crm_contract_id:0,
       contract_source:0,
       contract_code:'',
@@ -104,18 +108,18 @@
     },
     // 有效期
     contractValidityDate:[],
+    // 合同类型选中
+    contractTypeCheck:[]
+  })
 
-    // --------------套餐信息
+  // --------------套餐信息
+  const serviceData=reactive({
     showServiceFicc:false,
     showServiceQy:false,
     // 选中的套餐 - ficc
     checkedService:[],
     // 选中的套餐 - 权益
     checkedServiceQy:[],
-    // 套餐列表
-    serviceArray:[],
-    // 套餐列表 - 权益
-    serviceArrayQy:[],
     // 小套餐选中的品种
     checkedPermission:[],
     // 权益大套餐选中的品种
@@ -129,8 +133,6 @@
     serviceType:0,
     // 权益套餐 1、权益大套餐 2、行业套餐
     serviceTypeQy:0,
-    // 合同类型选中
-    contractTypeCheck:[],
     // 品种选择 - Ficc
     varietyDiaShow:false,
     //品种选择 - Qy
@@ -142,6 +144,15 @@
     serviceShow:false,
   })
 
+  // 销售列表类型1-单Ficc 2-单权益 3-ficc和权益
+  const sellerListType=ref(3)
+  // 选中的销售数组
+  const cascaderSelectSeller=ref([])
+  // 查看套餐报价单 图片
+  const previewImage=ref('')
+  // 查看套餐报价单 标题
+  const previewImageTitle=ref('')
+
   // 合同编号列表请求参数
   const contractNoQuery=reactive({
     page_size:20,
@@ -154,65 +165,49 @@
     contractNoArray:[]
   })
 
-  // 合同编号--列表
-
-  // 销售列表
-  const contractInfoForm=ref(null)
-  // 销售列表类型1-单Ficc 2-单权益 3-ficc和权益
-  const sellerListType=ref(3)
-  // 选中的销售数组
-  const cascaderSelectSeller=ref([])
-
-  // 查看套餐报价单 图片
-  const previewImage=ref('')
-  // 查看套餐报价单 标题
-  const previewImageTitle=ref('')
-
+  // --------------------------------------方法
   // 合同来源改变
   const contractSourceChange=(value)=>{
     // 切换来源,清空数据
-    compliance.form={...compliance.form,
-      product_ids:value==0?'1,2':'',
-      crm_contract_id:0,
-      contract_code:'',
-      company_name:'',
-      currency_unit:'CNY',
-      new_company:0,
-      seller_ids:'',
-      seller_id:'',
-      contract_status:'',
-      start_date:'',
-      end_date:'',
-      contract_amount:'',
-      contract_type:'',
-      has_payment:'',
-      actual_pay_companies:'',
-      relate_contract_code:'',
-      relate_contract_main_code:'',
-      sign_date:'',
-      agreed_pay_time:'',
-      services:[],
-      services_amount:'',
-      services_Qy_amount:'',
-      service_remark:'',
-      remark:""
-    }
+    compliance.form.product_ids=value==0?'1,2':'',
+    compliance.form.crm_contract_id=0,
+    compliance.form.contract_code='',
+    compliance.form.company_name='',
+    compliance.form.currency_unit='CNY',
+    compliance.form.new_company=0,
+    compliance.form.seller_ids='',
+    compliance.form.seller_id='',
+    compliance.form.contract_status='',
+    compliance.form.start_date='',
+    compliance.form.end_date='',
+    compliance.form.contract_amount='',
+    compliance.form.contract_type='',
+    compliance.form.has_payment='',
+    compliance.form.actual_pay_companies='',
+    compliance.form.relate_contract_code='',
+    compliance.form.relate_contract_main_code='',
+    compliance.form.sign_date='',
+    compliance.form.agreed_pay_time='',
+    compliance.form.services=[],
+    compliance.form.services_amount='',
+    compliance.form.services_Qy_amount='',
+    compliance.form.service_remark='',
+    compliance.form.remark=""
     
-    compliance.checkedService=[]
-    compliance.checkedServiceQy=[]
-
-    compliance.checkedPermission=[]
-    compliance.checkedPermissionQyBig=[]
-    compliance.checkedPermissionQySmall=[]
+    serviceData.checkedService=[]
+    serviceData.checkedServiceQy=[]
+    serviceData.checkedPermission=[]
+    serviceData.checkedPermissionQyBig=[]
+    serviceData.checkedPermissionQySmall=[]
     sellerListType.value = value==0?3:''
-    compliance.contractTypeCheck=[]
     // 1-大套餐  2-小套餐
-    compliance.serviceType=0
-    compliance.serviceTypeQy=0
+    serviceData.serviceType=0
+    serviceData.serviceTypeQy=0
     // 品种选择 - Ficc
-    compliance.serviceVarietyShow=false
+    serviceData.serviceVarietyShow=false
     // 品种选择 - Qy
-    compliance.serviceVarietyShowQy=false
+    serviceData.serviceVarietyShowQy=false
+    compliance.contractTypeCheck=[]
     compliance.contractValidityDate=[]
     setTimeout(()=>{
       // 去除错误信息
@@ -222,14 +217,13 @@
 
 // ------------------------------------------------监听
   watch(()=>compliance.form.contract_amount,(newVal)=>{
-    if(compliance.showServiceFicc && compliance.showServiceQy){
+    if(serviceData.showServiceFicc && serviceData.showServiceQy){
       return 
-    }else if(!compliance.showServiceFicc){
+    }else if(!serviceData.showServiceFicc){
       compliance.form.services_Qy_amount = newVal
     }else{
       compliance.form.services_amount = newVal
     }
-    
   })
 
   watch(()=>props.supplementaryInfo.supplement,(value)=>{
@@ -237,9 +231,9 @@
       setSupplementaryData()
     }
   }) 
+
   watch(()=>props.detailInfo.contract_register_id,(value)=>{
     if(value){
-      console.log(props.detailInfo);
       setComplianceDetail()
     }
   }) 
@@ -248,7 +242,6 @@
 
   // 合同类型改变
   const contractTypeChange=(value)=>{
-    // console.log(value);
     if(!value) return 
     compliance.form.has_payment = value[0]
     compliance.form.contract_type = value[1]
@@ -276,10 +269,10 @@
         const element = value[i];
         if(element[0]==2){
           // ficc
-          ficcSeller = element[2]
+          ficcSeller = element[element.length-1]
         }else{
           //权益
-          qySeller = element[2]
+          qySeller = element[element.length-1]
         }
       }
       // 编辑,不允许修改销售数量
@@ -290,38 +283,38 @@
           return 
         }
       }
-      console.log(compliance.form.seller_ids);
       cascaderSelectSeller.value=[ficcSeller,qySeller]
       compliance.form.seller_ids= cascaderSelectSeller.value.join(',')
       // 根据销售选择是否显示套餐
       if(ficcSeller && qySeller){
         // 都有
-        compliance.showServiceFicc=true
-        compliance.showServiceQy=true
+        serviceData.showServiceFicc=true
+        serviceData.showServiceQy=true
         if(!compliance.form.contract_register_id){
           // 新增的情况才置空
           compliance.form.services_amount = compliance.form.services_Qy_amount = ''
         }
       }else if(!ficcSeller){
         // 没有ficc销售
-        compliance.showServiceFicc=false
-        compliance.showServiceQy=true
+        serviceData.showServiceFicc=false
+        serviceData.showServiceQy=true
         compliance.form.services_Qy_amount = compliance.form.contract_amount
         compliance.form.services_amount =''
       }else{
         // 没有权益销售
-        compliance.showServiceFicc=true
-        compliance.showServiceQy=false
+        serviceData.showServiceFicc=true
+        serviceData.showServiceQy=false
         compliance.form.services_amount = compliance.form.contract_amount
         compliance.form.services_Qy_amount =''
       }
     }else{
       if(compliance.form.contract_register_id){
+        // 编辑的情况下
         ElMessage.warning('合规套餐类型已定,不允许修改销售数量')
         cascaderSelectSeller.value = compliance.form.seller_ids.split(',').map(item => +item)
         return 
       }
-      compliance.showServiceFicc = compliance.showServiceQy=true
+      serviceData.showServiceFicc = serviceData.showServiceQy=true
       compliance.form.services_amount = compliance.form.services_Qy_amount = ''
       cascaderSelectSeller.value=[]
     }
@@ -329,10 +322,8 @@
   // 合同编号选中
   const selectContractNo=(value)=>{
     let selectItem=contractNoInfo.contractNoArray.find(item=>item.contract_code == value)
-    // console.log(selectItem);
     // 获取套餐详情
     getServiceDetail({contract_id:selectItem.contract_id}).then(res=>{
-      // console.log(res);
       let servivesTemp = res.data?res.data.Service||[]:[]
       if(selectItem.product_id==1){
         // FICC套餐
@@ -340,10 +331,10 @@
         let smallService = servivesTemp.find(item => item.ServiceTemplateId==2)
         // 是否有大套餐
         let hasBigService = servivesTemp.some(item => item.ServiceTemplateId==1)
-        compliance.serviceVarietyShow=!!smallService
-        compliance.serviceType = !!smallService?2:hasBigService?1:0
-        compliance.checkedService=servivesTemp.map(item => item.ServiceTemplateId)
-        compliance.checkedPermission=smallService?smallService.ChartPermissionIds||[]:[]
+        serviceData.serviceVarietyShow=!!smallService
+        serviceData.serviceType = !!smallService?2:hasBigService?1:0
+        serviceData.checkedService=servivesTemp.map(item => item.ServiceTemplateId)
+        serviceData.checkedPermission=smallService?smallService.ChartPermissionIds||[]:[]
         compliance.form.services_Qy_amount = ''
       }else{
         //权益
@@ -352,27 +343,26 @@
         // 行业套餐
         let smallServiceQY = servivesTemp.filter(item => [14,15,16,17,18].includes(item.FMSServiceTemplatePId))
 
-        compliance.serviceVarietyShowQy = (!!bigServiceQY) || (!!smallServiceQY)
-        compliance.serviceTypeQy = compliance.qYDiaType =  !!bigServiceQY?1:!!smallServiceQY?2:0
-        compliance.checkedServiceQy=[!!bigServiceQY?10:13]
+        serviceData.serviceVarietyShowQy = (!!bigServiceQY) || (!!smallServiceQY)
+        serviceData.serviceTypeQy = serviceData.qYDiaType =  !!bigServiceQY?1:!!smallServiceQY?2:0
+        serviceData.checkedServiceQy=[!!bigServiceQY?10:13]
         if(!!bigServiceQY){
           //权益大套餐
-          compliance.checkedPermissionQyBig = [bigServiceQY.FMSServiceTemplateId]
-          compliance.checkedPermissionQySmall = []
+          serviceData.checkedPermissionQyBig = [bigServiceQY.FMSServiceTemplateId]
+          serviceData.checkedPermissionQySmall = []
         }else{
           //行业套餐
-          compliance.checkedPermissionQyBig = []
-          compliance.checkedPermissionQySmall = smallServiceQY.map(item => item.FMSServiceTemplateId)
+          serviceData.checkedPermissionQyBig = []
+          serviceData.checkedPermissionQySmall = smallServiceQY.map(item => item.FMSServiceTemplateId)
         }
         compliance.form.services_amount = ''
       }
-      compliance.varietyDiaType='edit'
+      serviceData.varietyDiaType='edit'
 
     })
 
     compliance.form.product_ids = selectItem.product_id.toString()
     sellerListType.value = selectItem.product_id
-    // console.log(compliance.form);
     compliance.form.company_name=selectItem.company_name
     compliance.form.crm_contract_id=selectItem.contract_id
     compliance.form.start_date=selectItem.start_date
@@ -395,37 +385,36 @@
       'start_date','contract_amount','relate_contract_code','actual_pay_companies'
     ])
   
-    compliance.showServiceFicc = selectItem.product_id == 1
-    compliance.showServiceQy = selectItem.product_id == 2
+    serviceData.showServiceFicc = selectItem.product_id == 1
+    serviceData.showServiceQy = selectItem.product_id == 2
 
   }
 
   // 合规登记-提交
   const complianceSubmit=()=>{
-    // console.log(compliance.checkedService);
     contractInfoForm.value.validate(valid=>{
       if(valid){
         compliance.form.services=[]
         compliance.form.service_amount=[]
         // FICC
-        if(compliance.showServiceFicc){
-          if(compliance.checkedService.length==0){
+        if(serviceData.showServiceFicc){
+          if(serviceData.checkedService.length==0){
             ElMessage.warning('请选择FICC套餐')
             return 
           }
-          if((!compliance.checkedPermission || compliance.checkedPermission.length==0) 
-          && compliance.checkedService.some(serviceId =>serviceId==2)){
+          if((!serviceData.checkedPermission || serviceData.checkedPermission.length==0) 
+          && serviceData.checkedService.some(serviceId =>serviceId==2)){
             ElMessage.warning('请保存FICC小套餐品种')
             return 
           }
-          compliance.checkedService.map(serviceId=>{
+          serviceData.checkedService.map(serviceId=>{
             let serviceSelectItem = props.serviceItem.serviceArray.find(it=> it.service_template_id==serviceId) || {}
             // 小套餐
             if(serviceId==2){
               compliance.form.services.push({
                 service_template_id:serviceSelectItem.service_template_id,
                 value:'',
-                chart_permission_ids:compliance.checkedPermission?compliance.checkedPermission.join(','):'',
+                chart_permission_ids:serviceData.checkedPermission?serviceData.checkedPermission.join(','):'',
                 chart_permission_id:serviceSelectItem.chart_permission_id,
                 title:serviceSelectItem.title
               })
@@ -451,38 +440,40 @@
         }
         
         // 权益
-        if(compliance.showServiceQy){
-          if(compliance.checkedServiceQy.length==0){
+        if(serviceData.showServiceQy){
+          if(serviceData.checkedServiceQy.length==0){
             ElMessage.warning('请选择权益套餐')
             return 
           }
           // 权益大套餐
-          if((!compliance.checkedPermissionQyBig || compliance.checkedPermissionQyBig.length==0) 
-          && compliance.checkedServiceQy.some(serviceId =>serviceId==10)){
+          if((!serviceData.checkedPermissionQyBig || serviceData.checkedPermissionQyBig.length==0) 
+          && serviceData.checkedServiceQy.some(serviceId =>serviceId==10)){
             ElMessage.warning('请保存权益大套餐类型')
             return 
           }
 
           // 行业套餐
-          if((!compliance.checkedPermissionQySmall || compliance.checkedPermissionQySmall.length==0) 
-          && compliance.checkedServiceQy.some(serviceId =>serviceId==13)){
+          if((!serviceData.checkedPermissionQySmall || serviceData.checkedPermissionQySmall.length==0) 
+          && serviceData.checkedServiceQy.some(serviceId =>serviceId==13)){
             ElMessage.warning('请保存行业套餐品种')
             return 
           }
-          compliance.checkedServiceQy.map(serviceId=>{
+          serviceData.checkedServiceQy.map(serviceId=>{
             let serviceSelectItem = props.serviceItem.serviceArrayQy.find(it=> it.service_template_id==serviceId)
             if(serviceSelectItem)
             compliance.form.services.push({service_template_id:serviceSelectItem.service_template_id,title:serviceSelectItem.title})
             // 权益大套餐
             if(serviceId==10){
-              let subServiceItem = serviceSelectItem.children.find(it=> it.service_template_id==compliance.checkedPermissionQyBig[0])
+              let subServiceItem = serviceSelectItem.children.find(it=> it.service_template_id==serviceData.checkedPermissionQyBig[0])
               compliance.form.services.push({service_template_id:subServiceItem.service_template_id,title:subServiceItem.title})
             }else if(serviceId==13){
-              // 行业套餐
+              // 行业套餐 - 每一层都要push
+              // 是否有子层被选中
               const hasSubList=[0,0,0,0,0]
-              compliance.checkedPermissionQySmall.map(serviceTemplateId=>{
+              serviceData.checkedPermissionQySmall.map(serviceTemplateId=>{
                 for (let i = 0; i < serviceSelectItem.children.length; i++) {
                   const element = serviceSelectItem.children[i];
+                  // 最后一层 - 主客观
                   let subItem=element.children.find(it =>it.service_template_id == serviceTemplateId)
                   if(subItem){
                     compliance.form.services.push({service_template_id:subItem.service_template_id,title:subItem.title})
@@ -491,16 +482,15 @@
                   }
                 }
               })
-              hasSubList.map(serviceTemplateId =>{
+              // 中间层 - 医药、消费、科技、智造、策略
+              hasSubList.map((serviceTemplateId,ind) =>{
                 if(serviceTemplateId){
-                  let tempItem = serviceSelectItem.children.find(it => it.service_template_id==serviceTemplateId)
+                  let tempItem = serviceSelectItem.children[ind]
                   compliance.form.services.push({service_template_id:tempItem.service_template_id,title:tempItem.title})
                 }
               })
-              
             }
           })
-          // console.log(compliance.form.services);
           // 套餐金额
           if(!compliance.form.services_Qy_amount){
             ElMessage.error('请填写权益套餐金额')
@@ -516,19 +506,16 @@
         compliance.form.contract_amount = +parseFloat(compliance.form.contract_amount).toFixed(2)
         compliance.form.services_amount = +parseFloat(compliance.form.services_amount).toFixed(2) || 0
         compliance.form.services_Qy_amount = +parseFloat(compliance.form.services_Qy_amount).toFixed(2) || 0
-        console.log(compliance.form.services_amount,compliance.form.services_Qy_amount);
         let servicesAll = Math.round((compliance.form.services_Qy_amount+compliance.form.services_amount)*100)/100
         if(servicesAll!=compliance.form.contract_amount){
           ElMessage.error('套餐总金额不等于合同金额')
           return 
         }
-        // compliance.form.service_amount = [{product_id:1,service_amount:compliance.form.services_amount},
-        // {product_id:2,service_amount:compliance.form.services_Qy_amount}]
+
         if(!compliance.form.has_payment){
           compliance.form.has_payment=0
           compliance.form.actual_pay_companies=''
         }
-        console.log(compliance.form);
         // 检验合同名称或者合同有效期是否重复
         if(compliance.form.contract_register_id){
           // 编辑
@@ -585,22 +572,22 @@
   const viewService=(serviceTemplateId)=>{
     if(!canServiceShow(serviceTemplateId)) return 
     if(serviceTemplateId==2){
-      compliance.varietyDiaShow=true
-      compliance.varietyDiaType='view'
+      serviceData.varietyDiaShow=true
+      serviceData.varietyDiaType='view'
       return 
     }
     let viewItem=compliance.form.services.find(item => item.service_template_id == serviceTemplateId)
     previewImageTitle.value = viewItem.title
     previewImage.value=viewItem.value
-    compliance.serviceShow=true
+    serviceData.serviceShow=true
   }
 
   // 查看套餐 - 权益
   const viewServiceQy=(serviceTemplateId,diaType)=>{
     if(!canServiceShow(serviceTemplateId)) return 
-    compliance.varietyDiaShowQy=true
-    compliance.qYDiaType = diaType
-    compliance.varietyDiaType='view'
+    serviceData.varietyDiaShowQy=true
+    serviceData.qYDiaType = diaType
+    serviceData.varietyDiaType='view'
   }
   // 合同编号远程搜索
   const contractNoSearch=(value)=>{
@@ -609,7 +596,6 @@
     contractNoQuery.current=1
     contractNoInfo.contractNoArray=[]
     getContractSearchListFun()
-    // console.log(value);
   }
   const loadContractNoMore=()=>{
     if(contractNoInfo.contractNoArray.length >=contractNoInfo.contractNoTotal) return 
@@ -632,26 +618,25 @@
     compliance.form.seller_ids=value+''
   }
 
-    // 选择品种 - ficc
-    const selectVariety=()=>{
-    compliance.varietyDiaType='edit'
-    compliance.varietyDiaShow=true
+  // 选择品种 - ficc
+  const selectVariety=()=>{
+    serviceData.varietyDiaType='edit'
+    serviceData.varietyDiaShow=true
   }
   // 选择品种 - 权益
   const selectVarietyQy=(diaType)=>{
-    compliance.varietyDiaType='edit'
-    compliance.varietyDiaShowQy=true
-    compliance.qYDiaType = diaType
+    serviceData.varietyDiaType='edit'
+    serviceData.varietyDiaShowQy=true
+    serviceData.qYDiaType = diaType
   }
 
   const getPermissionChecked=(list)=>{
-    compliance.checkedPermission=list
+    serviceData.checkedPermission=list
   }
 
   const getPermissionQYChecked=(list)=>{
-    console.log(list,'list');
-    if(compliance.qYDiaType==1) compliance.checkedPermissionQyBig=list
-    else if(compliance.qYDiaType==2) compliance.checkedPermissionQySmall=list
+    if(serviceData.qYDiaType==1) serviceData.checkedPermissionQyBig=list
+    else if(serviceData.qYDiaType==2) serviceData.checkedPermissionQySmall=list
   }
 
     // 有效期变更触发函数
@@ -667,24 +652,18 @@
 
   // 服务改变
   const serciveChange=(value,type,serviceType='ficc',openDia=true)=>{
-    // console.log(value,type,serviceType);
     if(serviceType=='ficc'){
-      // ficc套餐修改
       if(type==2){
-        compliance.serviceVarietyShow=value
-        compliance.varietyDiaType='edit'
-        compliance.varietyDiaShow=openDia&&value
+        serviceData.serviceVarietyShow=value
+        serviceData.varietyDiaType='edit'
+        serviceData.varietyDiaShow=openDia&&value
       }
-      compliance.serviceType = value?type:0
+      serviceData.serviceType = value?type:0
     }else{
-      // 权益套餐修改
-      // if(type==2){
-        compliance.serviceVarietyShowQy=value
-        compliance.varietyDiaType='edit'
-        compliance.varietyDiaShowQy=openDia&&value
-      // }
-      compliance.serviceTypeQy = compliance.qYDiaType =  value?type:0
-      // console.log(compliance.qYDiaType);
+      serviceData.serviceVarietyShowQy=value
+      serviceData.varietyDiaType='edit'
+      serviceData.varietyDiaShowQy=openDia&&value
+      serviceData.serviceTypeQy = serviceData.qYDiaType =  value?type:0
     }
   }
 
@@ -708,7 +687,7 @@
     compliance.form.currency_unit=props.detailInfo.currency_unit
     compliance.form.new_company=props.detailInfo.new_company
     compliance.form.seller_ids=props.detailInfo.seller_ids
-    compliance.form.seller_id=props.detailInfo.seller_id || props.detailInfo.rai_seller_id
+    compliance.form.seller_id=props.detailInfo.seller_id
     compliance.form.contract_status=props.detailInfo.contract_status
     compliance.form.start_date=props.detailInfo.start_date
     compliance.form.end_date=props.detailInfo.end_date
@@ -728,29 +707,14 @@
     // 合同类型回显
     compliance.contractTypeCheck = [compliance.form.has_payment,compliance.form.contract_type]
     // 销售&套餐显示
-    if(props.detailInfo.seller_id && props.detailInfo.rai_seller_id){
-      compliance.showServiceFicc = compliance.showServiceQy=true
+    sellerListType.value=props.detailInfo.sellerListType
+    if(sellerListType.value == 3){
+      serviceData.showServiceFicc = serviceData.showServiceQy=true
       cascaderSelectSeller.value = compliance.form.seller_ids.split(',').map(item => +item) 
-      sellerListType.value = 3
-    }else if(!props.detailInfo.seller_id){
-      sellerListType.value = 2
-      compliance.showServiceQy=true
+    }else if(sellerListType.value == 2){
+      serviceData.showServiceQy=true
     }else{
-      sellerListType.value = 1
-      compliance.showServiceFicc=true
-    }
-    rmbRate.value=props.detailInfo.rmb_rate
-    if(props.currencyList.length>0){
-      // 拿到货币列表后才去取单位
-      compliance.currencyUnit=props.currencyList.find(item => item.code==props.detailInfo.currency_unit)?.unit_name
-    }else{
-      // 轮询等拿到货币列表后去取单位,并清除轮询定时器
-      const timer = setInterval(()=>{
-        if(props.currencyList.length>0){
-          compliance.currencyUnit=props.currencyList.find(item => item.code==props.detailInfo.currency_unit)?.unit_name
-          clearInterval(timer)
-        }
-      },10)
+      serviceData.showServiceFicc=true
     }
     // 套餐金额
     compliance.form.services_amount = props.detailInfo.service_amount_list.find(it => it.product_id==1)?
@@ -759,7 +723,7 @@
     props.detailInfo.service_amount_list.find(it => it.product_id==2).service_amount:0
     serviceDataHandle(props.detailInfo.services)
   }
-
+  // 回显套餐数据
   const serviceDataHandle=(services)=>{
     services.map(item =>{
       if(item.service_template_id==2){
@@ -771,20 +735,20 @@
           chart_permission_id:item.chart_permission_id,
           title:item.title
         })
-        compliance.checkedPermission=item.chart_permission_ids.split(',')
+        serviceData.checkedPermission=item.chart_permission_ids.split(',')
       }else if(item.service_template_id==11 || item.service_template_id==12){
         // 权益大套餐
-        compliance.checkedPermissionQyBig = [item.service_template_id]
+        serviceData.checkedPermissionQyBig = [item.service_template_id]
         compliance.form.services.push(item)
       }else if([19,20,21,22,23,24,25,26,27].includes(item.service_template_id)){
         // 行业套餐
-        compliance.checkedPermissionQySmall.push(item.service_template_id)
+        serviceData.checkedPermissionQySmall.push(item.service_template_id)
         compliance.form.services.push(item)
       }else{
         compliance.form.services.push(item)
       }
     })
-    compliance.checkedService=services.map(item => {
+    serviceData.checkedService=services.map(item => {
       if(item.product_id==1){
         let serviceId=item.service_template_id
         // 大套餐或者小套餐
@@ -792,7 +756,7 @@
         return serviceId
       }
     }).filter(Boolean)
-    compliance.checkedServiceQy=services.map(item => {
+    serviceData.checkedServiceQy=services.map(item => {
       if(item.product_id==2){
         let serviceId=item.service_template_id
         // 权益大套餐或者行业套餐
@@ -912,18 +876,18 @@
       </div>
       <div class="info-row">
         <div class="info-row-title" >套餐信息</div>
-        <div class="info-row-services" v-if="compliance.showServiceFicc">
+        <div class="info-row-services" v-if="serviceData.showServiceFicc">
           <div class="info-row-services-header" id="info-row-services-header">
             <span>FICC套餐</span>
             <el-input v-model="compliance.form.services_amount" :disabled="operationtype!='compliance'"
             placeholder="请输入套餐金额" style="width: 200px;" />
           </div>
             <el-checkbox-group :disabled="operationtype!='compliance'"
-          v-model="compliance.checkedService" class="info-service-box" id="service-information">
+          v-model="serviceData.checkedService" class="info-service-box" id="service-information">
             <!-- 大套餐 -->
             <el-checkbox :label="serviceItem.serviceArray[0]?.service_template_id" @change="(e) => serciveChange(e,1)" 
               :class="{'viewService':canServiceShow(serviceItem.serviceArray[0]?.service_template_id)}"
-            :disabled="compliance.serviceType==2" @click="viewService(serviceItem.serviceArray[0]?.service_template_id)">
+            :disabled="serviceData.serviceType==2" @click="viewService(serviceItem.serviceArray[0]?.service_template_id)">
               {{serviceItem.serviceArray[0]?.title}}
             </el-checkbox>
             <!-- 小套餐 -->
@@ -931,10 +895,10 @@
               <el-checkbox :label="serviceItem.serviceArray[1]?.service_template_id" style="margin-right: 0;"
               @change="(e) => serciveChange(e,2)" 
                 :class="{'viewService':canServiceShow(serviceItem.serviceArray[1]?.service_template_id)}"
-                :disabled="compliance.serviceType==1" @click="viewService(serviceItem.serviceArray[1]?.service_template_id)">
+                :disabled="serviceData.serviceType==1" @click="viewService(serviceItem.serviceArray[1]?.service_template_id)">
                 {{serviceItem.serviceArray[1]?.title}}
               </el-checkbox>
-              <span v-if="(compliance.serviceVarietyShow&&operationtype=='compliance')" 
+              <span v-if="(serviceData.serviceVarietyShow&&operationtype=='compliance')" 
               @click="selectVariety" class="select-variety">选择品种</span>
             </div>
             <!-- 市场策略 -->
@@ -949,24 +913,24 @@
             </el-checkbox>
           </el-checkbox-group>
         </div>
-        <div class="info-row-services" v-if="compliance.showServiceQy">
+        <div class="info-row-services" v-if="serviceData.showServiceQy">
           <div class="info-row-services-header" id="info-row-services-header">
             <span>权益套餐</span>
             <el-input v-model="compliance.form.services_Qy_amount" :disabled="operationtype!='compliance'"
             placeholder="请输入套餐金额" style="width: 200px;" />
           </div>
             <el-checkbox-group :disabled="operationtype!='compliance'"
-          v-model="compliance.checkedServiceQy" class="info-service-box" id="service-information">
+          v-model="serviceData.checkedServiceQy" class="info-service-box" id="service-information">
             <!-- 权益大套餐、行业套餐 -->
             <div class="service-small" v-for="(item,index) in [1,2]" :key="item">
               <el-checkbox :label="serviceItem.serviceArrayQy[index]?.service_template_id" style="margin-right: 0;"
               @change="(e) => serciveChange(e,item,'qy')" 
                 :class="{'viewService':canServiceShow(serviceItem.serviceArrayQy[index]?.service_template_id)}"
-                :disabled="compliance.serviceTypeQy!=0 && compliance.serviceTypeQy != item" 
+                :disabled="serviceData.serviceTypeQy!=0 && serviceData.serviceTypeQy != item" 
                 @click="viewServiceQy(serviceItem.serviceArrayQy[index]?.service_template_id,item)">
                 {{serviceItem.serviceArrayQy[index]?.title}}
               </el-checkbox>
-              <span v-if="(compliance.serviceVarietyShowQy&&compliance.qYDiaType==item&&operationtype=='compliance')" 
+              <span v-if="(serviceData.serviceVarietyShowQy&&serviceData.qYDiaType==item&&operationtype=='compliance')" 
               @click="selectVarietyQy(item)" class="select-variety">选择品种</span>
             </div>
             <!-- 非行业套餐 -->
@@ -992,22 +956,22 @@
         </div>
       </div>
       <!-- 小套餐选择品种弹窗 -->
-      <permission-dia v-model:visible="compliance.varietyDiaShow" :type="compliance.varietyDiaType"
-      @selectFinish="getPermissionChecked" :hasCheckedPermission="compliance.checkedPermission"></permission-dia>
+      <permission-dia v-model:visible="serviceData.varietyDiaShow" :type="serviceData.varietyDiaType"
+      @selectFinish="getPermissionChecked" :hasCheckedPermission="serviceData.checkedPermission"></permission-dia>
       <!-- 权益大套餐、行业套餐选择品种弹窗 -->
-      <permission-qy-dia v-model:visible="compliance.varietyDiaShowQy" :type="compliance.varietyDiaType" 
-      @selectFinish="getPermissionQYChecked" :serviceType="compliance.qYDiaType"
-      :permissionData="compliance.qYDiaType==1?serviceItem.serviceArrayQy[0]?.children:serviceItem.serviceArrayQy[1]?.children"
-      :hasCheckedPermission="compliance.qYDiaType==1?compliance.checkedPermissionQyBig:compliance.checkedPermissionQySmall"></permission-qy-dia>
+      <permission-qy-dia v-model:visible="serviceData.varietyDiaShowQy" :type="serviceData.varietyDiaType" 
+      @selectFinish="getPermissionQYChecked" :serviceType="serviceData.qYDiaType"
+      :permissionData="serviceData.qYDiaType==1?serviceItem.serviceArrayQy[0]?.children:serviceItem.serviceArrayQy[1]?.children"
+      :hasCheckedPermission="serviceData.qYDiaType==1?serviceData.checkedPermissionQyBig:serviceData.checkedPermissionQySmall"></permission-qy-dia>
       <!-- 查看套餐弹窗 -->
-      <el-dialog v-model="compliance.serviceShow" style="min-width: 800px;" title="" width="70vw" top="5vh">
+      <el-dialog v-model="serviceData.serviceShow" style="min-width: 800px;" title="" width="70vw" top="5vh">
         <template #header>
           <div style="text-align: center;">{{previewImageTitle}}</div>
         </template>
         <img style="width: 100%; display: block; margin: 0 auto 20px auto" 
         :src="previewImage" />
         <div style="text-align: center; margin: 30px 0 10px">
-          <el-button type="primary" @click="compliance.serviceShow=false">知道了</el-button>
+          <el-button type="primary" @click="serviceData.serviceShow=false">知道了</el-button>
         </div>
       </el-dialog>
     </div>

+ 278 - 286
src/views/financialManagement/contractProgress-component/InvoiceAndPayment.vue

@@ -1,183 +1,176 @@
 <script setup>
   import '../style/contractRegistration.scss'
+  import {ElMessage} from 'element-plus'
   import {registerInvoice,registerPayment} from '@/api/financialMana'
-  // 开票记录表单
-  const invoiceFormRef=ref(null)
-  // 到款记录表单
-  const placementFormRef=ref(null)
+  import {intervalDataRequest} from '@/utils/common-methods'
+  import {moneyFormatter} from '@/utils/common-methods'
+
+  const props=defineProps({
+    // 权限类型
+    operationtype:{
+      type:String,
+      default:'compliance'
+    },
+    // 货币数据
+    currencyList:{
+      type:Array,
+      default:()=>[]
+    },
+    // 类型 '开票' '到款 '
+    type:{
+      type:String,
+      default:'开票'
+    },
+    // 销售数据
+    sellerData:{
+      type:Object,
+      default:()=>{}
+    },
+    // 详情数据
+    IPDetailInfo:{
+      type:Object,
+      default:()=>{}
+    }
+  })
+  const emits=defineEmits(['submitSuccess'])
+
+  // 开票/到款记录表单
+  const iandPFormRef=ref(null)
   // 货币单位
   const IandP=reactive({
     currencyUnit:'',
     moneyData:{
-      // 开票金额
-      haveInvoiceMoney:0,
-      waitInvoiceMoney:0,
-      allInvoiceMoney:'',
-      // 到款金额
-      havePlacementMoney:0,
-      waitPlacementMoney:0,
-      allPlacementMoney:0,
-      // FICC开票金额
-      haveInvoiceMoneyFICC:0,
-      waitInvoiceMoneyFICC:0,
-      allInvoiceMoneyFICC:0,
-      // FICC到款金额
-      havePlacementMoneyFICC:0,
-      waitPlacementMoneyFICC:0,
-      allPlacementMoneyFICC:0, 
-      // 权益开票金额
-      haveInvoiceMoneyQY:0,
-      waitInvoiceMoneyQY:0,
-      allInvoiceMoneyQY:0,
-      // 权益到款金额
-      havePlacementMoneyQY:0,
-      waitPlacementMoneyQY:0,
-      allPlacementMoneyQY:0,
-    },
-    // 开票时 FICC的销售列表
-    sellerInvoiceListF:[],
-    // 开票时 权益的销售列表
-    sellerInvoiceListQ:[]
+      // 金额
+      haveMoney:0,
+      waitMoney:0,
+      // FICC金额
+      haveMoneyFICC:0,
+      waitMoneyFICC:0,
+      allMoneyFICC:0,
+      // 权益金额
+      haveMoneyQY:0,
+      waitMoneyQY:0,
+      allMoneyQY:0,
+    }
   })
-  
-  // -----------------------------监听
-  // 已开票金额-FICC
-  watch(()=> contractInfo.moneyData.haveInvoiceMoneyFICC ,(newValue)=>{
-    contractInfo.moneyData.waitInvoiceMoneyFICC = contractInfo.moneyData.allInvoiceMoneyFICC-newValue
-    contractInfo.moneyData.waitInvoiceMoneyFICC=Math.round(contractInfo.moneyData.waitInvoiceMoneyFICC*100)/100
-    contractInfo.moneyData.waitInvoiceMoney = 
-    Math.round((contractInfo.moneyData.waitInvoiceMoneyFICC+contractInfo.moneyData.waitInvoiceMoneyQY)*100)/100
-    
-    contractInfo.moneyData.haveInvoiceMoney = 
-    Math.round((contractInfo.moneyData.haveInvoiceMoneyFICC+contractInfo.moneyData.haveInvoiceMoneyQY)*100)/100
+  // ---------------开票/到款金额信息
+  const amountForm=reactive({
+    amountData:[
+      {
+        service_product_id:'',
+        origin_amount:'',
+        amount:'',
+        invoice_date:'',
+        remark:'',
+        // dom的类型
+        amountDomType:'text',
+        remarkDomType:'text',
+        seller_id:0,
+        seller_name:''
+      }
+    ]
   })
-  // 已开票金额-QY
-  watch(()=> contractInfo.moneyData.haveInvoiceMoneyQY ,(newValue)=>{
-    contractInfo.moneyData.waitInvoiceMoneyQY = contractInfo.moneyData.allInvoiceMoneyQY-newValue
-    contractInfo.moneyData.waitInvoiceMoneyQY=Math.round(contractInfo.moneyData.waitInvoiceMoneyQY*100)/100
-    contractInfo.moneyData.waitInvoiceMoney = 
-    Math.round((contractInfo.moneyData.waitInvoiceMoneyFICC+contractInfo.moneyData.waitInvoiceMoneyQY)*100)/100
-    
-    contractInfo.moneyData.haveInvoiceMoney = 
-    Math.round((contractInfo.moneyData.haveInvoiceMoneyFICC+contractInfo.moneyData.haveInvoiceMoneyQY)*100)/100
+  //开票-到款展开和收起
+  const isIandPExpand=reactive({
+    haveInvoice:false,
+    waitInvoice:false
   })
-  // 已到款金额-FICC
-  watch(()=> contractInfo.moneyData.havePlacementMoneyFICC ,(newValue)=>{
-    contractInfo.moneyData.waitPlacementMoneyFICC = contractInfo.moneyData.allPlacementMoneyFICC-newValue
-    contractInfo.moneyData.waitPlacementMoneyFICC=Math.round(contractInfo.moneyData.waitPlacementMoneyFICC*100)/100
-    contractInfo.moneyData.waitPlacementMoney = 
-    Math.round((contractInfo.moneyData.waitPlacementMoneyQY+contractInfo.moneyData.waitPlacementMoneyFICC)*100)/100
+  // 货币汇率
+  const rmbRate=ref(1)
+
+  const sellerListType=ref(3)
+
+  // -----------------------------监听
+  // 金额-FICC
+  watch(()=> IandP.moneyData.haveMoneyFICC ,(newValue)=>{
+    IandP.moneyData.waitMoneyFICC = IandP.moneyData.allMoneyFICC-newValue
+    IandP.moneyData.waitMoneyFICC=Math.round(IandP.moneyData.waitMoneyFICC*100)/100
+    IandP.moneyData.waitMoney = 
+    Math.round((IandP.moneyData.waitMoneyFICC+IandP.moneyData.waitMoneyQY)*100)/100
     
-    contractInfo.moneyData.havePlacementMoney = 
-    Math.round((contractInfo.moneyData.havePlacementMoneyFICC+contractInfo.moneyData.havePlacementMoneyQY)*100)/100
+    IandP.moneyData.haveMoney = 
+    Math.round((IandP.moneyData.haveMoneyFICC+IandP.moneyData.haveMoneyQY)*100)/100
   })
-  // 已到款金额-QY
-  watch(()=> contractInfo.moneyData.havePlacementMoneyQY ,(newValue)=>{
-    contractInfo.moneyData.waitPlacementMoneyQY = contractInfo.moneyData.allPlacementMoneyQY-newValue
-    contractInfo.moneyData.waitPlacementMoneyQY=Math.round(contractInfo.moneyData.waitPlacementMoneyQY*100)/100
-    contractInfo.moneyData.waitPlacementMoney = 
-    Math.round((contractInfo.moneyData.waitPlacementMoneyQY+contractInfo.moneyData.waitPlacementMoneyFICC)*100)/100
+  // 金额-QY
+  watch(()=> IandP.moneyData.haveMoneyQY ,(newValue)=>{
+    IandP.moneyData.waitMoneyQY = IandP.moneyData.allMoneyQY-newValue
+    IandP.moneyData.waitMoneyQY=Math.round(IandP.moneyData.waitMoneyQY*100)/100
+    IandP.moneyData.waitMoney = 
+    Math.round((IandP.moneyData.waitMoneyFICC+IandP.moneyData.waitMoneyQY)*100)/100
     
-    contractInfo.moneyData.havePlacementMoney = 
-    Math.round((contractInfo.moneyData.havePlacementMoneyFICC+contractInfo.moneyData.havePlacementMoneyQY)*100)/100
+    IandP.moneyData.haveMoney = 
+    Math.round((IandP.moneyData.haveMoneyFICC+IandP.moneyData.haveMoneyQY)*100)/100
   })
-
+  watch(()=>props.IPDetailInfo.contract_register_id,(value)=>{
+    if(value){
+      setIandPDetail()
+    }
+  }) 
 // ------------------------------------------方法
   // 切换套餐类型
-  const productIdChange=(value,type,row)=>{
+  const productIdChange=(value,row)=>{
     // 清空销售
-    if(type=='invoice'){
+    if(props.type=='开票'){
       row.seller_id=''
     }
     if(!row.origin_amount) return
-    if(type=='invoice'){
       // 开票
-      if(value==1){
-        //切换成FICC套餐类型
-        contractInfo.moneyData.haveInvoiceMoneyFICC += row.origin_amount
-        contractInfo.moneyData.haveInvoiceMoneyQY -= row.origin_amount
-      }else{
-        //切换成QY套餐类型
-        contractInfo.moneyData.haveInvoiceMoneyFICC -= row.origin_amount
-        contractInfo.moneyData.haveInvoiceMoneyQY += row.origin_amount
-      }
-      contractInfo.moneyData.haveInvoiceMoneyFICC = Math.round(contractInfo.moneyData.haveInvoiceMoneyFICC*100)/100
-      contractInfo.moneyData.haveInvoiceMoneyQY = Math.round(contractInfo.moneyData.haveInvoiceMoneyQY*100)/100
+    if(value==1){
+      //切换成FICC套餐类型
+      IandP.moneyData.haveMoneyFICC += row.origin_amount
+      IandP.moneyData.haveMoneyQY -= row.origin_amount
     }else{
-      if(value==1){
-        //切换成FICC套餐类型
-        contractInfo.moneyData.havePlacementMoneyFICC += row.origin_amount
-        contractInfo.moneyData.havePlacementMoneyQY -= row.origin_amount
-      }else{
-        //切换成QY套餐类型
-        contractInfo.moneyData.havePlacementMoneyFICC -= row.origin_amount
-        contractInfo.moneyData.havePlacementMoneyQY += row.origin_amount
-      }
-      contractInfo.moneyData.havePlacementMoneyFICC = Math.round(contractInfo.moneyData.havePlacementMoneyFICC*100)/100
-      contractInfo.moneyData.havePlacementMoneyQY = Math.round(contractInfo.moneyData.havePlacementMoneyQY*100)/100
+      //切换成QY套餐类型
+      IandP.moneyData.haveMoneyFICC -= row.origin_amount
+      IandP.moneyData.haveMoneyQY += row.origin_amount
     }
+    IandP.moneyData.haveMoneyFICC = Math.round(IandP.moneyData.haveMoneyFICC*100)/100
+    IandP.moneyData.haveMoneyQY = Math.round(IandP.moneyData.haveMoneyQY*100)/100
   }
   // 添加行
-  const addTableRow=(type)=>{
-    if(type=='invoice'){
-      invoiceForm.invoiceData.push({
-        service_product_id:sellerListType.value == 3?'':sellerListType.value,origin_amount:'',amount:'',invoice_date:'',remark:'',
-      seller_id:'',seller_name:'',amountDomType:'text',remarkDomType:'text'})
-    }else{
-      placementForm.placementData.push({
-        service_product_id:sellerListType.value == 3?'':sellerListType.value,origin_amount:'',
-        amount:'',invoice_date:'',remark:'',amountDomType:'text',remarkDomType:'text'})
-    }
+  const addTableRow=()=>{
+    amountForm.amountData.push({
+      service_product_id:sellerListType.value == 3?'':sellerListType.value,origin_amount:'',amount:'',invoice_date:'',remark:'',
+    seller_id:0,seller_name:'',amountDomType:'text',remarkDomType:'text'})
   }
 
   // 表格添加行
-  const addRow=(type,row,index)=>{
-    console.log(type,row,index);
+  const addRow=(row,index)=>{
     if(!(row.amount && row.invoice_date && row.service_product_id)){
       ElMessage.error('请填写完整信息')
       return
     }
-    if(type=='invoice'){
+    if(props.type=='开票'){
       if(!row.seller_id){
         ElMessage.error('请填写完整信息')
         return
       }
-      invoiceForm.invoiceData.splice((index+1),0,
-      {service_product_id:sellerListType.value == 3?'':sellerListType.value,origin_amount:'',
-      amount:'',invoice_date:'',remark:'',seller_id:'',seller_name:'',amountDomType:'text',remarkDomType:'text'})
-    }else{
-      placementForm.placementData.splice((index+1),0,
-      {service_product_id:sellerListType.value == 3?'':sellerListType.value,origin_amount:'',
-      amount:'',invoice_date:'',remark:'',amountDomType:'text',remarkDomType:'text'})
     }
+    amountForm.amountData.splice((index+1),0,
+    {service_product_id:sellerListType.value == 3?'':sellerListType.value,origin_amount:'',
+    amount:'',invoice_date:'',remark:'',seller_id:0,seller_name:'',amountDomType:'text',remarkDomType:'text'})
   }
 
 
   // 表格删除行
-  const deleteRow=(type,row,index)=>{
-    let tempArr=[]
-    let word='开票'
+  const deleteRow=(row,index)=>{
     let haveSalesman=false
-    if(type=='invoice'){
-      tempArr=invoiceForm.invoiceData
-      if(tempArr[index].seller_id) haveSalesman=true
-      word='开票'
+    if(props.type=='开票'){
+      if(amountForm.amountData[index].seller_id) haveSalesman=true
     }else{
-      console.log(row);
       if(row.is_pre_pay==1){
         // 预到款登记
         ElMessage.error('该笔到款是预到款,不允许删除!')
         return 
       }
-      tempArr=placementForm.placementData
-      word='到款'
     }
-    if(tempArr[index].origin_amount=='' && tempArr[index].amount=='' && (tempArr[index].service_product_id=='' || sellerListType.value != 3)
-    && tempArr[index].invoice_date=='' && !haveSalesman){
+    if(amountForm.amountData[index].origin_amount=='' && amountForm.amountData[index].amount=='' 
+    && (amountForm.amountData[index].service_product_id=='' || sellerListType.value != 3)
+    && amountForm.amountData[index].invoice_date=='' && !haveSalesman){
       // 没有内容 直接删除
-      tempArr.splice(index,1)
+      amountForm.amountData.splice(index,1)
     }else{
-      ElMessageBox.confirm(`是否删除该条${word}记录?`,
+      ElMessageBox.confirm(`是否删除该条${props.type}记录?`,
       '提示',    
       {
         confirmButtonText: '确定',
@@ -185,10 +178,10 @@
         type: 'warning',
       }).then(res=>{
         // 有金额才进行删除后的运算
-        if(tempArr[index].origin_amount!=''){
-          tempArr.splice(index,1)
+        if(amountForm.amountData[index].origin_amount!=''){
+          amountForm.amountData.splice(index,1)
           let money=0                                           
-          tempArr.map(item =>{
+          amountForm.amountData.map(item =>{
             if(item.service_product_id == row.service_product_id){
               money+=parseFloat(item.origin_amount) || 0
             }
@@ -196,38 +189,24 @@
           })
           // 保留两位小数、防止计算时精度丢失
           money=Math.round(money*100)/100
-          if(type=='invoice'){
-            if(row.service_product_id==1){
-              contractInfo.moneyData.haveInvoiceMoneyFICC=money
-            }else{
-              contractInfo.moneyData.haveInvoiceMoneyQY=money
-            }
+          if(row.service_product_id==1){
+            IandP.moneyData.haveMoneyFICC=money
           }else{
-            if(row.service_product_id==1){
-              contractInfo.moneyData.havePlacementMoneyFICC=money
-            }else{
-              contractInfo.moneyData.havePlacementMoneyQY=money
-            }
+            IandP.moneyData.haveMoneyQY=money
           }
         }else{
-          tempArr.splice(index,1)
+          amountForm.amountData.splice(index,1)
         }
       }).catch(()=>{})
     }
   }
   // 金额改变
-  const moneyChange=(type,value,index,row)=>{ 
+  const moneyChange=(value,index,row)=>{ 
     // console.log(value);
     let numerValue=parseFloat(value)
-    let tempArr=[]
-    if(type=='invoice'){
-      tempArr=invoiceForm.invoiceData
-    }else{
-      tempArr=placementForm.placementData
-    }
 
     if(!numerValue&&numerValue!=0&&value){
-      tempArr[index].origin_amount=''
+      amountForm.amountData[index].origin_amount=''
       ElMessage.error('请输入数字')
       return
     }
@@ -235,13 +214,12 @@
     // 考虑到类似12.02的情况
     if(!((value.endsWith('.') && value.indexOf('.')==(value.length-1)) || 
     (value.endsWith('0') && value.indexOf('.')==(value.length-2)))&&numerValue){
-      tempArr[index].origin_amount=numerValue
+      amountForm.amountData[index].origin_amount=numerValue
     }
-    // console.log(rmbRate.value);
-    tempArr[index].amount=tempArr[index].origin_amount/rmbRate.value
+    amountForm.amountData[index].amount=amountForm.amountData[index].origin_amount/rmbRate.value
 
     let money=0
-    tempArr.map(item =>{
+    amountForm.amountData.map(item =>{
       if(item.service_product_id == row.service_product_id){
         money+=Math.round(item.origin_amount*100)/100 || 0
       }
@@ -249,88 +227,12 @@
     // 保留两位小数、防止计算时精度丢失
     money=Math.round(money*100)/100
     
-    if(type=='invoice'){
-      if(row.service_product_id==1){
-        contractInfo.moneyData.haveInvoiceMoneyFICC=money
-      }else{
-        contractInfo.moneyData.haveInvoiceMoneyQY=money
-      }
+    if(row.service_product_id==1){
+      IandP.moneyData.haveMoneyFICC=money
     }else{
-      if(row.service_product_id==1){
-        contractInfo.moneyData.havePlacementMoneyFICC=money
-      }else{
-        contractInfo.moneyData.havePlacementMoneyQY=money
-      }
+      IandP.moneyData.haveMoneyQY=money
     }
   }
-  // 金额格式化,保留两位小数
-  const moneyFormatter=(money)=>{
-    let result=money.toString()
-    if(result.indexOf('.')==-1){
-      // 没有小数
-      return result+'.00'
-    }else{
-      let arr = result.split('.')
-      let decimal = arr[1].padEnd(2,'0')
-      return arr[0]+'.'+decimal
-    }
-  }
-  //开票-到款展开和收起
-  const isIandPExpand=reactive({
-    haveInvoice:false,
-    waitInvoice:false,
-    havePlacement:false,
-    waitPlacement:false
-  })
-
-  // 开票登记保存
-  const invoiceSubmit=()=>{
-    invoiceFormRef.value.validate(valid=>{
-      if(valid){
-        // 转化
-        invoiceForm.invoiceData.forEach(element => {
-          element.origin_amount = parseFloat(element.origin_amount)
-          element.amount = parseFloat(element.amount.toFixed(2))
-        });
-        let param={
-          contract_register_id:contractRegisterId,
-          invoice_type:1,
-          amount_list:invoiceForm.invoiceData,
-        }
-        registerInvoice(param).then(res=>{
-          let messageHint=ElMessage.success('开票登记成功')
-          setTimeout(()=>{
-            messageHint.close()
-            router.back()
-          },1000)
-        })
-      }
-    })
-  }
-  // 到款登记保存
-  const placementSubmit=()=>{
-    placementFormRef.value.validate(valid=>{
-      if(valid){
-        // 转化
-        placementForm.placementData.forEach(element => {
-          element.origin_amount = parseFloat(element.origin_amount)
-          element.amount = parseFloat(element.amount.toFixed(2))
-        });
-        let param={
-          contract_register_id:contractRegisterId,
-          invoice_type:2,
-          amount_list:placementForm.placementData
-        }
-        registerPayment(param).then(res=>{
-          let messageHint=ElMessage.success('到款登记成功')
-          setTimeout(()=>{
-            messageHint.close()
-            router.back()
-          },1000)
-        })
-      }
-    })
-  }
   // 点击输入框后 文本切换成输入框
   const iandPInput=(row,prop)=>{
     row[prop]='input'
@@ -338,11 +240,9 @@
   // 金额输入框失去焦点
   const iandPAmountBlur=(row)=>{
     if(row.origin_amount){
-      // console.log(parseFloat(row.origin_amount).toFixed(2));
       row.origin_amount= Math.round(parseFloat(row.origin_amount)*100)/100
     }
     row.amountDomType ='text'
-    // console.log(row.origin_amount);
   }
   
   let elMessageDom=null
@@ -357,21 +257,111 @@
       }
     }
   }
+
+  // 开票/到款登记保存
+  const iandPSubmit=()=>{
+    iandPFormRef.value.validate(valid=>{
+      if(valid){
+        // 转化
+        amountForm.amountData.forEach(element => {
+          element.origin_amount = parseFloat(element.origin_amount)
+          element.amount = parseFloat(element.amount.toFixed(2))
+        });
+        let invoice_type = props.type=='开票'?1:2
+        let registerprop = props.type=='开票'?registerInvoice:registerPayment
+        let param={
+          contract_register_id:props.IPDetailInfo.contract_register_id,
+          invoice_type,
+          amount_list:amountForm.amountData,
+        }
+        registerprop(param).then(res=>{
+          let messageHint=ElMessage.success(props.type+'登记成功')
+          setTimeout(()=>{
+            messageHint.close()
+            emits('submitSuccess')
+          },1000)
+        })
+      }
+    })
+  }
+
+  const setIandPDetail=()=>{
+    sellerListType.value = props.IPDetailInfo.sellerListType
+    rmbRate.value=props.IPDetailInfo.rmb_rate
+    amountForm.amountData[0].service_product_id = sellerListType.value == 3?'':sellerListType.value
+
+    // FICC套餐总金额 = FICC套餐剩余开篇金额
+    IandP.moneyData.waitMoneyFICC= IandP.moneyData.allMoneyFICC =
+    props.IPDetailInfo.service_amount_list.find(item => item.product_id==1)?props.IPDetailInfo.service_amount_list.find(item => item.product_id==1).service_amount:0
+    // 权益套餐总金额 = 权益套餐剩余开篇金额
+    IandP.moneyData.waitMoneyQY= IandP.moneyData.allMoneyQY =
+    props.IPDetailInfo.service_amount_list.find(item => item.product_id==2)?props.IPDetailInfo.service_amount_list.find(item => item.product_id==2).service_amount:0
+    let amoutList = props.type=='开票'?props.IPDetailInfo.invoice_list:props.IPDetailInfo.payment_list
+    if(amoutList.length>0){
+      amountForm.amountData=[]
+      amoutList.map(item=>{
+        if(item.service_product_id==1){
+          // FICC
+          IandP.moneyData.haveMoneyFICC+=item.origin_amount
+        }else{
+          // 权益
+          IandP.moneyData.haveMoneyQY+=item.origin_amount
+        }
+        amountForm.amountData.push({
+          invoice_id:item.contract_invoice_id,
+          service_product_id:item.service_product_id,
+          origin_amount:item.origin_amount,
+          amount:item.amount,
+          invoice_date:item.invoice_time,
+          remark:item.remark,
+          seller_id:item.seller_id,
+          seller_name:item.seller_name
+        })
+      })
+      // 添加一行空的
+      amountForm.amountData.push({
+        service_product_id:sellerListType.value == 3?'':sellerListType.value,              
+        origin_amount:'',
+        amount:'',
+        invoice_date:'',
+        remark:'',
+        amountDomType:'text',
+        remarkDomType:'text',
+        seller_id:0,
+        seller_name:''
+      })
+    }
+    IandP.moneyData.haveMoney=
+    IandP.moneyData.haveMoneyFICC+IandP.moneyData.haveMoneyQY
+
+    IandP.moneyData.waitMoney = IandP.moneyData.waitMoneyFICC+IandP.moneyData.waitMoneyQY
+    IandP.moneyData.allInvoiceMoney = IandP.moneyData.allPlacementMoney=
+    IandP.moneyData.allMoneyFICC+IandP.moneyData.allMoneyQY
+    // 拿取货币单位
+    const intervalCallback=()=>{
+      IandP.currencyUnit=props.currencyList.find(item => item.code==props.IPDetailInfo.currency_unit)?.unit_name
+    }
+    intervalDataRequest(()=> props.currencyList.length>0 ,intervalCallback,1)
+  }
+
+  defineExpose({hasRegisteFinish:()=>IandP.moneyData.waitMoney==0,iandPSubmit})
+
+  
 </script>
 
 <template>
     <div id="contractProgress-InvoiceAndPayment">
       <div class="info-row" >
-        <div class="info-row-title">开票信息</div>
+        <div class="info-row-title">{{ type }}信息</div>
         <div class="info-row-invoice-payment">
           <div class="invoice-payment-title">
-            <div v-if="contractInfo.showServiceFicc && contractInfo.showServiceQy" style="margin-right: 30px;margin-bottom: 20px;">
+            <div v-if="sellerListType==3" style="margin-right: 30px;margin-bottom: 20px;">
               <div class="invoice-payment-money-multiple" :style="{height:isIandPExpand.haveInvoice?'135px':'59px'}">
                 <div class="invoice-payment-money-multiple-head" @click="isIandPExpand.haveInvoice=!isIandPExpand.haveInvoice">
-                  <span style="margin-right: 20px;">已开票金额</span>
+                  <span style="margin-right: 20px;">已{{ type }}金额</span>
                   <span>
-                    <span class="invoice-payment-money">{{moneyFormatter(contractInfo.moneyData?.haveInvoiceMoney)}}</span>
-                  ({{ contractInfo.currencyUnit }})
+                    <span class="invoice-payment-money">{{moneyFormatter(IandP.moneyData.haveMoney)}}</span>
+                  ({{ IandP.currencyUnit }})
                   </span>
                   <el-icon size="16px">
                     <svg-Icon name="svgIcon-common-arrow_right" style="transition: all 0.1s ease;"
@@ -381,26 +371,26 @@
                 <div class="invoice-payment-money-multiple-body">
                   <div style="margin-bottom: 16px;">
                     <span style="margin-right: 20px;">FICC套餐</span>
-                    <span class="invoice-payment-money">{{ moneyFormatter(contractInfo.moneyData?.haveInvoiceMoneyFICC) }}</span>({{ contractInfo.currencyUnit }})
+                    <span class="invoice-payment-money">{{ moneyFormatter(IandP.moneyData?.haveMoneyFICC) }}</span>({{ IandP.currencyUnit }})
                   </div>
                   <div>
                     <span style="margin-right: 20px;">权益套餐</span>
-                    <span class="invoice-payment-money">{{ moneyFormatter(contractInfo.moneyData?.haveInvoiceMoneyQY) }}</span>({{ contractInfo.currencyUnit }})
+                    <span class="invoice-payment-money">{{ moneyFormatter(IandP.moneyData?.haveMoneyQY) }}</span>({{ IandP.currencyUnit }})
                   </div>
                 </div>
               </div>
             </div>
-            <div style="margin-right: 30px;" v-else>已开票金额:
-              <span class="invoice-payment-money">{{moneyFormatter(contractInfo.moneyData?.haveInvoiceMoney)}}</span>
-              ({{ contractInfo.currencyUnit }})
+            <div style="margin-right: 30px;" v-else>已{{ type }}金额:
+              <span class="invoice-payment-money">{{moneyFormatter(IandP.moneyData?.haveMoney)}}</span>
+              ({{ IandP.currencyUnit }})
             </div>
-            <div v-if="contractInfo.showServiceFicc && contractInfo.showServiceQy" style="margin-bottom: 20px;">
+            <div v-if="sellerListType==3" style="margin-bottom: 20px;">
               <div class="invoice-payment-money-multiple" :style="{height:isIandPExpand.waitInvoice?'135px':'59px'}">
                 <div class="invoice-payment-money-multiple-head" @click="isIandPExpand.waitInvoice=!isIandPExpand.waitInvoice">
-                  <span style="margin-right: 20px;">剩余开票金额</span>
+                  <span style="margin-right: 20px;">剩余{{ type }}金额</span>
                   <span>
-                    <span class="invoice-payment-money">{{moneyFormatter(contractInfo.moneyData?.waitInvoiceMoney)}}</span>
-                  ({{ contractInfo.currencyUnit }})
+                    <span class="invoice-payment-money">{{moneyFormatter(IandP.moneyData?.waitMoney)}}</span>
+                  ({{ IandP.currencyUnit }})
                   </span>
                   <el-icon size="16px">
                     <svg-Icon name="svgIcon-common-arrow_right" style="transition: all 0.1s ease;"
@@ -410,24 +400,25 @@
                 <div class="invoice-payment-money-multiple-body">
                   <div style="margin-bottom: 16px;">
                     <span style="margin-right: 20px;">FICC套餐</span>
-                    <span class="invoice-payment-money">{{ moneyFormatter(contractInfo.moneyData?.waitInvoiceMoneyFICC) }}</span>({{ contractInfo.currencyUnit }})
+                    <span class="invoice-payment-money">{{ moneyFormatter(IandP.moneyData?.waitMoneyFICC) }}</span>({{ IandP.currencyUnit }})
                   </div>
                   <div>
                     <span style="margin-right: 20px;">权益套餐</span>
-                    <span class="invoice-payment-money">{{ moneyFormatter(contractInfo.moneyData?.waitInvoiceMoneyQY) }}</span>({{ contractInfo.currencyUnit }})
+                    <span class="invoice-payment-money">{{ moneyFormatter(IandP.moneyData?.waitMoneyQY) }}</span>({{ IandP.currencyUnit }})
                   </div>
                 </div>
               </div>
             </div>
-            <div v-else>剩余开票金额:
-              <span class="invoice-payment-money">{{moneyFormatter(contractInfo.moneyData?.waitInvoiceMoney)}}</span>
-              ({{ contractInfo.currencyUnit }})
+            <div v-else>剩余{{ type }}金额:
+              <span class="invoice-payment-money">{{moneyFormatter(IandP.moneyData?.waitMoney)}}</span>
+              ({{ IandP.currencyUnit }})
             </div>
-            <el-button type="primary" style="margin: 0 0 0 20px;" @click="addTableRow('invoice')" 
-            v-if="contractInfo.operationtype=='invoice'&&invoiceForm.invoiceData.length==0">添加开票信息</el-button>
+            <el-button type="primary" style="margin: 0 0 0 20px;" @click="addTableRow" 
+            v-if="amountForm.amountData.length==0">添加{{ type }}信息</el-button>
           </div>
-          <el-form ref="invoiceFormRef" :model="invoiceForm" :disabled="contractInfo.operationtype!='invoice'">
-            <el-table :data="invoiceForm.invoiceData" border v-if="invoiceForm.invoiceData.length>0" style="width: 100%;"> 
+          <el-form ref="iandPFormRef" :model="amountForm" 
+          :disabled="operationtype!='invoice'&&type=='开票' || operationtype!='placement'&&type=='到款'">
+            <el-table :data="amountForm.amountData" border v-if="amountForm.amountData.length>0" style="width: 100%;"> 
               <el-table-column label="序号" width="80" align="center">
                 <template #default="{row,$index}">
                   {{$index+1}}
@@ -438,9 +429,9 @@
                   <span style="color: var(--dangerColor);">*</span>套餐类型
                 </template>
                 <template #default="{row,$index}">
-                  <el-form-item :prop="`invoiceData.${$index}.service_product_id`" :show-message="false" v-if="!row.invoice_id"
+                  <el-form-item :prop="`amountData.${$index}.service_product_id`" :show-message="false" v-if="!row.invoice_id"
                   :rules="{required:true,message:()=>{ ElMessage.error('套餐类型不能为空')},trigger:'change'}">
-                    <el-select v-model="row.service_product_id" style="width: 124px;" @change="value=> productIdChange(value,'invoice',row)"
+                    <el-select v-model="row.service_product_id" style="width: 124px;" @change="value=> productIdChange(value,row)"
                     placeholder="请选择套餐" filterable>
                       <el-option label="FICC套餐" :value="1"></el-option>
                       <el-option label="权益套餐" :value="2"></el-option>
@@ -449,21 +440,21 @@
                   <span v-else>{{ row.service_product_id?row.service_product_id==1?'FICC套餐':'权益套餐' : '--' }}</span>
                 </template>
               </el-table-column>
-              <el-table-column label="开票金额" width="160" show-overflow-tooltip  align="center" prop="origin_amount">
+              <el-table-column :label="type+'金额'" width="160" show-overflow-tooltip  align="center" prop="origin_amount">
                 <template #header>
-                  <span style="color: var(--dangerColor);">*</span>开票金额
+                  <span style="color: var(--dangerColor);">*</span>{{ type }}金额
                 </template>
                 <template #default="{row,$index}">
-                  <el-form-item :prop="`invoiceData.${$index}.origin_amount`" :show-message="false" v-if="!row.invoice_id"
-                  :rules="{required:true,message:()=>{ ElMessage.error('开票金额不能为空')},trigger:'blur'}">
-                    <label :for="'invoice'+$index+'origin_amount'" style="cursor: pointer;" 
+                  <el-form-item :prop="`amountData.${$index}.origin_amount`" :show-message="false" v-if="!row.invoice_id"
+                  :rules="{required:true,message:()=>{ ElMessage.error(type+'金额不能为空')},trigger:'blur'}">
+                    <label :for="type=='开票'?'invoice':'payment'+$index+'origin_amount'" style="cursor: pointer;" 
                     :style="{color:row.origin_amount?'var(--secondaryTextColor)':'var(--hitTextColorOne)'}"
                     v-show="row.amountDomType=='text'" @click="iandPInput(row,'amountDomType')">
                       {{ row.origin_amount ? parseFloat(row.origin_amount).toFixed(2): '单击此处输入金额'}}
                     </label>
-                    <el-input v-model.trim="row.origin_amount" :id="'invoice'+$index+'origin_amount'" style="width: 124px;" 
+                    <el-input v-model.trim="row.origin_amount" :id="type=='开票'?'invoice':'payment'+$index+'origin_amount'" style="width: 124px;" 
                     v-show="row.amountDomType=='input'" @blur="iandPAmountBlur(row)"
-                      placeholder="请输入金额" @input="(e)=>moneyChange('invoice',e,$index,row)"></el-input>
+                      placeholder="请输入金额" @input="(e)=>moneyChange(e,$index,row)"></el-input>
                   </el-form-item>
                   <span  v-else>{{ row.origin_amount.toFixed(2)}}</span>
                 </template>
@@ -471,42 +462,42 @@
               <el-table-column label="换算金额(元)" show-overflow-tooltip width="160" align="center" prop="amount">
                 <template #default="{row,$index}">
                   <span v-if="row.amount">{{ row.amount.toFixed(2)}}</span>
-                  <span v-else style="color: var(--hitTextColorOne);">开票金额为空</span>
+                  <span v-else style="color: var(--hitTextColorOne);">{{type}}金额为空</span>
                 </template>
               </el-table-column>
-              <el-table-column label="开票日" width="120" align="center" prop="invoice_date">
+              <el-table-column :label="type+'日'" width="120" align="center" prop="invoice_date">
                 <template #header>
-                  <span style="color: var(--dangerColor);">*</span>开票
+                  <span style="color: var(--dangerColor);">*</span>{{type}}
                 </template>
                 <template #default="{row,$index}" >
-                  <el-form-item :prop="`invoiceData.${$index}.invoice_date`" :show-message="false" v-if="!row.invoice_id"
-                  :rules="{required:true,message:()=>{ ElMessage.error('请选择开票日')},trigger:'change'}">       
+                  <el-form-item :prop="`amountData.${$index}.invoice_date`" :show-message="false" v-if="!row.invoice_id"
+                  :rules="{required:true,message:()=>{ ElMessage.error(`请选择${type}日`)},trigger:'change'}">       
                     <el-date-picker v-model="row.invoice_date" style="width: 124px;"
                     placeholder="请选择日期" value-format="YYYY-MM-DD" :clearable="false" ></el-date-picker>
                   </el-form-item>
                   <span v-show="row.invoice_id">{{ row.invoice_date || '--' }}</span>
                 </template>
               </el-table-column >
-              <el-table-column label="销售" width="120" align="center" prop="seller_id">
+              <el-table-column label="销售" width="120" align="center" prop="seller_id" v-if="type=='开票'">
                 <template #header>
                   <span style="color: var(--dangerColor);">*</span>销售
                 </template>
                 <template #default="{row,$index}">
-                  <el-form-item :prop="`invoiceData.${$index}.seller_id`" :show-message="false" v-if="!row.invoice_id"
+                  <el-form-item :prop="`amountData.${$index}.seller_id`" :show-message="false" v-if="!row.invoice_id"
                   :rules="{required:true,message:()=>{ ElMessage.error('销售不能为空')},trigger:'change'}">
-                    <el-select v-model="row.seller_id" style="width: 124px;" :ref='`invoiceData-service_product_id${$index}`'
+                    <el-select v-model="row.seller_id" style="width: 124px;" :ref='`amountData-service_product_id${$index}`'
                     placeholder="请选择销售" filterable v-if="row.service_product_id==1">
                       <el-option :label="item.seller_name" :value="item.seller_id" 
-                      v-for="item in contractInfo.sellerInvoiceListF" :key="item.seller_id">
+                      v-for="item in sellerData?.ficc_list" :key="item.seller_id">
                       </el-option>
                     </el-select>
-                    <el-select v-model="row.seller_id" style="width: 124px;" :ref='`invoiceData-service_product_id${$index}`'
+                    <el-select v-model="row.seller_id" style="width: 124px;" :ref='`amountData-service_product_id${$index}`'
                     placeholder="请选择销售" filterable v-else-if="row.service_product_id==2">
                       <el-option :label="item.seller_name" :value="item.seller_id" 
-                      v-for="item in contractInfo.sellerInvoiceListQ" :key="item.seller_id">
+                      v-for="item in sellerData?.rai_list" :key="item.seller_id">
                       </el-option>
                     </el-select>
-                    <el-select v-model="row.seller_id" style="width: 124px;" :ref='`invoiceData-service_product_id${$index}`'
+                    <el-select v-model="row.seller_id" style="width: 124px;" :ref='`amountData-service_product_id${$index}`'
                     placeholder="请选择销售" v-else
                       @visible-change="selectVisible">
                     </el-select>
@@ -526,12 +517,13 @@
                   <span v-else>{{row.remark || '--'}}</span>
                 </template>
               </el-table-column>
-              <el-table-column label="操作" width="120" align="center" v-if="contractInfo.operationtype=='invoice'">
-                <template #default="{row,$index,column}" >
-                  <span class="table-operation-button" v-show="$index==invoiceForm.invoiceData.length-1" 
-                  @click="addRow('invoice',row,$index)" style="margin-right: 10px;">添加</span>
+              <el-table-column label="操作" width="120" align="center" 
+              v-if="operationtype=='invoice'&&type=='开票' || operationtype=='placement'&&type=='到款'">
+                <template #default="{row,$index}">
+                  <span class="table-operation-button" v-show="$index==amountForm.amountData.length-1" 
+                  @click="addRow(row,$index)" style="margin-right: 10px;">添加</span>
                   <span class="table-operation-button" style="color: var(--dangerColor);" 
-                  @click="deleteRow('invoice',row,$index)">删除</span>
+                  @click="deleteRow(row,$index)">删除</span>
                 </template>
               </el-table-column>
             </el-table>

+ 52 - 155
src/views/financialManagement/contractProgress.vue

@@ -3,7 +3,6 @@
 
   import {useRouter,useRoute} from 'vue-router'
   import {useStore} from 'vuex'
-  import {ElMessage} from 'element-plus'
   import {getSellerList} from '@/api/crm'
   import {getServiceList,registerDetail,preRegistrationDetail} from '@/api/financialMana'
   import {getCurrencyList} from '@/api/common'
@@ -58,37 +57,9 @@
   })
 
   const complianceRef=ref(null)
-  // ---------------开票信息
-  const invoiceForm=reactive({
-    invoiceData:[
-      {
-        service_product_id:'',
-        origin_amount:'',
-        amount:'',
-        invoice_date:'',
-        remark:'',
-        // dom的类型
-        amountDomType:'text',
-        remarkDomType:'text',
-        seller_id:'',
-        seller_name:''
-      }
-    ]
-  })
-  // ---------------到款信息
-  const placementForm=reactive({
-    placementData:[
-      {
-        service_product_id:'',
-        origin_amount:'',
-        amount:'',
-        invoice_date:'',
-        remark:'',
-        amountDomType:'text',
-        remarkDomType:'text',
-      }
-    ]
-  })
+  const invoiceRef=ref(null)
+  const paymentRef=ref(null)
+
   // 套餐
   const serviceItem=reactive({
     serviceArray:[],
@@ -106,11 +77,10 @@
   }
   // 预登记信息
   const supplementaryInfo=ref({})
-  // 详情信息
+  // 合规详情信息
   const detailInfo=ref({})
-
-
-
+  // 开票到款详情信息
+  const IPDetailInfo=ref({})
   // -----------------------method
   // 权限验证
   const permissionValidation=()=>{
@@ -120,9 +90,10 @@
     */
     let flag=0 // 拥有的权限个数
     let permissionButtons=store.getters.permissionButtons
-    for (let i = 0,len=permissionButtons.length; i < len || flag==3; i++) {
+    for (let i = 0,len=permissionButtons.length; i < len && flag<3; i++) {
       const element = permissionButtons[i];
-      if(element.button_code=='financial:list:complianceAdd' || element.button_code=='financial:list:complianceEdit'){
+      if(element.button_code=='financial:list:complianceAdd' 
+      || element.button_code=='financial:list:complianceEdit' && !permissionItem.compliance){
         permissionItem.compliance=true
         flag++
       }else if(element.button_code=='financial:list:invoice'){
@@ -134,7 +105,7 @@
       }
     }
     if(operationtype!='view'){
-      if(permissionItem[operationtype]===false){
+      if(!permissionItem[operationtype]){
         // 没有权限
         let messageHint=ElMessage.warning('暂无权限')
         setTimeout(()=>{
@@ -150,8 +121,6 @@
   const getSellerListFun=()=>{
     getSellerList().then(res=>{
       allSeller.value=res.data || {}
-      contractInfo.sellerInvoiceListF = allSeller.value.ficc_list || []
-      contractInfo.sellerInvoiceListQ = allSeller.value.rai_list || []
     })
   }
   // 获取服务列表
@@ -173,9 +142,9 @@
     if(operationtype=='compliance'){
       complianceRef.value.complianceSubmit()
     }else if(operationtype=='invoice'){
-      invoiceSubmit()
+      invoiceRef.value.iandPSubmit()
     }else if(operationtype=='placement'){
-      placementSubmit()
+      paymentRef.value.iandPSubmit()
     }
   }
   
@@ -207,13 +176,17 @@
       },300)
     }
   }
-
-  const submitSuccessHandler=()=>{
-    router.replace('/financial/list')
+  // 提交成功回调
+  const submitSuccessHandler=(type='compliance')=>{
+    if(type=='compliance'){
+      router.replace('/financial/list')
+    }else{
+      router.back()
+    }
   }
-
   // --------------------------------
   onMounted(()=>{
+    // 缓存dom查询结果
     contractInfo.infoBoxDomList = document.getElementsByClassName('info-row-item')
   })
 
@@ -225,12 +198,11 @@
   supplementary_item.invoice_type = parseInt(route.query.invoice_type) || 0
   // complianceId没有,认为是合规登记
   operationtype=contractRegisterId?(route.query.type || 'view'):'compliance'
-  
 
   // 是否是开票登记或者单款登记
-  const isIOrP =operationtype=='invoice' || operationtype=='placement'
+  const isIOrP = operationtype=='invoice' || operationtype=='placement'
 
-  // 处理各个登记模块展开和收起的默认状态
+  // 处理各个登记模块展开和收起的默认状态 
   if(operationtype=='compliance'){
     // 合规展开
     contractInfo.foldDomStatus[0].isFold=false
@@ -251,18 +223,26 @@
     }
   }
 
-
   if(permissionValidation()){
     // 权限通过
     getSellerListFun()
     getServiceListFun()
     getCurrencyListFun()
   }
+
   if(contractRegisterId){
     //请求详情接口
     registerDetail({contract_register_id:contractRegisterId}).then(res=>{
       if(!res.data) return 
       contractInfo.progressList=res.data.logs || [{}]
+      let sellerListType=3
+      if(res.data.seller_id && res.data.rai_seller_id){
+        sellerListType = 3
+      }else if(!res.data.seller_id){
+        sellerListType = 2
+      }else{
+        sellerListType = 1
+      }
       detailInfo.value={
         contract_register_id:res.data.contract_register_id,
         product_ids:res.data.product_ids,
@@ -272,8 +252,8 @@
         currency_unit:res.data.currency_unit,
         new_company:res.data.new_company,
         seller_ids:res.data.seller_ids,
-        seller_id:res.data.seller_id,
-        rai_seller_id:res.data.rai_seller_id,
+        seller_id:res.data.seller_id || res.data.rai_seller_id,
+        sellerListType,
         contract_status:res.data.contract_status,
         start_date:res.data.start_date,
         end_date:res.data.end_date,
@@ -292,100 +272,15 @@
         service_amount_list:res.data.service_amount_list,
         services:res.data.service_list
       }
-      // invoiceForm.invoiceData[0].service_product_id = 
-      // placementForm.placementData[0].service_product_id=sellerListType.value == 3?'':sellerListType.value
-
-      // // 开票
-      // // console.log(res.data.service_amount_list.find(item => item.product_id==1),res.data.service_amount_list.find(item => item.product_id==2));
-      // // FICC套餐总金额 = FICC套餐剩余开篇金额
-      // contractInfo.moneyData.waitInvoiceMoneyFICC=contractInfo.moneyData.waitPlacementMoneyFICC=
-      // contractInfo.moneyData.allInvoiceMoneyFICC = contractInfo.moneyData.allPlacementMoneyFICC=
-      // res.data.service_amount_list.find(item => item.product_id==1)?res.data.service_amount_list.find(item => item.product_id==1).service_amount:0
-      // // 权益套餐总金额 = 权益套餐剩余开篇金额
-      // contractInfo.moneyData.waitInvoiceMoneyQY=contractInfo.moneyData.waitPlacementMoneyQY=
-      // contractInfo.moneyData.allInvoiceMoneyQY = contractInfo.moneyData.allPlacementMoneyQY=
-      // res.data.service_amount_list.find(item => item.product_id==2)?res.data.service_amount_list.find(item => item.product_id==2).service_amount:0
-
-      // if(res.data.invoice_list.length>0){
-      //   invoiceForm.invoiceData=[]
-      //   res.data.invoice_list.map(item=>{
-      //     if(item.service_product_id==1){
-      //       // FICC
-      //       contractInfo.moneyData.haveInvoiceMoneyFICC+=item.origin_amount
-      //     }else{
-      //       // 权益
-      //       contractInfo.moneyData.haveInvoiceMoneyQY+=item.origin_amount
-      //     }
-      //     invoiceForm.invoiceData.push({
-      //       invoice_id:item.contract_invoice_id,
-      //       service_product_id:item.service_product_id,
-      //       origin_amount:item.origin_amount,
-      //       amount:item.amount,
-      //       invoice_date:item.invoice_time,
-      //       remark:item.remark,
-      //       seller_id:item.seller_id,
-      //       seller_name:item.seller_name
-      //     })
-      //   })
-      //   // 添加一行空的
-      //   if(operationtype=='invoice'){
-      //     invoiceForm.invoiceData.push({
-      //       service_product_id:sellerListType.value == 3?'':sellerListType.value,              
-      //       origin_amount:'',
-      //       amount:'',
-      //       invoice_date:'',
-      //       remark:'',
-      //       amountDomType:'text',
-      //       remarkDomType:'text',
-      //       seller_id:'',
-      //       seller_name:''
-      //     })
-      //   }
-      // }
-      // // 到款
-      // if(res.data.payment_list.length>0){
-      //   placementForm.placementData=[]
-      //   res.data.payment_list.map(item=>{
-      //     if(item.service_product_id==1){
-      //       // FICC
-      //       contractInfo.moneyData.havePlacementMoneyFICC+=item.origin_amount
-      //     }else{
-      //       // 权益
-      //       contractInfo.moneyData.havePlacementMoneyQY+=item.origin_amount
-      //     }
-      //     placementForm.placementData.push({
-      //       invoice_id:item.contract_invoice_id,
-      //       service_product_id:item.service_product_id,
-      //       origin_amount:item.origin_amount,
-      //       amount:item.amount,
-      //       is_pre_pay:item.is_pre_pay,
-      //       invoice_date:item.invoice_time,
-      //       remark:item.remark
-      //     })
-      //   })
-      //   // 添加一行空的
-      //   if(operationtype=='placement'){
-      //     placementForm.placementData.push({
-      //       service_product_id:sellerListType.value == 3?'':sellerListType.value,
-      //       origin_amount:'',
-      //       amount:'',
-      //       invoice_date:'',
-      //       is_pre_pay:0,
-      //       remark:'',
-      //       amountDomType:'text',
-      //       remarkDomType:'text'
-      //     })
-      //   }
-      // }
-      // contractInfo.moneyData.haveInvoiceMoney=
-      // contractInfo.moneyData.haveInvoiceMoneyFICC+contractInfo.moneyData.haveInvoiceMoneyQY
-      // contractInfo.moneyData.havePlacementMoney=
-      // contractInfo.moneyData.havePlacementMoneyFICC+contractInfo.moneyData.havePlacementMoneyQY
-
-      // contractInfo.moneyData.waitInvoiceMoney = contractInfo.moneyData.waitPlacementMoney=
-      // contractInfo.moneyData.waitInvoiceMoneyFICC+contractInfo.moneyData.waitInvoiceMoneyQY
-      // contractInfo.moneyData.allInvoiceMoney = contractInfo.moneyData.allPlacementMoney=
-      // contractInfo.moneyData.allInvoiceMoneyFICC+contractInfo.moneyData.allInvoiceMoneyQY
+      IPDetailInfo.value={
+        contract_register_id:res.data.contract_register_id,
+        sellerListType,
+        rmb_rate:res.data.rmb_rate,
+        currency_unit:res.data.currency_unit,
+        service_amount_list:res.data.service_amount_list || [],
+        invoice_list:res.data.invoice_list || [],
+        payment_list:res.data.payment_list || []
+      }
     })
   }else if(supplementary_item.id){
     // 拿到预登记详情信息
@@ -427,37 +322,39 @@
             </div>
           </div>
           <!-- 开票登记 -->
-          <!-- <div class="info-box" v-show="operationtype!='compliance' && contractInfo.form.has_payment!=1" 
+          <div class="info-box" v-show="operationtype!='compliance' && detailInfo.has_payment!=1" 
           :style="{order:operationtype=='invoice'?2:0}"
           style="margin-top:20px ;" v-permission="['financial:list:invoice','financial:list:placement','financial:list:viewIandP','or']">
             <div class="info-box-head" @click="unfoldOrFlod(1)"
             :style="{cursor:isIOrP?'pointer':'default'}">
-              <div class="info-box-head-text">开票登记{{contractInfo.moneyData.waitInvoiceMoney==0?'':'(待开票)'}}</div>
+              <div class="info-box-head-text">开票登记{{invoiceRef?.hasRegisteFinish()?'':'(待开票)'}}</div>
               <span class="info-box-head-span" v-if="isIOrP" >
                 {{ contractInfo.foldDomStatus[1].isFold?'展开':'收起' }}
               </span>
             </div>
             <div class="info-row-box" :style="{height:contractInfo.foldDomStatus[1].domHeight}">
-              <InvoiceAndPayment class="info-row-item" type="开票"></InvoiceAndPayment>
+              <InvoiceAndPayment class="info-row-item" :currencyList="currencyList" type="开票" ref="invoiceRef" :operationtype="operationtype"
+              :IPDetailInfo="IPDetailInfo" :sellerData="allSeller" @submitSuccess="submitSuccessHandler('iandP')"></InvoiceAndPayment>
             </div>
-          </div> -->
+          </div>
           <!-- 到款登记 -->
-          <!-- <div class="info-box" v-show="operationtype!='compliance' && contractInfo.form.has_payment!=1" 
+          <div class="info-box" v-show="operationtype!='compliance' && detailInfo.has_payment!=1" 
           v-permission="['financial:list:invoice','financial:list:placement','financial:list:viewIandP','or']"
           style="margin-top:20px;order: 1;">
             <div class="info-box-head" @click="unfoldOrFlod(2)"
             :style="{cursor:isIOrP?'pointer':'default'}">
-              <div class="info-box-head-text">到款登记{{contractInfo.moneyData.waitPlacementMoney==0?'':'(待到款)'}}</div>
+              <div class="info-box-head-text">到款登记{{paymentRef?.hasRegisteFinish()?'':'(待到款)'}}</div>
               <span class="info-box-head-span" v-if="isIOrP" >
                 {{ contractInfo.foldDomStatus[2].isFold?'展开':'收起' }}
               </span>
             </div>
             <div class="info-row-box" :style="{height:contractInfo.foldDomStatus[2].domHeight}">
               <div class="info-row-item">
-                <InvoiceAndPayment class="info-row-item" type="到款"></InvoiceAndPayment>
+                <InvoiceAndPayment class="info-row-item" :currencyList="currencyList" type="到款" ref="paymentRef" :operationtype="operationtype"
+                :IPDetailInfo="IPDetailInfo" :sellerData="allSeller" @submitSuccess="submitSuccessHandler('iandP')"></InvoiceAndPayment>
               </div>
             </div>
-          </div> -->
+          </div>
         </div>
         <div class="contract-progress-aside"></div>
       </div>