快乐的昕的电脑
2025-10-25 8665f6ea328877d28bff1750155fdfe70c9ee4d9
components/mold.vue
@@ -108,9 +108,8 @@
        <!-- 说明 -->
        <view class="tool-desc">
            <p style="color:red;">当前工单中,换了几次刀,就会产生几条数据。上刀时间、下刀时间在表中能看到。</p>
            <p style="color:red;">上刀时间和对应时间用生产计数器匹配,查出当时的生产数(累计计数)。</p>
            <p style="color:red;">寿命比预警值在刀具上,默认统一。</p>
            <p style="color:red;">'使用上限'以下刀时的'使用上限'为计算标准</p>
            <p style="color:red;">寿命比预警值默认为90%</p>
        </view>
    </view>
</template>
@@ -189,10 +188,12 @@
                            return null;
                        };
                        // 这里需要把 lifeWarn 字段也带出来
                        const mapped = (payload || []).map(t => ({
                            no: getField(t, 'cutterId', 'CUTTER_ID', 'cutteR_ID', 'daA001', 'no'),
                            name: getField(t, 'cutterName', 'CUTTER_NAME', 'cutteR_NAME', 'name'),
                            model: getField(t, 'cutterModel', 'CUTTER_MODEL', 'cutteR_MODEL', 'model')
                            model: getField(t, 'cutterModel', 'CUTTER_MODEL', 'cutteR_MODEL', 'model'),
                            lifeWarn: getField(t, 'modlLifeWorning', 'lifeWarn', 'LIFE_WARN', 'lifE_WARN')
                        }));
                        this.filteredTools = mapped;
@@ -242,6 +243,14 @@
                this.toolName = tool.name;
                this.toolModel = tool.model;
                this.activeToolNo = tool.no;
                // 新增:带出寿命比预警值
                if (tool.lifeWarn !== undefined && tool.lifeWarn !== null) {
                    // 格式化为百分比字符串
                    const warn = Number(tool.lifeWarn);
                    this.lifeWarnInput = warn <= 1 ? `${(warn * 100).toFixed(0)}%` : `${warn.toFixed(0)}%`;
                } else {
                    this.lifeWarnInput = '';
                }
            },
            confirmTool() {
                this.showToolDialog = false;
@@ -458,6 +467,18 @@
                        };
                    });
                    // 新增:按上刀时间降序排序(越晚的越上面)
                    mapped.sort((a, b) => {
                        // 时间格式如 "10-24 16:03",转为 Date 对象比较
                        const parse = s => {
                            if (!s) return 0;
                            // 补年份,假设都是今年
                            const year = new Date().getFullYear();
                            return new Date(`${year}-${s.replace(/-/g, '-')}:00`).getTime();
                        };
                        return parse(b.upTime) - parse(a.upTime); // 注意这里顺序反过来
                    });
                    this.toolRecords = mapped;
                    const totalFromRes = Number(
                        res.data?.total ?? res.data?.totalCount ?? res.total ?? res.totalCount ?? mapped.length
@@ -487,6 +508,13 @@
                        this.toolModel = order.cutterModel || order.cutteR_MODEL || '';
                        // 关键:获取工单最新采集数
                        this.workOrderCurrentCjNum = order.CurrentCjNum ?? order.currentCjNum ?? null;
                        // 新增:自动填充寿命比预警值
                        if (order.modlLifeWorning !== undefined && order.modlLifeWorning !== null) {
                            const warn = Number(order.modlLifeWorning);
                            this.lifeWarnInput = warn <= 1 ? `${(warn * 100).toFixed(0)}%` : `${warn.toFixed(0)}%`;
                        } else {
                            this.lifeWarnInput = '';
                        }
                    } else {
                        this.workOrderCurrentCjNum = null;
                    }