Files
syops/frontend/src/features/order-delivery-reply/views/OrderDeliveryReplyPage.vue
T

1050 lines
52 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* features/order-delivery-reply/views/OrderDeliveryReplyPage.vue
* 用途:订单交期回复工作台操作页——筛选分页、单行/联合回复批次、单行/批量通知、手动同步。
* 依赖:api/orderDeliveryReply.api(统一 requestJson)、useMessage、auth store(manage/access 权限)、
* element-plus、PaginationBar。
* 逻辑:所有数据只读本地快照;保存与通知是两步(联合回复只保存,批量通知才发送并锁定);
* 保存/通知成功后即时刷新列表(需求 §9);仅 access 用户隐藏全部写操作。
* 回复弹窗数量守恒(2026-09-23 由「超额仅提醒」修订):每行各批次合计必须等于订单数量
* 才能保存,弹窗实时红字提示 + 保存拦截,后端 422 兜底。
* 企微卡片直达:登录回跳后 query 仍在,按 status/order_no/line_no 还原筛选并滚动高亮目标行,
* wecom_trace 上报打开回执——保证「点卡片 → 登录 → 直达该 Agent 对应内容与位置」。
* 列顺序:客户编号(简称副文案) → 订单日期 → 订单单号:项次 → 产品编号(品名副文案) →
* 客户产品编号 → 数量 → 约定交货日 → 交期回复状态 → 交期回复 → 交期回复人员 →
* 业务员(部门副文案) → 客户订单 → 规格 → 单位 → 通知时间(2026-10-09 自交期回复人员列拆出);
* 独立的部门列/品名列已并入合并展示。
* 浏览体验:页面高度收敛至视口(滚动全部发生在表格容器内 → 列头 sticky 固定、横向滚动条
* 常驻表格底缘);左侧冻结前四列标识区(勾选/客户编号/订单日期/订单单号:项次,
* 冻结单元格用 utilities.css 的 frozen-cell 实色基底防透出,并随行悬停/选中/直达高亮联动);
* 筛选区无外置字段标签(提示字占位已取消,含义由 placeholder/选项承担,aria-label 保留无障碍语义),
* 输入框/按钮显式 text-sm + h-9(36px),与合同付款预警 .contract-filter-input/.contract-filter-submit
* (14px/600/36px/圆角8px)渲染规格逐项一致。
* 交期回复列批次交互(2026-10-09):动作入口统一为批次条前的加号(lucide Plus,title/aria 复用
* replyAction/editReplyAction 键)——未回复=空批次条(不显示时间/数量)+ 加号回复;
* 已回复/部分回复=加号修改回复(仅未锁定可管理);「交期已锁定」徽标已取消(锁定状态由
* 无加号与交期回复人员列「已通知」体现)。全表批次条左缘对齐:所有行首条批次前保留
* w-6 加号占位,展开行其余批次条加 pl-7 缩进;>1 批时首条批次后保留展开/收起小箭头
* (▼ 全部 / ▲ 收起只留第一批)。
* 批次条就地编辑(2026-10-09):未锁定可管理行点击批次条原地变「日期+数量」输入(预填当前值;
* 未回复行空批次条点击=新增第一条批次),输入条渲染后自动聚焦日期框;回车/失焦自动保存单行
* 接口(整行批次提交,与弹窗保存同口径校验);校验失败红字持续显示并重聚焦日期框,直至修正
* 保存或 Esc 取消;双清空=放弃编辑;批次条不显示备注内容;多批次/备注仍走加号弹窗。
* 表格对齐(2026-10-09):除交期回复列(批次条按既定左对齐布局)外,全列内容水平居中、
* 行内容垂直居中,列头文字全部居中;交期回复状态徽标统一等宽(min-w-68px)。
* 设计系统(docs/ui/DESIGN_SYSTEM.md):根节点挂 page-shell;区块容器用 surface-panel;
* 筛选和回复弹窗用 Element Plus;冻结列和批次条就地编辑保持原表格。
* 状态与交互色一律走 --status-* 令牌(badge-*/bg-row-*/frozen-cell-*),品牌强调用 brand-*。
* 批量通知确认使用 ElMessageBox.confirm。
*/
<script setup lang="ts">
import { computed, nextTick, onMounted, reactive, ref } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useAuthStore } from '@/features/auth/stores/auth.store';
import { useMessage } from '@/shared/composables/useMessage';
import { requestJson } from '@/shared/api/client';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import { Download } from '@element-plus/icons-vue';
import {
ElButton,
ElCheckbox,
ElDatePicker,
ElDialog,
ElInput,
ElMessageBox,
ElOption,
ElSelect,
} from 'element-plus';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/shared/styles/element-theme.css';
import { ChevronDown, ChevronUp, Plus } from 'lucide-vue-next';
import {
ORDER_DELIVERY_REPLY_MANAGE_PERMISSION,
} from '@/features/order-delivery-reply/constants';
import {
batchReplyOrderDelivery,
exportOrderDeliveryLines,
getLatestOrderDeliverySync,
listOrderDeliveryLines,
notifyOrderDeliveryBatch,
runOrderDeliverySync,
saveOrderDeliveryBatches,
type BatchSummary,
type OrderDeliveryLine,
type OrderDeliverySyncRun,
} from '@/features/order-delivery-reply/api/orderDeliveryReply.api';
const { t } = useI18n();
const msg = useMessage();
const auth = useAuthStore();
/** manage 可写(保存/通知/同步);access 或 manage 可看(路由与侧栏已按 access 守卫)。 */
const canManage = computed(() => auth.hasFeaturePermission(ORDER_DELIVERY_REPLY_MANAGE_PERMISSION));
/* ============ 列表查询 ============ */
const filters = reactive({ keyword: '', order_date: '', status: '' as '' | 'replied' | 'not_fully_replied' });
const appliedFilters = reactive({ ...filters });
const items = ref<OrderDeliveryLine[]>([]);
const total = ref(0);
const page = ref(1);
const pageSize = ref(50);
const pageSizeOptions = [20, 50, 100, 200];
const loading = ref(false);
const latestSync = ref<OrderDeliverySyncRun | null>(null);
async function loadLines() {
loading.value = true;
try {
const data = await listOrderDeliveryLines({ ...appliedFilters, page: page.value, page_size: pageSize.value });
items.value = data.items;
total.value = data.total;
if (data.page !== page.value) page.value = data.page;
} catch (error) {
msg.error(error instanceof Error ? error.message : t('workspace.orderDeliveryReply.loadFailed'));
} finally {
loading.value = false;
}
}
async function loadLatestSync() {
try {
latestSync.value = await getLatestOrderDeliverySync();
} catch {
latestSync.value = null;
}
}
function doSearch() {
clearHighlight();
Object.assign(appliedFilters, filters);
page.value = 1;
void loadLines();
}
function doReset() {
Object.assign(filters, { keyword: '', order_date: '', status: '' });
doSearch();
}
/** 分页条:页码跳转(与管理控制台数据报表同一 PaginationBar 组件)。 */
function goToPage(next: number) {
if (next === page.value) return;
page.value = next;
void loadLines();
}
/** 切换每页条数:回到第 1 页并重查。 */
function changePageSize(size: number) {
if (size === pageSize.value) return;
pageSize.value = size;
page.value = 1;
void loadLines();
}
/** 手动同步(manage):同步执行完成后刷新列表与最近同步时间。 */
const syncing = ref(false);
async function doSync() {
syncing.value = true;
try {
const result = await runOrderDeliverySync();
if (result.status === 'skipped') {
msg.warning(t('workspace.orderDeliveryReply.syncSkipped'));
} else {
msg.success(t('workspace.orderDeliveryReply.syncDone', { count: result.line_count }));
}
await Promise.all([loadLines(), loadLatestSync()]);
} catch (error) {
msg.error(error instanceof Error ? error.message : t('workspace.orderDeliveryReply.syncFailedTitle'));
} finally {
syncing.value = false;
}
}
/* ============ 勾选(全选仅本页) ============ */
const selected = ref<string[]>([]);
const expanded = ref<string[]>([]);
const lineKey = (line: OrderDeliveryLine) => `${line.order_no}:${line.line_no}`;
const selectedLines = computed(() => items.value.filter((line) => selected.value.includes(lineKey(line))));
const allChecked = computed(() => items.value.length > 0 && items.value.every((line) => selected.value.includes(lineKey(line))));
const someChecked = computed(() => !allChecked.value && items.value.some((line) => selected.value.includes(lineKey(line))));
/** 勾选中「已有批次且未锁定」的行才可批量通知(无批次/已锁定会被后端 skipped)。 */
const notifiableSelected = computed(() => selectedLines.value.filter((line) => line.batches.length > 0 && !line.locked));
function toggleLine(line: OrderDeliveryLine, on: boolean) {
const key = lineKey(line);
selected.value = on ? [...selected.value, key] : selected.value.filter((k) => k !== key);
}
function togglePageAll(on: boolean) {
if (on) {
const keys = new Set(selected.value);
items.value.forEach((line) => keys.add(lineKey(line)));
selected.value = [...keys];
} else {
const pageKeys = new Set(items.value.map(lineKey));
selected.value = selected.value.filter((k) => !pageKeys.has(k));
}
}
function toggleExpand(key: string) {
expanded.value = expanded.value.includes(key)
? expanded.value.filter((k) => k !== key)
: [...expanded.value, key];
}
/* ============ 派生展示 ============ */
type LineStatus = OrderDeliveryLine['status'];
/** 状态徽章:颜色走 badge-success/warning/error(--status-* 令牌,亮暗自适应)。 */
const statusMeta = (status: LineStatus) => {
const map: Record<LineStatus, { label: string; cls: string }> = {
not_replied: { label: t('workspace.orderDeliveryReply.statusNotReplied'), cls: 'badge-error' },
partial_replied: { label: t('workspace.orderDeliveryReply.statusPartial'), cls: 'badge-warning' },
replied: { label: t('workspace.orderDeliveryReply.statusReplied'), cls: 'badge-success' },
};
return map[status];
};
/* ============ 回复弹窗(单行 / 联合) ============ */
interface EditableBatch { planned_date: string; qty: string; remark: string }
interface EditableLine { line: OrderDeliveryLine; batches: EditableBatch[] }
const modalVisible = ref(false);
const modalTitle = ref('');
const modalLines = ref<EditableLine[]>([]);
// 弹窗模式:single=单行回复/修改回复(不显示快速统一交期区),batch=联合回复交期(保留)。
const modalMode = ref<'single' | 'batch'>('single');
const quickDate = ref('');
const saving = ref(false);
function openReplyModal(lines: OrderDeliveryLine[], title: string, mode: 'single' | 'batch') {
cancelChipEdit(); // 打开弹窗前退出批次条就地编辑,避免弹窗与行内编辑态叠加
modalLines.value = lines.map((line) => ({
line,
batches: line.batches.map((batch) => ({
planned_date: batch.planned_date,
qty: String(Number(batch.qty)),
remark: batch.remark || '',
})),
}));
// 无批次的行默认给一条空批次,便于快速填写。
modalLines.value.forEach((entry) => {
if (entry.batches.length === 0) entry.batches.push({ planned_date: '', qty: '', remark: '' });
});
modalTitle.value = title;
quickDate.value = '';
modalMode.value = mode;
modalVisible.value = true;
}
function openSingleReply(line: OrderDeliveryLine) {
if (chipSaving.value) return; // 保存进行中禁止开弹窗:弹窗按旧批次数据提交会覆盖刚保存的编辑
openReplyModal([line], t('workspace.orderDeliveryReply.modalTitleSingle', { order: line.order_no, item: line.line_no }), 'single');
}
function openBatchReply() {
if (chipSaving.value) return;
const lines = selectedLines.value.filter((line) => !line.locked);
if (!lines.length) return;
openReplyModal(lines, t('workspace.orderDeliveryReply.modalTitleBatch', { count: lines.length }), 'batch');
}
function applyQuickDate() {
if (!quickDate.value) return;
modalLines.value.forEach((entry) => entry.batches.forEach((batch) => { batch.planned_date = quickDate.value; }));
}
/**
* 日期选择器清空后写回空字符串,保持筛选和批次交期的原有字符串。
* @param value - 日期选择器回传值
* @returns YYYY-MM-DD 或空字符串
*/
function dateText(value: unknown): string {
return typeof value === 'string' ? value : '';
}
/**
* 筛选状态下拉。清空后回到全部,并立即查询。
* @param value - 已回复、未完全回复或空
*/
function onFilterStatus(value: unknown): void {
filters.status = value === 'replied' || value === 'not_fully_replied' ? value : '';
doSearch();
}
/**
* 行填写问题文案(实时校验,2026-09-23):
* [规则 1] 已填数量但未填交期的批次 → 「第 N 批未填交期」;
* [规则 2] 已填交期但未填数量的批次 → 「第 N 批未填数量」;
* [规则 3] 同一订单行不同批次交期重复 → 「同一订单单号:项次的不同批次交期时间不能相同」;
* [规则 4] 批次填写完整时合计 ≠ 订单数量 → 「各批次合计 X,须等于订单数量 Y」。
* 只有交期与数量都齐全的批次计入合计;完全空白的批次忽略;缺填/重复错误优先于数量错误展示,
* 保证报错随填写内容实时切换。锁定行不可编辑不校验。
*/
function lineIssueText(entry: EditableLine): string {
if (entry.line.locked) return '';
const missingDates: number[] = [];
const missingQtys: number[] = [];
let total = 0;
let hasInput = false;
entry.batches.forEach((batch, idx) => {
const hasDate = !!batch.planned_date;
const hasQty = batch.qty !== '' && Number(batch.qty) > 0;
if (!hasDate && !hasQty) return; // 空白批次忽略
hasInput = true;
if (hasDate && hasQty) {
total += Number(batch.qty);
} else if (!hasDate) {
missingDates.push(idx + 1);
} else {
missingQtys.push(idx + 1);
}
});
if (!hasInput) return '';
const parts: string[] = [];
if (missingDates.length) parts.push(t('workspace.orderDeliveryReply.batchMissingDate', { batches: missingDates.join('、') }));
if (missingQtys.length) parts.push(t('workspace.orderDeliveryReply.batchMissingQty', { batches: missingQtys.join('、') }));
// 同单不同批次交期重复(后端 _parse_batches 亦拒绝重复交期,此处实时提示)
const filledDates = entry.batches.filter((batch) => batch.planned_date).map((batch) => batch.planned_date);
const duplicatedDates = [...new Set(filledDates.filter((d, i) => filledDates.indexOf(d) !== i))];
if (duplicatedDates.length) parts.push(t('workspace.orderDeliveryReply.batchDuplicateDate', { dates: duplicatedDates.join('、') }));
if (!parts.length && Math.abs(total - Number(entry.line.qty || 0)) > 1e-6) {
parts.push(t('workspace.orderDeliveryReply.qtyTotalMismatchLine', { total, qty: Number(entry.line.qty || 0) }));
}
return parts.join(';');
}
async function saveReplies() {
const validItems: { order_no: string; line_no: number; batches: { planned_date: string; qty: string; remark: string | null }[] }[] = [];
for (const { line, batches } of modalLines.value) {
const cleaned = batches
.filter((batch) => batch.planned_date && Number(batch.qty) > 0)
.map((batch) => ({ planned_date: batch.planned_date, qty: batch.qty, remark: batch.remark.trim() || null }));
if (line.locked) continue; // 锁定行不允许再改(后端也会 409)
if (!cleaned.length) continue;
validItems.push({ order_no: line.order_no, line_no: line.line_no, batches: cleaned });
}
// 填写校验(2026-09-23,与实时提示同口径):缺交期/缺数量、合计≠订单数量都按行拦截。
const issueTexts: string[] = [];
for (const entry of modalLines.value) {
if (entry.line.locked) continue;
const text = lineIssueText(entry);
if (text) issueTexts.push(`${entry.line.order_no}:${entry.line.line_no} ${text}`);
}
if (issueTexts.length) {
msg.warning(t('workspace.orderDeliveryReply.saveBlocked', { detail: issueTexts.join(';') }));
return;
}
if (!validItems.length) {
msg.warning(t('workspace.orderDeliveryReply.noValidBatches'));
return;
}
saving.value = true;
try {
const [singleItem] = validItems;
if (validItems.length === 1 && singleItem) {
// 仅一行时走单行接口;多行必须走批量接口逐行保存(此前误判为 if (singleItem),
// 恒为真导致联合回复只保存第一行,批量分支成死代码)。
await saveOrderDeliveryBatches(singleItem.order_no, singleItem.line_no, singleItem.batches);
msg.success(t('workspace.orderDeliveryReply.saveSingleDone'));
} else {
const summary: BatchSummary = await batchReplyOrderDelivery(validItems);
if (summary.failed > 0) {
const failedText = summary.items.filter((item) => !item.ok).map((item) => `${item.order_no}:${item.line_no} ${item.error || ''}`).join(';');
msg.warning(t('workspace.orderDeliveryReply.saveBatchPartial', { ok: summary.succeeded, fail: summary.failed, detail: failedText }));
} else {
msg.success(t('workspace.orderDeliveryReply.saveBatchDone', { ok: summary.succeeded }));
}
}
modalVisible.value = false;
selected.value = [];
await loadLines(); // 保存或通知后即时刷新(需求 §9)
} catch (error) {
msg.error(error instanceof Error ? error.message : t('workspace.orderDeliveryReply.saveFailedTitle'));
// 行已不在同步范围(erp_missing/被新同步剔除):旧列表过期,自动刷新让该行消失。
const message = error instanceof Error ? error.message : '';
if (message.includes('LINE_NOT_FOUND') || message.includes('不在同步范围') || message.includes('not found')) {
await loadLines();
}
} finally {
saving.value = false;
}
}
/* ============ 批次条就地编辑(2026-10-09) ============ */
// 未锁定且可管理的行:点击批次条原地变「日期+数量」输入,回车/失焦自动保存单行接口;
// 校验与弹窗同口径(lineIssueText:缺交期/缺数量、同单交期重复、合计≠订单数量),红字阻断保存;
// 双清空=放弃编辑(行内不提供删除,结构调整/备注/多批次走加号弹窗)。
const editingChip = ref<{ key: string; idx: number } | null>(null);
const chipDraft = reactive({ planned_date: '', qty: '' });
const chipIssue = ref('');
// 单行保存进行中标志:整行提交语义下,禁止并发(再点其他批次条/开弹窗),
// 否则两个 in-flight 保存或「弹窗基于旧批次数据」会互相覆盖丢编辑
const chipSaving = ref(false);
const isChipEditable = (line: OrderDeliveryLine) => canManage.value && !line.locked;
const isChipEditing = (line: OrderDeliveryLine, idx: number) =>
editingChip.value?.key === lineKey(line) && editingChip.value?.idx === idx;
function startChipEdit(line: OrderDeliveryLine, idx: number) {
if (!isChipEditable(line) || chipSaving.value) return;
// 未回复行批次列表为空:idx=0 表示「新增第一条批次」,同样可进入编辑
if (line.batches.length > 0 && idx >= line.batches.length) return;
const batch = line.batches[idx];
editingChip.value = { key: lineKey(line), idx };
chipDraft.planned_date = batch?.planned_date ?? '';
chipDraft.qty = batch ? String(Number(batch.qty)) : '';
chipIssue.value = '';
// 输入条渲染后自动聚焦日期框,点击即可填
void nextTick(() => {
document.querySelector<HTMLInputElement>('[data-chip-edit] [data-chip-date]')?.focus();
});
}
function cancelChipEdit() {
editingChip.value = null;
chipIssue.value = '';
}
/** 失焦提交:relatedTarget 仍在输入条内(日期↔数量切换)时不提交。 */
function onChipFocusout(event: FocusEvent, line: OrderDeliveryLine, idx: number) {
const next = event.relatedTarget as Node | null;
if (next && (event.currentTarget as HTMLElement).contains(next)) return;
chipCommit(line, idx);
}
function chipCommit(line: OrderDeliveryLine, idx: number) {
if (!isChipEditing(line, idx) || chipSaving.value) return;
// 注意:v-model 在 type="number" 输入框上会自动把值转成 number,
// 这里必须统一 String() 容错,否则 qty.trim() 抛 TypeError 中断整个失焦提交
const date = String(chipDraft.planned_date ?? '').trim();
const qty = String(chipDraft.qty ?? '').trim();
// 双清空=放弃编辑;只填其一致「缺交期/缺数量」红字,保持编辑态
if (!date && !(qty !== '' && Number(qty) > 0)) {
cancelChipEdit();
return;
}
// 整行批次合并提交,与弹窗保存完全同口径:
// 编辑已有批次=仅替换该条;未回复行空批次条=新增第一条(line.batches 为空数组)
const source = line.batches[idx];
const edited: EditableBatch = { planned_date: date, qty, remark: source?.remark || '' };
const merged: EditableBatch[] =
idx < line.batches.length
? line.batches.map((b, i) =>
i === idx ? edited : { planned_date: b.planned_date, qty: String(Number(b.qty)), remark: b.remark || '' },
)
: [edited];
const issue = lineIssueText({ line, batches: merged });
if (issue) {
chipIssue.value = issue;
// 校验失败:保持编辑态并重新聚焦日期框,红字提示持续可见,直至修正保存或 Esc 取消
void nextTick(() => {
document.querySelector<HTMLInputElement>('[data-chip-edit] [data-chip-date]')?.focus();
});
return;
}
const cleaned = merged
.filter((b) => b.planned_date && Number(b.qty) > 0)
.map((b) => ({ planned_date: b.planned_date, qty: b.qty, remark: b.remark.trim() || null }));
if (!cleaned.length) {
cancelChipEdit();
return;
}
void saveChipEdit(line, idx, cleaned);
}
async function saveChipEdit(
line: OrderDeliveryLine,
idx: number,
cleaned: { planned_date: string; qty: string; remark: string | null }[],
) {
const target = { key: lineKey(line), idx };
chipSaving.value = true;
try {
await saveOrderDeliveryBatches(line.order_no, line.line_no, cleaned);
msg.success(t('workspace.orderDeliveryReply.saveSingleDone'));
// 仅当用户未切去编辑其他批次条时才退出编辑态
if (editingChip.value?.key === target.key && editingChip.value?.idx === target.idx) {
cancelChipEdit();
}
await loadLines();
// loadLines 重建行 DOM:若用户已切去编辑其他批次条,重聚焦其日期框,
// 否则焦点丢失后后续「失焦提交」永远不会触发(表现为填了不保存)
if (editingChip.value) {
void nextTick(() => {
document.querySelector<HTMLInputElement>('[data-chip-edit] [data-chip-date]')?.focus();
});
}
} catch (error) {
msg.error(error instanceof Error ? error.message : t('workspace.orderDeliveryReply.saveFailedTitle'));
const message = error instanceof Error ? error.message : '';
if (message.includes('LINE_NOT_FOUND') || message.includes('不在同步范围') || message.includes('not found')) {
editingChip.value = null;
chipIssue.value = '';
await loadLines();
}
} finally {
chipSaving.value = false;
}
}
/* ============ 导出 Excel(2026-10-09) ============ */
const exporting = ref(false);
/** 按当前筛选(appliedFilters)导出全部命中行;后端生成 xlsx,前端 blob 触发下载。 */
async function doExportExcel() {
exporting.value = true;
try {
await exportOrderDeliveryLines({ ...appliedFilters });
msg.success(t('workspace.orderDeliveryReply.exportDone'));
} catch (error) {
msg.error(error instanceof Error ? error.message : t('workspace.orderDeliveryReply.exportFailed'));
} finally {
exporting.value = false;
}
}
/* ============ 通知 ============ */
const notifying = ref(false);
/**
* 批量通知入口。确认后执行 doNotifyBatch,取消不发送。
*/
async function requestNotifyBatch() {
if (!notifiableSelected.value.length) return;
try {
await ElMessageBox.confirm(
t('workspace.orderDeliveryReply.notifyBatchConfirm', { count: notifiableSelected.value.length }),
t('workspace.orderDeliveryReply.batchNotify'),
{
type: 'warning',
confirmButtonText: t('common.deleteDialog.confirm'),
cancelButtonText: t('common.deleteDialog.cancel'),
},
);
} catch {
return;
}
await doNotifyBatch();
}
/** 批量通知:部分成功 warning 汇总,全部失败 error;提示后刷新列表让锁定即时生效。 */
async function doNotifyBatch() {
const lines = notifiableSelected.value;
if (!lines.length) return;
notifying.value = true;
try {
const summary = await notifyOrderDeliveryBatch(lines.map((line) => ({ order_no: line.order_no, line_no: line.line_no })));
const failedText = summary.items.filter((item) => !item.ok).map((item) => `${item.order_no}:${item.line_no} ${item.error || ''}`).join(';');
if (summary.failed > 0 && summary.succeeded > 0) {
msg.warning(t('workspace.orderDeliveryReply.notifyPartial', { ok: summary.succeeded, fail: summary.failed, skip: summary.skipped, detail: failedText }));
} else if (summary.failed > 0 && summary.succeeded === 0) {
msg.error(t('workspace.orderDeliveryReply.notifyAllFailed', { fail: summary.failed, detail: failedText }));
} else {
msg.success(t('workspace.orderDeliveryReply.notifyBatchDone', { ok: summary.succeeded, skip: summary.skipped }));
}
selected.value = [];
await loadLines();
} catch (error) {
msg.error(error instanceof Error ? error.message : t('workspace.orderDeliveryReply.notifyFailedTitle'));
} finally {
notifying.value = false;
}
}
/* ============ 同步状态展示 ============ */
const latestSyncText = computed(() => {
const run = latestSync.value;
if (!run) return t('workspace.orderDeliveryReply.syncNever');
const time = (run.finished_at || run.started_at || '').replace('T', ' ').slice(0, 19);
if (run.status === 'success') return t('workspace.orderDeliveryReply.syncAt', { time });
if (run.status === 'running') return t('workspace.orderDeliveryReply.syncRunning');
return t('workspace.orderDeliveryReply.syncFailedAt', { time });
});
const latestSyncFailed = computed(() => latestSync.value?.status === 'failed');
/* ============ 企微卡片直达定位 ============ */
// 企微卡片「查看详情」→(未登录先登录,守卫以 redirect 原样回跳)→ 本页按 query 还原内容与位置:
// status=交期回复状态筛选(提醒卡)、order_no=关键词筛选、line_no=滚动定位并高亮该行(行通知卡);
// wecom_trace 上报卡片打开回执(与工作台 deeplink 同一后端接口,失败静默只留痕)。
const route = useRoute();
const highlightKey = ref('');
let highlightTimer: ReturnType<typeof setTimeout> | null = null;
function clearHighlight() {
if (highlightTimer) {
clearTimeout(highlightTimer);
highlightTimer = null;
}
highlightKey.value = '';
}
const isLineHighlighted = (line: OrderDeliveryLine) => highlightKey.value === lineKey(line);
/** 行交互态:直达高亮(warning)优先于勾选选中(info),均走状态令牌(亮暗自适应)。 */
const rowCls = (line: OrderDeliveryLine) => {
if (isLineHighlighted(line)) return 'bg-row-highlight';
return selected.value.includes(lineKey(line)) ? 'bg-row-selected' : '';
};
/** 冻结单元格用 utilities.css 的 frozen-cell(实色基底防透出滚动内容),状态与整行联动;高亮优先于勾选。 */
const frozenCellCls = (line: OrderDeliveryLine) => {
if (isLineHighlighted(line)) return 'frozen-cell frozen-cell--highlight';
return selected.value.includes(lineKey(line)) ? 'frozen-cell frozen-cell--selected' : 'frozen-cell';
};
/** 列表就绪后定位目标行:滚动到视口中央 + 高亮 8 秒;行不在当前筛选结果中时静默跳过。 */
async function focusTargetLine(orderNo: string, lineNo: number) {
const key = `${orderNo}:${lineNo}`;
if (!items.value.some((line) => lineKey(line) === key)) return;
highlightKey.value = key;
await nextTick();
document.querySelector(`[data-line-key="${key}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'center' });
msg.success(t('workspace.orderDeliveryReply.deepLinkLocated', { order: orderNo, item: lineNo }));
if (highlightTimer) clearTimeout(highlightTimer);
highlightTimer = setTimeout(clearHighlight, 8000);
}
/** 上报企微卡片打开回执(WecomNotifyAudit.opened_at);仅留痕,失败不影响页面使用。请求头带 application/json,后端 get_json 才读得到 trace_id。 */
async function reportWecomTraceOpened(traceId: string) {
try {
await requestJson('/api/user/wecom/deeplink-opened', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ trace_id: traceId }),
});
} catch {
// 回执只留痕:失败不打扰用户。
}
}
onMounted(async () => {
const query = route.query;
const orderNo = typeof query.order_no === 'string' ? query.order_no.trim() : '';
const lineNo = typeof query.line_no === 'string' ? Number(query.line_no) : NaN;
const status = typeof query.status === 'string' ? query.status : '';
const traceId = typeof query.wecom_trace === 'string' ? query.wecom_trace : '';
// [STEP 1] 还原筛选(登录回跳后 query 仍在):关键词命中订单单号;状态筛选定位提醒卡对应视图。
if (orderNo) filters.keyword = orderNo;
if (status === 'replied' || status === 'not_fully_replied') filters.status = status;
if (orderNo || status) Object.assign(appliedFilters, filters);
if (traceId) void reportWecomTraceOpened(traceId);
// [STEP 2] 加载列表后按 line_no 滚动定位 + 高亮(行级通知卡直达场景)。
await loadLines();
void loadLatestSync();
if (orderNo && Number.isInteger(lineNo) && lineNo > 0) await focusTargetLine(orderNo, lineNo);
});
</script>
<template>
<!-- 全页基准字号:text-sm 14px(表头/筛选区/工具栏/表格统一),子元素按需覆写;
例外:页头标题 text-lg→md:text-xl(18/20px,与合同付款预警页头对齐)、徽章类 badge 基类自带 text-xs(12px)
高度收敛至视口(h-screen + overflow-hidden):页面自身不滚动,滚动全部在表格容器内,
列头 sticky 固定、横向滚动条常驻表格底缘;聊天壳 iframe 与独立路由均适用。
page-shell:iframe 嵌入路由无外层布局壳,由本页根节点补齐 L1 页面底色与前景色 -->
<div class="page-shell flex h-screen flex-col gap-4 overflow-hidden p-6 text-sm">
<!-- 页头:标题 + 最近同步 + 手动刷新 -->
<div class="flex flex-wrap items-center gap-3">
<!-- 页头标题字号与合同付款预警页头一致:小屏 text-lg 18px、≥768px md:text-xl 20px -->
<h1 class="text-lg font-bold text-primary md:text-xl">{{ t('workspace.nav.orderDeliveryReply') }}</h1>
<span class="badge whitespace-nowrap" :class="latestSyncFailed ? 'badge-error' : 'badge-info'">
{{ latestSyncText }}
</span>
<div class="flex-1" />
<ElButton v-if="canManage" :disabled="syncing" :loading="syncing" @click="doSync">
{{ syncing ? t('workspace.orderDeliveryReply.syncing') : t('workspace.orderDeliveryReply.syncNow') }}
</ElButton>
</div>
<!-- 搜索区:合并关键词搜索(订单/产品/客户命中任一字段),shrink-0 防压缩;surface-panel 为设计系统 L2 区块容器(无 hover 阴影)。
外置字段标签已取消(2026-10-09:去掉提示字及其占位,单行紧凑布局与合同付款预警筛选一致):
字段含义由输入框 placeholder / 选项承担,无障碍语义用 aria-label 保留(复用 filterKeyword 等 i18n 键)。
输入控件显式 text-sm(14px)+h-9(36px):与 .contract-filter-input(14px/36px/圆角8px)渲染规格逐项一致 -->
<div class="surface-panel flex shrink-0 flex-wrap items-center gap-3 px-4 py-2.5">
<ElInput
v-model="filters.keyword"
class="order-reply-keyword"
clearable
:placeholder="t('workspace.orderDeliveryReply.filterKeywordPh')"
:aria-label="t('workspace.orderDeliveryReply.filterKeyword')"
@keyup.enter="doSearch"
/>
<ElDatePicker
:model-value="filters.order_date || undefined"
type="date"
value-format="YYYY-MM-DD"
:aria-label="t('workspace.orderDeliveryReply.filterOrderDate')"
@update:model-value="filters.order_date = dateText($event)"
/>
<ElSelect
class="order-reply-status"
:model-value="filters.status || undefined"
clearable
:placeholder="t('workspace.orderDeliveryReply.statusAll')"
:aria-label="t('workspace.orderDeliveryReply.filterStatus')"
@update:model-value="onFilterStatus"
>
<ElOption value="replied" :label="t('workspace.orderDeliveryReply.statusReplied')" />
<ElOption value="not_fully_replied" :label="t('workspace.orderDeliveryReply.statusNotFully')" />
</ElSelect>
<ElButton type="primary" @click="doSearch">{{ t('workspace.orderDeliveryReply.search') }}</ElButton>
<ElButton @click="doReset">{{ t('workspace.orderDeliveryReply.reset') }}</ElButton>
</div>
<!-- 工具栏:全选 + 联合回复 + 批量通知(shrink-0 防压缩,py-2 紧凑高度) -->
<div class="surface-panel flex shrink-0 flex-wrap items-center gap-3 px-4 py-2">
<ElCheckbox :model-value="allChecked" :indeterminate="someChecked" @change="togglePageAll(Boolean($event))">
{{ t('workspace.orderDeliveryReply.selectAll') }}
</ElCheckbox>
<span class="text-muted">{{ t('workspace.orderDeliveryReply.selectedCount', { count: selectedLines.length }) }}</span>
<template v-if="canManage">
<ElButton type="primary" :disabled="selectedLines.length === 0" @click="openBatchReply">
{{ t('workspace.orderDeliveryReply.batchReply') }}
</ElButton>
<ElButton type="primary" :disabled="notifiableSelected.length === 0 || notifying" :loading="notifying" @click="requestNotifyBatch">
{{ t('workspace.orderDeliveryReply.batchNotify') }}
</ElButton>
</template>
<div class="flex-1" />
<!-- 导出 Excel(2026-10-09 增补,原提示文字胶囊取消):按当前筛选导出全部行 -->
<ElButton type="primary" :icon="Download" :disabled="exporting" :loading="exporting" @click="doExportExcel">
{{ t('workspace.orderDeliveryReply.exportExcel') }}
</ElButton>
</div>
<!-- 列表 -->
<div class="surface-panel min-h-0 flex-1 overflow-auto">
<table class="w-full border-collapse text-center">
<!-- z-30 高于表体冻结单元格(z-20):纵向滚动时冻结列不会盖住表头 -->
<thead class="sticky top-0 z-30 bg-surface-soft text-muted [&_th]:whitespace-nowrap">
<tr>
<!-- 左侧冻结标识区(前四列):勾选/客户编号/订单日期/订单单号:项次,宽度固定保证偏移对齐 -->
<th class="sticky left-0 z-30 w-8 bg-surface-soft px-2 py-2" />
<th class="sticky left-8 z-30 w-32 min-w-[8rem] bg-surface-soft px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colCustomer') }}</th>
<th class="sticky left-[10rem] z-30 w-24 bg-surface-soft px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colOrderDate') }}</th>
<th class="sticky left-[16rem] z-30 w-40 min-w-[10rem] border-r border-default bg-surface-soft px-2 py-2 text-center shadow-sticky-col">{{ t('workspace.orderDeliveryReply.colOrderLine') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colPartNo') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colCustomerPartNo') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colQty') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colAgreedDate') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colStatus') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colReply') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colReplyPerson') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colSalesperson') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colCustomerPo') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colSpec') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colUnit') }}</th>
<th class="px-2 py-2 text-center">{{ t('workspace.orderDeliveryReply.colNotifiedTime') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="line in items"
:key="lineKey(line)"
:data-line-key="lineKey(line)"
class="hover-row border-t border-default"
:class="rowCls(line)"
>
<!-- 冻结单元格:frozen-cell 实色基底(半透明会透出滚动内容),悬停/选中/直达高亮由 CSS 联动 -->
<td
class="sticky left-0 z-20 px-2 py-1.5"
:class="frozenCellCls(line)"
>
<input type="checkbox" class="admin-checkbox" :checked="selected.includes(lineKey(line))" @change="toggleLine(line, ($event.target as HTMLInputElement).checked)" />
</td>
<td
class="sticky left-8 z-20 w-32 min-w-[8rem] max-w-[8rem] px-2 py-1.5"
:class="frozenCellCls(line)"
:title="line.customer_full_name || line.customer_short_name || ''"
>
<div>{{ line.customer_no || '—' }}</div>
<div class="truncate text-muted">{{ line.customer_short_name || '' }}</div>
</td>
<td
class="sticky left-[10rem] z-20 w-24 min-w-[6rem] max-w-[6rem] overflow-hidden px-2 py-1.5"
:class="frozenCellCls(line)"
>{{ line.order_date || '—' }}</td>
<td
class="sticky left-[16rem] z-20 w-40 min-w-[10rem] max-w-[10rem] overflow-hidden whitespace-nowrap border-r border-default px-2 py-1.5 font-mono text-left shadow-sticky-col"
:class="frozenCellCls(line)"
>{{ line.order_no }}:{{ line.line_no }}</td>
<td class="px-2 py-1.5" :title="line.part_name || ''">
<!-- 截断盒 mx-auto:限宽盒在列内居中(继承 text-center),截断能力保留 -->
<div class="mx-auto max-w-[10rem] truncate font-mono">{{ line.part_no || '—' }}</div>
<div class="mx-auto max-w-[14rem] truncate text-muted">{{ line.part_name || '' }}</div>
</td>
<td class="whitespace-nowrap px-2 py-1.5 font-mono">{{ line.customer_part_no || '—' }}</td>
<td class="px-2 py-2 text-center tabular-nums">{{ line.qty ?? '—' }}</td>
<td class="whitespace-nowrap px-2 py-1.5">{{ line.agreed_date || '—' }}</td>
<td class="px-2 py-1.5">
<span class="badge inline-block min-w-[68px] whitespace-nowrap text-center font-semibold" :class="statusMeta(line.status).cls">
{{ statusMeta(line.status).label }}
</span>
</td>
<!-- 交期回复:动作入口为批次条前的加号(lucide Plus);未回复=空批次条(不显示时间/数量);
所有行首条批次条前保留等宽加号占位(无动作时为透明占位)、展开行其余批次条加 pl-7 缩进,
保证全表批次条左缘对齐;「交期已锁定」徽标已取消(锁定状态由无加号与交期回复人员列「已通知」体现);
>1 批时首条批次后有展开/收起小箭头 -->
<td class="px-2 py-1.5">
<template v-if="line.batches.length === 0">
<div class="flex items-center gap-1">
<button
v-if="canManage"
type="button"
class="btn-ghost h-6 w-6 shrink-0 rounded-md p-0"
:disabled="chipSaving"
:title="t('workspace.orderDeliveryReply.replyAction')"
:aria-label="t('workspace.orderDeliveryReply.replyAction')"
@click="openSingleReply(line)"
>
<Plus class="h-4 w-4" />
</button>
<span v-else class="w-6 shrink-0" aria-hidden="true" />
<!-- 未回复空批次条:可管理时可点击就地填写交期+数量(回车/失焦自动保存单行接口);不显示占位文字 -->
<div
v-if="isChipEditing(line, 0)"
data-chip-edit
class="flex items-center gap-1 rounded border-l-[3px] border-brand-500 bg-surface-soft px-1.5 py-0.5"
:class="chipSaving ? 'opacity-60' : ''"
@focusout="onChipFocusout($event, line, 0)"
@keydown.enter.prevent="chipCommit(line, 0)"
@keydown.esc.prevent="cancelChipEdit"
>
<input v-model="chipDraft.planned_date" data-chip-date type="date" class="h-6 w-[125px] rounded border border-default bg-surface px-1 text-sm text-primary outline-none focus:border-brand-500" :aria-label="t('workspace.orderDeliveryReply.filterOrderDate')" />
<input v-model="chipDraft.qty" type="number" min="0" class="h-6 w-16 rounded border border-default bg-surface px-1 text-sm text-primary outline-none focus:border-brand-500" :aria-label="t('workspace.orderDeliveryReply.colQty')" @focus="($event.target as HTMLInputElement).select()" />
<span v-if="line.unit" class="text-muted">{{ line.unit }}</span>
</div>
<div
v-else-if="isChipEditable(line)"
class="h-6 w-24 cursor-pointer rounded border-l-[3px] border-brand-500 bg-surface-soft transition-colors hover-surface-strong"
:title="t('workspace.orderDeliveryReply.replyAction')"
@click="startChipEdit(line, 0)"
/>
<div v-else class="h-6 w-24 rounded border-l-[3px] border-brand-500 bg-surface-soft" />
</div>
<p v-if="isChipEditing(line, 0) && chipIssue" class="mt-0.5 text-xs text-status-error">{{ chipIssue }}</p>
</template>
<template v-else>
<div class="flex flex-col gap-0.5">
<div
v-for="(batch, idx) in line.batches"
:key="batch.seq ?? idx"
v-show="idx === 0 || expanded.includes(lineKey(line))"
class="flex items-center gap-1"
:class="idx > 0 ? 'pl-7' : ''"
>
<template v-if="idx === 0">
<button
v-if="canManage && !line.locked"
type="button"
class="btn-ghost h-6 w-6 shrink-0 rounded-md p-0"
:disabled="chipSaving"
:title="t('workspace.orderDeliveryReply.editReplyAction')"
:aria-label="t('workspace.orderDeliveryReply.editReplyAction')"
@click="openSingleReply(line)"
>
<Plus class="h-4 w-4" />
</button>
<span v-else class="w-6 shrink-0" aria-hidden="true" />
</template>
<!-- 批次条:未锁定可管理行点击原地编辑(日期+数量,回车/失焦自动保存) -->
<div
v-if="isChipEditing(line, idx)"
data-chip-edit
class="flex items-center gap-1 rounded border-l-[3px] border-brand-500 bg-surface-soft px-1.5 py-0.5"
:class="chipSaving ? 'opacity-60' : ''"
@focusout="onChipFocusout($event, line, idx)"
@keydown.enter.prevent="chipCommit(line, idx)"
@keydown.esc.prevent="cancelChipEdit"
>
<input v-model="chipDraft.planned_date" data-chip-date type="date" class="h-6 w-[125px] rounded border border-default bg-surface px-1 text-sm text-primary outline-none focus:border-brand-500" :aria-label="t('workspace.orderDeliveryReply.filterOrderDate')" />
<input v-model="chipDraft.qty" type="number" min="0" class="h-6 w-16 rounded border border-default bg-surface px-1 text-sm text-primary outline-none focus:border-brand-500" :aria-label="t('workspace.orderDeliveryReply.colQty')" @focus="($event.target as HTMLInputElement).select()" />
<span v-if="line.unit" class="text-muted">{{ line.unit }}</span>
</div>
<div
v-else
class="max-w-[230px] truncate rounded border-l-[3px] border-brand-500 bg-surface-soft px-2 py-0.5 text-secondary"
:class="isChipEditable(line) ? 'cursor-pointer transition-colors hover-surface-strong' : ''"
:title="isChipEditable(line) ? t('workspace.orderDeliveryReply.editReplyAction') : undefined"
@click="startChipEdit(line, idx)"
>
{{ batch.planned_date }} · <b class="text-brand-600">{{ batch.qty }}</b> {{ line.unit }}
</div>
<button
v-if="idx === 0 && line.batches.length > 1"
type="button"
class="btn-ghost h-6 w-6 shrink-0 rounded-md p-0"
:title="expanded.includes(lineKey(line)) ? t('workspace.orderDeliveryReply.collapse') : t('workspace.orderDeliveryReply.expand', { count: line.batches.length - 1 })"
:aria-label="expanded.includes(lineKey(line)) ? t('workspace.orderDeliveryReply.collapse') : t('workspace.orderDeliveryReply.expand', { count: line.batches.length - 1 })"
@click="toggleExpand(lineKey(line))"
>
<ChevronUp v-if="expanded.includes(lineKey(line))" class="h-4 w-4" />
<ChevronDown v-else class="h-4 w-4" />
</button>
</div>
</div>
<p v-if="editingChip && editingChip.key === lineKey(line) && chipIssue" class="mt-0.5 text-xs text-status-error">{{ chipIssue }}</p>
</template>
</td>
<!-- 交期回复人员:通知时间已拆至独立「通知时间」列(2026-10-09),本列仅工号/姓名/待通知提示 -->
<td class="px-2 py-1.5">
<template v-if="line.notified_employee_id || line.notified_user_name">
<div class="font-mono">{{ line.notified_employee_id || '' }}</div>
<div class="text-muted">{{ line.notified_user_name || '' }}</div>
</template>
<span v-else class="text-muted">{{ t('workspace.orderDeliveryReply.pendingNotify') }}</span>
</td>
<!-- 业务员(副文案部门):与客户编号/简称同款合并展示,独立部门列已取消 -->
<td class="px-2 py-1.5" :title="line.salesperson_code || ''">
<div class="whitespace-nowrap">{{ line.salesperson_name || line.salesperson_code || '—' }}</div>
<div class="text-muted">{{ line.dept_name || line.dept_code || '' }}</div>
</td>
<td class="px-2 py-1.5 font-mono" :title="line.customer_po || ''"><span class="mx-auto block max-w-[10rem] truncate">{{ line.customer_po || '—' }}</span></td>
<td class="px-2 py-1.5" :title="line.spec || ''"><span class="mx-auto block max-w-[10rem] truncate">{{ line.spec || '—' }}</span></td>
<td class="px-2 py-1.5">{{ line.unit || '—' }}</td>
<!-- 通知时间(2026-10-09 自「交期回复人员」列拆出独立列):锁定行展示通知时间戳,单行不折行 -->
<td class="whitespace-nowrap px-2 py-1.5" :class="line.locked ? 'text-status-success' : 'text-muted'">{{ line.locked ? (line.notified_at || '—') : '—' }}</td>
</tr>
<tr v-if="!loading && items.length === 0">
<td colspan="16" class="px-4 py-16 text-center text-muted">{{ t('workspace.orderDeliveryReply.empty') }}</td>
</tr>
</tbody>
</table>
</div>
<!-- 分页:复用管理控制台-数据报表的 PaginationBar(摘要 + 每页条数 + 页码按钮),组件自带字号不再强改 -->
<PaginationBar
:page="page"
:page-size="pageSize"
:total="total"
:page-size-options="pageSizeOptions"
@update:page="goToPage"
@update:page-size="changePageSize"
/>
<ElDialog
v-model="modalVisible"
:title="modalTitle"
width="960px"
align-center
append-to-body
:close-on-click-modal="false"
>
<div v-if="modalMode === 'batch'" class="order-reply-quick">
<span>{{ t('workspace.orderDeliveryReply.quickDate') }}</span>
<ElDatePicker
:model-value="quickDate || undefined"
type="date"
value-format="YYYY-MM-DD"
@update:model-value="quickDate = dateText($event)"
/>
<ElButton @click="applyQuickDate">{{ t('workspace.orderDeliveryReply.applyQuickDate') }}</ElButton>
<span>{{ t('workspace.orderDeliveryReply.modalHint') }}</span>
</div>
<div v-for="entry in modalLines" :key="lineKey(entry.line)" class="order-reply-line">
<div class="order-reply-line__head">
<span class="order-reply-line__no">{{ entry.line.order_no }}</span>
<span>{{ t('workspace.orderDeliveryReply.itemLabel', { item: entry.line.line_no }) }}</span>
<span>{{ entry.line.customer_no }} · {{ entry.line.customer_short_name }}</span>
<span>{{ entry.line.part_no }} · {{ entry.line.part_name }}</span>
<span class="order-reply-line__qty">
{{ t('workspace.orderDeliveryReply.orderQtyLabel', { qty: entry.line.qty ?? 0, unit: entry.line.unit || '' }) }}
</span>
</div>
<div class="order-reply-line__body">
<div v-for="(batch, idx) in entry.batches" :key="idx" class="order-reply-batch">
<ElDatePicker
:model-value="batch.planned_date || undefined"
type="date"
value-format="YYYY-MM-DD"
@update:model-value="batch.planned_date = dateText($event)"
/>
<ElInput v-model="batch.qty" type="number" :placeholder="t('workspace.orderDeliveryReply.qtyPh')" />
<ElInput v-model="batch.remark" :placeholder="t('workspace.orderDeliveryReply.remarkPh')" />
<ElButton link type="danger" :title="t('workspace.orderDeliveryReply.removeBatch')" @click="entry.batches.splice(idx, 1)">✕</ElButton>
</div>
<ElButton class="order-reply-add" @click="entry.batches.push({ planned_date: '', qty: '', remark: '' })">
{{ t('workspace.orderDeliveryReply.addBatch') }}
</ElButton>
<p v-if="lineIssueText(entry)" class="order-reply-issue">{{ lineIssueText(entry) }}</p>
</div>
</div>
<template #footer>
<ElButton @click="modalVisible = false">{{ t('common.cancel') }}</ElButton>
<ElButton type="primary" :loading="saving" :disabled="saving" @click="saveReplies">
{{ saving ? t('workspace.orderDeliveryReply.saving') : t('workspace.orderDeliveryReply.saveReply') }}
</ElButton>
</template>
</ElDialog>
</div>
</template>
<style scoped>
.order-reply-keyword {
width: min(100%, 22rem);
}
.order-reply-status {
width: 11rem;
}
.order-reply-quick,
.order-reply-line__head,
.order-reply-batch {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.order-reply-quick,
.order-reply-line {
margin-bottom: 12px;
}
.order-reply-line {
overflow: hidden;
border: 1px solid var(--el-border-color-lighter);
border-radius: var(--el-border-radius-base);
}
.order-reply-line__head {
padding: 8px 12px;
background: var(--el-fill-color-light);
}
.order-reply-line__no {
padding: 0 8px;
border-radius: 4px;
background: var(--el-fill-color);
font-weight: 600;
}
.order-reply-line__qty {
margin-left: auto;
}
.order-reply-line__body {
display: flex;
flex-direction: column;
gap: 8px;
padding: 12px;
}
.order-reply-batch {
display: grid;
grid-template-columns: 170px 120px minmax(0, 1fr) 40px;
}
.order-reply-add {
width: 100%;
}
.order-reply-issue {
margin: 0;
color: var(--el-color-danger);
}
</style>