Explorar o código

feat(inventoryTable): 添加报价方式和折让比例功能

liujt hai 5 meses
pai
achega
788907283f

+ 137 - 8
src/BIZComponents/inventoryTable.vue

@@ -710,6 +710,55 @@
           </el-input>
         </el-form-item>
       </template>
+
+      <template v-slot:quoteWay="scope">
+        <el-form-item prop="quoteWay">
+          <el-select
+            v-model="scope.row.quoteWay"
+            clearable
+            filterable
+          >
+            <el-option
+              v-for="i in quoteTypeOp"
+              :key="i.value"
+              :value="i.value"
+              :label="i.label"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+      </template>
+      <template v-slot:headerQuoteWay="{ column }">
+        <span class="is-required">{{ column.label }}</span>
+      </template>
+
+      <template v-slot:discountRatio="scope">
+        <el-form-item
+          :prop="'datasource.' + scope.$index + '.discountRatio'"
+          :rules="{
+            required: isDiscount == 1 ? true : false,
+            message: '请输入折让比例',
+            trigger: 'change'
+          }"
+        >
+          <el-input
+            v-model="scope.row.discountRatio"
+            placeholder="请输入"
+            type="number"
+            :min="0"
+            :max="100"
+            :disabled="quoteType === 2"
+            @input="getDiscountRatioPrice(scope.row)"
+          >
+            <template slot="append">%</template>
+          </el-input>
+        </el-form-item>
+      </template>
+
+      <template v-slot:headerDiscountRatio="{ column }">
+        <span :class="isDiscount ? 'is-required' : ''">{{
+          column.label
+        }}</span>
+      </template>
       <!-- <template v-slot:saleUnit="scope">
         <el-form-item
           :prop="'datasource.' + scope.$index + '.' + countObj.unitIdKey"
@@ -927,7 +976,7 @@
   import ProductionVersion from '@/components/ProductionVersion2/index.vue';
   import { getInventoryTotalAPI } from '@/api/wms';
   import { pricingWayList, lbjtList } from '@/enum/dict.js';
-  import { changeCount, getAllPrice } from '@/BIZComponents/setProduct.js';
+  import { changeCount, getAllPrice, getAllDiscountPrice } from '@/BIZComponents/setProduct.js';
   import { contactQueryByCategoryIdsAPI } from '@/api/saleManage/contact';
   import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
   import timeDialog from '@/components/timeDialog/index.vue';
@@ -938,7 +987,7 @@
   import tabMixins from '@/mixins/tableColumnsMixin';
   import commodityPriceListDialog from '@/views/commodityManagement/commodityPriceList/components/commodityPriceListDialog.vue';
   const dayjs = require('dayjs');
-  import { levelList } from '@/enum/dict.js';
+  import { levelList, quoteTypeOp } from '@/enum/dict.js';
   import {
     getGoodsPriceByCondition,
     getGoodsByCategoryId
@@ -1116,7 +1165,9 @@
         extraTax: '',
         quotationSubtotalTax: '',
         // 新增未税小记字段
-        quotationSubtotalBeforeTax: ''
+        quotationSubtotalBeforeTax: '',
+        quoteWay: '',
+        discountRatio: 100
       };
       return {
         levelList,
@@ -1138,7 +1189,8 @@
           { label: '分批到货', value: 2 }
         ],
         columnsVersion: 1,
-        selection: []
+        selection: [],
+        quoteTypeOp
       };
     },
     computed: {
@@ -1229,7 +1281,15 @@
             slot: 'saleCount',
             headerSlot: this.isTotalCount ? 'headerTotalCount' : '',
             align: 'center'
-          }
+          },
+          {
+            width: 250,
+            prop: 'quoteWay',
+            label: '报价方式',
+            slot: 'quoteWay',
+            headerSlot: 'headerQuoteWay',
+            align: 'center'
+          },
         ];
 
         // 当quoteType为2时添加生产加工相关列
@@ -1419,6 +1479,15 @@
 
             isNone: this.quoteType === 2
           },
