Преглед изворни кода

版本冲突,先和与财务2.0合并

hbchen пре 2 година
родитељ
комит
52a7318af4

+ 8 - 0
src/api/common.js

@@ -8,3 +8,11 @@ export function getOSSToken() {
   })
 }
 
+ // 获取 货币单位与汇率
+ export function getCurrencyList() {
+  return request({
+      url:'/contract/register/currency_list',
+      method:'get'
+  })
+}
+

+ 80 - 51
src/views/financialManagement/contractProgress.vue

@@ -6,6 +6,7 @@
   import {ElMessage} from 'element-plus'
   import {getSellerList,getContractSearchList,getServiceDetail} from '@/api/crm'
   import {getServiceList,registerAdd,registerDetail,registerEdit,registerInvoice,registerPayment} from '@/api/financialMana'
+  import {getCurrencyList} from '@/api/common'
   import scrollableSelect from '@/components/scrollable-select/index.vue'
 
   const router = useRouter()
@@ -23,9 +24,6 @@
   const contractTypeArray=[{id:1,label:"新签合同"},{id:2,label:"续约合同"},{id:3,label:"代付合同"},{id:4,label:"补充协议"}]
   const operationType=[{op_type:1,label:"合规登记"},{op_type:2,label:"开票登记"},{op_type:3,label:"到款登记"},
   {op_type:4,label:"修改合同状态"},{op_type:5,label:"删除合同登记"},{op_type:6,label:"合规编辑"}]
-  const currencyList=[{currencyId:'1',currencyName:'人民币'},{currencyId:'2',currencyName:'美元'},{currencyId:'3',currencyName:'英镑'},
-  {currencyId:'4',currencyName:'新加坡币'}]
-
 
   // 合同信息
   const contractInfo=reactive({
@@ -49,7 +47,7 @@
       contract_code:'',
       company_name:'',
       isNew:'',
-      currencyId:'1',
+      currency_unit:'CNY',
       seller_id:'',
       seller_name:'',
       contract_status:'',
@@ -67,7 +65,7 @@
       remark:""
     },
     // 货币单位
-    currencyUnit:'(新元)',
+    currencyUnit:'',
     rules:{
       contract_source:{required:true,message:'合同来源不能为空',trigger:'change'},
       contract_code:{required:true,message:'合同编号不能为空',trigger:'blur'},
@@ -88,11 +86,7 @@
       }],
       contract_type:{required:true,message:'合同类型不能为空',trigger:'change'},
       has_payment:{required:true,message:'请选择是否是代付',trigger:'change'},
