fcx
2025-12-06 93b04dfa60b2128273cd070269d8eaaeb14e15e8
pages/QC/SJ/List.vue
@@ -11,15 +11,22 @@
                  @click="onClickItem({currentIndex: 0})">未完成({{ uncheckedCount }})
          </button>
          <button :class="['tab-button', current === 1 ? 'active' : '']"
                  @click="onClickItem({currentIndex: 1})">{{ checkedCount }}
                  @click="onClickItem({currentIndex: 1})">已提交({{ checkedCount }})
          </button>
        </view>
      </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="请输入检验单号或物料编码"
                 @confirm="handleSearch"/>
          <input class="search-input" v-model="searchValue" :placeholder="'请输入'+options[optionsIndex]"
                 @confirm="handleSearch" />
          <button class="search-button" @click="handleSearch">搜索</button>
        </view>
      </view>
@@ -35,9 +42,15 @@
          <view v-if="item.urgent == 1" class="badge urgent">急料</view>
          <view v-if="item.isFirst == 1" class="badge normal">首次</view>
          <view class="card-title">检验单号: {{ item.billNo }}</view>
          <view :class="{'status-pending': current === 0, 'status-assigned': current === 0 && item.statusUser, 'status-pass': current === 1 && item.result === '合格', 'status-fail': current === 1 && item.result === '不合格'}"
          <view :class="{
                  'status-pending': !item.result && current === 0,
                  'status-assigned': current === 0 && item.statusUser && !item.result,
                  'status-pass': item.result === '合格'&& current === 1,
                  'status-fail': item.result === '不合格'&& current === 1,
                  'status-submitted': !item.result && current === 1
                }"
                class="status">
            {{ current === 0 ? (item.statusUser ? '已分配' : '未提交') : (item.result ? item.result : '已提交') }}
            {{ current === 0 ? ('' ? item.result : '未提交') : (item.result ? item.result : '已提交') }}
          </view>
        </view>
@@ -51,31 +64,53 @@
          <view class="info-row">
            <view class="info-item">
              <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.daa018 }}</view>
            </view>
         <view class="info-item">
           <view class="info-label">齐套状态</view>
           <view class="info-content">{{ item.daA019 }}</view>
         </view>
          </view>
      <view class="info-row">
            <view class="info-item">
              <view class="info-label">产线</view>
              <view class="info-content">{{ item.line }}</view>
            </view>
            <view class="info-item">
              <view class="info-label">工单数量</view>
              <view class="info-content highlight">{{ item.daa008 }}</view>
              <view class="info-label">工单号</view>
              <view class="info-content">{{ item.daa001 }}</view>
            </view>
         <view class="info-item">
           <view class="info-label">工单数</view>
           <view class="info-content highlight">{{ item.daa008 }}</view>
         </view>
          </view>
          <view class="info-row">
            <view class="info-item">
              <view class="info-label">创建人</view>
            <!-- <view class="info-item">
              <view class="info-label">创建人1</view>
              <view class="info-content">{{ item.fName }}</view>
            </view>
            <view v-if="item.statusUser" class="info-item">
            </view> -->
           <!-- <view v-if="item.statusUser" class="info-item">
              <view class="info-label">检验人</view>
              <view class="info-content">{{ item.statusUser }}</view>
            </view>
            </view> -->
          </view>
          <!-- 在未完成状态下显示创建时间,已完成状态下显示检测结果 -->
          <view v-if="current === 0" class="meta-info">
            <view class="meta-item">{{ item.statusDate }}</view>
            <view class="meta-item">创建人: {{ item.fName }}</view>
         <view class="meta-item">检验人: {{ item.statusUser }}</view>
          </view>
        <view v-if="current === 0" class="meta-info">
           <view class="meta-item">创建时间: {{ item.createTime }}</view>
        </view>
          <view v-if="current === 1" class="meta-info">
            <view class="meta-item">{{ item.statusDate }}</view>
@@ -84,7 +119,9 @@
        </view>
        <view class="card-actions">
          <button class="primary">{{ current === 0 ? '继续检验' : '查看详情' }}</button>
         <button v-if="current === 0 && IQCJL==1"
            @click.stop="assignTask(item)">{{item.statusUser == null ? '分配' : '重新分配'}}</button>
          <button class="primary">{{ current === 0 ? '开始检验' : '查看详情' }}</button>
        </view>
      </view>
    </view>
