xwt
2025-09-03 0c3ea5f8246b22ad945e4086a9507c30d6245a8b
pages/QC/LLJ/List.vue
@@ -16,7 +16,7 @@
            </view>
            <!-- 新增搜索框和按钮 -->
            <view class="search-container">
               <input class="search-input" v-model="searchValue" :placeholder="'请输入'+options[optionsIndex]"
               <input class="search-input" v-model="searchValue" :placeholder="optionsIndex === 0 ? '选择项目时显示全部数据' : '请输入'+options[optionsIndex]"
                  @confirm="handleSearch" />
               <button class="search-button" @click="handleSearch">搜索</button>
            </view>
@@ -30,7 +30,6 @@
         </view>
      </view>
      <!-- 检验单列表 -->
      <view class="inspection-list">
         <!-- 检验单卡片1 -->
@@ -38,10 +37,19 @@
            <view class="card-header">
               <text class="badge urgent" v-if="item.urgentFlag == 1">急料</text>
               <text class="badge urgent" v-if="item.jycs == 1">超时</text>
               <text class="badge normal" v-if="item.ftype == 1">委外</text>
               <text class="badge normal" v-if="item.first == 1">首次来料</text>
               <text class="card-title">检验单号: {{item.releaseNo}}</text>
               <text class="status pending" v-if="item.userName==null && item.activeTab==0">待分配</text>
               <view v-if="item.userName == null && item.activeTab == 0">
                       <text class="status pending" :class="{
                           'emergency-pending': item.lotNo1 === '紧急放行,请勿验退!',
                           'unmaintained-not-emergency': isUnmaintainedAndNotEmergency(item)
                       }">
                       {{ item.lotNo1 === '紧急放行,请勿验退!' ? '紧急放行/' + getStatusText(item) : getStatusText(item) }}
                       </text>
                   </view>
               <text class="status assigned" v-if="item.userName!=null && item.activeTab==0">已分配</text>
               <text class="status pass" v-if="item.fcheckResu=='合格' && item.activeTab==1">合格</text>
               <text class="status Unqualified" v-if="item.fcheckResu=='不合格' && item.activeTab==1">不合格</text>
@@ -60,7 +68,7 @@
               <view class="info-row">
                  <view class="info-item">
                     <text class="info-label">项目</text>
                     <text class="info-content">{{item.projectCodes}}</text>
                     <text class="info-content">{{item.DEPARTMENTNAME}}</text>
                  </view>
                  <view class="info-item" v-if="item.extendNo1!=null">
                     <text class="info-label">技改状态</text>
@@ -70,6 +78,10 @@
                     <text class="info-label">数量</text>
                     <text class="info-content highlight">{{item.fcovertQty}}</text>
                  </view>
                  <view class="info-item" v-if="item.jyxm !== null && item.jyxm !== undefined">
                     <text class="info-label">检验项目</text>
                     <text class="info-content">{{item.jyxm}}</text>
                  </view>
               </view>
               <view class="info-row">
                  <view class="info-item">
@@ -78,10 +90,7 @@
                  </view>
               </view>
               <view class="info-row">
                  <view class="info-item" v-if="item.newFngDesc!=null">
                     <text class="info-label">上次不良描述</text>
                     <text class="info-content">{{item.newFngDesc}}</text>
                  </view>
                  <view class="info-item" v-if="item.fngDesc!=null">
                     <text class="info-label">不良描述</text>
                     <text class="info-content">{{item.fngDesc}}</text>
