Bladeren bron

任务确认添加字段、bug修复

lucw 8 maanden geleden
bovenliggende
commit
65af2d6c16

+ 74 - 66
src/views/batchRecord/components/editModal.vue

@@ -13,7 +13,6 @@
         class="switch"
         v-if="details && details.processInstanceId"
         :maxable="true"
-        style="margin-bottom: 20px"
       >
         <div class="switch_left">
           <ul>
@@ -37,7 +36,7 @@
         label-width="130px"
       >
         <header-title title="事项信息"></header-title>
-        <el-row style="margin-bottom: 20px">
+        <el-row>
           <el-col :span="8">
             <el-form-item label="记录编码">
               <el-input
@@ -124,13 +123,13 @@
 
         <header-title
           title="基本信息"
-          v-if="form.itemType == 2 && reportWorkType != 4"
+          v-if="form.itemType != 1 && reportWorkType != 4"
           style="margin-top: 20px"
         ></header-title>
 
-        <template v-if="form.itemType == 2 && reportWorkType != 4">
-          <el-row style="margin-bottom: 20px">
-            <el-col :span="8">
+        <template v-if="form.itemType != 1 && reportWorkType != 4">
+          <el-row>
+            <el-col v-if="form.itemType == 2" :span="8">
               <el-form-item
                 v-if="form.recordRulesClassify == 3"
                 label="关联设备"
@@ -197,11 +196,13 @@
                 </el-date-picker>
               </el-form-item>
             </el-col>
-          </el-row>
 
-          <el-row style="margin-bottom: 20px">
             <el-col :span="8">
-              <el-form-item label="执行人" required prop="teamId">
+              <el-form-item
+                label="执行人"
+                :required="form.itemType == 2"
+                :prop="form.itemType == 2 ? 'teamId' : ''"
+              >
                 <div style="display: flex">
                   <el-select
                     v-model="form.teamId"
@@ -243,7 +244,11 @@
               </el-form-item>
             </el-col>
             <el-col :span="8">
-              <el-form-item label="工时" required prop="duration">
+              <el-form-item
+                label="工时"
+                :required="form.itemType == 2"
+                :prop="form.itemType == 2 ? 'duration' : ''"
+              >
                 <el-input
                   placeholder="请输入"
                   v-model="form.duration"
@@ -258,7 +263,7 @@
                 </el-input>
               </el-form-item>
             </el-col>
-            <el-col :span="8">
+            <el-col v-if="form.itemType == 2" :span="8">
               <el-form-item label="检查有效期">
                 <el-input
                   placeholder="请输入"
@@ -287,7 +292,7 @@
             </el-col>
           </el-row>
 
-          <el-row style="margin-bottom: 20px">
+          <el-row v-if="form.itemType == 2">
             <el-col v-if="form.recordRulesExecuteMethodName" :span="8">
               <el-form-item label="执行方式">
                 <el-input
@@ -326,27 +331,9 @@
         </template>
 
         <header-title title="关联产品" style="margin-top: 20px"></header-title>
-        <el-row style="margin-bottom: 20px">
+        <el-row>
           <el-col :span="8">
             <el-form-item label="生产工单号" prop="workOrderCode">
-              <!-- <el-select
-                v-model="form.workOrderCode"
-                placeholder="请选择生产工单"
-                style="width: 100%"
-                filterable
-                remote
-                clearable
-                :remote-method="getWorkOrderList"
-                @change="workOrderCodeChange"
-              >
-                <el-option
-                  v-for="item in workOrderList"
-                  :key="item.id"
-                  :label="item.code"
-                  :value="item.code"
-                >
-                </el-option>
-              </el-select> -->
               <el-input
                 v-model="form.workOrderCode"
                 placeholder="请选择生产工单"
@@ -383,7 +370,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        <el-row style="margin-bottom: 20px">
+        <el-row>
           <el-col :span="8">
             <el-form-item
               label="产品编码"
@@ -438,7 +425,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        <el-row style="margin-bottom: 20px">
+        <el-row>
           <el-col :span="8">
             <el-form-item label="规格" prop="specification">
               <el-input
@@ -591,10 +578,10 @@
                 @change="checkUsersIdsChange(row)"
               >
                 <el-option
-                  v-for="item in activeTeamUserList"
-                  :label="item.name"
-                  :value="item.id"
-                  :key="item.id"
+                  v-for="item in form.executeUsers"
+                  :label="item.userName"
+                  :value="item.userId"
+                  :key="item.userId"
                 >
                 </el-option>
               </el-select>
