!24 Merge branch 'dev' into change
Merge pull request !24 from 王瑞雪/change
This commit is contained in:
20 files changed
+904
-191
No files matched your search
@@ -3,9 +3,11 @@
|
||||
* 依赖:统一 requestJson(失败抛 BusinessError);后端 /api/order-delivery-reply。
|
||||
* 逻辑:列表筛选分页、保存批次(单行/联合)、单行与批量通知、手动同步与最近同步状态。
|
||||
* 带 JSON 正文的写请求在本文件声明 Content-Type: application/json,供 Flask get_json 解析。
|
||||
* 按当前筛选导出 Excel(后端生成 xlsx,blob 触发下载)。
|
||||
*/
|
||||
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
|
||||
/**
|
||||
* 组装带 JSON 正文的写请求。
|
||||
@@ -157,3 +159,41 @@ export const runOrderDeliverySync = () =>
|
||||
/** 最近一次同步运行记录;从未同步过返回 null。 */
|
||||
export const getLatestOrderDeliverySync = () =>
|
||||
requestJson<OrderDeliverySyncRun | null>('/api/order-delivery-reply/sync/latest');
|
||||
|
||||
/** 导出 Excel 查询参数(与列表筛选一致;导出全部命中行,不分页)。 */
|
||||
export interface OrderDeliveryExportParams {
|
||||
keyword?: string;
|
||||
order_date?: string;
|
||||
status?: '' | 'replied' | 'not_fully_replied';
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出当前筛选下的全部订单行 Excel。
|
||||
* 触发时机:工具栏「导出 Excel」按钮。后端生成 xlsx 文件流,此处 blob 触发浏览器下载,
|
||||
* 文件名「订单交期回复_YYYY-MM-DD.xlsx」(日期取本地当天);失败抛 Error(HTTP 状态码)。
|
||||
*/
|
||||
export async function exportOrderDeliveryLines(params: OrderDeliveryExportParams): Promise<void> {
|
||||
const query = new URLSearchParams();
|
||||
if (params.keyword) query.set('keyword', params.keyword);
|
||||
if (params.order_date) query.set('order_date', params.order_date);
|
||||
if (params.status) query.set('status', params.status);
|
||||
const response = await fetch(`/api/order-delivery-reply/lines/export?${query.toString()}`, {
|
||||
method: 'GET',
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Export failed: HTTP ${response.status}`);
|
||||
}
|
||||
const blob = await response.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
// 文件名日期取浏览器本地时区(toISOString 为 UTC,北京时间 0-8 点导出会差一天)
|
||||
const now = new Date();
|
||||
const localDate = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
||||
link.download = `订单交期回复_${localDate}.xlsx`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* features/order-delivery-reply/views/OrderDeliveryReplyPage.chipEdit.spec.ts
|
||||
* 用途:锁定「批次条就地编辑」核心契约(回归用)。
|
||||
* 依赖:vitest、@vue/test-utils、vue-i18n、vue-router memory history。
|
||||
* 逻辑:完整挂载工作台页(mock API/权限/消息):
|
||||
* 1) 未回复行点击空批次条进入编辑态,填写日期+数量失焦 → 调用单行保存接口(整行批次);
|
||||
* 2) 只填数量不填日期失焦 → 不保存且行内红字提示(batchMissingDate);
|
||||
* 3) 多批次行改其中一条数量致合计≠订单数量 → 不保存且红字提示(qtyTotalMismatchLine)。
|
||||
*/
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { createRouter, createMemoryHistory } from 'vue-router';
|
||||
import OrderDeliveryReplyPage from './OrderDeliveryReplyPage.vue';
|
||||
|
||||
const hoisted = vi.hoisted(() => ({
|
||||
listMock: vi.fn(),
|
||||
saveMock: vi.fn(),
|
||||
batchMock: vi.fn(),
|
||||
notifyMock: vi.fn(),
|
||||
syncMock: vi.fn(),
|
||||
latestSyncMock: vi.fn(),
|
||||
requestJsonMock: vi.fn(),
|
||||
messageMocks: { info: vi.fn(), success: vi.fn(), warning: vi.fn(), error: vi.fn() },
|
||||
}));
|
||||
|
||||
vi.mock('@/features/order-delivery-reply/api/orderDeliveryReply.api', () => ({
|
||||
listOrderDeliveryLines: hoisted.listMock,
|
||||
saveOrderDeliveryBatches: hoisted.saveMock,
|
||||
batchReplyOrderDelivery: hoisted.batchMock,
|
||||
notifyOrderDeliveryBatch: hoisted.notifyMock,
|
||||
runOrderDeliverySync: hoisted.syncMock,
|
||||
getLatestOrderDeliverySync: hoisted.latestSyncMock,
|
||||
}));
|
||||
|
||||
vi.mock('@/shared/api/client', () => ({
|
||||
requestJson: hoisted.requestJsonMock,
|
||||
}));
|
||||
|
||||
vi.mock('@/shared/composables/useMessage', () => ({
|
||||
useMessage: () => hoisted.messageMocks,
|
||||
}));
|
||||
|
||||
vi.mock('@/features/auth/stores/auth.store', () => ({
|
||||
useAuthStore: () => ({ hasFeaturePermission: () => true }),
|
||||
}));
|
||||
|
||||
/** 两行样例:A 未回复(空批次,订单数量 1);B 部分回复(3 批次 30/50/20,订单数量 100)。 */
|
||||
const sampleLines = [
|
||||
{
|
||||
id: 1,
|
||||
order_no: '8301-T1',
|
||||
line_no: 4,
|
||||
qty: '1',
|
||||
unit: 'SET',
|
||||
status: 'not_replied' as const,
|
||||
locked: false,
|
||||
batches: [] as { seq?: number; planned_date: string; qty: string; remark?: string | null }[],
|
||||
undelivered_qty: '1',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
order_no: '8301-T2',
|
||||
line_no: 1,
|
||||
qty: '100',
|
||||
unit: 'PCS',
|
||||
status: 'partial_replied' as const,
|
||||
locked: false,
|
||||
batches: [
|
||||
{ seq: 1, planned_date: '2026-09-04', qty: '30', remark: null },
|
||||
{ seq: 2, planned_date: '2026-09-11', qty: '50', remark: null },
|
||||
{ seq: 3, planned_date: '2026-09-23', qty: '20', remark: null },
|
||||
],
|
||||
undelivered_qty: '0',
|
||||
},
|
||||
];
|
||||
|
||||
const mountPage = async () => {
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [{ path: '/:pathMatch(.*)*', component: { template: '<div />' } }],
|
||||
});
|
||||
router.push('/chat/39');
|
||||
await router.isReady();
|
||||
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages: { 'zh-CN': {} } });
|
||||
const wrapper = mount(OrderDeliveryReplyPage, {
|
||||
global: {
|
||||
plugins: [router, i18n],
|
||||
stubs: { PaginationBar: true, DeleteConfirmDialog: true },
|
||||
},
|
||||
});
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
describe('OrderDeliveryReplyPage 批次条就地编辑', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
hoisted.listMock.mockResolvedValue({ items: sampleLines, page: 1, page_size: 50, total: 2 });
|
||||
hoisted.latestSyncMock.mockResolvedValue(null);
|
||||
hoisted.saveMock.mockResolvedValue({ order_no: '8301-T1', line_no: 4, batches: [], total_qty: '1' });
|
||||
hoisted.requestJsonMock.mockResolvedValue(undefined);
|
||||
});
|
||||
|
||||
it('未回复行:点击空批次条进入编辑,填写日期+数量失焦后调用单行保存', async () => {
|
||||
const wrapper = await mountPage();
|
||||
|
||||
// 未回复行(8301-T1:4)的可编辑空批次条:title 为 replyAction 键(i18n 缺失时回退键名)
|
||||
const emptyChip = wrapper.find('div[title="workspace.orderDeliveryReply.replyAction"]');
|
||||
expect(emptyChip.exists()).toBe(true);
|
||||
await emptyChip.trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
// 编辑态输入条出现(data-chip-edit),自动聚焦日期框
|
||||
const editor = wrapper.find('[data-chip-edit]');
|
||||
expect(editor.exists()).toBe(true);
|
||||
const dateInput = editor.find('[data-chip-date]');
|
||||
expect((dateInput.element as HTMLInputElement).value).toBe('');
|
||||
|
||||
// 填写日期 + 数量后失焦提交
|
||||
await dateInput.setValue('2026-10-20');
|
||||
await editor.find('input[type="number"]').setValue('1');
|
||||
await editor.trigger('focusout');
|
||||
await flushPromises();
|
||||
|
||||
expect(hoisted.saveMock).toHaveBeenCalledTimes(1);
|
||||
expect(hoisted.saveMock).toHaveBeenCalledWith('8301-T1', 4, [
|
||||
{ planned_date: '2026-10-20', qty: '1', remark: null },
|
||||
]);
|
||||
});
|
||||
|
||||
it('未回复行:只填数量不填日期失焦 → 不保存且红字提示缺交期', async () => {
|
||||
const wrapper = await mountPage();
|
||||
const emptyChip = wrapper.find('div[title="workspace.orderDeliveryReply.replyAction"]');
|
||||
await emptyChip.trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
const editor = wrapper.find('[data-chip-edit]');
|
||||
await editor.find('input[type="number"]').setValue('1');
|
||||
await editor.trigger('focusout');
|
||||
await flushPromises();
|
||||
|
||||
expect(hoisted.saveMock).not.toHaveBeenCalled();
|
||||
const hint = wrapper.find('p.text-status-error');
|
||||
expect(hint.exists()).toBe(true);
|
||||
expect(hint.text()).toContain('batchMissingDate');
|
||||
});
|
||||
|
||||
it('多批次行:改第 2 条数量致合计≠订单数量失焦 → 不保存且红字提示', async () => {
|
||||
const wrapper = await mountPage();
|
||||
|
||||
// B 行(8301-T2:1)首条批次条:title 为 editReplyAction 键
|
||||
const chips = wrapper.findAll('div[title="workspace.orderDeliveryReply.editReplyAction"]');
|
||||
expect(chips.length).toBeGreaterThanOrEqual(1);
|
||||
await chips[0].trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
const editor = wrapper.find('[data-chip-edit]');
|
||||
// 预填首条批次当前值
|
||||
expect((editor.find('[data-chip-date]').element as HTMLInputElement).value).toBe('2026-09-04');
|
||||
// 只改数量为 60 → 30→60 后合计 130 ≠ 100
|
||||
await editor.find('input[type="number"]').setValue('60');
|
||||
await editor.trigger('focusout');
|
||||
await flushPromises();
|
||||
|
||||
expect(hoisted.saveMock).not.toHaveBeenCalled();
|
||||
const hint = wrapper.find('p.text-status-error');
|
||||
expect(hint.exists()).toBe(true);
|
||||
expect(hint.text()).toContain('qtyTotalMismatchLine');
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* features/order-delivery-reply/views/OrderDeliveryReplyPage.vue
|
||||
* 用途:订单交期回复工作台操作页——筛选分页、单行/联合回复批次、单行/批量通知、手动同步。
|
||||
* 依赖:api/orderDeliveryReply.api(统一 requestJson)、useMessage、auth store(manage/access 权限)。
|
||||
* 依赖:api/orderDeliveryReply.api(统一 requestJson)、useMessage、auth store(manage/access 权限)、
|
||||
* shared DeleteConfirmDialog(批量通知二次确认)、PaginationBar。
|
||||
* 逻辑:所有数据只读本地快照;保存与通知是两步(联合回复只保存,批量通知才发送并锁定);
|
||||
* 保存/通知成功后即时刷新列表(需求 §9);仅 access 用户隐藏全部写操作。
|
||||
* 回复弹窗数量守恒(2026-09-23 由「超额仅提醒」修订):每行各批次合计必须等于订单数量
|
||||
@@ -10,10 +11,30 @@
|
||||
* wecom_trace 上报打开回执——保证「点卡片 → 登录 → 直达该 Agent 对应内容与位置」。
|
||||
* 列顺序:客户编号(简称副文案) → 订单日期 → 订单单号:项次 → 产品编号(品名副文案) →
|
||||
* 客户产品编号 → 数量 → 约定交货日 → 交期回复状态 → 交期回复 → 交期回复人员 →
|
||||
* 业务员(部门副文案) → 客户订单 → 规格 → 单位;独立的部门列/品名列已并入合并展示。
|
||||
* 业务员(部门副文案) → 客户订单 → 规格 → 单位 → 通知时间(2026-10-09 自交期回复人员列拆出);
|
||||
* 独立的部门列/品名列已并入合并展示。
|
||||
* 浏览体验:页面高度收敛至视口(滚动全部发生在表格容器内 → 列头 sticky 固定、横向滚动条
|
||||
* 常驻表格底缘);左侧冻结前四列标识区(勾选/客户编号/订单日期/订单单号:项次,
|
||||
* 冻结单元格用实色背景防透出);筛选区与工具栏字号与表格统一(text-sm 14px)并压缩高度。
|
||||
* 冻结单元格用 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;
|
||||
* 弹窗用 dialog-overlay/panel/header/body/footer;输入用 input-field/select-field;
|
||||
* 状态与交互色一律走 --status-* 令牌(badge-*/bg-row-*/frozen-cell-*),品牌强调用 brand-*。
|
||||
* 批量通知确认使用共享 DeleteConfirmDialog(confirmTone=primary),不再用原生 window.confirm。
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -24,11 +45,14 @@ 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 DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { ChevronDown, ChevronUp, Download, Plus } from 'lucide-vue-next';
|
||||
import {
|
||||
ORDER_DELIVERY_REPLY_MANAGE_PERMISSION,
|
||||
} from '@/features/order-delivery-reply/constants';
|
||||
import {
|
||||
batchReplyOrderDelivery,
|
||||
exportOrderDeliveryLines,
|
||||
getLatestOrderDeliverySync,
|
||||
listOrderDeliveryLines,
|
||||
notifyOrderDeliveryBatch,
|
||||
@@ -158,15 +182,13 @@ function toggleExpand(key: string) {
|
||||
}
|
||||
|
||||
/* ============ 派生展示 ============ */
|
||||
const repliedQty = (line: OrderDeliveryLine) =>
|
||||
line.batches.reduce((sum, batch) => sum + Number(batch.qty || 0), 0);
|
||||
const undelivered = (line: OrderDeliveryLine) => Number(line.undelivered_qty || 0);
|
||||
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: 'bg-rose-50 text-rose-600' },
|
||||
partial_replied: { label: t('workspace.orderDeliveryReply.statusPartial'), cls: 'bg-orange-50 text-orange-600' },
|
||||
replied: { label: t('workspace.orderDeliveryReply.statusReplied'), cls: 'bg-emerald-50 text-emerald-600' },
|
||||
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];
|
||||
};
|
||||
@@ -184,6 +206,7 @@ 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) => ({
|
||||
@@ -203,10 +226,12 @@ function openReplyModal(lines: OrderDeliveryLine[], title: string, mode: 'single
|
||||
}
|
||||
|
||||
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');
|
||||
@@ -316,15 +341,153 @@ async function saveReplies() {
|
||||
}
|
||||
}
|
||||
|
||||
/* ============ 批次条就地编辑(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);
|
||||
const notifyConfirmVisible = ref(false);
|
||||
|
||||
/** 批量通知入口:先弹共享 DeleteConfirmDialog(primary 语气)二次确认,确认后执行 doNotifyBatch。 */
|
||||
function requestNotifyBatch() {
|
||||
if (!notifiableSelected.value.length) return;
|
||||
notifyConfirmVisible.value = true;
|
||||
}
|
||||
|
||||
/** 批量通知:部分成功 warning 汇总,全部失败 error;提示后刷新列表让锁定即时生效。 */
|
||||
async function doNotifyBatch() {
|
||||
const lines = notifiableSelected.value;
|
||||
if (!lines.length) return;
|
||||
const ok = window.confirm(t('workspace.orderDeliveryReply.notifyBatchConfirm', { count: lines.length }));
|
||||
if (!ok) return;
|
||||
notifying.value = true;
|
||||
try {
|
||||
const summary = await notifyOrderDeliveryBatch(lines.map((line) => ({ order_no: line.order_no, line_no: line.line_no })));
|
||||
@@ -373,15 +536,16 @@ function clearHighlight() {
|
||||
}
|
||||
|
||||
const isLineHighlighted = (line: OrderDeliveryLine) => highlightKey.value === lineKey(line);
|
||||
const rowCls = (line: OrderDeliveryLine) =>
|
||||
isLineHighlighted(line) ? 'bg-amber-50' : selected.value.includes(lineKey(line)) ? 'bg-blue-50/60' : '';
|
||||
/** 冻结单元格必须实色背景(防透出滚动内容),且与整行高亮/勾选色联动;高亮优先于勾选。 */
|
||||
const frozenCellCls = (line: OrderDeliveryLine) =>
|
||||
isLineHighlighted(line)
|
||||
? 'bg-amber-100 group-hover:bg-amber-200'
|
||||
: selected.value.includes(lineKey(line))
|
||||
? 'bg-blue-100 group-hover:bg-blue-200'
|
||||
: 'bg-white group-hover:bg-slate-100';
|
||||
/** 行交互态:直达高亮(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) {
|
||||
@@ -430,15 +594,17 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 全页统一字号:与表头一致(text-sm 14px),根容器设定基准,子元素不再覆写;
|
||||
唯一例外:交期回复状态/交期已锁定徽标保持 text-xs(12px)加粗 -->
|
||||
<!-- 高度收敛至视口(h-screen + overflow-hidden):页面自身不滚动,滚动全部在表格容器内,
|
||||
列头 sticky 固定、横向滚动条常驻表格底缘;聊天壳 iframe 与独立路由均适用 -->
|
||||
<div class="flex h-screen flex-col gap-4 overflow-hidden p-6 text-sm">
|
||||
<!-- 全页基准字号: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">
|
||||
<h1 class="font-bold text-primary">{{ t('workspace.nav.orderDeliveryReply') }}</h1>
|
||||
<span class="rounded-full px-3 py-1" :class="latestSyncFailed ? 'bg-rose-50 text-rose-600' : 'bg-blue-50 text-blue-600'">
|
||||
<!-- 页头标题字号与合同付款预警页头一致:小屏 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" />
|
||||
@@ -447,72 +613,70 @@ onMounted(async () => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索区:合并关键词搜索(订单/产品/客户命中任一字段),字号与表格统一(text-sm),shrink-0 防压缩 -->
|
||||
<div class="flex shrink-0 flex-wrap items-end gap-3 rounded-2xl border border-default bg-surface px-4 py-2.5">
|
||||
<label class="flex flex-col gap-1 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.filterKeyword') }}
|
||||
<input v-model="filters.keyword" class="h-8 min-w-[340px] rounded-lg border border-default px-3 text-primary outline-none focus:border-blue-500" :placeholder="t('workspace.orderDeliveryReply.filterKeywordPh')" @keyup.enter="doSearch" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.filterOrderDate') }}
|
||||
<input v-model="filters.order_date" type="date" class="h-8 rounded-lg border border-default px-3 text-primary outline-none focus:border-blue-500" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.filterStatus') }}
|
||||
<!-- 状态筛选选择即生效(无需再点查询);其余条件仍由「查询」统一提交 -->
|
||||
<select v-model="filters.status" class="min-w-[140px] rounded-lg border border-default bg-white px-3 py-[5px] text-sm leading-5 text-primary outline-none focus:border-blue-500" @change="doSearch">
|
||||
<option value="">{{ t('workspace.orderDeliveryReply.statusAll') }}</option>
|
||||
<option value="replied">{{ t('workspace.orderDeliveryReply.statusReplied') }}</option>
|
||||
<option value="not_fully_replied">{{ t('workspace.orderDeliveryReply.statusNotFully') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<button type="button" class="btn-primary h-8" @click="doSearch">{{ t('workspace.orderDeliveryReply.search') }}</button>
|
||||
<button type="button" class="btn-ghost h-8" @click="doReset">{{ t('workspace.orderDeliveryReply.reset') }}</button>
|
||||
<div class="flex-1" />
|
||||
<span class="text-muted">{{ t('workspace.orderDeliveryReply.totalCount', { count: total }) }}</span>
|
||||
<!-- 搜索区:合并关键词搜索(订单/产品/客户命中任一字段),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">
|
||||
<input v-model="filters.keyword" class="input-field h-9 w-auto min-w-[340px] rounded-lg px-3 py-1 text-sm" :placeholder="t('workspace.orderDeliveryReply.filterKeywordPh')" :aria-label="t('workspace.orderDeliveryReply.filterKeyword')" @keyup.enter="doSearch" />
|
||||
<input v-model="filters.order_date" type="date" class="input-field h-9 w-auto rounded-lg px-3 py-1 text-sm" :aria-label="t('workspace.orderDeliveryReply.filterOrderDate')" />
|
||||
<!-- 状态筛选选择即生效(无需再点查询);其余条件仍由「查询」统一提交 -->
|
||||
<select v-model="filters.status" class="select-field h-9 w-auto min-w-[140px] rounded-lg px-3 py-1 text-sm" :aria-label="t('workspace.orderDeliveryReply.filterStatus')" @change="doSearch">
|
||||
<option value="">{{ t('workspace.orderDeliveryReply.statusAll') }}</option>
|
||||
<option value="replied">{{ t('workspace.orderDeliveryReply.statusReplied') }}</option>
|
||||
<option value="not_fully_replied">{{ t('workspace.orderDeliveryReply.statusNotFully') }}</option>
|
||||
</select>
|
||||
<!-- 查询/重置:text-sm(14px)+font-semibold(600)+h-9(36px),与合同付款预警 .contract-filter-submit 完全一致 -->
|
||||
<button type="button" class="btn-primary h-9 text-sm font-semibold" @click="doSearch">{{ t('workspace.orderDeliveryReply.search') }}</button>
|
||||
<button type="button" class="btn-ghost h-9 text-sm font-semibold" @click="doReset">{{ t('workspace.orderDeliveryReply.reset') }}</button>
|
||||
</div>
|
||||
|
||||
<!-- 工具栏:全选 + 联合回复 + 批量通知(shrink-0 防压缩,py-2 紧凑高度) -->
|
||||
<div class="flex shrink-0 flex-wrap items-center gap-3 rounded-2xl border border-default bg-surface px-4 py-2">
|
||||
<div class="surface-panel flex shrink-0 flex-wrap items-center gap-3 px-4 py-2">
|
||||
<label class="flex items-center gap-2 text-primary">
|
||||
<input type="checkbox" class="h-4 w-4 rounded border-default text-blue-600" :checked="allChecked" :indeterminate.prop="someChecked" @change="togglePageAll(($event.target as HTMLInputElement).checked)" />
|
||||
<input type="checkbox" class="admin-checkbox" :checked="allChecked" :indeterminate.prop="someChecked" @change="togglePageAll(($event.target as HTMLInputElement).checked)" />
|
||||
{{ t('workspace.orderDeliveryReply.selectAll') }}
|
||||
</label>
|
||||
<span class="text-muted">{{ t('workspace.orderDeliveryReply.selectedCount', { count: selectedLines.length }) }}</span>
|
||||
<template v-if="canManage">
|
||||
<button type="button" class="btn-primary h-8" :disabled="selectedLines.length === 0" @click="openBatchReply">
|
||||
<button type="button" class="btn-primary h-9 text-sm font-semibold" :disabled="selectedLines.length === 0" @click="openBatchReply">
|
||||
{{ t('workspace.orderDeliveryReply.batchReply') }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary h-8" :disabled="notifiableSelected.length === 0 || notifying" @click="doNotifyBatch">
|
||||
<button type="button" class="btn-primary h-9 text-sm font-semibold" :disabled="notifiableSelected.length === 0 || notifying" @click="requestNotifyBatch">
|
||||
{{ t('workspace.orderDeliveryReply.batchNotify') }}
|
||||
</button>
|
||||
</template>
|
||||
<div class="flex-1" />
|
||||
<span class="whitespace-nowrap rounded-full bg-slate-100 px-3 py-1 text-muted">{{ t('workspace.orderDeliveryReply.toolbarHint') }}</span>
|
||||
<!-- 导出 Excel(2026-10-09 增补,原提示文字胶囊取消):按当前筛选导出全部行 -->
|
||||
<button type="button" class="btn-primary h-9 text-sm font-semibold" :disabled="exporting" @click="doExportExcel">
|
||||
<Download class="h-4 w-4" aria-hidden="true" />
|
||||
{{ t('workspace.orderDeliveryReply.exportExcel') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 列表 -->
|
||||
<div class="min-h-0 flex-1 overflow-auto rounded-2xl border border-default bg-surface">
|
||||
<table class="w-full border-collapse">
|
||||
<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-slate-50 text-muted [&_th]:whitespace-nowrap">
|
||||
<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-slate-50 px-2 py-2" />
|
||||
<th class="sticky left-8 z-30 w-32 min-w-[8rem] bg-slate-50 px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colCustomer') }}</th>
|
||||
<th class="sticky left-[10rem] z-30 w-24 bg-slate-50 px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colOrderDate') }}</th>
|
||||
<th class="sticky left-[16rem] z-30 w-40 min-w-[10rem] border-r border-default bg-slate-50 px-2 py-2 text-left shadow-[2px_0_6px_-2px_rgba(15,23,42,0.12)]">{{ t('workspace.orderDeliveryReply.colOrderLine') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colPartNo') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colCustomerPartNo') }}</th>
|
||||
<th class="px-2 py-2 text-right">{{ t('workspace.orderDeliveryReply.colQty') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colAgreedDate') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colStatus') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colReply') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colReplyPerson') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colSalesperson') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colCustomerPo') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colSpec') }}</th>
|
||||
<th class="px-2 py-2 text-left">{{ t('workspace.orderDeliveryReply.colUnit') }}</th>
|
||||
<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>
|
||||
@@ -520,15 +684,15 @@ onMounted(async () => {
|
||||
v-for="line in items"
|
||||
:key="lineKey(line)"
|
||||
:data-line-key="lineKey(line)"
|
||||
class="group border-t border-default hover:bg-slate-50"
|
||||
class="hover-row border-t border-default"
|
||||
:class="rowCls(line)"
|
||||
>
|
||||
<!-- 冻结单元格必须实色背景(半透明会透出滚动内容),并用 group-hover 与整行悬停/选中/直达高亮联动 -->
|
||||
<!-- 冻结单元格:frozen-cell 实色基底(半透明会透出滚动内容),悬停/选中/直达高亮由 CSS 联动 -->
|
||||
<td
|
||||
class="sticky left-0 z-20 px-2 py-1.5"
|
||||
:class="frozenCellCls(line)"
|
||||
>
|
||||
<input type="checkbox" class="h-4 w-4 rounded border-default text-blue-600" :checked="selected.includes(lineKey(line))" @change="toggleLine(line, ($event.target as HTMLInputElement).checked)" />
|
||||
<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"
|
||||
@@ -543,70 +707,132 @@ onMounted(async () => {
|
||||
: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 shadow-[2px_0_6px_-2px_rgba(15,23,42,0.12)]"
|
||||
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 || ''">
|
||||
<div class="max-w-[10rem] truncate font-mono">{{ line.part_no || '—' }}</div>
|
||||
<div class="max-w-[14rem] truncate text-muted">{{ line.part_name || '' }}</div>
|
||||
<!-- 截断盒 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-right tabular-nums">{{ line.qty ?? '—' }}</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="whitespace-nowrap rounded-full px-2.5 py-0.5 text-xs font-semibold" :class="statusMeta(line.status).cls">
|
||||
<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>
|
||||
<!-- 交期回复:无批次=回复交期;有批次可展开;锁定=已锁定 -->
|
||||
<td class="px-2 py-1.5 align-top">
|
||||
<!-- 交期回复:动作入口为批次条前的加号(lucide Plus);未回复=空批次条(不显示时间/数量);
|
||||
所有行首条批次条前保留等宽加号占位(无动作时为透明占位)、展开行其余批次条加 pl-7 缩进,
|
||||
保证全表批次条左缘对齐;「交期已锁定」徽标已取消(锁定状态由无加号与交期回复人员列「已通知」体现);
|
||||
>1 批时首条批次后有展开/收起小箭头 -->
|
||||
<td class="px-2 py-1.5">
|
||||
<template v-if="line.batches.length === 0">
|
||||
<span class="text-muted">{{ t('workspace.orderDeliveryReply.statusNotReplied') }}</span>
|
||||
<div v-if="canManage" class="mt-0.5">
|
||||
<button type="button" class="rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-blue-600" @click="openSingleReply(line)">
|
||||
{{ t('workspace.orderDeliveryReply.replyAction') }}
|
||||
<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 items-center gap-2">
|
||||
<span class="whitespace-nowrap rounded-full border border-default bg-slate-50 px-2 py-0.5 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.batchCount', { count: line.batches.length }) }} ·
|
||||
{{ t('workspace.orderDeliveryReply.repliedOf', { replied: repliedQty(line), remain: undelivered(line) }) }}
|
||||
<span v-if="repliedQty(line) > undelivered(line)" class="ml-1 font-semibold text-orange-500">{{ t('workspace.orderDeliveryReply.overTag') }}</span>
|
||||
</span>
|
||||
<button v-if="line.batches.length > 1" type="button" class="rounded-full border border-default px-2 py-0.5 text-blue-600" @click="toggleExpand(lineKey(line))">
|
||||
{{ expanded.includes(lineKey(line)) ? t('workspace.orderDeliveryReply.collapse') : t('workspace.orderDeliveryReply.expand', { count: line.batches.length - 1 }) }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-0.5 flex flex-col gap-0.5">
|
||||
<div class="flex flex-col gap-0.5">
|
||||
<div
|
||||
v-for="(batch, idx) in line.batches"
|
||||
:key="batch.seq ?? idx"
|
||||
v-show="expanded.includes(lineKey(line)) || idx === 0"
|
||||
class="max-w-[230px] truncate rounded border-l-[3px] border-blue-500 bg-blue-50/50 px-2 py-0.5 text-secondary"
|
||||
v-show="idx === 0 || expanded.includes(lineKey(line))"
|
||||
class="flex items-center gap-1"
|
||||
:class="idx > 0 ? 'pl-7' : ''"
|
||||
>
|
||||
{{ batch.planned_date }} · <b class="text-blue-600">{{ batch.qty }}</b> {{ line.unit }}
|
||||
<i v-if="batch.remark" class="ml-1 not-italic text-muted">{{ batch.remark }}</i>
|
||||
<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>
|
||||
<div class="mt-0.5">
|
||||
<span v-if="line.locked" class="rounded-full bg-emerald-50 px-2.5 py-0.5 text-xs font-semibold text-emerald-600">{{ t('workspace.orderDeliveryReply.lockedTag') }}</span>
|
||||
<button v-else-if="canManage" type="button" class="rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-blue-600" @click="openSingleReply(line)">
|
||||
{{ t('workspace.orderDeliveryReply.editReplyAction') }}
|
||||
</button>
|
||||
</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>
|
||||
<div v-if="line.locked" class="text-emerald-600">
|
||||
{{ t('workspace.orderDeliveryReply.notifiedTag', { name: line.salesperson_name || line.salesperson_code || '' }) }}
|
||||
<span class="text-muted">{{ line.notified_at || '' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<span v-else class="text-muted">{{ t('workspace.orderDeliveryReply.pendingNotify') }}</span>
|
||||
</td>
|
||||
@@ -615,20 +841,21 @@ onMounted(async () => {
|
||||
<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="block max-w-[10rem] truncate">{{ line.customer_po || '—' }}</span></td>
|
||||
<td class="px-2 py-1.5" :title="line.spec || ''"><span class="block max-w-[10rem] truncate">{{ line.spec || '—' }}</span></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="15" class="px-4 py-16 text-center text-muted">{{ t('workspace.orderDeliveryReply.empty') }}</td>
|
||||
<td colspan="16" class="px-4 py-16 text-center text-muted">{{ t('workspace.orderDeliveryReply.empty') }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 分页:复用管理控制台-数据报表的 PaginationBar(摘要 + 每页条数 + 页码按钮) -->
|
||||
<!-- 分页:复用管理控制台-数据报表的 PaginationBar(摘要 + 每页条数 + 页码按钮),组件自带字号不再强改 -->
|
||||
<PaginationBar
|
||||
class="[&_*]:!text-sm"
|
||||
:page="page"
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
@@ -637,30 +864,29 @@ onMounted(async () => {
|
||||
@update:page-size="changePageSize"
|
||||
/>
|
||||
|
||||
<!-- 回复弹窗 -->
|
||||
<div v-if="modalVisible" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40" @click.self="modalVisible = false">
|
||||
<div class="flex max-h-[88vh] w-[min(960px,94vw)] flex-col overflow-hidden rounded-2xl bg-white shadow-2xl">
|
||||
<div class="flex items-center gap-3 border-b border-default px-5 py-4">
|
||||
<!-- 回复弹窗:dialog-overlay/panel/header/body/footer 设计系统 L2 结构 -->
|
||||
<div v-if="modalVisible" class="dialog-overlay items-center" @click.self="modalVisible = false">
|
||||
<div class="dialog-panel max-h-[88vh] w-[min(960px,94vw)]">
|
||||
<div class="dialog-header">
|
||||
<h3 class="font-bold text-primary">{{ modalTitle }}</h3>
|
||||
<div class="flex-1" />
|
||||
<button type="button" class="text-muted" @click="modalVisible = false">×</button>
|
||||
<button type="button" class="btn-ghost h-8 w-8 px-0 text-lg leading-none" @click="modalVisible = false">×</button>
|
||||
</div>
|
||||
<div class="flex-1 overflow-auto px-5 py-4">
|
||||
<div class="dialog-body">
|
||||
<!-- 快速统一交期:仅联合回复弹窗显示;单行回复/修改回复弹窗已取消该区(2026-10-07),直接逐批次填写 -->
|
||||
<div v-if="modalMode === 'batch'" class="mb-4 flex flex-wrap items-end gap-3 rounded-xl border border-default bg-blue-50/40 px-4 py-3">
|
||||
<div v-if="modalMode === 'batch'" class="flex flex-wrap items-end gap-3 rounded-xl border border-default bg-surface-soft px-4 py-3">
|
||||
<label class="flex flex-col gap-1 text-muted">
|
||||
{{ t('workspace.orderDeliveryReply.quickDate') }}
|
||||
<input v-model="quickDate" type="date" class="h-9 rounded-lg border border-default px-3 text-primary" />
|
||||
<input v-model="quickDate" type="date" class="input-field h-9 w-auto rounded-lg px-3 py-1.5" />
|
||||
</label>
|
||||
<button type="button" class="h-9 rounded-lg border border-default px-3 text-primary" @click="applyQuickDate">
|
||||
<button type="button" class="btn-secondary btn-sm h-9" @click="applyQuickDate">
|
||||
{{ t('workspace.orderDeliveryReply.applyQuickDate') }}
|
||||
</button>
|
||||
<span class="text-muted">{{ t('workspace.orderDeliveryReply.modalHint') }}</span>
|
||||
</div>
|
||||
<!-- 每行批次编辑器 -->
|
||||
<div v-for="entry in modalLines" :key="lineKey(entry.line)" class="mb-4 overflow-hidden rounded-xl border border-default">
|
||||
<div class="flex flex-wrap items-center gap-2 bg-slate-50 px-3 py-2">
|
||||
<span class="rounded bg-indigo-50 px-2 py-0.5 font-semibold text-indigo-600">{{ entry.line.order_no }}</span>
|
||||
<div v-for="entry in modalLines" :key="lineKey(entry.line)" class="overflow-hidden rounded-xl border border-default">
|
||||
<div class="flex flex-wrap items-center gap-2 bg-surface-soft px-3 py-2">
|
||||
<span class="rounded bg-surface-strong px-2 py-0.5 font-semibold text-primary">{{ entry.line.order_no }}</span>
|
||||
<span>{{ t('workspace.orderDeliveryReply.itemLabel', { item: entry.line.line_no }) }}</span>
|
||||
<span class="text-muted">{{ entry.line.customer_no }} · {{ entry.line.customer_short_name }}</span>
|
||||
<span class="text-muted">{{ entry.line.part_no }} · {{ entry.line.part_name }}</span>
|
||||
@@ -669,27 +895,36 @@ onMounted(async () => {
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-3 py-3">
|
||||
<div v-for="(batch, idx) in entry.batches" :key="idx" class="grid grid-cols-[170px_120px_1fr_36px] items-center gap-2">
|
||||
<input v-model="batch.planned_date" type="date" class="h-9 rounded-lg border border-default px-2 text-primary" />
|
||||
<input v-model="batch.qty" type="number" min="0" :placeholder="t('workspace.orderDeliveryReply.qtyPh')" class="h-9 rounded-lg border border-default px-2 text-primary" />
|
||||
<input v-model="batch.remark" :placeholder="t('workspace.orderDeliveryReply.remarkPh')" class="h-9 rounded-lg border border-default px-2 text-primary" />
|
||||
<button type="button" class="h-9 rounded-lg bg-rose-50 text-rose-600" :title="t('workspace.orderDeliveryReply.removeBatch')" @click="entry.batches.splice(idx, 1)">✕</button>
|
||||
<div v-for="(batch, idx) in entry.batches" :key="idx" class="grid grid-cols-[170px_120px_1fr_40px] items-center gap-2">
|
||||
<input v-model="batch.planned_date" type="date" class="input-field h-9 rounded-lg px-2 py-1.5" />
|
||||
<input v-model="batch.qty" type="number" min="0" :placeholder="t('workspace.orderDeliveryReply.qtyPh')" class="input-field h-9 rounded-lg px-2 py-1.5" />
|
||||
<input v-model="batch.remark" :placeholder="t('workspace.orderDeliveryReply.remarkPh')" class="input-field h-9 rounded-lg px-2 py-1.5" />
|
||||
<button type="button" class="btn-danger btn-sm" :title="t('workspace.orderDeliveryReply.removeBatch')" @click="entry.batches.splice(idx, 1)">✕</button>
|
||||
</div>
|
||||
<button type="button" class="w-full rounded-lg border border-dashed border-slate-300 py-2 text-blue-600" @click="entry.batches.push({ planned_date: '', qty: '', remark: '' })">
|
||||
<button type="button" class="w-full rounded-lg border border-dashed border-default py-2 text-brand-600 transition-colors hover-surface-soft" @click="entry.batches.push({ planned_date: '', qty: '', remark: '' })">
|
||||
{{ t('workspace.orderDeliveryReply.addBatch') }}
|
||||
</button>
|
||||
<!-- 行级实时校验提示:缺交期/缺数量按批次序号指出,合计不等给出已填/应填;随填写实时切换 -->
|
||||
<p v-if="lineIssueText(entry)" class="text-rose-500">{{ lineIssueText(entry) }}</p>
|
||||
<p v-if="lineIssueText(entry)" class="text-status-error">{{ lineIssueText(entry) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end gap-3 border-t border-default bg-slate-50 px-5 py-3">
|
||||
<button type="button" class="btn-ghost" @click="modalVisible = false">{{ t('common.cancel') }}</button>
|
||||
<div class="dialog-footer">
|
||||
<button type="button" class="btn-secondary" @click="modalVisible = false">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="saveReplies">
|
||||
{{ saving ? t('workspace.orderDeliveryReply.saving') : t('workspace.orderDeliveryReply.saveReply') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 批量通知二次确认:共享 DeleteConfirmDialog(primary 语气,非删除;确认/取消文案用组件默认 i18n) -->
|
||||
<DeleteConfirmDialog
|
||||
v-model="notifyConfirmVisible"
|
||||
:title="t('workspace.orderDeliveryReply.batchNotify')"
|
||||
:message="t('workspace.orderDeliveryReply.notifyBatchConfirm', { count: notifiableSelected.length })"
|
||||
confirm-tone="primary"
|
||||
@confirm="doNotifyBatch"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user