Kaynağa Gözat

fix(adjustmentNote): 修复调整单表格数据合并问题并优化单价差异计算

liujt 9 ay önce
ebeveyn
işleme
63de93a78c

+ 32 - 3
src/views/saleManage/saleOrder/adjustmentNote‌/components/addAdjustDialog.vue

@@ -376,9 +376,38 @@
       handleSelectionChange(list) {
         // this.form.productList = val;
         console.log('select------list', list);
-        this.adjustData = list;
-        this.$refs.inventoryTableRef &&
-          this.$refs.inventoryTableRef.putTableValue(list);
+        // 创建深拷贝避免引用关系
+        this.adjustData = JSON.parse(JSON.stringify(list));
+        
+        if (this.$refs.inventoryTableRef) {
+          // 获取当前inventoryTable中已有的数据
+          const currentData = this.$refs.inventoryTableRef.form.datasource || [];
+          
+          // 创建一个映射,记录已存在的数据
+          const existingItemsMap = {};
+          currentData.forEach(item => {
+            if (item.productCode) {
+              existingItemsMap[item.productCode] = item;
+            }
+          });
+          
+          // 合并数据,保留已编辑的单价等信息
+          this.adjustData.forEach(item => {
+            if (existingItemsMap[item.productCode]) {
+              // 保留已编辑的字段
+              const existingItem = existingItemsMap[item.productCode];
+              item.singlePriceDiff = existingItem.singlePriceDiff !== undefined ? existingItem.singlePriceDiff : item.singlePriceDiff;
+              item.totalCount = existingItem.totalCount !== undefined ? existingItem.totalCount : item.totalCount;
+              item.totalPrice = existingItem.totalPrice !== undefined ? existingItem.totalPrice : item.totalPrice;
+              
+              // 移除已处理的项
+              delete existingItemsMap[item.productCode];
+            }
+          });
+          
+          // 调用putTableValue方法更新表格数据
+          this.$refs.inventoryTableRef.putTableValue(this.adjustData);
+        }
       },
       //删除产品
       remove(row) {

+ 105 - 573
src/views/saleManage/saleOrder/adjustmentNote‌/components/inventoryTable.vue

@@ -10,213 +10,26 @@
       class="time-form"
       :maxHeight="250"
     >
-      <!-- 表头工具栏 -->
-      <template v-slot:toolbar>
-        <div
-          class="headbox"
-          :style="{
-            justifyContent: type != '10' ? 'space-between' : 'flex-end'
-          }"
-        >
-          <!-- <el-button
-            size="small"
-            type="primary"
-            icon="el-icon-plus"
-            class="ele-btn-icon"
-            @click="handlAdd"
-            v-if="type != '10'"
-            >新增
-          </el-button> -->
-          <div class="pricebox">
-            <span class="amount">总金额{{ totalAmount }}元</span>
-          </div>
-        </div>
-      </template>
-
-      <template v-slot:orderNo="{ row, $index }">
-        <el-form-item :prop="'datasource.' + $index + '.orderNo'">
-          <el-select v-model="row.orderNo" style="width: 100%">
-            <el-option
-              :label="item.orderNo"
-              :value="item.orderNo"
-              @click.native="orderNoChange(row, item)"
-              v-for="(item, index) in orderOption"
-              :key="index"
-            ></el-option>
-          </el-select>
-        </el-form-item>
-      </template>
-
-      <!--   发货总重   -->
-      <template v-slot:sendTotalWeight="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.sendTotalWeight'"
-          :rules="[
-            {
-              required: pricingWay == 2 && [3, 1].includes(returnSourceType),
-              message: '请输入数字',
-              trigger: 'blur'
-            }
-          ]"
-        >
-          <el-input
-            v-model="scope.row.sendTotalWeight"
-            @blur="changeSendTotalWeight(scope.$index)"
-            :disabled="returnSourceType == 2"
-            style="width: 60%; margin-right: 10px"
-          >
-          </el-input>
-          <el-button
-            size="small"
-            type="primary"
-            v-if="[3, 1].includes(returnSourceType)"
-            @click.native="(e) => handleOutBound(e, scope.row, scope.$index)"
-            >选择
-          </el-button>
-        </el-form-item>
-      </template>
-
-      <template v-slot:receiveTotalWeight="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.receiveTotalWeight'"
-          :rules="[
-            {
-              required:
-                (entrustedCode || returnSourceType == 2) && pricingWay == 2,
-              message: '请输入数字',
-              trigger: 'blur'
-            }
-          ]"
-        >
-          <el-input
-            v-model="scope.row.receiveTotalWeight"
-            :disabled="[3, 1].includes(returnSourceType) && !entrustedCode"
-            @blur="changeReceiveTotalWeight(scope.$index)"
-            style="width: 60%; margin-right: 10px"
-          >
-          </el-input>
-          <el-button
-            size="small"
-            type="primary"
-            v-if="entrustedCode || returnSourceType == 2"
-            @click.native="(e) => handleInnerBound(e, scope.row, scope.$index)"
-            >选择
-          </el-button>
-        </el-form-item>
-      </template>
-      <template v-slot:technicalDrawings="{ row, $index }">
+      <template v-slot:singlePriceDiff="scope">
         <el-form-item
           style="margin-bottom: 20px"
