tjx
2025-11-04 aa89ca0a32631d365b42ab7d1e9dbb60a8ae8108
components/mold.vue
@@ -2,18 +2,16 @@
    <view class="page">
        <!-- 刀具选择区 -->
        <view class="top-section-grid">
            <!-- 第一行 -->
            <!-- 第一行:移除刀具目录按钮 -->
            <view class="form-row">
                <view class="form-cell">
                    <label class="form-label">刀具编号:</label>
                    <input class="input small-font" v-model="selectedToolNo" placeholder="请通过刀具目录选择" disabled />
                    <button class="btn-blue" @click="openToolDialog" :disabled="loadingTools">刀具目录</button>
                </view>
                <view class="form-cell">
                    <label class="form-label">设置使用上限:</label>
                    <input class="input small-font" type="number" v-model="useLimitInput" placeholder="每次换刀后手填" :disabled="!selectedToolNo || loadingForm" />
                </view>
                <!-- 新增:寿命比预警值输入框 -->
                <view class="form-cell">
                    <label class="form-label">寿命比预警值:</label>
                    <view class="input-with-unit">
@@ -26,7 +24,7 @@
                </view>
            </view>
            <!-- 第二行 -->
            <!-- 第二行:在最后添加刀具目录按钮 -->
            <view class="form-row">
                <view class="form-cell">
                    <label class="form-label">刀具名称:</label>
@@ -36,10 +34,13 @@
                    <label class="form-label">规格型号:</label>
                    <input class="input small-font" v-model="toolModel" placeholder="刀具带出" disabled />
                </view>
                <!-- 新增的刀具目录按钮 -->
                <view class="form-cell">
                    <button class="btn-blue large-btn" @click="openToolDialog" :disabled="loadingTools">刀具目录</button>
                </view>
            </view>
        </view>
        <!-- 操作按钮 -->
        </view>  <!-- 这里闭合 top-section-grid -->
        <!-- 操作按钮 - 移出 top-section-grid -->
        <view class="button-row">
            <button class="save-btn" @click="handleUpTool" :disabled="submitting || loadingForm">上刀提交</button>
            <button class="save-btn" @click="handleDownTool" :disabled="submitting || loadingForm">下刀提交</button>
