فهرست منبع

Merge branch 'master' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-qms into dengfei

695593266@qq.com 1 سال پیش
والد
کامیت
6f2763f9b7

+ 63 - 1
src/api/aps/index.js

@@ -8,6 +8,9 @@ export async function routeList(params) {
     return res.data.data;
   }
 }
+
+
+
 // 工序
 export async function getProduceTaskList(params) {
   const res = await request.post('/main/producerouting/taskinstance/page',params);
@@ -59,4 +62,63 @@ export async function warehousing (data) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}
+
+// 工厂列表
+export async function getFactoryList(params) {
+  const res = await request.get(`/main/factoryarea/getFactoryList`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// aps生产计划获取产品的多个bom版本
+export async function bomListByPlan(params) {
+  const res = await request.get(`/main/bomCategory/bomListByPlan`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 根据bom 获取工艺路线
+
+export async function bomRoutingList(id) {
+  const res = await request.get(`/main/bomCategory/bomRoutingList/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  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 getCode (code) {
+  const res = await request.get(`/main/codemanage/getCode/` + code, {});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 查询工厂列表-分页
+export async function getFactoryarea(params) {
+  const res = await request.get(`/main/factoryarea/page`, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+

+ 194 - 0
src/components/selectionDialog/processRoute.vue

@@ -0,0 +1,194 @@
+<template>
+  <ele-modal
+    title="选择工艺路线"
+    custom-class="ele-dialog-form long-dialog-form"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    top="5vh"
+    :close-on-press-escape="false"
+    append-to-body
+    width="70%"
+    :maxable="true"
+  >
+    <el-card shadow="never">
+      <route-search @search="reload"></route-search>
+
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        row-key="id"
+        height="calc(100vh - 460px)"
+        class="dict-table"
+        @cell-click="cellClick"
+      >
+        <template v-slot:action="{ row }">
+          <el-radio class="radio" v-model="radio" :label="row.id"
+            ><i></i
+          ></el-radio>
+        </template>
+      </ele-pro-table>
+    </el-card>
+    <div slot="footer">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+  import { routeList } from '@/api/aps';
+  import { reviewStatus } from '@/enum/dict';
+  import routeSearch from './routeSearch.vue'
+  export default {
+    components: {
+        routeSearch
+    },
+    props: {},
+    data() {
+      return {
+        visible: false,
+        columns: [
+          {
+            action: 'action',
+            slot: 'action',
+            align: 'center',
+            label: '选择'
+          },
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'code',
+            label: '工艺路线编码',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110,
+            slot: 'code'
+          },
+          {
+            prop: 'name',
+            label: '工艺路线名称',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+
+          {
+            prop: 'version',
+            label: '工艺路线版本',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'status',
+            label: '状态',
+            align: 'center',
+            slot: 'status',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            // filters: [
+            //   { text: '草稿', value: -1 },
+            //   { text: '失效', value: 0 },
+            //   { text: '生效', value: 1 }
+            // ],
+            filterMultiple: false,
+            columnKey: 'status',
+            formatter:(row)=>{
+              if(row.status == -1){
+                return '草稿'
+              }else if(row.status == 0){
+                return '失效'
+              }else{
+                return '生效'
+              }
+            }
+          },
+          {
+            prop: 'approvalStatus',
+            label: '审核状态',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 100,
+            formatter: (_row, _column, cellValue) => {
+              return reviewStatus[_row.approvalStatus];
+            }
+          },
+          {
+            prop: 'factoriesName',
+            label: '所属工厂',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            align: 'center',
+            prop: 'createTime',
+            label: '创建时间',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+        ],
+
+        radio: null
+      };
+    },
+
+    watch: {},
+    methods: {
+      open(item) {
+        if (item) {
+          this.radio = item.id;
+        }
+        this.visible = true;
+      },
+
+      /* 表格数据源 */
+      datasource({ page, limit, where, order }) {
+        return routeList({
+          pageNum: page,
+          size: limit,
+          ...where
+        });
+      },
+
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where });
+      },
+
+      handleNodeClick(data, node) {
+        this.curNodeData = data;
+        this.reload({ categoryId: data.id });
+      },
+
+      // 单击获取id
+      cellClick(row) {
+        this.current = row;
+        this.radio = row.id;
+      },
+      handleClose() {
+        this.visible = false;
+        this.current = null;
+        this.radio = '';
+      },
+
+      selected() {
+        if (!this.current) {
+          return this.$message.warning('请选择工艺路线');
+        }
+        this.$emit('changeParent', this.current);
+        this.handleClose();
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped></style>

+ 80 - 0
src/components/selectionDialog/routeSearch.vue

@@ -0,0 +1,80 @@
+<!-- 搜索表单 -->
+<template>
+  <seekPage :seekList="seekList" :formLength="3" @search="search"></seekPage>
+</template>
+<script>
+  import { getFactoryarea } from '@/api/aps';
+  export default {
+    data() {
+      return {
+        statusList: [
+          { label: '草稿', value: -1 },
+          { label: '失效', value: 0 },
+          { label: '生效', value: 1 }
+        ],
+        options_factory: []
+      };
+    },
+    mounted() {
+      this.getFactoryarea();
+    },
+    computed: {
+      // 表格列配置
+      seekList() {
+        return [
+          {
+            label: '工艺路线编码:',
+            value: 'code',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '工艺路线名称:',
+            value: 'name',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '状态:',
+            value: 'status',
+            type: 'select',
+            placeholder: '请选择',
+            planList: this.statusList
+          },
+          {
+            label: '所属工厂:',
+            value: 'factoriesId',
+            type: 'select',
+            placeholder: '请选择',
+            planList: this.options_factory
+          }
+        ];
+      }
+    },
+    methods: {
+      /* 搜索 */
+      search(e) {
+        this.$emit('search', {
+          ...e
+        });
+      },
+      // 获取工厂数据
+      getFactoryarea() {
+        let par = {
+          type: 1,
+          size: 9999
+        };
+        getFactoryarea(par).then((res) => {
+          if (res.list && res.list.length > 0) {
+            this.options_factory = res.list.map((el) => {
+              return {
+                value: el.id,
+                label: el.name
+              };
+            });
+          }
+        });
+      }
+    }
+  };
+</script>

+ 10 - 0
src/enum/dict.js

@@ -31,3 +31,13 @@ export const numberList = [
   'dispose_status',
   'inspection_plan_status'
 ];
+
+//审核状态
+export const reviewStatus = {
+  0: '未提交',
+  1: '审核中',
+  2: '已审核',
+  3: '审核不通过'
+};
+
+

+ 90 - 5
src/views/inspectionPlan/components/new-edit.vue

@@ -173,7 +173,7 @@
             tooltip-effect="dark"
             :max-height="300"
             border
-            row-key="id"
+            row-key="sampleCode"
           >
             <el-table-column
               label="序号"
@@ -1404,11 +1404,95 @@
         return await getCode('sample_code');
       },
 
+      // 创建计量数量为1的样品清单函数,用于计数类型的
+      async createSampleList(list) {
+        if (this.baseForm.qualityMode != null) {
+          const ProductSampleList = [];
+          console.log(list, 'list');
+          for (const oldItem of list) {
+            const count = oldItem.measureQuantity;
+            const newMeasureQuantity = oldItem.measureQuantity / count;
+            const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
+
+            console.log(typeof oldItem.qualitySampleTemplateList, 'ssssss');
+
+            // 遍历新数组设置 qualityResults 默认值
+            this.schemeList.forEach((item) => {
+              if (typeof item === 'object' && item !== null) {
+                item.qualityResults = 1; // 设置默认值
+              }
+              delete item.id;
+            });
+
+            console.log(oldItem, 'oldItem');
+            console.log(count, newMeasureQuantity, newWeight);
+            delete oldItem.id;
+
+            if (
+              oldItem.qualitySampleTemplateList == undefined ||
+              oldItem.qualitySampleTemplateList == null ||
+              oldItem.qualitySampleTemplateList.length == 0
+            ) {
+              oldItem.qualitySampleTemplateList = JSON.parse(
+                JSON.stringify(this.schemeList)
+              );
+              for (let i = 0; i < count; i++) {
+                ProductSampleList.push({
+                  ...oldItem,
+                  measureQuantity: newMeasureQuantity,
+                  weight: newWeight,
+                  sampleCode: await this.getSampleCode(),
+                  qualitySampleTemplateList: JSON.parse(
+                    JSON.stringify(this.schemeList)
+                  )
+                });
+              }
+              console.log(ProductSampleList, 'ProductSampleList');
+              this.sampleList = ProductSampleList;
+              const pNum = ProductSampleList.reduce((sum, item) => {
+                return sum + Number(item.weight || 0);
+              }, 0);
+              this.baseForm.totalWeight = parseFloat(pNum.toFixed(2));
+            } else {
+              for (let i = 0; i < count; i++) {
+                ProductSampleList.push({
+                  ...oldItem,
+                  measureQuantity: newMeasureQuantity,
+                  weight: newWeight,
+                  sampleCode: await this.getSampleCode(),
+                  qualitySampleTemplateList: JSON.parse(
+                    JSON.stringify(oldItem.qualitySampleTemplateList)
+                  )
+                });
+              }
+              console.log(ProductSampleList, 'ProductSampleList');
+              this.sampleList = ProductSampleList;
+              const pNum = ProductSampleList.reduce((sum, item) => {
+                return sum + Number(item.weight || 0);
+              }, 0);
+              this.baseForm.totalWeight = parseFloat(pNum.toFixed(2));
+            }
+          }
+        }
+      },
+
       //更新样品清单数据
       async updatePackingList(list) {
-        for (let i = 0; i < list.length; i++) {
-          list[i].sampleCode = await this.getSampleCode();
+        // 计量类型1是数量,2是重量
+        if (this.baseForm.inspectionStandards == 1) {
+          this.createSampleList(list);
         }
+
+        if (this.baseForm.inspectionStandards == 2) {
+          for (let i = 0; i < list.length; i++) {
+            list[i].sampleCode = await this.getSampleCode();
+          }
+          // this.updatePackingList(list, this.form.total);
+          // this.handleWeightFullSample(this.form.total);
+        }
+
+        console.log(this.baseForm.inspectionStandards);
+
         this.sampleList = list;
         this.baseForm.sampleNumber = list.length;
         this.samplePagination.currentPage = 1;
@@ -2062,7 +2146,8 @@
           if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
             this.baseForm.isUnpack = this.isCheck ? 1 : 2;
           }
-          this.baseForm.conditionType = this.conditionType;
+          this.baseForm.conditionType =
+            this.conditionType ?? this.kkconditionType;
           // isSampleList: true,
           // isPackingList: true,
 
@@ -2300,7 +2385,7 @@
           // }
           return;
         }
-
+        // 全检
         if (this.baseForm.qualityMode == 1) {
           // console.log('+++++++++1');
           // this.handleSampleList();

+ 32 - 22
src/views/inspectionTemplate/index.vue

@@ -2,8 +2,8 @@
   <div class="ele-body">
     <el-card shadow="never">
       <seek-page
+        v-if="renderFlag"
         :seekList="seekList"
-        v-if="typeList.length"
         @search="search"
         ref="search"
       ></seek-page>
@@ -15,7 +15,7 @@
         height="calc(100vh - 400px)"
         tool-class="ele-toolbar-form"
         cache-key="inspectionClassify"
-        row-key="qualityLevelId"
+        row-key="id"
         @selection-change="selectionChangeHandle"
       >
         <template v-slot:toolbar>
@@ -118,11 +118,10 @@
       AddOrUpdate
       // search
     },
-    computed: {
-      seekList() {
-        console.log(this.typeList);
-        
-        return [
+    computed: {},
+    data() {
+      return {
+        seekList: [
           {
             label: '名称:',
             value: 'qualitySchemeTemplateName',
@@ -140,7 +139,7 @@
             value: 'type',
             type: 'select',
             placeholder: '',
-            planList: this.typeList
+            planList: []
           },
           {
             label: '状态:',
@@ -152,11 +151,7 @@
             ],
             placeholder: ''
           }
-        ];
-      }
-    },
-    data() {
-      return {
+        ],
         dataForm: {
           key: ''
         },
@@ -224,18 +219,33 @@
             fixed: 'right'
           }
         ],
-        typeList: []
+        typeList: [],
+        renderFlag: false
       };
     },
-    created() {
-      this.requestDict('质检类型').then((res) => {
-        this.typeList = res.map((item) => {
-          return {
-            value: item.dictCode,
-            label: item.dictValue
-          };
-        });
+    async created() {
+      const res = await this.requestDict('质检类型');
+    
+      this.typeList = res.map((item) => {
+        let values = Object.keys(item);
+        return {
+          value: Number(values[0]),
+          label: item[values[0]]
+        };
+      });
+
+      const index = this.seekList.findIndex((item) => item.value === 'type');
+
+      this.$set(this.seekList, index, {
+        label: '类型:',
+        value: 'type',
+        type: 'select',
+        placeholder: '',
+        planList: this.typeList
       });
+      this.renderFlag = true;
+
+   
     },
     methods: {
       // 获取数据列表

+ 5 - 5
src/views/inspectionWork/components/baseInfo.vue

@@ -214,10 +214,10 @@
               style="width: 100%"
               v-model="form.qualityMode"
               placeholder="请选择"
-              :disabled="
-                parseInt(qualityType1) == 1 || parseInt(qualityType1) == 3
-              "
             >
+            <!-- :disabled="
+                parseInt(qualityType1) == 1 || parseInt(qualityType1) == 3
+              " -->
               <el-option
                 v-for="item in qualityModeList"
                 :label="item.label"
@@ -587,8 +587,8 @@
       // 人员选择
       changeExecutor(val) {
         if (val) {
-          this.form.executeId = val;
-          this.form.executeName = this.executorList.filter(
+          this.form.qualityId = val;
+          this.form.qualityName = this.executorList.filter(
             (item) => item.id === val
           )[0].name;
         }

+ 43 - 19
src/views/inspectionWork/components/newQualityContentTabs.vue

@@ -465,6 +465,12 @@
           // console.log(newVal, 'schemeList');
         },
         deep: true
+      },
+      activeName: {
+        handler(newVal) {
+          this.activeNameKK=newVal
+          // console.log(newVal);
+        }
       }
     },
     props: {
@@ -715,6 +721,8 @@
       },
       // 分页后的样品列表
       paginatedSampleList() {
+        console.log(this.sampleList);
+
         const { currentPage, pageSize } = this.samplePagination;
         const start = (currentPage - 1) * pageSize;
         const end = start + pageSize;
@@ -964,35 +972,51 @@
         this.$refs.inspectionTemplateRef.open(2);
       },
       async inspectionTemplateSuccess(select) {
+        console.log(select);
+
         let data = await getQualityTemplateByIds({
           templateIds: select.map((item) => item.id)
         });
-        // planTemplateList
-        console.log(data);
+
+        // 这里是选择方案后,数据新加,要改为覆盖
+        // this.templateList.push(...data);
+        // const strings = this.templateList.map((item) => JSON.stringify(item));
+        // const removeDupList = [...new Set(strings)];
+        // const result = removeDupList.map((item) => JSON.parse(item));
+
+        this.templateList = [];
         this.templateList.push(...data);
-        const strings = this.templateList.map((item) => JSON.stringify(item));
-        const removeDupList = [...new Set(strings)];
-        const result = removeDupList.map((item) => JSON.parse(item));
-        this.templateList = result.map(item=>{
-          item['qualityResults']=1
-          return item
+        this.templateList.forEach((item) => {
+          item['qualityResults'] = 1;
+        });
+
+        // this.templateList = result.map((item) => {
+        //   item['qualityResults'] = 1;
+        //   return item;
+        // });
+
+        this.sampleList.forEach((item, index) => {
+          this.$set(
+            this.sampleList[index],
+            'qualitySampleTemplateList',
+            this.templateList
+          );
         });
-        // console.log(this.templateList);
-        this.sampleList.forEach((item,index)=>{
-          this.$set(this.sampleList[index],'qualitySampleTemplateList',this.templateList)
-        })
         this.schemePagination.total = this.templateList.length;
       },
       handDel(index) {
         console.log(index);
         this.templateList.splice(index, 1);
-        this.sampleList.forEach((item,index)=>{
-          this.$set(this.sampleList[index],'qualitySampleTemplateList',this.templateList.map(item=>{
-            item['qualityResults']=1
-          return item
-          }))
-
-        })
+        this.sampleList.forEach((item, index) => {
+          this.$set(
+            this.sampleList[index],
+            'qualitySampleTemplateList',
+            this.templateList.map((item) => {
+              item['qualityResults'] = 1;
+              return item;
+            })
+          );
+        });
       }
     }
   };

+ 14 - 12
src/views/inspectionWork/components/sampleListDialog.vue

@@ -190,18 +190,18 @@
             label: '质检结果',
             prop: 'qualityResults',
             align: 'center',
-            slot: 'qualityResults'
-            // formatter: (row, column) => {
-            //   if (row.qualityResults) {
-            //     return row.qualityResults == 1
-            //       ? '合格'
-            //       : row.qualityResults == 2
-            //       ? '不合格'
-            //       : row.qualityResults == 3
-            //       ? '让步接收'
-            //       : '';
-            //   }
-            // }
+            slot: 'qualityResults',
+            formatter: (row, column) => {
+              if (row.qualityResults) {
+                return row.qualityResults == 1
+                  ? '合格'
+                  : row.qualityResults == 2
+                  ? '不合格'
+                  : row.qualityResults == 3
+                  ? '让步接收'
+                  : '';
+              }
+            }
           }
           // { label: '货区', prop: 'areaName', align: 'center', },
           // { label: '货架', prop: 'goodsShelfName', align: 'center', },
@@ -243,6 +243,8 @@
           }
         }
         this.tableData = list;
+        console.log( this.tableData);
+        
         this.visible = true;
       },
       qualityResultsListChange() {

+ 1 - 0
src/views/inspectionWork/components/toolList.vue

@@ -159,6 +159,7 @@ export default {
                 // },
             ],
             data: [],
+            type:''
         }
     },
     methods: {

+ 144 - 16
src/views/inspectionWork/edit.vue

@@ -192,27 +192,18 @@
     methods: {
       //切换检验方式
       changeModel(val, flag) {
+        console.log('切换检验方式');
+
         this.$refs.tabsRef.tableSelClear();
         this.sampleList = [];
         this.$refs.tabsRef.tabsChange('1');
         this.$refs.tabsRef.tabsConditionType(null);
-
         this.form.qualityMode = val;
         //检验方式 全检
         if (this.form.qualityMode == 1) {
           this.activeName = '2';
           this.form.sampleNumber = '';
-          const sData = this.$refs.tabsRef.$refs.sourceTable.getData();
-          if (sData.length == 0) {
-            for (let i = 0; i < sData.length; i++) {
-              this.$set(sData[i], 'qualityStatus', 2);
-            }
-          }
-          console.log(
-            this.$refs.tabsRef.$refs.sourceTable.getData(),
-            'packingList'
-          );
-          this.getProSamList(sData);
+          this.changeGetSampleList(this.inventoryList);
         } else {
           this.activeName = '1';
           if (!flag) {
@@ -297,6 +288,133 @@
           this.sampleList = this.addStatus;
         }
       },
+      // 创建计量数量为1的样品清单函数,用于计数类型的
+      async createSampleList(list) {
+        if (this.form.qualityMode != null) {
+          console.log('sssssjijdiajdia');
+
+          this.$message('正在生成样品清单');
+          const ProductSampleList = [];
+          console.log(list, 'list');
+          for (const oldItem of list) {
+            const count = oldItem.measureQuantity;
+            const newMeasureQuantity = oldItem.measureQuantity / count;
+            const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
+
+            console.log(typeof oldItem.qualitySampleTemplateList, 'ssssss');
+
+            // 遍历新数组设置 qualityResults 默认值
+            this.schemeList.forEach((item) => {
+              if (typeof item === 'object' && item !== null) {
+                item.qualityResults = 1; // 设置默认值
+              }
+              delete item.id;
+            });
+
+            console.log(oldItem, 'oldItem');
+            console.log(count, newMeasureQuantity, newWeight);
+            delete oldItem.id;
+
+            if (
+              oldItem.qualitySampleTemplateList == undefined ||
+              oldItem.qualitySampleTemplateList == null ||
+              oldItem.qualitySampleTemplateList.length == 0
+            ) {
+              oldItem.qualitySampleTemplateList = JSON.parse(
+                JSON.stringify(this.schemeList)
+              );
+              for (let i = 0; i < count; i++) {
+                ProductSampleList.push({
+                  ...oldItem,
+                  measureQuantity: newMeasureQuantity,
+                  weight: newWeight,
+                  sampleCode: await this.getSampleCode(),
+                  qualitySampleTemplateList: JSON.parse(
+                    JSON.stringify(this.schemeList)
+                  )
+                });
+              }
+              console.log(ProductSampleList, 'ProductSampleList');
+              this.sampleList = ProductSampleList;
+              const pNum = ProductSampleList.reduce((sum, item) => {
+                return sum + Number(item.weight || 0);
+              }, 0);
+              this.form.totalWeight = parseFloat(pNum.toFixed(2));
+            } else {
+              for (let i = 0; i < count; i++) {
+                ProductSampleList.push({
+                  ...oldItem,
+                  measureQuantity: newMeasureQuantity,
+                  weight: newWeight,
+                  sampleCode: await this.getSampleCode(),
+                  qualitySampleTemplateList: JSON.parse(
+                    JSON.stringify(oldItem.qualitySampleTemplateList)
+                  )
+                });
+              }
+              console.log(ProductSampleList, 'ProductSampleList');
+              this.sampleList = ProductSampleList;
+              const pNum = ProductSampleList.reduce((sum, item) => {
+                return sum + Number(item.weight || 0);
+              }, 0);
+              this.form.totalWeight = parseFloat(pNum.toFixed(2));
+            }
+          }
+        }
+      },
+      // 全检计量计重的样品清单函数
+      async updatePackingList(list, sampleCount) {
+        // for (let i = 0; i < list.length; i++) {
+        //   list[i].sampleCode = await this.getSampleCode();
+        // }
+
+        const dataList = [];
+        let currentNum = sampleCount - list.length;
+        let currentNum1 = sampleCount;
+        // console.log(this.selectedList);
+
+        for (const item of list) {
+          const qualitySampleTemplateList = item.qualitySampleTemplateList
+            ?.length
+            ? JSON.parse(JSON.stringify(item.qualitySampleTemplateList))
+            : JSON.parse(
+                JSON.stringify(
+                  this.schemeList.map((item) => {
+                    item['qualityResults'] = 1;
+                    return item;
+                  })
+                )
+              );
+
+          if (sampleCount >= list.length) {
+            dataList.push({
+              ...item,
+              measureQuantity: item.measureQuantity, //作为计量数量
+              sampleCode: await this.getSampleCode(),
+              qualitySampleTemplateList
+            });
+          }
+        }
+
+        this.sampleList = dataList;
+        this.sampleNumber = this.sampleList.length;
+      },
+      // 切换检验方式为全检后生成样品
+      changeGetSampleList(list) {
+        this.$message('正在生成样品清单');
+        console.log(list);
+        console.log(this.form.total);
+
+        // 计量类型1是数量,2是重量
+        if (this.form.inspectionStandards == 1) {
+          this.createSampleList(list);
+        }
+        if (this.form.inspectionStandards == 2) {
+          this.updatePackingList(list, this.form.total);
+          // this.handleWeightFullSample(this.form.total);
+        }
+      },
+
       //输入取样数量
       changeNumber(val) {
         if (this.form.qualityMode !== 2) {
@@ -466,8 +584,11 @@
         });
 
         // await this.queryQualityInventory()
+        // 质检方案
         await this.queryQualityTempleContent();
+        // 样品清单
         await this.queryQualitySamplContent();
+        // 来源清单
         await this.getQueryQualityInventory();
       },
       // getNewData(val) {
@@ -611,7 +732,7 @@
             console.log(222222222222222222);
             await this.handleWeightFullSample(sampleCount);
           }
-        this.activeName = '2';
+          this.activeName = '2';
 
           this.$refs.tabsRef.tabsChange('2');
         } catch (error) {
@@ -743,9 +864,9 @@
         });
         let addStatus = res.list.map((item) => {
           item.isValid = true;
-          item.disposeTime = item.disposeTime
-            ? item.disposeTime.split(' ')[0]
-            : null;
+          // item.disposeTime = item.disposeTime
+          //   ? item.disposeTime.split(' ')[0]
+          //   : null;
           item.sampleDate = item.sampleDate
             ? item.sampleDate.split(' ')[0]
             : null;
@@ -793,6 +914,8 @@
 
           delete this.form['qualityTimeEnd'];
 
+          console.log(this.sampleList);
+
           let params = {
             ...this.form,
             sampleList: this.sampleList,
@@ -802,6 +925,7 @@
             qualityInventoryList: this.inventoryList
           };
           console.log(params, 'params ----');
+
           URL(params)
             .then((msg) => {
               this.loading = false;
@@ -1293,9 +1417,13 @@
       },
 
       async handleWeightFullSample(sampleCount) {
+        console.log(sampleCount);
+
         const dataList = [];
         let currentNum = sampleCount - this.selectedList.length;
         let currentNum1 = sampleCount;
+        console.log(this.selectedList);
+
         for (const item of this.selectedList) {
           const qualitySampleTemplateList = item.qualitySampleTemplateList
             ?.length

+ 4 - 2
src/views/inspectionWork/index.vue

@@ -423,7 +423,9 @@
         return getList({
           ...where,
           pageNum: page,
-          size: limit
+          size: limit,
+          // status: 0,
+          // qualityMode:'02'
         });
       },
       search(where) {
@@ -449,7 +451,7 @@
                 const id = type !== 'add' ? row.id : '';
                 const qualityType = type !== 'add' ? row.qualityType : null;
                 const qualityTimeStart = row.qualityTimeStart || '';
-
+                // qualityType是质检类型 来料,生产
                 this.$router.push({
                   path: '/inspectionWork/edit',
                   query: {

+ 3 - 1
src/views/sample/samplemanagement/index.vue

@@ -48,6 +48,7 @@
             :underline="false"
             icon="el-icon-edit"
             @click="openEdit('edit', row)"
+            v-if="row.status !== 2"
           >
             修改
           </el-link>
@@ -63,6 +64,7 @@
             class="ele-action"
             title="确定要删除吗?"
             @confirm="remove(row)"
+            v-if="row.status !== 2"
           >
             <template v-slot:reference>
               <el-link type="danger" :underline="false" icon="el-icon-delete">
@@ -183,7 +185,7 @@
             width: 80,
             formatter: (row, column, cellValue) => {
               console.log(this.getDictName('处置状态', cellValue));
-              
+
               return this.getDictName('处置状态', cellValue);
             }
           },

+ 1313 - 0
src/views/unqualifiedProduct/unqualifiedList/components/factoryAdd.vue

@@ -0,0 +1,1313 @@
+<template>
+  <!-- :close-on-click-modal="false" -->
+  <ele-modal
+    width="80vw"
+    :visible.sync="factoryVisable"
+    custom-class="ele-dialog-form"
+    :before-close="cancel"
+    :title="title"
+    :maxable="true"
+  >
+    <div class="form-wrapper">
+      <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="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="planType">
+              <el-select
+                v-model="form.planType"
+                style="width: 100%"
+                @change="changeProduceType"
+                size="mini"
+                disabled
+              >
+                <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="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="计划开始日期:"
+              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="计划结束日期:"
+              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-row>
+
+        <headerTitle title="产品信息"> </headerTitle>
+
+        <el-row :gutter="24">
+          <ele-pro-table
+            ref="tableRef"
+            :columns="columns"
+            row-key="code"
+            :cache-key="`ProductionPlanTable`"
+            :datasource="form.productInfoList"
+            border
+            height="40vh"
+            key="id"
+          >
+            <template v-slot:requiredFormingNum="{ row, $index }">
+              <el-input
+                v-model.number="row.requiredFormingNum"
+                size="small"
+                type="number"
+                style="width: 100%"
+                placeholder="输入要求生产数量"
+                @input="tableHandleKeyUp(row, 'procut')"
+              ></el-input>
+              <!-- placeholder="输入要求生产数量" @input="tableHandleKeyUp(row, 'sum')"></el-input> -->
+            </template>
+
+            <template v-slot:blockCount="{ row, $index }">
+              <el-input
+                v-model.number="row.blockCount"
+                size="small"
+                type="number"
+                style="width: 100%"
+                placeholder="输入数量"
+                @input="inputNumber(row, $index)"
+              ></el-input>
+            </template>
+
+            <template v-slot:productType="{ row, $index }">
+              <el-select
+                v-model="row.productType"
+                @change="changeProductType(row, $index)"
+                :key="$index"
+              >
+                <el-option
+                  v-for="item of producedList"
+                  :key="$index + item.code"
+                  :label="item.name"
+                  :value="item.code"
+                ></el-option>
+              </el-select>
+            </template>
+
+            <template v-slot:bomCategoryId="{ row, $index }">
+              <el-select
+                v-model="row.bomCategoryId"
+                @change="changeBomId(row, $index)"
+              >
+                <el-option
+                  v-for="item of row.bomVersionList"
+                  :key="item.id"
+                  :label="item.name + '(V' + item.versions + '.0)'"
+                  :value="item.id"
+                ></el-option>
+              </el-select>
+            </template>
+
+            <!-- //权重等级 -->
+            <template
+              v-slot:weight="{ row, $index }"
+              v-if="clientEnvironmentId == 4"
+            >
+              <el-select
+                v-model="row.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>
+            </template>
+
+            <!-- 是否开槽 -->
+            <template
+              v-slot:isSlotting="{ row, $index }"
+              v-if="clientEnvironmentId == 4"
+            >
+              <el-select
+                v-model="row.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>
+            </template>
+
+            <!-- 开槽类型 -->
+            <template
+              v-slot:slottingType="{ row, $index }"
+              v-if="clientEnvironmentId == 4"
+            >
+              <DictSelection
+                dictName="开槽类型"
+                v-model="row.slottingType"
+                size="mini"
+              >
+              </DictSelection>
+            </template>
+
+            <!-- 工艺路线 -->
+
+            <template
+              v-slot:produceRoutingId="{ row, $index }"
+              v-if="clientEnvironmentId != 4"
+            >
+              <!-- <el-form-item required> -->
+              <div style="display: flex">
+                <el-select
+                  v-model="row.produceRoutingId"
+                  v-show="isRouteSelect(row)"
+                >
+                  <el-option
+                    v-for="item of row.routingList"
+                    :key="item.id"
+                    :label="item.name"
+                    :value="item.id"
+                  ></el-option>
+                </el-select>
+
+                <div style="display: flex">
+                  <el-input
+                    v-show="!isRouteSelect(row)"
+                    disabled
+                    v-model="row.produceRoutingName"
+                  ></el-input>
+                  <el-button
+                    v-show="isSelectShow"
+                    type="primary"
+                    size="mini"
+                    @click="openDialog($index)"
+                    >选择</el-button
+                  >
+                </div>
+              </div>
+              <!-- </el-form-item> -->
+            </template>
+
+            <template v-slot:produceRoutingId="{ row, $index }" v-else>
+              <el-input
+                v-model="row.produceRoutingName"
+                style="width: 100%"
+                readonly
+              ></el-input>
+            </template>
+
+            <template v-slot:factoriesId="{ row, $index }">
+              <el-select
+                v-model="row.factoriesId"
+                :key="row.factoriesId"
+                @change="(e) => selectFactory(e, row)"
+              >
+                <el-option
+                  v-for="item of factoryList"
+                  :key="item.id"
+                  :label="item.name"
+                  :value="item.id"
+                ></el-option>
+              </el-select>
+            </template>
+
+            <!-- <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> -->
+
+            <!-- 模具数量 -->
+            <template
+              v-slot:moCount="{ row, $index }"
+              v-if="clientEnvironmentId == '4'"
+            >
+              <div>
+                <el-input
+                  style="width: 100%"
+                  size="small"
+                  v-model="row.moCount"
+                  oninput="value=value.replace(/[^0-9.]/g,'')"
+                  @input="tableHandleKeyUp(row, 'moCount')"
+                  placeholder="请输入"
+                >
+                </el-input>
+              </div>
+            </template>
+
+            <!-- 块数 -->
+            <template
+              v-slot:blockCount="{ row, $index }"
+              v-if="clientEnvironmentId == '4'"
+            >
+              <div>
+                <el-input
+                  size="small"
+                  style="width: 100%"
+                  @input="tableHandleKeyUp(row, 'blockCount')"
+                  v-model="row.blockCount"
+                  placeholder="请输入"
+                ></el-input>
+              </div>
+            </template>
+
+            <template v-slot:productWeight="{ row, $index }">
+              <span>{{ row.productWeight ? row.productWeight : '-' }}</span>
+            </template>
+
+            <template v-slot:set="{ row, $index }">
+              <el-button
+                type="text"
+                @click="handleDeleteItem($index)"
+                v-if="!row.id"
+                >删除</el-button
+              >
+            </template>
+            <template v-slot:headerProduceRoutingId="{ column }">
+              <div class="header_required"
+                ><span class="is-required">{{ column.label }}</span></div
+              >
+            </template>
+            <template v-slot:headerProcessingBOM="{ column }">
+              <div :class="isRequired ? 'header_required' : ''"
+                ><span class="is-required">{{ column.label }}</span></div
+              >
+            </template>
+          </ele-pro-table>
+          <!-- <div class="add-product" @click="addEquipment">
+            <i class="el-icon-circle-plus-outline"></i>
+          </div> -->
+        </el-row>
+      </el-form>
+
+      <!-- 选择产品 -->
+      <!-- <EquipmentDialog
+        @choose="confirmChoose"
+        :selectList="[]"
+        ref="equipmentRefs"
+        isMultiple="0"
+      >
+      </EquipmentDialog> -->
+    </div>
+
+    <template v-slot:footer>
+      <el-button @click="cancel">取消</el-button>
+      <el-button type="primary" @click="save" :loading="loading">
+        确定
+      </el-button>
+    </template>
+    <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
+  </ele-modal>
+</template>
+
+<script>
+  // import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
+  // import { getCode } from '@/api/codeManagement';
+  import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
+  // import { parameterGetByCode } from '@/api/mainData/index';
+  import {
+    bomRoutingList,
+    bomListByPlan,
+    // saveSaleToPlan,
+    getFactoryList,
+    // temporarilyUpdate,
+    temporaryPlanSave,
+    getCode
+  } from '@/api/aps';
+
+  export default {
+    watch: {
+      factoryData: {
+        handler(val) {
+          console.log(this.form);
+          this.form.productInfoList = val;
+        },
+        immediate: true
+      }
+    },
+    created() {
+      this.getFactoryList();
+      // this.form.productInfoList=this.
+    },
+    components: {
+      // EquipmentDialog,
+      ProcessRoute
+    },
+    props: {
+      factoryVisable: {
+        type: Boolean,
+        default: false
+      },
+      factoryType: {
+        type: Number,
+        default: 3
+      },
+      factoryData: {
+        type: Array,
+        default: () => []
+      }
+    },
+    computed: {
+      // 是否必填 字段 ( 首先看计划类型 如果是返工返修)
+      // 就不是必填 否则就看配置参数
+
+      // 必填的时候 不显示选择按钮 跟 展示输入框 只能有下拉选择框 ( 选择了加工方式 带出 BOM 版本 带出 工艺路线 工艺路线不能选择)
+      // 不必填的时候 显示 选择按钮跟 展示输入框 并且可以存在选择框 一开始默认展示选择框
+      //   选择按钮选择数据后 隐藏选择框 显示展示框(input) 情况 加工方式 跟 BOM版本
+      //   选择了加工方式 清空 选择框选择的工艺路线
+
+      // 是否必填字段
+      isRequired() {
+        if (this.form.planType == 5) {
+          return false;
+        }
+        return this.processingRequired == 1;
+      },
+      // 工艺路线 输入框展示跟选择框判断
+      isRouteSelect() {
+        return (row) => {
+          if (this.isRequired) {
+            return true;
+          }
+          if (!row.selectionRowShow) {
+            return true;
+          }
+
+          return false;
+        };
+      },
+
+      // 选择按钮的显示
+      isSelectShow() {
+        if (this.form.planType == 5) {
+          return true;
+        }
+        return this.processingRequired == 0;
+      },
+      clientEnvironmentId() {
+        return this.$store.state.user.info.clientEnvironmentId;
+      },
+      columns() {
+        return [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+
+          // {
+          //   slot: 'lineNumber',
+          //   prop: 'lineNumber',
+          //   label: '行号',
+          //   align: 'center',
+          //   minWidth: 140
+          // },
+          {
+            slot: 'productName',
+            prop: 'categoryName',
+            label: '产品名称',
+            align: 'center',
+            minWidth: 140
+          },
+          {
+            slot: 'productCode',
+            prop: 'categoryCode',
+            label: '物料编码',
+            align: 'center',
+            minWidth: 140
+          },
+          {
+            slot: 'brandNo',
+            prop: 'brandNum',
+            label: '牌号',
+            align: 'center',
+            minWidth: 140
+          },
+          {
+            slot: 'model',
+            prop: 'modelType',
+            label: '型号',
+            align: 'center',
+            minWidth: 140
+          },
+          {
+            slot: 'specification',
+            prop: 'specification',
+            label: '规格',
+            align: 'center',
+            minWidth: 140
+          },
+          {
+            slot: 'productUnitWeight',
+            prop: 'productUnitWeight',
+            label: '单重',
+            align: 'center',
+            minWidth: 140
+          },
+          {
+            slot: 'weightUnit',
+            prop: 'weightUnit',
+            label: '重量单位',
+            align: 'center',
+            minWidth: 140
+          },
+
+          {
+            slot: 'requiredFormingNum',
+            prop: 'requiredFormingNum',
+            label: '要求生产数量',
+            align: 'center',
+            minWidth: 140
+          },
+          {
+            slot: 'productType',
+            prop: 'productType',
+            label: '加工方式',
+            headerSlot: 'headerProcessingBOM',
+            align: 'center',
+            minWidth: 180
+          },
+          {
+            slot: 'bomCategoryId',
+            prop: 'bomCategoryId',
+            label: 'BOM版本',
+            headerSlot: 'headerProcessingBOM',
+            align: 'center',
+            minWidth: 180,
+            show: this.clientEnvironmentId !== 4
+          },
+          {
+            slot: 'produceRoutingId',
+            prop: 'produceRoutingId',
+            headerSlot: 'headerProduceRoutingId',
+            label: '工艺路线',
+            align: 'center',
+            minWidth: 240
+          },
+          {
+            slot: 'measuringUnit',
+            prop: 'measuringUnit',
+            label: '计量单位',
+            align: 'center',
+            minWidth: 140
+          },
+          {
+            slot: 'moCount',
+            prop: 'moCount',
+            label: '模数',
+            align: 'center',
+            minWidth: 140,
+            show: this.clientEnvironmentId == 4
+          },
+          {
+            slot: 'blockCount',
+            prop: 'blockCount',
+            label: '块数',
+            align: 'center',
+            minWidth: 140,
+            show: this.clientEnvironmentId == 4
+          },
+          {
+            slot: 'factoriesId',
+            prop: 'factoriesId',
+            label: '所属工厂',
+            align: 'center',
+            minWidth: 140
+          },
+
+          {
+            slot: 'weight',
+            prop: 'weight',
+            label: '权重等级',
+            align: 'center',
+            minWidth: 140,
+            show: this.clientEnvironmentId == 4
+          },
+          {
+            slot: 'isSlotting',
+            prop: 'isSlotting',
+            label: '是否开槽',
+            align: 'center',
+            minWidth: 140,
+            show: this.clientEnvironmentId == 4
+          },
+          {
+            slot: 'slottingType',
+            prop: 'slottingType',
+            label: '开槽类型',
+            align: 'center',
+            minWidth: 140,
+            show: this.clientEnvironmentId == 4
+          },
+
+          {
+            slot: 'productWeight',
+            prop: 'productWeight',
+            label: '订单重量',
+            align: 'center',
+            minWidth: 140
+          },
+          {
+            slot: 'set',
+            prop: 'set',
+            label: '操作',
+            align: 'center',
+            minWidth: 140,
+            fixed: 'right'
+          }
+        ];
+      }
+    },
+    data() {
+      return {
+        // visible: false,
+        title: '',
+        type: 3,
+        weightList: [
+          { code: 1, name: 'A' },
+          { 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,
+          categoryId: '',
+          productName: '',
+          planType: '5',
+          moCount: '', // 模具数量
+          blockCount: 0, // 块数
+          noWordCount: '', // 无字数量
+          weight: '',
+          startTime: '',
+          endTime: '',
+          isSlotting: '', //是否开槽
+          slottingType: '', //开槽类型
+          id: '',
+          produceType: 2,
+          bomCategoryId: '',
+          produceRoutingId: '',
+          requiredFormingNum: '',
+          productInfoList: []
+        },
+        disabledList: [],
+        bomVersionList: [],
+        routingList: [],
+        rules: {
+          productName: [
+            { required: true, message: '请选择名称', trigger: 'change' }
+          ],
+
+          bomCategoryId: [
+            { required: true, message: '请选择BOM版本', trigger: 'blur' }
+          ],
+
+          produceType: [
+            { required: true, message: '请选择工艺路线', trigger: 'blur' }
+          ],
+          produceRoutingId: [
+            { required: true, message: '请选择工艺路线', trigger: 'blur' }
+          ],
+
+          reqMoldTime: [
+            { required: true, message: '请选择要求完成日期', trigger: 'blur' }
+          ],
+
+          requiredFormingNum: [
+            { required: true, message: '请输入生产数量', trigger: 'blur' }
+          ]
+        },
+        producedList: [
+          { code: 2, name: '加工(MBOM)' },
+          { code: 3, name: '装配(ABOM)' }
+        ],
+        selectIndex: 0, // 选择工艺路线的当前数据下标
+        processingRequired: 0 // 加工方式跟BOM 版本是否必填 1:是 0:否
+        // selectionRowShow: false // 工艺路线输入框展示 状态
+      };
+    },
+
+    // computed: {
+    //   clientEnvironmentId() {
+    //     return this.$store.state.user.info.clientEnvironmentId;
+    //   }
+    // },
+    mounted() {
+      // 加工方式跟BOM版本字段是否必填
+      // parameterGetByCode({
+      //   code: 'production_plan_code'
+      // }).then((res) => {
+      //   if (res) {
+      //     this.processingRequired = res.value;
+      //   }
+      // });
+    },
+    methods: {
+      selectFactory(e, row) {
+        let data = this.factoryList.find((item) => item.id === e);
+        this.$set(row, 'factoriesName', data.name);
+      },
+
+      // 打开工艺路线
+      openDialog(index) {
+        this.selectIndex = index;
+        this.$refs.processRouteRef.open();
+      },
+
+      // 选择工艺路线
+      changeParent(item) {
+        let data = this.form.productInfoList[this.selectIndex];
+        this.$set(data, 'bomVersionList', []);
+        this.$set(data, 'bomCategoryId', '');
+        this.$set(data, 'model', '');
+        this.$set(data, 'routingList', []);
+        this.$set(data, 'productType', '');
+        this.$set(data, 'produceRoutingName', item.name);
+        this.$set(data, 'produceRoutingId', item.id);
+        this.$set(data, 'selectionRowShow', true);
+        // this.selectionRowShow = true;
+      },
+      async getFactoryList() {
+        this.factoryList = await getFactoryList();
+      },
+      addEquipment() {
+        this.$refs.equipmentRefs.open();
+      },
+
+      // confirmChoose(list) {
+      //   list.map((el) => (el.selectionRowShow = false));
+      //   if (this.clientEnvironmentId == 4) {
+      //     list.map((v) => {
+      //       if (v.name.includes('板材')) {
+      //         v.produceRoutingId = '1856970794952372226';
+      //         v.produceRoutingName = '板材';
+      //         v.produceVersionName = '板材';
+      //       } else {
+      //         (v.produceRoutingId = '1857313733642596353'),
+      //           (v.produceRoutingName = '砌块'),
+      //           (v.produceVersionName = '砌块');
+      //       }
+      //     });
+      //   }
+
+      //   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,
+      //           produceRoutingId: item.produceRoutingId,
+      //           produceRoutingName: item.produceRoutingName,
+      //           produceVersionName: item.produceVersionName
+      //         };
+      //       }
+      //     })
+      //     .concat(this.disabledList);
+
+      //   this.form.productInfoList = [];
+
+      //   //  取出在弹窗中选中并且不在表格中的数据
+      //   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) {
+      //       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);
+
+      //   this.$refs.tableRef.setData(this.form.productInfoList);
+
+      //   this.changeLineNumber();
+
+      //   //重置
+      //   this.$set(this.form, 'produceType', '');
+      //   this.$set(this.form, 'bomCategoryId', '');
+      //   this.$set(this.form, 'produceRoutingId', '');
+
+      //   this.bomListVersion();
+      // },
+
+      // changeLineNumber() {
+      //   this.form.productInfoList.map((item, index) => {
+      //     item.lineNumber = 10 * (index + 1);
+      //   });
+      // },
+      // handleDeleteItem(index) {
+      //   this.$confirm('确定删除当前数据?', '提示')
+      //     .then(() => {
+      //       const newArray = this.form.productInfoList.filter(
+      //         (item, i) => i !== index
+      //       );
+      //       this.form.productInfoList = newArray;
+      //       this.$refs.tableRef.setData(newArray);
+      //     })
+      //     .catch(() => {});
+      // },
+
+      async getPlanCode() {
+        this.loading = true;
+        try {
+          const code = await getCode('product_code');
+          this.$set(this.form, 'code', code);
+        } catch (err) {}
+      },
+
+      initForm() {
+        this.form = {
+          timeDimensionPlanType: 3,
+          categoryId: '',
+          productName: '',
+          planType: '5',
+          moCount: '', // 模具数量
+          blockCount: 0, // 块数
+          noWordCount: '', // 无字数量
+          weight: '',
+          isSlotting: '', //是否开槽
+          slottingType: '', //开槽类型
+          id: '',
+          produceType: 2,
+          status: 2,
+          bomCategoryId: '',
+          produceRoutingId: '',
+          productInfoList: [],
+          requiredFormingNum: ''
+        };
+        // console.log(this.$refs);
+        // this.$refs.tableRef.setData([]);
+      },
+      changeBomIdFn(bomCategoryId) {
+        return new Promise((resolve, reject) => {
+          bomRoutingList(bomCategoryId).then((res) => {
+            let arr = res || [];
+            if (arr.length == 0) {
+              row.produceRoutingId = '';
+            }
+            resolve(arr);
+          });
+        });
+      },
+
+      // 选择BOM
+      changeBomId(row, index) {
+        // row.routingList = []
+        bomRoutingList(row.bomCategoryId).then((res) => {
+          let arr = res || [];
+          if (arr.length > 0) {
+            this.$nextTick(() => {
+              row.produceRoutingName = arr[0].name;
+              row.produceVersionName = arr[0].version;
+              row.routingList = arr;
+              this.$set(
+                this.form.productInfoList[index],
+                'produceRoutingId',
+                arr[0].id
+              );
+              // this.selectionRowShow = false;
+              row.selectionRowShow = false;
+              this.$set(this.form.productInfoList[index], 'routingList', arr);
+            });
+          }
+          this.$forceUpdate();
+        });
+      },
+
+      // 清空BOM 跟工艺路线
+      wipeData(index) {
+        let row = this.form.productInfoList[index];
+        row.bomCategoryId = '';
+        row.routingList = [];
+        row.bomVersionList = [];
+        row.produceRoutingId = '';
+        row.produceRoutingName = '';
+        row.produceVersionName = '';
+        row.selectionRowShow = false;
+        // this.selectionRowShow = false;
+      },
+
+      // 选择加工方式
+      changeProductType(row, index) {
+        let param = {
+          bomType: row.productType,
+          categoryId: row.categoryId
+        };
+
+        this.wipeData(index);
+        // row.bomCategoryId = '';
+        // this.form.productInfoList[index].bomVersionList = [];
+        bomListByPlan(param).then((res) => {
+          let arr = res || [];
+          this.$nextTick(() => {
+            if (arr.length) {
+              row.bomVersionList = arr;
+              this.form.productInfoList[index].bomVersionList = arr;
+              row.bomCategoryId = arr[0].id;
+              this.changeBomId(row, index);
+              let arrAll = JSON.parse(JSON.stringify(this.form));
+              this.$set(this, 'form', arrAll);
+            }
+          });
+
+          // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
+        });
+      },
+
+      // 参数校验
+      parameterVerification() {
+        let flag = true;
+        this.form.productInfoList.forEach((v) => {
+          if (this.isRequired) {
+            if (!v.productType) {
+              flag = false;
+              this.$message.warning('请选择加工方式');
+              return;
+            }
+
+            if (!v.bomCategoryId) {
+              flag = false;
+              this.$message.warning('请选择BOM版本');
+              return;
+            }
+          }
+
+          if (!v.produceRoutingId) {
+            flag = false;
+            this.$message.warning('请选择工艺路线');
+            return;
+          }
+        });
+        return flag;
+      },
+      save() {
+        this.$refs.form.validate(async (valid) => {
+          if (!valid) {
+            return false;
+          }
+
+          let flag = this.parameterVerification();
+          // 必填参数校验
+          if (!flag) return;
+          if (!this.form.id) {
+            if (this.form.productInfoList.length) {
+              this.form.productInfoList.map((item, index) => {
+                delete item.selectionRowShow;
+                if (item.bomVersionList && item.bomVersionList.length) {
+                  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;
+
+            // console.log(this.form,'this.form 1+1 ')
+            // return
+            temporaryPlanSave(this.form)
+              .then((res) => {
+                this.$message.success('新增成功!');
+                // this.visible = false;
+                this.cancel();
+              })
+              .finally(() => {
+                this.loading = false;
+              });
+          } else {
+            this.loading = true;
+            temporaryPlanSave(this.form)
+              .then((res) => {
+                this.$message.success('修改成功!');
+                // this.visible = false;
+                this.initForm();
+                this.$emit('close', true);
+              })
+              .finally(() => {
+                this.loading = false;
+              });
+          }
+        });
+      },
+      bomListVersionFn(produceType, categoryId) {
+        return new Promise((resolve, reject) => {
+          let param = {
+            bomType: produceType,
+            categoryId: categoryId
+          };
+          bomListByPlan(param).then((res) => {
+            this.bomVersionList = res || [];
+            resolve(res || []);
+          });
+        });
+      },
+
+      bomListVersion() {
+        let param = {
+          bomType: this.form.produceType,
+          categoryId: this.form.categoryId
+        };
+        bomListByPlan(param).then((res) => {
+          this.$nextTick(() => {
+            this.bomVersionList = res || [];
+          });
+        });
+      },
+
+      // 工艺路线
+
+      getPlanRouting() {
+        bomRoutingList(this.form.bomCategoryId).then((res) => {
+          this.routingList = res || [];
+        });
+      },
+
+      // 宝悦 工艺路线
+      getPlanRoutingNew() {
+        // bomRoutingList(this.form.bomCategoryId).then((res) => {
+        //   this.routingList = res || []
+        // })
+      },
+
+      tableHandleKeyUp(row, name) {
+        // return
+        // , index, e, name
+        if (name == 'procut') {
+          row.return;
+        }
+        if (row.specification && this.clientEnvironmentId == 4) {
+          let modelArr = row.specification.split('*');
+          let modelLong = modelArr[0]; // model规格长度
+          let modeWide = modelArr[1]; // model规格宽度
+          let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
+          modeHight = Number(modeHight);
+          if (name === 'moCount') {
+            // 模数
+
+            this.$set(row, 'moCount', row.moCount);
+            // 计算块数的公式:
+            // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
+            // 每一模的块数*模数moCount = 总块数
+            if (row.productName.includes('板材')) {
+              // 块数
+              let blockCount =
+                Math.floor(600 / modelLong) *
+                Math.floor(120 / modeHight) *
+                Math.floor(60 / modeWide) *
+                row.moCount;
+
+              row['blockCount'] = blockCount;
+              // this.$set(row, 'blockCount', blockCount);
+            } else if (row.productName.includes('砌块')) {
+              let modelLongFixed = (600 / modelLong).toFixed(2);
+              modelLongFixed = modelLongFixed.substring(
+                0,
+                modelLongFixed.length - 1
+              );
+              let modeWideFixed = (120 / modeWide).toFixed(2);
+              modeWideFixed = modeWideFixed.substring(
+                0,
+                modeWideFixed.length - 1
+              );
+              let modeHightFixed = (60 / modeHight).toFixed(2);
+              modeHightFixed = modeHightFixed.substring(
+                0,
+                modeHightFixed.length - 1
+              );
+              let num =
+                Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
+                row.moCount;
+              row['blockCount'] = num;
+            }
+
+            let numNew = (
+              Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
+              row.blockCount
+            ).toFixed(5);
+            row['requiredFormingNum'] = numNew;
+          } else if (name === 'sum') {
+            let e = row.requiredFormingNum;
+            //方数
+            row.planProductNum = e;
+
+            row.blockCount = Math.floor(
+              e / ((modelLong * modeWide * modeHight) / 1000000)
+            );
+
+            if (row.productName.includes('板材')) {
+              let num = Math.ceil(
+                row.blockCount /
+                  (Math.floor(600 / modelLong) *
+                    Math.floor(120 / modeHight) *
+                    Math.floor(60 / modeWide))
+              );
+
+              // 48 480  4807 480
+              row.moCount = num;
+            } else if (row.productName.includes('砌块')) {
+              row.moCount = Math.ceil(
+                row.blockCount /
+                  Math.floor(
+                    (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+                  )
+              );
+            }
+          } else if (name === 'blockCount') {
+            //块数
+            // row.blockCount = row.moCount;
+
+            row.blockCount = row.blockCount;
+
+            if (row.productName.includes('板材')) {
+              let moCount = Math.ceil(
+                row.blockCount /
+                  (Math.floor(600 / modelLong) *
+                    Math.floor(120 / modeHight) *
+                    Math.floor(60 / modeWide))
+              );
+
+              row.moCount = moCount;
+            } else if (row.productName.includes('砌块')) {
+              let moCount = Math.ceil(
+                row.blockCount /
+                  Math.floor(
+                    (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+                  )
+              );
+              this.$set(this.form, 'moCount', moCount);
+              row.moCount = moCount;
+            }
+
+            let a = (
+              (Number(row.blockCount) * modelLong * modeWide * modeHight) /
+              1000000
+            ).toFixed(5);
+            row.requiredFormingNum = a;
+          }
+        }
+      },
+
+      changeProduceType(e) {
+        if (this.clientEnvironmentId !== 4) {
+          this.form.bomCategoryId = '';
+          this.form['bomCategoryName'] = '';
+          this.form['bomCategoryVersions'] = '';
+
+          this.bomVersionList = [];
+
+          this.routingList = [];
+          this.form.produceRoutingId = '';
+          this.form.produceRoutingName = '';
+          this.form.produceVersionName = '';
+          this.bomListVersion();
+        }
+      },
+
+      // 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.getPlanRouting();
+      // },
+
+      changeRoute() {
+        this.$forceUpdate();
+        this.routingList.forEach((f) => {
+          if (f.id == this.form.produceRoutingId) {
+            this.$set(this.form, 'produceRoutingId', f.id);
+            this.$set(this.form, 'produceRoutingName', f.name);
+            this.$set(this.form, 'produceVersionName', f.version);
+          }
+        });
+      },
+
+      cancel() {
+        // this.visible = false;
+        this.initForm();
+        this.$emit('update:factoryVisable', false);
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .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;
+  }
+
+  .header_required {
+    .is-required:before {
+      content: '*';
+      color: #f56c6c;
+      margin-right: 4px;
+    }
+  }
+</style>

+ 2 - 0
src/views/unqualifiedProduct/unqualifiedList/detailList.vue

@@ -10,6 +10,7 @@
         :pageSize="20"
         :pageSizes="[20, 30, 40, 50, 100]"
         :key="key"
+        row-key="id"
       >
         <!-- 操作列 -->
         <template v-slot:toolbar v-if="showBtn">
@@ -346,6 +347,7 @@
             width: 45,
             type: 'selection',
             columnKey: 'selection',
+            reserveSelection: true,
             align: 'center',
             selectable: (row, index) => {
               return row.disposalStatus !== 2; //

+ 1 - 15
src/views/unqualifiedProduct/unqualifiedList/index.vue

@@ -167,21 +167,6 @@
             width: 100,
             showOverflowTooltip: true
           },
-
-          // {
-          //   prop: 'weight',
-          //   label: '重量',
-          //   align: 'center',
-          //   width: 100,
-          //   showOverflowTooltip: true
-          // },
-          // {
-          //   prop: 'weightUnit',
-          //   label: '重量单位',
-          //   align: 'center',
-          //   width: 100,
-          //   showOverflowTooltip: true
-          // },
           // {
           //   prop: 'produceRoutingName',
           //   label: '工艺路线',
@@ -236,6 +221,7 @@
       }
     },
     created() {
+      this.requestDict('质检计划类型');
       this.requestDict('处置状态');
     },
     filters: {},

+ 37 - 9
src/views/unqualifiedProduct/unqualifiedList/rework/index.vue

@@ -8,17 +8,18 @@
         :columns="columns"
         :datasource="datasource"
         :selection.sync="selection"
+        row-key="id"
       >
         <!-- 操作列 -->
-        <!-- <template v-slot:toolbar>
+        <template v-slot:toolbar>
           <el-button
             type="primary"
             slot="reference"
             :disabled="selection.length == 0"
-            @click="open(1)"
+            @click="addProductPlan"
             >转生产计划</el-button
           >
-          <el-button
+          <!-- <el-button
             type="primary"
             slot="reference"
             :disabled="selection.length == 0"
@@ -43,8 +44,8 @@
                 >批量删除</el-button
               >
             </template>
-          </el-popconfirm>
-        </template> -->
+          </el-popconfirm> -->
+        </template>
         <template v-slot:action="{ row }">
           <el-popconfirm
             class="ele-action"
@@ -72,11 +73,19 @@
       </ele-pro-table>
     </el-card>
     <SalesToProduction ref="salesToProductionRef" @success="reload" />
+
+    <factory-add
+      v-if="factoryVisable"
+      ref="factoryAddRef"
+      :factoryVisable.sync="factoryVisable"
+      :factoryData="selection"
+    ></factory-add>
   </div>
 </template>
 
 <script>
- import OrderSearch from '../components/probationalGoods-search.vue';
+  import OrderSearch from '../components/probationalGoods-search.vue';
+
   // import OrderSearch from '../components/rework-search.vue';
   import SalesToProduction from '../components/salesToProduction.vue';
   import dictMixins from '@/mixins/dictMixins';
@@ -86,14 +95,17 @@
     getReworkList,
     deleteReworkList
   } from '@/api/unacceptedProduct/index';
+  import FactoryAdd from '../components/factoryAdd.vue';
   export default {
     components: {
       OrderSearch,
-      SalesToProduction
+      SalesToProduction,
+      FactoryAdd
     },
     mixins: [dictMixins],
     data() {
       return {
+        factoryVisable: false,
         loading: false,
         dialogVisible: false,
         current: null,
@@ -108,7 +120,18 @@
     computed: {
       // 表格列配置
       columns() {
-       return [
+        return [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            reserveSelection: true,
+            selectable: (row, index) => {
+              return true;
+              return row.disposalStatus !== 2; //
+            }
+          },
           {
             columnKey: 'index',
             label: '序号',
@@ -231,7 +254,7 @@
             label: '创建时间',
             align: 'center',
             width: 160
-          },
+          }
           // {
           //   prop: 'reviewerName',
           //   label: '创建人',
@@ -328,6 +351,11 @@
         this.$nextTick(() => {
           this.$refs.table.reload({ page: 1, where });
         });
+      },
+      addProductPlan() {
+        console.log(this.selection);
+
+        this.factoryVisable = true;
       }
     }
   };