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

feat(工单管理): 添加工单分页导航功能并优化流程逻辑

liujt 6 месяцев назад
Родитель
Сommit
ccb1e0a585

+ 49 - 4
src/views/batchRecord/components/programRulesDialog.vue

@@ -4,6 +4,7 @@
     :visible.sync="visible"
     :visible.sync="visible"
     :close-on-click-modal="false"
     :close-on-click-modal="false"
     @close="handleClose"
     @close="handleClose"
+    append-to-body
     resizable
     resizable
     maxable
     maxable
     width="80%"
     width="80%"
@@ -512,6 +513,38 @@
       </ele-pro-table>
       </ele-pro-table>
     </el-form>
     </el-form>
 
 
+    <div v-if="plansList.length > 1" class="footer-box">
+        <div class="txt-tip">
+          共
+          <span class="active">
+            {{ plansList.length || 0 }}   
+          </span>
+          条记录,当前位于第
+          <span class="active">{{ activeIndex + 1 }}</span
+          >条
+        </div>
+
+        <el-button
+          type="primary"
+          icon="el-icon-arrow-left"
+          size="mini"
+          :disabled="activeIndex === 0"
+          @click="activeIndex--"
+        >
+          上一页
+        </el-button>
+
+        <el-button
+          type="primary"
+          size="mini"
+          :disabled="activeIndex === plansList.length - 1"
+          @click="activeIndex++"
+        >
+          下一页
+          <i class="el-icon-arrow-right el-icon--right"></i>
+        </el-button>
+      </div>
+
     <template v-slot:footer>
     <template v-slot:footer>
       <el-button
       <el-button
         v-if="type != 'detail'"
         v-if="type != 'detail'"