-          :prop="'datasource.' + $index + '.technicalDrawings'"
-        >
-          <div v-if="row.technicalDrawings && row.technicalDrawings?.length">
-            <el-link
-              v-for="link in row.technicalDrawings"
-              :key="link.id"
-              type="primary"
-              :underline="false"
-              @click="downloadFile(link)"
-            >
-              {{ link.name }}
-            </el-link>
-          </div>
-        </el-form-item>
-      </template>
-      <template v-slot:returnReason="{ row, $index }">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + $index + '.returnReason'"
+          :prop="'datasource.' + scope.$index + '.singlePriceDiff'"
         >
           <el-input
-            clearable
-            v-model="row.returnReason"
-            type="textarea"
+            v-model="scope.row.singlePriceDiff"
             placeholder="请输入"
-          />
-        </el-form-item>
-      </template>
-      <template v-slot:remark="{ row, $index }">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + $index + '.remark'"
-        >
-          <el-input
-            clearable
-            v-model="row.remark"
-            type="textarea"
-            placeholder="请输入"
-          />
-        </el-form-item>
-      </template>
-
-      <template v-slot:totalCount="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.totalCount'"
-          :rules="[{ required: true, message: '请输入数字', trigger: 'blur' }]"
-        >
-          <el-input
-            v-model="scope.row.totalCount"
             type="number"
-            @input="changeNum(scope.row, scope.$index)"
-          ></el-input>
-        </el-form-item>
-      </template>
-
-      <template v-slot:totalPrice="{ row, $index }">
-        <el-form-item
-          v-if="row.pricingWay == 2"
-          :prop="'datasource.' + $index + '.totalPrice'"
-        >
-          <el-input
-            type="number"
-            v-model="row.totalPrice"
-            placeholder="请输入"
-          />
-        </el-form-item>
-        <span v-else>{{ row.totalPrice }}</span>
-      </template>
-      <template v-slot:notaxSinglePrice="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.notaxSinglePrice'"
-        >
-          <el-input
-            v-model="scope.row.notaxSinglePrice"
-            placeholder="请输入"
-            type="number"
-            @change="changeNum(scope.row, scope.$index)"
+            @input="handleSinglePriceDiffChange(scope.row, scope.$index)"
+            @blur="handleSinglePriceDiffChange(scope.row, scope.$index)"
           >
             <!-- <template slot="append">元</template> -->
           </el-input>
         </el-form-item>
       </template>
