Browse Source

采购报价单-增加折扣/折后单价/折后金额字段,增加统一设置子表折扣按钮

jingbb 2 months ago
parent
commit
c1a4c2e5cd

+ 30 - 10
src/views/purchase/purchaseQuotationFrm/PurchaseQuotationForm.data.ts

@@ -272,19 +272,31 @@ export const PuechaseQuotationFormProductColumns: JVxeColumn[] = [
         return cellValue
       },
     },
+    {
+      title: '折扣(discount)',
+      key: 'discount',
+      type: JVxeTypes.inputNumber,
+      placeholder: '请输入${title}',
+      defaultValue:'',  
+      width:"200px",
+      validateRules: [{ required: true, message: '' }],
+    },
     {
       title: '单价(price)',
-      key: 'taxPrice',
+      key: 'taxPriceOriginal',
       type: JVxeTypes.inputNumber,
       placeholder: '请输入${title}',
       defaultValue:'',  
       width:"200px",
       validateRules: [{ required: true, message: '' }],
-      formatter({ cellValue, row, column }) {
-        row.taxAmount = Number(row.quantity)*Number(row.taxPrice)
-        row.taxAmount = isNaN( row.taxAmount)?'':Number(row.taxAmount).toFixed(4)
-        return cellValue
-      },
+    },
+    {
+      title: '折后单价(discount price)',
+      key: 'taxPrice',
+      type: JVxeTypes.normal,
+      placeholder: '请输入${title}',
+      defaultValue:'',  
+      width:"200px",
     },
     {
       title: '上次报价(last price)',
@@ -296,15 +308,23 @@ export const PuechaseQuotationFormProductColumns: JVxeColumn[] = [
     },
     {
       title: '金额(amount)',
+      key: 'taxAmountOriginal',
+      type: JVxeTypes.normal,
+      placeholder: '请输入${title}',
+      defaultValue:'',  
+      width:"200px",
+    },
+    {
+      title: '折后金额(discount amount)',
       key: 'taxAmount',
       type: JVxeTypes.normal,
       placeholder: '请输入${title}',
       defaultValue:'',  
       width:"200px",
-      formatter({ cellValue, row, column }) {
-        row.taxAmount = isNaN( row.taxAmount)?0:row.taxAmount
-        return cellValue
-      },
+      // formatter({ cellValue, row, column }) {
+      //   row.taxAmount = isNaN( row.taxAmount)?0:row.taxAmount
+      //   return cellValue
+      // },
     },
     {
       title: '备注(note)',

+ 46 - 2
src/views/purchase/purchaseQuotationFrm/components/PurchaseQuotationFormForm.vue

@@ -211,6 +211,7 @@
           选择供应商询价单(select supplier inquiry form)</a-button
         >
         <a-button type="primary" @click="selectProducts" style="margin-right: 1%; margin-bottom: 1%"> 选择产品(select product)</a-button>
+        <a-button type="primary" @click="setDiscountForSonList" style="margin-right: 1%; margin-bottom: 1%"> 设置折扣(set discount)</a-button>
         <j-vxe-table
           :keep-source="true"
           resizable
@@ -223,6 +224,7 @@
           :rowNumber="true"
           :rowSelection="true"
           asyncRemove
+          @value-change="changeValues"
         >
           <template #action="props">
             <a-popconfirm title="确定删除吗?" @confirm="handleDelete1(props)">
@@ -254,6 +256,7 @@
     <SelectPrpductModal ref="SelectPrpductModalRef" @select-product="addProduct" />
     <SelectProjectModal ref="SelectProjectModalRef" @select-project="addProject" />
     <SelectSupplierInquiryModal ref="SelectSupplierInquiryModalRef" @select-customer-inquiry="addProductFromCustomer" />
+    <SetSonList ref="SetSonListRef" @success="setSonListFiled"></SetSonList>
   </a-spin>
 </template>
 
@@ -279,6 +282,7 @@
   import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
   import { JDictSelectTag,ApiSelect,JSelect } from '/@/components/Form';
   import JSelectInput from '/@/components/Form/src/jeecg/components/JSelectInput.vue';
+  import SetSonList from './SetSonList.vue';
   import { Form, message } from 'ant-design-vue';
   import moment from 'moment';
   const useForm = Form.useForm;
@@ -295,7 +299,8 @@
       JSelectInput,
       SelectSupplierInquiryModal,
       ApiSelect,
-      JSelect
+      JSelect,
+      SetSonList
     },
     props: {
       formDisabled: {
@@ -310,6 +315,7 @@
       const loading = ref(false);
       const formRef = ref();
       var showField = ref('currency+name');
+      var SetSonListRef =ref();
       var SelectPrpductModalRef = ref();
       var SelectProjectModalRef = ref();
       var SelectSupplierInquiryModalRef = ref();
@@ -608,6 +614,40 @@
             formData.suppilerName = ''
           }        
       }
+      function changeValues(prop){
+       if (prop.col.key == 'quantity'||prop.col.key == 'taxPriceOriginal') {
+          if (prop.row.quantity||prop.row.taxPriceOriginal) {
+            var num = Number(prop.row.quantity) * Number(prop.row.taxPriceOriginal)
+            prop.row.taxAmountOriginal = isNaN(num) ? '' : num.toFixed(2);
+            prop.row.discount = isNaN( prop.row.discount)?0:Number( prop.row.discount)
+            prop.row.taxPrice =  (Number(prop.row.taxPriceOriginal)*(1-prop.row.discount/100)).toFixed(2)
+            prop.row.taxAmount =  (Number(prop.row.taxPrice)*Number(prop.row.quantity)).toFixed(2)
+          }
+        }
+        if (prop.col.key == 'discount') {
+          if (prop.row.discount||prop.row.taxPriceOriginal||prop.row.quantity) {
+            prop.row.taxPrice =  (Number(prop.row.taxPriceOriginal)*(1-prop.row.discount/100)).toFixed(2)
+            prop.row.taxAmount =  (Number(prop.row.taxPrice)*Number(prop.row.quantity)).toFixed(2)
+          } 
+        }
+      }
+      function setDiscountForSonList(){
+        SetSonListRef.value.getTable()
+      }
+      function setSonListFiled(value){
+        var xTable = (PuechaseQuotationFormProductTableRef.value!.getXTable()).data
+        if(xTable.length>0){
+          xTable.map(item=>{
+            item.discount = isNaN(value.numericalValue)?0:value.numericalValue
+            if (item.taxAmountOriginal) {
+              item.taxPrice =  (Number(item.taxPriceOriginal)*(1-item.discount/100)).toFixed(2)
+              item.taxAmount =  (Number(item.taxPrice)*Number(item.quantity)).toFixed(2)
+
+            }
+          })
+        }
+        PuechaseQuotationFormProductTable.dataSource =[...xTable]
+      }
       return {
         PuechaseQuotationFormShipTableRef,
         PuechaseQuotationFormShipTable,
@@ -646,7 +686,11 @@
         changeSupplier,
         notAllowEdit,
         ClassList,
-        showField
+        showField,
+        changeValues,
+        setDiscountForSonList,
+        SetSonListRef,
+        setSonListFiled
       };
     },
   });