@@ -48,81 +49,81 @@
        <!-- 刀具目录弹窗 -->
        <view v-if="showToolDialog" class="dialog-overlay">
            <view class="dialog">
                <view class="form-group">
                    <input v-model="searchKey" placeholder="输入刀具编码、名称模糊搜索" class="input" @input="onSearchKeyInput" />
                    <button class="btn-blue" @click="searchTool" :disabled="loadingTools">搜索</button>
                <view class="dialog">
                    <view class="form-group">
                        <input v-model="searchKey" placeholder="输入刀具编码、名称模糊搜索" class="input" @input="onSearchKeyInput" />
                        <button class="btn-blue" @click="searchTool" :disabled="loadingTools">搜索</button>
                    </view>
                    <view class="tool-list">
                        <button v-for="tool in filteredTools"
                                :key="tool.no"
                                class="tool-btn"
                                :class="{ active: activeToolNo === tool.no }"
                                @click="selectTool(tool)">
                            {{ tool.no }} | {{ tool.name }}
                        </button>
                    </view>
                    <view class="dialog-actions">
                        <div style="display: flex; align-items: center;">
                            <button class="btn-blue" @click="prevPage" :disabled="pageIndex === 1 || loadingTools">上一页</button>
                            <span style="margin: 0 12px;">第{{ pageIndex }}页 / 共{{ totalPages }}页</span>
                            <button class="btn-blue" @click="nextPage" :disabled="pageIndex === totalPages || loadingTools">下一页</button>
                        </div>
                        <div style="display: flex; gap: 18px; align-items: center;">
                            <button class="btn-blue" @click="confirmTool">确定</button>
                            <button class="btn-disabled" @click="closeToolDialog">取消</button>
                        </div>
                    </view>
                </view>
                <view class="tool-list">
                    <button v-for="tool in filteredTools"
                            :key="tool.no"
                            class="tool-btn"
                            :class="{ active: activeToolNo === tool.no }"
                            @click="selectTool(tool)">
                        {{ tool.no }} | {{ tool.name }}
                    </button>
                </view>
                <view class="dialog-actions">
                    <div style="display: flex; align-items: center;">
                        <button class="btn-blue" @click="prevPage" :disabled="pageIndex === 1 || loadingTools">上一页</button>
                        <span style="margin: 0 12px;">第{{ pageIndex }}页 / 共{{ totalPages }}页</span>
                        <button class="btn-blue" @click="nextPage" :disabled="pageIndex === totalPages || loadingTools">下一页</button>
                    </div>
                    <div style="display: flex; gap: 18px; align-items: center;">
                        <button class="btn-blue" @click="confirmTool">确定</button>
                        <button class="btn-disabled" @click="closeToolDialog">取消</button>
                    </div>
                </view>
            </view>
        </view>
        <!-- 刀具使用记录表格 -->
        <view class="table-section">
            <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>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="(item, idx) in toolRecords" :key="item.id" :class="{'row-odd': idx % 2 === 0}">
                        <td>{{ item.no }}</td>
                        <td class="left">{{ item.name }}</td>
                        <td>{{ item.upTime }}</td>
                        <td class="num">{{ item.upCount != null ? item.upCount : '' }}</td>
                        <td>{{ item.downTime }}</td>
                        <td class="num">{{ item.downCount != null ? item.downCount : '' }}</td>
                        <td class="num">{{ item.useCount != null ? item.useCount : '' }}</td>
                        <td class="num">{{ item.useLimit != null ? item.useLimit : '' }}</td>
                        <td class="num">{{ item.lifePercent }}</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>
                    </tr>
                    <tr v-if="!toolRecords.length">
                        <td colspan="11">暂无数据</td>
                    </tr>
                </tbody>
            </table>
                <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>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="(item, idx) in toolRecords" :key="item.id" :class="{'row-odd': idx % 2 === 0}">
                            <td>{{ item.no }}</td>
                            <td class="left">{{ item.name }}</td>
                            <td>{{ item.upTime }}</td>
                            <td class="num">{{ item.upCount != null ? item.upCount : '' }}</td>
                            <td>{{ item.downTime }}</td>
                            <td class="num">{{ item.downCount != null ? item.downCount : '' }}</td>
                            <td class="num">{{ item.useCount != null ? item.useCount : '' }}</td>
                            <td class="num">{{ item.useLimit != null ? item.useLimit : '' }}</td>
                            <td class="num">{{ item.lifePercent }}</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>
                        </tr>
                        <tr v-if="!toolRecords.length">
                            <td colspan="11">暂无数据</td>
                        </tr>
                    </tbody>
                </table>
        </view>
        <!-- 说明 -->
        <!--<view class="tool-desc">
            <p style="color:red;">'使用上限'以下刀时的'使用上限'为计算标准</p>
            <p style="color:red;">寿命比预警值默认为90%</p>
        </view>-->
            <!-- 说明 -->
            <!--<view class="tool-desc">
        <p style="color:red;">'使用上限'以下刀时的'使用上限'为计算标准</p>
        <p style="color:red;">寿命比预警值默认为90%</p>
    </view>-->
    </view>
