Explorar o código

物料清单功能改动

lucw hai 7 meses
pai
achega
1fd5adf3c7

+ 173 - 0
src/views/produce/components/prenatalExamination/material.vue

@@ -0,0 +1,173 @@
+<template>
+  <div>
+    <header-title title="物料清单"></header-title>
+
+    <ele-pro-table
+      ref="table"
+      row-key="id"
+      :columns="materialColumns"
+      :datasource="materialList"
+      cache-key="prenatal-examination-material-list-table-2510231107"
+      autoAmendPage
+      :needPage="false"
+      @refresh="$emit('refresh')"
+    >
+      <template v-slot:toolbar>
+        <el-button type="primary" @click="openMaterialModal"
+          >添加物料</el-button
+        >
+      </template>
+    </ele-pro-table>
+
+    <header-title title="产出清单" style="margin-top: 20px"></header-title>
+
+    <materialModal ref="materialModalRef" @confirm="materialConfirm" />
+  </div>
+</template>
+
+<script>
+  import materialModal from './materialModal.vue';
+
+  export default {
+    components: {
+      materialModal
+    },
+    props: {
+      // 物料明细
+      pickDetails: {
+        type: Array,
+        default: () => []
+      },
+      // 上到工序产出明细
+      previousOutputDetails: {
+        type: Array,
+        default: () => []
+      },
+      // 工单id
+      workOrderId: {
+        type: [String, Number],
+        required: true
+      },
+      // 规则id
+      ruleId: {
+        type: [String, Number],
+        required: true
+      },
+      // 工序id
+      produceTaskId: {
+        type: [String, Number],
+        required: true
+      }
+    },
+    watch: {
+      pickDetails: {
+        handler(newVal) {
+          this.localPickDetails = JSON.parse(JSON.stringify(newVal));
+        },
+        deep: true
+      }
+    },
+    computed: {
+      // 物料清单(包含上到工序产出明细)
+      materialList() {
+        return [...this.previousOutputDetails, ...this.localPickDetails];
+      }
+    },
+    data() {
+      return {
+        localPickDetails: JSON.parse(JSON.stringify(this.pickDetails)),
+        // 物料清单表头
+        materialColumns: [
+          {
+            width: 45,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center'
+          },
+          {
+            label: '类型',
+            prop: 'categoryLevelNamePath',
+            minWidth: 120
+          },
+          {
+            label: '编码',
+            prop: 'categoryCode',
+            minWidth: 120
+          },
+          {
+            label: '名称',
+            prop: 'categoryName',
+            minWidth: 120
+          },
+          {
+            prop: 'model',
+            label: '型号',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'specifications',
+            label: '规格',
+            align: 'center',
+            width: 160,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'brandNo',
+            label: '牌号',
+            align: 'center'
+          },
+          {
+            label: '工序名称',
+            prop: 'produceTaskName',
+            minWidth: 120
+          },
+          {
+            label: '数量',
+            prop: 'feedQuantity',
+            minWidth: 120,
+            formatter: (row) => {
+              return (row.quantity || '') + (row.unit || '');
+            }
+          }
+        ]
+      };
+    },
+    methods: {
+      // 选择物料
+      openMaterialModal() {
+        this.$refs.materialModalRef.open(
+          {
+            workOrderId: this.workOrderId,
+            ruleId: this.ruleId,
+            produceTaskId: this.produceTaskId
+          },
+          []
+        );
+      },
+      materialConfirm(data) {
+        // 选择物料后添加
+        console.log('data', data);
+
+        data.forEach((newItem) => {
+          const index = this.localPickDetails.findIndex(
+            (item) =>
+              item.categoryCode === newItem.categoryCode &&
+              item.produceTaskInstanceId === newItem.produceTaskInstanceId
+          );
+          if (index !== -1) {
+            // 存在则替换数量
+            this.localPickDetails[index].quantity = newItem.quantity;
+          } else {
+            // 不存在则添加
+            this.localPickDetails.push({ ...newItem });
+          }
+        });
+
+        this.$emit('update:pickDetails', this.localPickDetails);
+      }
+    }
+  };
+</script>
+
+<style></style>

