快乐的昕的电脑
2025-10-16 77084439440fed9bb54e65f98b363f2d64fae7b0
新增:历史报工记录数组
已修改1个文件
185 ■■■■■ 文件已修改
components/WorkOrderPrint.vue 185 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
components/WorkOrderPrint.vue
@@ -21,7 +21,8 @@
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                            <!-- 当前实时统计(保持原来单行) -->
                            <tr class="summary-row">
                                <td>{{ nowTime }}</td>
                                <td>{{ staffDisplay || '-' }}</td>
                                <td>{{ orderNo || '-' }}</td>
@@ -34,11 +35,29 @@
                                <td>{{ calculatedDefectiveCount }}</td>
                                <td>{{ sQuantity }}</td>
                            </tr>
                            <!-- 历史报工记录行 -->
                            <tr v-for="(r, idx) in reportingHistory" :key="idx">
                                <td>{{ r.time }}</td>
                                <td>{{ r.staff || '-' }}</td>
                                <td>{{ r.orderNo || '-' }}</td>
                                <td>{{ r.productName || '-' }}</td>
                                <td>{{ r.planQty }}</td>
                                <td>{{ r.machineNo || '-' }}</td>
                                <td>{{ r.initialValue }}</td>
                                <td>{{ r.productionCount }}</td>
                                <td>{{ r.totalProduction }}</td>
                                <td>{{ r.defective }}</td>
                                <td>{{ r.good }}</td>
                            </tr>
                            <tr v-if="!reportingHistory.length">
                                <td colspan="11" class="no-data">暂无历史报工记录</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </view>
            <!-- 下面原有内容保持不变 -->
            <view class="status-row">
                <view class="status-box">
                    <text>机台面板数:</text>
@@ -68,106 +87,8 @@
                </view>
            </view>
            <view class="flex-row gap-lg">
                <view class="print-section flex-grow">
                    <view class="barcode-info">
                        <view class="user-select">
                            <text>不良数量:</text>
                            <input v-model="customAmount" class="inp bad-input" placeholder="请输入数量" />
                        </view>
                        <view class="user-select">
                            <button class="details-btn" @click="confirmCustomAmount">确认提交</button>
                        </view>
                    </view>
                </view>
                <view class="current-user-section fill-width">
                    <text>当前报工人:</text>
                    <text class="current-user-name">{{ staffDisplay || '未选择' }}</text>
                    <button class="select-user-btn" @click="isShowUserSelect = true">选人</button>
                </view>
            </view>
            <!-- 选人弹窗 -->
            <view v-if="isShowUserSelect" class="overlay">
                <view class="popup user-select-popup">
                    <!-- 搜索栏 -->
                    <view class="user-search-bar">
                        <input v-model.trim="userSearch"
                               type="text"
                               class="user-search-input"
                               placeholder="输入工号或姓名搜索"
                               @keydown.enter.prevent />
                        <button v-if="userSearch" class="user-search-clear" @click="userSearch=''">清空</button>
                        <view class="user-search-info">
                            匹配:{{ filteredUsers.length }} / {{ users.length }}
                        </view>
                    </view>
                    <view class="user-list-scroll">
                        <template v-if="filteredUsers.length">
                            <view class="user-list-grid">
                                <button v-for="(u, index) in filteredUsers"
                                        :key="index"
                                        :class="['user-list-btn', {'selected': u===staffNo}]"
                                        @click="selectUser(u)">
                                    <span class="user-code">{{ u.split(':')[0] }}</span>
                                    <span class="user-name">{{ u.split(':')[1] }}</span>
                                </button>
                            </view>
                        </template>
                        <view v-else class="no-user-result">
                            未找到匹配人员
                        </view>
                    </view>
                    <view class="user-popup-footer">
                        <button class="clean-btn wide-btn" @click="isShowUserSelect = false">关闭</button>
                    </view>
                </view>
            </view>
            <view class="bottom-section">
                <button class="save-btn" @click="save">保存并生效</button>
                <button class="cancel-btn" @click="cancel">取消</button>
            </view>
            <!-- 保留旧弹窗 -->
            <view v-if="isShow" class="overlay">
                <view class="popup">
                    <view class="bottom-section1">
                        <button class="clean-btn" type="warn" @click="deleteBarcode">关闭</button>
                    </view>
                    <view class="reason-section">
                        <text>报工人:</text>
                        <view class="reason-buttons">
                            <button v-for="(u,index) in users" :key="index"
                                    :class="{'reason-btn':true,'selected': user===u}"
                                    @click="toggleUser(u)">
                                {{ formatUser(u) }}
                            </button>
                        </view>
                    </view>
                </view>
            </view>
            <view v-if="barcodeIsShow" class="overlay">
                <view class="popup">
                    <uni-table ref="table" border stripe emptyText="暂无更多数据" class="table1">
                        <uni-tr>
                            <uni-th align="center" style="font-size:40px;">生成时间</uni-th>
                            <uni-th align="center" style="width:39%;font-size:40px;">条码</uni-th>
                            <uni-th align="center" style="font-size:40px;">报工人</uni-th>
                            <uni-th align="center" style="font-size:40px;">报工数量</uni-th>
                        </uni-tr>
                        <uni-tr v-for="(item,index) in reportingList" :key="index">
                            <uni-td align="center"><input type="text" v-model="item.bgDate" style="width:26vh;" /></uni-td>
                            <uni-td align="center"><input v-model="item.itemNoCade" style="width:40vh;" /></uni-td>
                            <uni-td align="center"><input v-model="item.staffName" /></uni-td>
                            <uni-td align="center"><input v-model="item.okQty" /></uni-td>
                        </uni-tr>
                    </uni-table>
                    <view><button class="clean-btn" type="warn" @click="barcodeIsShow=false">关闭</button></view>
                </view>
            </view>
            <!-- 其余模板保持原样 -->
            <!-- ... -->
        </view>
    </view>
