Преглед изворни кода

fix:856【库存台账】【入库操作】所有入库操作,颜色取主数据已维护好的信息

mlchen пре 3 часа
родитељ
комит
1d779370b3
2 измењених фајлова са 111 додато и 18 уклоњено
  1. 108 15
      src/views/warehouseManagement/stockManagement/add.vue
  2. 3 3
      vue.config.js

+ 108 - 15
src/views/warehouseManagement/stockManagement/add.vue

@@ -411,18 +411,27 @@
                   </DictSelection>
                 </el-form-item>
               </template>
-              <template v-slot:colorKey="{ row, $index }">
+              <template v-slot:colorKey="{ row }">
                 <el-form-item>
-                  <DictSelection
-                    dictName="物品颜色"
-                    clearable
+                  <el-select
                     v-model="row.colorKey"
-                    :isOne="$index === 0"
+                    style="width: 100%"
+                    clearable
                     filterable
-                    allow-create
-                    default-first-option
+                    :placeholder="
+                      row.colorOptions && row.colorOptions.length
+                        ? '请选择'
+                        : '主数据未维护颜色'
+                    "
                   >
-                  </DictSelection>
+                    <el-option
+                      v-for="color in row.colorOptions"
+                      :key="color"
+                      :label="color"
+                      :value="color"
+                    >
+                    </el-option>
+                  </el-select>
                 </el-form-item>
               </template>
 
@@ -707,16 +716,25 @@
           </el-table-column>
           <el-table-column label="颜色" prop="colorKey" width="300">
             <template slot-scope="{ row }">
-              <DictSelection
-                dictName="物品颜色"
-                clearable
+              <el-select
                 v-model="row.colorKey"
-                :isOne="false"
+                style="width: 100%"
+                clearable
                 filterable
-                allow-create
-                default-first-option
+                :placeholder="
+                  row.colorOptions && row.colorOptions.length
+                    ? '请选择'
+                    : '主数据未维护颜色'
+                "
               >
-              </DictSelection>
+                <el-option
+                  v-for="color in row.colorOptions"
+                  :key="color"
+                  :label="color"
+                  :value="color"
+                >
+                </el-option>
+              </el-select>
             </template>
           </el-table-column>
 
@@ -1510,6 +1528,7 @@
                 // 编辑时单位选择消失bug
               };
             });
+            await this.fillColorOptions(this.productList);
             // this.$nextTick(() => {
             //   this.listSaveArrs();
             // });
@@ -1524,6 +1543,68 @@
       changeCount(number) {
         return new BigNumber(number).toString();
       },
+      // 按物品编码批量取主数据维护的颜色(一次请求,供本页所有行共用)
+      async fetchColorOptionsByCodes(rows) {
+        const codes = Array.from(
+          new Set(
+            (rows || [])
+              .map((item) => item && item.categoryCode)
+              .filter((code) => !!code)
+          )
+        );
+        if (!codes.length) return {};
+        let list = [];
+        try {
+          list =
+            (await outin.getListByNameOrModeType({ codeList: codes })) || [];
+        } catch (error) {
+          // 取色失败不阻塞页面初始化(401/网络异常已由 request.js 统一提示)
+          console.warn('主数据颜色获取失败', error);
+          return {};
+        }
+        const colorMap = {};
+        list.forEach((item) => {
+          // 主数据颜色是英文逗号串:去空格、去空值、去重,保持主数据原顺序
+          colorMap[item.code] = Array.from(
+            new Set(
+              String(item.colorKey || '')
+                .split(',')
+                .map((color) => color.trim())
+                .filter((color) => !!color)
+            )
+          );
+        });
+        return colorMap;
+      },
+      // 给产品行挂上主数据颜色选项;历史颜色不在选项内也不清空
+      async fillColorOptions(rows) {
+        const list = rows || [];
+        let colorMap = {};
+        try {
+          colorMap = await this.fetchColorOptionsByCodes(list);
+        } catch (error) {
+          // 兜底:任何取色异常都只退化为「无颜色选项」,不影响调用方流程
+          console.warn('主数据颜色填充失败', error);
+        }
+        list.forEach((row) => {
+          if (!row) return;
+          this.$set(row, 'colorOptions', colorMap[row.categoryCode] || []);
+        });
+        return list;
+      },
+      // 包装行颜色选项继承对应产品行(按 parentIndex 对应)
+      fillPackingColorOptions(packingRows, productRows) {
+        const map = {};
+        (productRows || []).forEach((row) => {
+          if (!row) return;
+          map[String(row.index)] = row.colorOptions || [];
+        });
+        (packingRows || []).forEach((row) => {
+          if (!row) return;
+          const options = map[String(row.parentIndex)];
+          this.$set(row, 'colorOptions', options ? options.slice() : []);
+        });
+      },
       viewInit() {
         const _this = this;
         // 编辑时选单位没有选项bug
@@ -1631,6 +1712,8 @@
               }
             }
             this.packingList = arr;
+            await this.fillColorOptions(this.productList);
+            this.fillPackingColorOptions(this.packingList, this.productList);
             // 获取物料维度数据
             let iArr = [];
             arr.forEach((item) => {
@@ -2002,6 +2085,13 @@
             // }
             return item;
           });
+          await this.fillColorOptions(this.productList);
+          this.productList.forEach((productItem) => {
+            this.fillPackingColorOptions(
+              productItem.outInDetailRecordRequestList,
+              this.productList
+            );
+          });
           console.log(this.productList, 'productList');
           this.$nextTick(() => {
             this.batchSave();
@@ -2435,6 +2525,7 @@
                 isUnpack: item.isUnpack // 是否允许拆包
               };
             });
+            await this.fillColorOptions(this.productList);
             console.log(this.productList);
             this.handleAvatarSuccess();
             loading.close();
@@ -2944,6 +3035,7 @@
           };
         });
         this.productList = this.productList.concat(productList);
+        await this.fillColorOptions(productList);
         console.log('this.productList--------', this.productList);
       },
       // 产品信息行的必填字段(生产入库额外要求生产日期/失效日期)
@@ -3733,6 +3825,7 @@
           );
           this.packingList.splice(packingIndex + 1, 0, ...packingList);
         }
+        this.fillPackingColorOptions(packingList, [row]);
 
         const lastIndex = this.packingList.length - 1;
 

+ 3 - 3
vue.config.js

@@ -2,7 +2,7 @@
  * @Author: mlchen 374826075@qq.com
  * @Date: 2026-07-21 09:26:11
  * @LastEditors: mlchen 374826075@qq.com
- * @LastEditTime: 2026-10-14 16:10:16
+ * @LastEditTime: 2026-11-18 09:14:18
  * @FilePath: /kd-aiot-frontend-wms/vue.config.js
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -43,8 +43,8 @@ module.exports = {
         // target: 'http://124.71.68.31:50001',
         // target: 'http://192.168.1.132:18086',
         // target: 'http://192.168.1.105:18086', //开发
-        target: 'http://localhost:18086', //开发
-        // target: 'http://192.168.1.251:18086', //测试
+        // target: 'http://localhost:18086', //开发
+        target: 'http://192.168.1.251:18086', //测试
         // target: 'http://192.168.1.116:18086',
 
         // target: 'http://192.168.1.116:18086',