Przeglądaj źródła

颜色机型的选择框修改成单选

695593266@qq.com 1 miesiąc temu
rodzic
commit
d8008397d9

+ 8 - 0
.claude/settings.local.json

@@ -0,0 +1,8 @@
+{
+  "permissions": {
+    "allow": [
+      "mcp__ide__getDiagnostics",
+      "Bash(xargs grep *)"
+    ]
+  }
+}

+ 9 - 0
src/api/saleOrder/index.js

@@ -381,3 +381,12 @@ export async function getErpSalesOrder(params) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+//通过id获取颜色机型信息
+export async function getColorModelInfoById(id) {
+  const res = await request.get(`/main/category/keyInfo/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 11 - 1
src/mixins/tableColumnsMixin.js

@@ -128,7 +128,17 @@ export default {
 
       // 合并保留的对象和新增的对象
       console.log(updated, 'dsds');
-      return { nlist: [...updated, ...added], type: updateType };
+      const merged = [...updated, ...added];
+      const seen = new Set();
+      const deduped = merged.filter((item) => {
+        const k =
+          item && (item.id || item.prop || item.columnKey || item.label);
+        if (!k) return true;
+        if (seen.has(k)) return false;
+        seen.add(k);
+        return true;
+      });
+      return { nlist: deduped, type: updateType };
     },
 
     // 提交columns配置

+ 58 - 55
src/views/productionPlan/components/factoryAdd/index.vue

@@ -202,16 +202,15 @@
               <el-select
                 clearable
                 v-model="row.modelKey"
-                multiple
                 filterable
                 allow-create
                 default-first-option
               >
                 <el-option
-                  v-for="item in modelList"
-                  :key="item.label"
-                  :value="item.label"
-                  :label="item.label"
+                  v-for="item in row.modelList"
+                  :key="item"
+                  :value="item"
+                  :label="item"
                 >
                 </el-option>
               </el-select>
@@ -220,16 +219,15 @@
               <el-select
                 clearable
                 v-model="row.colorKey"
-                multiple
                 filterable
                 allow-create
                 default-first-option
               >
                 <el-option
-                  v-for="item in colorList"
-                  :key="item.label"
-                  :value="item.label"
-                  :label="item.label"
+                  v-for="item in row.colorList"
+                  :key="item"
+                  :value="item"
+                  :label="item"
                 >
                 </el-option>
               </el-select>
@@ -515,14 +513,14 @@
   import { getCode } from '@/api/codeManagement';
   import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
   import { parameterGetByCode } from '@/api/mainData/index';
-  import { getByCode } from '@/api/system/dictionary-data';
   import {
     bomRoutingList,
     bomListByPlan,
     getFactoryList,
     saveAndRelease,
     temporaryPlanSave,
-    getUpdateInfoByCode
+    getUpdateInfoByCode,
+    getColorModelInfoById
   } from '@/api/saleOrder';
   import { planIsReview } from '@/api/productionPlan/index';
   import contactDialog from '@/components/contactDialog/openContactDialog.vue';
@@ -929,31 +927,6 @@
     // },
     mounted() {},
     methods: {
-      // 获取
-      async getCodeData() {
-        let arr1 = await this.getLevelCode('product_model_key');
-        let arr2 = await this.getLevelCode('product_color_key');
-        this.modelList = arr1;
-        this.colorList = arr2;
-      },
-      async getLevelCode(code) {
-        try {
-          const res = await getByCode(code);
-          if (res.code == 0) {
-            let list = Object.values(res.data).map((el) => {
-              let k = Object.keys(el)[0];
-              let v = Object.values(el)[0];
-              return {
-                label: v,
-                value: k
-              };
-            });
-            return list;
-          }
-        } catch (err) {
-          this.$message.error(err.message);
-        }
-      },
       selectFactory(e, row) {
         let data = this.factoryList.find((item) => item.id === e);
         this.$set(row, 'factoriesName', data.name);
@@ -993,7 +966,6 @@
         const [processingRes, saleOrderRes] = await Promise.all([
           parameterGetByCode({ code: 'production_plan_code' }),
           parameterGetByCode({ code: 'create_plan_binding_sale_order' }),
-          this.getCodeData(),
           this.getFactoryList(),
           this.getPlannedReleaseRequire('planned_release_require')
         ]);
@@ -1060,17 +1032,37 @@
           );
         }
 
-        const resAll = await Promise.all(
-          productList.map((item) => findBomCategoryByCategoryId(item.categoryId))
-        );
+        const [resAll, infoAll] = await Promise.all([
+          Promise.all(
+            productList.map((item) => findBomCategoryByCategoryId(item.categoryId))
+          ),
+          Promise.all(
+            productList.map(async (item) => {
+              try {
+                return (await getColorModelInfoById(item.categoryId)) || {};
+              } catch (e) {
+                return {};
+              }
+            })
+          )
+        ]);
 
         productList.forEach((item, index) => {
-          if (typeof item.colorKey === 'string' && item.colorKey) {
-            this.$set(productList[index], 'colorKey', item.colorKey.split(','));
-          }
-          if (typeof item.modelKey === 'string' && item.modelKey) {
-            this.$set(productList[index], 'modelKey', item.modelKey.split(','));
-          }
+          const info = infoAll[index] || {};
+          const colorKey = info.colorKey || '';
+          const modelKey = info.modelKey || '';
+          this.$set(productList[index], 'colorList', colorKey ? colorKey.split(',') : []);
+          this.$set(productList[index], 'modelList', modelKey ? modelKey.split(',') : []);
+          this.$set(
+            productList[index],
+            'colorKey',
+            item.colorKey || (colorKey ? colorKey.split(',')[0] : '')
+          );
+          this.$set(
+            productList[index],
+            'modelKey',
+            item.modelKey || (modelKey ? modelKey.split(',')[0] : '')
+          );
 
           if (!resAll[index]) return;
 
@@ -1118,9 +1110,17 @@
         }
         let ids = this.form.productInfoList.map((item) => item.categoryId);
 
-        let result = list
-          .filter((i) => !ids.includes(i.id))
-          .map((item, index) => {
+        const filtered = list.filter((i) => !ids.includes(i.id));
+        let result = await Promise.all(
+          filtered.map(async (item) => {
+            let info = {};
+            try {
+              info = (await getColorModelInfoById(item.id)) || {};
+            } catch (e) {
+              info = {};
+            }
+            const colorKey = info.colorKey || '';
+            const modelKey = info.modelKey || '';
             return {
               categoryId: item.id,
               productCode: item.code,
@@ -1135,13 +1135,16 @@
               produceRoutingName: item.produceRoutingName,
               produceVersionName: item.produceVersionName,
               factoriesId: this.factoriesId,
-              colorKey: item.colorKey ? item.colorKey.split(',') : [],
-              modelKey: item.modelKey ? item.modelKey.split(',') : [],
+              colorList: colorKey ? colorKey.split(',') : [],
+              modelList: modelKey ? modelKey.split(',') : [],
+              colorKey: colorKey ? colorKey.split(',')[0] : '',
+              modelKey: modelKey ? modelKey.split(',')[0] : '',
               factoriesName: this.factoryList?.find(
                 (factoryData) => factoryData.id === this.factoriesId
               )?.name
             };
-          });
+          })
+        );
         // this.form.productInfoList = [];
 
         //  取出在弹窗中选中并且不在表格中的数据
@@ -1467,8 +1470,8 @@
           const isAdd = !this.form.id;
 
           this.form.productInfoList.forEach((item) => {
-            item.colorKey = item.colorKey.toString();
-            item.modelKey = item.modelKey.toString();
+            item.colorKey = item.colorKey == null ? '' : String(item.colorKey);
+            item.modelKey = item.modelKey == null ? '' : String(item.modelKey);
             if (isAdd) delete item.selectionRowShow;
           });
 

+ 0 - 48
src/views/requirementListPlan/components/orderList.vue

@@ -15,54 +15,6 @@
       label-width="140px"
     >
       <el-row :gutter="10" class="basic">
-        <!-- <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
-          <el-form-item label="计划编号:">
-            <el-input v-model="form.planCode" disabled></el-input>
-          </el-form-item>
-        </el-col>
-
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
-          <el-form-item label="批次号:">
-            <el-input v-model="form.batchNo" disabled></el-input>
-          </el-form-item>
-        </el-col>
-
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
-          <el-form-item label="编码:">
-            <el-input v-model="form.categoryCode" disabled></el-input>
-          </el-form-item>
-        </el-col>
-
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
-          <el-form-item label="名称:">
-            <el-input v-model="form.categoryName" disabled></el-input>
-          </el-form-item>
-        </el-col>
-
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
-          <el-form-item label="零部件图号:">
-            <el-input v-model="form.imgCode" disabled></el-input>
-          </el-form-item>
-        </el-col>
-
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
-          <el-form-item label="需求订单号:">
-            <el-input v-model="form.code" disabled></el-input>
-          </el-form-item>
-        </el-col>
-
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
-          <el-form-item label="顶级产品编号:">
-            <el-input v-model="form.topCategoryName" disabled></el-input>
-          </el-form-item>
-        </el-col>
-
-        <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
-          <el-form-item label="顶级产品名称:">
-            <el-input v-model="form.topCategoryName" disabled></el-input>
-          </el-form-item>
-        </el-col> -->
-
         <el-col
           v-for="item in baseFields"
           :key="item.prop"

+ 57 - 50
src/views/saleOrder/components/create-order.vue

@@ -234,17 +234,16 @@
                 <el-select
                   clearable
                   v-model="scope.row.modelKey"
-                  multiple
                   filterable
                   allow-create
                   default-first-option
                   :disabled="isOrderSource"
                 >
                   <el-option
-                    v-for="item in modelList"
-                    :key="item.label"
-                    :value="item.label"
-                    :label="item.label"
+                    v-for="item in scope.row.modelList"
+                    :key="item"
+                    :value="item"
+                    :label="item"
                   >
                   </el-option>
                 </el-select>
@@ -265,17 +264,16 @@
                 <el-select
                   clearable
                   v-model="scope.row.colorKey"
-                  multiple
                   filterable
                   allow-create
                   default-first-option
                   :disabled="isOrderSource"
                 >
                   <el-option
-                    v-for="item in colorList"
-                    :key="item.label"
-                    :value="item.label"
-                    :label="item.label"
+                    v-for="item in scope.row.colorList"
+                    :key="item"
+                    :value="item"
+                    :label="item"
                   >
                   </el-option>
                 </el-select>
@@ -686,7 +684,8 @@
     bomListByPlan,
     bomRoutingList,
     getFactoryList,
-    findBomCategoryByCategoryIds
+    findBomCategoryByCategoryIds,
+    getColorModelInfoById
   } from '@/api/saleOrder';
   import { listBomType } from '@/api/productionPlan/index';
   import { parameterGetByCode } from '@/api/mainData/index';
@@ -841,7 +840,7 @@
     mounted() {
       this.mandatoryField();
       this.getFactoryList();
-      this.getCodeData();
+      // this.getCodeData();
     },
     methods: {
       selectPersonnel() {
@@ -924,34 +923,36 @@
         getOrderDetail(code).then(async (res) => {
           console.log(res, 'res');
           if (res.productInfoList) {
-            for (let item of res.productInfoList) {
-              if (!item.bomCategoryId) {
-                item.productType = '';
-                item.selectionRowShow = true;
-              } else {
-                item.selectionRowShow = false;
-              }
-              if (item.productType) {
-                item.productType = parseInt(item.productType);
-              }
-            }
+            await Promise.all(
+              res.productInfoList.map(async (item) => {
+                if (!item.bomCategoryId) {
+                  item.productType = '';
+                  item.selectionRowShow = true;
+                } else {
+                  item.selectionRowShow = false;
+                }
+                if (item.productType) {
+                  item.productType = parseInt(item.productType);
+                }
+                let info = {};
+                try {
+                  info = (await getColorModelInfoById(item.categoryId)) || {};
+                } catch (e) {
+                  info = {};
+                }
+                const colorKey = info.colorKey || '';
+                const modelKey = info.modelKey || '';
+                item.colorList = colorKey ? colorKey.split(',') : [];
+                item.modelList = modelKey ? modelKey.split(',') : [];
+                item.colorKey =
+                  item.colorKey || (colorKey ? colorKey.split(',')[0] : '');
+                item.modelKey =
+                  item.modelKey || (modelKey ? modelKey.split(',')[0] : '');
+              })
+            );
           }
           if (res.productInfoList && res.productInfoList.length != 0) {
             res.productInfoList.forEach((item, index) => {
-              if (item.colorKey && typeof item.colorKey == 'string') {
-                this.$set(
-                  res.productInfoList[index],
-                  'colorKey',
-                  item.colorKey.split(',')
-                );
-              }
-              if (item.modelKey && typeof item.modelKey == 'string') {
-                this.$set(
-                  res.productInfoList[index],
-                  'modelKey',
-                  item.modelKey.split(',')
-                );
-              }
               item.lackNum = null;
               if (item.bomVersionList?.length && item.productType) {
                 item.bomVersionList = item.bomVersionList.filter(
@@ -1151,8 +1152,8 @@
             params.productInfoList.forEach((el) => delete el.id);
           }
           params.productInfoList.forEach((item) => {
-            item.colorKey = item.colorKey.toString();
-            item.modelKey = item.modelKey.toString();
+            item.colorKey = item.colorKey == null ? '' : String(item.colorKey);
+            item.modelKey = item.modelKey == null ? '' : String(item.modelKey);
           });
 
           createOrUpdate(params)
@@ -1248,17 +1249,20 @@
       // 确定选择
       async confirmChoose(list) {
         list.map((el) => (el.selectionRowShow = false));
-        list = list
-          .filter(
-            (i) =>
-              !this.disabledList.find(
-                (p) => p.productCode == i.code || p.productCode == i.productCode
-              )
-          )
-          .map((item, index) => {
+        const filtered = list.filter(
+          (i) =>
+            !this.disabledList.find(
+              (p) => p.productCode == i.code || p.productCode == i.productCode
+            )
+        );
+        const mapped = await Promise.all(
+          filtered.map(async (item, index) => {
             if (item.productCode) {
               return item;
             } else {
+              const info = (await getColorModelInfoById(item.id)) || {};
+              const colorKey = info.colorKey || '';
+              const modelKey = info.modelKey || '';
               return {
                 categoryId: item.id,
                 productCode: item.code,
@@ -1269,12 +1273,15 @@
                 specification: item.specification,
                 brandNo: item.brandNum,
                 measuringUnit: item.measuringUnit,
-                colorKey: item.colorKey ? item.colorKey.split(',') : [],
-                modelKey: item.modelKey ? item.modelKey.split(',') : []
+                colorList: colorKey ? colorKey.split(',') : [],
+                modelList: modelKey ? modelKey.split(',') : [],
+                colorKey: colorKey ? colorKey.split(',')[0] : '',
+                modelKey: modelKey ? modelKey.split(',')[0] : ''
               };
             }
           })
-          .concat(this.disabledList);
+        );
+        list = mapped.concat(this.disabledList);
         // 取出在弹窗中选中并且不在表格中的数据
         const result = list.filter(
           (i) =>

+ 156 - 54
src/views/saleOrder/salesToProductionNewTwo.vue

@@ -415,16 +415,15 @@
               <el-select
                 clearable
                 v-model="scope.row.modelKey"
-                multiple
                 filterable
                 allow-create
                 default-first-option
               >
                 <el-option
-                  v-for="item in modelList"
-                  :key="item.label"
-                  :value="item.label"
-                  :label="item.label"
+                  v-for="item in scope.row.modelList"
+                  :key="item"
+                  :value="item"
+                  :label="item"
                 >
                 </el-option>
               </el-select>
@@ -440,16 +439,15 @@
               <el-select
                 clearable
                 v-model="scope.row.colorKey"
-                multiple
                 filterable
                 allow-create
                 default-first-option
               >
                 <el-option
-                  v-for="item in colorList"
-                  :key="item.label"
-                  :value="item.label"
-                  :label="item.label"
+                  v-for="item in scope.row.colorList"
+                  :key="item"
+                  :value="item"
+                  :label="item"
                 >
                 </el-option>
               </el-select>
@@ -878,7 +876,8 @@
     bomRoutingList,
     bomListByPlan,
     getFactoryList,
-    getInventoryTotalAPI
+    getInventoryTotalAPI,
+    getColorModelInfoById
   } from '@/api/saleOrder';
   import {
     findBomCategoryByCategoryId,
@@ -1019,7 +1018,7 @@
     },
     mounted() {
       this.mandatoryField();
-      this.getCodeData();
+      // this.getCodeData();
       this.getplannedReleaseRequire('planned_release_require');
       parameterGetByCode({ code: 'salesToProduction_batchNo' }).then((res) => {
         if (res) {
@@ -1070,6 +1069,51 @@
         this.modelList = arr1;
         this.colorList = arr2;
       },
+      // 根据 categoryId 给每一行填充机型/颜色可选项
+      async fillColorModelInfo(item) {
+        let info = {};
+        try {
+          info = (await getColorModelInfoById(item.categoryId)) || {};
+        } catch (e) {
+          info = {};
+        }
+        const colorKey = info.colorKey || '';
+        const modelKey = info.modelKey || '';
+        const baseColorList = colorKey ? colorKey.split(',') : [];
+        const baseModelList = modelKey ? modelKey.split(',') : [];
+
+        let curColor = item.colorKey;
+        if (Array.isArray(curColor)) {
+          curColor = curColor[0] || '';
+        } else if (typeof curColor !== 'string') {
+          curColor = '';
+        }
+        if (!curColor && baseColorList.length) {
+          curColor = baseColorList[0];
+        }
+        let curModel = item.modelKey;
+        if (Array.isArray(curModel)) {
+          curModel = curModel[0] || '';
+        } else if (typeof curModel !== 'string') {
+          curModel = '';
+        }
+        if (!curModel && baseModelList.length) {
+          curModel = baseModelList[0];
+        }
+
+        const mergedColorList = Array.from(
+          new Set([...baseColorList, curColor].filter((v) => v !== '' && v != null))
+        );
+        const mergedModelList = Array.from(
+          new Set([...baseModelList, curModel].filter((v) => v !== '' && v != null))
+        );
+
+        this.$set(item, 'colorList', mergedColorList);
+        this.$set(item, 'modelList', mergedModelList);
+        this.$set(item, 'colorKey', curColor);
+        this.$set(item, 'modelKey', curModel);
+        return item;
+      },
       async getLevelCode(code) {
         try {
           const res = await getByCode(code);
@@ -1109,6 +1153,7 @@
           return;
         }
         const producedList = JSON.parse(this.$route.query.producedList);
+        console.log(producedList, 'producedList');
         this.producedList = producedList;
       },
       // 初始化时间赋值
@@ -1172,6 +1217,12 @@
         }
         if (data.salesOrders && data.salesOrders.length > 0) {
           this.form.factoriesId = data.salesOrders[0].factoriesId;
+          await Promise.all(
+            this.form.salesOrders.map(async (item, index) => {
+              await this.fillColorModelInfo(item);
+              this.$set(this.form.salesOrders, index, item);
+            })
+          );
         }
         // this.form.factoriesId = data.salesOrders
         //   ? data.salesOrders[0].factoriesId
@@ -1322,7 +1373,24 @@
 
       getSaleInfo() {
         let params = JSON.parse(this.$route.query.selection);
-        productionToPlan(params).then((res) => {
+        productionToPlan(params).then(async (res) => {
+          // 先初始化每行的下拉可选列表,保证 el-select 初次渲染就能显示已选项
+          if (Array.isArray(res?.salesOrders)) {
+            res.salesOrders.forEach((item) => {
+              if (Array.isArray(item.colorKey)) {
+                item.colorKey = item.colorKey[0] || '';
+              } else if (typeof item.colorKey !== 'string') {
+                item.colorKey = '';
+              }
+              if (Array.isArray(item.modelKey)) {
+                item.modelKey = item.modelKey[0] || '';
+              } else if (typeof item.modelKey !== 'string') {
+                item.modelKey = '';
+              }
+              item.colorList = item.colorKey ? [item.colorKey] : [];
+              item.modelList = item.modelKey ? [item.modelKey] : [];
+            });
+          }
           this.form = deepClone(res);
           console.log(222222222222222222222222, '===', res);
           this.initTime();
@@ -1369,35 +1437,66 @@
               });
             }
           }
-          this.form.salesOrders.map((item, index) => {
-            if (this.clientEnvironmentId == '4') {
-              this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
-            } else {
-              item.planProductNum = item.lackNum;
-              item.requiredFormingNum = item.lackNum;
-            }
-            item.slottingType = item.slottingType && item.slottingType + '';
-            item.priority = index + 1;
-
-            item.reqMoldTime = item.deliveryTime;
-            if (item.colorKey && typeof item.colorKey == 'string') {
-              this.$set(
-                this.form.salesOrders[index],
-                'colorKey',
-                item.colorKey.split(',')
+          const updatedSalesOrders = await Promise.all(
+            this.form.salesOrders.map(async (item, index) => {
+              if (this.clientEnvironmentId == '4') {
+                this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
+              } else {
+                item.planProductNum = item.lackNum;
+                item.requiredFormingNum = item.lackNum;
+              }
+              item.slottingType = item.slottingType && item.slottingType + '';
+              item.priority = index + 1;
+              item.reqMoldTime = item.deliveryTime;
+
+              let info = {};
+              try {
+                info = (await getColorModelInfoById(item.categoryId)) || {};
+              } catch (e) {
+                info = {};
+              }
+              const colorKey = info.colorKey || '';
+              const modelKey = info.modelKey || '';
+              const baseColorList = colorKey ? colorKey.split(',') : [];
+              const baseModelList = modelKey ? modelKey.split(',') : [];
+
+              let curColor = item.colorKey;
+              if (Array.isArray(curColor)) {
+                curColor = curColor[0] || '';
+              } else if (typeof curColor !== 'string') {
+                curColor = '';
+              }
+              if (!curColor && baseColorList.length) {
+                curColor = baseColorList[0];
+              }
+              let curModel = item.modelKey;
+              if (Array.isArray(curModel)) {
+                curModel = curModel[0] || '';
+              } else if (typeof curModel !== 'string') {
+                curModel = '';
+              }
+              if (!curModel && baseModelList.length) {
+                curModel = baseModelList[0];
+              }
+
+              // 把当前已选的值合并进可选列表,保证 el-select 能正确显示已选项
+              const mergedColorList = Array.from(
+                new Set([...baseColorList, curColor].filter((v) => v !== '' && v != null))
               );
-            }
-            if (item.modelKey && typeof item.modelKey == 'string') {
-              this.$set(
-                this.form.salesOrders[index],
-                'modelKey',
-                item.modelKey.split(',')
+              const mergedModelList = Array.from(
+                new Set([...baseModelList, curModel].filter((v) => v !== '' && v != null))
               );
-            }
-            // dayjs(
-            //     new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
-            // ).format('YYYY-MM-DD');
-          });
+
+              return {
+                ...item,
+                colorList: mergedColorList,
+                modelList: mergedModelList,
+                colorKey: curColor,
+                modelKey: curModel
+              };
+            })
+          );
+          this.$set(this.form, 'salesOrders', updatedSalesOrders);
           if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
             this.form.planType = 2;
           } else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
@@ -1778,19 +1877,22 @@
         let priority =
           this.form.salesOrders[this.form.salesOrders.length - 1]?.priority ||
           0;
-        this.form.salesOrders = this.form.salesOrders.concat(
-          result.map((item, index) => {
-            item.priority = ++priority;
-
-            item.planProductNum = item.lackNum;
-            item.requiredFormingNum = item.lackNum;
-            item.reqMoldTime = dayjs(
-              new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
-            ).format('YYYY-MM-DD');
-            return item;
-          })
+        const newItems = result.map((item, index) => {
+          item.priority = ++priority;
+
+          item.planProductNum = item.lackNum;
+          item.requiredFormingNum = item.lackNum;
+          item.reqMoldTime = dayjs(
+            new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
+          ).format('YYYY-MM-DD');
+          return item;
+        });
+        Promise.all(newItems.map((item) => this.fillColorModelInfo(item))).then(
+          () => {
+            this.form.salesOrders = this.form.salesOrders.concat(newItems);
+            this.changeData();
+          }
         );
-        this.changeData();
       },
       changeData() {
         var planProductNum = 0;
@@ -1815,8 +1917,8 @@
         }
         console.log(params, 'params');
         params.salesOrders.forEach((item) => {
-          item.colorKey = item.colorKey.toString();
-          item.modelKey = item.modelKey.toString();
+          item.colorKey = item.colorKey == null ? '' : String(item.colorKey);
+          item.modelKey = item.modelKey == null ? '' : String(item.modelKey);
         });
 
         if (type === 2) {