@@ -610,6 +643,7 @@
       return {
       return {
         visible: false,
         visible: false,
         title: '新增记录计划配置',
         title: '新增记录计划配置',
+        activeIndex: 0,
         formBaseData,
         formBaseData,
         addForm: JSON.parse(JSON.stringify(formBaseData)),
         addForm: JSON.parse(JSON.stringify(formBaseData)),
         rules: {
         rules: {
@@ -665,7 +699,8 @@
         butLoading: false,
         butLoading: false,
         teamAllList: [],
         teamAllList: [],
         loading: false,
         loading: false,
-        type: 'add' // 弹窗类型 add-新增 edit-编辑 detail-查看
+        type: 'add', // 弹窗类型 add-新增 edit-编辑 detail-查看
+        plansList: []
       };
       };
     },
     },
     computed: {
     computed: {
@@ -838,10 +873,12 @@
     },
     },
     methods: {
     methods: {
       // 外部调用,打开弹窗
       // 外部调用,打开弹窗
-      open(type, data) {
+      open(type, data, plans) {
         console.log('type data', type, data);
         console.log('type data', type, data);
         this.type = type;
         this.type = type;
-
+        if(plans && plans.length > 0) {
+          this.plansList = plans;
+        }
         if (type == 'add') {
         if (type == 'add') {
           this.title = '新增记录计划配置';
           this.title = '新增记录计划配置';
           this.getOrderCode();
           this.getOrderCode();
@@ -1073,7 +1110,7 @@
           productCode: '',
           productCode: '',
           // 1-成品统计,2-物料统计,3-工序统计"
           // 1-成品统计,2-物料统计,3-工序统计"
           statisticsType:
           statisticsType:
-            item.recordTemplateStyle == '4' ? this.statisticsType : null,
+            this.addForm.recordTemplateStyle == '4' ? this.statisticsType : null,
           // 公式
           // 公式
           formula: '',
           formula: '',
           _paramSelect: null,
           _paramSelect: null,
@@ -1276,4 +1313,12 @@
       cursor: pointer;
       cursor: pointer;
     }
     }
   }
   }
+
+  .footer-box {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    gap: 15px;
+    margin-top: 20px;
+  }
 </style>
 </style>

+ 47 - 2
src/views/batchRecord/components/workOrderReport.vue

@@ -6,6 +6,7 @@
     @close="handleClose"
     @close="handleClose"
     resizable
     resizable
     maxable
     maxable
+    append-to-body
     width="80%"
     width="80%"
   >
   >
     <header-title title="基本信息"></header-title>
     <header-title title="基本信息"></header-title>
@@ -311,6 +312,37 @@
 
 
     <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
     <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
 
 
+    <div v-if="recordsList.length > 1" class="footer-box">
+        <div class="txt-tip">
+          共
+          <span class="active">
+            {{ recordsList.length || 0 }}
+          </span>
+          条记录,当前位于第
+          <span class="active">{{ activeIndex + 1 }}</span
+          >条
+        </div>
+
+        <el-button
+          type="primary"
+          icon="el-icon-arrow-left"
+          size="mini"
+          :disabled="activeIndex === 0"
+          @click="activeIndex--"
+        >
+          上一页
+        </el-button>
+
+        <el-button
+          type="primary"
+          size="mini"
+          :disabled="activeIndex === recordsList.length - 1"
+          @click="activeIndex++"
+        >
+          下一页
+          <i class="el-icon-arrow-right el-icon--right"></i>
+        </el-button>
+      </div>
     <template v-slot:footer>
     <template v-slot:footer>
       <el-button
       <el-button
         v-if="type == 'add'"
         v-if="type == 'add'"
@@ -416,6 +448,7 @@
 
 
       return {
       return {
         visible: false,
         visible: false,
+        activeIndex: 0,
         type: 'add',
         type: 'add',
         title: '报工',
         title: '报工',
         formBaseData,
         formBaseData,
@@ -507,7 +540,8 @@
           { label: '工序统计', value: '3' }
           { label: '工序统计', value: '3' }
         ],
         ],
         executorList: [],
         executorList: [],
-        allTeamList: []
+        allTeamList: [],
+        recordsList: []
       };
       };
     },
     },
     computed: {
     computed: {
@@ -601,7 +635,7 @@
     },
     },
     methods: {
     methods: {
       // 外部调用,打开弹窗
       // 外部调用,打开弹窗
-      open(type = 'add', data) {
+      open(type = 'add', data, records) {
         this.type = type;
         this.type = type;
         console.log('data', data);
         console.log('data', data);
         if (type == 'add') {
         if (type == 'add') {
@@ -609,6 +643,9 @@
         } else {
         } else {
           this.title = '详情';
           this.title = '详情';
         }
         }
+        if(records && records.length > 0) {
+          this.recordsList = records;
+        }
         this.getOrderDetials(data.id);
         this.getOrderDetials(data.id);
         this.visible = true;
         this.visible = true;
       },
       },
@@ -1038,4 +1075,12 @@
   ::v-deep .el-select__tags::-webkit-scrollbar {
   ::v-deep .el-select__tags::-webkit-scrollbar {
     height: 2px !important;
     height: 2px !important;
   }
   }
+
+  .footer-box {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    gap: 15px;
+    margin-top: 20px;
+  }
 </style>
 </style>

+ 57 - 6
src/views/produce/components/prenatalExamination/index.vue

@@ -53,6 +53,18 @@
 
 
     <taskDialog ref="taskDialogRef" @reload="getData" />
     <taskDialog ref="taskDialogRef" @reload="getData" />
 
 
+    <!-- 派单 -->
+    <programRulesDialog
+      ref="programRulesDialogRef"
+      @reload="getData"
+    ></programRulesDialog>
+
+    <!-- 报工 -->
+    <workOrderReport
+      ref="workOrderReportRef"
+      @refresh="getData"
+    ></workOrderReport>
+
     <PlanRulesDialog
     <PlanRulesDialog
       ref="planRulesDialogRef"
       ref="planRulesDialogRef"
       @reload="getData"
       @reload="getData"
@@ -70,13 +82,17 @@
   import PlanRulesDialog from './PlanRulesDialog.vue';
   import PlanRulesDialog from './PlanRulesDialog.vue';
   import dictMixins from '@/mixins/dictMixins';
   import dictMixins from '@/mixins/dictMixins';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
+  import programRulesDialog from '@/views/batchRecord/components/programRulesDialog.vue';
+  import workOrderReport from '@/views/batchRecord/components/workOrderReport.vue';
 
 
   export default {
   export default {
     mixins: [dictMixins, tableColumnsMixin],
     mixins: [dictMixins, tableColumnsMixin],
     components: {
     components: {
       releaseRulesDialog,
       releaseRulesDialog,
       taskDialog,
       taskDialog,
-      PlanRulesDialog
+      PlanRulesDialog,
+      programRulesDialog,
+      workOrderReport
     },
     },
     data() {
     data() {
       return {
       return {
@@ -91,7 +107,9 @@
         butLoad: false,
         butLoad: false,
         // 记录规则
         // 记录规则
         showReleaseRulesDialog: false,
         showReleaseRulesDialog: false,
-        loading: true
+        loading: true,
+        programRulesDialogVisible: false,
+        programRulesInfo: {}
       };
       };
     },
     },
     computed: {
     computed: {
@@ -146,7 +164,7 @@
             minWidth: 150,
             minWidth: 150,
             formatter: (row) => {
             formatter: (row) => {
               // 毫秒转小时
               // 毫秒转小时
-              return row.duration
+              return row.duration && row.executeStatus == 2
                 ? (row.duration / 1000 / 60 / 60).toFixed(2) + ' 时'
                 ? (row.duration / 1000 / 60 / 60).toFixed(2) + ' 时'
                 : '';
                 : '';
             }
             }
@@ -240,9 +258,42 @@
           // 计划规则 巡点检 设备保养
           // 计划规则 巡点检 设备保养
           this.$refs.planRulesDialogRef.open(item);
           this.$refs.planRulesDialogRef.open(item);
         } else if (item.itemType == 2) {
         } else if (item.itemType == 2) {
-          if((!item.plans || item.plans.length == 0) && item.executeMethod == 1) {
-            this.$message.error('未生成记录计划');
-            return;
+          // 事件驱动
+          if(item.executeMethod == 1) {
+            // 是否有计划
+            if(!item.plans || item.plans.length == 0) {
+              this.$message.error('未生成记录计划');
+              return;
+            }
+            // 有计划无工单  派单
+            if(item.plans && item.plans.length > 0 && (!item.records || item.records.length == 0)) {
+              this.$refs.programRulesDialogRef.open('dispatch', item.plans[0], item.plans);
+              return;
+            }
+            // 有计划有工单未报工执行中  报工
+            if(item.plans && item.plans.length > 0 && item.records && item.records.length > 0 && (item.executeStatus == 1 || item.executeStatus == 0)) {
+              item.plans.forEach(plan => {
+                // 找到records数组中planid与当前plan.id匹配的记录
+                plan.matchedRecords = item.records.filter(record => record.planId == plan.id);
+              });
+              console.log('匹配后的plans数组:', item);
+              this.$refs.workOrderReportRef.open('add', item.plans[0]?.matchedRecords[0], item.plans[0]?.matchedRecords);
+              return;
+            }
+            // 有计划有工单已报工  详情
+            if(item.plans && item.plans.length > 0 && item.records && item.records.length > 0 && item.executeStatus == 2) {
+              item.plans.forEach(plan => {
+                // 找到records数组中planid与当前plan.id匹配的记录
+                plan.matchedRecords = item.records.filter(record => record.planId == plan.id);
+              });
+              console.log('详情匹配后的plans数组:', item);
+              if(item.plans[0]?.matchedRecords.length == 0) {
+                this.$message.error('未生成工单');
+                return
+              }
+              this.$refs.workOrderReportRef.open('detail', item.plans[0]?.matchedRecords[0], item.plans[0]?.matchedRecords);
+              return;
+            }
           }
           }
           this.$refs.releaseRulesDialogRef.open(
           this.$refs.releaseRulesDialogRef.open(
             item,
             item,