-      <template v-slot:headerTotalCount="{ column }">
+      <template v-slot:headerSinglePriceDiff="{ column }">
         <span class="is-required">{{ column.label }}</span>
       </template>
-
-      <template v-slot:headerSendTotalWeight="{ column }">
-        <span
-          :class="{
-            'is-required': pricingWay == 2 && [3, 1].includes(returnSourceType)
-          }"
-          >{{ column.label }}</span
-        >
-      </template>
-      <template v-slot:headerReceiveTotalWeight="{ column }">
-        <span
-          :class="{
-            'is-required':
-              (entrustedCode || returnSourceType == 2) && pricingWay == 2
-          }"
-          >{{ column.label }}</span
-        >
-      </template>
-
       <!-- 操作列 -->
-
       <template v-slot:action="{ $index }">
         <el-popconfirm
           v-if="type != '10'"
@@ -239,31 +52,12 @@
       type="send"
       @changeParent="changeParent"
     ></product-list>
-    <!--出库详情-->
-    <outbound-details-dialog
-      v-if="outboundDetailsDialogFlag"
-      ref="outboundDetailsDialogRef"
-      :outboundDetailsDialogFlag.sync="outboundDetailsDialogFlag"
-      @saveDate="saveDate"
-    ></outbound-details-dialog>
-    <!--入库详情-->
-    <innertboundDetailsDialog
-      v-if="innerboundDetailsDialogFlag"
-      ref="innerboundDetailsDialogRef"
-      :innerboundDetailsDialogFlag.sync="innerboundDetailsDialogFlag"
-      @saveDate="saveInnerDate"
-    ></innertboundDetailsDialog>
   </el-form>
 </template>
 <script>
-  import { numberReg } from 'ele-admin';
   import dictMixins from '@/mixins/dictMixins';
   import productList from '@/views/saleManage/saleOrder/invoice/components/product-list.vue';
-  import { getFile } from '@/api/system/file';
-  import outboundDetailsDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/outboundDetailsDialog.vue';
-  import innertboundDetailsDialog from '@/views/purchasingManage/purchaseOrder/returnGoods/components/innerboundDetailsDialog.vue';
   import tabMixins from '@/mixins/tableColumnsMixin';
