xwt
2025-09-03 0c3ea5f8246b22ad945e4086a9507c30d6245a8b
pages/QC/LLJ/Add.vue
@@ -1,14 +1,14 @@
<template>
   <view class="inspection-sheet">
      <!-- 头部信息 -->
      <view class="sheet-header">
         <h1>来料检验单</h1>
         <view class="inspection-number">检验单号:{{formData.releaseNo}}</view>
         <!--实验室送检 -->
         <view style="text-align: right;" class="action-buttons">
            <a class="sysLike" v-if="this.current" @click="toSysSubmitFrom(formData.releaseNo)">实验室送检</a>
         <!-- 头部信息 -->
         <view class="sheet-header">
            <h1>来料检验单</h1>
            <view class="inspection-number">检验单号:{{formData.releaseNo}}</view>
            <!--实验室送检 -->
            <view style="text-align: right;" class="action-buttons">
               <a class="sysLike" v-if="this.current" @click="toSysSubmitFrom(formData.releaseNo)">实验室送检</a>
            </view>
         </view>
      </view>
      <!-- 基本信息区 -->
      <view class="basic-info">
@@ -56,10 +56,6 @@
            <view class="info-label">不良描述:</view>
            <view class="info-value">{{formData.fngDesc}}</view>
         </view>
         <view class="info-block" v-if="formData.newFngDesc!=null">
            <view class="info-label">上次不良:</view>
            <view class="info-value">{{formData.newFngDesc}}</view>
         </view>
      </view>
      <view class="dropdown-row">
         <view class="info-label">不良原因:</view>
@@ -90,7 +86,7 @@
      </view>
      <view class="info-block" style="margin-top: 10px;">   
          <view class="info-label">破坏实验数量:</view>
          <view class="info-value highlight">{{formData.phsy}}</view>
          <view class="info-value highlight">{{formData.PHSY || formData.phsy || ''}}</view>
      </view>
      <!-- 表单上方操作按钮区 -->
