chencc 1 rok temu
rodzic
commit
9bf7c84dd0

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

@@ -246,6 +246,16 @@ export async function bomRoutingList(id) {
   return Promise.reject(new Error(res.data.message));
 }
 
+export async function temporaryPlanSave(data) {
+  const res = await request.post(`/aps/productionplan/temporaryPlanSave`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+
+
 //  分厂临时计划修改
 
 export async function temporarilyUpdate(data) {

+ 12 - 8
src/views/materialPlan/components/produceOrder.vue

@@ -45,10 +45,12 @@ export default {
         change: [{ label: '已变更', value: '9' }]
       },
       planType: [
-        { label: '所有计划类型', value: null },
-        { label: '内销计划', value: '1' },
-        { label: '外销计划', value: '2' },
-        { label: '预制计划', value: '3' }
+      { label: '所有计划类型', value: null },
+          { label: '内销计划', value: '1' },
+          { label: '外销计划', value: '2' },
+          { label: '预制计划', value: '3' },
+          { label: '改型计划', value: '4' },
+          { label: '返工返修计划', value: '5' },
       ],
 
       activeName: 'first',
@@ -322,10 +324,12 @@ export default {
       tableData: [],
       current: null,
       planType: [
-        { label: '所有计划类型', value: null },
-        { label: '内销计划', value: '1' },
-        { label: '外销计划', value: '2' },
-        { label: '预制计划', value: '3' }
+      { label: '所有计划类型', value: null },
+          { label: '内销计划', value: '1' },
+          { label: '外销计划', value: '2' },
+          { label: '预制计划', value: '3' },
+          { label: '改型计划', value: '4' },
+          { label: '返工返修计划', value: '5' },
       ],
 
     };

+ 461 - 146
src/views/productionPlan/components/factoryAdd/index.vue

@@ -1,56 +1,111 @@
 <template>
   <!-- :close-on-click-modal="false" -->
-  <ele-modal width="70vw" :visible.sync="visible" custom-class="ele-dialog-form" :title="title" :maxable="true">
+  <ele-modal width="80vw" :visible.sync="visible" custom-class="ele-dialog-form" :title="title" :maxable="true">
+
     <div class="form-wrapper">
-      <el-form ref="form" :model="form" :rules="rules" label-width="90px" class="formbox">
-        <el-row :gutter="24">
+
+      <el-form ref="form" :model="form" :rules="rules" label-width="110px" class="formbox">
+
+        <headerTitle title="基本信息"> </headerTitle>
+        <el-row :gutter="10">
           <el-col :span="6">
-            <el-form-item label="产品名称:" prop="productName">
-              <el-input @click.native="handleAdd" placeholder="请选择物料" v-model="form.productName" size="mini"></el-input>
+            <el-form-item label="计划编号:" prop="code">
+              <el-input placeholder="计划编号" size="mini" disabled v-model="form.code"></el-input>
             </el-form-item>
           </el-col>
-
           <el-col :span="6">
-            <el-form-item label="编码:" prop="productCode">
-              <el-input placeholder="" size="mini" disabled v-model="form.productCode"></el-input>
+            <el-form-item label="计划类型:" prop="planType">
+              <el-select v-model="form.planType" style="width: 100%" @change="changeProduceType" size="mini">
+                <el-option v-for="item of planTypeList" :key="item.value" :label="item.label"
+                  :value="item.value"></el-option>
+              </el-select>
             </el-form-item>
           </el-col>
 
-          <el-col :span="6">
-            <el-form-item label="牌号:" prop="brandNum">
+          <!-- <el-col :span="6">
+            <el-form-item label="加工方式:" prop="produceType">
+              <el-select v-model="form.produceType" style="width: 100%" @change="changeProduceType" size="mini">
+                <el-option v-for="item of producedList" :key="item.code" :label="item.name"
+                  :value="item.code"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col> -->
+
+          <!-- <el-col :span="6">
+            <el-form-item label="工艺路线:" prop="brandNum">
               <el-input placeholder="" size="mini" disabled v-model="form.brandNum"></el-input>
             </el-form-item>
+          </el-col> -->
+          <el-col :span="6">
+            <el-form-item label="批次号:" prop="batchNo">
+              <el-input placeholder="输入批次号" size="mini" v-model="form.batchNo"></el-input>
+            </el-form-item>
           </el-col>
           <el-col :span="6">
-            <el-form-item label="型号:" prop="modelType">
-              <el-input placeholder="" size="mini" disabled v-model="form.modelType"></el-input>
+            <el-form-item label="计划开始日期:" label-width="110px" prop="startTime">
+              <el-date-picker style="width: 100%" size="mini" v-model="form.startTime" :pickerOptions="{
+                disabledDate: (time) =>
+                  time.getTime() <
+                  new Date(new Date().setHours(0, 0, 0, 0)).getTime()
+              }" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
+              </el-date-picker>
             </el-form-item>
           </el-col>
 
         </el-row>
 
         <el-row :gutter="24">
-          
           <el-col :span="6">
-            <el-form-item label="规格:" prop="specification">
-              <el-input placeholder="" size="mini" disabled v-model="form.specification"></el-input>
+            <el-form-item label="计划结束日期:" label-width="110px" prop="endTime">
+              <el-date-picker style="width: 100%" size="mini" v-model="form.endTime" :pickerOptions="{
+                disabledDate: (time) =>
+                  time.getTime() <
+                  new Date(new Date().setHours(0, 0, 0, 0)).getTime()
+              }" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="要求完成日期:" label-width="110px" prop="reqMoldTime">
+              <el-date-picker style="width: 100%" size="mini" v-model="form.reqMoldTime" :pickerOptions="{
+                disabledDate: (time) =>
+                  time.getTime() <
+                  new Date(new Date().setHours(0, 0, 0, 0)).getTime()
+              }" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
+              </el-date-picker>
             </el-form-item>
           </el-col>
