fcx
4 天以前 6ca81c89d606b5be26c8b8526b191ae8e773167b
pages/QC/SJ/Add.vue
@@ -1,675 +1,988 @@
<template>
   <view class="inspection-sheet">
      <!-- 头部信息 -->
      <view class="sheet-header">
         <h1>首检检验单</h1>
         <view class="inspection-number">检验单号:{{formData.billNo}}</view>
  <view class="inspection-sheet">
    <!-- 头部信息 -->
    <view class="sheet-header">
      <h1>首检单</h1>
      <view class="inspection-number">检验单号:{{ formData.billNo }}</view>
    </view>
    <!-- 基本信息区 -->
    <view class="basic-info">
      <view class="info-row">
        <span class="info-label">创建时间:</span>
        <span class="info-value">{{ formData.createTime }}</span>
        <span class="info-label">检验人:</span>
        <span class="info-value">{{ formData.statusUser }}</span>
      </view>
    </view>
      </view>
    <!-- 物料信息区 -->
    <view class="material-info">
      <view class="info-block">
        <view class="info-label">生产线别:</view>
        <view v-if="!isUpdate" class="info-value">{{ formData.line }}</view>
        <superwei-combox v-else v-model="formData.line" :candidates="DAA020List"
                         class="picker info-value-input" placeholder="请选择或输入"
                         @select="onDaa020Change"></superwei-combox>
      </view>
      <view class="info-block">
        <view class="info-label">物料编码:</view>
        <view v-if="!isUpdate" class="info-value">{{ formData.itemNo }}</view>
        <superwei-combox v-else v-model="formData.itemNo" :candidates="boardItems" :isJSON="true"
                         class="picker info-value-input" keyName="itemName" placeholder="请选择或输入"
                         @select="onItemChange"></superwei-combox>
      </view>
      <view class="info-block">
        <view class="info-label">产品名称:</view>
        <view class="info-value">{{ formData.daa003 }}</view>
      </view>
      <view class="info-block">
        <view class="info-label">规格型号:</view>
        <view class="info-value">{{ formData.daa004 }}</view>
      </view>
      <view class="info-block">
        <view class="info-label">工单编号:</view>
        <view v-if="!isUpdate" class="info-value">{{ formData.daa001 }}</view>
        <picker v-else :range="DAA001List" class="picker info-value-input" name="selector"
                @change="onDaa001Change">
          <view>{{ DAA001List[DAA001Index] }}</view>
        </picker>
        <view class="info-label">项目:</view>
        <view class="info-value">{{ formData.projecT_CODE }}</view>
        <view class="info-label">工单数量:</view>
        <view class="info-value highlight">{{ formData.daa008 }}</view>
      </view>
      <view v-if="formData.remarks && current" class="info-block">
        <view class="info-label">备注:</view>
        <view class="info-value">{{ formData.remarks }}</view>
      </view>
    </view>
      <!-- 基本信息区 -->
      <view class="basic-info">
         <view class="info-row">
            <span class="info-label">创建人:</span>
            <span class="info-value">{{formData.fName}}</span>
         </view>
         <view class="info-row">
            <span class="info-label">创建时间:</span>
            <span class="info-value">{{formData.createTime}}</span>
            <!--        <span class="info-label">&nbsp;负责人:</span>
        <span class="info-value">{{formData.statusUser}}</span> -->
         </view>
      </view>
    <!-- 操作按钮区 -->
    <view class="action-buttons">
            <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="toSNScanCode(formData.releaseNo)">SN确认</button>
      <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="toYzxSubmitFrom(formData.releaseNo)">一致性核对</button>
      <button class="secondary-btn" @click="getTable">获取检验项目</button>
    </view>
      <!-- 物料信息区 -->
      <view class="material-info">
         <view class="info-block">
            <view class="info-label">物料编码:</view>
            <view class="info-value">{{formData.itemNo}}</view>
         </view>
         <view class="info-block">
            <view class="info-label">产品名称:</view>
            <view class="info-value">{{formData.daa003}}</view>
         </view>
         <view class="info-block">
            <view class="info-label">规格型号:</view>
            <view class="info-value">{{formData.daa004}}</view>
         </view>
         <view class="info-block">
            <view class="info-label">生产线别:</view>
            <view class="info-value">{{formData.line}}</view>
         </view>
    <!-- 检验项目表格 -->
    <view v-if="tableData.length > 0" class="inspection-table">
      <table>
        <thead>
        <tr>
          <th style="text-align: center;" width="15%">检验项目</th>
          <th style="text-align: center;" width="50%">检验描述</th>
          <th style="text-align: center;" width="20%">记录(点击)</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="(item, index) in tableData" :key="index">
          <td>{{ item.projName }}</td>
          <td>
            <view v-if="item.result=='合格'" class="watermark approved">合格</view>
            <view v-if="item.result=='不合格'" class="watermark rejected">不合格</view>
            <view v-if="item.result=='未完成'" class="watermark pending">待确认</view>
            <view class="description-text">{{ item.itemMod }}</view>
          </td>
          <td>
            <button v-if="item.isCheck < item.levelNum" class="record-btn record-btn-fill"
                    @click="toDetail(item, index)">
              填写 <!--({{ item.isCheck }}/{{ item.levelNum }})-->
            </button>
            <button v-else class="record-btn record-btn-view" @click="toDetail(item, index)">
              查看<!--({{ item.isCheck }}/{{ item.levelNum }})-->
            </button>
          </td>
        </tr>
        </tbody>
      </table>
    </view>
         <view class="info-block">
    <!-- 操作按钮区 -->
    <view class="action-buttons">
      <button v-if="isUpdate && !isShowTable" class="secondary-btn" @click="save">创建检验单并生成部分默认值</button>
      <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="uploadImages">查看所有图片</button>
      <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="addDefectDescription">查看不良描述</button>
   <!--  <button v-if="!isUpdate && !formData.statusUser && !isShowTable" class="secondary-btn" @click="removeXJ">
        删除单据
      </button> -->
      <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="saveRemarks">添加备注</button>
      <button v-if="!isUpdate && !isShowTable && formData.fSubmit != 1" class="primary-btn" @click="submit">检验提交</button>
   <!--   <button  class="secondary-btn" @click="getTable">获取检验项目</button> -->