@@ -1570,7 +1557,16 @@
       // 任务确认报工
       async saveRuleRecord() {
         this.butLoading = true;
-        await saveRuleRecord(this.form);
+
+        const body = JSON.parse(JSON.stringify(this.form));
+
+        if (body.duration) {
+          // 工时小时转毫秒
+          body.duration = Number(body.duration);
+          body.duration = body.duration * 60 * 60 * 1000;
+        }
+
+        await saveRuleRecord(body);
         this.$message.success('报工成功!');
         this.butLoading = false;
         // 返回
@@ -1816,7 +1812,6 @@
         }
       },
       checkTeamList(id) {
-        this.form.executeUsersIds = [];
         const index = this.teamList.findIndex((item) => item.id == id);
         this.teamUserList = this.teamAllList[index];
         console.log('this.teamUserList', this.teamUserList);
@@ -1863,25 +1858,35 @@
           this.checked = false;
         }
 
-        // 同步 executeUsers
-        this.form.executeUsers = this.form.executeUsersIds
-          .map((id) => {
-            const user = this.teamUserList.find((item) => item.id === id);
-            console.log('user', user);
-            if (user) {
-              return {
-                teamId: this.form.teamId,
-                teamName: this.teamList.find(
-                  (team) => team.id == this.form.teamId
-                )?.name,
-                userId: user.id,
-                userName: user.name
-              };
-            } else {
-              return null;
-            }
-          })
-          .filter((item) => item !== null);
+        const deleteUserIds = this.form.executeUsers
+          .map((i) => i.userId)
+          .filter((id) => !this.form.executeUsersIds.includes(id));
+
+        const addUserIds = this.form.executeUsersIds.filter(
+          (id) => !this.form.executeUsers.map((i) => i.userId).includes(id)
+        );
+
+        // 删除 用户
+        if (deleteUserIds.length > 0) {
+          this.form.executeUsers = this.form.executeUsers.filter(
+            (item) => !deleteUserIds.includes(item.userId)
+          );
+        }
+
+        // 添加 用户
+        addUserIds.forEach((id) => {
+          const user = this.teamUserList.find((item) => item.id === id);
+          if (user) {
+            this.form.executeUsers.push({
+              teamId: this.form.teamId,
+              teamName: this.teamList.find(
+                (team) => team.id == this.form.teamId
+              )?.name,
+              userId: user.id,
+              userName: user.name
+            });
+          }
+        });
 
         console.log('this.form.executeUsers', this.form.executeUsers);
 
@@ -1910,14 +1915,8 @@
       checkUsersIdsChange(row) {
         // 同步 checkUsers
         row.checkUsers = row.checkUsersIds.map((i) => {
-          const user = this.activeTeamUserList.find((item) => item.id === i);
-          return {
-            teamId: this.form.teamId,
-            teamName: this.teamList.find((team) => team.id == this.form.teamId)
-              ?.name,
-            userId: user.id,
-            userName: user.name
-          };
+          const user = this.form.executeUsers.find((item) => item.userId === i);
+          return user;
         });
 
         console.log('row', row);
@@ -1976,4 +1975,13 @@
     padding: 8px 20px;
     border-bottom: 1px solid #ccc;
   }
+
+  :deep(
+      .el-dialog:not(.ele-dialog-form)
+        .el-dialog__body
+        .el-form
+        .el-form-item:last-child
+    ) {
+    margin-bottom: 22px;
+  }
 </style>

+ 109 - 27
src/views/produce/components/prenatalExamination/index.vue

@@ -2,7 +2,7 @@
   <el-dialog
     title="报工"
     :visible.sync="dialogVisible"
-    width="600px"
+    width="60%"
     :before-close="handleClose"
   >
     <div>
@@ -14,25 +14,30 @@
         class="step-list"
         v-loading="loading"
       >
-        <div
-          class="step-item"
-          v-for="(item, index) in ruleRecordsList"
-          :key="item.id"
-          @click="openMaintenancePlan(item)"
+        <ele-pro-table
+          ref="table"
+          row-key="id"
+          :columns="columns"
+          :datasource="ruleRecordsList"
+          cache-key="mes-ruleRecordsList-2511172018"
+          autoAmendPage
+          :need-page="false"
+          @refresh="getData"
         >
-          <div class="circle">{{ index + 1 }}</div>
-          <div class="desc">{{
-            item.ruleName || item.itemTaskName || item.planConfigName
-          }}</div>
-          <div class="methods">{{ item.recordRulesExecuteMethodName }}</div>
+          <template v-slot:num="{ $index }">
+            <div class="circle">{{ $index + 1 }}</div>
+          </template>
 
