啊鑫
昨天 4606f230a2c64fef2f54f61a35e67acd087df51c
pages/QC/LLJ/Add.vue
@@ -1,482 +1,987 @@
<template>
   <view>
      <view class="form-container">
         <form :modelValue="formData">
            <view class="form-group">
               <label class="form-label">检验单号:</label>
               <input class="form-input" disabled="true" type="text" v-model="formData.releaseNo" />
            </view>
            <view class="form-group">
               <label class="form-label">到货单号:</label>
               <input class="form-input" disabled="true" type="text" v-model="formData.lotNo" />
            </view>
            <!--  <view class="form-group">
          <label class="form-label">创建人:</label>
          <input class="form-input" disabled="true" type="text" v-model="formData.createBy"/>
        </view>-->
            <view class="form-group">
               <label class="form-label">创建时间:</label>
               <input class="form-input" disabled="true" type="text" v-model="formData.createDate" />
            </view>
            <view class="form-group">
               <label class="form-label">物料编码:</label>
               <input class="form-input" disabled="true" type="text" v-model="formData.itemNo" />
            </view>
            <view class="form-group">
               <label class="form-label">物料名称:</label>
               <input class="form-input" disabled="true" type="text" v-model="formData.itemName" />
            </view>
            <view class="form-group">
               <label class="form-label">规格型号:</label>
               <input class="form-input" disabled="true" type="text" v-model="formData.itemModel" />
            </view>
            <view class="form-group">
               <label class="form-label">数量:</label>
               <input class="form-input" disabled="true" type="text" v-model="formData.fcovertQty" />
            </view>
            <view class="form-group">
               <label class="form-label">不合格描述:</label>
               <input class="form-input" disabled="true" type="text" v-model="formData.remarks" />
            </view>
         </form>
      </view>
  <view class="page-container">
    <!-- 表单卡片 -->
    <view class="form-card">
      <view class="form-title">
        <view class="title-icon">📋</view>
        <span>检验单信息</span>
      </view>
      <view class="form-container">
        <form :modelValue="formData">
          <view class="form-grid">
            <view class="form-group">
              <label class="form-label">检验单号:</label>
              <input class="form-input" disabled="true" type="text" v-model="formData.releaseNo" />
            </view>
            <view class="form-group">
              <label class="form-label">到货单号:</label>
              <input class="form-input" disabled="true" type="text" v-model="formData.lotNo" />
            </view>
            <view class="form-group">
              <label class="form-label">创建时间:</label>
              <input class="form-input" disabled="true" type="text" v-model="formData.createDate" />
            </view>
            <view class="form-group">
              <label class="form-label">物料编码:</label>
              <input class="form-input" disabled="true" type="text" v-model="formData.itemNo" />
            </view>
            <view class="form-group">
              <label class="form-label">物料名称:</label>
              <input class="form-input" disabled="true" type="text" v-model="formData.itemName" />
            </view>
            <view class="form-group">
              <label class="form-label">物料规格:</label>
              <input class="form-input" disabled="true" type="text" v-model="formData.itemModel" />
            </view>
            <view class="form-group">
              <label class="form-label">数量:</label>
              <input class="form-input" disabled="true" type="text" v-model="formData.fcovertQty" />
            </view>
            <view class="form-group">
              <label class="form-label">不合格描述:</label>
              <input class="form-input" disabled="true" type="text" v-model="formData.remarks" />
            </view>
          </view>
        </form>
      </view>
    </view>
      <view class="list-container">
         <uni-table ref="table" border emptyText="暂无更多数据">
            <uni-tr>
               <uni-th align="center" class="th" style="color: #FFFFFF;">检验项目</uni-th>
               <uni-th align="center" class="th" style="color: #FFFFFF">检验描述</uni-th>
               <uni-th align="center" class="th" style="color: #FFFFFF">是否合格</uni-th>
               <uni-th align="center" class="th" style="color: #FFFFFF">记录(点击)</uni-th>
            </uni-tr>
            <uni-tr v-for="(item, index) in tableData" :key="index">
               <uni-td align="center">
                  <input class="form-input" disabled="true" type="text" v-model="item.fcheckItem" />
               </uni-td>
               <uni-td align="center">
                  <input class="form-input" disabled="true" type="text" v-model="item.fcheckItemDesc" />
               </uni-td>
               <uni-td align="center">
                  <input class="form-input" disabled="true" type="text" v-model="item.fcheckResu" />
               </uni-td>
               <uni-td>
                  <view class="uni-group">
                     <button v-if="item.fenterQty >=item.checkQyt" type="default" @click="toDetail(item)">
                        {{ item.checkQyt + '/' + item.fenterQty }}
                     </button>
                     <button v-else type="warn" @click="toDetail(item)">
                        {{ item.checkQyt + '/' + item.fenterQty }}
                     </button>
                  </view>
               </uni-td>
            </uni-tr>
         </uni-table>
      </view>
    <!-- 检验项目卡片 -->
    <view class="table-card">
      <view class="table-title">
        <view class="title-icon">🔍</view>
        <span>检验项目</span>
      </view>
      <view class="list-container">
        <uni-table ref="table" border emptyText="暂无更多数据">
          <uni-tr>
            <uni-th align="center" class="th">检验项目</uni-th>
            <uni-th align="center" class="th">检验描述</uni-th>
            <uni-th align="center" class="th">是否合格</uni-th>
            <uni-th align="center" class="th">记录(点击)</uni-th>
          </uni-tr>
          <uni-tr v-for="(item, index) in tableData" :key="index" class="table-row" :class="{ 'hover-effect': isHoveringRow === index }" @mouseenter="isHoveringRow = index" @mouseleave="isHoveringRow = -1">
            <uni-td align="center">
              <input class="form-input" disabled="true" type="text" v-model="item.fcheckItem" />
            </uni-td>
            <uni-td align="center">
              <view class="value-with-tooltip cursor-pointer"
                    @click.stop="showTooltip(item.fcheckItemDesc, $event, item.fcheckItem)">
                <input class="form-input" disabled="true" type="text" v-model="item.fcheckItemDesc" />
              </view>
            </uni-td>
            <uni-td align="center">
              <span class="result-badge" :class="{ 'pass': item.fcheckResu === '合格', 'fail': item.fcheckResu === '不合格', 'pending': item.fcheckResu === '未检验' }">
                {{ item.fcheckResu }}
              </span>
            </uni-td>
            <uni-td>
              <view class="uni-group">
                <button :class="item.fenterQty >= item.checkQyt ? 'btn-normal' : 'btn-warn'" @click="toDetail(item)">
                  {{ item.checkQyt + '/' + item.fenterQty }}
                </button>
              </view>
            </uni-td>
          </uni-tr>
        </uni-table>
      </view>
    </view>
      <view class="plus-button">
         <view class="plus-button">
            <button type="warn" v-if="!isUpdate && !isShowTable" @click="submit">检验提交</button>
         </view>
    <!-- 操作按钮区域 -->
    <view class="action-buttons">
      <view class="button-group">
        <button :class="['action-btn', { 'btn-primary': !isUpdate && !isShowTable, 'btn-disabled': !canSubmit }]" v-if="!isUpdate && !isShowTable" @click="submit" :disabled="!canSubmit">
          检验提交
        </button>
      </view>
      <view class="button-group">
        <button :class="['action-btn', { 'btn-secondary': isUpdate && !isShowTable, 'btn-disabled': !canGenerate }]" v-if="isUpdate && !isShowTable" @click="getItem" :disabled="!canGenerate">
          创建检验单并生成部分默认值
        </button>
      </view>
      <view class="button-group">
        <button :class="['action-btn', { 'btn-tertiary': !isUpdate && !isShowTable, 'btn-disabled': !canUpload }]" v-if="!isUpdate && !isShowTable" @click="toImage" :disabled="!canUpload">
          上传/查看图片
        </button>
      </view>
      <view class="button-group">
        <button :class="['action-btn', { 'btn-quaternary': !isUpdate && !isShowTable, 'btn-disabled': !canEdit }]" v-if="!isUpdate && !isShowTable" @click="saveRemarks" :disabled="!canEdit">
          添加不合格描述
        </button>
      </view>
      <view class="button-group">
        <button :class="['action-btn', { 'btn-accent': isShowTable, 'btn-disabled': !canGetTable }]" v-if="isShowTable" @click="getTable" :disabled="!canGetTable">
          获取检验项目
        </button>
      </view>
      <view class="button-group">
        <button :class="['action-btn', { 'btn-success': isShowTable && isUpdate, 'btn-disabled': !canSaveTable }]" v-if="isShowTable && isUpdate" @click="saveTable" :disabled="!canSaveTable">
          生成检验项目
        </button>
      </view>
    </view>
         <button type="warn" v-if="isUpdate && !isShowTable" @click="getItem">创建检验单并生成部分默认值</button>
      </view>
      <view class="plus-button">
         <button type="warn" v-if="!isUpdate && !isShowTable" @click="toImage">上传/查看图片</button>
      </view>
      <view class="plus-button">
         <button type="warn" v-if="!isUpdate && !formData.fcheckResu && !isShowTable" @click="removeXJ">删除单据</button>
      </view>
      <view class="plus-button">
         <button type="warn" v-if="!isUpdate && !isShowTable" @click="saveRemarks">添加不合格描述</button>
      </view>
    <!-- 不合格描述弹出层 -->
    <view v-if="remarksPopup" class="overlay active">
      <view class="popup" :class="{ 'popup-scale': isPopupAnimated }" @animationend="isPopupAnimated = false">
        <view class="popup-header">
          <h3 class="popup-title">修改不合格描述</h3>
          <view class="close-btn" @click="remarksPopup = !remarksPopup">×</view>
        </view>
        <form>
          <view class="form-group">
            <label class="form-label">不合格描述:</label>
            <input class="form-input" type="text" v-model="remarks" />
          </view>
          <view class="button-group popup-buttons">
            <button :class="['action-btn', 'btn-danger']" @click="editRemarks">
              修改
            </button>
            <button :class="['action-btn', 'btn-light']" @click="remarksPopup = !remarksPopup">
              取消
            </button>
          </view>
        </form>
      </view>
    </view>
      <view class="plus-button">
         <button type="warn" v-if="isShowTable" @click="getTable">获取检验项目</button>
      </view>
      <view class="plus-button">
         <button type="warn" v-if="isShowTable && isUpdate" @click="saveTable">生成检验项目</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>
               <button type="warn" @click="editRemarks">修改</button>
               <button @click="remarksPopup = !remarksPopup">取消</button>
            </form>
         </view>
      </view>
   </view>
    <!-- 提示框全局组件 -->
    <view v-if="showTooltipBox" class="tooltip-container">
      <view class="tooltip"
            :style="{top: tooltipY + 'px', left: tooltipX + 'px'}"
            :class="{ 'active': tooltipBoxAnimated }">
        <view class="tooltip-content">
          <view class="tooltip-title">{{ tooltipTitle }}</view>
          <view class="tooltip-body">{{ tooltipValue }}</view>
        </view>
        <view class="tooltip-arrow" :style="{ transform: tooltipArrowTransform }"></view>
      </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: "",
               userCode: "",
               itemId: ""
            },