@@ -374,6 +370,19 @@
            
         }
      },
      computed: {
         isUnmaintainedAndNotEmergency() {
            // 判断表单是否未维护且不是紧急放行
            // 未维护的条件:tableData为空或所有检验项目都未完成
            const isUnmaintained = this.tableData.length === 0 ||
               this.tableData.every(item => item.fcheckResu === null || item.fcheckResu === '');
            // 不是紧急放行的条件:emergencyStatus为false
            const isNotEmergency = !this.formData.emergencyStatus;
            return isUnmaintained && isNotEmergency;
         }
      },
      onLoad(options) {
         //options中包含了url附带的参数
         let params = options;
@@ -575,42 +584,22 @@
                  }).then(res => {
                     if (res.status == 0) {
                        if(this.$loginInfo.account == 'PL017'){
                           this.QcIssueResultDetailes = {
                              fbatchQty: this.formData.fbatchQty,
                              itemName: this.formData.itemName,
                              itemNo: this.formData.itemNo,
                              suppName: this.formData.suppName,
                              appicationReason: this.formData.fngDesc,
                              badReason: this.badreason,
                              remark: this.remarks || '',
                              workShop: this.WORKSHOP,
                              releaseNo: this.formData.releaseNo,
                              staffNo: 'HMCS',
                              // staffNo: this.$loginInfo.account,
                              iqcStatus: this.PSTYPE,
                              department: this.WORKSHOP, // 使用WORKSHOP替代未定义的DEPARTMENT
                              EMERGENCY: this.formData.emergencyStatus ? "1" : "0" // 确保紧急放行状态正确传递
                           };
                        }
                        else{
                           this.QcIssueResultDetailes = {
                              fbatchQty: this.formData.fbatchQty,
                              itemName: this.formData.itemName,
                              itemNo: this.formData.itemNo,
                              suppName: this.formData.suppName,
                              appicationReason: this.formData.fngDesc,
                              badReason: this.badreason,
                              remark: this.remarks || '',
                              workShop: this.WORKSHOP,
                              releaseNo: this.formData.releaseNo,
                              // staffNo: 'HMCS',
                              staffNo: this.$loginInfo.account,
                              iqcStatus: this.PSTYPE,
                              department: this.WORKSHOP, // 使用WORKSHOP替代未定义的DEPARTMENT
                              EMERGENCY: this.formData.emergencyStatus ? "1" : "0" // 确保紧急放行状态正确传递
                           };
                        }
                        // 统一推送给HMCS,不管哪个账号
                        this.QcIssueResultDetailes = {
                           fbatchQty: this.formData.fcovertQty,
                           itemName: this.formData.itemName,
                           itemNo: this.formData.itemNo,
                           suppName: this.formData.suppName,
                           appicationReason: this.formData.fngDesc,
                           badReason: this.badreason,
                           remark: this.remarks || '',
                           workShop: this.WORKSHOP,
                           releaseNo: this.formData.releaseNo,
                           staffNo: 'HMCS', // 统一推送给HMCS
                           iqcStatus: this.PSTYPE,
                           department: this.WORKSHOP, // 使用WORKSHOP替代未定义的DEPARTMENT
                           EMERGENCY: this.formData.emergencyStatus ? "1" : "0" // 确保紧急放行状态正确传递
                        };
                        console.log("提交的紧急放行状态:", this.formData.emergencyStatus ? "1" : "0");
                        console.log("完整的提交数据:", this.QcIssueResultDetailes);
@@ -745,9 +734,9 @@
                  this.pstypeIndex = this.pstypeOptions.indexOf(this.PSTYPE);
                  
                  // 确保PHSY字段被正确设置
                  this.formData.PHSY = data.PHSY;
                  this.PHSY = data.PHSY || ''; // 同时设置页面绑定的PHSY变量
                  // 确保PHSY字段被正确设置(兼容大小写)
                  this.formData.PHSY = data.PHSY || data.phsy;
                  this.PHSY = (data.PHSY || data.phsy || '').toString(); // 同时设置页面绑定的PHSY变量
                  
                  console.log("加载的紧急放行状态:", this.formData.emergencyStatus);
                  this.$post({
@@ -760,6 +749,16 @@
                     let tableData = res1.data.tbBillList
                     //当已检验个数都不为空时按照检测结构排序
                     tableData.sort((a, b) => {
                        // 首先按Fstand排序:Fstand不为空的排在前面
                        const aHasFstand = a.fstand !== null && a.fstand !== undefined;
                        const bHasFstand = b.fstand !== null && b.fstand !== undefined;
                        if (aHasFstand && !bHasFstand) {
                           return -1;
                        } else if (!aHasFstand && bHasFstand) {
                           return 1;
                        }
                        // 然后按检验结果排序
                        if (a.result === '合格' && b.result === '未完成') {
                           return -1;
                        } else if (a.result === '未完成' && b.result === '合格') {
@@ -1307,19 +1306,31 @@
         addDestruction() {
            // 添加破坏实验的逻辑
            this.destructionPopup = !this.destructionPopup;
            // 修复:确保PHSY变量正确初始化
            this.PHSY = this.formData.PHSY || '';
            this.isInteger = true;
         },
         editDestruction() {
            // 验证输入是否为整数或空字符串
            if(this.PHSY === '') {
               this.isInteger = true;
            } else {
               const isInteger = /^-?\d+$/.test(this.PHSY);
               this.isInteger = isInteger;
               if (!isInteger) {
                  uni.showToast({
                     title: '请输入整数值或留空',
                     icon: 'none',
                     duration: 2000
                  });
                  return;
               }
            }
            // 显示加载提示
            uni.showLoading({
               title: '保存中...'
            });
         
            this.$post({
               url: "/LLJ/savePhsyGid",
@@ -1329,20 +1340,42 @@
                  PHSY: this.PHSY
               }
            }).then(res => {
               if (res.data.tbBillList > 0) {
               uni.hideLoading();
               if (res.data && res.data.tbBillList > 0) {
                  this.formData.PHSY = this.PHSY === '' ? null : this.PHSY;
                  this.destructionPopup = false;
                  uni.showToast({
                     title: '保存成功',
                     icon: 'success',
                     duration: 2000
                  });
                  // 立即重新加载数据确保同步
                  setTimeout(() => {
                     this.init();
                  }, 500);
               } else {
                  uni.showToast({
                     title: '保存失败',
                     icon: 'none',
                     duration: 2000
                  });
               }
            }).catch(err => {
               uni.hideLoading();
               console.error('保存失败:', err);
               uni.showToast({
                  title: '保存失败,请重试',
                  icon: 'none',
                  duration: 2000
               });
            })
         },
         clearDestruction() {
            this.PHSY = '';
            // 显示加载提示
            uni.showLoading({
               title: '清除中...'
            });
            this.$post({
               url: "/LLJ/savePhsyGid",
               data: {
@@ -1351,16 +1384,35 @@
                  PHSY: ''
               }
            }).then(res => {
               if (res.data.tbBillList > 0) {
               uni.hideLoading();
               if (res.data && res.data.tbBillList > 0) {
                  this.formData.PHSY = null;
                  this.PHSY = '';
                  this.destructionPopup = false;
                  uni.showToast({
                     title: '清除成功',
                     icon: 'success',
                     duration: 2000
                  });
                  // 立即重新加载数据确保同步
                  setTimeout(() => {
                     this.init();
                  }, 500);
               } else {
                  uni.showToast({
                     title: '清除失败',
                     icon: 'none',
                     duration: 2000
                  });
               }
            }).catch(err => {
               uni.hideLoading();
               console.error('清除失败:', err);
               uni.showToast({
                  title: '清除失败,请重试',
                  icon: 'none',
                  duration: 2000
               });
            })
         },
         viewAttachmentInfo() {
@@ -1944,6 +1996,39 @@
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      min-height: 100vh;
      position: relative;
      transition: all 0.3s ease;
   }
   /* 未维护且非紧急放行表单的紫色样式 */
   .inspection-sheet.unmaintained-form {
      background: linear-gradient(135deg, #f8f4ff 0%, #f0e6ff 100%);
      border: 2px solid #9c27b0;
      box-shadow: 0 0 20px rgba(156, 39, 176, 0.2);
   }
   .inspection-sheet.unmaintained-form .sheet-header {
      border-bottom: 2px solid #9c27b0;
   }
   .inspection-sheet.unmaintained-form .sheet-header h1 {
      color: #6a1b9a;
   }
   .inspection-sheet.unmaintained-form .inspection-number {
      color: #9c27b0;
   }
   .inspection-sheet.unmaintained-form .material-info {
      border: 1px solid #e1bee7;
      background-color: rgba(156, 39, 176, 0.05);
   }
   .inspection-sheet.unmaintained-form .info-label {
      color: #6a1b9a;
   }
   .inspection-sheet.unmaintained-form .info-value {
      color: #4a148c;
   }
   /* 头部样式 */