-          <el-button
-            :type="item.executeStatus == 0 ? 'primary' : 'default'"
-            class="status-btn"
-          >
-            {{ executeStatusTest(item.executeStatus) }}
-          </el-button>
-        </div>
+          <template v-slot:action="{ row }">
+            <el-button
+              :type="row.executeStatus == 0 ? 'primary' : 'default'"
+              class="status-btn"
+              @click="openMaintenancePlan(row)"
+            >
+              {{ executeStatusTest(row.executeStatus) }}
+            </el-button>
+          </template>
+        </ele-pro-table>
       </div>
       <el-empty v-else></el-empty>
     </div>
@@ -48,7 +53,10 @@
 
     <taskDialog ref="taskDialogRef" @reload="getData" />
 
-    <PlanRulesDialog ref="planRulesDialogRef" @reload="getData"></PlanRulesDialog>
+    <PlanRulesDialog
+      ref="planRulesDialogRef"
+      @reload="getData"
+    ></PlanRulesDialog>
   </el-dialog>
 </template>
 
@@ -60,8 +68,11 @@
   } from '@/api/producetaskrulerecord/index.js';
   import taskDialog from './taskDialog.vue';
   import PlanRulesDialog from './PlanRulesDialog.vue';
+  import dictMixins from '@/mixins/dictMixins';
+  import tableColumnsMixin from '@/mixins/tableColumnsMixin';
 
   export default {
+    mixins: [dictMixins, tableColumnsMixin],
     components: {
       releaseRulesDialog,
       taskDialog,
@@ -83,6 +94,74 @@
         loading: true
       };
     },
+    computed: {
+      columns() {
+        return [
+          {
+            width: 50,
+            type: 'index',
+            slot: 'num',
+            align: 'center',
+            label: '序号'
+          },
+          {
+            prop: 'produceTaskName',
+            label: '名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 150,
+            formatter: (row) => {
+              return row.ruleName || row.itemTaskName || row.planConfigName;
+            }
+          },
+          {
+            prop: 'executeMethod',
+            label: '执行方式',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 150,
+            formatter: (row) => {
+              return this.getDictValue('记录规则执行方式', row.executeMethod);
+            }
+          },
+          {
+            prop: 'reportUserName',
+            label: '报工人',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'finishTime',
+            label: '报工时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'duration',
+            label: '工时',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 150,
+            formatter: (row) => {
+              // 毫秒转小时
+              return row.duration
+                ? (row.duration / 1000 / 60 / 60).toFixed(2) + ' 时'
+                : '';
+            }
+          },
+          // 操作
+          {
+            label: '操作',
+            align: 'center',
+            width: 130,
+            fixed: 'right',
+            slot: 'action'
+          }
+        ];
+      }
+    },
     methods: {
       open(workOrderInfo, produceTaskInfo, reportWorkType) {
         console.log('workOrderInfo 工单信息', workOrderInfo);
@@ -180,14 +259,7 @@
     display: flex;
     flex-direction: column;
     gap: 24px;
-    padding: 24px;
-  }
-
-  .step-item {
-    display: flex;
-    flex-flow: row wrap;
-    align-items: center;
-    gap: 32px;
+    // padding: 24px;
 
     .circle {
       width: 28px;
@@ -222,6 +294,8 @@
       width: 100px;
       height: 40px;
       font-size: 16px;
+      margin: 5px 0;
+
       &.el-button--default {
         background: #e1e1e1;
         color: #999;
@@ -234,4 +308,12 @@
       }
     }
   }
+
+  .step-item {
+    display: flex;
+    flex-flow: row wrap;
+    align-items: center;
+    gap: 32px;
+    justify-content: space-around;
+  }
 </style>

+ 39 - 34
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -340,10 +340,10 @@
               @change="checkUsersIdsChange(row)"
             >
               <el-option
-                v-for="item in activeTeamUserList"
-                :label="item.name"
-                :value="item.id"
-                :key="item.id"
+                v-for="item in addForm.executeUsers"
+                :label="item.userName"
+                :value="item.userId"
+                :key="item.userId"
               >
               </el-option>
             </el-select>
@@ -864,6 +864,7 @@
               (item) => item.id == this.addForm.teamId
             );
             this.teamUserList = this.teamAllList[index];