</template>
@@ -643,28 +644,31 @@
</script>
<style scoped>
    /* 原样保持,未改动样式,只插入了一个输入框 */
    /* 优化顶部表单区域样式 */
    .top-section-grid {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 16px;
        gap: 12px;
        margin-bottom: 2vh;
        width: 95vw;
        max-width: 1600px;
        margin-left: auto;
        margin-right: auto;
        padding: 12px;
        background: #f8f9fa;
        border-radius: 8px;
        border: 1px solid #e9ecef;
    }
    /* 新增:表单行样式 */
    /* 表单行样式优化 */
    .form-row {
        display: flex;
        justify-content: center;
        align-items: flex-end;
        gap: 32px;
        margin-bottom: 16px;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin-bottom: 8px;
    }
        .form-row:last-child {
@@ -674,62 +678,72 @@
    .form-cell {
        display: flex;
        align-items: center;
        flex: 1;
        margin: 0 8px;
        min-height: 44px;
    }
    .form-label {
        width: 90px;
        width: 100px;
        font-weight: bold;
        font-size: 18px;
        color: #333;
        white-space: nowrap;
        margin-right: 8px;
        flex-shrink: 0;
    }
    .input {
        padding: 1vh;
        font-size: 1.1vw;
        border: 1px solid #ccc;
        width: 10vw;
        margin-right: 8px;
        border-radius: 6px;
        background: #f8f8f8;
        padding: 8px 12px;
        font-size: 16px;
        border: 1px solid #dcdfe6;
        flex: 1;
        margin-right: 0;
        border-radius: 4px;
        background: #fff;
        min-width: 0;
        height: 36px;
        box-sizing: border-box;
    }
        /* 新增:小字体样式 */
        .input.small-font {
            font-size: 1vw; /* 调小字体 */
            font-size: 15px;
        }
    .form-select {
        width: 12vw;
        padding: 1vh;
        font-size: 1.1vw;
        margin-right: 8px;
        border-radius: 6px;
        background: #f8f8f8;
    }
        .input:disabled {
            background-color: #f5f7fa;
            color: #c0c4cc;
            cursor: not-allowed;
        }
    .btn-blue {
        background-color: #00A2E9;
        background-color: #1890ff;
        color: white;
        border: none;
        padding: 14px 36px;
        margin-left: 8px;
        border-radius: 10px;
        padding: 8px 16px;
        border-radius: 4px;
        cursor: pointer;
        font-size: 1.1vw;
        font-weight: bold;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
        transition: background 0.2s, box-shadow 0.2s;
        font-size: 16px;
        font-weight: 500;
        white-space: nowrap;
        height: 36px;
        box-sizing: border-box;
        transition: all 0.3s;
        flex-shrink: 0;
    }
        .btn-blue:active,
        .btn-blue:focus {
            background-color: #0086c2;
            box-shadow: 0 4px 12px rgba(0,162,233,0.12);
        .btn-blue:hover {
            background-color: #40a9ff;
        }
        .btn-blue:active {
            background-color: #096dd9;
        }
        .btn-blue:disabled {
            background: #b3e0f7;
            color: #eee;
            background: #bae7ff;
            color: #91d5ff;
            cursor: not-allowed;
            box-shadow: none;
        }
    .button-row {
@@ -756,6 +770,20 @@
        color: #333;
    }
    .save-btn:hover {
        background-color: #40a9ff;
    }
    .save-btn:active {
        background-color: #096dd9;
    }
    .save-btn:disabled, .cancel-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }
    /* 弹窗样式 */
    .dialog-overlay {
        position: fixed;
        top: 0;
@@ -852,6 +880,7 @@
        box-shadow: none;
    }
    /* 表格样式 */
    .table-section {
        display: flex;
        justify-content: center;
@@ -935,47 +964,60 @@
        font-size: 0.9vw;
    }
    .header-badge {
        display: inline-block;
        background: #fff7e6;
        color: #8a6d00;
        border: 1px solid #ffe58f;
        padding: 1px 6px;
        border-radius: 3px;
        margin-left: 6px;
        font-size: 0.8vw;
        vertical-align: middle;
    }
    .warn {
        color: red;
        font-weight: bold;
    }
    .bottom-section {
        display: flex;
        justify-content: space-around;
        margin-top: 2vh;
    }
    .tool-desc {
        margin-top: 2vh;
    }
    /* 新增:带单位的输入框样式 */
    /* 带单位的输入框样式 */
    .input-with-unit {
        display: flex;
        align-items: center;
        flex: 1;
    }
        .input-with-unit .input {
            width: 10vw;
            flex: 1;
            margin-right: 8px;
        }
    .unit-text {
        color: #666;
        font-size: 0.9vw;
        font-size: 14px;
        white-space: nowrap;
        width: 20px;
    }
    /* 响应式调整 */
    @media (max-width: 1200px) {
        .form-cell {
            margin: 0 4px;
        }
        .form-label {
            width: 90px;
            font-size: 16px;
        }
        .input {
            font-size: 14px;
            padding: 6px 10px;
        }
        .btn-blue {
            padding: 6px 12px;
            font-size: 14px;
        }
    }
    /* 新增大按钮样式 */
    .btn-blue.large-btn {
        padding: 8px 24px;
        font-size: 16px;
        height: 36px;
        min-width: 100px;
    }
    /* 调整表单单元格布局以适应按钮 */
    .form-row .form-cell:last-child {
        justify-content: center;
        flex: 0 0 auto;
        min-width: 120px;
    }
</style>