<!--      <button v-if="isShowTable && isUpdate" class="primary-btn" @click="saveTable">生成检验项目</button> -->
    </view>
            <view class="info-label" v-if="formData.extendNo1!=null">技改状态:</view>
            <view class="info-value" v-if="formData.extendNo1!=null">{{formData.extendNo1}}</view>
            <!-- <view class="info-label">项目:</view>
      <view class="info-value">{{formData.projectCodes}}</view> -->
            <view class="info-label">数量:</view>
            <view class="info-value highlight">{{formData.daa008}}</view>
         </view>
         <view class="info-block" v-if="formData.fngDesc!=null">
            <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="action-buttons" v-if="this.current" >
      <button class="secondary-btn" @click="getInspectionItems">获取检验项目</button>
    </view> -->
      <!-- 检验项目表格 -->
      <view class="inspection-table">
         <table>
            <thead>
               <tr>
                  <th width="15%" style="text-align: center;">检验项目</th>
                  <th width="50%" style="text-align: center;">质量要求</th>
                  <th width="20%" style="text-align: center;">记录(点击)</th>
               </tr>
            </thead>
            <tbody>
               <tr v-for="(item, index) in tableData" :key="index">
                  <td>{{ item.projName }}</td>
                  <td>
                     <view v-if="item.result=='合格'" class="watermark approved">{{ getStatusText(item.result) }}
                     </view>
                     <view v-if="item.result=='不合格'" class="watermark rejected">{{ getStatusText(item.result) }}
                     </view>
                     <view v-if="item.result=='未完成'" class="watermark pending">{{ getStatusText(item.result) }}
                     </view>
                     <view class="description-text">{{ item.itemMod }}</view>
                  </td>
                  <td>
                     <button v-if="item.current" class="record-btn" @click="fillRecord(item,index)">填写</button>
                     <button v-if="!item.current" class="record-btn" @click="fillRecord(item,index)">查看</button>
                  </td>
               </tr>
            </tbody>
         </table>
      </view>
      <!-- 操作按钮区 -->
      <view class="action-buttons">
         <button class="secondary-btn" @click="uploadImages">上传/查看图片</button>
         <button class="secondary-btn" @click="addDefectDescription" v-if="this.current">添加不良描述</button>
         <!-- 首检这边会填完检验项目自动提交,不用写提交逻辑 -->
         <!-- <button class="primary-btn" @click="submitInspection" v-if="this.current">检验提交</button> -->
      </view>
      <view v-if="remarksPopup" class="overlay">
         <view class="popup">
            <h3>修改不合格描述</h3>
            <form>
               <view class="form-group">
                  <label class="form-label">不合格描述:</label>
                  <input class="form-input" type="text" v-model="remarks" />
               </view>
            </form>
            <button class="updateBut" @click="editRemarks">修改</button>
            <button @click="remarksPopup = !remarksPopup">取消</button>
         </view>
      </view>
   </view>
    <!-- 弹窗 -->
    <view v-if="remarksPopup" class="overlay">
      <view class="popup">
        <h3>修改备注</h3>
        <form>
          <view class="form-group">
            <label class="form-label">备注:</label>
            <textarea v-model="remarks" class="form-input form-textarea" placeholder="请输入备注信息..."></textarea>
          </view>
          <button class="updateBut" @click="editRemarks">修改</button>
          <button @click="remarksPopup = !remarksPopup">取消</button>
        </form>
      </view>
    </view>
  </view>