+          {
+            width: 160,
+            prop: 'discountRatio',
+            label: '折让比例',
+            align: 'center',
+            isNone: !this.isDiscount,
+            slot: 'discountRatio',
+            headerSlot: 'headerDiscountRatio'
+          },
           {
             width: 160,
             prop: 'discountSinglePrice',
@@ -1933,11 +2002,12 @@
 
       changeAll() {
         this.allPrice = getAllPrice(this.form.datasource) || 0;
+        this.form.discountTotalPrice = getAllDiscountPrice(this.form.datasource) || 0;
         if (this.isDiscountTotalPrice) {
-          this.form.discountTotalPrice = this.allPrice;
-          this.$emit('setDiscountTotalPrice', this.allPrice);
+          this.form.discountTotalPrice = this.form.discountTotalPrice;
+          this.$emit('setDiscountTotalPrice', this.form.discountTotalPrice);
         }
-        this.$emit('setCountAmount', this.allPrice);
+        this.$emit('setCountAmount', this.allPrice, this.form.discountTotalPrice);
       },
 
       setCustomerMark(customerMark) {
@@ -1947,6 +2017,42 @@
         });
       },
 
+      // 计算折让单价,折让总价
+      getDiscountRatioPrice(row) {
+        this.form.datasource.forEach((item, index) => {
+          if (item.singlePrice && item.discountRatio) {
+            this.$set(
+              this.form.datasource[index],
+              'discountSinglePrice',
+              parseFloat(
+                (item.singlePrice * (item.discountRatio / 100)).toFixed(2)
+              )
+            );
+
+            this.$set(
+              this.form.datasource[index],
+              'discountTotalPrice',
+              parseFloat(
+                (item.totalPrice * (item.discountRatio / 100)).toFixed(2)
+              )
+            );
+            
+          } else {
+            this.$set(this.form.datasource[index], 'discountSinglePrice', 0);
+            this.$set(this.form.datasource[index], 'discountTotalPrice', 0);
+          }
+          this.$set(
+            this.form,
+            'discountTotalPrice',
+            this.form.datasource.reduce(
+              (acc, cur) => acc + Number(cur.discountTotalPrice || 0),
+              0
+            )
+          );
+          this.changeAll();
+        });
+      },
+
       //计算不含税单价
       getNotaxSinglePrice() {
         this.form.datasource.forEach((item, index) => {
@@ -1963,6 +2069,7 @@
           }
         });
       },
+
       //设置优惠后总金额修改产品单价
       discountInputByOrder(val) {
         this.form.discountTotalPrice = val;
@@ -1978,6 +2085,11 @@
             'discountTotalPrice',
             this.getDiscountTotalPrice(item)
           );
+          this.$set(
+            this.form.datasource[index],
+            'discountRatio',
+            this.getDiscountRatio(item)
+          );
         });
         this.$emit('setDiscountTotalPrice', val);
 
@@ -1999,6 +2111,20 @@
         return isNaN(num) ? '' : num;
       },
 
+      //获取折让比例
+      getDiscountRatio(row) {
+        let num = 100;
+        // if(Number(row.discountRatio)) {
+        //   num =
+        //   ((Number(this.form.discountTotalPrice) / Number(this.allPrice)) * Number(row.discountRatio)).toFixed(2);
+        //   console.log('折让比例', row.discountRatio, num, (Number(this.form.discountTotalPrice) / Number(this.allPrice)))
+        // } else {
+          num = ((Number(this.form.discountTotalPrice) / Number(this.allPrice)) * 100).toFixed(2);
+        // }
+        
+        return isNaN(num) ? '' : num;
+      },
+
       //获取折让合计
       getDiscountTotalPrice(row) {
         let num = 0;
@@ -2057,6 +2183,7 @@
             );
             item['customerMark'] = item.customerMark || this.customerMark;
             item['arrivalWay'] = item.arrivalWay || 1;
+            item.discountRatio = Number(item.discountRatio) || 100; 
           });
           this.form.datasource = productList;
 
@@ -2213,8 +2340,10 @@
             this.$set(parasm, 'taxRate', item.taxRate);
             this.$set(parasm, 'discountSinglePrice', item.singlePrice);
             this.$set(parasm, 'totalCount', '');
+            this.$set(parasm, 'discountRatio', item.discountRatio);
           } else {
             this.$set(parasm, 'singlePrice', parasm.singlePrice || 0);
+            this.$set(parasm, 'discountRatio', parasm.discountRatio || 100);
           }
 
           // 初始化生产加工特有字段及未税小记

+ 8 - 137
src/BIZComponents/inventoryTableNew.vue → src/BIZComponents/inventoryTableOld.vue

@@ -710,55 +710,6 @@
           </el-input>
         </el-form-item>
       </template>
