啊鑫
4 天以前 97af26e2ad64d7974367df80a900c1f680bd19c5
pages/QC/XJ/Add.vue
@@ -1,124 +1,166 @@
<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.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="uni-form-item uni-column form-item edit">
          <text class="form-label">线体编号:</text>
          <picker v-if="isUpdate" class="picker form-input" name="selector" :range="DAA020List"
                  @change="onDaa020Change">
            <text>{{ DAA020List[DAA020Index] }}</text>
          </picker>
          <input v-else class="form-input" disabled="true" type="text" v-model="formData.daa020"/>
        </view>
        <view class="uni-form-item uni-column form-item edit">
          <text class="form-label">物料编码:</text>
          <picker v-if="isUpdate" class="picker form-input" name="selector" :range="ItemList"
                  @change="onItemChange">
            <text>{{ ItemList[ItemIndex] }}</text>
          </picker>
          <input v-else class="form-input" disabled="true" type="text" v-model="formData.itemNo"/>
        </view>
        <view class="uni-form-item uni-column form-item edit">
          <text class="form-label">计划编号:</text>
          <picker v-if="isUpdate" class="picker form-input" name="selector" :range="DAA001List"
                  @change="onDaa001Change">
            <text>{{ DAA001List[DAA001Index] }}</text>
          </picker>
          <input v-else class="form-input" disabled="true" type="text" v-model="formData.billNo"/>
        </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.planQty"/>
        </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 class="inspection-sheet">
    <!-- 头部信息 -->
    <view class="sheet-header">
      <h1>巡检单</h1>
      <view class="inspection-number">检验单号:{{ formData.releaseNo }}</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-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.projName"/>
          </uni-td>
          <uni-td align="center">
            <input class="form-input" disabled="true" type="text" v-model="item.result"/>
          </uni-td>
          <uni-td>
            <view class="uni-group">
              <button v-if="item.isCheck >=item.levelNum" type="default" @click="toDetail(item)">
                {{ item.levelNum + '/' + item.isCheck }}
              </button>
              <button v-else type="warn" @click="toDetail(item)">
                {{ item.levelNum + '/' + item.isCheck }}
              </button>
            </view>
          </uni-td>
        </uni-tr>
      </uni-table>
    </view>
    <view class="plus-button">
      <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 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 class="basic-info">
      <view class="info-row">
        <span class="info-label">创建人:</span>
        <span class="info-value">{{ formData.createBy }}</span>
        <span class="info-label">创建时间:</span>
        <span class="info-value">{{ formData.createDate }}</span>
      </view>
    </view>
    <!-- 物料信息区 -->
    <view class="material-info">
      <view class="info-block">
        <view class="info-label">线体编号:</view>
        <view v-if="!isUpdate" class="info-value">{{ formData.daa020 }}</view>
        <picker v-if="isUpdate" :range="DAA020List" class="picker info-value-input" name="selector"
                @change="onDaa020Change">
          <view>{{ DAA020List[DAA020Index] }}</view>
        </picker>
      </view>
      <view class="info-block">
        <view class="info-label">物料编码:</view>
        <view v-if="!isUpdate" class="info-value">{{ formData.itemNo }}</view>
        <picker v-if="isUpdate" :range="ItemList" class="picker info-value-input" name="selector"
                @change="onItemChange">
          <view>{{ ItemList[ItemIndex] }}</view>
        </picker>
      </view>
      <view class="info-block">
        <view class="info-label">计划编号:</view>
        <view v-if="!isUpdate" class="info-value">{{ formData.billNo }}</view>
        <picker v-if="isUpdate" :range="DAA001List" class="picker info-value-input" name="selector"
                @change="onDaa001Change">
          <view>{{ DAA001List[DAA001Index] }}</view>
        </picker>
      </view>
      <view class="info-block">
        <view class="info-label">物料名称:</view>
        <view class="info-value">{{ formData.itemName }}</view>
      </view>
      <view class="info-block">
        <view class="info-label">规格型号:</view>
        <view class="info-value">{{ formData.itemModel }}</view>
      </view>
      <view class="info-block">
        <view class="info-label">工单数量:</view>
        <view class="info-value highlight">{{ formData.planQty }}</view>
      </view>
      <view v-if="formData.remarks" class="info-block">
        <view class="info-label">不合格描述:</view>
        <view class="info-value">{{ formData.remarks }}</view>
      </view>
    </view>
    <!-- 操作按钮区 - 检验项目获取 -->
    <view v-if="isUpdate && !isShowTable" class="action-buttons">
      <button class="primary-btn" @click="getItem">创建检验单</button>
    </view>
    <view v-if="isShowTable" class="action-buttons">
      <button class="secondary-btn" @click="getTable">获取项目</button>
      <button v-if="isUpdate" class="primary-btn" @click="saveTable">生成项目</button>
    </view>
    <!-- 检验项目表格 -->
    <view v-if="tableData.length > 0" class="inspection-table">
      <!-- 表格头部统计信息 -->
      <view class="table-header-stats">
        <view class="stats-left">
          <view class="stats-title">检验项目清单</view>
          <view class="stats-subtitle">共 {{ tableData.length }} 个检验项目</view>
        </view>
        <view class="stats-right">
          <view class="stat-item passed">
            <span class="stat-count">{{ getPassedCount() }}</span>
            <span class="stat-label">已合格</span>
          </view>
          <view class="stat-item failed">
            <span class="stat-count">{{ getFailedCount() }}</span>
            <span class="stat-label">不合格</span>
          </view>
          <view class="stat-item pending">
            <span class="stat-count">{{ getPendingCount() }}</span>
            <span class="stat-label">待检验</span>
          </view>
        </view>
      </view>
      <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>
            <view class="project-name-wrapper">
                        <span :class="{
                           'status-approved': item.result=='合格',
                           'status-rejected': item.result=='不合格',
                           'status-pending': item.result=='未完成'
                        }" class="status-indicator"></span>
              <span>{{ item.projName }}</span>
            </view>
          </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 :class="{
                        'record-btn-fill': item.isCheck >= item.levelNum,
                        'record-btn-view': item.isCheck < item.levelNum
                     }" class="record-btn" @click="toDetail(item)">
              {{ item.isCheck >= item.levelNum ? '查看' : '填写' }}
            </button>
          </td>
        </tr>
        </tbody>
      </table>
    </view>
    <!-- 操作按钮区 - 底部操作 -->
    <view v-if="!isUpdate && !isShowTable" class="action-buttons">
      <button class="secondary-btn" @click="toImage">图片管理</button>
      <button class="secondary-btn" @click="saveRemarks">添加描述</button>
      <button v-if="!formData.fcheckResu" class="primary-btn"
              style="background: linear-gradient(135deg, #e74c3c, #c0392b);" @click="removeXJ">删除单据
      </button>
    </view>
    <!-- 不合格描述弹窗 -->
    <view v-if="remarksPopup" class="overlay">
      <view class="popup">
        <h3>修改不合格描述</h3>
        <view class="form-group">
          <label class="form-label">不合格描述:</label>
          <input v-model="remarks" class="form-input" placeholder="请输入不合格描述" type="text"/>
        </view>
        <view class="popup-buttons">
          <button class="updateBut" @click="editRemarks">修改</button>
          <button class="secondary-btn" @click="remarksPopup = !remarksPopup">取消</button>
        </view>
      </view>
    </view>
  </view>
