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

feat(产前检查): 添加事件驱动计划规则弹窗功能

liujt 7 месяцев назад
Родитель
Сommit
81d5d4dc42

+ 1 - 37
src/views/batchRecord/components/programRulesDialog.vue

@@ -513,38 +513,6 @@
       </ele-pro-table>
     </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>
       <el-button
         v-if="type != 'detail'"
@@ -700,7 +668,6 @@
         teamAllList: [],
         loading: false,
         type: 'add', // 弹窗类型 add-新增 edit-编辑 detail-查看
-        plansList: []
       };
     },
     computed: {
@@ -873,12 +840,9 @@
     },
     methods: {
       // 外部调用,打开弹窗
-      open(type, data, plans) {
+      open(type, data) {
         console.log('type data', type, data);
         this.type = type;
-        if(plans && plans.length > 0) {
-          this.plansList = plans;
-        }
         if (type == 'add') {
           this.title = '新增记录计划配置';
           this.getOrderCode();

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

@@ -311,38 +311,6 @@
     </el-form>
 
     <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>
       <el-button
         v-if="type == 'add'"
@@ -540,8 +508,7 @@
           { label: '工序统计', value: '3' }
         ],
         executorList: [],
-        allTeamList: [],
-        recordsList: []
+        allTeamList: []
       };
     },
     computed: {
@@ -635,7 +602,7 @@
     },
     methods: {
       // 外部调用,打开弹窗
-      open(type = 'add', data, records) {
+      open(type = 'add', data) {
         this.type = type;
         console.log('data', data);
         if (type == 'add') {
@@ -643,9 +610,6 @@
         } else {
           this.title = '详情';
         }
-        if(records && records.length > 0) {
-          this.recordsList = records;
-        }
         this.getOrderDetials(data.id);
         this.visible = true;
       },

+ 43 - 27
src/views/produce/components/prenatalExamination/PlanRulesDialog copy.vue → src/views/produce/components/prenatalExamination/PlanRulesEventDialog.vue

@@ -9,31 +9,31 @@
     width="80%"
     append-to-body
   >
-    <div v-if="rulesInfo && currentPlanOrders">
-      <!-- {{ JSON.stringify(currentPlanOrders) }} -->
-      <!-- 根据当前currentPlanOrders的 planStatus状态展示不同内容 -->
+    <div v-if="rulesInfo && currentPlans">
+      <!-- {{ JSON.stringify(currentPlans) }} -->
+      <!-- 根据当前currentPlanOrders的 status状态展示不同内容 -->
       <!-- 0 派单, 4为撤回的计划 -->
       <programRulesDialog
         v-if="
-          currentPlanOrders.planStatus == 0 || currentPlanOrders.planStatus == 4
+          currentPlans.status == 0 || currentPlans.status == 4
         "
-        :planId="currentPlanOrders.planId"
-        :info="currentPlanOrders"
+        :planId="currentPlans.id"
+        :info="currentPlans"
         @done="setWorkOrderIdAndStatus"
       />
       <!-- 1 报工 -->
-      <signingUpWork
-        v-if="currentPlanOrders.planStatus == 1"
-        :planId="currentPlanOrders.planId"
-        :workOrderId="currentPlanOrders.eamWorkOrderId"
-        @refresh="setPlanStatus(2)"
-      ></signingUpWork>
+      <!-- <signingUpWork
+        v-if="currentPlans.status == 1"
+        :planId="currentPlans.planId"
+        :workOrderId="currentPlans.eamWorkOrderId"
+        @refresh="setStatus(2)"
+      ></signingUpWork> -->
       <!-- 2 执行中 3 完成展示详情-->
       <workOrderDetails
         v-if="
-          currentPlanOrders.planStatus == 3 || currentPlanOrders.planStatus == 2
+          currentPlans.status == 3 || currentPlans.status == 2
         "
-        :workOrderId="currentPlanOrders.eamWorkOrderId"
+        :workOrderId="currentPlanRecords.id"
       ></workOrderDetails>
     </div>
 
@@ -42,7 +42,7 @@
         <div class="txt-tip">
           <span class="active">
-            {{ rulesInfo ? rulesInfo.planOrders.length : 0 }}
+            {{ rulesInfo ? rulesInfo.plans.length : 0 }}
           </span>
           条记录,当前位于第
           <span class="active">{{ activeIndex + 1 }}</span
@@ -62,7 +62,7 @@
         <el-button
           type="primary"
           size="mini"
-          :disabled="activeIndex === rulesInfo.planOrders.length - 1"
+          :disabled="activeIndex === rulesInfo.plans.length - 1"
           @click="activeIndex++"
         >
           下一页
@@ -78,8 +78,8 @@
 <script>
   import dictMixins from '@/mixins/dictMixins';
   import signingUpWork from './components/workOrder/signingUpWork.vue';
-  import workOrderDetails from './components/workOrder/details.vue';
-  import programRulesDialog from './components/workOrder/programRulesDialog.vue';
+  import workOrderDetails from './components/workOrder/workOrderEvent.vue';
+  import programRulesDialog from './components/workOrder/programRulesEventDialog.vue';
 
   export default {
     mixins: [dictMixins],
@@ -99,13 +99,28 @@
       };
     },
     computed: {
-      // 当前设备信息
-      currentPlanOrders() {
-        if (this.rulesInfo && this.rulesInfo.planOrders) {
-          return this.rulesInfo.planOrders[this.activeIndex];
+      // 当前计划信息
+      currentPlans() {
+        if (this.rulesInfo && this.rulesInfo.plans) {
+          console.log('this.rulesInfo.plans', this.rulesInfo.plans[this.activeIndex]);
+          return this.rulesInfo.plans[this.activeIndex];
         }
         return {};
+      },
+      // 当前计划工单信息
+      currentPlanRecords() {
+        if (this.currentPlans && this.currentPlans.matchedRecords) {
+          console.log('this.currentPlans.matchedRecords', this.currentPlans.matchedRecords[this.activeIndex]);
+          return this.currentPlans.matchedRecords?.[0] || {};
+        }
+        return {};
+      },
+      orderLength() {
+        return this.currentPlans.status == 0 || this.currentPlans.status == 4 ? this.rulesInfo.plans.length : this.currentPlans.matchedRecords.length;
       }
+    },
+    created() {
+      
     },
     methods: {
       // 外部调用,打开弹窗
@@ -126,14 +141,15 @@
         });
       },
       // 报工成功后刷新当前项状态
-      setPlanStatus(status) {
-        this.rulesInfo.planOrders[this.activeIndex].planStatus = status;
+      setStatus(status) {
+        console.log('status~~~', status);
+        this.rulesInfo.plans[this.activeIndex].status = status;
       },
       setWorkOrderIdAndStatus(workOrderId) {
-        console.log('workOrderId', workOrderId);
-        this.rulesInfo.planOrders[this.activeIndex].eamWorkOrderId =
+        // console.log('workOrderId', workOrderId);
+        this.rulesInfo.plans[this.activeIndex].matchedRecords[0].id =
           workOrderId;
-        this.setPlanStatus(1);
+        this.setStatus(2);
       }
     }
   };

+ 1304 - 0
src/views/produce/components/prenatalExamination/components/workOrder/programRulesEventDialog.vue

@@ -0,0 +1,1304 @@
+<template>
+  <div>
+    <header-title title="基本信息"></header-title>
+    <el-form
+      ref="formRef"
+      :model="addForm"
+      :rules="rules"
+      label-width="120px"
+      :disabled="type === 'detail'"
+      v-loading="loading"
+    >
+      <el-row>
+        <el-col :span="8">
+          <el-form-item label="计划配置单号" prop="code">
+            <el-input
+              v-model="addForm.code"
+              size="small"
+              placeholder="自动带出"
+              disabled
+            ></el-input>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="计划配置名称" prop="name">
+            <el-input
+              v-model="addForm.name"
+              size="small"
+              placeholder="请输入"
+              :disabled="type === 'dispatch'"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="自动派单" prop="autoOrder">
+            <el-select
+              v-model="addForm.autoOrder"
+              size="small"
+              style="width: 100%"
+              :disabled="type === 'dispatch'"
+            >
+              <el-option :value="1" label="是"></el-option>
+              <el-option :value="0" label="否"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="计划完成时长" prop="duration">
+            <div style="display: flex">
+              <el-input
+                type="number"
+                v-model="addForm.duration"
+                size="small"
+                placeholder="请输入"
+                @input="formDataDurationTime"
+                :disabled="type === 'dispatch'"
+              >
+                <template #suffix>分钟</template>
+              </el-input>
+            </div>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="类型" prop="type">
+            <el-select
+              v-model="addForm.type"
+              size="small"
+              @change="typeChange"
+              style="width: 100%"
+            >
+              <el-option :value="1" label="班组"></el-option>
+              <el-option :value="0" label="个人"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" v-if="addForm.autoOrder && addForm.type == 1">
+          <el-form-item label="班组" prop="teamId">
+            <el-select
+              v-model="addForm.teamId"
+              size="small"
+              @change="teamChange"
+              style="width: 100%"
+            >
+              <el-option
+                :value="i.id"
+                :label="i.name"
+                v-for="i in teamAllList"
+                :key="i.id"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" v-if="addForm.autoOrder && addForm.type == 0">
+          <el-form-item label="部门" prop="groupId">
+            <deptSelect
+              v-model="addForm.groupId"
+              @changeGroup="searchDeptNodeClick"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" v-if="addForm.autoOrder && addForm.type == 0">
+          <el-form-item label="负责人" prop="executeIdList">
+            <el-select
+              v-model="addForm.executeIdList"
+              size="small"
+              style="width: 100%"
+              multiple
+              filterable
+              @change="executeIdListChange"
+            >
+              <el-option
+                v-for="item in executorList"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <!-- <el-col :span="8">
+          <el-form-item label="审核人" prop="approvalUserId">
+            <el-select
+              v-model="addForm.approvalUserId"
+              size="small"
+              clearable
+              style="width: 100%"
+              filterable
+            >
+              <el-option
+                v-for="item in uerList"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col> -->
+        <el-col :span="8">
+          <el-form-item label="紧急程度" prop="urgent">
+            <DictSelection
+              dictName="紧急程度"
+              clearable
+              v-model="addForm.urgent"
+              :disabled="type === 'dispatch'"
+            >
+            </DictSelection>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="关联记录规则" required prop="ruleName">
+            <div class="mask-box" @click="handleAddTab">
+              <el-input
+                v-model="addForm.ruleName"
+                placeholder="请选择记录规则"
+                size="small"
+                readonly
+                :disabled="type === 'dispatch'"
+              >
+                <template #append>
+                  <el-button size="small">选择规则</el-button>
+                </template>
+              </el-input>
+            </div>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="关联车间" required prop="workshopPlanName">
+            <div class="mask-box" @click="openWorkShops">
+              <el-input
+                v-model="addForm.workshopPlanName"
+                placeholder="请选择关联车间"
+                size="small"
+                readonly
+                :disabled="type === 'dispatch'"
+              >
+                <template #append>
+                  <el-button size="small">选择车间</el-button>
+                </template>
+              </el-input>
+            </div>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="16">
+          <el-form-item label="备注" prop="remark">
+            <el-input
+              type="textarea"
+              resize="none"
+              v-model="addForm.remark"
+              :rows="2"
+              placeholder="请详细说明"
+              size="small"
+              :disabled="type === 'dispatch'"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+
+      <header-title title="规则明细" style="margin-top: 20px"> </header-title>
+
+      <el-tabs
+        v-if="addForm.recordTemplateStyle == '4'"
+        v-model="statisticsType"
+        type="card"
+      >
+        <el-tab-pane
+          v-for="i in statisticsTypeList"
+          :label="i.label"
+          :name="i.value"
+          :key="i.value"
+        >
+        </el-tab-pane>
+      </el-tabs>
+
+      <ele-pro-table
+        ref="table"
+        :columns="bankColumns"
+        :datasource="detialsDatasource"
+        :need-page="false"
+        row-key="id"
+        class="table_list"
+        cache-key="workshop-record-plan-details-item-2511201537"
+      >
+        <template v-slot:toolbar>
+          <div style="display: flex; align-items: center; gap: 10px">
+            <el-button
+              type="primary"
+              icon="el-icon-plus"
+              class="ele-btn-icon"
+              @click="addRow()"
+            >
+              新建
+            </el-button>
+          </div>
+        </template>
+
+        <template v-slot:sortNum="{ row }">
+          <el-input-number
+            style="width: 80px"
+            v-model.number="row.sortNum"
+            placeholder="请输入排序"
+            size="mini"
+            type="number"
+            :min="1"
+            controls-position="right"
+          ></el-input-number>
+        </template>
+
+        <template v-slot:paramType="{ row }">
+          <el-select
+            v-model="row.paramType"
+            placeholder="请选择参数类型"
+            size="mini"
+            @change="paramTypeChange(row)"
+          >
+            <el-option label="数值" :value="1" />
+            <el-option label="选择" :value="2" />
+            <el-option label="上下限" :value="3" />
+            <el-option label="规格" :value="4" />
+            <el-option label="时间" :value="5" />
+            <el-option label="范围" :value="6" />
+            <el-option label="文本" :value="7" />
+            <!-- <el-option label="枚举" :value="8" /> -->
+            <el-option label="计算" :value="9" />
+          </el-select>
+        </template>
+
+        <template v-slot:paramValue="{ row }">
+          <!-- 根据参数类型渲染不同的输入组件 -->
+          <el-link
+            v-if="addForm.recordTemplateStyle == '3'"
+            :underline="false"
+            style="cursor: pointer"
+          >
+            <div class="ele-cell">
+              <div @click="selectChooseModalProduct(row)">
+                {{ row.productName ? row.productName : '请选择产品' }}
+              </div>
+              <i
+                v-if="row.tools.length == 0"
+                class="el-icon-arrow-down"
+                @click="selectChooseModalProduct(row)"
+              ></i>
+              <i v-else class="el-icon-close" @click="clearProduct(row)"></i>
+            </div>
+          </el-link>
+          <el-input
+            v-else
+            v-model="row.paramValue"
+            placeholder="请输入参数内容"
+            size="mini"
+            type="textarea"
+            rows="1"
+            autosize
+          ></el-input>
+        </template>
+
+        <template v-slot:formula="{ row }">
+          <div v-if="row.paramType == 9" class="formula-builder">
+            <div class="formula-builder__selects">
+              <!-- 选择参数:从已填的非计算参数内容里取 -->
+              <el-select
+                v-model="row._paramSelect"
+                placeholder="选择参数"
+                size="mini"
+                style="width: 100px; margin-right: 8px; flex-shrink: 0"
+                @change="paramSelectChange($event, row)"
+              >
+                <el-option
+                  v-for="item in getSelectOptionsByDetails(
+                    row.statisticsType,
+                    item
+                  )"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                />
+              </el-select>
+
+              <!-- 选择运算符 -->
+              <el-select
+                v-model="row._opSelect"
+                :key="row._opSelect + '_opSelect'"
+                placeholder="选择符号"
+                size="mini"
+                style="width: 100px; flex-shrink: 0"
+                @change="opSelectChange($event, row)"
+              >
+                <el-option
+                  v-for="op in opSelectOptions"
+                  :key="op"
+                  :label="op"
+                  :value="op"
+                />
+              </el-select>
+
+              <!-- 替换或者追加 -->
+              <el-select
+                v-if="row.activeIndex != undefined"
+                v-model="row._replaceOrAppend"
+                :key="row._replaceOrAppend + 'row._replaceOrAppend'"
+                placeholder="选择"
+                size="mini"
+                style="width: 80px; margin-left: 8px; flex-shrink: 0"
+              >
+                <el-option key="append" label="追加" value="append" />
+                <el-option key="replace" label="替换" value="replace" />
+              </el-select>
+            </div>
+
+            <!-- 已组装公式标签展示 -->
+            <div
+              v-if="row.formulaParts && row.formulaParts.length"
+              style="display: inline-flex; flex-wrap: wrap; max-width: 100%"
+            >
+              <el-tag
+                v-for="(p, index) in row.formulaParts"
+                :key="index"
+                size="mini"
+                closable
+                :type="row.activeIndex === index ? 'primary' : 'info'"
+                @click="formulaPartsTagClick(index, row)"
+                @close="tagItemDelete(index, row)"
+              >
+                {{ p }}
+              </el-tag>
+            </div>
+
+            <!-- 公式字符串展示(只读) -->
+            <el-input
+              v-if="row.formulaParts && row.formulaParts.length"
+              :value="row.formulaParts.join('')"
+              size="mini"
+              type="textarea"
+              disabled
+              placeholder="公式"
+              style="margin-top: 6px"
+            />
+          </div>
+        </template>
+
+        <template v-slot:defaultValue="{ row }">
+          <el-row>
+            <el-col :span="12">
+              <!-- <el-select
+                v-if="row.paramType != 7"
+                v-model="row.symbol"
+                placeholder="请选择"
+                size="mini"
+              >
+                <el-option label=">" value=">"> </el-option>
+                <el-option label="<" value="<"> </el-option>
+                <el-option label="!=" value="!="> </el-option>
+                <el-option label=">=" value=">="> </el-option>
+                <el-option label="<=" value="<="> </el-option>
+                <el-option label="~~" value="~~"> </el-option>
+                <el-option label="+-" value="+-"> </el-option>
+                <el-option label="......" value="......"> </el-option>
+              </el-select> -->
+              <DictSelection
+                v-if="row.paramType != 7"
+                clearable
+                dictName="数学字符"
+                v-model="row.symbol"
+                placeholder="请选择逻辑"
+                size="mini"
+              ></DictSelection>
+            </el-col>
+            <el-col :span="row.paramType != 7 ? 12 : 24">
+              <el-input
+                v-model="row.defaultValue"
+                placeholder="请输入默认值"
+                size="mini"
+              ></el-input>
+            </el-col>
+          </el-row>
+        </template>
+        <template v-slot:maxValue="{ row }">
+          <el-input
+            v-if="row.paramType == 3 || row.paramType == 6"
+            v-model="row.maxValue"
+            placeholder="请输入参数上限"
+            size="mini"
+          ></el-input>
+        </template>
+        <template v-slot:minValue="{ row }">
+          <el-input
+            v-if="row.paramType == 3 || row.paramType == 6"
+            v-model="row.minValue"
+            placeholder="请输入参数下限"
+            size="mini"
+          ></el-input>
+        </template>
+        <template v-slot:unitName="{ row }">
+          <!-- <el-input
+            v-model="row.unitName"
+            placeholder="请输入参数单位"
+            size="mini"
+          ></el-input> -->
+          <DictSelection
+            v-if="row.paramType != 7"
+            dictName="工艺参数单位"
+            clearable
+            filterable
+            v-model="row.unitName"
+            size="mini"
+          >
+          </DictSelection>
+        </template>
+        <template v-slot:toolName="{ row }">
+          <el-link :underline="false" style="cursor: pointer">
+            <div class="ele-cell">
+              <div @click="handleAdd(row)">
+                {{
+                  row.tools && row.tools.length > 0
+                    ? row.tools.map((i) => i.toolName).join(',')
+                    : '请选择'
+                }}
+              </div>
+              <i
+                v-if="row.tools.length == 0"
+                class="el-icon-arrow-down"
+                @click="handleAdd(row)"
+              ></i>
+              <i v-else class="el-icon-close" @click="clearTool(row)"></i>
+            </div>
+          </el-link>
+        </template>
+        <template v-slot:toolCodes="{ row }">
+          <el-input
+            :value="
+              row.tools && row.tools.length > 0
+                ? row.tools.map((i) => i.toolCode).join(',')
+                : ''
+            "
+            placeholder="工具自动带出"
+            disabled
+            size="mini"
+          ></el-input>
+        </template>
+        <template v-slot:remark="{ row }">
+          <el-input
+            v-model="row.remark"
+            placeholder="请输入"
+            size="mini"
+          ></el-input>
+        </template>
+
+        <template v-slot:action="{ row }">
+          <el-link
+            v-if="type != 'detail'"
+            type="danger"
+            :underline="false"
+            icon="el-icon-delete"
+            @click="deleteRow(item, row)"
+          >
+            删除
+          </el-link>
+        </template>
+      </ele-pro-table>
+    </el-form>
+
+    <!-- <template v-slot:footer> -->
+    <div class="footer-box">
+      <el-button
+        v-if="type != 'detail'"
+        type="primary"
+        @click="submit"
+        :loading="butLoading"
+        >{{ type == 'dispatch' ? '派单' : '保存' }}</el-button
+      >
+      <!-- <el-button @click="handleClose">取消</el-button> -->
+    </div>
+    <!-- </template> -->
+
+    <selectReleaseRules
+      ref="selectReleaseRulesRef"
+      @chooseRules="chooseRules"
+    ></selectReleaseRules>
+
+    <selectWorkshop
+      ref="selectWorkshopRef"
+      @confirm="confirmWorkshops"
+    ></selectWorkshop>
+
+    <toolModal
+      ref="toolModalTowRef"
+      @chooseModal="chooseModalProduct"
+      :multiple="false"
+    />
+
+    <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
+  </div>
+</template>
+
+<script>
+  import dictMixins from '@/mixins/dictMixins';
+  import tableColumnsMixin from '@/mixins/tableColumnsMixin';
+  import { getUserPage } from '@/api/system/organization';
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import { getCode } from '@/api/ruleManagement/matter';
+  import selectReleaseRules from '@/components/selectReleaseRules/select-release-rules.vue';
+  import selectWorkshop from '@/components/selectWorkshop/selectWorkshop.vue';
+  import {
+    getRecordRulesPlanDetail,
+    recordrulesplanSaveOrUpdate,
+    recordrulesGetById,
+    recordrulesplanManualDispatchOrder
+  } from '@/api/recordRules/index.js';
+  import toolModal from '@/views/batchRecord/components/toolModal.vue';
+  import { getteampage } from '@/api/workforceManagement/team';
+
+  export default {
+    mixins: [dictMixins, tableColumnsMixin],
+    props: {
+      dialogTitle: {
+        type: String,
+        default: () => {
+          return '派单';
+        }
+      },
+      // 计划id
+      planId: {
+        type: String,
+        required: true
+      },
+      // 当前信息
+      info: {
+        type: Object,
+        required: true
+      }
+    },
+    components: {
+      deptSelect,
+      selectReleaseRules,
+      selectWorkshop,
+      toolModal
+    },
+    data() {
+      const formBaseData = {
+        address: '',
+        areaId: 0,
+        areaName: '',
+        autoOrder: 1,
+        code: '',
+        configCode: '',
+        configType: 1,
+        createUserName: '',
+        details: [],
+        duration: null,
+        executeUser: [],
+        factoryId: null,
+        factoryName: '',
+        id: null,
+        name: '',
+        planEndTime: '',
+        planStartTime: '',
+        remark: '',
+        ruleId: null,
+        ruleName: '',
+        status: 0,
+        type: 0,
+        updateUserName: '',
+        urgent: '1',
+        workshopCode: '',
+        workshopId: null,
+        workshopName: '',
+        workshopPlanId: null,
+        workshopPlanName: '',
+        recordRulesClassify: null,
+        recordTemplateStyle: null,
+        reportWorkType: null,
+        executeIdList: [],
+        groupId: '', // 部门id
+        teamId: '' // 班组id
+      };
+
+      return {
+        visible: false,
+        title: '新增记录计划配置',
+        activeIndex: 0,
+        formBaseData,
+        addForm: JSON.parse(JSON.stringify(formBaseData)),
+        rules: {
+          name: [
+            { required: true, message: '请输入计划配置名称', trigger: 'blur' }
+          ],
+          autoOrder: [
+            { required: true, message: '请选择是否自动派单', trigger: 'change' }
+          ],
+          ruleId: [
+            { required: true, message: '请选择规则名称', trigger: 'change' }
+          ],
+          duration: [
+            { required: true, message: '请输入计划完成时长', trigger: 'blur' }
+          ],
+          categoryLevelId: [
+            { required: true, message: '请选择设备分类', trigger: 'change' }
+          ],
+          categoryId: [
+            { required: true, message: '请选择设备类别', trigger: 'change' }
+          ],
+          groupId: [
+            { required: true, message: '请选择部门', trigger: 'change' }
+          ],
+          teamId: [
+            { required: true, message: '请选择班组', trigger: 'change' }
+          ],
+          executeIdList: [
+            { required: true, message: '请选择人员', trigger: 'change' }
+          ],
+          urgent: [
+            { required: true, message: '请选择紧急程度', trigger: 'change' }
+          ],
+          ruleName: [
+            { required: true, message: '请选择规则名称', trigger: 'change' }
+          ],
+          workshopPlanName: [
+            { required: true, message: '请选择车间区域', trigger: 'change' }
+          ]
+        },
+        executorList: [],
+        uerList: [],
+        // 执行方式列表
+        executeMethodList: [],
+        // 1-成品统计,2-物料统计,3-工序统计"
+        statisticsType: '1',
+        statisticsTypeList: [
+          { label: '成品统计', value: '1' },
+          { label: '物料统计', value: '2' },
+          { label: '工序统计', value: '3' }
+        ],
+        opSelectOptions: ['+', '-', '*', '/', '%', '(', ')'],
+        butLoading: false,
+        teamAllList: [],
+        loading: false,
+        type: 'add', // 弹窗类型 add-新增 edit-编辑 detail-查看
+      };
+    },
+    computed: {
+      // 当前用户信息
+      loginUser() {
+        return this.$store.state.user?.info;
+      },
+      workshopsColumns() {
+        return [
+          {
+            width: 45,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center'
+          },
+          {
+            prop: 'workshopCode',
+            label: '车间编码'
+          },
+          {
+            label: '车间名称',
+            prop: 'workshopName'
+          },
+          {
+            label: '所属工厂',
+            prop: 'factoryName'
+          },
+          {
+            label: '所属厂房',
+            prop: 'workshopPlanName',
+            slot: 'factory'
+          },
+          {
+            label: '所属区域',
+            prop: 'areaName'
+          },
+          {
+            label: '详细地址',
+            prop: 'address'
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 110,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            fixed: 'right'
+          }
+        ];
+      },
+      bankColumns() {
+        const list = [
+          {
+            width: 110,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center',
+            label: '序号'
+          },
+          {
+            prop: 'sortNum',
+            label: '排序',
+            align: 'center',
+            slot: 'sortNum',
+            minWidth: 110
+          },
+          {
+            prop: 'paramType',
+            label: '参数类型',
+            align: 'center',
+            slot: 'paramType',
+            minWidth: 110
+          },
+          {
+            prop: 'paramValue',
+            label: '参数内容',
+            align: 'center',
+            slot: 'paramValue',
+            minWidth: 261
+          },
+          {
+            prop: 'formula',
+            label: '计算公式',
+            align: 'center',
+            slot: 'formula',
+            minWidth: 300
+          },
+          {
+            prop: 'defaultValue',
+            label: '默认值',
+            align: 'center',
+            slot: 'defaultValue',
+            minWidth: 150
+          },
+          {
+            prop: 'maxValue',
+            label: '参数上限',
+            align: 'center',
+            slot: 'maxValue',
+            minWidth: 110
+          },
+          {
+            prop: 'minValue',
+            label: '参数下限',
+            align: 'center',
+            slot: 'minValue',
+            minWidth: 110
+          },
+          {
+            prop: 'unitName',
+            label: '参数单位',
+            align: 'center',
+            slot: 'unitName',
+            minWidth: 110
+          },
+          {
+            prop: 'toolName',
+            label: '工具名称',
+            align: 'center',
+            slot: 'toolName',
+            minWidth: 110
+          },
+          {
+            prop: 'toolCodes',
+            label: '工具编码',
+            align: 'center',
+            slot: 'toolCodes',
+            minWidth: 110
+          },
+          {
+            prop: 'remark',
+            label: '备注',
+            align: 'center',
+            slot: 'remark',
+            minWidth: 110
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 110,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            fixed: 'right'
+          }
+        ];
+        if (this.addForm.recordTemplateStyle != '4') {
+          // 过滤掉 计算公式 列
+          return list.filter((i) => i.prop != 'formula');
+        }
+        return list;
+      },
+      // 过滤明细数据源
+      detialsDatasource() {
+        // 如果是模板样式4,过滤统计类型
+        if (this.addForm.recordTemplateStyle == '4') {
+          return this.addForm.details.filter(
+            (i) => i.statisticsType == this.statisticsType
+          );
+        }
+        return this.addForm.details;
+      }
+    },
+    created() {
+      // 获取审核人列表、巡点检人员
+      this.getUserList();
+      // 获取所有班组
+      this.getAllTeamList();
+      
+    },
+    mounted() {
+      this.open('dispatch', this.info)
+    },
+    methods: {
+      // 外部调用,打开弹窗
+      open(type, data) {
+        console.log('type data', type, data);
+        this.type = type;
+        if (type == 'add') {
+          this.title = '新增记录计划配置';
+          this.getOrderCode();
+        } else if (type == 'edit') {
+          this.title = '修改记录计划配置';
+          this.getDetail(data.id);
+        } else if (type == 'dispatch') {
+          this.title = '派单';
+          this.getDetail(data.id);
+        } else {
+          this.title = '查看记录计划配置';
+          this.getDetail(data.id);
+        }
+
+        this.visible = true;
+
+        this.$nextTick(() => {
+          this.$refs.formRef && this.$refs.formRef.clearValidate();
+        });
+      },
+      // 查询详情
+      async getDetail(id) {
+        this.loading = true;
+        const data = await getRecordRulesPlanDetail(id);
+        console.log('记录计划配置详情', data);
+        this.$util.assignObject(this.addForm, data);
+        // 处理回显数据
+        if (this.addForm.type === 0) {
+          // 个人
+          this.addForm.executeIdList = this.addForm.executeUser.map(
+            (item) => item.userId
+          );
+          this.addForm.groupId = this.addForm.executeUser[0]?.groupId || '';
+          this.searchDeptNodeClick(this.addForm.groupId);
+        } else {
+          // 班组
+          this.addForm.teamId = this.addForm.executeUser[0]?.teamId || '';
+        }
+
+        // if (this.type === 'dispatch') {
+        //   // 自动派单
+        //   this.addForm.autoOrder = 1;
+        // }
+
+        this.loading = false;
+
+        console.log('this.addForm', this.addForm);
+      },
+      // 关闭时清理表单
+      handleClose() {
+        this.addForm = JSON.parse(JSON.stringify(this.formBaseData));
+        this.$nextTick(() => {
+          this.$refs.formRef.clearValidate();
+          this.visible = false;
+        });
+      },
+      // 构建数据
+      formMateBody() {
+        // 通过校验,构建数据
+        const body = JSON.parse(JSON.stringify(this.addForm));
+
+        return body;
+      },
+      // 提交
+      submit() {
+        console.log('this.addForm', this.addForm);
+        this.$refs.formRef.validate(async (valid) => {
+          if (valid) {
+            this.butLoading = true;
+
+            try {
+              // 赋值创建人和更新人
+              if (this.addForm.id) {
+                this.addForm.updateUserName = this.loginUser?.name || '';
+              } else {
+                this.addForm.createUserName = this.loginUser?.name || '';
+              }
+
+              const body = this.formMateBody();
+
+              console.log('body', body);
+              const workOrderId = ''
+              if (this.type == 'dispatch') {
+                const res = await recordrulesplanManualDispatchOrder(body);
+                workOrderId = res.data || '';
+                this.$message.success('派单成功');
+              } else {
+                await recordrulesplanSaveOrUpdate(body);
+                this.$message.success('保存成功');
+              }
+              this.butLoading = false;
+
+              this.$emit('done', workOrderId);
+
+              this.handleClose();
+            } catch (error) {
+              this.butLoading = false;
+            }
+          }
+        });
+      },
+      // 过滤计划完成时长
+      formDataDurationTime(value) {
+        if (value > 0) {
+          this.addForm.duration = value.replace(/^[0]+/, '');
+        } else {
+          this.addForm.duration = 0;
+        }
+      },
+      typeChange() {
+        this.addForm.groupId = '';
+        this.addForm.executeIdList = [];
+      },
+      //选择部门(搜索)
+      async searchDeptNodeClick(info, data) {
+        if (info) {
+          // 根据部门获取人员
+          const params = { groupId: info };
+          await this.getUserList(params);
+        } else {
+          this.addForm.groupId = null;
+        }
+      },
+      // 获取审核人列表、巡点检人员
+      async getUserList(params) {
+        try {
+          let data = { pageNum: 1, size: -1 };
+          // 如果传了参数就是获取部门人员数据
+          if (params) {
+            data = Object.assign(data, params);
+          }
+          const res = await getUserPage(data);
+          if (params) {
+            this.executorList = res.list;
+          } else {
+            this.uerList = res.list;
+          }
+        } catch (error) {}
+      },
+      // 获取自动生成的单号
+      async getOrderCode() {
+        const data = await getCode('record_rules_plan_code');
+        this.addForm.code = data;
+      },
+      // 选择记录规则
+      handleAddTab() {
+        // 添加tab
+        this.$refs.selectReleaseRulesRef.open(
+          '',
+          '',
+          this.addForm.ruleId ? [this.addForm.ruleId] : []
+        );
+      },
+      async chooseRules(rules) {
+        console.log('选择的规则', rules);
+
+        // 查询规则明细,回显规则明细数据
+        const data = await recordrulesGetById(rules.id);
+
+        // 处理详情的 公式 字段
+        data.details.forEach((item) => {
+          if (item.paramType == 9 && item.formula) {
+            // formula格式为[A][+][b][*][C] 拆分 -> ['A','+','b','*','C']
+            if (item.formula) {
+              const matches = item.formula.match(/\[([^\]]+)\]/g);
+              if (matches) {
+                this.$set(
+                  item,
+                  'formulaParts',
+                  matches.map((m) => m.slice(1, -1)).filter(Boolean)
+                );
+              }
+            } else {
+              this.$set(item, 'formulaParts', []);
+            }
+            this.$set(item, '_paramSelect', null);
+            this.$set(item, '_opSelect', null);
+            this.$set(item, '_replaceOrAppend', '');
+          }
+        });
+
+        console.log('规则明细数据', data.details);
+
+        this.addForm.ruleId = rules.id;
+        this.addForm.ruleName = rules.name;
+        this.addForm.details = data.details;
+        this.addForm.recordRulesClassify = rules.classify;
+        this.addForm.recordTemplateStyle = rules.recordTemplateStyle;
+        this.addForm.reportWorkType = rules.reportWorkType;
+      },
+      // 打开选择车间弹窗
+      openWorkShops() {
+        this.$refs.selectWorkshopRef.open();
+      },
+      confirmWorkshops(info) {
+        console.log('info', info);
+        this.addForm.workshopId = info.workshopId;
+        this.addForm.workshopName = info.workshopName;
+        this.addForm.workshopPlanId = info.workshopPlanId;
+        this.addForm.workshopPlanName = info.workshopPlanName;
+        this.addForm.address = info.extInfo.location;
+        this.addForm.areaId = info.areaId;
+        this.addForm.areaName = info.areaName;
+        this.addForm.factoryId = info.factoryId;
+        this.addForm.factoryName = info.factoryName;
+      },
+      // 添加
+      addRow() {
+        // 最大sortNum 值 +1
+        let sortNum = 1;
+        if (this.addForm.details.length > 0) {
+          const maxSortNum = Math.max(
+            ...this.addForm.details.map((i) => i.sortNum || 0)
+          );
+          sortNum = maxSortNum + 1;
+        }
+
+        this.addForm.details.push({
+          id: new Date().getTime(),
+          defaultValue: '',
+          maxValue: null,
+          minValue: null,
+          paramType: null,
+          paramValue: null,
+          remark: '',
+          symbol: null,
+          tools: [],
+          unitName: null,
+          productName: '',
+          productCode: '',
+          // 1-成品统计,2-物料统计,3-工序统计"
+          statisticsType:
+            this.addForm.recordTemplateStyle == '4' ? this.statisticsType : null,
+          // 公式
+          formula: '',
+          _paramSelect: null,
+          _opSelect: null,
+          _replaceOrAppend: '',
+          formulaParts: [],
+          sortNum
+        });
+        console.log('currentTab item', this.addForm);
+      },
+      // 类型变化
+      paramTypeChange(row) {
+        if (row.pageType != 9) {
+          // 清空
+          row.formulaParts = [];
+          row.formula = '';
+        }
+      },
+      // 选择物品 产品、物料等
+      selectChooseModalProduct(row) {
+        this.currentRow = row;
+        this.$refs.toolModalTowRef.open([], '选择物品');
+      },
+      chooseModalProduct(current) {
+        console.log('current', current);
+        this.currentRow.productName = current.name;
+        this.currentRow.productCode = current.code;
+        this.currentRow.unitName = current.weightUnit;
+        console.log('this.currentRow', this.currentRow);
+      },
+      // 清空产品
+      clearProduct(row) {
+        row.productName = '';
+        row.productCode = '';
+      },
+      // 基于详情返回selectOptions
+      getSelectOptionsByDetails(statisticsType, item) {
+        let paramTypeOptions = [];
+        for (const detail of item.details.filter(
+          (i) => i.statisticsType == statisticsType
+        )) {
+          if (detail.paramType != 9 || !detail.paramType) {
+            paramTypeOptions.push({
+              value: detail.paramValue,
+              label: detail.paramValue
+            });
+          }
+        }
+        // 过滤空值
+        paramTypeOptions = paramTypeOptions.filter((i) => i.value);
+        // 追加一个 (要求生产数量)
+        paramTypeOptions.push({
+          value: '要求生产数量',
+          label: '要求生产数量'
+        });
+        return paramTypeOptions;
+      },
+      paramSelectChange(val, row) {
+        if (!val) return;
+        row.formulaParts = row.formulaParts || [];
+        if (row.activeIndex != undefined) {
+          if (!row._replaceOrAppend || row._replaceOrAppend === 'replace') {
+            row.formulaParts.splice(row.activeIndex, 1, val);
+          } else if (row._replaceOrAppend === 'append') {
+            row.formulaParts.splice(row.activeIndex + 1, 0, val);
+            // 追加后activeIndex后移一位
+            this.$set(row, 'activeIndex', row.activeIndex + 1);
+          }
+          // row.activeIndex = undefined;
+        } else {
+          row.formulaParts.push(val);
+        }
+        row.formula = row.formulaParts.map((p) => `[${p}]`).join('');
+        row._paramSelect = null;
+      },
+      opSelectChange(val, row) {
+        if (!val) return;
+        row.formulaParts = row.formulaParts || [];
+        if (row.activeIndex != undefined) {
+          if (!row._replaceOrAppend || row._replaceOrAppend === 'replace') {
+            row.formulaParts.splice(row.activeIndex, 1, val);
+          } else if (row._replaceOrAppend === 'append') {
+            row.formulaParts.splice(row.activeIndex + 1, 0, val);
+            // 追加后activeIndex后移一位
+            this.$set(row, 'activeIndex', row.activeIndex + 1);
+          }
+          // row.activeIndex = undefined;
+        } else {
+          row.formulaParts.push(val);
+        }
+        row.formula = row.formulaParts.map((p) => `[${p}]`).join('');
+        row._opSelect = null;
+      },
+      tagItemDelete(index, row) {
+        if (this.type == 'detail') return;
+        row.formulaParts.splice(index, 1);
+        row.formula = row.formulaParts.map((p) => `[${p}]`).join('');
+      },
+      formulaPartsTagClick(index, row) {
+        if (this.type == 'detail') return;
+
+        if (!row._replaceOrAppend) {
+          // 默认追加
+          row._replaceOrAppend = 'append';
+        }
+
+        if (row.activeIndex && row.activeIndex === index) {
+          this.$set(row, 'activeIndex', undefined);
+        } else {
+          this.$set(row, 'activeIndex', index);
+        }
+      },
+      handleAdd(row) {
+        this.currentRow = row;
+        this.$refs.toolModalRef.open(row.toolCodes);
+      },
+      chooseModal(data) {
+        console.log('data', data);
+        this.currentRow.tools = data.map((i) => {
+          return {
+            toolCode: i.code,
+            toolName: i.name
+          };
+        });
+      },
+      // 清空工具
+      clearTool(row) {
+        row.tools = [];
+      },
+      deleteRow(time, row) {
+        const index = this.addForm.findIndex((item) => item.id === row.id);
+        if (index !== -1) {
+          this.addForm.splice(index, 1);
+        }
+      },
+      // 负责人变更 同步执行人列表
+      executeIdListChange() {
+        this.addForm.executeUser = this.addForm.executeIdList.map((userId) => {
+          const user = this.executorList.find((u) => u.id === userId);
+          return {
+            userId: user.id,
+            userName: user.name,
+            groupId: user.groupId,
+            groupName: user.groupName
+          };
+        });
+        console.log('this.addForm.executeUser', this.addForm.executeUser);
+      },
+      async getAllTeamList() {
+        const { list } = await getteampage({
+          pageNum: 1,
+          size: -1
+        });
+        console.log('teamAllList 班组', list);
+        this.teamAllList = list;
+      },
+      teamChange() {
+        console.log('this.addForm.teamId', this.addForm.teamId);
+        // 当前班组
+        const currentTeam = this.teamAllList.find(
+          (item) => item.id === this.addForm.teamId
+        );
+        if (currentTeam) {
+          // 同步执行人
+          this.addForm.executeUser = [
+            {
+              teamId: currentTeam.id,
+              teamName: currentTeam.name
+            }
+          ];
+        }
+      }
+    }
+  };
+</script>
+
+<style scoped lang="scss">
+  :deep(.el-form) {
+    .el-form-item:last-child {
+      margin-bottom: 22px !important;
+    }
+  }
+
+  ::v-deep .el-row {
+    display: flex;
+    flex-wrap: wrap;
+  }
+
+  .mask-box {
+    position: relative;
+
+    &::after {
+      content: '';
+      width: 100%;
+      height: 100%;
+      position: absolute;
+      top: 0;
+      left: 0;
+      background: rgba(0, 0, 0, 0);
+      cursor: pointer;
+    }
+  }
+
+  .footer-box {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    gap: 15px;
+    margin-top: 20px;
+  }
+</style>

