Sfoglia il codice sorgente

feat(adjustmentNote): 优化冲差单功能并修复若干问题

liujt 7 mesi fa
parent
commit
2a94a26737

+ 31 - 1
src/BIZComponents/inventoryTableDetails.vue

@@ -5,6 +5,7 @@
       :needPage="false"
       :columns="columns"
       :datasource="form.datasource"
+      row-key="id"
       height="350"
       full-height="calc(100vh - 76px)"
       class="time-form"
@@ -293,6 +294,18 @@ export default {
     isProductionRequirements: {
       type: Boolean,
       default: false
+    },
+    // 是否勾选
+    isSelected: {
+      type: Boolean,
+      default: false
+    },
+    // 选中的列表返显
+    selectedIds: {
+      type: Array,
+      default: () => {
+        return [];
+      }
     }
   },
   data() {
@@ -305,7 +318,8 @@ export default {
       },
       columnsVersion: 1,
       // 新增:存储data中的type值,用于控制新增字段显示
-      dataType: null
+      dataType: null,
+      selection: []
     };
   },
   computed: {
@@ -346,6 +360,12 @@ export default {
           columnKey: 'index',
           align: 'center'
         },
+        {
+          width: 45,
+          type: 'selection',
+          columnKey: 'selection',
+          align: 'center'
+        },
         orderColumn,
         {
           width: 280,
@@ -893,6 +913,15 @@ export default {
     this.requestDict('商品价格类型');
   },
   methods: {
+    handleDone() {
+      if(this.isSelected) {
+        // this.$refs.table.setSelectedRowKeys(this.selectedIds);
+      }
+    },
+    handleSelectionChange(val) {
+      console.log(val, 'val');
+      this.$emit('selection-change', val);
+    },
     async getSupplierObj(productList, queryName) {
       try {
         let categoryIds = productList
@@ -981,6 +1010,7 @@ export default {
             data.productList ||
             data.detailList)) ||
         [];
+        console.log(productList, 'productList~~~~~~');
       if (productList) {
         productList.forEach((item) => {
           item.thickNess = item.thickNess || '';

+ 12 - 1
src/api/saleManage/adjustmentNote‌.js

@@ -54,4 +54,15 @@ export async function deleteInfo(id) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}  
+
+/**
+ * 批量删除事项
+ */
+export async function deleteBatch(data) {
+  const res = await request.delete(`/eom/punchSlipOrder/v1/deleteBatch`, {data});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}  

+ 1 - 0
src/components/pop-modal/index.vue

@@ -6,6 +6,7 @@
         :visible.sync="visible"
         custom-class="ele-dialog-form"
         :close-on-click-modal="true"
+        :append-to-body="true"
         @update:visible="updateVisible"
     >
         <div style="padding: 10px 0 20px;">{{content}}</div>

+ 35 - 27
src/views/saleManage/saleOrder/adjustmentNote‌/components/addAdjustDialog.vue

@@ -130,7 +130,7 @@
         ref="inventoryTableDetailsRef"
         :isDiscountTotalPrice="true"
         :isSelected="true"
-        :selectedList="adjustData"
+        :selectedIds="selectIds"
         @selection-change="handleSelectionChange"
       ></inventoryTableDetails>
       <headerTitle
@@ -266,14 +266,12 @@
         sourceNo: '',
         sourceId: '',
         adjustAmount: '',
-        adjustDiscountAmount: ''
+        adjustDiscountAmount: '',
+        detailList: [],
+        originalList: [],
       };
 
       return {
-        orderOption: [],
-        oldProductList: [],
-        detailData: {},
-        acceptUnpackoptions,
         visible: false,
         processSubmitDialogFlag: false,
         title: '',
@@ -282,9 +280,6 @@
         formDef,
         form: copyObj(formDef),
         orderForm: {},
-        tableBankData: [],
-        tableLinkData: [],
-        groupData: [],
         rules: {
           type: [
             { required: true, message: '请选择', trigger: 'change' }
@@ -304,6 +299,7 @@
         orderId: '',
         productList: [],
         adjustData: [],
+        selectIds: [],
       };
     },
     async created() {
@@ -396,20 +392,22 @@
               delete existingItemsMap[item.productCode];
             }
           });
-          
+          this.form.detailList = this.adjustData;
           // 调用putTableValue方法更新表格数据
-          this.$refs.inventoryTableRef.putTableValue(this.adjustData);
+          this.$refs.inventoryTableRef.putTableValue(this.form);
         }
       },
       // 计算总金额和优惠总金额
       setCountAmount(allPrice, diffPriceTotal) {
-        this.form.adjustAmount = this.orderForm.totalAmount + Number(diffPriceTotal);
-        this.form.adjustDiscountAmount = this.orderForm.payAmount + Number(diffPriceTotal);
+        console.log('allPrice~~~', allPrice, diffPriceTotal);
+        this.form.adjustAmount = allPrice;
+        this.form.adjustDiscountAmount = allPrice;
         this.form.differenceAmount = diffPriceTotal;
       },
       // 优惠后总金额修改产品折让单价
       discountInput() {
-        this.$refs.inventoryTableRef.discountInputByOrder(this.form.adjustDiscountAmount, this.form.amount);
+        console.log('this.form.adjustDiscountAmount~~~', this.form.adjustDiscountAmount, this.form.adjustAmount);
+        this.$refs.inventoryTableRef.discountInputByOrder(this.form.adjustDiscountAmount, this.form.adjustAmount);
       },
       //删除产品
       remove(row) {
@@ -429,28 +427,36 @@
 
       //打开新增编辑弹框
       async open(type, row) {
+        console.log(type)
         this.title = type === 'add' ? '新增' : '修改';
         this.isUpdate = type != 'add';
         this.row = row;
         this.visible = true;
-        console.log('row~~~~~~~~~~', row);
+        console.log('row~~~~~~~~~~333', row);
         if (row && row?.id && !this.isUpdate) {
+          console.log('add!!!')
           await this.getSaleOrderDetail(row?.id);
         } else {
+          console.log('update!!!')
           const data = await getInfo(row?.id);
           if (data) {
-            const tempdata = {
-              // ...data,
-              totalPrice: data.amount,
-              discountTotalPrice: data.discountAmount,
-              productList: data.originalList
-            }
-            this.businessId = data.id;
-            this.adjustData = data.detailList;
-            this.form = data;
-            this.$refs.inventoryTableDetailsRef &&
-              this.$refs.inventoryTableDetailsRef.putTableValue(tempdata);
-            this.$refs.inventoryTableRef && this.$refs.inventoryTableRef.putTableValue(data.detailList);
+            // this.$nextTick(() => {
+              const tempdata = {
+                // ...data,
+                totalPrice: data.amount,
+                discountTotalPrice: data.discountAmount,
+                productList: data.originalList
+              }
+              this.businessId = data.id;
+              this.adjustData = data.detailList;
+              this.selectIds = this.adjustData.map(item => item.sourceDetailId);
+              this.form = data;
+              console.log('tempdata~~~', this.form, data);
+              this.$refs.inventoryTableDetailsRef &&
+                this.$refs.inventoryTableDetailsRef.putTableValue(tempdata);
+              this.$refs.inventoryTableRef && this.$refs.inventoryTableRef.putTableValue(data);
+            // });
+            
           }
         }
         
@@ -468,6 +474,8 @@
         if (data) {
           this.form.sourceNo = data.orderNo;
           this.form.sourceId = data.id;
+          // this.form.amount = data.totalAmount;
+          // this.form.discountAmount = data.payAmount;
           this.$nextTick(() => {
             this.$refs.inventoryTableDetailsRef &&
               this.$refs.inventoryTableDetailsRef.putTableValue(data);

+ 2 - 2
src/views/saleManage/saleOrder/adjustmentNote‌/components/detailAdjustDialog.vue

@@ -141,7 +141,7 @@
 
           <el-col :span="8">
             <el-form-item labelWidth="100px" prop="files" label="附件">
-              <fileMain disabled v-model="form.files"></fileMain>
+              <fileMain type="view" v-model="form.files"></fileMain>
             </el-form-item>
           </el-col>
         </el-row>
@@ -385,7 +385,7 @@
           console.log('tempdata~~~~', tempdata);
           this.$refs.inventoryTableDetailsRef &&
             this.$refs.inventoryTableDetailsRef.putTableValue(tempdata);
-          this.$refs.inventoryTableRef && this.$refs.inventoryTableRef.putTableValue(data.detailList);
+          this.$refs.inventoryTableRef && this.$refs.inventoryTableRef.putTableValue(data);
         }
       },
 

+ 23 - 12
src/views/saleManage/saleOrder/adjustmentNote‌/components/inventoryTable.vue

@@ -60,6 +60,7 @@
   import dictMixins from '@/mixins/dictMixins';
   import productList from '@/views/saleManage/saleOrder/invoice/components/product-list.vue';
   import tabMixins from '@/mixins/tableColumnsMixin';
+  import { reduce } from 'lodash';
 
   export default {
     mixins: [dictMixins, tabMixins],
@@ -347,8 +348,10 @@
       //设置优惠后总金额修改产品单价
       discountInputByOrder(val, amount) {
         this.form.adjustDiscountAmount = val;
-        this.form.amount = amount;
-        this.allPrice = amount;
+        // this.form.amount = amount;
+        // this.allPrice = amount;
+
+        console.log('val~~~', val, amount);
 
         this.form.datasource.forEach((item, index) => {
           this.$set(
@@ -406,17 +409,21 @@
       },
       //获取折让单价
       getDiscountSinglePrice(row) {
-        console.log('row~~~', this.allPrice);
+        console.log('row~~~', this.allPrice, row.adjustDiscountAmount);
+
         let num =
           (Number(this.form.adjustDiscountAmount) / Number(this.allPrice)) *
           Number(row.adjustPrice);
-        return isNaN(num) ? '' : num;
+        
+        // let num =
+        //   Number(this.form.adjustDiscountAmount) * (Number(row.adjustDiscountAmount) /Number(this.allPrice));
+        return isNaN(num) ? '' : num.toFixed(2);
       },
 
       //获取折让合计
       getDiscountTotalPrice(row) {
         let num = 0;
-        num = Number(row.adjustDiscountAmount) * Number(row.quantity);
+        num = Number(row.adjustDiscountPrice) * Number(row.quantity);
         return isNaN(num) ? '' : num.toFixed(2);
       },
       getTotalCount(row) {
@@ -457,14 +464,17 @@
 
       //修改回显
       putTableValue(data) {
+        console.log('data~~~', data);
         if (data) {
-          // 创建数据的深拷贝,避免引用关系导致两边数据互相影响
-          const copyData = JSON.parse(JSON.stringify(data));
           
+
+          let productList = data.productList || data.detailList || [];
+          console.log('productList~~~', productList);
+
+          // 创建数据的深拷贝,避免引用关系导致两边数据互相影响
+          const copyData = JSON.parse(JSON.stringify(productList));
           copyData.forEach((v) => {
-            v.sendTotalCount = v.packingQuantity || 0;
-            v.sendProductId = v.sendProductId || v.categoryId || v.productId;
-            // 初始化单价差异字段,如果未定义则设为0
+            
             if (v.adjustPrice !== undefined && v.priceDifference === undefined) {
               v.priceDifference = '';
             }
@@ -479,8 +489,9 @@
           // });
           
           this.form.datasource = copyData;
-        
-          // this.allPrice = form.amount;
+          // this.changeDiffPrice();
+          const total = reduce(this.form.datasource, (acc, cur) => acc + Number(cur.amount), 0);
+          this.allPrice = total
         }
       },
 

+ 2 - 2
src/views/saleManage/saleOrder/adjustmentNote‌/components/searchTable.vue

@@ -23,14 +23,14 @@ export default {
           value: 'reason',
           type: 'DictSelection',
           placeholder: '请选择',
-          dictName: '冲差原因'
+          dictName: '冲差原因'
         },
         {
           label: '调整类型:',
           value: 'adjustType',
           type: 'DictSelection',
           placeholder: '请选择',
-          dictName: '调整类型'
+          dictName: '调整类型'
         },
       ];
     }

+ 17 - 4
src/views/saleManage/saleOrder/adjustmentNote‌/index.vue

@@ -159,7 +159,7 @@
 
   import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
   import tabMixins from '@/mixins/tableColumnsMixin';
-  import { getTableList, deleteInfo } from '@/api/saleManage/adjustmentNote‌';
+  import { getTableList, deleteInfo, deleteBatch } from '@/api/saleManage/adjustmentNote‌';
   import { reviewStatus } from '@/enum/dict';
   export default {
     mixins: [dictMixins,tabMixins],
@@ -374,6 +374,7 @@
     methods: {
       /* 表格数据源 */
       datasource({ page, limit, where, order }) {
+        
         if (this.saleOrderData.id) {
           where['sourceId'] = this.saleOrderData.id;
         }
@@ -396,6 +397,11 @@
       handleAddOrEdit(type, row) {
         this.addAdjustDialogFlag = true;
         this.$nextTick(() => {
+          console.log('row~~~~~~~~~222', this.saleOrderData)
+          if(this.saleOrderData.id && type == 'add') {
+            this.$refs.addAdjustDialogRef.open(type, this.saleOrderData);
+            return;
+          }
           this.$refs.addAdjustDialogRef.open(type, row);
         });
       },
@@ -409,7 +415,7 @@
       allDelBtn() {
         if (this.selection.length === 0) return;
         let flag = this.selection.some((item) =>
-          [1, 2].includes(item.reviewStatus)
+          [1, 2].includes(item.status)
         );
         if (flag)
           return this.$message.warning(
@@ -428,8 +434,15 @@
 
       //删除弹框确定
       commitBtn() {
-        const dataId = this.selection.map((v) => v.id);
-        this.remove(dataId);
+        const dataId = this.selection.map((v) => v.id)?.join(',');
+        console.log('dataId', dataId)
+        // this.remove(dataId);
+        deleteBatch({
+          ids: dataId
+        }).then((res) => {
+          this.$message.success('删除成功!');
+          this.reload();
+        });
       },
       adjustSubmit(res) {
         this.processSubmitDialogFlag = true;

+ 4 - 3
src/views/saleManage/saleOrder/components/drawer.vue

@@ -135,9 +135,10 @@
         </el-tab-pane>
         <el-tab-pane label="冲差单" name="冲差单">
           <adjustmentNote
-          :saleOrderData="row"
-          :showAdd="true"
-          ref="adjustmentNoteRef"
+            v-if="activeName == '冲差单'"
+            :saleOrderData="row"
+            :showAddBtn="true"
+            ref="adjustmentNoteRef"
           ></adjustmentNote>
         </el-tab-pane>
       </el-tabs>