export default {
  data() {
    return {
      formData: {
        id: "",
        releaseNo: "",
        createBy: "",
        createDate: "",
        lotNo: "",
        itemNo: "",
        billNo: "",
        fcovertQty: "",
        detailMem: "",
        taskNo: "",
        fcheckResu: "",
        boardModel: "",
        planQty: "",
        mocode: "",
        boardStyle: "",
        userCode: "",
        itemId: ""
      },
            DAA020List: [],
            DAA020Index: -1,
            DAA001List: [],
            DAA001Index: -1,
            schemeResult: [],
            isShowTable: false,
            ItemList: [],
            ItemIndex: -1,
            boardItems: [],
            lineList: [],
            lineNo: "",
            tableData: [],
            isSubmit: true,
            isUpdate: true,
            remarks: "",
            remarksPopup: false,
         };
      },
      onLoad(options) {
         //options中包含了url附带的参数
      DAA020List: [],
      DAA020Index: -1,
      DAA001List: [],
      DAA001Index: -1,
      schemeResult: [],
      isShowTable: false,
      ItemList: [],
      ItemIndex: -1,
      boardItems: [],
      lineList: [],
      lineNo: "",
      tableData: [],
      isSubmit: true,
      isUpdate: true,
      remarks: "",
      remarksPopup: false,
      isHoveringRow: -1,
      isPopupAnimated: false,
      // 按钮状态控制
      canSubmit: true,
      canGenerate: true,
      canUpload: true,
      canEdit: true,
      canGetTable: true,
      canSaveTable: true,
      // 提示框相关
      showTooltipBox: false,
      tooltipTitle: '',
      tooltipValue: '',
      tooltipX: 0,
      tooltipY: 0,
      tooltipBoxAnimated: false,
      tooltipArrowTransform: 'translateX(-50%) rotate(180deg)'
    };
  },
  onLoad(options) {
    //options中包含了url附带的参数
    let params = options;
         let params = options;
    if (params["id"]) {
      this.isUpdate = false;
      this.formData.id = params["id"];
      this.formData.releaseNo = params["releaseNo"];
      this.formData.lotNo = params["lotNo"];
      console.log(this.formData.lotNo);
      //getQaItemXj02
      this.init();
    } 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");
      });
    }
  },
  methods: {
    removeXJ() {
      if (this.formData.id) {
        this.$post({
          url: "/LLJ/removeXJ",
          data: {
            releaseNo: this.formData.releaseNo
          }
        }).then(res => {
          if (res.data.tbBillList > 0) {
            this.$showMessage("删除成功");
            //关闭当前页面,返回上一页面或多级页面
            uni.navigateBack();
          } else {
            this.$showMessage("删除失败");
          }
        });
      } else {
        this.$showMessage("请先选择检验单号");
      }
    },
    getItem() {
      if (this.isSubmit) {
        this.$showMessage("此物料无启用的检验项目,请维护!");
        return;
      }
         if (params["id"]) {
            this.isUpdate = false;
            this.formData.id = params["id"];
            this.formData.releaseNo = params["releaseNo"];
            this.formData.lotNo = params["lotNo"];
            console.log(this.formData.lotNo);
            //getQaItemXj02
            this.init();
         } 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");
            });
      if (!this.formData.billNo) {
        this.$showMessage("请选择计划编号");
        return;
      }
         }
      },
      methods: {
         removeXJ() {
            if (this.formData.id) {
               this.$post({
                  url: "/LLJ/removeXJ",
                  data: {
                     releaseNo: this.formData.releaseNo
                  }
               }).then(res => {
                  if (res.data.tbBillList > 0) {
                     this.$showMessage("删除成功");
                     //关闭当前页面,返回上一页面或多级页面
                     uni.navigateBack();
                  } else {
                     this.$showMessage("删除失败");
                  }
               });
            } else {
               this.$showMessage("请先选择检验单号");
            }
         },
         getItem() {
      this.$post({
        url: "/XJ/save",
        data: {
          from: this.formData,
          userNo: this.$loginInfo.account,
          items: this.tableData
        }
      }).then(res => {
        this.formData.id = res.data.tbBillList;
        this.$showMessage("生成检验项目成功");
        this.init();
        this.isUpdate = false;
      });
    },
    submit() {
      this.$post({
        url: "/LLJ/IqcQaSubmit",
        data: {
          userNo: this.$loginInfo.account,
          releaseNo: this.formData.releaseNo
        }
      }).then(res => {
        if (res.statusCode === 200) {
          this.$showMessage("成功提交检验");
          setTimeout(() => {
            this.hideCustomMessage();
          }, 7000);
        } else {
          this.$showMessage(res.data.message);
        }
      })
    },
            if (this.isSubmit) {
               this.$showMessage("此物料无启用的检验项目,请维护!");
               return;
            }
    init() {
      //获取当前登录的用户
      let userName = this.$loginInfo.account;
      this.$post({
        url: "/LLJ/getPage",
        data: {
          id: this.formData.id,
          createUser: userName,
          pageIndex: 1,
          limit: 1,
        }
      }).then(res => {
        let data = res.data.tbBillList[0];
        if (data) {
          this.formData = data;
            if (!this.formData.billNo) {
               this.$showMessage("请选择计划编号");
               return;
            }
            this.$post({
               url: "/XJ/save",
               data: {
                  from: this.formData,
                  userNo: this.$loginInfo.account,
                  items: this.tableData
               }
            }).then(res => {
               this.formData.id = res.data.tbBillList;
               this.$showMessage("生成检验项目成功");
               this.init();
               this.isUpdate = false;
            });
         },
         submit() {
            this.$post({
               url: "/LLJ/IqcQaSubmit",
               data: {
                  userNo: this.$loginInfo.account,
                  releaseNo: this.formData.releaseNo
               }
            }).then(res => {
               //console.log(res);
               //2024-11-28 kyy 校验合格提交增加提示
               if (res.statusCode === 200) {
                  this.$showMessage("成功提交检验");
                  // 使用setTimeout在7秒后隐藏消息
                  setTimeout(() => {
                     this.hideCustomMessage();
                  }, 7000); // 7000毫秒等于7秒
               } else {
                  this.$showMessage(res.data.message);
               }
            })
         },
         init() {
            //获取当前登录的用户
            let userName = this.$loginInfo.account;
            this.$post({
               url: "/LLJ/getPage",
               data: {
                  id: this.formData.id,
                  // createUser :this.formData.createUser,
                  createUser: userName,
                  pageIndex: 1,
                  limit: 1,
               }
            }).then(res => {
               let data = res.data.tbBillList[0];
               if (data) {
                  this.formData = data;
                  this.$post({
                     url: "/LLJ/getJYItem",
                     data: {
                        id: this.formData.id,
                        releaseNo: this.formData.releaseNo
                     }
                  }).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;
                     }
                  })
               }
            });
         },
         toDetail(item) {
            if (this.isUpdate) {
               uni.showToast({
                  icon: "none",
                  title: "请先生成检验项目",
                  duration: 2000,
               });
            } else {
               uni.navigateTo({
                  url: 'detail?mainId=' + item.id
               });
            }
         },
         saveRemarks() {
            this.remarksPopup = !this.remarksPopup;
            this.remarks = this.formData.remarks;
         },
         editRemarks() {
            if (this.remarks) {
               //saveRemarksGid
               this.$post({
                  url: "/LLJ/saveRemarksGid",
                  data: {
                     gid: this.formData.id,
                     remarks: this.remarks,
                     releaseNo: this.formData.releaseNo,
                  }
               }).then(res => {
                  if (res.data.tbBillList > 0) {
                     this.formData.remarks = this.remarks;
                     this.remarksPopup = !this.remarksPopup;
                     this.$showMessage("保存成功");
                  }
               })
            }
         },
         toImage() {
            uni.navigateTo({
               url: 'ImageItem?id=' + this.formData.id
            });
         },
         getTable() {
            this.$post({
               url: "/LLJ/setJYItem",
               data: {
                  itemId: this.formData.itemId,
                  quantity: this.formData.fcovertQty,
                  releaseNo: this.formData.releaseNo
               }
            }).then(res => {
               if (res.data.tbBillList.length > 0) {
                  this.tableData = res.data.tbBillList; // 在箭头函数中,this 指向外层作用域的 this
                  this.isShowTable = true;
                  this.isUpdate = true;
               } else {
                  this.$showMessage("此物料没有启用的检验项目,请维护!");
                  this.isShowTable = true;
                  this.isUpdate = false;
                  this.tableData = [];
               }
            });
         },
         saveTable() {
            if (this.tableData.length === 0) {
               return;
            }
            this.$post({
               url: "/LLJ/saveItem",
               data: {
                  releaseNo: this.formData.releaseNo,
                  items: this.tableData,
                  userNo: this.$loginInfo.account,
                  gid: this.formData.id
               }
            }).then(res => {
               this.formData.id = res.data.tbBillList;
               this.isShowTable = false;
               this.isUpdate = false;
               this.init();
            })
         }
      },
      onShow() {
         //每次进入页面都会执行的方法
         if (this.formData.id) {
            this.init();
         }
      }
   };
          this.$post({
            url: "/LLJ/getJYItem",
            data: {
              id: this.formData.id,
              releaseNo: this.formData.releaseNo
            }
          }).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;
            }
          })
        }
      });
    },
    toDetail(item) {
      if (this.isUpdate) {
        uni.showToast({
          icon: "none",
          title: "请先生成检验项目",
          duration: 2000,
        });
      } else {
        uni.navigateTo({
          url: 'detail?mainId=' + item.id
        });
      }
    },
    saveRemarks() {
      // 确保表单数据存在
      if (!this.formData) return;
      this.remarksPopup = !this.remarksPopup;
      this.remarks = this.formData.remarks || '';
      this.isPopupAnimated = true;
    },
    editRemarks() {
      if (this.remarks && this.formData.id) {
        this.$post({
          url: "/LLJ/saveRemarksGid",
          data: {
            gid: this.formData.id,
            remarks: this.remarks,
            releaseNo: this.formData.releaseNo,
          }
        }).then(res => {
          if (res.data.tbBillList > 0) {
            this.formData.remarks = this.remarks;
            this.remarksPopup = false;
            this.$showMessage("保存成功");
          } else {
            this.$showMessage("保存失败");
          }
        }).catch(() => {
          this.$showMessage("保存失败,请重试");
        });
      } else if (!this.formData.id) {
        this.$showMessage("请先生成检验单");
      } else {
        this.$showMessage("请输入不合格描述");
      }
    },
    toImage() {
      uni.navigateTo({
        url: 'ImageItem?id=' + this.formData.id
      });
    },
    getTable() {
      this.$post({
        url: "/LLJ/setJYItem",
        data: {
          itemId: this.formData.itemId,
          quantity: this.formData.fcovertQty,
          releaseNo: this.formData.releaseNo
        }
      }).then(res => {
        if (res.data.tbBillList.length > 0) {
          this.tableData = res.data.tbBillList;
          this.isShowTable = true;
          this.isUpdate = true;
        } else {
          this.$showMessage("此物料没有启用的检验项目,请维护!");
          this.isShowTable = true;
          this.isUpdate = false;
          this.tableData = [];
        }
      });
    },
    saveTable() {
      if (this.tableData.length === 0) {
        return;
      }
      this.$post({
        url: "/LLJ/saveItem",
        data: {
          releaseNo: this.formData.releaseNo,
          items: this.tableData,
          userNo: this.$loginInfo.account,
          gid: this.formData.id
        }
      }).then(res => {
        this.formData.id = res.data.tbBillList;
        this.isShowTable = false;
        this.isUpdate = false;
        this.init();
      })
    },
    // 提示框相关方法
    showTooltip(value, event, title = '') {
      if (!value) return;
      // 防止事件冒泡
      event.stopPropagation();
      // 获取点击位置,支持触摸事件
      const clientX = event.clientX || (event.touches && event.touches[0].clientX) || 0;
      const clientY = event.clientY || (event.touches && event.touches[0].clientY) || 0;
      // 设置提示框内容和位置
      this.tooltipTitle = title;
      this.tooltipValue = value;
      // 计算提示框位置,避免超出屏幕
      const screenWidth = uni.getSystemInfoSync().windowWidth;
      const screenHeight = uni.getSystemInfoSync().windowHeight;
      const tooltipWidth = 240; // 提示框宽度
      const tooltipHeight = 120; // 提示框高度
      // 计算X坐标,防止超出屏幕右侧
      let x = clientX + 20;
      if (x + tooltipWidth > screenWidth) {
        x = Math.max(10, clientX - tooltipWidth - 20);
        this.tooltipArrowTransform = 'translateX(-50%) rotate(0deg)';
      } else {
        this.tooltipArrowTransform = 'translateX(-50%) rotate(180deg)';
      }
      // 计算Y坐标,防止超出屏幕顶部和底部
      let y = clientY - tooltipHeight - 20;
      if (y < 0) {
        y = clientY + 20;
        this.tooltipArrowTransform = 'translateX(-50%) rotate(180deg) translateY(-100%)';
      } else if (y + tooltipHeight > screenHeight) {
        y = screenHeight - tooltipHeight - 10;
      }
      this.tooltipX = x;
      this.tooltipY = y;
      // 显示提示框并添加动画
      this.showTooltipBox = true;
      setTimeout(() => {
        this.tooltipBoxAnimated = true;
      }, 10);
    },
    hideTooltip() {
      this.tooltipBoxAnimated = false;
      setTimeout(() => {
        this.showTooltipBox = false;
      }, 200);
    },
    getStatusDescription(status) {
      const descriptions = {
        '合格': '该检验项目已完成,结果符合质量标准。',
        '不合格': '该检验项目未通过,结果不符合质量标准。\n请查看不合格描述了解详情。',
        '未检验': '该检验项目尚未进行检测,请及时安排检验。'
      };
      return descriptions[status] || status;
    }
  },
  onShow() {
    //每次进入页面都会执行的方法
    if (this.formData.id) {
      this.init();
    }
  },
  onUnload() {
    // 页面卸载时隐藏提示框
    this.showTooltipBox = false;
  }
};
</script>
<style>
   .form-group {
      display: flex;
      align-items: center;
      border-bottom: 1px solid #c9c9c9;
   }