-
-      <template v-slot:quoteWay="scope">
-        <el-form-item prop="quoteWay">
-          <el-select
-            v-model="scope.row.quoteWay"
-            clearable
-            filterable
-          >
-            <el-option
-              v-for="i in quoteTypeOp"
-              :key="i.value"
-              :value="i.value"
-              :label="i.label"
-            ></el-option>
-          </el-select>
-        </el-form-item>
-      </template>
-      <template v-slot:headerQuoteWay="{ column }">
-        <span class="is-required">{{ column.label }}</span>
-      </template>
-
-      <template v-slot:discountRatio="scope">
-        <el-form-item
-          :prop="'datasource.' + scope.$index + '.discountRatio'"
-          :rules="{
-            required: isDiscount == 1 ? true : false,
-            message: '请输入折让比例',
-            trigger: 'change'
-          }"
-        >
-          <el-input
-            v-model="scope.row.discountRatio"
-            placeholder="请输入"
-            type="number"
-            :min="0"
-            :max="100"
-            :disabled="quoteType === 2"
-            @input="getDiscountRatioPrice(scope.row)"
-          >
-            <template slot="append">%</template>
-          </el-input>
-        </el-form-item>
-      </template>
-
-      <template v-slot:headerDiscountRatio="{ column }">
-        <span :class="isDiscount ? 'is-required' : ''">{{
-          column.label
-        }}</span>
-      </template>
       <!-- <template v-slot:saleUnit="scope">
         <el-form-item
           :prop="'datasource.' + scope.$index + '.' + countObj.unitIdKey"
@@ -976,7 +927,7 @@
   import ProductionVersion from '@/components/ProductionVersion2/index.vue';
   import { getInventoryTotalAPI } from '@/api/wms';
   import { pricingWayList, lbjtList } from '@/enum/dict.js';
-  import { changeCount, getAllPrice, getAllDiscountPrice } from '@/BIZComponents/setProduct.js';
+  import { changeCount, getAllPrice } from '@/BIZComponents/setProduct.js';
   import { contactQueryByCategoryIdsAPI } from '@/api/saleManage/contact';
   import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
   import timeDialog from '@/components/timeDialog/index.vue';
@@ -987,7 +938,7 @@
   import tabMixins from '@/mixins/tableColumnsMixin';
   import commodityPriceListDialog from '@/views/commodityManagement/commodityPriceList/components/commodityPriceListDialog.vue';
   const dayjs = require('dayjs');
-  import { levelList, quoteTypeOp } from '@/enum/dict.js';
+  import { levelList } from '@/enum/dict.js';
   import {
     getGoodsPriceByCondition,
     getGoodsByCategoryId
@@ -1165,9 +1116,7 @@
         extraTax: '',
         quotationSubtotalTax: '',
         // 新增未税小记字段
-        quotationSubtotalBeforeTax: '',
-        quoteWay: '',
-        discountRatio: 100
+        quotationSubtotalBeforeTax: ''
       };
       return {
         levelList,
@@ -1189,8 +1138,7 @@
           { label: '分批到货', value: 2 }
         ],
         columnsVersion: 1,
-        selection: [],
-        quoteTypeOp
+        selection: []
       };
     },
     computed: {
@@ -1281,15 +1229,7 @@
             slot: 'saleCount',
             headerSlot: this.isTotalCount ? 'headerTotalCount' : '',
             align: 'center'
-          },
-          {
-            width: 250,
-            prop: 'quoteWay',
-            label: '报价方式',
-            slot: 'quoteWay',
-            headerSlot: 'headerQuoteWay',
-            align: 'center'
-          },
+          }
         ];
 
         // 当quoteType为2时添加生产加工相关列
@@ -1479,15 +1419,6 @@
 
             isNone: this.quoteType === 2
           },
-          {
-            width: 160,
-            prop: 'discountRatio',
-            label: '折让比例',
-            align: 'center',
-            isNone: !this.isDiscount,
-            slot: 'discountRatio',
-            headerSlot: 'headerDiscountRatio'
-          },
           {
             width: 160,
             prop: 'discountSinglePrice',
@@ -2002,12 +1933,11 @@
 
       changeAll() {
         this.allPrice = getAllPrice(this.form.datasource) || 0;
-        this.form.discountTotalPrice = getAllDiscountPrice(this.form.datasource) || 0;
         if (this.isDiscountTotalPrice) {
-          this.form.discountTotalPrice = this.form.discountTotalPrice;
-          this.$emit('setDiscountTotalPrice', this.form.discountTotalPrice);
+          this.form.discountTotalPrice = this.allPrice;
+          this.$emit('setDiscountTotalPrice', this.allPrice);
         }
-        this.$emit('setCountAmount', this.allPrice, this.form.discountTotalPrice);
+        this.$emit('setCountAmount', this.allPrice);
       },
 
       setCustomerMark(customerMark) {
@@ -2017,42 +1947,6 @@
         });
       },
 
