Просмотр исходного кода

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-mes into dengfei

695593266@qq.com 7 месяцев назад
Родитель
Сommit
998b405e39

+ 12 - 0
src/api/producetaskrecordrulesrecord/index.js

@@ -42,3 +42,15 @@ export async function getById(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// /mes/producetaskrulerecordpickdetail/queryListByWorkOrderId post
+export async function queryListByWorkOrderId(body) {
+  const res = await request.post(
+    '/mes/producetaskrulerecordpickdetail/queryListByWorkOrderId',
+    body
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 23 - 0
src/api/producetaskrulerecord/index.js

@@ -79,3 +79,26 @@ export async function logicDeleteById(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// /mes/producetaskrulerecordpickdetail/queryPickAndFeedByWorkOrderId
+export async function queryPickAndFeedByWorkOrderId(body) {
+  const res = await request.post(
+    '/mes/producetaskrulerecordpickdetail/queryPickAndFeedByWorkOrderId',
+    body
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// GET /mes/producetaskrulerecordpickdetail/queryAllProduceTaskInstanceInPickOrder/{workOrderId}
+export async function queryAllProduceTaskInstanceInPickOrder(workOrderId) {
+  const res = await request.get(
+    `/mes/producetaskrulerecordpickdetail/queryAllProduceTaskInstanceInPickOrder/${workOrderId}`
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 255 - 0
src/views/produce/components/prenatalExamination/materialModal.vue

@@ -0,0 +1,255 @@
+<template>
+  <el-dialog
+    v-if="visible"
+    :title="title"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="70%"
+    :fullscreen="fullscreen"
+    class="fullscreen"
+  >
+    <el-card shadow="never">
+      <seek-page :seekList="seekList"></seek-page>
+      <ele-pro-table
+        style="min-height: 400px"
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        :selection.sync="selection"
+        :need-page="false"
+        row-key="index"
+      >
+      </ele-pro-table>
+    </el-card>
+
+    <div class="rx-sc">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import SeekPage from '@/components/common/seekPage.vue';
+  import {
+    queryPickAndFeedByWorkOrderId,
+    queryAllProduceTaskInstanceInPickOrder
+  } from '@/api/producetaskrulerecord/index.js';
+
+  export default {
+    components: {
+      SeekPage
+    },
+    data() {
+      return {
+        fullscreen: false,
+        visible: false,
+        title: '选择物品',
+        type: null,
+
+        // 表格列配置
+        columns: [
+          {
+            columnKey: 'selection',
+            type: 'selection',
+            width: 45,
+            align: 'center',
+            reserveSelection: true,
+            fixed: 'left',
+            selectable: (row, index) => {
+              // 已选物料不可再选
+              return !this.pickDetails.some(
+                (item) =>
+                  item.categoryCode === row.categoryCode &&
+                  item.produceTaskInstanceId === row.produceTaskInstanceId
+              );
+            }
+          },
+          {
+            width: 45,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center'
+          },
+          {
+            label: '批次号',
+            prop: 'batchNo',
+            minWidth: 120
+          },
+
+          {
+            label: '领料类型',
+            prop: 'categoryLevelNamePath',
+            minWidth: 120
+          },
+          {
+            label: '物料编码',
+            prop: 'categoryCode',
+            minWidth: 120
+          },
+          {
+            label: '物料名称',
+            prop: 'categoryName',
+            minWidth: 120
+          },
+          {
+            label: '工序名称',
+            prop: 'produceTaskName',
+            minWidth: 120
+          },
+          {
+            label: '领料数量',
+            prop: 'pickQuantity',
+            minWidth: 120,
+            formatter: (row) => {
+              return (row.pickQuantity || 0) + (row.pickUnit || '');
+            }
+          },
+          {
+            label: '出库数量',
+            prop: 'outStorageQuantity',
+            minWidth: 120,
+            formatter: (row) => {
+              return (row.outStorageQuantity || 0) + (row.outStorageUnit || '');
+            }
+          },
+          {
+            label: '投料数量',
+            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 || '');
+            }
+          }
+        ],
+
+        // 表格选中数据
+        selection: [],
+        taskPlanList: [],
+        workOrderId: '',
+        ruleId: '',
+        // 已选物料
+        pickDetails: []
+      };
+    },
+    computed: {
+      seekList() {
+        return [
+          {
+            label: '关键词:',
+            value: 'keyword',
+            type: 'input',
+            placeholder: '物料编码、物料名称、批次号'
+          },
+          {
+            label: '工序名称:',
+            value: 'produceTaskInstanceId',
+            type: 'select',
+            placeholder: '选择工序',
+            planList: this.taskPlanList
+          }
+        ];
+      }
+    },
+    created() {},
+    methods: {
+      /* 表格数据源 */
+      async datasource({ page, limit, where }) {
+        const res = await queryPickAndFeedByWorkOrderId({
+          ...where,
+          workOrderId: this.workOrderId,
+          ruleId: this.ruleId
+          // pageNum: page,
+          // size: limit
+        });
+        return res;
+      },
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where: where });
+      },
+      handleClose() {
+        this.$refs.table.setSelectedRows([]);
+        this.selection = [];
+        this.visible = false;
+      },
+      open(workOrderId, ruleId, pickDetails = []) {
+        this.workOrderId = workOrderId;
+        this.pickDetails = pickDetails;
+        this.ruleId = ruleId;
+        this.$nextTick(() => {
+          // this.reload({ workOrderId });
+          this.queryAllProduceTaskList(workOrderId);
+        });
+        this.visible = true;
+      },
+      selected() {
+        if (this.selection.length === 0) {
+          this.$message.warning('请至少选择一条数据');
+          return;
+        }
+        this.$emit('confirm', this.selection);
+        this.handleClose();
+      },
+      async queryAllProduceTaskList(workOrderId) {
+        const res = await queryAllProduceTaskInstanceInPickOrder(workOrderId);
+        this.taskPlanList = res.map((item) => {
+          return {
+            label: item.taskName,
+            value: item.taskId
+          };
+        });
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .rx-sc {
+    flex: 0 0 50px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+  }
+  .ml60 {
+    margin-left: 60px;
+  }
+</style>

+ 258 - 22
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -195,11 +195,53 @@
       ref="table"
       row-key="id"
       :columns="materialColumns"
-      :datasource="[]"
+      :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>
 
     <header-title title="检查项目"></header-title>
@@ -355,6 +397,8 @@
     </template>
 
     <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
+
+    <materialModal ref="materialModalRef" @confirm="materialConfirm" />
   </ele-modal>
 </template>
 
@@ -369,14 +413,15 @@
     saveOrUpdateAndSubmit,
     saveOrUpdate,
     logicDelete,
-    getById
+    getById,
+    queryListByWorkOrderId
   } from '@/api/producetaskrecordrulesrecord/index';
   import toolModal from '@/views/batchRecord/components/toolModal.vue';
   import { getTeam } from '@/api/produce/job.js';
-  import { det, row } from 'mathjs';
+  import materialModal from './materialModal.vue';
 
   export default {
-    components: { SelectUser, toolModal },
+    components: { SelectUser, toolModal, materialModal },
     emits: ['reload'],
     props: {
       isTempRecord: {
@@ -430,7 +475,9 @@
           // }
         ],
         // 班组id
-        teamId: ''
+        teamId: '',
+        // 物料字段name
+        pickDetails: []
       };
 
       return {
@@ -450,11 +497,10 @@
                 if (!value) return callback();
                 const now = new Date();
                 const start = new Date(value);
-                if (start < now) {
-                  callback(new Error('开始时间不能小于当前时间'));
-                } else {
-                  callback();
-                }
+                // if (start < now) {
+                //   return callback(new Error('开始时间不能小于当前时间'));
+                // }
+                callback();
               },
               trigger: 'blur'
             }
@@ -534,7 +580,127 @@
         checked: false,
         teamUserList: [],
         teamList: [],
-        teamAllList: []
+        teamAllList: [],
+        // 物料清单表头
+        materialColumns: [
+          {
+            width: 45,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center'
+          },
+          {
+            label: '批次号',
+            prop: 'batchNo',
+            minWidth: 120
+          },
+
+          {
+            label: '领料类型',
+            prop: 'categoryLevelNamePath',
+            minWidth: 120
+          },
+          {
+            label: '物料编码',
+            prop: 'categoryCode',
+            minWidth: 120
+          },
+          {
+            label: '物料名称',
+            prop: 'categoryName',
+            minWidth: 120
+          },
+          {
+            label: '工序名称',
+            prop: 'produceTaskName',
+            minWidth: 120
+          },
+          {
+            label: '领料数量',
+            prop: 'pickQuantity',
+            minWidth: 120,
+            formatter: (row) => {
+              return (row.pickQuantity || '') + (row.pickUnit || '');
+            }
+          },
+          {
+            label: '出库数量',
+            prop: 'outStorageQuantity',
+            minWidth: 120,
+            formatter: (row) => {
+              return (
+                (row.outStorageQuantity || '') + (row.outStorageUnit || '')
+              );
+            }
+          },
+          {
+            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 || '');
+            }
+          }
+        ]
       };
     },
     computed: {
@@ -556,16 +722,7 @@
         return this.teamUserList.filter((user) =>
           this.addForm.executeUsersIds.includes(user.id)
         );
-      },
-      // 物料清单表头
-      materialColumns: [
-        {
-          width: 45,
-          type: 'index',
-          columnKey: 'index',
-          align: 'center'
-        }
-      ]
+      }
     },
     mounted() {
       if (localStorage.getItem('singleUserInfo') == '1') {
@@ -667,11 +824,26 @@
             this.teamUserList = this.teamAllList[index];
           }
 
+          this.getListByWorkOrderId();
+
           this.loading = false;
         } catch (error) {
           this.loading = false;
         }
       },