/* 基础配色方案 */
:root {
  --primary-color: #3b82f6;         /* 主蓝色 - 专业感 */
  --primary-dark: #2563eb;         /* 深蓝 - 强调 */
  --primary-light: #bfdbfe;       /* 浅蓝 - 背景 */
  --secondary-color: #64748b;      /* 次色调 - 灰色蓝 */
  --success-color: #10b981;        /* 成功 - 绿色 */
  --warning-color: #f59e0b;        /* 警告 - 橙色 */
  --danger-color: #ef4444;         /* 危险 - 红色 */
  --info-color: #06b6d4;           /* 信息 - 青色 */
  --text-primary: #1e293b;         /* 主文本 - 深灰 */
  --text-secondary: #64748b;       /* 次文本 - 中灰 */
  --text-tertiary: #94a3b8;        /* 辅助文本 - 浅灰 */
  --bg-primary: #f8fafc;           /* 主背景 - 极浅灰 */
  --bg-secondary: #e2e8f0;         /* 次背景 - 浅灰 */
  --card-bg: #ffffff;              /* 卡片背景 - 白色 */
  --border-color: #e2e8f0;         /* 边框 - 浅灰 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
   .form-label {
      margin-bottom: 0;
      padding: 5px;
   }
/* 页面整体样式 */
.page-container {
  padding: 16px;
  background-color: var(--bg-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
   .form-input {
      flex: 1;
      margin-bottom: 0;
      padding: 5px;
   }
/* 卡片样式 */
.form-card, .table-card {
  background-color: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}
   .picker {
      flex: 1;
      margin-bottom: 0;
      padding: 5px;
      font-size: 12px;
   }
.form-card:hover, .table-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
   .uni-form-item {
      display: flex;
      border-bottom: 1px solid #c9c9c9;
   }
.form-title, .table-title {
  background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
  padding: 20px 30px;
  font-size: 20px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
}
   .edit {
      background-color: white;
   }
.title-icon {
  margin-right: 12px;
  font-size: 24px;
}
   /* 默认样式 */
   .list-container {
      height: 60vh;
      /* 设置列表容器的高度为剩余空间,并减去表单容器的高度 */
      overflow-y: auto;
      /* 允许列表容器垂直滚动 */
      padding: 10px;
      /* 可选:添加一些内边距,使列表内容更美观 */
   }
/* 表单样式 */
.form-container {
  padding: 24px 30px;
}
   /* 在小屏幕设备上,重置高度为适应屏幕 */
   @media (max-width: 768px) {
      .list-container {
         height: calc(100vh - 376px);
         /* 适当调整高度 */
      }
   }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
   .form-container {
      padding: 10px;
      /* 可选:添加一些内边距,使表单内容更美观 */
   }
.form-group {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 0;
  transition: all 0.2s;
}
   .th {
      background-color: lightskyblue;
      color: #FFFFFF;
   }
.form-group:hover {
  border-bottom-color: var(--primary-color);
}
   .plus-button {
      line-height: 59px;
      font-size: 24px;
      cursor: pointer;
      z-index: 1000;
      margin-bottom: 10px;
   }
.form-label {
  width: 100px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  margin-top: 4px;
}
   .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;
   }
.form-input {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  border: none;
  outline: none;
  background-color: transparent;
  padding: 8px 0;
}
   .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% */
   }
.form-input:focus {
  color: var(--primary-color);
}
/* 表格样式 */
.list-container {
  padding: 24px 30px;
}
.th {
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
  font-size: 14px;
  padding: 16px 12px;
}
.table-row {
  transition: background-color 0.2s;
}
.hover-effect {
  background-color: var(--primary-light) !important;
}
.result-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  display: inline-block;
}
.pass {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}
.fail {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
}
.pending {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--warning-color);
}
/* 按钮样式 */
.action-buttons {
  display: flex;
  flex-direction: column; /* 垂直排列按钮 */
  gap: 12px; /* 按钮间距 */
  padding: 0 16px 20px;
}
.button-group {
  width: 100%; /* 每个按钮组占满宽度 */
}
.action-btn {
  width: 100%;
  height: 48px;
  line-height: 48px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}