-      // 计算折让单价,折让总价
-      getDiscountRatioPrice(row) {
-        this.form.datasource.forEach((item, index) => {
-          if (item.singlePrice && item.discountRatio) {
-            this.$set(
-              this.form.datasource[index],
-              'discountSinglePrice',
-              parseFloat(
-                (item.singlePrice * (item.discountRatio / 100)).toFixed(2)
-              )
-            );
-
-            this.$set(
-              this.form.datasource[index],
-              'discountTotalPrice',
-              parseFloat(
-                (item.totalPrice * (item.discountRatio / 100)).toFixed(2)
-              )
-            );
-            
-          } else {
-            this.$set(this.form.datasource[index], 'discountSinglePrice', 0);
-            this.$set(this.form.datasource[index], 'discountTotalPrice', 0);
-          }
-          this.$set(
-            this.form,
-            'discountTotalPrice',
-            this.form.datasource.reduce(
-              (acc, cur) => acc + Number(cur.discountTotalPrice || 0),
-              0
-            )
-          );
-          this.changeAll();
-        });
-      },
-
       //计算不含税单价
       getNotaxSinglePrice() {
         this.form.datasource.forEach((item, index) => {
@@ -2069,7 +1963,6 @@
           }
         });
       },
-
       //设置优惠后总金额修改产品单价
       discountInputByOrder(val) {
         this.form.discountTotalPrice = val;
@@ -2085,11 +1978,6 @@
             'discountTotalPrice',
             this.getDiscountTotalPrice(item)
           );
-          this.$set(
-            this.form.datasource[index],
-            'discountRatio',
-            this.getDiscountRatio(item)
-          );
         });
         this.$emit('setDiscountTotalPrice', val);
 
@@ -2111,20 +1999,6 @@
         return isNaN(num) ? '' : num;
       },
 
-      //获取折让比例
-      getDiscountRatio(row) {
-        let num = 100;
-        // if(Number(row.discountRatio)) {
-        //   num =
-        //   ((Number(this.form.discountTotalPrice) / Number(this.allPrice)) * Number(row.discountRatio)).toFixed(2);
-        //   console.log('折让比例', row.discountRatio, num, (Number(this.form.discountTotalPrice) / Number(this.allPrice)))
-        // } else {
-          num = ((Number(this.form.discountTotalPrice) / Number(this.allPrice)) * 100).toFixed(2);
-        // }
-        
-        return isNaN(num) ? '' : num;
-      },
-
       //获取折让合计
       getDiscountTotalPrice(row) {
         let num = 0;
@@ -2183,7 +2057,6 @@
             );
             item['customerMark'] = item.customerMark || this.customerMark;
             item['arrivalWay'] = item.arrivalWay || 1;
-            item.discountRatio = Number(item.discountRatio) || 100; 
           });
           this.form.datasource = productList;
 
@@ -2340,10 +2213,8 @@
             this.$set(parasm, 'taxRate', item.taxRate);
             this.$set(parasm, 'discountSinglePrice', item.singlePrice);
             this.$set(parasm, 'totalCount', '');
-            this.$set(parasm, 'discountRatio', item.discountRatio);
           } else {
             this.$set(parasm, 'singlePrice', parasm.singlePrice || 0);
-            this.$set(parasm, 'discountRatio', parasm.discountRatio || 100);
           }
 
           // 初始化生产加工特有字段及未税小记

+ 1 - 1
src/views/contractManage/contractBook/components/addDialogNew.vue

@@ -776,7 +776,7 @@
   import { emailReg, telReg } from 'ele-admin';
   import { acceptUnpackoptions } from '@/enum/dict';
   import inventoryTable from './inventoryTable.vue';
-  import inventoryTable1 from '@/BIZComponents/inventoryTableNew.vue';
+  import inventoryTable1 from '@/BIZComponents/inventoryTable.vue';
   import inquiryList from './inquiryList.vue';
   import quotationList from './quotationList.vue';
   // import fileMain from '@/components/addDoc/index';

+ 1 - 1
src/views/saleManage/saleOrder/components/addDialogNew.vue

@@ -721,7 +721,7 @@
 
 <script>
   import { emailReg, numberReg, telReg } from 'ele-admin';
-  import inventoryTable from '@/BIZComponents/inventoryTableNew.vue';
+  import inventoryTable from '@/BIZComponents/inventoryTable.vue';
   import fileUpload from '@/components/upload/fileUpload';
   import dictMixins from '@/mixins/dictMixins';
   import parentList from '@/views/saleManage/contact/components/parentList.vue';