+ 74 - 0
src/views/purchase/purchaseQuotationFrm/components/SetSonList.vue

@@ -0,0 +1,74 @@
+<template>
+    <a-modal
+      title="设置折扣字段(Set discount)"
+      width="45%"
+      :visible="visible"
+      :maskClosable="false"
+      switchFullscreen
+      @ok = "handleOk"
+      @cancel="handleCancel">
+        <div>
+          <a-card  :body-style="{ padding: '10px' }" :bordered="false" style="margin: 10px;">
+            <div class="table-page-search-wrapper">
+             <a-form :model="form" :label-col="labelCol" :wrapper-col="wrapperCol"  :rules="rules" ref="formRef">
+                <a-row :gutter="24">
+                    <a-col :md="24" :sm="24">
+                        <a-form-item label="数值(numerical value)" name="numericalValue">
+                            <a-input-number placeholder="请输入" v-model:value="form.numericalValue" style="width: 100%;"></a-input-number>
+                        </a-form-item>
+                    </a-col>
+                </a-row>
+            </a-form>
+           </div>
+        </a-card>
+      </div>
+    </a-modal>
+</template>
+<script lang="ts" setup>
+    import {ref, reactive } from 'vue';
+    var visible = ref(false);
+    const emit = defineEmits([ 'success']); //定义emit
+    var form = ref({
+        numericalValue:''
+    });
+    var formRef = ref();
+    const labelCol = ref({
+        xs: { span: 24 },
+        sm: { span: 5 },
+    });
+    const wrapperCol = ref({
+        xs: { span: 24 },
+        sm: { span: 19 },
+    });
+    const rules = {
+      numericalValue: [{required: true,message: '请输入数值',},],
+    }
+    function handleOk(){
+        formRef.value .validate().then(() => {
+              emit('success',form.value)
+              handleCancel()
+          }).catch((error) => {
+            console.log('error', error);
+          });
+    }
+    function handleCancel(){
+        visible.value = false;
+        form.value.numericalValue=''
+        formRef.value.resetFields();
+    }
+    function getTable(){
+        visible.value = true
+    }
+    defineExpose({
+        getTable
+    });
+</script>
+<style scoped lang="less">
+/deep/.ant-form-item{
+    margin-bottom: 8px !important;
+}
+// /deep/.ant-table-wrapper .ant-table-thead > tr > th, .ant-table-wrapper .ant-table-thead > tr > td{
+//     padding: 8px !important;
+// }
+
+</style>