zjh
2025-11-10 6ec5099ef65c0e0dc4b1fae5f69eb70dc54dd2b0
pages/QC/SJ/List.vue
@@ -57,31 +57,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>
@@ -90,7 +112,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>
@@ -104,7 +128,6 @@
<script>
export default {
  components: {},
  data() {
    return {
      items: ['未完成', '已完成'],
@@ -114,73 +137,96 @@
      limit: 20,
      totalPage: 0,
      totalCount: 0,
      noData: false, // 没有更多数据了
      isLoading: false, // 是否正在加载
      tipShow: false, // 是否显示顶部提示框
      noData: false,
      isLoading: false,
      tipShow: false,
      searchValue: '',
      uncheckedCount: 0,
      checkedCount: '已完成'
      checkedCount: '已完成',
      IQCJL: 0, // IQC 检验员标识
     userId:""
    };
  },
  onLoad() {
    //页面加载时调用的事件
    this.init();
  },
  methods: {
    init() {
      let result = "未完成";
      if (this.current === 1) {
        result = "已完成";
      }
      if (this.isLoading) return; // 如果正在加载则不继续执行
  // 页面加载时只执行一次
  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: {
    async init() {
      let result = this.current === 1 ? "已完成" : "未完成";
      if (this.isLoading) return;
      this.isLoading = true;
      const userName = this.$loginInfo.account;
      //获取当前登录的用户
      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];
      try {
        const res = await this.$post({
          url: "/SJ/GetPage",
          data: {
            pageIndex: this.pageIndex,
            limit: this.limit,
            statusUser: userName,
            result: result,
            searchValue: this.searchValue
          }
        });
        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;
        this.isLoading = false; // 结束加载
        // 更新计数
        if (this.current === 1) {
          this.checkedCount = '已完成(' + this.totalCount + ')';
        } else {
          this.uncheckedCount = this.totalCount;
        }
      }).catch(() => {
        this.isLoading = false; // 出现错误时结束加载
      });
      } catch (e) {
        console.error("加载检验单数据失败:", e);
      } finally {
        this.isLoading = false;
      }
    },
    handleFabClick() {
      uni.navigateTo({
        url: 'Add?id'
      });
    // 搜索
    handleSearch() {
      this.pageIndex = 1;
      this.data = [];
      this.init();
    },
    // Tab 切换
    onClickItem(index) {
      if (this.current !== index.currentIndex) {
        this.current = index.currentIndex;
@@ -189,59 +235,50 @@
        this.init();
      }
    },
    handleSearch() {
      this.pageIndex = 1;
      this.data = [];
      this.init();
    },
    // 跳转详情
    navigateToDetail(item) {
      if (this.current === 1) {
       uni.navigateTo({
         url: 'Add?id=' + item.id + '&billNo=' + item.billNo+
                     '&current=B'
       });
      }else{
         uni.navigateTo({
           url: 'Add?id=' + item.id + '&billNo=' + item.billNo+
                              '&current=A'
         });
      }
      const type = this.current === 1 ? "B" : "A";
      uni.navigateTo({
        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>
/* 基础样式重置 */
.inspection-app {