+
+          <!-- <el-col :span="6">
+            <el-form-item label="BOM版本:" prop="bomCategoryId" v-if="clientEnvironmentId != 4">
+              <el-select v-model="form.bomCategoryId" style="width: 100%" @change="changeBomId" size="mini">
+                <el-option v-for="item of bomVersionList" :key="item.id"
+                  :label="item.name + '(V' + item.versions + '.0)'" :value="item.id"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col> -->
+          <!-- <el-col :span="6">
+            <el-form-item label="批次号:" prop="batchNo">
+              <el-input v-model="form.batchNo" size="mini" style="width: 100%" placeholder="输入批次号"></el-input>
+            </el-form-item>
+          </el-col> -->
+
         </el-row>
 
-        <headerTitle title="计划信息"> </headerTitle>
+
+        <headerTitle title="产品信息"> </headerTitle>
 
         <el-row :gutter="24">
-          <el-col :span="6">
+          <!-- <el-col :span="6">
             <el-form-item label="加工方式:" prop="produceType">
               <el-select v-model="form.produceType" style="width: 100%" @change="changeProduceType" size="mini">
                 <el-option v-for="item of producedList" :key="item.code" :label="item.name"
                   :value="item.code"></el-option>
               </el-select>
             </el-form-item>
-          </el-col>
+          </el-col> -->
 
-          <el-col :span="6">
+          <!-- <el-col :span="6">
             <el-form-item label="BOM版本:" prop="bomCategoryId" v-if="clientEnvironmentId != 4">
               <el-select v-model="form.bomCategoryId" style="width: 100%" @change="changeBomId" size="mini">
                 <el-option v-for="item of bomVersionList" :key="item.id"
@@ -73,112 +128,228 @@
             <el-form-item label="工艺路线:" prop="produceRoutingId" v-if="clientEnvironmentId == 4">
               <el-input v-model="form.produceRoutingName" style="width: 100%" readonly size="mini"></el-input>
             </el-form-item>