-  import { levelList } from '@/enum/dict.js';
 
   export default {
     mixins: [dictMixins, tabMixins],
@@ -282,40 +76,24 @@
       type: {
         default: ''
       },
-      orderOption: {
-        default: () => {
-          return [];
-        }
-      }
+
     },
 
     components: {
-      innertboundDetailsDialog,
-      outboundDetailsDialog,
       productList
     },
     data() {
-      const defaultForm = {
-        key: null,
-        endTime: '',
-        isFirst: 0,
-        name: '',
-        startTime: '',
-        workHour: '',
-        technicalDrawings: []
-      };
       return {
-        cacheKeyUrl: 'eos-saleManage-returnorder-inventoryTable',
+        cacheKeyUrl: 'eos-saleManage-saleOrder-adjustmentNote-inventoryTable',
         payAmount: '',
-        outboundDetailsDialogFlag: false,
-        innerboundDetailsDialogFlag: false,
-        numberReg,
-        defaultForm,
         form: {
           datasource: []
         },
-        rules: {},
-        oldSendTotalWeightList: [],
+        rules: {
+          'singlePriceDiff': [
+            { required: true, message: '请输入', trigger: 'blur' }
+          ]
+        },
 
         columns: [
           {
@@ -326,20 +104,12 @@
             fixed: 'left'
           },
           {
-            minWidth: 200,
-            prop: 'orderNo',
-            slot: 'orderNo',
-            label: '订单编码',
+            minWidth: 160,
+            prop: 'productCode',
+            label: '编码',
             showOverflowTooltip: true,
             align: 'center'
           },
-          // {
-          //   minWidth: 160,
-          //   prop: 'productCode',
-          //   label: '编码',
-          //   showOverflowTooltip: true,
-          //   align: 'center'
-          // },
           {
             minWidth: 120,
             prop: 'productName',
@@ -347,103 +117,27 @@
             showOverflowTooltip: true,
             align: 'center'
           },
-
-          // {
-          //   minWidth: 160,
-          //   prop: 'batchNo',
-          //   label: '批次号',
-          //   showOverflowTooltip: true,
-          //   slot: 'batchNo',
-          //   align: 'center'
-          // },
-          // {
-          //   minWidth: 160,
-          //   prop: 'barcodes',
-          //   label: '发货条码',
-          //   showOverflowTooltip: true,
-          //   slot: 'barcodes',
-          //   align: 'center'
-          // },
-          // {
-          //   minWidth: 120,
-          //   prop: 'materielDesignation',
-          //   label: '物料代号',
-          //   showOverflowTooltip: true,
-          //   align: 'center'
-          // },
-          // {
-          //   minWidth: 120,
-          //   prop: 'clientCode',
-          //   label: '客户代号',
-          //   showOverflowTooltip: true,
-          //   align: 'center'
-          // },
-          // {
-          //   minWidth: 120,
-          //   prop: 'engrave',
-          //   label: '刻码',
-          //   showOverflowTooltip: true,
-          //   align: 'center'
-          // },
-          // {
-          //   minWidth: 160,
-          //   prop: 'packageNo',
-          //   align: 'center',
-          //   label: '包装编码',
-          //   showOverflowTooltip: true
-          // },
-          // {
-          //   minWidth: 100,
-          //   prop: 'packingQuantity',
-          //   align: 'center',
-          //   label: '包装数量',
-          //   showOverflowTooltip: true
-          // },
-          // {
-          //   minWidth: 120,
-          //   prop: 'packingUnit',
-          //   align: 'center',
-          //   label: '包装单位',
-          //   showOverflowTooltip: true
-          // },
-          // {
-          //   minWidth: 150,
-          //   prop: 'totalCount',
-          //   slot: 'totalCount',
-          //   label: '退货数量',
-          //   showOverflowTooltip: true,
-          //   align: 'center'
-          // },
+          {
+            minWidth: 120,
+            prop: 'specification',
+            label: '规格',
+            showOverflowTooltip: true,
+            align: 'center'
+          },
+          {
+            minWidth: 120,
+            prop: 'modelType',
+            label: '型号',
+            showOverflowTooltip: true,
+            align: 'center'
+          },
           {
             minWidth: 150,
-            prop: 'measuringUnit',
+            prop: 'saleCount',
             label: '数量',
             showOverflowTooltip: true,
             align: 'center'
           },
-          // {
-          //   width: 160,
-          //   prop: 'pricingWay',
-          //   label: '计价方式',
-          //   slot: 'pricingWay',
-          //   align: 'center',
-          //   formatter: (row, column) => {
-          //     return row.pricingWay == 1
-          //       ? '按数量计费'
-          //       : row.pricingWay == 2
-          //       ? '按重量计费'
-          //       : '';
-          //   }
-          // },
-          // {
-          //   width: 160,
-          //   prop: 'goodsPriceType',
-          //   label: '价格类型',
-          //   formatter: (row, column) => {
-          //     return this.getDictValue('商品价格类型', row.goodsPriceType);
-          //   },
-          //   align: 'center'
-          // },
           {
             width: 100,
             prop: 'singlePrice',
@@ -453,10 +147,11 @@
           },
           {
             width: 180,
-            prop: 'notaxSinglePrice',
+            prop: 'singlePriceDiff',
             label: '单价差异',
-            slot: 'notaxSinglePrice',
-            align: 'center'
+            slot: 'singlePriceDiff',
+            align: 'center',
+            headerSlot: 'headerSinglePriceDiff'
           },
           {
             width: 130,
@@ -469,9 +164,16 @@
           },
           {
             width: 130,
-            prop: 'notaxSinglePrice1',
+            prop: 'notaxSinglePrice',
             label: '不含税单价',
-            slot: 'notaxSinglePrice1',
+            slot: 'notaxSinglePrice',
+            align: 'center'
+          },
+          {
+            width: 130,
+            prop: 'discountSinglePrice',
+            label: '折让单价',
+            slot: 'discountSinglePrice',
             align: 'center'
           },
           {
@@ -481,76 +183,13 @@
             label: '合计',
             align: 'center'
           },
-          // {
-          //   minWidth: 80,
-          //   prop: 'weight',
-          //   label: '重量',
-          //   showOverflowTooltip: true,
-          //   align: 'center'
-          // },
-          // {
-          //   minWidth: 120,
-          //   prop: 'receiveTotalWeight',
-          //   label: '重量',
-          //   // slot: 'singleWeight',
-          //   showOverflowTooltip: true,
-          //   align: 'center'
-          // },
-          // {
-          //   minWidth: 100,
-          //   prop: 'weightUnit',
-          //   label: '重量单位',
-          //   showOverflowTooltip: true,
-          //   align: 'center'
-          // },
-          // {
-          //   prop: 'provenance',
-          //   label: '产地',
-          //   slot: 'provenance',
-          //   align: 'center',
-          //   minWidth: 200,
-          //   showOverflowTooltip: true,
-          //   formatter: (row, column) => {
-          //     return row.provenance && row.provenance.length
-          //       ? row.provenance
-          //           .map((item) => this.getDictValue('产地', item))
-          //           .join(',')
-          //       : '';
-          //   }
-          // },
-
-          // {
-          //   minWidth: 100,
-          //   prop: 'renturnType',
-          //   label: '状态',
-          //   showOverflowTooltip: true,
-          //   align: 'center'
-          // },
-          // {
-          //   minWidth: 120,
-          //   prop: 'goodsLevel',
-          //   label: '物品级别',
-          //   formatter: (_row, _column, cellValue) => {
-          //     return levelList.find((item) => item.value == _row.goodsLevel)
-          //       ?.label;
-          //   },
-          //   align: 'center'
-          // },
-          // {
-          //   minWidth: 200,
-          //   prop: 'returnReason',
-          //   label: '退货原因',
-          //   slot: 'returnReason',
-          //   align: 'center'
-          // },
-
-          // {
-          //   width: 220,
-          //   prop: 'remark',
-          //   label: '备注',
-          //   slot: 'remark',
-          //   align: 'center'
-          // },
+          {
+            width: 120,
+            prop: 'discountTotalPrice',
+            slot: 'discountTotalPrice',
+            label: '折让合计',
+            align: 'center'
+          },
           // {
           //   columnKey: 'action',
           //   label: '操作',
@@ -565,8 +204,7 @@
       };
     },
     created() {
-      this.requestDict('产地');
-      this.requestDict('商品价格类型');
+
     },
     computed: {
       totalAmount() {
@@ -580,132 +218,54 @@
           num += this.form.datasource[index].totalPrice;
         });
         return parseFloat(num).toFixed(2);
-      }
+      },
+
     },
     mounted() {
-      console.log(this.entrustedCode);
+      
     },
     methods: {
-      // downloadFile(file) {
-      //   getFile({ objectName: file.storePath }, file.name);
+      // changeSinglePriceDiff(row, index) {
+      //   if (row.singlePriceDiff && row.singlePrice) {
+      //     this.$set(
+      //       this.form.datasource[index],
+      //       'totalPrice',
+      //       row.singlePriceDiff * row.totalCount || 0
+      //     );
+      //   }
       // },
-
-      //出库单详情
-      handleOutBound(e, rows, index) {
-        this.curIndex = index;
-        this.outboundDetailsDialogFlag = true;
-        this.$nextTick(() => {
-          let row = {
-            sendNo: this.entrustedCode || this.sendNo,
-            productCode: rows.productCode
-          };
-          this.$refs.outboundDetailsDialogRef.init(row);
-        });
-      },
-      //选择退货信息回调
-      saveDate(data = []) {
-        let totalWeight = data.reduce((num, row) => {
-          num += Number(row.weight);
-          return num;
-        }, 0);
-        this.$set(
-          this.form.datasource[this.curIndex],
-          'sendTotalWeight',
-          totalWeight
-        );
-        this.setIcreaseTotalWeight();
-      },
-
-      //入库单详情
-      handleInnerBound(e, rows, index) {
-        this.curIndex = index;
-        this.innerboundDetailsDialogFlag = true;
-        this.$nextTick(() => {
-          let row = {
-            sendNo: this.entrustedCode,
-            productCode: rows.productCode
-          };
-          this.$refs.innerboundDetailsDialogRef.init(row);
-        });
-      },
-      //选择入库单信息
-      saveInnerDate(data = []) {
-        let totalWeight = data.reduce((num, row) => {
-          num += Number(row.weight);
-          return num;
-        }, 0);
-        this.$set(
-          this.form.datasource[this.curIndex],
-          'receiveTotalWeight',
-          totalWeight
-        );
-        if (this.returnSourceType == 2)
-          this.$set(
-            this.form.datasource[this.curIndex],
-            'sendTotalWeight',
-            totalWeight
-          );
-        this.setIcreaseTotalWeight();
-      },
-      //修改发货总重
-      changeSendTotalWeight(index) {
-        this.curIndex = index;
-        this.setIcreaseTotalWeight();
-      },
-      //修改收货总重
-      changeReceiveTotalWeight(index) {
-        this.curIndex = index;
-        if (this.returnSourceType == 2)
-          this.form.datasource[this.curIndex].sendTotalWeight =
-            this.form.datasource[this.curIndex].receiveTotalWeight;
-        this.setIcreaseTotalWeight();
+      // 处理单价差异变化,更新单价
+      handleSinglePriceDiffChange(row, index) {
+        // 确保原单价和单价差异都有值
+        const originalPrice = Number(row.singlePrice) || 0;
+        const priceDiff = Number(row.singlePriceDiff) || 0;
+        
+        // 计算新单价 = 原单价 + 单价差异
+        const newPrice = originalPrice + priceDiff;
+        
+        // 使用$set更新单价字段
+        this.$set(this.form.datasource[index], 'singlePrice', newPrice);
+        
+        // 同时更新总价
+        if (row.totalCount) {
+          this.$set(this.form.datasource[index], 'totalPrice', row.totalCount * newPrice);
+        }
       },
-      //设置增重总重
-      setIcreaseTotalWeight() {
-        let sendTotalWeight = Number(
-          this.form.datasource[this.curIndex].sendTotalWeight
-        );
-        let receiveTotalWeight = Number(
-          this.form.datasource[this.curIndex].receiveTotalWeight
-        );
-        // if (this.entrustedCode) {
-        if (this.pricingWay == 2) {
-          if (isNaN(receiveTotalWeight) || isNaN(sendTotalWeight)) {
-            return this.$set(
-              this.form.datasource[this.curIndex],
-              'increaseTotalWeight',
-              ''
-            );
-          } else {
+      //计算不含税单价
+      getNotaxSinglePrice() {
+        this.form.datasource.forEach((item, index) => {
+          if (item.singlePrice && item.taxRate) {
             this.$set(
-              this.form.datasource[this.curIndex],
-              'increaseTotalWeight',
-              (sendTotalWeight - receiveTotalWeight).toFixed(2)
+              this.form.datasource[index],
+              'notaxSinglePrice',
+              parseFloat(
+                (item.singlePrice / (1 + item.taxRate / 100)).toFixed(2)
+              )
             );
+          } else {
+            this.$set(this.form.datasource[index], 'notaxSinglePrice', '');
           }
-        } else {
-          this.$set(
-            this.form.datasource[this.curIndex],
-            'increaseTotalWeight',
-            (sendTotalWeight - receiveTotalWeight).toFixed(2)
-          );
-        }
-        // } else {
-        //   this.$set(this.form.datasource[this.curIndex], 'increaseTotalWeight', sendTotalWeight);
-        // }
-        // if (this.pricingWay == 2) {
-        //   this.getWeightPrice();
-        // }
-        this.$refs.table.reload();
-      },
-      changeNum(row, index) {
-        if (row.totalCount && row.singlePrice) {
-          this.$set(
-            this.form.datasource[index],
-            'totalPrice',
-            row.totalCount * row.singlePrice
-          );
-        }
+        });
       },
       //获取订单总金额
       gettotalAmount() {
@@ -727,24 +287,7 @@
           // this.$store.commit('returnGoods/setAllcountAmount', 0);
         }
       },
-      orderNoChange(row, item) {
-        row['orderId'] = item.orderId;
-      },
-      //选择产品回调
-      async changeParent(obj, idx) {
-        console.log(obj, '9999');
-        obj.sendTotalCount = obj.totalCount;
-        obj.sendProductId = obj.id;
-        obj.id = '';
-
-        // if (obj.warehouseId) {
-        //   obj['warehouseNum'] = await getWarehouseOutStock({
-        //     warehouseId: obj.warehouseId,
-        //     code: obj.productCode
-        //   });
-        // }
-        this.$set(this.form.datasource, this.form.datasource.length, obj);
-      },
+  
       // validateTotalCount(row) {
       //   return (rule, value, callback) => {
       //     if (isNaN(value) || Number(value) <= 0) {
@@ -797,32 +340,27 @@
       //修改回显
       putTableValue(data) {
         if (data) {
-          data.forEach((v) => {
-            // v.returnReason = v.returnReason || '';
-            // v.returnType = '';
+          // 创建数据的深拷贝,避免引用关系导致两边数据互相影响
+          const copyData = JSON.parse(JSON.stringify(data));
+          
+          copyData.forEach((v) => {
             v.sendTotalCount = v.packingQuantity || 0;
             v.sendProductId = v.sendProductId || v.categoryId || v.productId;
+            // 初始化单价差异字段,如果未定义则设为0
+            if (v.singlePrice !== undefined && v.singlePriceDiff === undefined) {
+              v.singlePriceDiff = 0;
+            }
           });
-          this.oldSendTotalWeightList = data.map((item) => {
+          
+          this.oldSendTotalWeightList = copyData.map((item) => {
             return {
               productCode: item.productCode,
               oldSendTotalWeight: item.sendTotalWeight,
               oldReceiveTotalWeight: item.receiveTotalWeight
             };
           });
-          this.form.datasource = data;
-          // this.form.datasource.forEach(async (v, index) => {
-          //   if (v.warehouseId) {
-          //     this.$set(
-          //       this.form.datasource[index],
-          //       'warehouseNum',
-          //       await getWarehouseOutStock({
-          //         warehouseId: v.warehouseId,
-          //         code: v.productCode
-          //       })
-          //     );
-          //   }
-          // });
+          
+          this.form.datasource = copyData;
           this.gettotalAmount();
         }
       },
@@ -842,13 +380,7 @@
           n.key = index + 1;
         });
       },
-      // 添加
-      handlAdd() {
-        if (!this.sendId && !this.entrustedCode)
-          return this.$message.error('请先选择来源单据');
-        this.$emit('handleSelectGoods', this.form.datasource);
-        // this.$refs.productListRef.open(this.form.datasource);
-      },
+
 
       validateForm(callback) {
         //开始表单校验

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

@@ -382,7 +382,7 @@
             fixed: 'right'
           }
         ],
-        cacheKeyUrl:'eos-b5bbaa6e-saleManage-accountstatement',
+        cacheKeyUrl:'eos-saleManage-saleOrder-adjustmentNote-index',
       };
     },
     computed: {},