+ 1067 - 0
src/views/produce/components/prenatalExamination/components/workOrder/workOrderEvent.vue

@@ -0,0 +1,1067 @@
+<template>
+  <div>
+    <header-title title="基本信息"></header-title>
+    <el-form
+      ref="formRef"
+      :model="addForm"
+      :rules="rules"
+      label-width="120px"
+      v-loading="loading"
+      :disabled="type == 'detail'"
+    >
+      <el-row>
+        <el-col :span="8">
+          <el-form-item label="记录规则名称" required>
+            <el-input
+              v-model="addForm.ruleName"
+              placeholder="自动带出"
+              disabled
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="记录规则分类" required>
+            <DictSelection
+              dictName="记录规则类型"
+              clearable
+              v-model="addForm.recordRulesClassify"
+              disabled
+            >
+            </DictSelection>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="检查开始时间" required prop="checkStartTime">
+            <el-date-picker
+              v-model="addForm.checkStartTime"
+              type="datetime"
+              format="yyyy-MM-dd HH:mm:ss"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              placeholder="选择日期"
+              style="width: 100%"
+              :picker-options="{
+                disabledDate: (time) => time.getTime() > Date.now()
+              }"
+              @change="computedDuration"
+            >
+            </el-date-picker>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="检查结束时间" required prop="checkFinishTime">
+            <el-date-picker
+              v-model="addForm.checkFinishTime"
+              type="datetime"
+              format="yyyy-MM-dd HH:mm:ss"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              placeholder="选择日期"
+              style="width: 100%"
+              :picker-options="{
+                disabledDate: (time) => time.getTime() > Date.now()
+              }"
+              @change="computedDuration"
+            >
+            </el-date-picker>
+          </el-form-item>
+        </el-col>
+        <el-col v-if="!addForm.planExecuteType" :span="8">
+          <el-form-item label="部门">
+            <deptSelect
+              v-model="addForm.groupId"
+              @changeGroup="searchDeptNodeClick"
+            />
+          </el-form-item>
+        </el-col>
+
+        <el-col v-if="!addForm.planExecuteType" :span="8">
+          <el-form-item label="指定负责人" prop="executeUsersIds">
+            <el-select
+              v-model="addForm.executeUsersIds"
+              size="small"
+              style="width: 100%"
+              multiple
+              filterable
+              @change="executeIdListChange"
+            >
+              <el-option
+                v-for="item in executorList"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col v-if="addForm.planExecuteType" :span="8">
+          <!-- <el-form-item label="班组" prop="teamId">
+            <el-select
+              v-model="addForm.teamId"
+              size="small"
+              @change="teamChange"
+              style="width: 100%"
+            >
+              <el-option
+                :value="i.id"
+                :label="i.name"
+                v-for="i in allTeamList"
+                :key="i.id"
+              ></el-option>
+            </el-select>
+          </el-form-item> -->
+          <el-form-item label="执行人" required prop="teamId">
+            <el-select
+              v-model="addForm.teamId"
+              placeholder="请选择班组"
+              filterable
+              style="width: 120px"
+              @change="checkTeamList(addForm.teamId)"
+              disabled
+            >
+              <el-option
+                v-for="item in allTeamList"
+                :label="item.name"
+                :value="item.id"
+                :key="item.id"
+              >
+              </el-option>
+            </el-select>
+            <el-select
+              v-model="addForm.executeUsersIds"
+              placeholder="请选择执行人"
+              filterable
+              multiple
+              @change="changeId"
+            >
+              <div class="checkboxWrapper">
+                <el-checkbox v-model="checked" @change="checkChange">
+                  全选
+                </el-checkbox>
+              </div>
+              <el-option
+                v-for="item in teamUserList"
+                :label="item.name"
+                :value="item.id"
+                :key="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="工时" required prop="duration">
+            <el-input
+              placeholder="请输入"
+              v-model="addForm.duration"
+              type="number"
+              min="0"
+              step="0.1"
+              @change="durationChagne"
+            >
+              <template slot="append">
+                <div style="width: 40px; box-sizing: border-box">小时</div>
+              </template>
+            </el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="结论" required prop="conclusion">
+            <el-radio-group v-model="addForm.conclusion">
+              <el-radio :label="1">合格</el-radio>
+              <el-radio :label="2">不合格</el-radio>
+            </el-radio-group>
+          </el-form-item>
+        </el-col>
+      </el-row>
+
+      <header-title title="检查项目" :style="`margin-top: 20px`"></header-title>
+
+      <template v-if="addForm.recordTemplateStyle == '4'">
+        <el-tabs v-model="statisticsType" type="card">
+          <el-tab-pane
+            v-for="i in statisticsTypeList"
+            :label="i.label"
+            :name="i.value"
+            :key="i.value"
+          >
+          </el-tab-pane>
+        </el-tabs>
+        <statistics
+          ref="statisticsRef"
+          :details.sync="addForm.details"
+          :statisticsType="statisticsType"
+          :produceTaskId="addForm.produceTaskId"
+          :workOrderId="addForm.workOrderId"
+          :routingId="addForm.produceRoutingId"
+          :ruleId="addForm.ruleId"
+        ></statistics>
+      </template>
+
+      <ele-pro-table
+        v-if="addForm.recordTemplateStyle != '4'"
+        v-loading="loading"
+        ref="table"
+        row-key="id"
+        :columns="detailsColumns"
+        :datasource="addForm.details"
+        cacheKey="mes-releaseRulesDialong-2510281408"
+        :needPage="false"
+      >
+        <template v-slot:toolkit>
+          <el-button
+            v-if="addForm.recordTemplateStyle != '3'"
+            type="primary"
+            @click="batchCheck"
+            >批量检查</el-button
+          >
+          <el-button
+            v-if="addForm.recordTemplateStyle != '3'"
+            type="primary"
+            @click="batchQualified"
+            >批量合格</el-button
+          >
+        </template>
+        <template v-slot:paramValue="{ row }">
+          <div v-if="addForm.recordTemplateStyle == '3'">
+            {{ row.productName }}
+          </div>
+          <div v-else>
+            {{ row.paramValue }}
+            <span v-if="row.paramValue">{{ row.paramValue }}</span>
+            <!-- 兼容一下 模板改造功能 -->
+            <span v-else>
+              {{ row.productName }}
+            </span>
+          </div>
+        </template>
+        <template v-slot:toolNames="{ row }">
+          <el-link :underline="false" style="cursor: pointer">
+            <div class="ele-cell">
+              <div @click="handleAdd(row)">
+                {{ row.toolNames ? row.toolNames : '请选择' }}
+              </div>
+              <i
+                v-if="!row.toolNames"
+                class="el-icon-arrow-down"
+                @click="handleAdd(row)"
+              ></i>
+              <i v-else class="el-icon-close" @click="clearTool(row)"></i>
+            </div>
+          </el-link>
+        </template>
+        <template v-slot:checkUsersIds="{ row }">
+          <div>
+            <el-select
+              v-model="row.checkUsersIds"
+              placeholder="请选择检查人"
+              filterable
+              multiple
+              @change="checkUsersIdsChange(row)"
+            >
+              <el-option
+                v-for="item in addForm.executeUsers"
+                :label="item.userName"
+                :value="item.userId"
+                :key="item.userId"
+              >
+              </el-option>
+            </el-select>
+          </div>
+        </template>
+        <template v-slot:checkStatus="{ row }">
+          <div>
+            <el-radio-group v-model="row.checkStatus">
+              <el-radio :label="1">已检查</el-radio>
+              <el-radio :label="0">未检查</el-radio>
+            </el-radio-group>
+          </div>
+        </template>
+        <template v-slot:errorMsg="{ row }">
+          <div>
+            <el-input
+              type="text"
+              :rows="1"
+              placeholder="请输入"
+              v-model="row.errorMsg"
+            >
+              <template v-if="row.unitName" slot="append">
+                <div>{{ row.unitName }}</div>
+              </template>
+            </el-input>
+          </div></template
+        >
+        <template v-slot:checkResult="{ row }">
+          <div>
+            <el-radio-group v-model="row.checkResult">
+              <el-radio :label="1">合格</el-radio>
+              <el-radio :label="0">不合格</el-radio>
+            </el-radio-group>
+          </div>
+        </template>
+      </ele-pro-table>
+    </el-form>
+
+    <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
+    <!-- <template v-slot:footer> -->
+    <div class="footer-box">
+      <el-button
+        v-if="type == 'add'"
+        type="primary"
+        @click="submit"
+        :loading="butLoading"
+        >报 工</el-button
+      >
+    </div>
+      <!-- <el-button @click="handleClose">取 消</el-button> -->
+    <!-- </template> -->
+  </div>
+</template>
+
+<script>
+  import dictMixins from '@/mixins/dictMixins';
+  import { getById } from '@/api/producetaskrecordrulesrecord/index';
+  import { getTeam } from '@/api/produce/job.js';
+  import toolModal from '@/views/batchRecord/components/toolModal.vue';
+  import { producetaskrulerecordSaveOrUpdateAndSubmit } from '@/api/recordRules/index.js';
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import { getUserPage } from '@/api/system/organization';
+  import { getteampage } from '@/api/workforceManagement/team';
+
+  export default {
+    mixins: [dictMixins],
+    props: {
+      workOrderId: {
+        type: [Number, String],
+        required: true
+      }
+    },
+    components: {
+      toolModal,
+      deptSelect
+    },
+    watch: {
+      workOrderId: {
+        handler(newVal) {
+          if (newVal) {
+            console.log('workOrderId~~~~~~~~~~~', newVal);
+            this.getOrderDetials();
+          }
+        },
+        deep: true,
+        immediate: true
+      },
+      'addForm.details': {
+        handler(details) {
+          // 排除 物料添加 和 生产统计 模板
+          if (
+            this.addForm.recordTemplateStyle == '4' ||
+            this.addForm.recordTemplateStyle == '3'
+          )
+            return;
+          const any = details.some((i) => i.checkResult === null);
+
+          if (any || details.length === 0) return;
+
+          const every = details.every((i) => i.checkResult == 1);
+          this.addForm.conclusion = every ? 1 : 2;
+          console.log('this.addForm.conclusion', this.addForm.conclusion);
+        },
+        deep: true
+      }
+    },
+    data() {
+      const formBaseData = {
+        id: null,
+        workshopArea: '',
+        workshopAreaId: null,
+        checkFinishTime: '',
+        checkStartTime: '',
+        checkValidity: null,
+        checkValidityUnit: '',
+        conclusion: null,
+        isTempRecord: this.isTempRecord,
+        details: [],
+        deviceId: 0,
+        deviceName: '',
+        batchNo: '',
+        executeMethod: 0,
+        formingNum: 0,
+        itemType: 0,
+        produceRoutingId: 0,
+        produceRoutingName: '',
+        produceTaskConfigId: 0,
+        produceTaskId: 0,
+        produceTaskName: '',
+        productCode: '',
+        productModel: '',
+        productName: '',
+        recordRulesClassify: null,
+        recordTemplateStyle: null,
+        ruleId: 0,
+        ruleName: '',
+        reportWorkType: 0,
+        specification: '',
+        workOrderCode: '',
+        workOrderId: 0,
+        itemTaskName: '',
+        brandNo: '',
+        duration: null,
+        // 执行人
+        executeUsersIds: [],
+        executeUsers: [],
+        // 班组id
+        teamId: '',
+        groupId: null,
+        // 物料字段name
+        pickDetails: [],
+        // 本次产出明细
+        outputDetails: [],
+        recordRulesExecuteMethodId: null,
+        recordRulesExecuteMethodName: '',
+        // 	产出类型 1-原材料,2-在制品,3.BOM标准产出
+        outputType: 1,
+        planExecuteType: 0
+      };
+
+      return {
+        visible: false,
+        activeIndex: 0,
+        type: 'add',
+        title: '报工',
+        formBaseData,
+        addForm: JSON.parse(JSON.stringify(formBaseData)),
+        rules: {
+          checkStartTime: [
+            { required: true, message: '请选择检查开始时间', trigger: 'blur' },
+            {
+              required: true,
+              message: '请选择检查开始时间',
+              trigger: 'change'
+            },
+            {
+              validator: (rule, value, callback) => {
+                if (!value) return callback();
+                const start = new Date(value).getTime();
+                const now = Date.now();
+                if (start > now) {
+                  callback(new Error('开始时间不能超过当前时间'));
+                } else {
+                  callback();
+                }
+              },
+              trigger: 'blur'
+            }
+          ],
+          checkFinishTime: [
+            { required: true, message: '请选择检查完成时间', trigger: 'blur' },
+            {
+              required: true,
+              message: '请选择检查完成时间',
+              trigger: 'change'
+            },
+            {
+              validator: (rule, value, callback) => {
+                if (!value) return callback();
+                const start = new Date(this.addForm.checkStartTime).getTime();
+                const finish = new Date(value).getTime();
+                const now = Date.now();
+                if (finish <= start) {
+                  callback(new Error('结束时间必须大于开始时间'));
+                } else if (finish > now) {
+                  callback(new Error('结束时间不能超过当前时间'));
+                } else {
+                  callback();
+                }
+              },
+              trigger: 'blur'
+            }
+          ],
+          conclusion: [
+            { required: true, message: '请选择结论', trigger: 'blur' },
+            { required: true, message: '请选择结论', trigger: 'change' }
+          ],
+          duration: [
+            { required: true, message: '请输入工时', trigger: 'blur' },
+            { required: true, message: '请输入工时', trigger: 'change' },
+            {
+              validator: (rule, value, callback) => {
+                if (value === '' || value === null) {
+                  callback();
+                } else if (Number(value) <= 0) {
+                  callback(new Error('工时必须大于0'));
+                } else {
+                  callback();
+                }
+              },
+              trigger: 'blur'
+            }
+          ],
+          teamId: [
+            { required: true, message: '请选择班组', trigger: 'blur' },
+            { required: true, message: '请选择班组', trigger: 'change' }
+          ]
+        },
+        loading: false,
+        currentRow: null,
+        butLoading: false,
+        checked: false,
+        teamUserList: [],
+        teamList: [],
+        teamAllList: [],
+        workshopAreaList: [],
+        // 1-成品统计,2-物料统计,3-工序统计"
+        statisticsType: '1',
+        statisticsTypeList: [
+          { label: '成品统计', value: '1' },
+          { label: '物料统计', value: '2' },
+          { label: '工序统计', value: '3' }
+        ],
+        executorList: [],
+        allTeamList: [],
+        recordsList: []
+      };
+    },
+    computed: {
+      // title() {
+      //   if (this.addForm.recordRulesClassify) {
+      //     const dictValue = this.getDictValue(
+      //       '记录规则类型',
+      //       this.addForm.recordRulesClassify
+      //     );
+      //     return dictValue + '记录表';
+      //   }
+      //   return '记录表';
+      // },
+      activeTeamUserList() {
+        return this.teamUserList.filter((user) =>
+          this.addForm.executeUsersIds.includes(user.id)
+        );
+      },
+      // 规则详情表头
+      detailsColumns() {
+        let list = [
+          {
+            width: 45,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center'
+          },
+          {
+            label: '检查内容',
+            prop: 'paramValue',
+            minWidth: 120,
+            slot: 'paramValue'
+          }
+        ];
+
+        if (this.addForm.recordTemplateStyle != '3') {
+          list = [
+            ...list,
+            {
+              label: '检查工具',
+              prop: 'toolNames',
+              minWidth: 120,
+              slot: 'toolNames'
+            },
+            {
+              label: '检查人',
+              prop: 'checkUsersIds',
+              minWidth: 120,
+              slot: 'checkUsersIds'
+            },
+            {
+              label: '检查情况',
+              prop: 'checkStatus',
+              minWidth: 120,
+              slot: 'checkStatus'
+            },
+            {
+              label: '描述',
+              prop: 'errorMsg',
+              minWidth: 120,
+              slot: 'errorMsg'
+            },
+            {
+              label: '检查结果',
+              prop: 'checkResult',
+              minWidth: 120,
+              slot: 'checkResult'
+            }
+          ];
+        } else {
+          list.push({
+            label: '描述',
+            prop: 'errorMsg',
+            minWidth: 120,
+            slot: 'errorMsg'
+          });
+        }
+        return list;
+      }
+    },
+    created() {
+      if (localStorage.getItem('singleUserInfo') == '1') {
+        const data = JSON.parse(localStorage.getItem('chooseUserInfo'));
+        this.getTeamList(data.teamId);
+      } else {
+        this.getTeamList(this.$store.state.user.info.teamId);
+      }
+      // 获取审核人列表、巡点检人员
+      this.getUserList();
+      this.getAllTeamList();
+    },
+    methods: {
+      // 外部调用,打开弹窗
+      open(type = 'add', data) {
+        this.type = type;
+        console.log('data', data);
+        if (type == 'add') {
+          this.title = '报工';
+        } else {
+          this.title = '详情';
+        }
+        this.getOrderDetials(data.id);
+        this.visible = true;
+      },
+      // 获取工单详情
+      async getOrderDetials() {
+        this.loading = true;
+        try {
+          const data = await getById(this.workOrderId);
+          const type = ''
+          if(data.executeStatus == 0 || data.executeStatus == 1) {
+            this.type = 'add';
+          } else {
+            this.type = 'detail';
+          }
+          console.log('data', data);
+          data.details = data.details.map((i) => {
+            i.toolNames = i.tools.map((j) => j.toolName).join(',');
+            i.checkUsersIds = i.checkUsers.map((j) => j.userId);
+            if (i.checkUsersIds.length == 0 && data.executeUsers.length > 0) {
+              // 默认执行人作为检查人
+              i.checkUsersIds = data.executeUsers
+                .filter((i) => i.userId)
+                .map((j) => j.userId);
+              i.checkUsers = data.executeUsers
+                .filter((i) => i.userId)
+                .map((j) => {
+                  return {
+                    teamId: j.teamId,
+                    teamName: j.teamName,
+                    userId: j.userId,
+                    userName: j.userName
+                  };
+                });
+            }
+            return i;
+          });
+          this.$util.assignObject(this.addForm, data);
+          console.log('this.addForm', this.addForm);
+
+          // 处理数据
+          this.addForm.executeUsersIds = this.addForm.executeUsers
+            .map((i) => i.userId)
+            .filter((i) => i); // 过滤掉 undefined
+
+          this.addForm.teamId =
+            this.addForm.executeUsers.length > 0
+              ? this.addForm.executeUsers[0].teamId
+              : '';
+
+          if (
+            this.addForm.executeUsers.length > 0 &&
+            !this.addForm.planExecuteType
+          ) {
+            let groupIds = this.addForm.executeUsers
+              .map((i) => i.groupId)
+              .filter(
+                (item, index, arr) => arr.indexOf(item) === index && item
+              );
+
+            if (groupIds.includes('1')) {
+              this.addForm.groupId = '1';
+            } else {
+              this.addForm.groupId =
+                this.addForm.executeUsers[0]?.groupId + '' || '1';
+            }
+
+            if (this.addForm.groupId) {
+              this.searchDeptNodeClick(this.addForm.groupId);
+            }
+          }
+
+          if (!this.addForm.teamId && this.teamList.length > 0) {
+            this.addForm.teamId = this.teamList[0].id;
+          }
+
+          // 工时毫秒转小时
+          this.addForm.duration = (
+            this.addForm.duration /
+            (1000 * 60 * 60)
+          ).toFixed(2);
+
+          this.addForm.recordRulesClassify += '';
+
+          // 加载班组人员列表
+          if (this.addForm.teamId) {
+            const index = this.teamList.findIndex(
+              (item) => item.id == this.addForm.teamId
+            );
+            this.teamUserList = this.teamAllList[index];
+            console.log('this.teamUserList', this.teamUserList);
+          }
+
+          this.$nextTick(() => {
+            this.$refs.formRef.clearValidate();
+
+            this.loading = false;
+          });
+        } catch (error) {
+          this.loading = false;
+        }
+      },
+      // 关闭时清理表单
+      handleClose() {
+        this.addForm = JSON.parse(JSON.stringify(this.formBaseData));
+        this.$nextTick(() => {
+          this.$refs.formRef.clearValidate();
+          this.visible = false;
+        });
+      },
+      // 提交
+      submit() {
+        this.$refs.formRef.validate(async (valid) => {
+          if (valid) {
+            console.log('this.addForm', this.addForm);
+            // this.handleClose();
+            if (this.addForm.executeUsersIds.length == 0) {
+              this.$message.warning('请选择执行人!');
+              return;
+            }
+
+            // 报工需要验证 缓存不验证 排除 recordTemplateStyle ==3 物料添加 == 4生产统计 模板
+            if (
+              this.addForm.recordTemplateStyle != '3' &&
+              this.addForm.recordTemplateStyle != '4'
+            ) {
+              // 验证检查项目
+              const detailRequired = this.addForm.details.some((i) => {
+                return (
+                  i.checkResult == null ||
+                  !i.checkStatus ||
+                  i.checkUsers?.length == 0
+                );
+              });
+
+              if (detailRequired) {
+                return this.$message.warning(
+                  '请先完善 检查人、检查情况、检查结果 内容!'
+                );
+              }
+            }
+
+            const body = JSON.parse(JSON.stringify(this.addForm));
+
+            // 工时小时转毫秒
+            body.duration = Number(body.duration);
+            body.duration = body.duration * 60 * 60 * 1000;
+
+            this.butLoading = true;
+
+            try {
+              await producetaskrulerecordSaveOrUpdateAndSubmit(body);
+              this.$message.success('报工成功!');
+              this.getOrderDetials();
+              this.butLoading = false;
+              // this.$emit('refresh');
+              // this.handleClose();
+            } catch (error) {
+              this.butLoading = false;
+            }
+          }
+        });
+      },
+      // 选择工具
+      handleAdd(row) {
+        this.currentRow = row;
+        this.$refs.toolModalRef.open(row.tools.map((i) => i.toolCode));
+      },
+      chooseModal(data) {
+        console.log('data', data);
+        this.currentRow.tools = data.map((i) => {
+          return {
+            toolCode: i.code,
+            toolName: i.name
+          };
+        });
+        this.currentRow.toolNames = this.currentRow.tools
+          .map((i) => i.toolName)
+          .join(',');
+      },
+      clearTool(row) {
+        row.tools = [];
+        row.toolNames = '';
+      },
+      checkTeamList(id) {
+        const index = this.teamList.findIndex((item) => item.id == id);
+        this.teamUserList = this.teamAllList[index];
+        console.log('this.teamUserList', this.teamUserList);
+      },
+      async getTeamList(id) {
+        if (!id) return;
+        const ids = id.split(',');
+        this.teamList = [];
+        this.teamUserList = [];
+        const list = ids.map((item) => getTeam(item));
+
+        const dataList = await Promise.all(list);
+
+        dataList.forEach((item) => {
+          this.teamList.push({
+            name: item.name,
+            id: item.id
+          });
+
+          this.teamAllList.push(item.userVOList);
+        });
+      },
+      changeId() {
+        if (this.addForm.executeUsersIds.length == this.teamUserList.length) {
+          this.checked = true;
+        } else {
+          this.checked = false;
+        }
+
+        const deleteUserIds = this.addForm.executeUsers
+          .map((i) => i.userId)
+          .filter((id) => !this.addForm.executeUsersIds.includes(id));
+
+        const addUserIds = this.addForm.executeUsersIds.filter(
+          (id) => !this.addForm.executeUsers.map((i) => i.userId).includes(id)
+        );
+
+        // 删除 用户
+        if (deleteUserIds.length > 0) {
+          this.addForm.executeUsers = this.addForm.executeUsers.filter(
+            (item) => !deleteUserIds.includes(item.userId)
+          );
+        }
+
+        // 添加 用户
+        addUserIds.forEach((id) => {
+          const user = this.teamUserList.find((item) => item.id === id);
+          if (user) {
+            this.addForm.executeUsers.push({
+              teamId: this.addForm.teamId,
+              teamName: this.teamList.find(
+                (team) => team.id == this.addForm.teamId
+              )?.name,
+              userId: user.id,
+              userName: user.name
+            });
+          }
+        });
+
+        console.log('this.addForm.executeUsers', this.addForm.executeUsers);
+
+        this.computedDuration();
+
+        // 同步详情执行人
+        this.addForm.details.forEach((detail) => {
+          detail.checkUsersIds = this.addForm.executeUsersIds;
+          detail.checkUsers = this.addForm.executeUsers;
+        });
+      },
+      checkChange() {
+        this.addForm.executeUsersIds = [];
+        if (this.checked) {
+          this.addForm.executeUsersIds = this.teamUserList.map(
+            (item) => item.id
+          );
+        } else {
+          this.addForm.executeUsersIds = [];
+        }
+      },
+      // 计算工时
+      computedDuration() {
+        if (
+          this.addForm.checkStartTime &&
+          this.addForm.checkFinishTime &&
+          this.addForm.executeUsersIds.length > 0
+        ) {
+          const start = new Date(this.addForm.checkStartTime);
+          const finish = new Date(this.addForm.checkFinishTime);
+          const diff = finish - start; // 毫秒差值
+          const hours = diff / (1000 * 60 * 60); // 转换为小时
+          const totalDuration = hours * this.addForm.executeUsersIds.length;
+          this.addForm.duration = totalDuration.toFixed(1);
+        }
+      },
+      durationChagne() {
+        // 保留小数后一位
+        if (
+          this.addForm.duration &&
+          this.addForm.duration.toString().includes('.')
+        ) {
+          this.addForm.duration = Number(this.addForm.duration).toFixed(1);
+        }
+      },
+      checkUsersIdsChange(row) {
+        // 同步 checkUsers
+        row.checkUsers = row.checkUsersIds.map((i) => {
+          const user = this.addForm.executeUsers.find(
+            (item) => item.userId === i
+          );
+          return user;
+        });
+
+        console.log('row', row);
+      },
+      // 查询车间区域
+      async getWorkshopArea() {
+        const data = await getFactoryarea({
+          pageNum: 1,
+          size: 999,
+          type: 3
+        });
+        console.log('list', data.list);
+        this.workshopAreaList = data.list;
+      },
+      workshopAreaIdChange(e) {
+        const area = this.workshopAreaList.find((i) => i.id === e);
+        if (area) {
+          this.addForm.workshopArea = area.name;
+        } else {
+          this.addForm.workshopArea = '';
+        }
+      },
+      // 批量检查
+      batchCheck() {
+        this.addForm.details = this.addForm.details.map((i) => {
+          i.checkStatus = 1;
+          return i;
+        });
+      },
+      // 批量合格
+      batchQualified() {
+        this.addForm.details = this.addForm.details.map((i) => {
+          i.checkResult = 1;
+          return i;
+        });
+      },
+      // 获取审核人列表、巡点检人员
+      async getUserList(params) {
+        try {
+          let data = { pageNum: 1, size: -1 };
+          // 如果传了参数就是获取部门人员数据
+          if (params) {
+            data = Object.assign(data, params);
+          }
+          const res = await getUserPage(data);
+          if (params) {
+            this.executorList = res.list;
+          } else {
+            this.uerList = res.list;
+          }
+        } catch (error) {}
+      },
+      //选择部门(搜索)
+      async searchDeptNodeClick(groupId, data) {
+        if (groupId) {
+          // 根据部门获取人员
+          const params = { groupId: groupId };
+          await this.getUserList(params);
+        } else {
+          this.addForm.groupId = null;
+        }
+      },
+      // 负责人变更 同步执行人列表
+      executeIdListChange() {
+        this.addForm.executeUsers = this.addForm.executeUsersIds
+          .map((userId) => {
+            const user = this.executorList.find((u) => u.id === userId);
+            if (!user) return null;
+            return {
+              userId: user.id,
+              userName: user.name,
+              groupId: user.groupId,
+              groupName: user.groupName
+            };
+          })
+          .filter((i) => i);
+        // 同步详情执行人
+        this.addForm.details.forEach((detail) => {
+          detail.checkUsersIds = this.addForm.executeUsersIds;
+          detail.checkUsers = this.addForm.executeUsers;
+        });
+        console.log('this.addForm.executeUsers', this.addForm.executeUsers);
+      },
+      async getAllTeamList() {
+        const { list } = await getteampage({
+          pageNum: 1,
+          size: -1
+        });
+        console.log('teamAllList 班组', list);
+        this.allTeamList = list;
+      },
+      teamChange() {
+        console.log('this.addForm.teamId', this.addForm.teamId);
+        // 当前班组
+        const currentTeam = this.allTeamList.find(
+          (item) => item.id === this.addForm.teamId
+        );
+        if (currentTeam) {
+          // 同步执行人
+          this.addForm.executeUser = [
+            {
+              teamId: currentTeam.id,
+              teamName: currentTeam.name
+            }
+          ];
+        }
+      }
+    }
+  };
+</script>
+
+<style scoped lang="scss">
+  :deep(.el-form) {
+    .el-form-item:last-child {
+      margin-bottom: 22px !important;
+    }
+  }
+
+  ::v-deep .el-row {
+    display: flex;
+    flex-wrap: wrap;
+  }
+
+  .checkboxWrapper {
+    padding: 8px 20px;
+    border-bottom: 1px solid #ccc;
+  }
+
+  ::v-deep .el-select__tags {
+    flex-wrap: nowrap;
+    overflow: auto;
+  }
+
+  /* 输入框最大宽度*/
+  ::v-deep .el-select__tags-text {
+    max-width: 90px;
+  }
+
+  /* 底部滚动条的高度*/
+  ::v-deep .el-select__tags::-webkit-scrollbar {
+    height: 2px !important;
+  }
+
+  .footer-box {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    gap: 15px;
+    margin-top: 20px;
+  }
+</style>

