快乐的昕的电脑
2025-11-19 f13213d0a2d44443790e648896303ed93dc1bacd
components/WorkOrderPrint.vue
@@ -238,9 +238,10 @@
            printNum: 1, reportingList: [], printLoading: false, customAmount: '',
            isGeneratingBarcode: false, lastGenerateTime: 0, generateRequestId: null,
            nowTimeTimer: null, nowTime: '',
            userSearch: '',
                userSearch: '',
                refreshTimer: null, // 新增:自动刷新定时器
            /* 新增:历史报工记录数组 */
            reportingHistory: []
                reportingHistory: []
         }
      },
      computed: {
@@ -278,10 +279,35 @@
         this.getXS0101();
         this.updateNowTime();
         // 秒级刷新;如不需动态跳秒可改为 60000
         this.nowTimeTimer = setInterval(this.updateNowTime, 1000);
            this.nowTimeTimer = setInterval(this.updateNowTime, 1000);
            // 新增:每分钟自动刷新数据(60000毫秒 = 1分钟)
            this.startAutoRefresh();
      },
      beforeDestroy() { if (this.nowTimeTimer) clearInterval(this.nowTimeTimer); },
      methods: {
        beforeDestroy() {
            if (this.nowTimeTimer) clearInterval(this.nowTimeTimer);
            // 新增:清理自动刷新定时器
            this.stopAutoRefresh();
        },
        methods: {
            // 新增:开始自动刷新
            startAutoRefresh() {
                // 先清除可能存在的旧定时器
                this.stopAutoRefresh();
                // 设置新的定时器,每分钟执行一次
                this.refreshTimer = setInterval(() => {
                    console.log('自动刷新数据...');
                    this.refresh();
                }, 60000); // 60000毫秒 = 1分钟
            },
            // 新增:停止自动刷新
            stopAutoRefresh() {
                if (this.refreshTimer) {
                    clearInterval(this.refreshTimer);
                    this.refreshTimer = null;
                }
            },
         formatUser(u) {
            if (!u) return '';
            const segs = u.split(':');
@@ -303,13 +329,24 @@
            this.isGeneratingBarcode = false; this.generateRequestId = null; this.lastGenerateTime = 0;
            this.$showMessage("已重置条码生成状态");
         },
         refresh() {
            this.$sendPostRequest({
               url: "http://192.168.0.94:9095/Numerical/RefreshDevBycl",
               data: { machineNo: this.order.machineNo },
               contentType: "application/json"
            }).then(r => { r.code == 200 ? this.fetchData(true) : this.$showMessage("同步失败"); });
         },
            // 修改:在手动刷新时也重置自动刷新计时器
            refresh() {
                this.$sendPostRequest({
                    url: "http://192.168.0.94:9095/Numerical/RefreshDevBycl",
                    data: { machineNo: this.order.machineNo },
                    contentType: "application/json"
                }).then(r => {
                    if (r.code == 200) {
                        this.fetchData(true);
                        this.$showMessage("数据刷新成功");
                    } else {
                        this.$showMessage("同步失败");
                    }
                }).catch(error => {
                    console.error('刷新失败:', error);
                    this.$showMessage("刷新失败,请检查网络连接");
                });
            },
         onDaa003Change(v) {
            let o = this.lineList[this.DAA003List.indexOf(v)];
            this.orderId = o.id; this.orderNo = o.daa001;
@@ -612,7 +649,7 @@
    .current-user-section,
    .defective-section,
    .submit-section {
        font-size: 24px;
        font-size: 30px;
    }
    /* 5. 输入框字体 */
@@ -746,11 +783,13 @@
        gap: 30px;
    }
    /* 不良数量区域 */
    .defective-section {
        display: flex;
        align-items: center;
        gap: 14px;
        font-size: 18px;
        font-size: 36px; /* 从32px改为36px */
        font-weight: bold; /* 可选:加粗字体 */
    }
    .submit-section {
@@ -766,20 +805,22 @@
        box-sizing: border-box;
    }
    /* 不良数量输入框 */
    .bad-input {
        width: 320px;
        max-width: 100%;
        height: 66px;
        border: 3px solid #808080;
        font-size: 34px;
        font-size: 42px;
        text-align: center;
    }
    /* 确认提交按钮*/
    .details-btn {
        padding: 12px 34px;
        background: #00a2e9;
        color: #fff;
        font-size: 20px;
        font-size: 32px;
        border: none;
        cursor: pointer;
        border-radius: 12px;
@@ -792,7 +833,7 @@
    .current-user-section {
        display: flex;
        align-items: center;
        font-size: 18px;
        font-size: 32px;
        border: 1.5px solid #f00;
        border-radius: 10px;
        padding: 14px 22px;
@@ -803,19 +844,23 @@
    .current-user-name {
        font-weight: bold;
        font-size: 22px;
        font-size: 32px;
    }
    /* 选人按钮 - 蓝色主题 */
    .select-user-btn {
        padding: 6px 22px;
        background: #eee;
        border: 1px solid #aaa;
        border-radius: 8px;
        font-size: 24px;
        background: #00a2e9; /* 与提交按钮相同的蓝色 */
        color: #fff; /* 白色文字 */
        border: none; /* 移除边框 */
        padding: 12px 22px; /* 调整内边距与提交按钮协调 */
        border-radius: 12px; /* 与提交按钮相同的圆角 */
        font-size: 32px; /* 保持字体大小 */
        cursor: pointer;
        transition: background 0.15s; /* 添加过渡效果 */
    }
        .select-user-btn:hover {
            background: #ddd;
            background: #008ac2;
        }
    .overlay {