重构: 入库改为工序选项(废弃勾选框) + TaskTreeNode增加remark调试log + isWarehouse计算属性

This commit is contained in:
2026-08-05 15:50:39 +08:00
parent f736cf0c13
commit c2db89d9d5
2 changed files with 25 additions and 13 deletions

View File

@ -87,6 +87,11 @@ export default {
currentUsername: { type: String, default: "" }, currentUsername: { type: String, default: "" },
}, },
emits: ["action", "editRecord", "viewRecords"], emits: ["action", "editRecord", "viewRecords"],
mounted() {
console.log("TaskTreeNode task keys:", Object.keys(this.task));
console.log("task.remark =", this.task.remark);
console.log("task.description =", this.task.description);
},
computed: { computed: {
canEditRecord() { canEditRecord() {
if (this.task.assignee_id == this.currentUserId) return true; if (this.task.assignee_id == this.currentUserId) return true;

View File

@ -252,8 +252,8 @@
</picker> </picker>
</view> </view>
<!-- 接收人选择 (Picker单选) --> <!-- 接收人选择仅非入库时显示 -->
<view class="form-item"> <view v-if="!isWarehouse" class="form-item">
<text class="form-label">接收人 <text class="required">*</text></text> <text class="form-label">接收人 <text class="required">*</text></text>
<picker mode="selector" :range="userOptions" range-key="name" @change="onUserChange"> <picker mode="selector" :range="userOptions" range-key="name" @change="onUserChange">
<view class="picker-value"> <view class="picker-value">
@ -265,19 +265,21 @@
</picker> </picker>
</view> </view>
<!-- 同时入库 --> <!-- 入库提示 -->
<label class="wh-label" @tap="transferForm.warehouse = !transferForm.warehouse"> <view v-if="isWarehouse" class="warehouse-hint">
<checkbox :checked="transferForm.warehouse" style="transform:scale(0.8)" /> 同时入库 (virtual_warehouse) 📦 该任务将直接入库任务状态变为已入库
</label> </view>
<input v-model="transferForm.note" class="popup-input" placeholder="交接备注(选填)" /> <input v-model="transferForm.note" class="popup-input" placeholder="交接备注(选填)" />
<view v-if="transferForm.assignees.length && transferForm.next_task_name" class="preview-hint"> <view v-if="transferForm.next_task_name" class="preview-hint">
将创建 {{ transferForm.assignees.length }}{{ transferForm.warehouse ? ' (+仓库)' : '' }} {{ transferForm.next_task_name }}任务 {{ isWarehouse ? '产品将入库并从个人待办中移除' : '将创建 1 ' + transferForm.next_task_name + '任务指派给 ' + (selectedUserName || '') }}
</view> </view>
<view class="popup-btns"> <view class="popup-btns">
<button class="btn-cancel" @tap="closeActionPopup">取消</button> <button class="btn-cancel" @tap="closeActionPopup">取消</button>
<button class="btn-primary" :disabled="actionLoading || !transferForm.next_task_name || (!transferForm.assignees.length && !transferForm.warehouse)" @tap="doTransfer">确认转交</button> <button class="btn-primary" :disabled="actionLoading || !transferForm.next_task_name || (!isWarehouse && !transferForm.assignees.length)" @tap="doTransfer">
{{ isWarehouse ? '📦 确认入库' : '确认转交' }}
</button>
</view> </view>
</template> </template>
</view> </view>
@ -348,6 +350,9 @@ export default {
const u = this.userOptions.find(u => u.id === this.transferForm.selectedUserId); const u = this.userOptions.find(u => u.id === this.transferForm.selectedUserId);
return u ? u.name : ""; return u ? u.name : "";
}, },
isWarehouse() {
return this.transferForm.next_task_name === "🏭 入库 (virtual_warehouse)";
},
activeTask() { activeTask() {
// 查找树中第一个 WIP 或 PENDING 任务作为底部 Footer 的操作目标 // 查找树中第一个 WIP 或 PENDING 任务作为底部 Footer 的操作目标
const findActive = (tasks) => { const findActive = (tasks) => {
@ -644,7 +649,7 @@ export default {
try { try {
if (!this.userOptions.length) await this.loadUsers(); if (!this.userOptions.length) await this.loadUsers();
if (!this.processOptions.length) { if (!this.processOptions.length) {
this.processOptions = [...TASK_NAME_OPTIONS]; this.processOptions = ["🏭 入库 (virtual_warehouse)", ...TASK_NAME_OPTIONS];
} }
} finally { } finally {
uni.hideLoading(); uni.hideLoading();
@ -690,15 +695,16 @@ export default {
}, },
async doTransfer() { async doTransfer() {
this.actionLoading = true; this.actionLoading = true;
const finalAssignees = [...this.transferForm.assignees]; const finalAssignees = this.isWarehouse
if (this.transferForm.warehouse) finalAssignees.push("virtual_warehouse"); ? ["virtual_warehouse"]
: [...this.transferForm.assignees];
try { try {
await post(`/tasks/${this.actionPopup.task.id}/transfer`, { await post(`/tasks/${this.actionPopup.task.id}/transfer`, {
next_assignees: finalAssignees, next_assignees: finalAssignees,
next_task_name: this.transferForm.next_task_name.trim(), next_task_name: this.transferForm.next_task_name.trim(),
note: this.transferForm.note.trim() || undefined, note: this.transferForm.note.trim() || undefined,
}); });
uni.showToast({ title: "转交成功", icon: "success" }); uni.showToast({ title: this.isWarehouse ? "已入库" : "转交成功", icon: "success" });
this.closeActionPopup(); this.closeActionPopup();
this.doQuery(this.product.serial_number); this.doQuery(this.product.serial_number);
} catch {} finally { this.actionLoading = false; } } catch {} finally { this.actionLoading = false; }
@ -784,6 +790,7 @@ export default {
.popup-tag-wh { background: #ede9fe; color: #7c3aed; } .popup-tag-wh { background: #ede9fe; color: #7c3aed; }
.popup-add-row { display: flex; gap: 6px; } .popup-add-row { display: flex; gap: 6px; }
.wh-label { font-size: 13px; display: flex; align-items: center; gap: 4px; margin-top: 6px; color: #6b7280; } .wh-label { font-size: 13px; display: flex; align-items: center; gap: 4px; margin-top: 6px; color: #6b7280; }
.warehouse-hint { font-size: 13px; background: #ede9fe; color: #7c3aed; padding: 10px 14px; border-radius: 10px; margin: 8px 0; text-align: center; }
.preview-hint { font-size: 12px; background: #f0fdf4; color: #16a34a; padding: 8px 10px; border-radius: 8px; margin: 6px 0; } .preview-hint { font-size: 12px; background: #f0fdf4; color: #16a34a; padding: 8px 10px; border-radius: 8px; margin: 6px 0; }
/* Picker & 表单 */ /* Picker & 表单 */