</template>
<script>
   export default {
      data() {
         return {
            formData: {
               id: "",
               releaseNo: "",
               createBy: "",
               createDate: "",
               lotNo: "",
               itemNo: "",
               billNo: "",
               fcovertQty: "",
               detailMem: "",
               taskNo: "",
               fcheckResu: "",
               boardModel: "",
               planQty: "",
               mocode: "",
               boardStyle: ""
            },
            tableData: [],
            remarksPopup: false,
            current: true
         }
      },
      onLoad(options) {
         //options中包含了url附带的参数
         let params = options;
export default {
  data() {
    return {
      formData: {
        createTime: "",
        id: "",
        billNo: "",
        itemNo: "",
        itemName: "",
        workshopCode: "",
        workshopName: "",
        line: "",
        lineName: "",
        comments: "",
        statusUser: "",
        itemId: "",
        fSubmit: 0,
        yzxChecked: false, // 添加一致性核对状态字段
      },
         if (params["id"]) {
            this.formData.id = params["id"];
            this.formData.releaseNo = params["releaseNo"];
            this.formData.lotNo = params["lotNo"];
            this.msgId = params["msgId"];
      DAA020List: [],
            if (params["current"] === 'A') {
               this.current = true;
            } else if (params["current"] === 'B') {
               this.current = false;
            }
      DAA001List: [],
      schemeResult: [],
      DAA001Index: -1,
            if (this.msgId > 0) {
               this.msgRead();
            }
      ItemList: [],
         } else {
            //初始化检验单号
            this.$post({
               url: "/LLJ/getMaxReleaseNo"
            }).then(res => {
               this.formData.releaseNo = res.data.tbBillList;
               this.formData.createBy = this.$loginInfo.account;
               this.formData.createDate = this.$getDate("yyyy-mm-dd");
            });
      boardItems: [],
         }
      womdaaList: [],
      },
      methods: {
         getStatusText(status) {
            const statusMap = {
               approved: '合格',
               rejected: '不合格',
               pending: '待确认'
            }
            if (status == '未完成') {
               return statusMap['pending'] || ''
            } else if (status == '合格') {
               return statusMap['approved'] || ''
            } else {
               return statusMap['rejected'] || ''
            }
      tableData: [],
         },
         getInspectionItems() {
            // 获取检验项目的逻辑
            this.$post({
               url: "/LLJ/setJYItem",
               data: {
                  itemNo: this.formData.itemNo,
                  quantity: this.formData.fcovertQty,
                  releaseNo: this.formData.releaseNo
               }
            }).then(res => {
               if (res.status == 0) {
                  uni.showToast({
                     title: res.message.toString(),
                     //将值设置为 success 或者直接不用写icon这个参数
                     icon: 'success',
                     //显示持续时间为 2秒
                     duration: 2000
                  })
                  // 如果有页面跳转,需要用定时器延迟
                  setTimeout(() => {
                     this.init();
                  }, 2000);
      isSubmit: true,
               } else {
                  uni.showToast({
                     title: res.message.toString(),
                     //将值设置为 success 或者直接不用写icon这个参数
                     icon: 'error',
                     //显示持续时间为 2秒
                     duration: 2000
                  })
               }
            });
         },
         fillRecord(item, index) {
            // 填写记录的逻辑
            uni.navigateTo({
               url: 'detail?mainId=' + item.id + '&formID=' + this.formData.id + '&releaseNo=' + this.formData
                  .billNo + '&index=' + index + '&current=' + this.current
            });
         },
         uploadImages() {
            // 上传/查看图片的逻辑
            uni.navigateTo({
               url: 'ImageItem?id=' + this.formData.id
            });
         },
         addDefectDescription() {
            // 添加不良描述的逻辑
            this.remarksPopup = !this.remarksPopup;
            this.remarks = this.formData.remarks;
         },
         submitInspection() {
            // 检验提交的逻辑
            this.$post({
               url: "/LLJ/IqcQaSubmit",
               data: {
                  userNo: this.$loginInfo.account,
                  releaseNo: this.formData.releaseNo
               }
            }).then(res => {
               if (res.status == 0) {
      isUpdate: true,
                  uni.showToast({
                     title: res.message.toString(),
                     icon: 'success',
                     duration: 2000
                  })
                  // 如果有页面跳转,需要用定时器延迟
                  setTimeout(() => {
                     uni.navigateTo({
                        url: 'List'
                     });
                  }, 2000); // 保持与 duration 相同的时长
      isShowTable: false,
               } else {
                  uni.showModal({
                     title: "提示",
                     content: res.message.toString(),
                     confirmText: "确定",
                     showCancel: false,
                     success: (res) => {
      remarks: "",
      remarksPopup: false,
                     }
                  })
               }
            })
         },
         onShow() {
            //每次进入页面都会执行的方法
            if (this.formData.id) {
               this.init();
            }
         },
         init() {
            let userName = this.$loginInfo.account;
      comments: "",
      commentsPopup: false,
      current: true,
            this.$post({
               url: "/SJ/GetPage",
               data: {
                  pageIndex: 1,
                  limit: 1,
                  id: this.formData.id
               }
            }).then(res => {
               let data = res.data.tbBillList[0];
               if (data) {
                  this.formData = data;
    };
  },
  onLoad(options) {
    //options中包含了url附带的参数
                  this.$post({
                     url: "/SJ/getQSItems",
                     data: {
                        pid: this.formData.id
                     }
                  }).then(res1 => {
                     let tableData = res1.data.tbBillList
                     //当已检验个数都不为空时按照检测结构排序
                     tableData.sort((a, b) => {
                        if (a.result === '未完成' && b.result === '合格') {
                           return -1;
                        } else if (a.result === '合格' && b.result === '未完成') {
                           return 1;
                        } else {
                           return 0;
                        }
                     });
                     this.tableData = tableData;
                     if (this.tableData.length === 0) {
                        this.isShowTable = true;
                     }
                     this.tableData.forEach((item, index) => {
                        this.$set(item, 'current', this.current);
                     });
                  })
               }
            });
         },
         msgRead() {
            msgRead(this.msgId, this.$loginInfo.account);
         },
         //去文件列表页面(文件类型,物料编号)
         toFileUrlByU9List(type, u9No) {
            if (type === 1) {
               uni.navigateTo({
                  url: 'FileUrlByU9List?type=' + type + '&itemID=' + u9No
               });
            } else {
               uni.navigateTo({
                  url: 'FileUrlByU9List2?type=' + type + '&itemID=' + u9No
               });
            }
         },
         editRemarks() {
            if (this.remarks) {
               //saveRemarksGid
               this.$post({
                  url: "/SJ/saveRemarksGid",
                  data: {
                     gid: this.formData.id,
                     remarks: this.remarks
                  }
               }).then(res => {
                  if (res.data.tbBillList > 0) {
                     this.formData.remarks = this.remarks;
                     this.remarksPopup = !this.remarksPopup;
                     this.$showMessage("保存成功");
                  }
               })
            } else {
               this.$post({
                  url: "/SJ/saveRemarksGid",
                  data: {
                     gid: this.formData.id,
                     remarks: ''
                  }
               }).then(res => {
                  if (res.data.tbBillList > 0) {
                     this.formData.remarks = this.remarks;
                     this.remarksPopup = !this.remarksPopup;
                     this.$showMessage("保存成功");
                  }
               })
            }
         },
    let params = options;
   if(params["current"]==='A')
      {
         this.current=true;
      }else if(params["current"]==='B'){
         this.current=false;
      }
   }
    if (params["id"]) {
      this.isUpdate = false;
      this.formData.id = params["id"];
      this.formData.billNo = params["billNo"];
      this.init();
    } else {
      //初始化检验单号
      this.$post({
        url: "/SJ/GetMaxBillNo"
      }).then(res => {
        this.formData.billNo = res.data.tbBillList;
        this.formData.createTime = this.$getDate("yyyy-mm-dd");
      });
      //产品编码下拉框的初始化
      this.$post({
        url: "/XJ/getLineAll"
      }).then(res => {
        this.lineList = res.data.tbBillList;
        this.DAA020List = res.data.tbBillList.map(item => item.lineName);
        this.formData.itemNo = "";
        this.formData.itemName = "";
        this.formData.workshopCode = "";
        this.formData.workshopName = "";
        this.formData.line = "";
        this.formData.lineName = "";
        this.formData.pbaid = null;
      })
    }
  },
  methods: {
    // 获取合格项目数量
    getPassedCount() {
      return this.tableData.filter(item => item.result === '合格').length;
    },
    // 获取不合格项目数量
    getFailedCount() {
      return this.tableData.filter(item => item.result === '不合格').length;
    },
    // 获取待检验项目数量
    getPendingCount() {
      return this.tableData.filter(item => item.result === '未完成').length;
    },
    removeXJ() {
      if (this.formData.id) {
        this.$post({
          url: "/SJ/removeSJ",
          data: {
            id: this.formData.id
          }
        }).then(res => {
          if (res.data.tbBillList > 0) {
            this.$showMessage("删除成功");
            //关闭当前页面,返回上一页面或多级页面
            uni.navigateBack();
          } else {
            this.$showMessage("删除失败");
          }
        });
      } else {
        this.$showMessage("请先选择检验单号");
      }
    },
    submit() {
      // 检查是否需要一致性核对
      if (this.current && !this.formData.yzxChecked) {
        // 先检查该物料是否维护了一致性核对项目
        this.$post({
          url: "/SJ/getYzxItem",
          data: {
            id: this.formData.id
          }
        }).then(res => {
          // 如果维护了一致性核对项目(components.length > 0),则要求完成核对
          if (res.data && res.data.length > 0) {
            uni.showModal({
              title: "提示",
              content: "请先完成一致性核对后再提交检验",
              confirmText: "去核对",
              cancelText: "取消",
              success: (modalRes) => {
                if (modalRes.confirm) {
                  this.toYzxSubmitFrom(this.formData.billNo);
                }
              }
            });
          } else {
            // 未维护一致性核对项目,允许直接提交
            this.submitInspection();
          }
        }).catch(() => {
          // 接口异常,允许提交
          this.submitInspection();
        });
        return;
      }
      // 已完成一致性核对或不需要核对,直接提交
      this.submitInspection();
    },
    submitInspection() {
      this.$post({
        url: "/SJ/SJQaSubmit",
        data: {
          userNo: this.$loginInfo.account,
          gid: this.formData.id
        }
      }).then(res => {
        //2024-11-28 kyy 校验合格提交增加提示
        console.log("完整响应数据:", res);
        console.log("Status Code的值:", res.statusCode);
        console.log("返回的数据:", res.data);
        // 检查多种成功条件
        if (res.statusCode === 200 || res.status === 0 || res.data === true || res.data.tbBillList === true) {
          this.$showMessage("成功提交检验");
          // 提交成功后刷新页面数据
          this.init();
          // 1.5秒后跳转到列表页面
          setTimeout(() => {
            uni.navigateTo({
              url: '/pages/QC/SJ/List'
            });
          }, 1500);
        } else {
          this.$showMessage(res.data.message || res.message || "提交失败");
        }
      }).catch(err => {
        console.log("提交出错:", err);
        this.$showMessage("提交失败,请重试");
      })
    },
    init() {
      if (this.formData.id) {
        this.$post({
          url: "/SJ/GetPage",
          data: {
            pageIndex: 1,
            limit: 1,
            id: this.formData.id
          }
        }).then(res => {
          let tbBillListElement = res.data.tbBillList[0];
          if (tbBillListElement) {
            // 保存当前的yzxChecked状态
            const currentYzxChecked = this.formData.yzxChecked;
            this.formData = tbBillListElement;
            // 恢复yzxChecked状态,避免被服务器数据覆盖
            this.formData.yzxChecked = currentYzxChecked;
            this.$post({
              url: "/SJ/getQSItems",
              data: {
                pid: this.formData.id
              }
            }).then(res => {
              this.tableData = res.data.tbBillList;
              this.tableData.sort((a, b) => {
                if (a.result === '未完成' && b.result === '合格') {
                  return -1;
                } else if (a.result === '合格' && b.result === '未完成') {
                  return 1;
                } else {
                  return 0;
                }
              });
              if (this.tableData.length <= 0) {
                this.isShowTable = true;
              }
            })
          }
        })
      }
    },
    onDaa020Change(event) {
      //获取生产线别的下标地址
      //this.formData.line = event;
      this.lineNo = this.lineList[this.DAA020List.indexOf(event)].lineNo;
      this.formData.line = this.lineNo;
      this.$post({
        url: "/XJ/getBoardItem",
        data: {
          lineNo: this.lineNo
        }
      }).then(res => {
        //填充工单号的数据源
        this.boardItems = res.data.tbBillList;
        this.ItemList = this.boardItems.map(item => item.itemName);
      })
    },
    onItemChange(event) {
      this.formData.itemNo = event.itemNo;
      this.$post({
        url: "/XJ/getDaa001",
        data: {
          daa020: this.lineNo,
          item: this.formData.itemNo
        }
      }).then(res => {
        //填充工单号的数据源
        this.schemeResult = res.data.tbBillList;
        this.DAA001List = this.schemeResult.map(s => s.daa001);
        //变为默认空值的状态
        this.DAA001Index = -1;
        this.formData.daa001 = "";
      })
    },
    //选取工单填充物料号和其他信息
    onDaa001Change(event) {
      this.DAA001Index = event.mp.detail.value;
      this.formData.daa001 = this.schemeResult[this.DAA001Index].daa001;
      //表单中的部分字段赋值
      this.$post({
        url: "/XJ/getItem",
        data: {
          daa001: this.formData.daa001
        }
      }).then(res => {
        let data = res.data.tbBillList[0];
        //当返回的结果集为空时置空原有的值
        if (!data) {
          this.formData.billNo = "";
          this.formData.taskNo = "";
          this.formData.itemNo = "";
          this.tableData = [];
          return;
        }
        //不为空时赋值
        this.formData.daa001 = data.daa001;
        this.formData.daa003 = data.daa003;
        this.formData.daa004 = data.daa004;
        this.formData.daa008 = data.daa008;
        this.formData.pbaid = data.id;
        this.$post({
          url: "/SJ/SetQSItems",
          data: {
            itemNo: this.formData.itemNo
          }
        }).then(res => {
          if (res.data.tbBillList.length > 0) {
            this.tableData = res.data.tbBillList; // 在箭头函数中,this 指向外层作用域的 this
            this.isSubmit = false;
          } else {
            this.$showMessage("此物料没有启用的检验项目,请维护!");
            this.isSubmit = true;
            this.tableData = [];
          }
        });
      });
    },
    toDetail(item, index) {
      if (this.isUpdate) {
        uni.showToast({
          icon: "none",
          title: "请先生成检验项目",
          duration: 2000,
        });
      } else {
        uni.navigateTo({
          url: 'detail?id=' + item.id + '&billNo=' + this.formData.billNo + '&gid=' + this.formData
              .id + '&index=' + index
        });
      }
    },
    getTable() {
      this.$post({
        url: "/SJ/SetQSItems",
        data: {
          itemNo: this.formData.itemNo
        }
      }).then(res => {
        if (res.data.tbBillList.length > 0) {
          this.tableData = res.data.tbBillList; // 在箭头函数中,this 指向外层作用域的 this
          this.isShowTable = true;
          this.isUpdate = true;
        //生成检验项目
        if (this.tableData.length === 0) {
          return;
        }
        this.$post({
          url: "/SJ/SaveItem",
          data: {
            gid: this.formData.id,
            items: this.tableData,
            statusUser: this.$loginInfo.account,
           ItemNo:this.formData.itemNo
          }
        }).then(res => {
          this.tableData = res.data.tbBillList.items;
          this.isShowTable = false;
          this.isUpdate = false;
        })
        } else {
          this.$showMessage("此物料没有启用的检验项目,请维护!");
          this.isShowTable = true;
          this.isUpdate = false;
          this.tableData = [];
        }
      });
    },
    saveTable() {
      if (this.tableData.length === 0) {
        return;
      }
      this.$post({
        url: "/SJ/SaveItem",
        data: {
          gid: this.formData.id,
          items: this.tableData,
          statusUser: this.$loginInfo.account
        }
      }).then(res => {
        this.tableData = res.data.tbBillList.items;
        this.isShowTable = false;
        this.isUpdate = false;
      })
    },
      toYzxSubmitFrom(releaseNo){
         uni.navigateTo({
            url: 'yzxFrom?id=' +this.formData.id+'&current='+(this.current ? 'true' : 'false')
         });
      },
      toSNScanCode(releaseNo){
         uni.navigateTo({
            url: 'ScanCode?id=' +this.formData.id+'&current='+(this.current ? 'true' : 'false')
         });
      },
    save() {
      // if (this.tableData.length === 0) {
      //    this.$showMessage(this.formData.itemNo + "物料没有检验项目");
      //    return;
      // }
      if (!this.formData.daa001) {
        this.$showMessage("请选择计划编号");
        return;
      }
      this.formData.statusUser = this.$loginInfo.account;
      this.$post({
        url: "/SJ/Save",
        data: {
          from: this.formData,
          items: this.tableData
        }
      }).then(res => {
        this.formData = res.data.tbBillList.result;
        this.tableData = res.data.tbBillList.items;
        this.isUpdate = false;
      })
    },
    saveRemarks() {
      this.remarksPopup = !this.remarksPopup;
      this.remarks = this.formData.remarks;
    },
    saveComments() {
      this.commentsPopup = !this.commentsPopup;
      this.comments = this.formData.comments;
    },
    editRemarks() {
      if (this.remarks) {
        //saveRemarksGid
        this.$post({
          url: "/SJ/saveRemarksGid",
          data: {
            gid: this.formData.id,
            remarks: this.remarks
          }
        }).then(res => {
          if (res.data.tbBillList > 0) {
            this.formData.remarks = this.remarks;
            this.remarksPopup = !this.remarksPopup;
            this.$showMessage("保存成功");
          }
        })
      }
    },
    editComments() {
      if (this.comments) {
        //saveRemarksGid
        this.$post({
          url: "/SJ/saveCommentGid",
          data: {
            gid: this.formData.id,
            comments: this.comments
          }
        }).then(res => {
          if (res.data.tbBillList > 0) {
            this.formData.comments = this.comments;
            this.commentsPopup = !this.commentsPopup;
            this.$showMessage("保存成功");
          }
        })
      }
    },
    uploadImages() {
      // 查看所有图片的逻辑
      console.log('点击了查看所有图片按钮,billNo:', this.formData.billNo);
      uni.navigateTo({
        url: 'ImageItemALL?id=' + this.formData.id
      });
    },
    addDefectDescription() {
      // 查看所有不良描述的逻辑
      console.log('点击了查看不良描述按钮,billNo:', this.formData.billNo);
      uni.navigateTo({
        url: 'Blms?id=' + this.formData.id
      });
    }
  },
  onShow() {
    // 每次进入页面都会执行的方法
    // 注释掉init()调用,避免覆盖一致性核对状态
    // this.init();
  }
};
</script>
<style>
   /* 基础样式 */
   .inspection-sheet {
      font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
      max-width: 1000px;
      margin: 0 auto;
      padding: 20px;
      background-color: #fff;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
   }
/* 基础样式 */
.inspection-sheet {
  font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  background-color: #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
   /* 头部样式 */
   .sheet-header {
      text-align: center;
      margin-bottom: 20px;
      padding-bottom: 15px;
      border-bottom: 2px solid #e0e0e0;
   }
/* 头部样式 */
.sheet-header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e0e0e0;
}
   .sheet-header h1 {
      color: #2c3e50;
      font-size: 24px;
      margin-bottom: 5px;
   }
.sheet-header h1 {
  color: #2c3e50;
  font-size: 24px;
  margin-bottom: 5px;
}
   .inspection-number {
      font-size: 16px;
      font-weight: bold;
      color: #3498db;
   }
.inspection-number {
  font-size: 16px;
  font-weight: bold;
  color: #3498db;
}
   /* 基本信息区样式 */
   .basic-info,
   .material-info {
      margin-bottom: 20px;
   }
/* 基本信息区样式 */
.basic-info,
.material-info {
  margin-bottom: 20px;
}
   .info-row {
      display: flex;
      margin-bottom: 10px;
      flex-wrap: wrap;
   }
.info-row {
  display: flex;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
   .info-label {
      font-weight: bold;
      color: #34495e;
      min-width: 80px;
      margin-right: 5px;
   }
.info-label {
  font-weight: bold;
  color: #34495e;
  min-width: 80px;
  margin-right: 5px;
}
   .info-value {
      color: #2c3e50;
      margin-right: 20px;
   }
.info-value {
  color: #2c3e50;
  margin-right: 20px;
}
   .highlight {
      font-weight: bold;
      color: #e74c3c;
   }
.highlight {
  font-weight: bold;
  color: #e74c3c;
}
   /* 物料信息区样式 */
   .material-info {
      border: 1px solid #eee;
      padding: 15px;
      border-radius: 5px;
   }
/* 物料信息区样式 */
.material-info {
  border: 1px solid #eee;
  padding: 15px;
  border-radius: 5px;
}
   .info-block {
      display: flex;
      align-items: center;
      margin-bottom: 10px;
      flex-wrap: wrap;
   }
.info-block {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
   .doc-links {
      margin-left: auto;
   }
.info-value-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  background: #ffffff;
  font-size: 14px;
  margin-top: 6px;
}
   .doc-link {
      color: #3498db;
      text-decoration: none;
      margin-left: 15px;
      padding: 3px 8px;
      border: 1px solid #3498db;
      border-radius: 3px;
      font-size: 12px;
   }
.picker {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  background: #ffffff;
  font-size: 14px;
  margin-top: 6px;
}
   .sysLike {
      color: #3498db;
      text-decoration: none;
      margin-left: 15px;
      padding: 3px 8px;
      border-radius: 3px;
      font-size: 12px;
   }
/* 表格样式 */
.inspection-table {
  margin: 25px 0;
}
   .doc-link:hover {
      background-color: #f0f8ff;
   }
.inspection-table table {
  width: 100%;
  border-collapse: collapse;
}
   /* 表格样式 */
   .inspection-table {
      margin: 25px 0;
   }
.inspection-table th, .inspection-table td {
  padding: 12px 15px;
  border: 1px solid #ddd;
  text-align: left;
}
   .inspection-table table {
      width: 100%;
      border-collapse: collapse;
   }
.inspection-table th {
  background-color: #f8f9fa;
  font-weight: bold;
  color: #34495e;
}
   .inspection-table th,
   .inspection-table td {
      padding: 12px 15px;
      border: 1px solid #ddd;
      text-align: left;
   }
.inspection-table tr:nth-child(even) {
  background-color: #f9f9f9;
}
   .inspection-table th {
      background-color: #f8f9fa;
      font-weight: bold;
      color: #34495e;
   }
.inspection-table tr:hover {
  background-color: #f1f5f9;
}
   .inspection-table tr:nth-child(even) {
      background-color: #f9f9f9;
   }
/* 检验描述列特殊样式 */
.inspection-table td:nth-child(2) {
  position: relative;
  overflow: hidden;
  padding: 0;
}
   .inspection-table tr:hover {
      background-color: #f1f5f9;
   }
/* 按钮样式 */
.action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
   /* 按钮样式 */
   .action-buttons {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      margin-top: 20px;
   }
.primary-btn,
.secondary-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
}
   .primary-btn,
   .secondary-btn {
      padding: 10px 20px;
      border: none;
      border-radius: 4px;
      font-size: 14px;
      cursor: pointer;
      transition: all 0.3s;
   }
.primary-btn {
  background-color: #3498db;
  color: white;
}
   .primary-btn {
      background-color: #3498db;
      color: white;
   }
.primary-btn:hover {
  background-color: #2980b9;
}
   .primary-btn:hover {
      background-color: #2980b9;
   }
.secondary-btn {
  background-color: #ecf0f1;
  color: #7f8c8d;
}
   .secondary-btn {
      background-color: #ecf0f1;
      color: #7f8c8d;
   }
.secondary-btn:hover {
  background-color: #d5dbdb;
}
   .secondary-btn:hover {
      background-color: #d5dbdb;
   }
.record-btn {
  padding: 6px 12px;
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: all 0.2s;
}
   .record-btn {
      padding: 6px 12px;
      background-color: #f8f9fa;
      border: 1px solid #ddd;
      /* border-radius: 3px; */
      cursor: pointer;
      transition: all 0.2s;
   }
.record-btn:hover {
  background-color: #e9ecef;
}
   .record-btn:hover {
      background-color: #e9ecef;
   }
/* 填写状态按钮 */
.record-btn-fill {
  background-color: #f8f9fa;
  border: 1px solid #ddd;
}
   /* 水印样式 */
   .watermark {
      position: absolute;
      font-size: 40px;
      font-weight: bold;
      opacity: 1;
      z-index: 1;
      pointer-events: none;
      transform: rotate(-15deg);
      width: 100%;
      text-align: center;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) rotate(-15deg);
   }