</template>
@@ -191,21 +112,21 @@
                printNum: 1, reportingList: [], printLoading: false, customAmount: '',
                isGeneratingBarcode: false, lastGenerateTime: 0, generateRequestId: null,
                nowTimeTimer: null, nowTime: '',
                // 新增:搜索关键字
                userSearch: ''
                userSearch: '',
                /* 新增:历史报工记录数组 */
                reportingHistory: []
            }
        },
        computed: {
            calculatedCurrentCount() { return (this.productionCount || 0) - (this.initialValue || 0); },
            calculatedTotalProduction() { return (this.kgQty || 0) + this.calculatedCurrentCount; },
            calculatedTotalProduction() { return (this.kgQty || 0); }, // 若需要恢复之前逻辑可改为 (this.kgQty||0)+this.calculatedCurrentCount
            calculatedDefectiveCount() { return this.calculatedTotalProduction - (this.sQuantity || 0); },
            planQtyDisplay() { return this.order.planQty || this.order.planQuantity || this.order.daa008|| 0; },
            planQtyDisplay() { return this.order.planQty || this.order.planQuantity || this.order.daa008 || 0; },
            staffDisplay() {
                if (!this.staffNo) return '';
                const segs = this.staffNo.split(':');
                return segs.length > 1 ? `${segs[0]} ${segs[1]}` : this.staffNo;
            },
            // 新增:过滤后的用户列表
            filteredUsers() {
                if (!this.userSearch) return this.users;
                const kw = this.userSearch.trim().toLowerCase();
@@ -261,6 +182,7 @@
                if (!this.orderId && !this.orderNo) return;
                this.getOrderById();
                this.getWomdaaPrintById();
                this.getReportingHistory(); // 新增:每次刷新同步历史
                if (flag) {
                    this.$post({ url: "/Womdaa/GetWomdaasByShow", data: { machineNo: this.machineNo } })
                        .then(res => {
@@ -269,6 +191,34 @@
                        });
                }
            },
            /* 新增:获取历史报工记录 */
            getReportingHistory() {
                if (!this.orderNo) { this.reportingHistory = []; return; }
                this.$post({
                    // 后端需要提供按 BILL_NO 查询的接口,示例路径:
                    url: "/MesReporting/GetByBillNo",
                    data: { billNo: this.orderNo }
                }).then(res => {
                    const list = res?.data?.tbBillList || res?.data || [];
                    this.reportingHistory = list.map(r => {
                        // 依据你数据库字段做映射(下面字段名按常见命名举例,需要按实际改)
                        return {
                            time: r.bgDate || r.startTime || r.createTime || '',        // 开始时间
                            staff: (r.staffNo ? (r.staffNo + ' ' + (r.staffName || '')) : (r.staffName || '')),
                            orderNo: r.billNo || this.orderNo,
                            productName: r.daa003 || this.order?.daa003,
                            planQty: this.planQtyDisplay,
                            machineNo: r.machineNo || this.machineNo,
                            initialValue: r.initialValue ?? 0,
                            productionCount: r.productionCount ?? r.todayOutput ?? 0,
                            totalProduction: r.kgQty ?? r.totalProduction ?? 0,
                            good: r.sQuantity ?? r.okQty ?? 0,
                            defective: (r.defectiveQty ??
                                ((r.kgQty ?? r.totalProduction ?? 0) - (r.sQuantity ?? r.okQty ?? 0)))
                        }
                    });
                }).catch(() => { this.reportingHistory = []; });
            },
            toggleUser(u) {
                if (!u) return;
                this.user = this.user === u ? null : u;
@@ -276,9 +226,8 @@
            },
            confirmCustomAmount() {
                if (!this.customAmount || isNaN(Number(this.customAmount))) { this.$showMessage('请输入有效的数量'); return; }
                if (!this.staffNo) { this.$showMessage('请选择报工人'); return; }//传递报工人
                // 拆分工号和姓名,取工号
                const staffNo = this.staffNo.split(':')[0];
                if (!this.staffNo) { this.$showMessage('请选择报工人'); return; }
                const staffNo = this.staffNo.split(':')[0];
                const amount = Number(this.customAmount);
                this.$post({
                    url: "/MesInvItemBarcodes/AddBFToBarcodes",
@@ -286,18 +235,19 @@
                        orderNo: this.orderNo,
                        orderId: this.orderId,
                        bf: amount,
                        staffNo: staffNo //报工人编号
                        staffNo: staffNo
                    }
                }).then(res => {
                    if (res.status == 1) { this.$showMessage(res.message); return; }
                    this.$showMessage('报废数量填写成功');
                    this.fetchData(true);
                    this.fetchData(true); // 自动刷新历史
                    this.customAmount = '';
                }).catch(() => this.$showMessage('报废数量填写失败,请重试'));
            },
            save() {
                if (!this.staffNo) { this.$showMessage('请选择报工人'); return; }
                uni.showToast({ title: '保存成功', icon: 'success' });
                this.getReportingHistory(); // 保存后也可刷新
            },
            cancel() { uni.showToast({ title: '取消操作', icon: 'none' }); },
            getOrderById() {
@@ -390,6 +340,19 @@
</script>
<style scoped>
    /* 原样式保持,新增几行辅助样式 */
    .report-table .summary-row {
        background: #f0f8ff;
        font-weight: 600;
    }
    .report-table .no-data {
        text-align: center;
        color: #777;
        font-size: 14px;
    }
    /* 其余样式保持不变 */
    .page {
        padding: 1.2vh 2vw;
        display: flex;