-          </el-col>
-          <el-col :span="6">
-            <el-form-item label="生产数量:" prop="requiredFormingNum">
-              <el-input v-model.number="form.requiredFormingNum" @input="tableHandleKeyUp(form, 'sum')" size="mini"
-                oninput="value=value.replace(/[^\d]/g,'')" style="width: 100%" placeholder="输入数量">
-                <template slot="append">{{ form.measuringUnit }} </template>
-              </el-input>
-            </el-form-item>
-          </el-col>
+          </el-col> -->
+
         </el-row>
 
         <el-row :gutter="24">
-         
-        <div v-if="clientEnvironmentId==4">
-          <el-col :span="6">
-            <el-form-item label="模数:" prop="requiredFormingNum">
-              <el-input v-model.number="form.moCount" @input="tableHandleKeyUp(form, 'moCount')" size="mini"
-                oninput="value=value.replace(/[^\d]/g,'')" style="width: 100%" placeholder="输入模数">
-                <!-- <template slot="append">{{ form.measuringUnit }} </template> -->
-              </el-input>
-            </el-form-item>
-          </el-col>
-
-          <el-col :span="6">
-            <el-form-item label="块数:" prop="requiredFormingNum">
-              <el-input v-model.number="form.blockCount" @input="tableHandleKeyUp(form, 'blockCount')" size="mini"
-                oninput="value=value.replace(/[^\d]/g,'')" style="width: 100%" placeholder="输入块数">
-                <!-- <template slot="append">{{ form.measuringUnit }} </template> -->
-              </el-input>
-            </el-form-item>
-          </el-col>
-
-          <el-col :span="6">
-            <el-form-item label="权重等级:" prop="weight">
-              <el-select v-model="form.weight" style="width: 100%" @change="changeProduceType" size="mini">
-                <el-option v-for="item of weightList" :key="item.code" :label="item.name"
-                  :value="item.code"></el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="6">
-            <el-form-item label="是否开槽:" prop="isSlotting">
-              <el-select v-model="form.isSlotting" style="width: 100%" @change="changeProduceType" size="mini">
-                <el-option v-for="item of isSlotting" :key="item.code" :label="item.name"
-                  :value="item.code"></el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="6" v-if="form.isSlotting == 1">
-            <el-form-item label="开槽类型:" prop="slottingType">
-              <DictSelection
-                dictName="开槽类型"
-                v-model="form.slottingType"
-                size="mini"
-              >
-              </DictSelection>
-            </el-form-item>
-          </el-col>
-        </div>
-
-
-          <el-col :span="6">
-            <el-form-item label="批次号:" prop="batchNo">
-              <el-input v-model="form.batchNo" size="mini" style="width: 100%" placeholder="输入批次号"></el-input>
-            </el-form-item>
-          </el-col>
-
-          <el-col :span="6">
-            <el-form-item label="要求完成日期:" label-width="110px" prop="reqMoldTime">
-              <el-date-picker style="width: 100%" size="mini" v-model="form.reqMoldTime" :pickerOptions="{
-                disabledDate: (time) =>
-                  time.getTime() <
-                  new Date(new Date().setHours(0, 0, 0, 0)).getTime()
-              }" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
-              </el-date-picker>
-            </el-form-item>
-          </el-col>
+          <div v-if="clientEnvironmentId == 4">
+            <el-col :span="6">
+              <el-form-item label="模数:" prop="requiredFormingNum">
+                <el-input v-model.number="form.moCount" @input="tableHandleKeyUp(form, 'moCount')" size="mini"
+                  oninput="value=value.replace(/[^\d]/g,'')" style="width: 100%" placeholder="输入模数">
+                  <!-- <template slot="append">{{ form.measuringUnit }} </template> -->
+                </el-input>
+              </el-form-item>
+            </el-col>
+
+            <el-col :span="6">
+              <el-form-item label="块数:" prop="requiredFormingNum">
+                <el-input v-model.number="form.blockCount" @input="tableHandleKeyUp(form, 'blockCount')" size="mini"
+                  oninput="value=value.replace(/[^\d]/g,'')" style="width: 100%" placeholder="输入块数">
+                  <!-- <template slot="append">{{ form.measuringUnit }} </template> -->
+                </el-input>
+              </el-form-item>
+            </el-col>
+
+            <el-col :span="6">
+              <el-form-item label="权重等级:" prop="weight">
+                <el-select v-model="form.weight" style="width: 100%" @change="changeProduceType" size="mini">
+                  <el-option v-for="item of weightList" :key="item.code" :label="item.name"
+                    :value="item.code"></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="是否开槽:" prop="isSlotting">
+                <el-select v-model="form.isSlotting" style="width: 100%" @change="changeProduceType" size="mini">
+                  <el-option v-for="item of isSlotting" :key="item.code" :label="item.name"
+                    :value="item.code"></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6" v-if="form.isSlotting == 1">
+              <el-form-item label="开槽类型:" prop="slottingType">
+                <DictSelection dictName="开槽类型" v-model="form.slottingType" size="mini">
+                </DictSelection>
+              </el-form-item>
+            </el-col>
+          </div>
+          <el-table :data="form.productInfoList" border height="40vh" key="id">
+            <el-table-column label="序号" align="center" width="60">
+              <template slot-scope="scope">
+                <span>{{ scope.$index + 1 }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column label="行号" align="center" prop="lineNumber">
+            </el-table-column>
+            <el-table-column label="产品名称" align="center" prop="productName">
+            </el-table-column>
+            <el-table-column label="物料编码" align="center" prop="productCode">
+            </el-table-column>
+            <el-table-column label="牌号" align="center" prop="brandNo">
+            </el-table-column>
+            <el-table-column label="型号" align="center" prop="model">
+            </el-table-column>
+            <el-table-column label="规格" align="center" prop="specification">
+            </el-table-column>
+            <el-table-column label="单重" align="center" prop="productUnitWeight">
+            </el-table-column>
+            <el-table-column label="重量单位" align="center" prop="weightUnit">
+            </el-table-column>
+            <el-table-column label="要求生产数量" width="140" align="center" prop="">
+              <template slot-scope="scope">
+                <!-- :prop="'requiredFormingNum.' + scope.$index + '.requiredFormingNum'" :rules="{
+                  required: true,
+                  message: '请输入要求生产数量',
+                  trigger: 'blur'
+                }" -->
+
+                <el-form-item label-width="0px">
+                  <el-input v-model.number="scope.row.requiredFormingNum" size="small" type="number" style="width: 100%"
+                    placeholder="输入数量" @input="inputNumber(scope.row, scope.$index)"></el-input>
+                </el-form-item>
+              </template>
+            </el-table-column>
+
+
+
+            <el-table-column label="加工方式" width="140" align="center" prop="productType">
+              <template slot-scope="scope">
+                <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.productType'">
+
+                  <el-select v-model="scope.row.productType" @change="changeProductType(scope.row, scope.$index)"
+                    :key="scope.$index">
+                    <el-option v-for="item of producedList" :key="scope.$index + item.code" :label="item.name"
+                      :value="item.code"></el-option>
+                  </el-select>
+
+                </el-form-item>
+              </template>
+            </el-table-column>
+
+
+
+            <el-table-column label="BOM版本" width="140" align="center" prop="bomCategoryId"
+              v-if="clientEnvironmentId != 4">
+              <template slot-scope="scope">
+                <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.bomCategoryId'"
+                  :key="scope.$index">
+
+                  <el-select v-model="scope.row.bomCategoryId" @change="changeBomId(scope.row, scope.$index)">
+                    <el-option v-for="item of scope.row.bomVersionList" :key="item.id"
+                      :label="item.name + '(V' + item.versions + '.0)'" :value="item.id"></el-option>
+                  </el-select>
+
+                </el-form-item>
+              </template>
+            </el-table-column>
+
+            <el-table-column label="工艺路线" width="140" align="center" prop="produceRoutingId"
+              v-if="clientEnvironmentId != 4">
+              <template slot-scope="scope">
+                <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.produceRoutingId'">
+                  <el-select v-model="scope.row.produceRoutingId">
+                    <el-option v-for="item of scope.row.routingList" :key="item.id" :label="item.name"
+                      :value="item.id"></el-option>
+                  </el-select>
+
+                </el-form-item>
+              </template>
+            </el-table-column>
+
+            <el-table-column label="工艺路线" align="center" prop="produceRoutingName" v-if="clientEnvironmentId == 4">
+              <template slot-scope="scope">
+                <el-form-item label-width="0px" :prop="'productInfoList.' + scope.$index + '.produceRoutingName'">
+                  <el-input v-model="form.produceRoutingName" style="width: 100%" readonly></el-input>
+
+                </el-form-item>
+              </template>
+            </el-table-column>
+
+            <!-- <el-table-column label="所属工厂" width="140" align="center" prop="factoriesId">
+              <template slot-scope="scope">
+                <el-form-item label-width="0px">
+
+                  <el-select v-model="scope.row.factoriesId" :key="scope.row.factoriesId">
+                    <el-option v-for="item of factoryList" :key="item.id" :label="item.name"
+                      :value="item.id"></el-option>
+                  </el-select>
+
+                </el-form-item>
+              </template>
+            </el-table-column> -->
+
+            <!-- <el-table-column label="所属工厂" width="140" align="center" prop="factoriesId">
+              <template slot-scope="scope">
+                <el-form-item label-width="0px">
+
+                  <el-select v-model="scope.row.factoriesId" :key="scope.row.factoriesId">
+                    <el-option v-for="item of factoryList" :key="item.id" :label="item.name"
+                      :value="item.id"></el-option>
+                  </el-select>
+
+                </el-form-item>
+              </template>
+            </el-table-column> -->
+
+
+
+
+            <el-table-column label="计量单位" align="center" prop="measuringUnit">
+
+            </el-table-column>
+            <el-table-column label="模数" align="center" width="100" v-if="clientEnvironmentId == '4'">
+              <template slot-scope="scope">
+                <div>
+                  <el-input style="width: 100%" size="small" v-model="scope.row.moCount"
+                    oninput="value=value.replace(/[^0-9.]/g,'')" @input="
+                      tableHandleKeyUp(scope.row, scope.$index, $event, 'moCount')
+                      " placeholder="请输入">
+                  </el-input>
+                </div>
+              </template>
+            </el-table-column>
+
+            <el-table-column align="center" width="100" label="块数" v-if="clientEnvironmentId == '4'">
+              <template slot-scope="scope">
+                <div>
+                  <el-input size="small" style="width: 100%" @input="
+                    tableHandleKeyUp(
+                      scope.row,
+                      scope.$index,
+                      $event,
+                      'blockCount'
+                    )
+                    " v-model="scope.row.blockCount" placeholder="请输入"></el-input>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="订单重量" align="center" prop="productWeight">
+              <template slot-scope="{ row }">
+                <span>{{ row.productWeight ? row.productWeight : '-' }}</span>
+              </template>
+            </el-table-column>
+            <!-- <el-table-column label="操作" align="center" width="70">
+              <template slot-scope="scope">
+                <el-link type="primary" :underline="false" @click="homogeneityInspect(scope.row)">
+                  齐套性检查
+                </el-link>
+                <el-button type="text" @click="handleDeleteItem(scope.$index)" v-if="!scope.row.id">删除</el-button>
+              </template>
+
+            </el-table-column> -->
+          </el-table>
+          <div class="add-product" @click="addEquipment">
+            <i class="el-icon-circle-plus-outline"></i>
+          </div>
         </el-row>
 
