fcx
4 天以前 4dc0880780b52c0c35456666a4643a7866b454a7
pages/QC/XJ/List.vue
@@ -17,10 +17,40 @@
      </view>
      <view class="filter-controls" style="margin-bottom: 5px;">
        <view class="dropdown-filter">
          <picker @change="onOptionsChange" :value="optionsIndex" :range="options">
            <view class="picker">{{options[optionsIndex]}}</view>
          </picker>
        </view>
        <!-- 搜索框和按钮 -->
        <view class="search-container">
          <input v-model="searchValue" class="search-input" placeholder="请输入检验单号或物料编码"
          <input v-model="searchValue" class="search-input" :placeholder="'请输入'+options[optionsIndex]"
                 @confirm="handleSearch"/>
          <button class="search-button" @click="handleSearch">搜索</button>
        </view>
      </view>
      <!-- 未提交页面显示时间日期文本,已提交页面显示状态筛选 -->
      <view class="filter-controls" style="margin-bottom: 5px;">
        <!-- 未提交页面:显示时间日期文本 -->
        <view v-if="current === 0" class="dropdown-filter">
          <view class="picker">时间日期</view>
        </view>
        <!-- 已提交页面:显示状态下拉框 -->
        <view v-if="current === 1" class="dropdown-filter">
          <picker @change="onStateChange" :value="stateIndex" :range="state">
            <view class="picker">{{state[stateIndex]}}</view>
          </picker>
        </view>
        <view class="dropdown-filter">
          <picker mode="date" :value="startDate" :end="endDate" @change="bindStartDate">
            <view class="picker">{{startDate}}</view>
          </picker>
        </view>
        <view class="dropdown-filter">
          <picker mode="date" :value="endDate" :start="startDate" @change="bindEndDate">
            <view class="picker">{{endDate}}</view>
          </picker>
        </view>
      </view>
    </view>
@@ -49,8 +79,19 @@
          <view class="info-row">
            <view class="info-item">
              <view class="info-label">产线</view>
              <view class="info-label">项目</view>
              <view class="info-content">{{ item.projecT_CODE }}</view>
            </view>
            <view class="info-item">
              <view class="info-label">线别</view>
              <view class="info-content">{{ item.daa020 }}</view>
            </view>
          </view>
          <view class="info-row">
            <view class="info-item">
              <view class="info-label">工单号</view>
              <view class="info-content">{{ item.billNo }}</view>
            </view>
            <view class="info-item">
              <view class="info-label">工单数量</view>
@@ -106,7 +147,14 @@
      tipShow: false, // 是否显示顶部提示框
      searchValue: '',
      uncheckedCount: 0,
      checkedCount: 0
      checkedCount: 0,
      optionsIndex: 0, // 新增:下拉选项索引
      options: ['项目', '线体', '工单号', '物料号', '物料名'], // 新增:搜索选项
      // 添加状态筛选和日期选择器相关变量
      stateIndex: 0,
      state: ['所有状态', '合格', '不合格'],
      startDate: new Date().toISOString().slice(0, 10),
      endDate: new Date().toISOString().slice(0, 10)
    };
  },
  onLoad() {
@@ -117,6 +165,38 @@
    handleSearch() {
      this.pageIndex = 1;
      this.data = [];
      this.init();
    },
    // 新增:搜索选项改变事件
    onOptionsChange(e) {
      this.optionsIndex = e.detail.value;
    },
    // 新增:状态筛选改变事件
    onStateChange(e) {
      this.pageIndex = 1;
      this.stateIndex = e.detail.value;
      this.data = [];
      console.log("状态筛选改变,选中状态:", this.state[this.stateIndex]);
      this.init();
    },
    // 新增:开始日期改变事件
    bindStartDate(e) {
      this.startDate = e.detail.value;
      this.pageIndex = 1;
      this.data = [];
      console.log("开始日期改变:", this.startDate);
      this.init();
    },
    // 新增:结束日期改变事件
    bindEndDate(e) {
      this.endDate = e.detail.value;
      this.pageIndex = 1;
      this.data = [];
      console.log("结束日期改变:", this.endDate);
      this.init();
    },
    // 计算是否超时的方法
@@ -166,11 +246,59 @@
          limit: this.limit,
          createUser: userName,
          result: result,
          searchValue: this.searchValue
          searchValue: this.searchValue,
          selectedIndex: this.optionsIndex // 新增:传递搜索选项索引
        }
      }).then(res => {
        // 处理数据并添加超时标识
        let processedData = this.processDataWithTimeoutCheck(res.data.tbBillList);
        // 对所有页面进行前端筛选(未提交和已提交)
        // 状态筛选
        if (this.stateIndex > 0) {
          const selectedState = this.state[this.stateIndex];
          console.log("前端状态筛选:", selectedState);
          if (selectedState === '合格') {
            processedData = processedData.filter(item => item.fcheckResu === '合格');
          } else if (selectedState === '不合格') {
            processedData = processedData.filter(item => item.fcheckResu === '不合格');
          }
        }
        // 日期范围筛选
        if (this.startDate || this.endDate) {
          console.log("前端日期筛选:", this.startDate, "到", this.endDate);
          const startDateObj = this.startDate ? new Date(this.startDate) : null;
          const endDateObj = this.endDate ? new Date(this.endDate) : null;
          // 设置开始日期的时间为当天的开始时间 (00:00:00)
          if (startDateObj) {
            startDateObj.setHours(0, 0, 0, 0);
          }
          // 设置结束日期的时间为当天的结束时间 (23:59:59)
          if (endDateObj) {
            endDateObj.setHours(23, 59, 59, 999);
          }
          processedData = processedData.filter(item => {
            if (item.createDate) {
              const itemDate = new Date(item.createDate);
              let isValid = true;
              if (startDateObj && itemDate < startDateObj) {
                isValid = false;
              }
              if (endDateObj && itemDate > endDateObj) {
                isValid = false;
              }
              return isValid;
            }
            return true;
          });
        }
        
        if (this.pageIndex === 1) {
          // 如果是第一页,直接覆盖原数据
@@ -199,7 +327,7 @@
    },
    handleFabClick() {
      uni.navigateTo({
        url: 'Add?id'
        url: 'Add?current=A'
      });
    },
    onClickItem(index) {
@@ -207,6 +335,12 @@
        this.current = index.currentIndex;
        this.data = [];
        this.pageIndex = 1;
        // 重置筛选条件
        this.searchValue = '';
        this.optionsIndex = 0;
        this.stateIndex = 0;
        this.startDate = new Date().toISOString().slice(0, 10);
        this.endDate = new Date().toISOString().slice(0, 10);
        this.init();
      }
    },
@@ -314,6 +448,19 @@
  gap: 5px;
}
.dropdown-filter {
  min-width: 70px;
}
.picker {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  font-size: 14px;
  min-width: 120px;
}
.status-tabs {
  display: flex;
  border-radius: 4px;