+      // 物料信息查询
+      async getListByWorkOrderId() {
+        // 查询物料信息
+        const materialList = await queryListByWorkOrderId({
+          workOrderId: this.addForm.workOrderId,
+          recordId: this.productionInfo.recordId,
+          produceTaskInstanceId: this.workOrderInfo.taskId,
+          ruleId: this.addForm.ruleId
+        });
+
+        console.log('materialList 物料信息', materialList);
+        this.addForm.pickDetails = materialList;
+      },
       // 规则信息
       async getRuleInfo() {
         const data = await getRecordRulesDetail(this.productionInfo.ruleId);
@@ -715,8 +887,8 @@
       handleBeforeClose() {
         this.addForm = JSON.parse(JSON.stringify(this.formDate));
         console.log('this.$refs.ruleFormRef', this.addForm);
-        this.$refs.ruleFormRef?.clearValidate();
         this.$nextTick(() => {
+          this.$refs.ruleFormRef.clearValidate();
           this.visible = false;
         });
       },
@@ -799,12 +971,20 @@
           this.addForm.checkValidityUnit = null;
           this.addForm.conclution = null;
           this.addForm.id = null;
+          this.addForm.pickDetails = [];
+          this.addForm.duration = 0;
+          this.addForm.executeUsers = [];
+          thia.addForm.executeUsersIds = [];
 
           this.getRuleList();
           this.$message.success('缓存清空成功!');
           this.productionInfo.executeStatus = 0;
           if (this.addForm.isTempRecord) {
             this.handleBeforeClose();
+          } else {
+            this.$nextTick(() => {
+              this.$refs.ruleFormRef.clearValidate();
+            });
           }
           this.$emit('reload');
         } catch (error) {
@@ -942,6 +1122,62 @@
         });
 
         console.log('row', row);
+      },
+      // 选择物料
+      openMaterialModal() {
+        this.$refs.materialModalRef.open(
+          this.addForm.workOrderId,
+          this.addForm.ruleId,
+          []
+        );
+      },
+      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;
+      },
+      noQualifiedQuantityMax(row) {
+        return row.reportQuantity - row.qualifiedQuantity;
       }
     }
   };

+ 2 - 2
src/views/produce/index.vue

@@ -118,8 +118,8 @@
               </el-popover></template
             >
 
-            <!-- <span
-              >支持工单编码,产品编码,产品名称,产品规格,牌号,型号,批次号查询</span
+            <!--
+            <span>支持工单编码,产品编码,产品名称,产品规格,牌号,型号,批次号查询</span
             > -->
           </div>
           <div