.btn-primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2), 0 2px 4px -1px rgba(59, 130, 246, 0.1);
}
.btn-primary:hover {
  background-color: var(--primary-dark);
  box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3), 0 4px 6px -2px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px -1px rgba(59, 130, 246, 0.2);
}
.btn-secondary {
  background-color: var(--secondary-color);
  color: white;
}
.btn-secondary:hover {
  background-color: #475569;
}
.btn-tertiary {
  background-color: var(--info-color);
  color: white;
}
.btn-tertiary:hover {
  background-color: #0891b2;
}
.btn-quaternary {
  background-color: var(--warning-color);
  color: white;
}
.btn-quaternary:hover {
  background-color: #d97706;
}
.btn-accent {
  background-color: var(--success-color);
  color: white;
}
.btn-accent:hover {
  background-color: #059669;
}
.btn-success {
  background-color: #16a34a;
  color: white;
}
.btn-success:hover {
  background-color: #15803d;
}
.btn-danger {
  background-color: var(--danger-color);
  color: white;
}
.btn-danger:hover {
  background-color: #dc2626;
}
.btn-light {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}
.btn-light:hover {
  background-color: #cbd5e1;
}
.btn-warn {
  background-color: var(--warning-color);
  color: white;
}
.btn-normal {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}
.btn-disabled {
  background-color: #e2e8f0 !important;
  color: #94a3b8 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
}
/* 弹出层样式 */
.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: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.overlay.active {
  opacity: 1;
  visibility: visible;
}
.popup {
  background-color: var(--card-bg);
  border-radius: 16px;
  padding: 30px;
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  transform: scale(0.95);
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0;
}
.overlay.active .popup {
  transform: scale(1);
  opacity: 1;
}
.popup-scale {
  animation: scaleIn 0.3s ease-out;
}
@keyframes scaleIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  position: relative;
}
.popup-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.close-btn {
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.2s;
}
.close-btn:hover {
  color: var(--text-primary);
}
.popup-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
/* 提示框样式 */
.tooltip-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2000;
}
.tooltip {
  position: absolute;
  background: white;
  color: var(--text-primary);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 6px 6px rgba(0, 0, 0, 0.06);
  max-width: 240px;
  min-width: 180px;
  word-break: break-word;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 2001;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.tooltip.active {
  opacity: 1;
  transform: scale(1);
}
.tooltip-content {
  padding: 14px 18px;
}
.tooltip-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--primary-color);
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px;
}
.tooltip-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.tooltip-arrow {
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  transform: translateX(-50%) rotate(45deg);
  z-index: -1;
  border: 1px solid #e2e8f0;
}
.cursor-pointer {
  cursor: pointer;
}
/* 响应式设计调整 */
@media (max-width: 576px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-label {
    width: 80px;
    font-size: 13px;
  }
  .form-input {
    font-size: 13px;
  }
  .action-btn {
    height: 44px;
    line-height: 44px;
    font-size: 13px;
  }
  .popup {
    padding: 24px;
  }
  .tooltip {
    max-width: 200px;
    min-width: 160px;
    border-radius: 8px;
  }
  .tooltip-content {
    padding: 10px 14px;
  }
  .tooltip-title {
    font-size: 13px;
    margin-bottom: 6px;
    padding-bottom: 4px;
  }
  .tooltip-body {
    font-size: 12px;
  }
}
</style>