.record-btn-fill:hover {
  background-color: #e9ecef;
}
   .watermark.approved {
      color: #2ecc71;
      /* 绿色 */
   }
/* 查看状态按钮 */
.record-btn-view {
  background-color: #f8f9fa;
  border: 1px solid #ddd;
}
   .watermark.rejected {
      color: #e74c3c;
      /* 红色 */
   }
.record-btn-view:hover {
  background-color: #e9ecef;
}
   .watermark.pending {
      color: #f39c12;
      /* 橙色 */
   }
/* 水印样式 */
.watermark {
  position: absolute;
  font-size: 40px;
  font-weight: bold;
  opacity: 1;
  z-index: 1;
  pointer-events: none;
  transform: rotate(-15deg);
  width: 100%;
  text-align: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-15deg);
}
   /* 描述文本容器 */
   .description-text {
      position: relative;
      z-index: 2;
      padding: 25px;
      background-color: rgba(255, 255, 255, 0.7);
   }
.watermark.approved {
  color: #2ecc71; /* 绿色 */
}
   /* 调整表格单元格 */
   .inspection-table td:nth-child(2) {
      position: relative;
      overflow: hidden;
      padding: 0;
   }
.watermark.rejected {
  color: #e74c3c; /* 红色 */
}
   .overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5);
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 10;
   }