+            console.log('this.teamUserList', this.teamUserList);
           }
 
           if (this.addForm.outputType == null) {
@@ -1204,14 +1205,13 @@
         row.toolNames = '';
       },
       checkTeamList(id) {
-        this.addForm.executeUsersIds = [];
         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;
+        if (!id) return;
         const ids = id.split(',');
         this.teamList = [];
         this.teamUserList = [];
@@ -1235,25 +1235,35 @@
           this.checked = false;
         }
 
-        // 同步 executeUsers
-        this.addForm.executeUsers = this.addForm.executeUsersIds
-          .map((id) => {
-            const user = this.teamUserList.find((item) => item.id === id);
-            console.log('user', user);
-            if (user) {
-              return {
-                teamId: this.addForm.teamId,
-                teamName: this.teamList.find(
-                  (team) => team.id == this.addForm.teamId
-                )?.name,
-                userId: user.id,
-                userName: user.name
-              };
-            } else {
-              return null;
-            }
-          })
-          .filter((item) => item !== null);
+        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);
 
@@ -1302,15 +1312,10 @@
       checkUsersIdsChange(row) {
         // 同步 checkUsers
         row.checkUsers = row.checkUsersIds.map((i) => {
-          const user = this.activeTeamUserList.find((item) => item.id === i);
-          return {
-            teamId: this.addForm.teamId,
-            teamName: this.teamList.find(
-              (team) => team.id == this.addForm.teamId
-            )?.name,
-            userId: user.id,
-            userName: user.name
-          };
+          const user = this.formDate.executeUsers.find(
+            (item) => item.userId === i
+          );
+          return user;
         });
 
         console.log('row', row);

+ 357 - 22
src/views/produce/components/prenatalExamination/taskDialog.vue

@@ -52,6 +52,97 @@
           </el-form-item>
         </el-col>
       </el-row>
+      <el-row>
+        <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 :span="8">
+          <el-form-item label="执行人">
+            <el-select
+              v-model="addForm.teamId"
+              placeholder="请选择班组"
+              filterable
+              style="width: 120px"
+              @change="checkTeamList(addForm.teamId)"
+            >
+              <el-option
+                v-for="item in teamList"
+                :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="工时">
+            <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-row>
     </el-form>
 
     <!-- 底部按钮 -->
@@ -79,6 +170,8 @@
   import DictSelection from '@/components/Dict/DictSelection.vue';
   import SelectUser from '@/components/select/SelectUser/index.vue';
   import { saveRuleRecord } from '@/api/producetaskrulerecord/index.js';
+  import { getTeam } from '@/api/produce/job.js';
+  import { getById } from '@/api/producetaskrecordrulesrecord/index';
 
   export default {
     components: { SelectUser },
@@ -122,7 +215,13 @@
         specification: '',
         workOrderCode: '',
         workOrderId: 0,
-        itemTaskName: ''
+        itemTaskName: '',
+        teamId: null,
+        checkStartTime: '',
+        checkFinishTime: '',
+        duration: null,
+        executeUsers: [],
+        executeUsersIds: []
       };
 
       return {
@@ -153,6 +252,51 @@
               message: '请选择检查有效期单位',
               trigger: 'change'
             }
+          ],
+          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'
+            }
           ]
         },
         productionInfo: null,
@@ -167,10 +311,23 @@
         loading: false,
         title: '任务确认',
         // 编辑 或者是  详情 edit detila
-        type: 'edit'
+        type: 'edit',
+        checked: false,
+        teamUserList: [],
+        teamList: [],
+        teamAllList: [],
+        checked: false
       };
     },
     computed: {},