@@ -112,7 +121,7 @@
      data() {
         return {
            projectIndex: 0,
            optionsIndex: 0,
            optionsIndex: 1, // 默认选择物料编号
            projects: ['当前', '全部'],
            activeTab: 0, // 0-未检验, 1-已检验
            uncheckedCount: 0,
@@ -121,33 +130,52 @@
            pageIndex: 1,
            limit: 20,
            IQCJL: 0,
            options: ['项目', '物料编号', '物料名称', '供应商', '采购员','到货单号','检验单号'],
            options: ['项目', '物料编号', '物料名称', '供应商', '到货单号','检验单号','物料规格'],
            searchValue: ''
         }
      },
      onLoad() {
         //页面加载时调用的事件
         // 初始化selectedField,因为默认选择物料编号
         const fieldMap = {
            0: 'DEPARTMENTNAME', // 项目
            1: 'itemNo', // 物料编号
            2: 'itemName', // 物料名称
            3: 'suppName', // 供应商
            4: 'lotNo' ,// 到货单号
            5: 'releaseNo' ,// 检验单号
            6: 'itemModel',//物料规格
         };
         this.selectedField = fieldMap[this.optionsIndex];
         this.init();
      },
      methods: {
         //搜索
         onOptionsChange(e) {
            this.optionsIndex = e.detail.value;
            // 当选择项目时,清空搜索值
            if (this.optionsIndex === 0) {
               this.searchValue = '';
            }
            // 根据选择的选项设置搜索字段
            const fieldMap = {
               0: 'projectCodes', // 项目
               0: 'DEPARTMENTNAME', // 项目
               1: 'itemNo', // 物料编号
               2: 'itemName', // 物料名称
               3: 'suppName', // 供应商
               4: 'purchaser' ,// 采购员
               5: 'lotNO' ,// 到货单号
               6: 'releaseNO' ,// 检验单号
               4: 'lotNo' ,// 到货单号
               5: 'releaseNo' ,// 检验单号
               6: 'itemModel',//物料规格
            };
            this.selectedField = fieldMap[this.optionsIndex];
         },
         //搜索按钮点击事件
         handleSearch() {
            // 当选择项目时,清空搜索值
            if (this.optionsIndex === 0) {
               this.searchValue = '';
            }
            this.init();
         },
         init() {
@@ -175,26 +203,35 @@
                  result: result,
                  SearchValue: this.searchValue,
                  selectedIndex: this.optionsIndex, //下拉框筛选条件
                  userIndex: this.projectIndex
                  userIndex: this.projectIndex,
                  emergency:this.meergency,
               }
            }).then(res => {
               // 去重处理 - 根据 releaseNo 去重
               const uniqueList = this.removeDuplicatesByReleaseNo(res.data.tbBillList);
               // 对数据进行排序处理
               const sortedList = this.sortInspectionList(uniqueList);
               if (this.pageIndex === 1) {
                  // 如果是第一页,直接覆盖原数据
                  this.inspectionList = res.data.tbBillList;
                  this.inspectionList = sortedList;
                  //添加Tab信息,判断是已检还是未检数据
                  this.inspectionList.forEach((item, index) => {
                     this.$set(item, 'activeTab', this.activeTab);
                     this.$set(item, 'IQCJL', this.IQCJL);
                     this.$set(item, 'EMERGENCY', item.emergency || null);
                  });
               } else {
                  if (res.data.tbBillList.length > 0) {
                  if (sortedList.length > 0) {
                     // 如果是下一页,追加新数据
                     this.inspectionList = [...this.inspectionList, ...res.data.tbBillList];
                     this.inspectionList = [...this.inspectionList, ...sortedList];
                     //添加Tab信息,判断是已检还是未检数据
                     this.inspectionList.forEach((item, index) => {
                        this.$set(item, 'activeTab', this.activeTab);
                        this.$set(item, 'IQCJL', this.IQCJL);
                        this.$set(item, 'EMERGENCY', item.emergency || null);
                     });
                  }
@@ -292,10 +329,19 @@
         },
         onShow() {
            //每次进入页面都会执行的方法
            // this.pageIndex = 1;
            // this.data = [];
            // //this.current = 0
            // 检查是否需要刷新数据
            const app = getApp();
            if (app.globalData && app.globalData.needRefreshList) {
               // 清除标记
               app.globalData.needRefreshList = false;
               // 强制刷新数据
               this.pageIndex = 1; // 重置页码
               this.inspectionList = []; // 清空列表数据
               this.init(); // 重新加载数据
            } else {
               // 正常刷新
            this.init();
            }
         },
         async onLoad() {
            if (this.$loginInfo.roleid.indexOf("90134") != -1 || this.$loginInfo.account == "PL017") {
@@ -305,6 +351,78 @@
            }
            await this.init(); // 自定义的刷新函数
         },
         // 根据 releaseNo 去重的方法
         removeDuplicatesByReleaseNo(array) {
            const seen = new Set();
            return array.filter(item => {
               const releaseNo = item.releaseNo;
               if (seen.has(releaseNo)) {
                  return false;
               }
               seen.add(releaseNo);
               return true;
            });
         },
         // 根据检验项目数量获取状态文本
         getStatusText(item) {
            // 如果没有检验项目,显示"未维护"
            if (!item.inspectionItemCount || item.inspectionItemCount === 0) {
               return '未维护';
            }
            // 如果有检验项目,显示"待检验"
            return '待检验';
         },
         // 判断是否为未维护且非紧急放行
         isUnmaintainedAndNotEmergency(item) {
            // 检查是否为未维护(没有检验项目)
            const isUnmaintained = !item.inspectionItemCount || item.inspectionItemCount === 0;
            // 检查是否为非紧急放行
            const isNotEmergency = item.lotNo1 !== '紧急放行,请勿验退!';
            return isUnmaintained && isNotEmergency;
         },
         // 判断是否为待分配状态(物料没有维护检验员或者该物料未在V_LLJ_USER里)
         isUnmaintainedItem(item) {
            // 检查物料是否在V_LLJ_USER视图中(即是否有维护检验员)
            // 如果item.fcode为null或undefined,说明该物料未在V_LLJ_USER视图中
            // 或者该物料没有维护检验员
            return !item.fcode || item.fcode === null || item.fcode === '';
         },
         // 对检验单列表进行排序
         sortInspectionList(list) {
            return list.sort((a, b) => {
               // 第一优先级:未提交校验的紧急放行
               const aIsEmergencyPending = a.lotNo1 === '紧急放行,请勿验退!' && this.activeTab === 0;
               const bIsEmergencyPending = b.lotNo1 === '紧急放行,请勿验退!' && this.activeTab === 0;
               if (aIsEmergencyPending && !bIsEmergencyPending) return -1;
               if (!aIsEmergencyPending && bIsEmergencyPending) return 1;
               // 第二优先级:未维护检验项目(非紧急放行)
               const aIsUnmaintained = this.isUnmaintainedAndNotEmergency(a);
               const bIsUnmaintained = this.isUnmaintainedAndNotEmergency(b);
               if (aIsUnmaintained && !bIsUnmaintained) return -1;
               if (!aIsUnmaintained && bIsUnmaintained) return 1;
               // 第三优先级:创建时间(未提交的按创建时间升序,已提交的按提交时间降序)
               if (this.activeTab === 0) {
                  // 未检验:按创建时间升序(越早越靠前)
                  const aCreateTime = new Date(a.createDate || 0);
                  const bCreateTime = new Date(b.createDate || 0);
                  return aCreateTime - bCreateTime;
               } else {
                  // 已检验:按提交时间降序(越晚越靠前)
                  const aIqcTime = new Date(a.iqcDate || 0);
                  const bIqcTime = new Date(b.iqcDate || 0);
                  return bIqcTime - aIqcTime;
               }
            });
         }
      }
   }
@@ -333,7 +451,7 @@
   /* 新增搜索框样式 */
   .search-container {
      display: flex;
      flex: 1;
      width: 300px; /* 固定宽度 */
      margin: 0 10px;
      height: 36px;
      /* 与其他控件高度一致 */
@@ -346,6 +464,8 @@
      border-radius: 4px 0 0 4px;
      font-size: 14px;
      background-color: white;
      min-width: 200px; /* 最小宽度 */
      max-width: 250px; /* 最大宽度 */
   }
   .search-button {
@@ -467,6 +587,17 @@
   .badge.normal {
      background-color: #ffaa00;
      color: white;
   }
   .badge.unmaintained {
      background-color: #1e8449;
      color: white;
   }
   .badge.emergency {
      background-color: #ff4d4f;
      color: white;
      margin-right: 5px;
   }
   .status {
@@ -609,5 +740,15 @@
      order: 4;
      width: 100%;
    } */
   .status.emergency-pending {
       background-color: #ff0000; /* 红色背景 */
       color: white;
   }
   .status.unmaintained-not-emergency {
       background-color: #9c27b0; /* 紫色背景 */
       color: white;
       box-shadow: 0 0 8px rgba(156, 39, 176, 0.3);
   }
   }
</style>