快乐的昕的电脑
2025-12-03 bc458b96305597cf661a86ddc66a3d29e4624b27
components/mold.vue
@@ -86,17 +86,18 @@
            <table class="styled-table">
                <thead>
                    <tr>
                        <th style="width:8%">刀具编号</th>
                        <th style="width:14%">刀具名称</th>
                        <th style="width:12%">上刀时间</th>
                        <th class="num" style="width:8%">上刀计数</th>
                        <th style="width:12%">下刀时间</th>
                        <th class="num" style="width:8%">下刀计数</th>
                        <th class="num" style="width:8%">使用次数</th>
                        <th class="num" style="width:8%">使用上限</th>
                        <th class="num" style="width:8%">寿命比%</th>
                        <th class="num" style="width:8%">寿命比预警值</th>
                        <th style="width:8%">预警状态</th>
                        <th style="width:7%">刀具编号</th>
                        <th style="width:12%">刀具名称</th>
                        <th style="width:10%">上刀时间</th>
                        <th class="num" style="width:7%">上刀计数</th>
                        <th style="width:10%">下刀时间</th>
                        <th class="num" style="width:7%">下刀计数</th>
                        <th class="num" style="width:7%">使用次数</th>
                        <th class="num" style="width:7%">使用上限</th>
                        <th class="num" style="width:7%">寿命比%</th>
                        <th class="num" style="width:7%">寿命比预警值</th>
                        <th style="width:7%">预警状态</th>
                        <th style="width:7%">刀具在机状态</th>
                    </tr>
                </thead>
                <tbody>
@@ -109,23 +110,60 @@
                        <!-- 只有第一行显示 currentCjNum,其它行显示 downCount -->
                        <td class="num">
                            <template v-if="idx === 0">
                                {{ item.currentCjNum != null ? item.currentCjNum : '' }}
                                <!-- 第一行:下机时不实时显示 currentCjNum,显示 downCount -->
                                <template v-if="!item.downTime">
                                    {{ item.currentCjNum != null ? item.currentCjNum : '' }}
                                </template>
                                <template v-else>
                                    {{ item.downCount != null ? item.downCount : '' }}
                                </template>
                            </template>
                            <template v-else>
                                {{ item.downCount != null ? item.downCount : '' }}
                            </template>
                        </td>
                        <td class="num">{{ item.useCount != null ? item.useCount : '' }}</td>
                        <!--使用次数-->
                        <td class="num">
                            <template v-if="idx === 0">
                                <!-- 第一行实时计算使用次数,若为下机则不实时显示 -->
                                <template v-if="!item.downTime">
                                    {{item.currentCjNum != null && item.upCount != null ? (Number(item.currentCjNum) - Number(item.upCount)) : (item.useCount != null ? item.useCount : '') }}
                                </template>
                                <template v-else>
                                    {{ item.useCount != null ? item.useCount : '' }}
                                </template>
                            </template>
                            <template v-else>
                                {{ item.useCount != null ? item.useCount : '' }}
                            </template>
                        </td>
                        <td class="num">{{ item.useLimit != null ? item.useLimit : '' }}</td>
                        <td class="num">{{ item.lifePercent }}</td>
                        <!--寿命比%-->
                        <td class="num">
                            <template v-if="idx === 0">
                                <!-- 第一行实时计算寿命比%,若为下机则不实时显示 -->
                                <template v-if="!item.downTime">
                                    {{item.currentCjNum != null && item.upCount != null && item.useLimit != null && Number(item.useLimit) > 0 ? Math.round((Number(item.currentCjNum) - Number(item.upCount)) / Number(item.useLimit) * 100) + '%' : (item.lifePercent != null ? item.lifePercent : '') }}
                                </template>
                                <template v-else>
                                    {{ item.lifePercent != null ? item.lifePercent : '' }}
                                </template>
                            </template>
                            <template v-else>
                                {{ item.lifePercent }}
                            </template>
                        </td>
                        <td class="num">{{ item.lifeWarn }}</td>
                        <td :class="item.warnStatus === '预警' ? 'warn-cell' : (item.warnStatus === '正常' ? 'ok-cell' : '')">
                            <span v-if="item.warnStatus === '预警'" class="warn-badge">警告</span>
                            <span v-else>{{ item.warnStatus }}</span>
                        </td>
                        <td>
                            {{ item.downTime ? '下机' : '在机' }}<!--在机状态-->
                        </td>
                    </tr>
                    <tr v-if="!toolRecords.length">
                        <td colspan="11">暂无数据</td>
                        <td colspan="12">暂无数据</td>
                    </tr>
                </tbody>
            </table>
@@ -187,7 +225,7 @@
            toolModel() { this.isDirty = true; }
        },
        methods: {
    //查询当前数采数,作为下刀计数实时显示
            //查询当前数采数,作为下刀计数实时显示
            async fetchCurrentCjNum(toolNo) {
                if (!this.machineNo) return null;
                try {
@@ -214,10 +252,9 @@
                if (this.machineNo && this.workOrderNo) {
                    await this.fetchFormData();
                    await this.fetchDefaultToolFromWorkOrder();
                    // 只更新第一行 currentCjNum
                    // 刷新后赋值第一行 currentCjNum
                    if (this.toolRecords.length > 0) {
                        const cjNum = await this.fetchCurrentCjNum(this.toolRecords[0].no);
                        this.$set(this.toolRecords[0], 'currentCjNum', cjNum);
                        this.$set(this.toolRecords[0], 'currentCjNum', this.workOrderCurrentCjNum);
                    }
                }
                this.$showMessage('刷新完成');
@@ -671,12 +708,15 @@
            this.fetchTools('');
            this.machineNo = uni.getStorageSync('machineNo') || '';
            this.workOrderNo = uni.getStorageSync('daa001') || '';
            // 去除默认预警值 (90% -> 0.9)
            //this.lifeWarnInput = '90';
            if (this.machineNo && this.workOrderNo) {
                this.fetchFormData();
                this.fetchDefaultToolFromWorkOrder();
                this.fetchFormData().then(async () => {
                    await this.fetchDefaultToolFromWorkOrder();
                    // 进入页面时赋值第一行 currentCjNum
                    if (this.toolRecords.length > 0) {
                        this.$set(this.toolRecords[0], 'currentCjNum', this.workOrderCurrentCjNum);
                    }
                });
            } else {
                console.warn('机台号或工单号为空,无法获取表单数据');
            }
@@ -1169,5 +1209,4 @@
        margin-right: 16px;
        flex: none !important; /* 关键:彻底禁止flex拉伸 */
    }
</style>