+    mounted() {
+      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);
+      }
+    },
     methods: {
       openView(productionInfo, workOrderInfo) {
         this.type = 'detail';
@@ -186,25 +343,31 @@
         this.productionInfo = productionInfo;
         this.workOrderInfo = workOrderInfo;
 
-        this.addForm.batchNo = workOrderInfo.batchNo;
-        this.addForm.executeMethod = productionInfo.executeMethod;
-        this.addForm.formingNum = workOrderInfo.formingNum;
-        this.addForm.itemType = productionInfo.itemType;
-        this.addForm.produceRoutingId = workOrderInfo.produceRoutingId;
-        this.addForm.produceRoutingName = workOrderInfo.produceRoutingName;
-        this.addForm.produceTaskConfigId = productionInfo.produceTaskConfigId;
-        this.addForm.produceTaskId = productionInfo.produceTaskId;
-        this.addForm.produceTaskName = productionInfo.produceTaskName;
-        this.addForm.productCode = workOrderInfo.productCode;
-        this.addForm.productModel = workOrderInfo.model;
-        this.addForm.productName = workOrderInfo.productName;
-        this.addForm.reportWorkType = productionInfo.reportWorkType;
-        this.addForm.specification = workOrderInfo.specification;
-        this.addForm.workOrderCode = workOrderInfo.code;
-        this.addForm.workOrderId = workOrderInfo.id;
-        this.addForm.itemTaskName = productionInfo.itemTaskName;
-        this.addForm.ruleId = productionInfo.ruleId;
-        this.addForm.brandNo = productionInfo.brandNo;
+        // 存在缓存记录
+        if (this.productionInfo.recordId != null) {
+          // 查询详情
+          this.getCacheInfo();
+        } else {
+          this.addForm.batchNo = workOrderInfo.batchNo;
+          this.addForm.executeMethod = productionInfo.executeMethod;
+          this.addForm.formingNum = workOrderInfo.formingNum;
+          this.addForm.itemType = productionInfo.itemType;
+          this.addForm.produceRoutingId = workOrderInfo.produceRoutingId;
+          this.addForm.produceRoutingName = workOrderInfo.produceRoutingName;
+          this.addForm.produceTaskConfigId = productionInfo.produceTaskConfigId;
+          this.addForm.produceTaskId = productionInfo.produceTaskId;
+          this.addForm.produceTaskName = productionInfo.produceTaskName;
+          this.addForm.productCode = workOrderInfo.productCode;
+          this.addForm.productModel = workOrderInfo.model;
+          this.addForm.productName = workOrderInfo.productName;
+          this.addForm.reportWorkType = productionInfo.reportWorkType;
+          this.addForm.specification = workOrderInfo.specification;
+          this.addForm.workOrderCode = workOrderInfo.code;
+          this.addForm.workOrderId = workOrderInfo.id;
+          this.addForm.itemTaskName = productionInfo.itemTaskName;
+          this.addForm.ruleId = productionInfo.ruleId;
+          this.addForm.brandNo = productionInfo.brandNo;
+        }
 
         console.log('this.productionInfo', this.productionInfo);
         console.log('this.addForm', this.addForm);
@@ -231,7 +394,13 @@
           // 提交
           this.butLoading = true;
           try {
-            await saveRuleRecord(this.addForm);
+            const body = JSON.parse(JSON.stringify(this.addForm));
+
+            // 工时小时转毫秒
+            body.duration = Number(body.duration);
+            body.duration = body.duration * 60 * 60 * 1000;
+
+            await saveRuleRecord(body);
             this.$message.success('报工成功!');
 
             this.butLoading = false;
@@ -244,6 +413,152 @@
             this.butLoading = false;
           }
         });
+      },
+      durationChagne() {
+        // 保留小数后一位
+        if (
+          this.addForm.duration &&
+          this.addForm.duration.toString().includes('.')
+        ) {
+          this.addForm.duration = Number(this.addForm.duration).toFixed(1);
+        }
+      },
+      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);
+        });
+      },
+      checkTeamList(id) {
+        const index = this.teamList.findIndex((item) => item.id == id);
+        this.teamUserList = this.teamAllList[index];
+        console.log('this.teamUserList', this.teamUserList);
+      },
+      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;
+        });
+      },
+      // 计算工时
+      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);
+        }
+      },
+      checkChange() {
+        this.addForm.executeUsersIds = [];
+        if (this.checked) {
+          this.addForm.executeUsersIds = this.teamUserList.map(
+            (item) => item.id
+          );
+        } else {
+          this.addForm.executeUsersIds = [];
+        }
+      },
+      // 获取详情
+      async getCacheInfo() {
+        this.loading = true;
+        try {
+          const data = await getById(this.productionInfo.recordId);
+          console.log('dat 缓存', data);
+
+          this.$util.assignObject(this.addForm, data);
+
+          // 工时毫秒转小时
+          this.addForm.duration = (
+            this.addForm.duration /
+            (1000 * 60 * 60)
+          ).toFixed(2);
+
+          this.addForm.recordRulesClassify += '';
+
+          this.addForm.executeUsersIds = this.addForm.executeUsers.map(
+            (i) => i.userId
+          );
+
+          this.addForm.teamId =
+            this.addForm.executeUsers.length > 0
+              ? this.addForm.executeUsers[0].teamId
+              : '';
+
+          // 加载班组人员列表
+          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);
+          }
+
+          console.log('this.addForm', this.addForm);
+
+          this.loading = false;
+        } catch (error) {
+          this.loading = false;
+        }
       }
     }
   };
@@ -264,4 +579,24 @@
   .el-form-item .el-form-item {
     margin-bottom: -5px;
   }
+
+  .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;
+  }
 </style>