-      // sign_date:{required:true,message:'签订日不能为空',trigger:'change'},
-      // agreed_pay_time:{required:true,message:'约定付款时间不能为空',trigger:'blur'}
-      actual_company_name:{required:true,message:'实际使用方不能为空',trigger:'blur'},
-      // relate_contract_code:{required:true,message:'关联合同不能为空',trigger:'blur'}
-
+      actual_company_name:{required:true,message:'实际使用方不能为空',trigger:'blur'}
     },
     moneyData:{
       // 开票金额
@@ -162,6 +156,7 @@
   const invoiceForm=reactive({
     invoiceData:[
       {
+        origin_amount:'',
         amount:'',
         invoice_date:'',
         remark:'',
@@ -176,6 +171,7 @@
   const placementForm=reactive({
     placementData:[
       {
+        origin_amount:'',
         amount:'',
         invoice_date:'',
         remark:'',
@@ -184,6 +180,12 @@
       }
     ]
   })
+
+  //---------------货币列表
+  const currencyList=ref([])
+  const haveGetCurrencyList=ref(false)
+  const rmbRate=ref(1)
+
   // 查看套餐报价单 图片
   const previewImage=ref('')
   // 查看套餐报价单 标题
@@ -246,6 +248,13 @@
       contractInfo.serviceArray=res.data || []
     })
   }
+  // 获取货币列表
+  const getCurrencyListFun=()=>{
+    getCurrencyList().then(res=>{
+      currencyList.value=res.data || []
+      haveGetCurrencyList.value=true
+    })
+  }
 
   // 有效期变更触发函数
   const contractValidityDateChane=(value)=>{
@@ -264,7 +273,7 @@
       contract_code:'',
       company_name:'',
       isNew:'',
-      currencyId:'1',
+      currency_unit:'CNY',
       seller_id:'',
       seller_name:'',
       contract_status:'',
@@ -404,18 +413,18 @@
   // 添加行
   const addTableRow=(type)=>{
     if(type=='invoice'){
-      invoiceForm.invoiceData.push({amount:'',invoice_date:'',remark:'',salesman:'',amountDomType:'text',remarkDomType:'text'})
+      invoiceForm.invoiceData.push({origin_amount:'',amount:'',invoice_date:'',remark:'',salesman:'',amountDomType:'text',remarkDomType:'text'})
     }else{
-      placementForm.placementData.push({amount:'',invoice_date:'',remark:'',amountDomType:'text',remarkDomType:'text'})
+      placementForm.placementData.push({origin_amount:'',amount:'',invoice_date:'',remark:'',amountDomType:'text',remarkDomType:'text'})
     }
   }
 
   // 表格添加行
   const addRow=(type,index)=>{
     if(type=='invoice'){
-      invoiceForm.invoiceData.splice((index+1),0,{amount:'',invoice_date:'',remark:'',salesman:'',amountDomType:'text',remarkDomType:'text'})
+      invoiceForm.invoiceData.splice((index+1),0,{origin_amount:'',amount:'',invoice_date:'',remark:'',salesman:'',amountDomType:'text',remarkDomType:'text'})
     }else{
-      placementForm.placementData.splice((index+1),0,{amount:'',invoice_date:'',remark:'',amountDomType:'text',remarkDomType:'text'})
+      placementForm.placementData.splice((index+1),0,{origin_amount:'',amount:'',invoice_date:'',remark:'',amountDomType:'text',remarkDomType:'text'})
     }
   }
   // 表格删除行
@@ -431,7 +440,7 @@
       tempArr=placementForm.placementData
       word='到款'
     }
-    if(tempArr[index].amount=='' && tempArr[index].invoice_date=='' && !haveSalesman){
+    if(tempArr[index].origin_amount=='' && tempArr[index].amount=='' && tempArr[index].invoice_date=='' && !haveSalesman){
       // 没有内容 直接删除
       tempArr.splice(index,1)
     }else{
@@ -443,11 +452,11 @@
         type: 'warning',
       }).then(res=>{
         // 有金额才进行删除后的运算
-        if(tempArr[index].amount!=''){
+        if(tempArr[index].origin_amount!=''){
           tempArr.splice(index,1)
           let money=0                                           
           tempArr.map(item =>{
-            money+=parseFloat(item.amount) || 0
+            money+=parseFloat(item.origin_amount) || 0
             // console.log(money);
           })
           // 保留两位小数、防止计算时精度丢失
@@ -475,7 +484,7 @@
     }
 
     if(!numerValue&&numerValue!=0&&value){
-      tempArr[index].amount=''
+      tempArr[index].origin_amount=''
       ElMessage.error('请输入数字')
       return
     }
@@ -483,14 +492,14 @@
     // 考虑到类似12.02的情况
     if(!((value.endsWith('.') && value.indexOf('.')==(value.length-1)) || 
     (value.endsWith('0') && value.indexOf('.')==(value.length-2)))&&numerValue){
-      tempArr[index].amount=numerValue
+      tempArr[index].origin_amount=numerValue
     }
-
-    // tempArr[index].amount=tempArr[index].amount*1
+    console.log(rmbRate.value);
+    tempArr[index].amount=tempArr[index].origin_amount/rmbRate.value
 
     let money=0
     tempArr.map(item =>{
-      money+=Math.round(item.amount*100)/100 || 0
+      money+=Math.round(item.origin_amount*100)/100 || 0
     })
     // 保留两位小数、防止计算时精度丢失
     money=Math.round(money*100)/100
@@ -575,7 +584,8 @@
       if(valid){
         // 转化
         invoiceForm.invoiceData.forEach(element => {
-          element.amount = parseFloat(element.amount)
+          element.origin_amount = parseFloat(element.origin_amount)
+          element.amount = parseFloat(element.amount.toFixed(2))
         });
         let param={
           contract_register_id:contractInfo.form.contract_register_id,
@@ -598,7 +608,8 @@
       if(valid){
         // 转化
         placementForm.placementData.forEach(element => {
-          element.amount = parseFloat(element.amount)
+          element.origin_amount = parseFloat(element.origin_amount)
+          element.amount = parseFloat(element.amount.toFixed(2))
         });
         let param={
           contract_register_id:contractInfo.form.contract_register_id,
@@ -668,13 +679,12 @@
   }
   // 金额输入框失去焦点
   const iandPAmountBlur=(row)=>{
-    if(row.amount){
-      // console.log(parseFloat(row.amount).toFixed(2));
-      row.amount= Math.round(parseFloat(row.amount)*100)/100
+    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);
-    // console.log(row.amount);
+    // console.log(row.origin_amount);
   }
   // --------------------------------
   onMounted(()=>{
@@ -714,6 +724,7 @@
     // 权限通过
     getSellerListFun()
     getServiceListFun()
+    getCurrencyListFun()
   }
   if(contractInfo.form.contract_register_id){
     //请求详情接口
@@ -724,7 +735,7 @@
         contract_code:res.data.contract_code,
         company_name:res.data.company_name,
         isNew:res.data.isNew,
-        currencyId:res.data.currencyId,
+        currency_unit:res.data.currency_unit,
         seller_id:res.data.seller_id,
         seller_name:res.data.seller_name,
         contract_status:res.data.contract_status,
@@ -741,6 +752,20 @@
         remark:res.data.remark,
         contract_source:res.data.contract_source,
       }
+      rmbRate.value=res.data.rmb_rate
+      if(haveGetCurrencyList.value){
+        // 拿到货币列表后才去取单位
+        contractInfo.currencyUnit=currencyList.value.find(item => item.code==res.data.currency_unit)?.unit_name
+      }else{
+        // 轮询等拿到货币列表后去取单位,并清除轮询定时器
+        const timer = setInterval(()=>{
+          if(haveGetCurrencyList.value){
+            contractInfo.currencyUnit=currencyList.value.find(item => item.code==res.data.currency_unit)?.unit_name
+            clearInterval(timer)
+          }
+        },10)
+      }
+
       res.data.service_list.map(item =>{
           // 小套餐
           if(item.service_template_id==2){
@@ -773,6 +798,7 @@
         res.data.invoice_list.map(item=>{
           invoiceForm.invoiceData.push({
             invoice_id:item.contract_invoice_id,
+            origin_amount:item.origin_amount,
             amount:item.amount,
             invoice_date:item.invoice_time,
             remark:item.remark,
@@ -782,6 +808,7 @@
         // 添加一行空的
         if(contractInfo.operationtype=='invoice'){
           invoiceForm.invoiceData.push({                   
+            origin_amount:'',
             amount:'',
             invoice_date:'',
             remark:'',
@@ -797,6 +824,7 @@
         res.data.payment_list.map(item=>{
           placementForm.placementData.push({
             invoice_id:item.contract_invoice_id,
+            origin_amount:item.origin_amount,
             amount:item.amount,
             invoice_date:item.invoice_time,
             remark:item.remark
@@ -805,6 +833,7 @@
         // 添加一行空的
         if(contractInfo.operationtype=='placement'){
           placementForm.placementData.push({
+            origin_amount:'',
             amount:'',
             invoice_date:'',
             remark:'',
@@ -867,8 +896,8 @@
                       prop="contract_amount">
                         <el-input v-model.trim="contractInfo.form.contract_amount"
                         placeholder="请输入合同金额" />
-                        <el-select v-model="contractInfo.form.currencyId" placeholder="请选择货币类型" style="margin-left: 20px;">
-                          <el-option v-for="item in currencyList" :key="item.currencyId" :label="item.currencyName" :value="item.currencyId">
+                        <el-select v-model="contractInfo.form.currency_unit" placeholder="请选择货币类型" style="margin-left: 20px;">
+                          <el-option v-for="item in currencyList" :key="item.code" :label="item.name" :value="item.code">
                           </el-option>
                         </el-select>
                       </el-form-item>
@@ -1013,11 +1042,11 @@
                     <div class="invoice-payment-title">
                       <div style="margin-right: 30px;">已开票金额:
                         <span class="invoice-payment-money">{{moneyFormatter(contractInfo.moneyData?.haveInvoiceMoney)}}</span>
-                        {{ contractInfo.currencyUnit }}
+                        {{ contractInfo.currencyUnit }}
                       </div>
                       <div>剩余开票金额:
                         <span class="invoice-payment-money">{{moneyFormatter(contractInfo.moneyData?.waitInvoiceMoney)}}</span>
-                        {{ contractInfo.currencyUnit }}
+                        {{ contractInfo.currencyUnit }}
                       </div>
                       <el-button type="primary" style="margin: 0 0 0 auto;" @click="addTableRow('invoice')" 
                       v-if="contractInfo.operationtype=='invoice'&&invoiceForm.invoiceData.length==0">添加开票信息</el-button>
@@ -1029,23 +1058,23 @@
                             {{$index+1}}
                           </template>
                         </el-table-column>
-                        <el-table-column label="开票金额" width="150" show-overflow-tooltip  align="center" prop="amount">
+                        <el-table-column label="开票金额" width="150" show-overflow-tooltip  align="center" prop="origin_amount">
                           <template #header>
                             <span style="color: var(--dangerColor);">*</span>开票金额
                           </template>
                           <template #default="{row,$index}">
-                            <el-form-item :prop="`invoiceData.${$index}.amount`" :show-message="false" v-if="!row.invoice_id"
+                            <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+'amount'" style="cursor: pointer;" 
-                              :style="{color:row.amount?'var(--secondaryTextColor)':'var(--hitTextColorOne)'}"
+                              <label :for="'invoice'+$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.amount ? parseFloat(row.amount).toFixed(2): '单击此处输入金额'}}
+                                {{ row.origin_amount ? parseFloat(row.origin_amount).toFixed(2): '单击此处输入金额'}}
                               </label>
-                              <el-input v-model.trim="row.amount" :id="'invoice'+$index+'amount'" style="width: 124px;" 
+                              <el-input v-model.trim="row.origin_amount" :id="'invoice'+$index+'origin_amount'" style="width: 124px;" 
                               v-show="row.amountDomType=='input'" @blur="iandPAmountBlur(row)"
                                 placeholder="请输入金额" @input="(e)=>moneyChange('invoice',e,$index)"></el-input>
                             </el-form-item>
-                            <span  v-else>{{ row.amount.toFixed(2)}}</span>
+                            <span  v-else>{{ row.origin_amount.toFixed(2)}}</span>
                           </template>
                         </el-table-column>
                         <el-table-column label="换算金额(元)" show-overflow-tooltip width="200" align="center" prop="amount">
@@ -1130,11 +1159,11 @@
                       <div style="margin-right: 30px;">
                         已到款金额:
                         <span class="invoice-payment-money">{{moneyFormatter(contractInfo.moneyData.havePlacementMoney)}}</span>
-                        {{ contractInfo.currencyUnit }}
+                        {{ contractInfo.currencyUnit }}
                       </div>
                       <div>剩余到款金额:
                         <span class="invoice-payment-money">{{moneyFormatter(contractInfo.moneyData.waitPlacementMoney)}}</span>
-                        {{ contractInfo.currencyUnit }}
+                        {{ contractInfo.currencyUnit }}
                       </div>
                       <el-button type="primary" style="margin: 0 0 0 auto;" @click="addTableRow('placement')" 
                       v-if="contractInfo.operationtype=='placement'&&placementForm.placementData.length==0">添加到款信息</el-button>
@@ -1146,23 +1175,23 @@
                             {{$index+1}}
                           </template>
                         </el-table-column>
-                        <el-table-column label="到款金额" width="150" align="center" prop="amount">
+                        <el-table-column label="到款金额" width="150" align="center" prop="origin_amount">
                           <template #header>
                             <span style="color: var(--dangerColor);">*</span>到款金额
                           </template>
                           <template #default="{row,$index}">
-                            <el-form-item :prop="`placementData.${$index}.amount`" :show-message="false" v-if="!row.invoice_id"
+                            <el-form-item :prop="`placementData.${$index}.origin_amount`" :show-message="false" v-if="!row.invoice_id"
                             :rules="{required:true,message:()=>{ ElMessage.error('到款金额不能为空')},trigger:'blur'}">
-                              <label :for="'placement'+$index+'amount'" style="cursor: pointer;" 
-                              :style="{color:row.amount?'var(--secondaryTextColor)':'var(--hitTextColorOne)'}"
+                              <label :for="'placement'+$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.amount ? parseFloat(row.amount).toFixed(2): '单击此处输入金额'}}
+                                {{ row.origin_amount ? parseFloat(row.origin_amount).toFixed(2): '单击此处输入金额'}}
                               </label>
-                              <el-input v-model.trim="row.amount" :id="'placement'+$index+'amount'" 
+                              <el-input v-model.trim="row.origin_amount" :id="'placement'+$index+'origin_amount'" 
                               style="width: 124px;" v-show="row.amountDomType=='input'" @blur="iandPAmountBlur(row)"
                               placeholder="请输入金额" @input="(e)=>moneyChange('placement',e,$index)"></el-input>
                             </el-form-item>
-                            <span  v-else>{{ row.amount.toFixed(2)}}</span>
+                            <span  v-else>{{ row.origin_amount.toFixed(2)}}</span>
                           </template>
                         </el-table-column>
                         <el-table-column label="换算金额(元)" width="200" align="center" prop="amount">

+ 4 - 4
src/views/financialManagement/financialList.vue

@@ -267,7 +267,7 @@ const statusArray=[{id:1,label:"进行中"},{id:2,label:"已完成"}]
               v-if="financial.tabelColumnShowArr.includes('sign_date')"></el-table-column>
               <el-table-column label="合同状态" align="center" width="90" prop="contract_status">
                 <template #default="{row}">
-                  {{contractStatusArray[row.contract_status-1].label}}
+                  {{contractStatusArray[row.contract_status-1]?.label}}
                 </template>
               </el-table-column>
               <el-table-column label="已开票金额" align="center" prop="invoiced_amount" width="100"
@@ -359,8 +359,8 @@ const statusArray=[{id:1,label:"进行中"},{id:2,label:"已完成"}]
           <el-table :data="dialog.invoiceDetailList" border max-height="600px">
             <el-table-column label="开票金额" prop="amount" align="center"></el-table-column>
             <el-table-column label="开票日" prop="invoice_time" align="center"></el-table-column>
-            <el-table-column label="销售" align="center">张三</el-table-column>
-            <el-table-column label="备注" align="center" show-overflow-tooltip  >备注</el-table-column>
+            <el-table-column label="销售" align="center" prop="seller_name"></el-table-column>
+            <el-table-column label="备注" align="center" show-overflow-tooltip prop="remark" ></el-table-column>
           </el-table>
         </el-dialog>
         <!-- 到款详情弹窗 -->
@@ -368,7 +368,7 @@ const statusArray=[{id:1,label:"进行中"},{id:2,label:"已完成"}]
           <el-table :data="dialog.refundDetailList" border max-height="600px">
             <el-table-column label="到款金额" prop="amount" align="center"></el-table-column>
             <el-table-column label="到款日" prop="invoice_time" align="center"></el-table-column>
-            <el-table-column label="备注" align="center" show-overflow-tooltip  >备注</el-table-column>
+            <el-table-column label="备注" align="center" show-overflow-tooltip prop="remark" ></el-table-column>
           </el-table>
         </el-dialog>
         <!-- 更改合同状态弹窗 -->