快乐的昕的电脑
8 小时以前 45157062cf1ca1a84e343caada2e12795c59ab7a
pages/index.vue
@@ -361,17 +361,8 @@
      onShow() {
         this.refresh();
         this.resetAutoRedirectTimer();
         // 页面显示时加载工单列表
         // 如果在工单选择页面,启动定时刷新
         if (this.currentTab === 7) {
            // 默认选中“待开工、未开工、暂停”
            this.engineeringNo = '待开工、未开工、暂停';
            this.engineeringNoMapList = [
               '待开工、未开工、暂停',
               '开工',
               '完工'
            ];
            this.getWomdaaByStatus();
            // 启动定时刷新
            this.startAutoRefresh();
         }
      },
@@ -474,12 +465,20 @@
         
         refresh() {
            this.getMachineList();
            this.getPrintInfo();
            this.getWomdaaIsShow();
            this.getPrintInfo(); // getPrintInfo 完成后会自动调用 getWomdaaIsShow()
            // 如果当前在工单选择页面,默认加载工单列表
            if (this.currentTab === 7) {
               // 默认选中“待开工、未开工、暂停”
               this.engineeringNo = '待开工、未开工、暂停';
               // 根据当前绑定工单的状态决定默认筛选条件
               let defaultStatus = '待开工、未开工、暂停';
               if (this.isShowTableData.length > 0) {
                  const currentOrderStatus = this.isShowTableData[0].daa018;
                  if (currentOrderStatus === '开工') {
                     defaultStatus = '开工';
                  } else if (currentOrderStatus === '完工') {
                     defaultStatus = '完工';
                  }
               }
               this.engineeringNo = defaultStatus;
               this.engineeringNoMapList = [
                  '待开工、未开工、暂停',
                  '开工',
@@ -862,7 +861,7 @@
         getStartBtnText(item) {
            const isSelected = this.isShowTableData.length > 0 && this.isShowTableData[0].daa001 === item.daa001;
            if (isSelected) {
               return '转跳到主界面';
               return '转跳报工界面';
            }
            return '开工';
         },
@@ -873,8 +872,12 @@
            const isSelected = this.isShowTableData.length > 0 && this.isShowTableData[0].daa001 === item.daa001;
            
            if (isSelected) {
               // 如果已选中,则跳转到主界面
               // 如果已选中,则先跳转到主界面,然后跳转到报工界面
               this.toDetail(item);
               // 延迟跳转到报工界面
               setTimeout(() => {
                  this.currentTab = 4;
               }, 100);
            } else {
               // 如果未选中,则执行开工逻辑
               let orderSelect = [{
@@ -891,16 +894,51 @@
                     editDate: editDate,
                     item: orderSelect
                  }
               }).then(res => {
               }).then(async res => {
                  if (res.data.tbBillList) {
                     this.getWomdaaIsShow();
                     uni.showToast({
                        title: '开工成功',
                        icon: 'success',
                        duration: 2000
                     });
                     // 调用后端方法绑定数采标志
                     const bindSuccess = await this.bindDataCollectionFlag(item.daa001);
                     // 绑定成功后再提示开工成功
                     if (bindSuccess) {
                        uni.showToast({
                           title: '开工成功',
                           icon: 'success',
                           duration: 2000
                        });
                     }
                  }
               });
            }
         },
         // 新增:绑定数采标志方法
         async bindDataCollectionFlag(orderNo) {
            try {
               const res = await this.$post({
                  url: '/MesOrderSelect/AddBySc',
                  data: {
                     machineNo: this.machineNo,
                     editDate: editDate,
                     item: orderSelect
                  }
               });
               if (res && res.status === 0) {
                  console.log('数采标志绑定成功');
                  this.$showMessage('数采标志绑定成功');
                  return true;
               } else {
                  console.error('数采标志绑定失败:', res.message || '未知错误');
                  this.$showMessage('数采标志绑定失败');
                  return false;
               }
            } catch (err) {
               console.error('绑定数采标志错误:', err);
               this.$showMessage('绑定数采标志失败');
               return false;
            }
         },
         
@@ -909,7 +947,7 @@
            if (!this.machineNo) {
               return;
            }
            // 直接用 flag 判断
            if (this.hasBindedCutterFlag) {
               uni.showToast({
@@ -919,10 +957,10 @@
               });
               return;
            }
            let editDate = this.formatDate(new Date());
            this.selectedIndexs = [];
            this.$post({
               url: "/MesOrderSelect/Remove",
               data: {
@@ -937,8 +975,35 @@
                     icon: 'success',
                     duration: 2000
                  });
                  // 暂停成功后,刷新当前页面
                  setTimeout(() => {
                     this.refresh();
                  }, 500);
               }
            });
         },
         // 启动自动刷新
         startAutoRefresh() {
            // 先清除现有定时器
            this.stopAutoRefresh();
            // 只在工单选择页面启动定时刷新
            if (this.currentTab === 7) {
               this.autoRefreshTimer = setInterval(() => {
                  if (this.currentTab === 7) {
                     this.refresh();
                  }
               }, this.autoRefreshInterval);
            }
         },
         // 停止自动刷新
         stopAutoRefresh() {
            if (this.autoRefreshTimer) {
               clearInterval(this.autoRefreshTimer);
               this.autoRefreshTimer = null;
            }
         }
      },
      computed: {}