.watermark.pending {
  color: #f39c12; /* 橙色 */
}
   .popup {
      background-color: #fff;
      padding: 20px;
      border: 1px solid #ccc;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      width: 68vw;
      /* 设置宽度为视口宽度的80% */
      height: 25vh;
      /* 设置高度为视口高度的80% */
   }
/* 描述文本容器 */
.description-text {
  position: relative;
  z-index: 2;
  padding: 25px;
  background-color: rgba(255, 255, 255, 0.7);
}
   .form-group {
      display: flex;
      align-items: center;
      border-bottom: 1px solid #c9c9c9;
   }
.sysLike {
  color: #3498db;
  text-decoration: none;
  margin-left: 15px;
  padding: 3px 8px;
  border: 1px solid #3498db;
  border-radius: 3px;
  font-size: 12px;
}
   .updateBut {
      background-color: #3498db;
      color: white;
   }
.sysLike:hover {
  background-color: #f0f8ff;
}
   /* 响应式设计 */
   @media (max-width: 500px) {
/* 弹出层样式 */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}
      .info-row,
      .info-block {
         flex-direction: column;
         align-items: flex-start;
      }
.popup {
  background-color: #fff;
  padding: 20px;
  border: 1px solid #ccc;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  width: 85vw;
  min-height: 35vh;
  max-height: 60vh;
  border-radius: 8px;
}
      .doc-links {
         margin-left: 0;
         margin-top: 10px;
      }
.popup h3 {
  margin-top: 0;
  color: #2c3e50;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
  margin-bottom: 15px;
  font-size: 16px;
  text-align: center;
}
      .action-buttons {
         flex-direction: column;
      }
.popup .form-group {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}
      .inspection-table table {
         display: block;
         overflow-x: auto;
      }
   }
.popup .form-label {
  margin-bottom: 5px;
  font-weight: bold;
  font-size: 14px;
}
.popup .form-input {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
}
.popup .form-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}
.popup-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.updateBut {
  background-color: #3498db;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 4px;
  margin-right: 10px;
  cursor: pointer;
  transition: all 0.3s;
}
.updateBut:hover {
  background-color: #2980b9;
}
/* 响应式设计 */
@media (max-width: 500px) {
  .info-row,
  .info-block {
    flex-direction: column;
    align-items: flex-start;
  }
  .doc-links {
    margin-left: 0;
    margin-top: 10px;
  }
  .action-buttons {
    flex-direction: column;
  }
  .inspection-table table {
    display: block;
    overflow-x: auto;
  }
}
</style>