Selaa lähdekoodia

fix: 修复物品清单替代料问题

tanzx 1 kuukausi sitten
vanhempi
commit
85455ceca8

+ 33 - 85
src/views/saleManage/saleOrder/invoice/components/inventoryTable.vue

@@ -7,7 +7,9 @@
         :columns="columns"
         :datasource="form.datasource"
         class="time-form"
+        :selection.sync="selection"
         @columns-change="handleColumnChange"
+        @header-dragend="handleHeaderDragend"
         :cache-key="cacheKeyUrl"
         height="350"
         full-height="calc(100vh - 76px)"
@@ -37,6 +39,16 @@
             >
               新增
             </el-button>
+            <el-button
+              size="small"
+              type="danger"
+              icon="el-icon-delete"
+              class="ele-btn-icon"
+              :disabled="!selection.length"
+              @click="batchRemove"
+            >
+              批量删除
+            </el-button>
           </div>
         </template>
         <template v-slot:technicalDrawings="{ row, $index }">
@@ -112,27 +124,6 @@
           <el-form-item
             :prop="'datasource.' + scope.$index + '.blockCount'"
             :rules="[{ required: true, message: '请输入', trigger: 'blur' }]"
-    <ele-pro-table
-      ref="table"
-      :needPage="false"
-      :columns="columns"
-      :datasource="form.datasource"
-      class="time-form"
-      :selection.sync="selection"
-      @columns-change="handleColumnChange"
-      @header-dragend="handleHeaderDragend"
-      :cache-key="cacheKeyUrl"
-    >
-      <!-- 表头工具栏 -->
-      <template v-slot:toolbar>
-        <div class="headbox">
-          <el-button
-            v-if="isShowAdd && needProduce != 4"
-            size="small"
-            type="primary"
-            icon="el-icon-plus"
-            class="ele-btn-icon"
-            @click="handlAdd"
           >
             <el-input
               v-model="scope.row.blockCount"
@@ -178,42 +169,6 @@
                 trigger: 'blur'
               }
             ]"
-            新增
-          </el-button>
-          <el-button
-            size="small"
-            type="danger"
-            icon="el-icon-delete"
-            class="ele-btn-icon"
-            :disabled="!selection.length"
-            @click="batchRemove"
-          >
-            批量删除
-          </el-button>
-        </div>
-      </template>
-      <template v-slot:technicalDrawings="{ row, $index }">
-        <el-form-item :prop="'datasource.' + $index + '.technicalDrawings'">
-          <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
-        </el-form-item>
-      </template>
-      <template v-slot:remark="{ row, $index }">
-        <el-form-item :prop="'datasource.' + $index + '.remark'">
-          <el-input
-            clearable
-            v-model="row.remark"
-            type="textarea"
-            placeholder="请输入"
-          />
-        </el-form-item>
-      </template>
-      <template v-slot:stockLedger="scope">
-        <el-form-item>
-          <el-popover
-            @hide="() => (selection = [])"
-            placement="right"
-            width="60%"
-            trigger="hover"
           >
             <el-select
               v-if="needProduce == 4 && orderNoList.length > 1"
@@ -469,31 +424,25 @@
         </template>
         <!-- 操作列 -->
         <template v-slot:action="scope">
-          <div>
-            <el-popconfirm
-              class="ele-action"
-              title="确定要删除吗?"
-              @confirm="remove(scope.$index)"
-            >
-              <template v-slot:reference>
-                <el-link
-                  type="danger"
-                  :underline="false"
-                  icon="el-icon-delete"
-                >
-                  删除
-                </el-link>
-              </template>
-            </el-popconfirm>
-            <el-link
-              type="primary"
-              :underline="false"
-              icon="el-icon-edit"
-              @click="selectStockLedgerDialogOpen(scope.row)"
-            >
-              替代料
-            </el-link>
-          </div>
+          <el-popconfirm
+            class="ele-action"
+            title="确定要删除吗?"
+            @confirm="remove(scope.$index)"
+          >
+            <template v-slot:reference>
+              <el-link type="danger" :underline="false" icon="el-icon-delete">
+                删除
+              </el-link>
+            </template>
+          </el-popconfirm>
+          <el-link
+            type="primary"
+            :underline="false"
+            icon="el-icon-edit"
+            @click="selectStockLedgerDialogOpen(scope.row)"
+          >
+            替代料
+          </el-link>
         </template>
       </ele-pro-table>
     </div>
@@ -705,14 +654,14 @@
         };
         return [
           {
-            width: 60,
+            width: 45,
             type: 'selection',
             columnKey: 'selection',
             align: 'center',
             fixed: 'left'
           },
           {
-            width: 45,
+            width: 60,
             type: 'index',
             columnKey: 'index',
             align: 'center',
@@ -1869,7 +1818,6 @@
         this.form.datasource.splice(i, 1);
         this.setSort();
       },
-
       batchRemove() {
         if (!this.selection.length) return;
         this.$confirm('确定要批量删除选中的物品吗?', '提示', {

+ 16 - 7
src/views/saleManage/saleOrder/invoice/components/replaceTable.vue

@@ -1104,12 +1104,19 @@
         if (data) {
           if (type == 'add') {
             data.forEach((item) => {
-              const data = this.warehouseList.find(
-                (val) => val.id == item.warehouseId
-              );
-              item['warehouseId'] = data.id;
-              item['warehouseName'] = data.name;
-              item['warehouseCode'] = data.code;
+              // 台账行仓库信息可能挂在顶层 warehouseId,也可能在 warehouseList 数组里
+              const warehouseId =
+                item.warehouseId ?? item.warehouseList?.[0]?.warehouse_id;
+              const warehouse =
+                this.warehouseList.find((val) => val.id == warehouseId) ||
+                this.warehouseList.find(
+                  (val) => val.name == item.warehouseName
+                );
+              if (warehouse) {
+                item['warehouseId'] = warehouse.id;
+                item['warehouseName'] = warehouse.name;
+                item['warehouseCode'] = warehouse.code;
+              }
               item.totalPrice = 0;
               item.singlePrice = 0;
               item.discountSinglePrice = 0;
@@ -1118,7 +1125,9 @@
           }
 
           this.form.datasource = [...this.form.datasource,...data];
-          data.forEach(async (item, index) => {
+          const startIndex = this.form.datasource.length - data.length;
+          data.forEach(async (item, i) => {
+            const index = startIndex + i;
             if (item.warehouseId) {
               this.$set(
                 this.form.datasource[index],