-        <el-row :gutter="24">
-          <el-col :span="6">
-            <el-form-item label="计划开始日期:" label-width="110px" prop="startTime">
-              <el-date-picker style="width: 100%" size="mini" v-model="form.startTime" :pickerOptions="{
-                disabledDate: (time) =>
-                  time.getTime() <
-                  new Date(new Date().setHours(0, 0, 0, 0)).getTime()
-              }" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
-              </el-date-picker>
-            </el-form-item>
-          </el-col>
 
-          <el-col :span="6">
-            <el-form-item label="计划结束日期:" label-width="110px" prop="endTime">
-              <el-date-picker style="width: 100%" size="mini" v-model="form.endTime" :pickerOptions="{
-                disabledDate: (time) =>
-                  time.getTime() <
-                  new Date(new Date().setHours(0, 0, 0, 0)).getTime()
-              }" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
-              </el-date-picker>
-            </el-form-item>
-          </el-col>
-        </el-row>
       </el-form>
 
       <!-- 选择产品 -->
-      <EquipmentDialog ref="equipmentRefs" @choose="confirmChoose" :selectList="[]">
+      <EquipmentDialog @choose="confirmChoose" :selectList="[]" ref="equipmentRefs">
       </EquipmentDialog>
     </div>
 
@@ -193,12 +364,15 @@
 
 <script>
 import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