+ 5 - 40
src/views/produce/components/prenatalExamination/materialModal.vue

@@ -86,24 +86,24 @@
           },
           {
             label: '名称',
-            prop: ' ',
+            prop: 'categoryName',
             minWidth: 120
           },
           {
-            prop: 'modelType',
+            prop: 'model',
             label: '型号',
             align: 'center',
             showOverflowTooltip: true
           },
           {
-            prop: 'specification',
+            prop: 'specifications',
             label: '规格',
             align: 'center',
             width: 160,
             showOverflowTooltip: true
           },
           {
-            prop: 'brandNum',
+            prop: 'brandNo',
             label: '牌号',
             align: 'center'
           },
@@ -117,42 +117,7 @@
             prop: 'feedQuantity',
             minWidth: 120,
             formatter: (row) => {
-              return (row.feedQuantity || 0) + (row.feedUnit || '');
-            }
-          },
-          {
-            label: '已报工数量',
-            prop: 'reportQuantity',
-            minWidth: 120,
-            formatter(row) {
-              return (row.reportQuantity || 0) + row.feedUnit;
-            }
-          },
-          {
-            label: '未报工数量',
-            prop: 'noReportQuantity',
-            minWidth: 120,
-            formatter(row) {
-              if (row.reportQuantity != null) {
-                return row.feedQuantity - row.reportQuantity + row.feedUnit;
-              }
-              return `${row.feedQuantity}${row.feedUnit || ''}`;
-            }
-          },
-          {
-            label: '合格总数',
-            prop: 'qualifiedQuantity',
-            minWidth: 120,
-            formatter(row) {
-              return (row.qualifiedQuantity || 0) + (row.feedUnit || '');
-            }
-          },
-          {
-            label: '不合格总数',
-            prop: 'noQualifiedQuantity',
-            minWidth: 120,
-            formatter(row) {
-              return (row.noQualifiedQuantity || 0) + (row.feedUnit || '');
+              return (row.quantity || 0) + (row.unit || '');
             }
           }
         ],

+ 18 - 251
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -209,64 +209,14 @@
       </el-row>
     </el-form>
 
-    <header-title
-      v-if="addForm.reportWorkType == '2' && addForm.produceTaskId"
-      title="物料清单"
-    ></header-title>
-
-    <ele-pro-table
-      v-if="addForm.reportWorkType == '2' && addForm.produceTaskId"
-      ref="table"
-      row-key="id"
-      :columns="materialColumns"
-      :datasource="addForm.pickDetails"
-      cache-key="prenatal-examination-material-list-table-2510231107"
-      autoAmendPage
-      :needPage="false"
-      @refresh="getListByWorkOrderId"
-    >
-      <template v-slot:toolbar>
-        <el-button type="primary" @click="openMaterialModal"
-          >添加物料</el-button
-        >
-      </template>
-
-      <template v-slot:reportQuantity="{ row }">
-        <el-input-number
-          size="small"
-          v-model.number="row.reportQuantity"
-          controls-position="right"
-          :min="0"
-          :max="row.feedQuantity"
-        ></el-input-number>
-      </template>
-      <template v-slot:qualifiedQuantity="{ row }">
-        <el-input-number
-          size="small"
-          v-model.number="row.qualifiedQuantity"
-          controls-position="right"
-          :min="0"
-          :max="qualifiedQuantityMax(row)"
-        ></el-input-number>
-      </template>
-      <template v-slot:noQualifiedQuantity="{ row }">
-        <el-input-number
-          size="small"
-          v-model.number="row.noQualifiedQuantity"
-          controls-position="right"
-          :min="0"
-          :max="noQualifiedQuantityMax(row)"
-        ></el-input-number>
-      </template>
-      <template v-slot:msg="{ row }">
-        <el-input
-          v-model="row.msg"
-          type="textarea"
-          rows="1"
-          autosize
-        ></el-input>
-      </template>
-    </ele-pro-table>
+    <material
+      v-if="addForm.produceTaskId"
+      :pickDetails.sync="addForm.pickDetails"
+      :previousOutputDetails="previousOutputDetails"
+      :workOrderId="addForm.workOrderId"
+      :ruleId="addForm.ruleId"
+      :produceTaskId="addForm.produceTaskId"
+    ></material>
 
     <header-title
       title="检查项目"
