fix(frontend): 流转蓝图 + 聊天室 + 卡片布局 + 打印功能修复
1. TreeCanvas.vue - Y轴坐标算法重构:
- calcSubtreeHeight 改为兄弟累加 (reduce) 替代 Math.max,彻底杜绝垂直重叠
- childNode.y = parentNode.y + CARD_H + VERTICAL_GAP 严格向下延伸
- 同级子节点按子树高度累加 startY,各占独立 Y 区域
- 加宽画布默认尺寸 (400→800, padding +300/+400)
2. detail.vue - onShow 生命周期修复:
- 新增 onShow() 钩子调用 fetchMessages(),解决聊天室退回不刷新问题
3. TaskSwipeCards.vue + detail.vue - CSS 防跳动:
- .ss-swiper-h / .ss-card-wrapper 添加 min-height: 220px
- .card 添加 min-height: 120px
4. detail.vue - 移动端打印标签:
- 新增「🖨️ 打印标签」按钮
- 双方案 ActionSheet: 网络打印机(后端API) / 蓝牙打印机(ESC/POS)
- 对接现有 /print/execute 端点
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
<view class="card-header-right">
|
||||
<text class="mode-toggle" @tap="toggleMode">{{ modeToggleLabel }}</text>
|
||||
<text class="edit-btn" @tap="openEditProduct">✏️</text>
|
||||
<text class="print-label-btn" @tap="printLabel">🖨️ 打印标签</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="info-grid">
|
||||
@ -246,6 +247,8 @@ export default {
|
||||
msgUnreadCount() { if (!this.lastMsgSeenAt) return this.messages.length; return this.messages.filter(m => m.created_at > this.lastMsgSeenAt).length; },
|
||||
},
|
||||
onLoad(options) { this.loadUsers(); this.loadCurrentUser(); const sn = options.serial || ""; if (sn) this.doQuery(sn); },
|
||||
// 🚀 onShow 生命周期:每次页面显示时刷新留言板(解决从聊天室退回不更新问题)
|
||||
onShow() { if (this.product?.id) { this.fetchMessages(); } },
|
||||
methods: {
|
||||
formatUserName, formatUserAvatar,
|
||||
formatName(name) { if (!name) return ""; return name.length === 2 ? name[0] + " " + name[1] : name; },
|
||||
@ -326,6 +329,37 @@ export default {
|
||||
closeMsgDrawer() { const last = this.messages[this.messages.length - 1]; this.lastMsgSeenAt = last ? last.created_at : new Date().toISOString(); this.showMsgDrawer = false; },
|
||||
scrollToBottom() { this.$nextTick(() => { this.bottomMsgId = 'msg-bottom'; }); },
|
||||
fmtMsgTime(d) { if (!d) return ''; const dt = new Date(d); const pad = (n) => String(n).padStart(2, '0'); return `${pad(dt.getMonth()+1)}-${pad(dt.getDate())} ${pad(dt.getHours())}:${pad(dt.getMinutes())}`; },
|
||||
// 🖨️ 打印标签:调用后端 API 发送打印指令
|
||||
async printLabel() {
|
||||
if (!this.product?.serial_number) return;
|
||||
uni.showActionSheet({
|
||||
itemList: ['网络打印机(后端API)', '蓝牙打印机(ESC/POS)'],
|
||||
success: async (res) => {
|
||||
if (res.tapIndex === 0) {
|
||||
// 方案A:网络打印机 → 调用后端 /print/execute API
|
||||
try {
|
||||
uni.showLoading({ title: '发送打印指令...' });
|
||||
await post(`/print/execute`, {
|
||||
serial_number: this.product.serial_number,
|
||||
material_name: this.product.material_name || '',
|
||||
spec_model: this.product.spec_model || '',
|
||||
order_no: this.product.order_no || '',
|
||||
copies: 1,
|
||||
});
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '打印指令已发送', icon: 'success' });
|
||||
} catch (e) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: e?.data?.detail || '打印失败', icon: 'none' });
|
||||
}
|
||||
} else if (res.tapIndex === 1) {
|
||||
// 方案B:蓝牙打印机 → 前端直连 ESC/POS 指令
|
||||
// ⚠️ 需要引入蓝牙打印 SDK,当前为占位架构
|
||||
uni.showToast({ title: '蓝牙打印功能开发中', icon: 'none' });
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@ -339,12 +373,13 @@ export default {
|
||||
.overall-val { font-size: 15px; font-weight: 700; color: #2563eb; flex: 1; }
|
||||
.overall-empty { color: #ef4444; }
|
||||
.overall-arrow { font-size: 12px; color: #9ca3af; }
|
||||
.card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); flex-shrink: 0; }
|
||||
.card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); flex-shrink: 0; min-height: 120px; }
|
||||
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
|
||||
.card-header-right { display: flex; align-items: center; gap: 8px; }
|
||||
.card-title { font-size: 15px; font-weight: 700; }
|
||||
.edit-btn { font-size: 18px; padding: 2px 6px; }
|
||||
.mode-toggle { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 8px; background: #eff6ff; color: #2563eb; }
|
||||
.print-label-btn { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 8px; background: #fef3c7; color: #b45309; margin-left: 4px; }
|
||||
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
|
||||
.label { font-size: 12px; color: #9ca3af; }
|
||||
.value { font-size: 14px; color: #1f2937; font-weight: 600; word-break: break-all; }
|
||||
|
||||
Reference in New Issue
Block a user