</template>
@@ -202,6 +244,18 @@
    }
  },
  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 || item.result === '').length;
    },
    removeXJ() {
      if (this.formData.id) {
        this.$post({
@@ -454,65 +508,439 @@
  }
};
</script>
<style>
.form-group {
/* 基础样式 */
.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 h1 {
  color: #2c3e50;
  font-size: 24px;
  margin-bottom: 5px;
}
.inspection-number {
  font-size: 16px;
  font-weight: bold;
  color: #3498db;
}
/* 基本信息区样式 */
.basic-info,
.material-info {
  margin-bottom: 20px;
}
.info-row {
  display: flex;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.info-label {
  font-weight: bold;
  color: #34495e;
  min-width: 80px;
  margin-right: 5px;
}
.info-value {
  color: #2c3e50;
  margin-right: 20px;
}
.highlight {
  font-weight: bold;
  color: #e74c3c;
}
/* 物料信息区样式 */
.material-info {
  border: 1px solid #eee;
  padding: 15px;
  border-radius: 5px;
}
.info-block {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #c9c9c9;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.form-label {
  margin-bottom: 0;
  padding: 5px;
}
.form-input {
.info-value-input {
  flex: 1;
  margin-bottom: 0;
  padding: 5px;
  padding: 8px 12px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  background: #ffffff;
  font-size: 14px;
  margin-top: 6px;
}
.picker {
  flex: 1;
  margin-bottom: 0;
  padding: 5px;
  font-size: 12px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  background: #ffffff;
  font-size: 14px;
  margin-top: 6px;
}
.uni-form-item {
/* 表格样式 */
.inspection-table {
  margin: 25px 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  background: #fff;
}
/* 表格头部统计信息 */
.table-header-stats {
  display: flex;
  border-bottom: 1px solid #c9c9c9;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-bottom: 1px solid #e0e0e0;
}
.edit {
  background-color: white;
.stats-left .stats-title {
  font-size: 18px;
  font-weight: bold;
  color: #2c3e50;
  margin-bottom: 4px;
}
/* 默认样式 */
.list-container {
  height: 60vh;
  /* 设置列表容器的高度为剩余空间,并减去表单容器的高度 */
  overflow-y: auto;
  /* 允许列表容器垂直滚动 */
  padding: 10px;
  /* 可选:添加一些内边距,使列表内容更美观 */
.stats-left .stats-subtitle {
  font-size: 14px;
  color: #7f8c8d;
}
/* 在小屏幕设备上,重置高度为适应屏幕 */
@media (max-width: 768px) {
  .list-container {
    height: calc(100vh - 376px);
    /* 适当调整高度 */
.stats-right {
  display: flex;
  gap: 16px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  min-width: 60px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.stat-item.passed {
  background: linear-gradient(135deg, rgba(39, 174, 96, 0.1), rgba(39, 174, 96, 0.2));
  border: 1px solid rgba(39, 174, 96, 0.3);
}
.stat-item.failed {
  background: linear-gradient(135deg, rgba(230, 126, 34, 0.1), rgba(230, 126, 34, 0.2));
  border: 1px solid rgba(230, 126, 34, 0.3);
}
.stat-item.pending {
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.1), rgba(243, 156, 18, 0.2));
  border: 1px solid rgba(243, 156, 18, 0.3);
}
.stat-count {
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  margin-bottom: 2px;
}
.stat-item.passed .stat-count {
  color: #27ae60;
}
.stat-item.failed .stat-count {
  color: #e67e22;
}
.stat-item.pending .stat-count {
  color: #f39c12;
}
.stat-label {
  font-size: 12px;
  color: #7f8c8d;
  font-weight: 500;
}
/* 移动端表格头部统计 */
@media (max-width: 500px) {
  .table-header-stats {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 16px;
  }
  .stats-right {
    width: 100%;
    justify-content: space-around;
    gap: 8px;
  }
  .stat-item {
    flex: 1;
    min-width: auto;
    padding: 6px 8px;
  }
  .stat-count {
    font-size: 16px;
  }
  .stat-label {
    font-size: 11px;
  }
  .stats-left .stats-title {
    font-size: 16px;
  }
  .stats-left .stats-subtitle {
    font-size: 13px;
  }
}
.form-container {
  padding: 10px;
  /* 可选:添加一些内边距,使表单内容更美观 */
.inspection-table table {
  width: 100%;
  border-collapse: collapse;
}
.th {
  background-color: lightskyblue;
  color: #FFFFFF;
.inspection-table th, .inspection-table td {
  padding: 16px 20px;
  border: none;
  text-align: left;
  border-bottom: 1px solid #eee;
}
.plus-button {
  line-height: 59px;
  font-size: 24px;
.inspection-table th {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-weight: 600;
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.5px;
  position: relative;
}
.inspection-table tbody tr {
  transition: all 0.3s ease;
  border-left: 4px solid transparent;
}
.inspection-table tbody tr:nth-child(even) {
  background-color: #f8fafc;
}
.inspection-table tbody tr:hover {
  background-color: #e8f4fd;
  border-left-color: #3498db;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}
/* 检验项目列样式 */
.inspection-table td:first-child {
  font-weight: 600;
  color: #2c3e50;
  font-size: 15px;
}
/* 项目名称包装器 */
.project-name-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* 状态指示器 */
.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}
.status-indicator.status-approved {
  background-color: #27ae60;
  box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.3);
}
.status-indicator.status-rejected {
  background-color: #e67e22;
  box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.3);
}
.status-indicator.status-pending {
  background-color: #f39c12;
  box-shadow: 0 0 0 2px rgba(243, 156, 18, 0.3);
}
/* 检验描述列特殊样式 */
.inspection-table td:nth-child(2) {
  position: relative;
  min-height: 80px;
  vertical-align: top;
  padding: 16px 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;
  z-index: 1000;
  margin-bottom: 10px;
  transition: all 0.3s;
}
.primary-btn {
  background-color: #3498db;
  color: white;
}
.primary-btn:hover {
  background-color: #2980b9;
}
.secondary-btn {
  background-color: #ecf0f1;
  color: #7f8c8d;
}
.secondary-btn:hover {
  background-color: #d5dbdb;
}
.record-btn {
  padding: 8px 16px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 13px;
  box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}
.record-btn:hover {
  background: linear-gradient(135deg, #2980b9, #1f618d);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(52, 152, 219, 0.4);
}
.record-btn:active {
  transform: translateY(0);
}
/* 填写状态按钮 */
.record-btn-fill {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  box-shadow: 0 2px 4px rgba(46, 204, 113, 0.3);
}
.record-btn-fill:hover {
  background: linear-gradient(135deg, #27ae60, #229954);
  box-shadow: 0 4px 8px rgba(46, 204, 113, 0.4);
}
/* 查看状态按钮 */
.record-btn-view {
  background: linear-gradient(135deg, #95a5a6, #7f8c8d);
  box-shadow: 0 2px 4px rgba(149, 165, 166, 0.3);
}
.record-btn-view:hover {
  background: linear-gradient(135deg, #7f8c8d, #6c7b7d);
  box-shadow: 0 4px 8px rgba(149, 165, 166, 0.4);
}
/* 水印样式 */
.watermark {
  position: absolute;
  font-size: 32px;
  font-weight: bold;
  opacity: 0.4;
  z-index: 3;
  pointer-events: none;
  bottom: 8px;
  right: 8px;
  transform: rotate(-15deg);
  transform-origin: bottom right;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
  min-width: 60px;
  text-align: center;
}
.watermark.approved {
  color: #27ae60; /* 更淡的绿色 */
}
.watermark.rejected {
  color: #e67e22; /* 更淡的红色 */
}
.watermark.pending {
  color: #f39c12; /* 橙色 */
}
/* 描述文本样式 */
.description-text {
  position: relative;
  z-index: 2;
  padding: 12px 16px;
  background: transparent;
  line-height: 1.6;
  font-size: 14px;
  color: #555;
  margin: 0;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  /* 确保文字不会太长遮挡水印 */
  padding-right: 80px;
  min-height: 20px;
  display: block;
}
/* 弹出层样式 */
.overlay {
  position: fixed;
  top: 0;
@@ -523,15 +951,87 @@
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}
.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% */
  border-radius: 8px;
}
.popup h3 {
  margin-top: 0;
  color: #2c3e50;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
  margin-bottom: 15px;
  font-size: 16px;
  text-align: center;
}
.popup .form-group {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}
.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-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;
  }
  .action-buttons {
    flex-direction: column;
  }
  .inspection-table table {
    display: block;
    overflow-x: auto;
  }
}
</style>