@@ -423,8 +373,6 @@
     </template>
 
     <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
-
-    <materialModal ref="materialModalRef" @confirm="materialConfirm" />
   </ele-modal>
 </template>
 
@@ -444,13 +392,13 @@
   } from '@/api/producetaskrecordrulesrecord/index';
   import toolModal from '@/views/batchRecord/components/toolModal.vue';
   import { getTeam } from '@/api/produce/job.js';
-  import materialModal from './materialModal.vue';
   import { getFactoryarea } from '@/api/aps/index';
   import dictMixins from '@/mixins/dictMixins';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
+  import material from './material.vue';
 
   export default {
-    components: { SelectUser, toolModal, materialModal },
+    components: { SelectUser, toolModal, material },
     mixins: [dictMixins, tableColumnsMixin],
     emits: ['reload'],
     props: {
@@ -609,140 +557,9 @@
         teamUserList: [],
         teamList: [],
         teamAllList: [],
-        // 物料清单表头
-        materialColumns: [
-          {
-            width: 45,
-            type: 'index',
-            columnKey: 'index',
-            align: 'center'
-          },
-          {
-            label: '类型',
-            prop: 'categoryLevelNamePath',
-            minWidth: 120
-          },
-          {
-            label: '编码',
-            prop: 'categoryCode',
-            minWidth: 120
-          },
-          {
-            label: '名称',
-            prop: 'categoryName',
-            minWidth: 120
-          },
-          ,
-          {
-            prop: 'modelType',
-            label: '型号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'specification',
-            label: '规格',
-            align: 'center',
-            width: 160,
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'brandNum',
-            label: '牌号',
-            align: 'center'
-          },
-          {
-            prop: 'modelType',
-            label: '型号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'specification',
-            label: '规格',
-            align: 'center',
-            width: 160,
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'brandNum',
-            label: '牌号',
-            align: 'center'
-          },
-          {
-            label: '工序名称',
-            prop: 'produceTaskName',
-            minWidth: 120
-          },
-          {
-            label: '数量',
-            prop: 'feedQuantity',
-            minWidth: 120,
-            formatter: (row) => {
-              return (row.feedQuantity || '') + (row.feedUnit || '');
-            }
-          },
-          {
-            label: '当次报工数量',
-            prop: 'reportQuantity',
-            minWidth: 160,
-            slot: 'reportQuantity'
-          },
-          {
-            label: '当次合格数量',
-            prop: 'qualifiedQuantity',
-            minWidth: 160,
-            slot: 'qualifiedQuantity'
-          },
-          {
-            label: '当次不合格数量',
-            prop: 'noQualifiedQuantity',
-            minWidth: 160,
-            slot: 'noQualifiedQuantity'
-          },
-          {
-            label: '不合格原因',
-            prop: 'msg',
-            minWidth: 160,
-            slot: 'msg'
-          },
-          {
-            label: '已报工数量',
-            prop: 'sumReportQuantity',
-            minWidth: 120,
-            formatter(row) {
-              return (row.sumReportQuantity || 0) + row.feedUnit;
-            }
-          },
-          {
-            label: '未报工数量',
-            prop: 'noReportQuantity',
-            minWidth: 120,
-            formatter(row) {
-              if (row.sumReportQuantity != null) {
-                return row.feedQuantity - row.sumReportQuantity + row.feedUnit;
-              }
-              return `${row.feedQuantity}${row.feedUnit || ''}`;
-            }
-          },
-          {
-            label: '合格总数',
-            prop: 'sumQualifiedQuantity',
-            minWidth: 120,
-            formatter(row) {
-              return (row.sumQualifiedQuantity || 0) + (row.feedUnit || '');
-            }
-          },
-          {
-            label: '不合格总数',
-            prop: 'sumNoQualifiedQuantity',
-            minWidth: 120,
-            formatter(row) {
-              return (row.sumNoQualifiedQuantity || 0) + (row.feedUnit || '');
-            }
-          }
-        ],
-        workshopAreaList: []
+        workshopAreaList: [],
+        // 上到工序的 产出明细
+        previousOutputDetails: []
       };
     },
     computed: {
@@ -940,15 +757,16 @@
       async getListByWorkOrderId() {
         if (!this.productionInfo.produceTaskId) return;
         // 查询物料信息
-        const materialList = await queryListByWorkOrderId({
+        const materialObject = await queryListByWorkOrderId({
           workOrderId: this.addForm.workOrderId,
           recordId: this.productionInfo.recordId,
           produceTaskId: this.productionInfo.produceTaskId,
           ruleId: this.addForm.ruleId
         });
 
-        console.log('materialList 物料信息', materialList);
-        this.addForm.pickDetails = materialList;
+        console.log('materialList 物料信息', materialObject);
+        this.addForm.pickDetails = materialObject.pickDetails;
+        this.previousOutputDetails = materialObject.outputDetails;
       },
       // 规则信息
       async getRuleInfo() {
@@ -999,6 +817,7 @@
       },
       // 提交
       submit(type) {
+        console.log('this.addForm', this.addForm);
         // 验证表单
         this.$refs.ruleFormRef.validate(async (valid) => {
           if (!valid) {
@@ -1229,58 +1048,6 @@
 
         console.log('row', row);
       },
-      // 选择物料
-      openMaterialModal() {
-        this.$refs.materialModalRef.open(
-          {
-            workOrderId: this.addForm.workOrderId,
-            ruleId: this.addForm.ruleId,
-            produceTaskId: this.workOrderInfo.produceTaskId
-          },
-          []
-        );
-      },
-      materialConfirm(data) {
-        // 选择物料后添加
-        console.log('data', data);
-
-        // 去重
-        const list = data
-          .filter((i) => {
-            const any = this.addForm.pickDetails.find(
-              (item) =>
-                item.categoryCode === i.categoryCode &&
-                item.produceTaskInstanceId === i.produceTaskInstanceId
-            );
-            return !any;
-          })
-          .map((i) => {
-            i.ruleId = this.addForm.ruleId;
-            return i;
-          });
-
-        // 覆盖部分数据
-        this.addForm.pickDetails = this.addForm.pickDetails.map((i) => {
-          const item = data.find(
-            (item) =>
-              item.categoryCode === i.categoryCode &&
-              item.produceTaskInstanceId === i.produceTaskInstanceId
-          );
-          if (item) {
-            return {
-              ...item,
-              reportQuantity: i.reportQuantity,
-              qualifiedQuantity: i.qualifiedQuantity,
-              noQualifiedQuantity: i.noQualifiedQuantity,
-              msg: i.msg
-            };
-          }
-          return i;
-        });
-        this.addForm.pickDetails = [...this.addForm.pickDetails, ...list];
-        console.log('list', list);
-        console.log('this.addForm.pickDetails', this.addForm.pickDetails);
-      },
       // qualifiedQuantityMax 最大合格数量
       qualifiedQuantityMax(row) {
         return row.reportQuantity - row.noQualifiedQuantity;

+ 2 - 2
vue.config.js

@@ -36,8 +36,8 @@ module.exports = {
         // target: 'http://192.168.1.125:18086',
         // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.251:18086',
-        target: 'http://192.168.1.125:18086',
-        // target: 'http://192.168.1.116:18086', // 赵沙金
+        // target: 'http://192.168.1.125:18086',
+        target: 'http://192.168.1.116:18086', // 赵沙金
         // target: 'http://192.168.1.251:18086', // 开发环境
         // target: 'http://192.168.1.103:18086',192.168.1.116
         // target: 'http://192.168.1.144:18086',