+ 19 - 1
src/views/produce/components/prenatalExamination/index.vue

@@ -69,6 +69,11 @@
       ref="planRulesDialogRef"
       @reload="getData"
     ></PlanRulesDialog>
+    <!-- 事件驱动-->
+    <PlanRulesEventDialog
+      ref="planRulesEventDialogRef"
+      @reload="getData"
+    ></PlanRulesEventDialog>
   </el-dialog>
 </template>
 
@@ -84,6 +89,7 @@
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
   import programRulesDialog from '@/views/batchRecord/components/programRulesDialog.vue';
   import workOrderReport from '@/views/batchRecord/components/workOrderReport.vue';
+  import PlanRulesEventDialog from './PlanRulesEventDialog.vue';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
@@ -92,7 +98,8 @@
       taskDialog,
       PlanRulesDialog,
       programRulesDialog,
-      workOrderReport
+      workOrderReport,
+      PlanRulesEventDialog
     },
     data() {
       return {
@@ -260,6 +267,17 @@
         } else if (item.itemType == 2) {
           // 事件驱动
           if(item.executeMethod == 1) {
+            // planRulesEventDialogRef
+
+            item.plans.forEach(plan => {
+              // 找到records数组中planid与当前plan.id匹配的记录
+              plan.matchedRecords = item.records.filter(record => record.planId == plan.id);
+            });
+            console.log('匹配后的plans数组:', item);
+            this.$refs.planRulesEventDialogRef.open(item);
+
+            return
+
             // 是否有计划
             if(!item.plans || item.plans.length == 0) {
               this.$message.error('未生成记录计划');