@@ -98,7 +135,6 @@
<script>
export default {
  components: {},
  data() {
    return {
      items: ['未完成', '已完成'],
@@ -108,124 +144,158 @@
      limit: 20,
      totalPage: 0,
      totalCount: 0,
      noData: false, // 没有更多数据了
      isLoading: false, // 是否正在加载
      tipShow: false, // 是否显示顶部提示框
      noData: false,
      isLoading: false,
      tipShow: false,
      searchValue: '',
      uncheckedCount: 0,
      checkedCount: '已完成'
      checkedCount: 0,
      IQCJL: 0, // IQC 检验员标识
     userId:"",
      optionsIndex: 0, // 新增:下拉选项索引
      options: ['项目', '线体', '工单号', '物料号', '物料名'] // 新增:搜索选项
    };
  },
  onLoad() {
    //页面加载时调用的事件
    this.init();
  // 页面加载时只执行一次
  async onLoad() {
    // 判断当前登录人是否为IQC检验员或特定账号
    const user = this.$loginInfo;
   this.userId=user.account;
    if (user.roleid && user.roleid.indexOf("90134") !== -1 || user.account === "PL017") {
      this.IQCJL = 1;
    } else {
      this.IQCJL = 0;
    }
    console.log("IQC检验员标识 IQCJL =", this.IQCJL);
    // 初始化加载数据
    await this.init();
  },
  // 每次页面重新显示时触发(返回页面也会触发)
  onShow() {
    console.log("onShow 触发,IQCJL =", this.IQCJL);
    // 避免重复加载:只在第一次或数据为空时重新加载
    if (this.data.length === 0) {
      this.pageIndex = 1;
      this.init();
    }
  },
  methods: {
    init() {
      let result = "未完成";
      if (this.current === 1) {
        result = "已完成";
      }
      if (this.isLoading) return; // 如果正在加载则不继续执行
      this.isLoading = true;
      //获取当前登录的用户
      let userName = this.$loginInfo.account;
      //页面加载时调用的事件
      this.$post({
        url: "/SJ/GetPage",
        data: {
          pageIndex: this.pageIndex,
          limit: this.limit,
          statusUser: userName,
          result: result,
          searchValue: this.searchValue
        }
      }).then(res => {
        if (this.pageIndex === 1) {
          // 如果是第一页,直接覆盖原数据
          this.data = res.data.tbBillList;
        } else {
          if (res.data.tbBillList.length > 0) {
            // 如果是下一页,追加新数据
            this.data = [...this.data, ...res.data.tbBillList];
          }
        }
        this.totalCount = res.totalCount;
        this.totalPage = Math.ceil(this.totalCount / this.limit);
        this.noData = this.pageIndex >= this.totalPage;
        this.isLoading = false; // 结束加载
        // 更新计数
        if (this.current === 1) {
          this.checkedCount = '已完成(' + this.totalCount + ')';
        } else {
          this.uncheckedCount = this.totalCount;
        }
      }).catch(() => {
        this.isLoading = false; // 出现错误时结束加载
      });
    // 新增:搜索选项改变事件
    onOptionsChange(e) {
      this.optionsIndex = e.detail.value;
    },
    handleFabClick() {
      uni.navigateTo({
        url: 'Add?id'
      });
    },
    onClickItem(index) {
      if (this.current !== index.currentIndex) {
        this.current = index.currentIndex;
        this.data = [];
        this.pageIndex = 1;
        this.init();
      }
    },
    // 新增:搜索按钮点击事件
    handleSearch() {
      this.pageIndex = 1;
      this.data = [];
      this.init();
    },
    async init() {
      let result = this.current === 1 ? "已完成" : "未完成";
      if (this.isLoading) return;
      this.isLoading = true;
      const userName = this.$loginInfo.account;
      try {
        const res = await this.$post({
          url: "/SJ/GetPage",
          data: {
            pageIndex: this.pageIndex,
            limit: this.limit,
            statusUser: userName,
            result: result,
            searchValue: this.searchValue,
            selectedIndex: this.optionsIndex // 新增:传递搜索选项索引
          }
        });
        const list = res.data.tbBillList || [];
        if (this.pageIndex === 1) {
          this.data = list;
        } else {
          this.data.push(...list);
        }
        this.totalCount = res.totalCount;
        this.totalPage = Math.ceil(this.totalCount / this.limit);
        this.noData = this.pageIndex >= this.totalPage;
        if (this.current === 1) {
          this.checkedCount = this.totalCount;
        } else {
          this.uncheckedCount = this.totalCount;
        }
      } catch (e) {
        console.error("加载检验单数据失败:", e);
      } finally {
        this.isLoading = false;
      }
    },
    // Tab 切换
    onClickItem(index) {
      if (this.current !== index.currentIndex) {
        this.current = index.currentIndex;
        this.data = [];
        this.pageIndex = 1;
        // 重置筛选条件
        this.optionsIndex = 0;
        this.searchValue = '';
        this.init();
      }
    },
    // 跳转详情
    navigateToDetail(item) {
      const type = this.current === 1 ? "B" : "A";
      uni.navigateTo({
        url: 'Add?id=' + item.id + '&billNo=' + item.billNo
        url: `Add?id=${item.id}&billNo=${item.billNo}&current=${type}`
      });
    },
   assignTask(item) {
         console.log(item);
            // 这里可以添加分配任务的逻辑
            uni.navigateTo({
               url: 'UpdateCheckBy?releaseNo=' + item.billNo + '&userID=' + this.userId +
                  '&staffName=' + item.statusUser
            });
         },
    // 添加按钮
    handleFabClick() {
      uni.navigateTo({
        url: 'Add?id'
      });
    }
  },
  /**
   * 下拉刷新回调函数
   */
  // 下拉刷新
  onPullDownRefresh() {
    this.pageIndex = 1;
    //重新执行一遍查询
    this.init();
    this.tipShow = true;
    //关闭动画
    uni.stopPullDownRefresh();
    setTimeout(() => {
      this.tipShow = false;
    }, 3000);
    this.init().then(() => {
      this.tipShow = true;
      uni.stopPullDownRefresh();
      setTimeout(() => (this.tipShow = false), 3000);
    });
  },
  /**
   * 上拉加载回调函数
   */
  // 上拉加载更多
  onReachBottom() {
    if (this.noData || this.isLoading) return;
    this.pageIndex++;
    this.init(); // 加载更多数据
  },
  onShow() {
    //每次进入页面都会执行的方法
    this.pageIndex = 1;
    this.data = [];
    //this.current = 0
    this.init();
  }
};
</script>
<style scoped>
/* 基础样式重置 */
@@ -460,7 +530,12 @@
}
.status-fail {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  background: linear-gradient(135deg, #ff0000, #ff0000);
  color: white;
}
.status-submitted {
  background: linear-gradient(135deg, #95a5a6, #7f8c8d);
  color: white;
}