Browse Source

销售订单-计算主表折后金额/子表折后金额折后单价

jingbb 4 months ago
parent
commit
cb6e6d34dd

+ 1 - 1
src/views/saleCode/salesOrder/SaleOrderForm.data.ts

@@ -329,7 +329,7 @@ export const saleOrderProductColumns: JVxeColumn[] = [
     {
       title: '折后金额(converted amount)',
       key: 'discountedAmount',
-      type: JVxeTypes.inputNumber,
+      type: JVxeTypes.normal,
       width:"200px",
       placeholder: '请输入${title}',
       defaultValue:'',

+ 31 - 3
src/views/saleCode/salesOrder/components/SlaeOrderFormForm.vue

@@ -66,7 +66,7 @@
 						</a-col>
 						<a-col :span="12">
 							<a-form-item label="汇率(exchange rate)" v-bind="validateInfos.exchangeRate" id="SaleOrderForm-exchangeRate" name="exchangeRate" :labelCol="formItemLayout.labelCol1" :wrapperCol="formItemLayout.wrapperCol1">
-								<a-input v-model:value="formData.exchangeRate" placeholder="请输入厂家(maker)"  allow-clear ></a-input>
+								<a-input v-model:value="formData.exchangeRate" placeholder="请输入"  allow-clear ></a-input>
 							</a-form-item>
 						</a-col>
 						<a-col :span="12">
@@ -185,6 +185,7 @@
           :rowNumber="true"
           :rowSelection="true"
           asyncRemove
+          @valueChange="changeValues"
           >
             <template #action="props">
               <a-popconfirm title="确定删除吗?" @confirm="handleDelete(props)">
@@ -222,7 +223,7 @@
 </template>
 
 <script lang="ts">
-  import { defineComponent, ref, reactive, computed, toRaw} from 'vue';
+  import { defineComponent, ref, reactive, computed, toRaw,nextTick} from 'vue';
   import { defHttp } from '/@/utils/http/axios';
   import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
   import { querySaleOrderFormShipFormShippTable,ClassList, querySaleOrderFormProductListByMainId, queryDataById, saveOrUpdate,queryVersonHistoryById,querysaleVersonFormShipListByMainId, querySaleVersonProductListByMainId} from '../SaleOrderyForm.api';
@@ -241,6 +242,7 @@
   import { useUserStore } from '/@/store/modules/user';
   import {  ApiSelect, } from '/@/components/Form/index';
   import moment from 'moment';
+import { InputNumberItem } from '/@/layouts/default/setting/components';
   const useForm = Form.useForm;
   export default defineComponent({
     name: "SaleOrderForm",
@@ -514,16 +516,23 @@
         SaleOrderFormShipFormProductTable.dataSource=arrProduct  
       }
       function addQuotation(data){
+        var allDiscountPrice = 0
         data.map(item=>{
           item.model = item.childModel
           item.deliveryTime = formData.deliveryTime
           item.sourceId = 'Quo'+item.childId
           item.taxPrice = item.salePrice
+          item.discountedPrice = (Number(item.taxPrice) *(1-Number(item.discount)/100))
+          item.discountedAmount =Number(item.discountedPrice) *Number(item.quantity)
+          item.discountedPrice =  (item.discountedPrice).toFixed(2)
+          item.discountedAmount = (item.discountedAmount).toFixed(2)
+          allDiscountPrice=allDiscountPrice+Number(item.discountedAmount)
         })
         var arrProduct = data.concat(SaleOrderFormShipFormProductTable.dataSource)
         notAllowEdit.value=true
         SaleOrderFormShipFormProductTable.dataSource=arrProduct  
         formData.sourceCode =data[0].billCode
+        formData.convertedAmount=allDiscountPrice
         if(!formData.sourceCode2&&formData.sourceCode2==''){
           formData.project = data[0].quotationProject
           formData.projectName = data[0].quotationProjectName
@@ -541,15 +550,22 @@
         }
       }
       function addContract(data){
+        var allDiscountPrice = 0
          data.map(item=>{
             item.model = item.childModel
             item.deliveryTime = formData.deliveryTime
             item.sourceId = 'Con'+item.childId
+            item.discountedPrice =Number(item.taxPrice)*(1-Number(item.discount)/100)
+            item.discountedAmount =Number(item.discountedPrice) *Number(item.quantity)
+            item.discountedPrice =  (item.discountedPrice).toFixed(2)
+            item.discountedAmount = (item.discountedAmount).toFixed(2)
+            allDiscountPrice=allDiscountPrice+Number(item.discountedAmount)
           })
           var arrProduct = data.concat(SaleOrderFormShipFormProductTable.dataSource)
           notAllowEdit.value=true
           SaleOrderFormShipFormProductTable.dataSource=arrProduct  
           formData.sourceCode2 =data[0].billCode
+          formData.convertedAmount=allDiscountPrice
           if(!formData.sourceCode&&formData.sourceCode==''){
             formData.project = data[0].quotationProject
             formData.projectName = data[0].quotationProjectName
@@ -602,6 +618,17 @@
         SaleOrderFormShipFormProductTable.dataSource = newArray  
         isSelect()
       }
+      function changeValues(prop){
+        if(prop.col.key=='discountedPrice'&&prop.row.quantity&&prop.row.discountedPrice){
+          prop.row.discountedAmount =  (prop.value*prop.row.quantity).toFixed(2)
+          var arr=SaleOrderFormShipFormProductTableRef.value.getTableData()
+          var allAmount = 0
+          arr.map(item=>{
+            allAmount = allAmount+Number(item.discountedAmount)
+          })
+          formData.convertedAmount=allAmount
+        }
+      }
       /**
        * 值改变事件触发-树控件回调
        * @param key
@@ -648,7 +675,8 @@
         viewAccessory,
         VersionDetail,
         notAllowEdit,
-        ClassList
+        ClassList,
+        changeValues
       }
     }
   });