Преглед изворни кода

一键报工功能完善产前准备等

lucw пре 9 месеци
родитељ
комит
7329aeb664

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

@@ -0,0 +1,46 @@
+import request from '@/utils/request';
+
+// 一键报工,新增或修改填写表单类型的执行记录,并修改状态为已执行
+export async function saveOrUpdateAndSubmit(body) {
+  const res = await request.post(
+    '/mes/producetaskrecordrulesrecord/saveOrUpdateAndSubmit',
+    body
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 缓存,新增或修改填写表单类型的执行记录
+export async function saveOrUpdate(body) {
+  const res = await request.post(
+    '/mes/producetaskrecordrulesrecord/saveOrUpdate',
+    body
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 一键报工,新增或修改填写表单类型的执行记录,并修改状态为已执行
+export async function logicDelete(id) {
+  const res = await request.delete(
+    '/mes/producetaskrecordrulesrecord/logicDelete/' + id
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+export async function getById(id) {
+  const res = await request.get(
+    '/mes/producetaskrecordrulesrecord/getById/' + id
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 4 - 0
src/components/select/SelectUser/index.vue

@@ -88,6 +88,10 @@
   export default {
     name: 'SelectUser',
     components: { Organization, clearList },
+    model: {
+      prop: 'visible',
+      event: 'update:visible'
+    },
     props: {
       visible: {
         type: Boolean,

+ 1 - 1
src/views/produce/components/footBtn.vue

@@ -34,7 +34,7 @@
             bjColor: '#FBD114'
           },
           {
-            name: '过程测',
+            name: '过程测',
             type: 'processDetection',
             bjColor: '#008888'
           },

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

@@ -9,7 +9,11 @@
       <!-- <el-button type="primary" plain round @click="openMaintenancePlan">
         设备保养计划
       </el-button> -->
-      <div class="step-list">
+      <div
+        v-if="loading || ruleRecordsList.length > 0"
+        class="step-list"
+        v-loading="loading"
+      >
         <div
           class="step-item"
           v-for="(item, index) in ruleRecordsList"
@@ -26,6 +30,7 @@
           </el-button>
         </div>
       </div>
+      <el-empty v-else></el-empty>
     </div>
     <template #footer>
       <el-button @click="handleUpdate" type="primary" :loading="butLoad"
@@ -38,12 +43,13 @@
     <programRulesDialog
       ref="programRulesDialogRef"
       :dialogTitle="dialogTitle"
-      @reload="getData()"
+      @reload="getData"
     />
 
     <releaseRulesDialog
       v-model="showReleaseRulesDialog"
       ref="releaseRulesDialogRef"
+      @reload="getData"
     />
   </el-dialog>
 </template>
@@ -52,6 +58,7 @@
   import releaseRulesDialog from './releaseRulesDialog.vue';
   import programRulesDialog from './programRulesDialog.vue';
   import { getLastRuleRecords } from '@/api/producetaskrulerecord/index.js';
+  import { getDate } from '@/utils/dateUtils';
 
   export default {
     components: { programRulesDialog, releaseRulesDialog },
@@ -64,11 +71,12 @@
         workOrderInfo: null,
         // 工序信息
         produceTaskInfo: null,
-        // 参考字典项:record_rules_execute_method,1-事件驱动,2-表单填写,3-任务驱动
+        // 	报工类型,参考字典项:record_rules_report_work_type,1-产前准备,2-过程监测,3-产后检查
         reportWorkType: 1,
         butLoad: false,
         // 记录规则
-        showReleaseRulesDialog: false
+        showReleaseRulesDialog: false,
+        loading: true
       };
     },
     methods: {
@@ -94,6 +102,7 @@
       },
       // 获取数据
       async getData() {
+        this.loading = true;
         const body = {
           workOrderId: this.workOrderInfo.id,
           produceTaskId: this.produceTaskInfo.id,
@@ -103,6 +112,7 @@
         const data = await getLastRuleRecords(body);
         this.ruleRecordsList = data;
         console.log('报工流程 事项', this.ruleRecordsList);
+        this.loading = false;
       },
       handleClose() {
         this.dialogVisible = false;
@@ -134,7 +144,11 @@
             this.produceTaskInfo
           );
         } else {
-          this.$refs.releaseRulesDialogRef.open(item);
+          this.$refs.releaseRulesDialogRef.open(
+            item,
+            this.workOrderInfo,
+            this.produceTaskInfo
+          );
         }
       }
     }

+ 261 - 55
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -18,7 +18,7 @@
     >
       <el-row>
         <el-col :span="8">
-          <el-form-item label="记录规则名称" required prop="recordRulesName">
+          <el-form-item label="记录规则名称" required>
             <el-input
               v-model="addForm.recordRulesName"
               size="small"
@@ -28,11 +28,7 @@
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item
-            label="记录规则分类"
-            required
-            prop="recordRulesClassify"
-          >
+          <el-form-item label="记录规则分类" required>
             <DictSelection
               dictName="记录规则类型"
               clearable
@@ -46,7 +42,6 @@
           <el-form-item
             v-if="ruleInfo && ruleInfo.classify == 3"
             label="关联设备"
-            prop="workshopArea"
           >
             <el-input
               v-model="addForm.deviceName"
@@ -69,6 +64,7 @@
               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%"
             >
@@ -83,15 +79,17 @@
               type="text"
             >
               <template slot="append">
-                <div style="width: 40px">
-                  <DictSelection
-                    dictName="检查有效期单位"
-                    clearable
-                    v-model="addForm.checkValidityUnit"
-                    placeholder="单位"
-                    style="width: auto"
-                  >
-                  </DictSelection>
+                <div style="width: 40px; box-sizing: border-box">
+                  <el-form-item required prop="checkValidityUnit">
+                    <DictSelection
+                      dictName="检查有效期单位"
+                      clearable
+                      v-model="addForm.checkValidityUnit"
+                      placeholder="单位"
+                      style="width: auto"
+                    >
+                    </DictSelection>
+                  </el-form-item>
                 </div>
               </template>
             </el-input>
@@ -111,7 +109,7 @@
     <header-title title="检查项目"></header-title>
 
     <!-- 表格 -->
-    <el-table :data="list" style="width: 100%">
+    <el-table :data="addForm.details" style="width: 100%">
       <el-table-column type="index" label="序号" width="50"> </el-table-column>
       <el-table-column label="检查内容">
         <template slot-scope="scope">
@@ -124,14 +122,18 @@
       <el-table-column label="检查工具">
         <template slot-scope="scope">
           <div>
-            {{ scope.row.tools.map((i) => i.toolName).join(',') }}
+            {{ scope.row.toolNames }}
           </div>
         </template>
       </el-table-column>
       <el-table-column label="检查人">
         <template slot-scope="scope">
-          <div @click="openSelectUser">
-            {{ scope.row.id }}
+          <div
+            @click="openSelectUser(scope.row)"
+            style="display: flex; align-items: center; cursor: pointer"
+          >
+            <div>{{ showCheckUserNames(scope.row.checkUsers) }}</div
+            ><i class="el-icon-caret-bottom"></i>
           </div>
         </template>
       </el-table-column>
@@ -181,52 +183,111 @@
     <!-- 底部按钮 -->
     <template #footer>
       <div class="modal-footer">
-        <el-button type="primary" @click="handleOk">一键报工</el-button>
-        <el-button type="primary" @click="handleOk">清空缓存</el-button>
-        <el-button type="primary" @click="handleOk">缓存</el-button>
+        <el-button
+          :loading="butLoading"
+          type="primary"
+          @click="submit('submit')"
+          :disabled="productionInfo && productionInfo.executeStatus == 2"
+        >
+          一键报工
+        </el-button>
+
+        <el-popconfirm
+          v-if="
+            productionInfo &&
+            productionInfo.recordId != null &&
+            productionInfo.executeStatus == 1
+          "
+          title="您确定要清空缓存吗?"
+          @confirm="clearCache"
+        >
+          <el-button slot="reference" :loading="butLoading" type="primary">
+            清空缓存
+          </el-button>
+        </el-popconfirm>
+
+        <el-button
+          :loading="butLoading"
+          type="primary"
+          @click="submit('cache')"
+          :disabled="productionInfo && productionInfo.executeStatus == 2"
+        >
+          缓存
+        </el-button>
+
+        <el-button
+          v-if="productionInfo && productionInfo.executeStatus == 2"
+          @click="handleBeforeClose"
+        >
+          关闭
+        </el-button>
       </div>
     </template>
     <!-- 选择用户 -->
-    <SelectUser ref="SelectUserRef" v-model="showSelectUser"></SelectUser>
+    <SelectUser
+      ref="SelectUserRef"
+      v-model="showSelectUser"
+      multipleSelect
+      @selectUserFinished="selectUserFinished"
+    ></SelectUser>
   </ele-modal>
 </template>
 
 <script>
+  import { submit } from '@/api/entrust';
   import {
     recordRulesDetailPage,
     getRecordRulesDetail
   } from '@/api/recordRules/index.js';
   import DictSelection from '@/components/Dict/DictSelection.vue';
   import SelectUser from '@/components/select/SelectUser/index.vue';
+  import {
+    saveOrUpdateAndSubmit,
+    saveOrUpdate,
+    logicDelete,
+    getById
+  } from '@/api/producetaskrecordrulesrecord/index';
 
   export default {
     components: { SelectUser },
+    emits: ['reload'],
     props: {},
     data() {
       const formDate = {
+        id: null,
+        workshopArea: '',
         checkFinishTime: '',
         checkValidity: null,
         checkValidityUnit: '',
         conclution: 0,
+        isTempRecord: 0,
         details: [],
         deviceId: 0,
         deviceName: '',
-        id: 0,
+        batchNo: '',
+        executeMethod: 0,
+        formingNum: 0,
+        itemType: 0,
         produceRoutingId: 0,
         produceRoutingName: '',
         produceTaskConfigId: 0,
         produceTaskId: 0,
-        recordRulesClassify: 0,
+        productCode: '',
+        productModel: '',
+        productName: '',
+        recordRulesClassify: null,
         recordRulesId: 0,
         recordRulesName: '',
+        reportWorkType: 0,
+        specification: '',
         workOrderCode: '',
-        workOrderId: 0,
-        workshopArea: ''
+        workOrderId: 0
       };
 
       return {
         visible: false,
-        addForm: formDate,
+        formDate,
+        addForm: JSON.parse(JSON.stringify(formDate)),
         formRules: {
           checkFinishTime: [
             { required: true, message: '请选择检查完成时间', trigger: 'blur' },
@@ -239,12 +300,30 @@
           checkValidity: [
             { required: true, message: '请输入检查有效期', trigger: 'blur' },
             { required: true, message: '请输入检查有效期', trigger: 'change' }
+          ],
+          checkValidityUnit: [
+            {
+              required: true,
+              message: '请选择检查有效期单位',
+              trigger: 'blur'
+            },
+            {
+              required: true,
+              message: '请选择检查有效期单位',
+              trigger: 'change'
+            }
           ]
         },
         productionInfo: null,
         list: [],
         ruleInfo: null,
-        showSelectUser: false
+        showSelectUser: false,
+        currentRow: null,
+        butLoading: false,
+        // 工艺路线
+        workOrderInfo: null,
+        //工序信息
+        produceTaskInfo: null
       };
     },
     computed: {
@@ -264,24 +343,60 @@
       }
     },
     methods: {
-      open(productionInfo) {
+      open(productionInfo, workOrderInfo, produceTaskInfo) {
         this.visible = true;
         this.productionInfo = productionInfo;
+        this.workOrderInfo = workOrderInfo;
+        this.produceTaskInfo = produceTaskInfo;
+
+        // 存在缓存记录
+        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.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.getRuleList();
+        }
+
         console.log('this.productionInfo', this.productionInfo);
-        this.getRuleList();
+        console.log('this.addForm', this.addForm);
         this.getRuleInfo();
       },
+      // 获取详情
+      async getCacheInfo() {
+        const data = await getById(this.productionInfo.recordId);
+        console.log('dat 缓存', data);
+        this.$util.assignObject(this.addForm, data);
+        this.addForm.recordRulesClassify += '';
+      },
       // 规则信息
       async getRuleInfo() {
         const data = await getRecordRulesDetail(this.productionInfo.ruleId);
         this.ruleInfo = data;
         console.log('this.ruleInfo', this.ruleInfo);
-        // 复制表单信息
-        this.addForm.recordRulesClassify = this.ruleInfo.classify;
-        this.addForm.recordRulesId = this.ruleInfo.id;
-        this.addForm.recordRulesName = this.ruleInfo.name;
-        this.addForm.deviceId = this.ruleInfo.deviceId;
-        this.addForm.deviceName = this.ruleInfo.deviceName;
+        if (this.productionInfo.recordId == null) {
+          // 赋值表单信息
+          this.addForm.recordRulesClassify = this.ruleInfo.classify + '';
+          this.addForm.recordRulesId = this.ruleInfo.id;
+          this.addForm.recordRulesName = this.ruleInfo.name;
+          this.addForm.deviceId = this.ruleInfo.deviceId;
+          this.addForm.deviceName = this.ruleInfo.deviceName;
+        }
       },
       // 查询记录规则 事项列表
       async getRuleList() {
@@ -291,33 +406,121 @@
           size: 9999
         });
         // 添加必要参数
-        this.list = list.map((i) => {
+        this.addForm.details = list.map((i) => {
           return {
-            ...i,
-            checkDeptId: 0,
-            checkDeptName: '',
             checkResult: null,
-            checkStatus: 0,
+            checkStatus: null,
             checkStatusDesc: '',
-            checkUserId: 0,
-            checkUserName: '',
             errorMsg: '',
-            executeStatus: 0
+            checkUsers: [],
+            paramValue: i.paramValue,
+            toolNames: i.tools.map((i) => i.toolName).join(','),
+            recordId: i.recordId
           };
         });
-        console.log('data list 事项列表', this.list);
+        console.log('this.addForm 添加规则', this.addForm);
       },
-      openSelectUser() {
+      openSelectUser(row) {
+        this.currentRow = row;
+        console.log('row', row);
         this.showSelectUser = true;
+        console.log('this.showSelectUser', this.showSelectUser);
       },
-      handleBeforeClose(done) {
-        this.visible = false;
+      handleBeforeClose() {
+        this.addForm = JSON.parse(JSON.stringify(this.formDate));
+        console.log('this.$refs.ruleFormRef', this.addForm);
+        this.$refs.ruleFormRef?.clearValidate();
+        this.$nextTick(() => {
+          this.visible = false;
+        });
       },
-      handleCancel() {
-        this.visible = false;
+
+      selectUserFinished(userInfo) {
+        console.log('userInfo', userInfo);
+        this.currentRow.checkUsers = userInfo.map((i) => {
+          // 构建参数和接口的对应上
+          return { ...i, userName: i.name, userId: i.id };
+        });
       },
-      handleOk() {
-        this.visible = false;
+      showCheckUserNames(userList) {
+        if (userList.length == 0) return '请选择部门-选择员工';
+
+        return userList
+          .map((i) => {
+            return i.groupName + '-' + i.userName;
+          })
+          .join(',');
+      },
+      // 提交
+      submit(type) {
+        // 验证表单
+        this.$refs.ruleFormRef.validate(async (valid) => {
+          if (!valid) {
+            return;
+          }
+
+          // 报工需要验证 缓存不验证
+          if (type == 'submit') {
+            // 验证检查项目
+            const detailRequired = this.addForm.details.some((i) => {
+              let qk = false;
+              if (this.ruleInfo.classify == 3) {
+                qk = Boolean(i.checkStatusDesc);
+              } else {
+                qk = i.checkStatus != null;
+              }
+
+              return i.checkResult == null || !qk || i.checkUsers?.length == 0;
+            });
+
+            if (detailRequired) {
+              return this.$message.warning(
+                '请先完善 检查人、检查情况、检查结果 内容!'
+              );
+            }
+          }
+
+          console.log('this.addForm', this.addForm);
+
+          // 提交
+          this.butLoading = true;
+          try {
+            if (type == 'submit') {
+              await saveOrUpdateAndSubmit(this.addForm);
+              this.$message.success('报工成功!');
+            } else {
+              await saveOrUpdate(this.addForm);
+              this.$message.success('缓存成功!');
+              this.productionInfo.executeStatus = 1;
+            }
+
+            this.butLoading = false;
+
+            // 返回
+            this.$emit('reload');
+
+            if (type == 'submit') {
+              this.handleBeforeClose();
+            }
+          } catch (error) {
+            this.butLoading = false;
+          }
+        });
+      },
+      async clearCache() {
+        try {
+          this.butLoading = true;
+          await logicDelete(this.productionInfo.recordId);
+          this.butLoading = false;
+          this.productionInfo.recordId == null;
+          this.addForm = JSON.parse(JSON.stringify(this.formDate));
+          this.getRuleList();
+          this.$message.success('缓存清空成功!');
+          this.productionInfo.executeStatus = 0;
+          this.$emit('reload');
+        } catch (error) {
+          this.butLoading = false;
+        }
       }
     }
   };
@@ -329,6 +532,9 @@
     min-height: 100px;
   }
   .modal-footer {
-    text-align: right;
+    display: flex;
+    align-items: center;
+    gap: 10px;
+    justify-content: flex-end;
   }
 </style>

+ 30 - 6
src/views/produce/index.vue

@@ -317,7 +317,7 @@
     <!-- BOM详情 -->
     <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
 
-    <!-- 产前准备 -->
+    <!-- 产前准备 、 过程监测 、产后检测 -->
     <prenatalExamination ref="prenatalExaminationRef" />
   </div>
 </template>
@@ -912,23 +912,47 @@
           }
         }
 
-        // 产前准备
-        if (t == 'prenatalExamination') {
+        // 产前准备 过程监测 产后检查
+        if (
+          t == 'prenatalExamination' ||
+          t == 'processDetection' ||
+          t == 'postpartumExamination'
+        ) {
           if (this.workListIds.length > 1) {
-            return this.$message.warning('产前准备只能选择一个工单!');
+            if (t == 'prenatalExamination') {
+              return this.$message.warning('产前准备只能选择一个工单!');
+            }
+            if (t == 'processDetection') {
+              return this.$message.warning('过程监测只能选择一个工单!');
+            }
+            return this.$message.warning('产后检查只能选择一个工单!');
           }
 
           if (this.workListIds.length < 1) {
             return this.$message.warning('请选择工单!');
           }
 
+          let reportWorkType = 1;
+
+          switch (t) {
+            case 'prenatalExamination':
+              reportWorkType = 1;
+              break;
+            case 'processDetection':
+              reportWorkType = 2;
+              break;
+            default:
+              reportWorkType = 3;
+              break;
+          }
+
           // 产前准备
           console.log('this.produceTaskInfo', this.produceTaskInfo);
           this.$refs.prenatalExaminationRef.open(
             this.workData.list[0],
             this.produceTaskInfo,
-            // 参考字典项:record_rules_execute_method,1-事件驱动,2-表单填写,3-任务驱动
-            1
+            // 	报工类型,参考字典项:record_rules_report_work_type,1-产前准备,2-过程监测,3-产后检查
+            reportWorkType
           );
         }
       },