+
 import { getCode } from '@/api/codeManagement';
 import {
   bomRoutingList,
   bomListByPlan,
   saveSaleToPlan,
-  temporarilyUpdate
+  getFactoryList,
+  temporarilyUpdate,
+  temporaryPlanSave
 } from '@/api/saleOrder';
 
 export default {
@@ -223,10 +397,10 @@ export default {
 
 
         // this.type = val;
-        this.title = !val.id ? '新增临时计划' : '编辑临时计划';
+        this.title = !val.id ? '新增临时生产计划' : '编辑临时生产计划';
         // this.form = this.factoryObj;
 
-
+        // this.getFactoryList();
 
         this.form = val;
         // 修改
@@ -258,10 +432,18 @@ export default {
         { code: 2, name: 'B' },
         { code: 3, name: 'C' }
       ],
+      factoryList: [],
       isSlotting: [
         { code: 1, name: '是' },
         { code: 2, name: '否' }
       ], //是否开槽
+      planTypeList: [
+        { label: '内销计划', value: '1' },
+        { label: '外销计划', value: '2' },
+        { label: '预制计划', value: '3' },
+        { label: '改型计划', value: '4' },
+        { label: '返工返修计划', value: '5' },
+      ],
       loading: false,
       form: {
         timeDimensionPlanType: 3,
@@ -271,16 +453,19 @@ export default {
         moCount: '', // 模具数量
         blockCount: 0, // 块数
         noWordCount: '',// 无字数量
-        weight:'',
-        isSlotting:'',//是否开槽
-        slottingType:'',//开槽类型
+        weight: '',
+        startTime: '',
+        endTime: '',
+        isSlotting: '',//是否开槽
+        slottingType: '',//开槽类型
         id: '',
         produceType: 2,
         bomCategoryId: '',
         produceRoutingId: '',
-        requiredFormingNum: ''
+        requiredFormingNum: '',
+        productInfoList: []
       },
-
+      disabledList: [],
       bomVersionList: [],
       routingList: [],
       rules: {
@@ -321,8 +506,13 @@ export default {
     }
   },
   methods: {
+    async getFactoryList() {
+      this.factoryList = await getFactoryList();
+    },
     open() {
 
+      console.log('this.form', this.form);
+
       this.visible = true;
 
       //this.clientEnvironmentId 环境判断 宝悦环境
@@ -333,7 +523,7 @@ export default {
       // this.getPlanRoutingNew();
     },
 
-    handleAdd() {
+    addEquipment() {
       this.$refs.equipmentRefs.open();
     },
 
@@ -359,6 +549,75 @@ export default {
         this.$set(this.form, 'produceVersionName', data.produceVersionName);
       }
 
+      console.log('list', list);
+
+
+      list = list.filter(
+        (i) =>
+          !this.disabledList.find(
+            (p) => p.productCode == i.code || p.productCode == i.productCode
+          )
+      )
+        .map((item, index) => {
+
+          if (item.productCode) {
+            return item;
+          } else {
+            return {
+              categoryId: item.id,
+              productCode: item.code,
+              productName: item.name,
+              productUnitWeight: item.netWeight,
+              weightUnit: item.weightUnit,
+              model: item.modelType,
+              specification: item.specification,
+              brandNo: item.brandNum,
+              measuringUnit: item.measuringUnit
+            };
+          }
+        })
+        .concat(this.disabledList);
+      this.form.productInfoList = [];
+
+      console.log('list', list);
+      console.log('this.form.productInfoList', this.form);
+
+      // 取出在弹窗中选中并且不在表格中的数据
+      const result = list.filter(
+        (i) =>
+          this.form.productInfoList.findIndex(
+            (p) => p.productCode === i.productCode
+          ) === -1
+      );
+
+      // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
+      const del = this.form.productInfoList.filter(
+        (i) => list.findIndex((p) => p.productCode === i.productCode) === -1
+      );
+
+      for (let i = this.form.productInfoList.length - 1; i >= 0; i--) {
+        for (let j in del) {
+          console.log(
+            this.form.productInfoList[i].productCode,
+            del[j].productCode
+          );
+          if (this.form.productInfoList[i].productCode === del[j].productCode) {
+            this.form.productInfoList.splice(i, 1);
+            break;
+          }
+        }
+      }
+      // bomVersionList
+      this.form.productInfoList = this.form.productInfoList.concat(result);
+
+      console.log(this.form.productInfoList, '11111111111111');
+
+
+      this.changeLineNumber();
+
+
+
+
       this.$set(this.form, 'categoryId', list[0].id);
       this.$set(this.form, 'productName', list[0].name);
       this.$set(this.form, 'productCode', list[0].code);
@@ -377,7 +636,11 @@ export default {
       this.bomListVersion();
 
     },
-
+    changeLineNumber() {
+      this.form.productInfoList.map((item, index) => {
+        item.lineNumber = 10 * (index + 1);
+      });
+    },
     handleDeleteItem(index) {
       this.form.salesOrders.splice(index, 1);
     },
@@ -398,28 +661,67 @@ export default {
         moCount: '', // 模具数量
         blockCount: 0, // 块数
         noWordCount: '',// 无字数量
-        weight:'',
-        isSlotting:'',//是否开槽
-        slottingType:'',//开槽类型
+        weight: '',
+        isSlotting: '',//是否开槽
+        slottingType: '',//开槽类型
         id: '',
         produceType: 2,
+        status: 2,
         bomCategoryId: '',
         produceRoutingId: '',
+        productInfoList: [],
         requiredFormingNum: ''
       };
     },
+    changeBomId(row, index) {
+
+      bomRoutingList(row.bomCategoryId).then((res) => {
+        let arr = res || [];
+        if (arr.length == 0) {
+          row.produceRoutingId = '';
+        }
+        this.$set(this.form.productInfoList[index], 'routingList', arr);
+
+        this.$forceUpdate()
+      })
+    },
+    changeProductType(row, index) {
+      let param = {
+        bomType: row.productType,
+        categoryId: row.categoryId
+      }
+      bomListByPlan(param).then(res => {
+        let arr = res || [];
+        if (arr.length == 0) {
+          row.bomCategoryId = '';
+        }
+        console.log(arr);
+        this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
+        this.$forceUpdate()
+      })
+
+    },
+
     save() {
+
       this.$refs.form.validate(async (valid) => {
+        console.log(this.$refs.form, 'validvalid', valid);
         if (!valid) {
           return false;
         }
+       
 
         if (!this.form.id) {
+          this.form.productInfoList.map((item, index) => {
+            item.bomCategoryName = item.bomVersionList[0].name;
+            item.bomCategoryVersions = item.bomVersionList[0].versions;
+            item.produceRoutingName = item.routingList[0].name;
+          });
           this.form.timeDimensionPlanType = this.type;
           await this.getPlanCode();
           this.loading = true;
 
-          saveSaleToPlan(this.form)
+          temporaryPlanSave(this.form)
             .then((res) => {
               this.$message.success('新增成功!');
               this.visible = false;
@@ -432,7 +734,7 @@ export default {
             });
         } else {
           this.loading = true;
-          temporarilyUpdate(this.form)
+          temporaryPlanSave(this.form)
             .then((res) => {
               this.$message.success('修改成功!');
               this.visible = false;
@@ -531,7 +833,7 @@ export default {
 
           let numNew =
             (Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
-            row.blockCount).toFixed(5);
+              row.blockCount).toFixed(5);
 
 
           this.$set(this.form, 'requiredFormingNum', numNew);
@@ -598,7 +900,7 @@ export default {
           let a =
             ((Number(this.form.blockCount) * modelLong * modeWide * modeHight) / 1000000).toFixed(5);
 
-            
+
           this.$set(this.form, 'requiredFormingNum', a);
 
         }
@@ -623,21 +925,21 @@ export default {
       }
     },
 
-    changeBomId() {
-      this.routingList = [];
-      this.form.produceRoutingId = '';
-      this.form.produceRoutingName = '';
-      this.form.produceVersionName = '';
+    // changeBomId() {
+    //   this.routingList = [];
+    //   this.form.produceRoutingId = '';
+    //   this.form.produceRoutingName = '';
+    //   this.form.produceVersionName = '';
 
-      this.bomVersionList.forEach((f) => {
-        if (f.id == this.form.bomCategoryId) {
-          this.$set(this.form, 'bomCategoryName', f.name);
-          this.$set(this.form, 'bomCategoryVersions', f.versions);
-        }
-      });
+    //   this.bomVersionList.forEach((f) => {
+    //     if (f.id == this.form.bomCategoryId) {
+    //       this.$set(this.form, 'bomCategoryName', f.name);
+    //       this.$set(this.form, 'bomCategoryVersions', f.versions);
+    //     }
+    //   });
 
-      this.getPlanRouting();
-    },
+    //   this.getPlanRouting();
+    // },
 
     changeRoute() {
       console.log(this.routingList, this.form.produceRoutingId);
@@ -654,6 +956,8 @@ export default {
     cancel() {
       console.log('取消');
       this.visible = false;
+
+      this.initForm();
       this.$emit('close');
     }
   }
@@ -664,4 +968,15 @@ export default {
 .el-form-item {
   margin-bottom: 14px !important;
 }
+
+.add-product {
+  width: 100%;
+  display: flex;
+  align-items: center;
+  justify-content: flex-end;
+  font-size: 30px;
+  color: #1890ff;
+  margin: 10px 0;
+  cursor: pointer;
+}
 </style>

+ 1 - 0
src/views/saleOrder/components/create-order.vue

@@ -120,6 +120,7 @@
           </el-form-item>
         </el-col>
       </el-row>
+      
       <el-table :data="form.productInfoList" border height="40vh" key="id">
         <el-table-column label="序号" align="center" width="60">
           <template slot-scope="scope">

+ 2 - 0
src/views/saleOrder/components/plan-submit.vue

@@ -120,6 +120,7 @@
       cancel() {
         this.visible = false;
       },
+
       async getPlanCode() {
         this.loading = true;
         try {
@@ -128,6 +129,7 @@
         } catch (err) {}
         this.loading = false;
       },
+
       submit(type) {
         this.$emit('publish', type);
         this.visible = false;

+ 1 - 1
src/views/workOrder/index.vue

@@ -26,7 +26,7 @@
         :columns="newColumns"
         :datasource="datasource"
         cache-key="workOrderTable"
-        row-key="code"
+        row-key="id"
         @sort-change="onSortChange"
         autoAmendPage
         :parse-data="parseData"