chore(order-delivery-reply): 前端页面调整、细节修改、优化逻辑等
This commit is contained in:
1 parent
7fb36b301c
commit
36868f875c
36 files changed
+1577
-376
No files matched your search
@@ -133,6 +133,20 @@ const loadOptions = async (source: string): Promise<void> => {
|
||||
}
|
||||
};
|
||||
|
||||
/** multi_select 选项本地搜索词(按字段 key 隔离)。 */
|
||||
const multiSearch = reactive<Record<string, string>>({});
|
||||
|
||||
/** multi_select 选项按关键词过滤(匹配 label/描述,大小写不敏感)。 */
|
||||
const filteredMultiOptions = (field: PlatformTaskParamField) => {
|
||||
const keyword = (multiSearch[field.key] || '').trim().toLowerCase();
|
||||
const all = optionsCache[field.options_source || ''] || [];
|
||||
if (!keyword) return all;
|
||||
return all.filter((o) =>
|
||||
String(o.label || '').toLowerCase().includes(keyword) ||
|
||||
String(o.description || '').toLowerCase().includes(keyword),
|
||||
);
|
||||
};
|
||||
|
||||
/** multi_select 勾选切换。 */
|
||||
const toggleMultiValue = (key: string, value: string | number): void => {
|
||||
const current: Array<string | number> = Array.isArray(params.value[key]) ? [...params.value[key]] : [];
|
||||
@@ -323,6 +337,12 @@ watch(
|
||||
v-else-if="field.type === 'multi_select'"
|
||||
class="max-h-52 space-y-1 overflow-y-auto rounded-xl border border-default bg-surface p-2"
|
||||
>
|
||||
<input
|
||||
v-model="multiSearch[field.key]"
|
||||
type="text"
|
||||
class="mb-1 w-full rounded-lg border border-default px-2 py-1.5 text-sm outline-none focus:border-blue-500"
|
||||
:placeholder="$t('admin.schedule.form.dynamicParamsSearchPlaceholder')"
|
||||
/>
|
||||
<p v-if="optionsLoading[field.options_source || '']" class="px-2 py-1 text-xs text-muted">
|
||||
{{ $t('admin.schedule.form.dynamicParamsOptionsLoading') }}
|
||||
</p>
|
||||
@@ -332,8 +352,14 @@ watch(
|
||||
>
|
||||
{{ $t('admin.schedule.form.dynamicParamsNoOptions') }}
|
||||
</p>
|
||||
<p
|
||||
v-else-if="!filteredMultiOptions(field).length"
|
||||
class="px-2 py-1 text-xs text-muted"
|
||||
>
|
||||
{{ $t('admin.schedule.form.dynamicParamsSearchNoMatch') }}
|
||||
</p>
|
||||
<label
|
||||
v-for="option in optionsCache[field.options_source || ''] || []"
|
||||
v-for="option in filteredMultiOptions(field)"
|
||||
:key="String(option.value)"
|
||||
class="flex cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 text-sm transition hover:bg-surface-soft"
|
||||
>
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
* 依赖:api/orderDeliveryReply.api(统一 requestJson)、useMessage、auth store(manage/access 权限)。
|
||||
* 逻辑:所有数据只读本地快照;保存与通知是两步(联合回复只保存,批量通知才发送并锁定);
|
||||
* 保存/通知成功后即时刷新列表(需求 §9);仅 access 用户隐藏全部写操作。
|
||||
* 回复弹窗数量守恒(2026-09-23 由「超额仅提醒」修订):每行各批次合计必须等于订单数量
|
||||
* 才能保存,弹窗实时红字提示 + 保存拦截,后端 422 兜底。
|
||||
* 企微卡片直达:登录回跳后 query 仍在,按 status/order_no/line_no 还原筛选并滚动高亮目标行,
|
||||
* wecom_trace 上报打开回执——保证「点卡片 → 登录 → 直达该 Agent 对应内容与位置」。
|
||||
* 列顺序:客户编号(简称副文案) → 订单日期 → 订单单号:项次 → 产品编号(品名副文案) →
|
||||
* 客户产品编号 → 数量 → 约定交货日 → 交期回复状态 → 交期回复 → 交期回复人员 →
|
||||
* 业务员(部门副文案) → 客户订单 → 规格 → 单位;独立的部门列/品名列已并入合并展示。
|
||||
@@ -13,11 +17,12 @@
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
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 {
|
||||
ORDER_DELIVERY_REPLY_MANAGE_PERMISSION,
|
||||
@@ -75,6 +80,7 @@ async function loadLatestSync() {
|
||||
}
|
||||
|
||||
function doSearch() {
|
||||
clearHighlight();
|
||||
Object.assign(appliedFilters, filters);
|
||||
page.value = 1;
|
||||
void loadLines();
|
||||
@@ -208,16 +214,47 @@ function applyQuickDate() {
|
||||
modalLines.value.forEach((entry) => entry.batches.forEach((batch) => { batch.planned_date = quickDate.value; }));
|
||||
}
|
||||
|
||||
/** 拆分合计超出未交数量时仅提醒不拦截(需求 §9)。 */
|
||||
const overQtyEntries = computed(() =>
|
||||
modalLines.value
|
||||
.filter((entry) => entry.batches.some((batch) => batch.planned_date && Number(batch.qty) > 0))
|
||||
.map((entry) => ({
|
||||
entry,
|
||||
total: entry.batches.reduce((sum, batch) => sum + (batch.planned_date && Number(batch.qty) > 0 ? Number(batch.qty) : 0), 0),
|
||||
}))
|
||||
.filter(({ entry, total }) => total > undelivered(entry.line)),
|
||||
);
|
||||
/**
|
||||
* 行填写问题文案(实时校验,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 }[] }[] = [];
|
||||
@@ -229,6 +266,17 @@ async function saveReplies() {
|
||||
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;
|
||||
@@ -305,15 +353,75 @@ const latestSyncText = computed(() => {
|
||||
});
|
||||
const latestSyncFailed = computed(() => latestSync.value?.status === 'failed');
|
||||
|
||||
onMounted(() => {
|
||||
// 企微卡片 jump_path 带 order_no/line_no 直达:自动填入关键词筛选并命中该行(关键词命中订单单号)。
|
||||
const query = useRoute().query;
|
||||
if (typeof query.order_no === 'string' && query.order_no) {
|
||||
filters.keyword = query.order_no;
|
||||
Object.assign(appliedFilters, filters);
|
||||
/* ============ 企微卡片直达定位 ============ */
|
||||
// 企微卡片「查看详情」→(未登录先登录,守卫以 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;
|
||||
}
|
||||
void loadLines();
|
||||
highlightKey.value = '';
|
||||
}
|
||||
|
||||
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';
|
||||
|
||||
/** 列表就绪后定位目标行:滚动到视口中央 + 高亮 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);仅留痕,失败不影响页面使用。 */
|
||||
async function reportWecomTraceOpened(traceId: string) {
|
||||
try {
|
||||
await requestJson('/api/user/wecom/deeplink-opened', {
|
||||
method: 'POST',
|
||||
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>
|
||||
|
||||
@@ -407,19 +515,20 @@ onMounted(() => {
|
||||
<tr
|
||||
v-for="line in items"
|
||||
:key="lineKey(line)"
|
||||
:data-line-key="lineKey(line)"
|
||||
class="group border-t border-default hover:bg-slate-50"
|
||||
:class="selected.includes(lineKey(line)) ? 'bg-blue-50/60' : ''"
|
||||
:class="rowCls(line)"
|
||||
>
|
||||
<!-- 冻结单元格必须实色背景(半透明会透出滚动内容),并用 group-hover 与整行悬停/选中联动 -->
|
||||
<!-- 冻结单元格必须实色背景(半透明会透出滚动内容),并用 group-hover 与整行悬停/选中/直达高亮联动 -->
|
||||
<td
|
||||
class="sticky left-0 z-20 px-2 py-1.5"
|
||||
:class="selected.includes(lineKey(line)) ? 'bg-blue-100 group-hover:bg-blue-200' : 'bg-white group-hover:bg-slate-100'"
|
||||
: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)" />
|
||||
</td>
|
||||
<td
|
||||
class="sticky left-8 z-20 w-32 min-w-[8rem] max-w-[8rem] px-2 py-1.5"
|
||||
:class="selected.includes(lineKey(line)) ? 'bg-blue-100 group-hover:bg-blue-200' : 'bg-white group-hover:bg-slate-100'"
|
||||
:class="frozenCellCls(line)"
|
||||
:title="line.customer_full_name || line.customer_short_name || ''"
|
||||
>
|
||||
<div>{{ line.customer_no || '—' }}</div>
|
||||
@@ -427,11 +536,11 @@ onMounted(() => {
|
||||
</td>
|
||||
<td
|
||||
class="sticky left-[10rem] z-20 w-24 min-w-[6rem] max-w-[6rem] overflow-hidden px-2 py-1.5"
|
||||
:class="selected.includes(lineKey(line)) ? 'bg-blue-100 group-hover:bg-blue-200' : 'bg-white group-hover:bg-slate-100'"
|
||||
: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="selected.includes(lineKey(line)) ? 'bg-blue-100 group-hover:bg-blue-200' : 'bg-white group-hover:bg-slate-100'"
|
||||
: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>
|
||||
@@ -551,8 +660,8 @@ onMounted(() => {
|
||||
<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>
|
||||
<span class="ml-auto">
|
||||
{{ t('workspace.orderDeliveryReply.undeliveredLabel', { remain: undelivered(entry.line), unit: entry.line.unit || '' }) }}
|
||||
<span class="ml-auto whitespace-nowrap">
|
||||
{{ t('workspace.orderDeliveryReply.orderQtyLabel', { qty: entry.line.qty ?? 0, unit: entry.line.unit || '' }) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 px-3 py-3">
|
||||
@@ -565,11 +674,10 @@ onMounted(() => {
|
||||
<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: '' })">
|
||||
{{ t('workspace.orderDeliveryReply.addBatch') }}
|
||||
</button>
|
||||
<!-- 行级实时校验提示:缺交期/缺数量按批次序号指出,合计不等给出已填/应填;随填写实时切换 -->
|
||||
<p v-if="lineIssueText(entry)" class="text-rose-500">{{ lineIssueText(entry) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="overQtyEntries.length" class="text-orange-500">
|
||||
{{ t('workspace.orderDeliveryReply.overWarning', { detail: overQtyEntries.map(({ entry, total }) => `${entry.line.order_no}:${entry.line.line_no} ${total} > ${undelivered(entry.line)}`).join(';') }) }}
|
||||
</p>
|
||||
</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>
|
||||
|
||||
Reference in new issue
Block a user