Merge branch 'dev' into change

This commit is contained in:
HTEWJ\26070045 committed 2026-10-13 09:23:01 +08:00
commit e181d4e9ec
137 files changed
+11616 -568

No files matched your search

@@ -261,7 +261,7 @@ watch(
type="date"
:value="params[field.key] ?? ''"
class="input-field w-full !text-sm !leading-5"
@input="setField(field.key, ($event.target as HTMLInputElement).value)"
@input="setField(field.key, ($event.target as HTMLInputElement).value === '' ? null : ($event.target as HTMLInputElement).value)"
/>
<input
v-else-if="field.type === 'datetime'"
@@ -341,7 +341,7 @@ watch(
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')"
:placeholder="resolveText(field.placeholder_key, field.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') }}
@@ -877,7 +877,6 @@ onMounted(() => {
}
.edit-card .input-field, .impact-dialog .input-field, .impact-dialog .select-field { min-width: 0; padding: 8px 9px; font: inherit; font-size: 13px; }
.actions, .impact-dialog footer { display: flex; flex-wrap: wrap; gap: 8px; }
.impact-dialog footer { justify-content: flex-end; }
.link-list, .plain-list { margin: 0; padding-left: 1.1rem; color: #475569; font-size: 13px; }
.adoption-link { color: #0369a1; text-decoration: underline; text-underline-offset: 2px; }
.adoption-link:hover { color: #0c4a6e; }
@@ -924,10 +923,12 @@ onMounted(() => {
background: var(--overlay-soft); padding: 24px;
}
.impact-dialog {
display: grid; width: min(520px, 96vw); max-height: 82vh; gap: 14px; overflow: auto;
display: grid; grid-auto-rows: max-content; width: min(520px, 96vw); max-height: 82vh; gap: 14px; overflow-y: auto;
border-radius: 12px; background: #fff; padding: 18px; box-shadow: 0 24px 64px rgb(15 23 42 / .24);
}
.impact-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* footer 用 sticky 钉在对话框可视底部:内容超高时确认/取消始终可见,不随表单或影响列表滚动消失(负 margin 抵消对话框 padding 实现通栏) */
.impact-dialog footer { position: sticky; bottom: -18px; justify-content: flex-end; margin: 4px -18px -18px; border-top: 1px solid var(--border-default); background: #fff; padding: 12px 18px; }
.impact-dialog h2, .impact-dialog p { margin: 0; }
.impact-summary {
display: grid; gap: 8px; border: 1px solid #fecaca; border-radius: 8px;
@@ -316,14 +316,15 @@ onMounted(() => { void load(); });
.identity-hero h1 { margin: 0; }
.identity-hero p { max-width: 760px; }
.identity-hero__meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }
.identity-hero__status { display: inline-flex; align-items: center; gap: .48rem; padding: .5rem .75rem; border: 1px solid #bfe7f8; border-radius: 999px; background: #effaff; color: #087aaa; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.identity-pulse { width: .5rem; height: .5rem; border-radius: 50%; background: #18b17c; box-shadow: 0 0 0 4px #dff8ed; }.identity-pulse--draft { background: #e09b22; box-shadow: 0 0 0 4px #fff2d5; }
/* 状态/品牌色统一 Tailwind 标准语义值(brand=sky 系 #0284c7、启用=green、草稿=amber),不再使用自造蓝绿 */
.identity-hero__status { display: inline-flex; align-items: center; gap: .48rem; padding: .5rem .75rem; border: 1px solid #bae6fd; border-radius: 999px; background: #f0f9ff; color: #0369a1; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.identity-pulse { width: .5rem; height: .5rem; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 4px #d1fae5; }.identity-pulse--draft { background: #f59e0b; box-shadow: 0 0 0 4px #fef3c7; }
.identity-hero__link { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.identity-flow { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; padding: 1rem; overflow: hidden; border: 1px solid #dce9f2; border-radius: 1rem; background: linear-gradient(105deg, #f4fbff, #fff); }
.identity-flow__rail { position: absolute; top: 1.84rem; left: 12%; right: 12%; height: 1px; background: #cce5f2; }
.identity-flow__step { position: relative; z-index: 1; display: flex; gap: .75rem; align-items: flex-start; min-width: 0; }
.identity-flow__step > span { display: grid; place-items: center; flex: 0 0 1.65rem; height: 1.65rem; border: 1px solid #b9d8e8; border-radius: 50%; background: #fff; color: #6b8298; font-size: .66rem; font-weight: 800; }
.identity-flow__step--active > span { border-color: #0d93cf; background: #0d93cf; color: #fff; box-shadow: 0 0 0 4px #dff4fc; }
.identity-flow__step--active > span { border-color: #0284c7; background: #0284c7; color: #fff; box-shadow: 0 0 0 4px #e0f2fe; }
.identity-flow strong { display: block; color: #193652; font-size: .82rem; font-weight: 800; }
.identity-flow small { display: -webkit-box; overflow: hidden; margin-top: .15rem; color: #7a8fa6; font-size: .72rem; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.identity-loading { display: flex; align-items: center; gap: .5rem; padding: 2rem; color: #6f839b; font-size: .9rem; }
@@ -336,12 +337,12 @@ onMounted(() => { void load(); });
.identity-definition-list { display: grid; }
.identity-definition-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .78rem 1.35rem; border-bottom: 1px solid #edf3f7; transition: background .18s ease; }
.identity-definition-row:hover { background: #f7fbfd; }
.identity-definition-row__icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: #e9f7fd; color: #0b90cc; }
.identity-definition-row__icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: #f0f9ff; color: #0284c7; }
.identity-definition-row strong { color: #1a3856; font-size: .86rem; font-weight: 750; }
.identity-definition-row p { overflow: hidden; margin-top: .18rem; color: #8194a8; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.identity-target, .identity-automation { padding: .32rem .52rem; border-radius: 999px; background: #f1f5f8; color: #677f98; font-size: .7rem; white-space: nowrap; }
.identity-automation-select { border: 1px solid #dce8ef; cursor: pointer; }
.identity-automation--enabled { background: #e4f8ef; color: #12865c; }
.identity-automation--enabled { background: #dcfce7; color: #15803d; }
.identity-empty { display: flex; align-items: center; gap: .55rem; min-height: 5.5rem; padding: 1.2rem 1.35rem; color: #7c91a7; font-size: .82rem; }
.identity-definition-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; padding: 1.1rem 1.35rem 1.35rem; background: linear-gradient(135deg, #f7fbfd 0%, #f3f9fc 100%); }
.identity-form-title { grid-column: 1 / -1; display: flex; align-items: center; gap: .42rem; color: #173857; font-size: .85rem; }
@@ -349,13 +350,13 @@ onMounted(() => { void load(); });
.identity-definition-form label { display: grid; gap: .35rem; color: #667f99; font-size: .72rem; font-weight: 700; }
.identity-label-with-tip { display: inline-flex; align-items: center; gap: .28rem; }
.identity-label-tip { width: .9rem; height: .9rem; color: #7d93a8; cursor: help; }
.identity-label-tip:focus-visible { border-radius: 50%; outline: 2px solid #7cc7eb; outline-offset: 2px; }
.identity-label-tip:focus-visible { border-radius: 50%; outline: 2px solid #7dd3fc; outline-offset: 2px; }
.identity-definition-form label small { color: #8295a8; font-size: .67rem; font-weight: 500; line-height: 1.35; }
.identity-definition-form .input-field, .identity-static-field { box-sizing: border-box; min-width: 0; height: 2.75rem; padding: 0 .8rem; border-color: #d9e7ef; background: #fff; font-size: .83rem; line-height: 1.25; }
.identity-definition-form select.input-field { padding-top: 0; padding-bottom: 0; line-height: 2.75rem; }
.identity-static-field { display: flex; align-items: center; padding: 0 .8rem; border: 1px solid #d9e7ef; border-radius: .65rem; color: #5f7893; }
.identity-source-help { display: grid; align-content: center; gap: .12rem; min-height: 2.75rem; padding: .48rem .7rem; border: 1px solid #d6eaf5; border-radius: .65rem; background: #edf8fe; color: #537189; font-size: .69rem; line-height: 1.35; }
.identity-source-help strong { color: #187eae; font-size: .72rem; }.identity-source-help small { color: #2e9068; font-size: .68rem; }
.identity-source-help strong { color: #0369a1; font-size: .72rem; }.identity-source-help small { color: #16a34a; font-size: .68rem; }
.identity-definition-form__submit { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; align-self: end; min-height: 2.5rem; }
.identity-panel--publication { position: sticky; top: 1rem; padding: 1.25rem; }
.identity-publication__header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
@@ -363,7 +364,7 @@ onMounted(() => { void load(); });
.identity-publication__hint { margin: .75rem 0 1rem; color: #75899f; font-size: .78rem; line-height: 1.6; }
.identity-version-list { display: flex; flex-wrap: wrap; gap: .5rem; padding-bottom: 1rem; border-bottom: 1px solid #e9f0f4; }
.identity-version { display: inline-flex; align-items: center; gap: .35rem; padding: .46rem .6rem; border: 1px solid #dbe7ee; border-radius: .6rem; background: #fff; color: #668099; font-size: .73rem; transition: all .18s ease; }
.identity-version:hover, .identity-version--selected { border-color: #0b91cd; background: #eefaff; color: #087cae; }
.identity-version:hover, .identity-version--selected { border-color: #0284c7; background: #f0f9ff; color: #0369a1; }
.identity-version span { font-weight: 800; }.identity-version small { font-size: .68rem; }
.identity-selection { margin: 1rem 0; }
.identity-published-definitions { margin: 1rem 0; }
@@ -374,12 +375,13 @@ onMounted(() => { void load(); });
.identity-published-definition small { margin-top: .15rem; color: #8194a8; font-size: .68rem; }
.identity-published-empty { margin: 0; color: #8194a8; font-size: .76rem; }
.identity-selection__heading { display: flex; justify-content: space-between; margin-bottom: .6rem; color: #274563; font-size: .78rem; font-weight: 750; }
.identity-selection__heading strong { color: #0a8bc4; }
.identity-selection__heading strong { color: #0284c7; }
.identity-check-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .54rem 0; border-bottom: 1px dashed #e2ebf1; color: #37516c; font-size: .78rem; }
.identity-check-row input { accent-color: #0c94ce; }.identity-check-row small { color: #8496a8; font-size: .68rem; }
/* @tailwindcss/forms 接管原生 checkbox 后 accent-color 无效:勾选填充取 currentColor,用 color 指定选中蓝 */
.identity-check-row input { color: #0284c7; }.identity-check-row small { color: #8496a8; font-size: .68rem; }
.identity-publication__actions { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; padding-top: 1rem; }
.identity-publication__actions .btn-primary, .identity-publication__actions .btn-ghost { min-width: 0; font-size: .79rem; }
.identity-published { grid-column: 1 / -1; display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: .45rem; padding: .7rem; border-radius: .65rem; background: #eaf9f0; color: #16895e; font-size: .78rem; font-weight: 700; }.identity-published code { overflow: hidden; color: #56826f; font-size: .67rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.identity-published { grid-column: 1 / -1; display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: .45rem; padding: .7rem; border-radius: .65rem; background: #dcfce7; color: #15803d; font-size: .78rem; font-weight: 700; }.identity-published code { overflow: hidden; color: #16a34a; font-size: .67rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 980px) { .identity-workbench { grid-template-columns: 1fr; }.identity-panel--publication { position: static; }.identity-hero { align-items: flex-start; flex-direction: column; gap: .85rem; }.identity-hero__meta { justify-content: flex-start; }.identity-flow__rail { display: none; } }
@media (max-width: 700px) { .identity-rules-page { gap: 1rem; }.identity-flow { grid-template-columns: 1fr; }.identity-definition-form { grid-template-columns: 1fr; }.identity-definition-row { grid-template-columns: auto minmax(0, 1fr); }.identity-target, .identity-automation { justify-self: start; }.identity-panel__heading { align-items: flex-start; flex-direction: column; }.identity-panel__heading > p { text-align: left; }.identity-definition-row__icon { grid-row: span 2; }.identity-publication__actions { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .identity-definition-row, .identity-version { transition: none; } }
@@ -146,8 +146,8 @@
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
<input class="input-field" :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
<label class="inline-check"><input v-model="parameter.required" type="checkbox">{{ t('admin.shippingInventory.required') }}</label>
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
<label class="inline-check"><input v-model="parameter.required" type="checkbox" class="admin-checkbox">{{ t('admin.shippingInventory.required') }}</label>
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox" class="admin-checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
<button type="button" class="btn-danger btn-sm" @click="source.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
</div>
<button type="button" class="btn-secondary btn-sm full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
@@ -172,8 +172,8 @@
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
<input class="input-field" :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
<label class="inline-check"><input v-model="parameter.required" type="checkbox">{{ t('admin.shippingInventory.required') }}</label>
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
<label class="inline-check"><input v-model="parameter.required" type="checkbox" class="admin-checkbox">{{ t('admin.shippingInventory.required') }}</label>
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox" class="admin-checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
<button type="button" class="btn-danger btn-sm" @click="receiptConfig.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
</div>
<button type="button" class="btn-secondary btn-sm full" @click="addReceiptParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
@@ -356,7 +356,8 @@
<div class="switch-field"><span>{{ t('admin.shippingInventory.enabled') }}</span><button type="button" class="status-switch" :class="{ on: mapping.enabled }" role="switch" :aria-checked="mapping.enabled" @click="mapping.enabled = !mapping.enabled"><i></i><b>{{ mapping.enabled ? t('admin.shippingInventory.enabledState') : t('admin.shippingInventory.disabledState') }}</b></button></div>
</template>
<div v-if="isEditableTab" class="form-actions full">
</form>
<div v-if="isEditableTab" class="form-actions">
<div
v-if="activeTab === 'sources' && selectedId"
class="source-enabled-footer"
@@ -385,7 +386,7 @@
}}</small>
</div>
<div class="form-actions-buttons">
<button v-if="!parsingReadOnly" type="submit" class="btn-primary" :disabled="saving || ruleReadOnly || templateReadOnly || inventoryFieldReadOnly">{{ saving ? t('admin.shippingInventory.saving') : t('admin.save') }}</button>
<button v-if="!parsingReadOnly" type="button" class="btn-primary" :disabled="saving || ruleReadOnly || templateReadOnly || inventoryFieldReadOnly" @click="saveCurrent">{{ saving ? t('admin.shippingInventory.saving') : t('admin.save') }}</button>
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'draft'" type="button" class="btn-secondary btn-sm" @click="publishCurrentRule">{{ t('admin.shippingInventory.publish') }}</button>
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'published'" type="button" class="btn-secondary btn-sm" @click="retireCurrentRule">{{ t('admin.shippingInventory.retire') }}</button>
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus === 'draft'" type="button" class="btn-secondary btn-sm" @click="publishCurrentTemplate">{{ t('admin.shippingInventory.publishTemplate') }}</button>
@@ -399,7 +400,6 @@
<button type="button" class="btn-ghost btn-sm" @click="closeDrawer">{{ t('admin.cancel') }}</button>
</div>
</div>
</form>
</aside>
</div>
</div>
@@ -1653,23 +1653,28 @@ onMounted(load);
.row-secondary { color: #94a3b8; font-size: 11px; }
.status-dot { position: absolute; top: 18px; right: 12px; width: 7px; height: 7px; border-radius: 50%; }
.status-dot.on { background: #22c55e; }
.status-dot.off { background: #b2bdc9; }
.status-dot.off { background: #94a3b8; }
.drawer-mask { position: fixed; z-index: 40; inset: 0; display: flex; justify-content: flex-end; background: var(--overlay-soft); }
.workbench-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.clone-template-mask { z-index: 80; align-items: center; justify-content: center; padding: 20px; }
.clone-template-dialog { width: min(480px, 100%); border-radius: 10px; background: #fff; box-shadow: 0 18px 48px rgb(15 23 42 / 25%); }
.clone-template-header { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e2e8f0; padding: 18px 20px; }.clone-template-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }.clone-template-header p { margin: 5px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
.clone-template-form { display: grid; gap: 14px; padding: 20px; }.clone-template-form label { display: grid; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }.clone-template-form .input-field { min-width: 0; padding: 8px 9px; font: inherit; font-size: 13px; }.clone-template-form small { color: #94a3b8; font-size: 11px; line-height: 1.45; }.clone-template-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #edf2f7; padding-top: 14px; }
.batch-validation-dialog { display: grid; width: min(780px, 100%); max-height: min(720px, calc(100vh - 40px)); grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 20px 56px rgb(15 23 42 / 28%); }.batch-selection, .batch-progress { display: grid; min-height: 0; gap: 14px; padding: 18px 20px; }.batch-selection { grid-template-rows: auto minmax(0, 1fr) auto; }.batch-selection-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 14px; }.batch-selection-toolbar label { display: grid; flex: 1; gap: 5px; color: #62788a; font-size: 11px; font-weight: 700; }.batch-selection-toolbar .input-field { min-width: 0; padding: 8px 9px; font: inherit; font-size: 13px; }.batch-selection-actions { display: flex; align-items: center; gap: 8px; }.batch-selection-actions > b { flex: 0 0 auto; border-radius: 999px; background: #e9f7fd; padding: 6px 9px; color: #13759d; font-size: 11px; white-space: nowrap; }.batch-selection-actions .btn-ghost { padding: 6px 8px; white-space: nowrap; }.batch-source-list, .batch-run-list { min-height: 0; overflow-y: auto; border: 1px solid #dce8ef; border-radius: 8px; background: #fbfdfe; }.batch-source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 1px; background: #e3edf3; }.batch-source-option { display: flex; min-width: 0; align-items: flex-start; gap: 9px; background: #fff; padding: 10px 11px; cursor: pointer; }.batch-source-option:hover { background: #f4fbfe; }.batch-source-option input { margin: 3px 0 0; accent-color: #168ebc; }.batch-source-option span { display: grid; min-width: 0; gap: 3px; }.batch-source-option b { overflow: hidden; color: #344b60; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.batch-source-option small { overflow: hidden; color: #8a9aab; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-empty { grid-column: 1 / -1; margin: 0; padding: 28px 12px; color: #8797a7; font-size: 12px; text-align: center; }.batch-progress { grid-template-rows: auto auto auto minmax(0, 1fr) auto; }.batch-progress-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }.batch-progress-heading > div { display: grid; gap: 3px; }.batch-progress-heading span { color: #16759f; font-size: 11px; font-weight: 800; }.batch-progress-heading strong { color: #334c60; font-size: 13px; }.batch-progress-heading > b { color: #1c6f96; font-size: 18px; font-variant-numeric: tabular-nums; }.batch-progress-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #e8f0f5; }.batch-progress-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22a1c7, #4bb8d7); transition: width .25s ease; }.batch-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }.batch-stat-grid button { display: grid; gap: 2px; border: 1px solid #e0eaf0; border-radius: 7px; background: #fff; padding: 8px; color: #708393; font: inherit; text-align: left; cursor: pointer; }.batch-stat-grid button:hover, .batch-stat-grid button.active { border-color: #8fd0e7; background: #eef9fd; }.batch-stat-grid b { color: #314b60; font-size: 16px; font-variant-numeric: tabular-nums; }.batch-stat-grid span { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-run-list { display: grid; align-content: start; }.batch-run { display: grid; grid-template-columns: 9px minmax(0, 1fr) minmax(0, .9fr); align-items: center; gap: 9px; border-bottom: 1px solid #e8eff3; padding: 9px 11px; }.batch-run:last-child { border-bottom: 0; }.batch-run-marker { width: 7px; height: 7px; border-radius: 50%; background: #a9b8c5; }.batch-run > div { display: grid; min-width: 0; gap: 2px; }.batch-run b, .batch-run small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.batch-run b { color: #385166; font-size: 12px; }.batch-run > div small { color: #8a9baa; font-size: 10px; }.batch-run-error { color: #ae493b; font-size: 10px; }.batch-run.is-completed .batch-run-marker { background: #32a665; }.batch-run.is-completed_empty .batch-run-marker { background: #e7a628; }.batch-run.is-failed .batch-run-marker { background: #db6552; }
.editor-drawer { width: min(760px, 100vw); height: 100%; overflow-y: auto; border-left: 1px solid var(--border-default); background: var(--bg-surface); box-shadow: -12px 0 32px rgb(15 23 42 / 18%); }
.drawer-header { position: sticky; z-index: 1; top: 0; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border-default); background: var(--bg-surface); padding: 18px 20px; }
.drawer-title-row { display: flex; align-items: center; gap: 9px; }.drawer-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }.source-run-status { flex: 0 0 auto; border: 1px solid #f2d3cd; border-radius: 999px; background: #fff4f1; padding: 3px 7px; color: #a53f30; font-size: 11px; font-weight: 700; }.source-run-status.enabled { border-color: #c7e7d0; background: #eefaf1; color: #247442; }
.batch-validation-dialog { display: grid; width: min(780px, 100%); max-height: min(720px, calc(100vh - 40px)); grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 20px 56px rgb(15 23 42 / 28%); }.batch-selection, .batch-progress { display: grid; min-height: 0; gap: 14px; padding: 18px 20px; }.batch-selection { grid-template-rows: auto minmax(0, 1fr) auto; }.batch-selection-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 14px; }.batch-selection-toolbar label { display: grid; flex: 1; gap: 5px; color: #62788a; font-size: 11px; font-weight: 700; }.batch-selection-toolbar .input-field { min-width: 0; padding: 8px 9px; font: inherit; font-size: 13px; }.batch-selection-actions { display: flex; align-items: center; gap: 8px; }.batch-selection-actions > b { flex: 0 0 auto; border-radius: 999px; background: #e9f7fd; padding: 6px 9px; color: #13759d; font-size: 11px; white-space: nowrap; }.batch-selection-actions .btn-ghost { padding: 6px 8px; white-space: nowrap; }.batch-source-list, .batch-run-list { min-height: 0; overflow-y: auto; border: 1px solid #dce8ef; border-radius: 8px; background: #fbfdfe; }.batch-source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 1px; background: #e3edf3; }.batch-source-option { display: flex; min-width: 0; align-items: flex-start; gap: 9px; background: #fff; padding: 10px 11px; cursor: pointer; }.batch-source-option:hover { background: #f4fbfe; }/* accent-color 在 @tailwindcss/forms 接管的原生 checkbox 上无效:勾选填充取 currentColor,用 color 指定选中蓝色 */
.batch-source-option input { margin: 3px 0 0; color: #168ebc; }.batch-source-option span { display: grid; min-width: 0; gap: 3px; }.batch-source-option b { overflow: hidden; color: #344b60; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.batch-source-option small { overflow: hidden; color: #8a9aab; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-empty { grid-column: 1 / -1; margin: 0; padding: 28px 12px; color: #8797a7; font-size: 12px; text-align: center; }.batch-progress { grid-template-rows: auto auto auto minmax(0, 1fr) auto; }.batch-progress-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }.batch-progress-heading > div { display: grid; gap: 3px; }.batch-progress-heading span { color: #16759f; font-size: 11px; font-weight: 800; }.batch-progress-heading strong { color: #334c60; font-size: 13px; }.batch-progress-heading > b { color: #1c6f96; font-size: 18px; font-variant-numeric: tabular-nums; }.batch-progress-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #e8f0f5; }.batch-progress-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22a1c7, #4bb8d7); transition: width .25s ease; }.batch-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }.batch-stat-grid button { display: grid; gap: 2px; border: 1px solid #e0eaf0; border-radius: 7px; background: #fff; padding: 8px; color: #708393; font: inherit; text-align: left; cursor: pointer; }.batch-stat-grid button:hover, .batch-stat-grid button.active { border-color: #8fd0e7; background: #eef9fd; }.batch-stat-grid b { color: #314b60; font-size: 16px; font-variant-numeric: tabular-nums; }.batch-stat-grid span { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-run-list { display: grid; align-content: start; }.batch-run { display: grid; grid-template-columns: 9px minmax(0, 1fr) minmax(0, .9fr); align-items: center; gap: 9px; border-bottom: 1px solid #e8eff3; padding: 9px 11px; }.batch-run:last-child { border-bottom: 0; }.batch-run-marker { width: 7px; height: 7px; border-radius: 50%; background: #a9b8c5; }.batch-run > div { display: grid; min-width: 0; gap: 2px; }.batch-run b, .batch-run small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.batch-run b { color: #385166; font-size: 12px; }.batch-run > div small { color: #8a9baa; font-size: 10px; }.batch-run-error { color: #ae493b; font-size: 10px; }.batch-run.is-completed .batch-run-marker { background: #32a665; }.batch-run.is-completed_empty .batch-run-marker { background: #e7a628; }.batch-run.is-failed .batch-run-marker { background: #db6552; }
/* 抽屉为 flex 三段式:头部/底部操作栏固定,.editor-form 独占剩余高度并内部滚动,操作栏位置不受内容增减影响 */
.editor-drawer { display: flex; flex-direction: column; width: min(760px, 100vw); height: 100%; overflow: hidden; border-left: 1px solid var(--border-default); background: var(--bg-surface); box-shadow: -12px 0 32px rgb(15 23 42 / 18%); }
.drawer-header { flex: 0 0 auto; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border-default); background: var(--bg-surface); padding: 18px 20px; }
/* 状态徽标统一 Tailwind 标准语义色:未启用=rose(与 components-ds 危险态一致)、启用=green(与 .status-switch 一致),不再用自造色值 */
.drawer-title-row { display: flex; align-items: center; gap: 9px; }.drawer-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }.source-run-status { flex: 0 0 auto; border: 1px solid #fecdd3; border-radius: 999px; background: #fff1f2; padding: 3px 7px; color: #be123c; font-size: 11px; font-weight: 700; }.source-run-status.enabled { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
.drawer-header p { margin: 5px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
.drawer-close { width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: #64748b; font-size: 24px; line-height: 1; cursor: pointer; }
.drawer-close:hover { background: #f1f5f9; color: #334155; }
.editor-form { display: grid; align-content: start; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 20px; }
/* grid-auto-rows 必须 max-content:本表单是受限高度的滚动网格,Chrome 会把包含 overflow:hidden 子项(.path-card)的隐式 auto 行压缩到远小于内容的高度,裁掉查询条件/按钮;显式 max-content 强制行高按内容 sizing */
.editor-form { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-auto-rows: max-content; align-content: start; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 20px; }
.editor-form label { display: flex; flex-direction: column; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }
.editor-form input, .editor-form select { min-width: 0; border: 1px solid var(--border-default); border-radius: 6px; background: var(--bg-surface); padding: 8px 9px; color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 400; }
/* checkbox/radio 必须排除:此处的 color 与 background 简写优先级更高,会覆盖 @tailwindcss/forms 的 :checked 样式(填充取 currentColor + 白色对钩背景图),导致勾选态与未勾选态渲染完全一致、无法分辨 */
.editor-form input:not([type='checkbox']):not([type='radio']), .editor-form select { min-width: 0; border: 1px solid var(--border-default); border-radius: 6px; background: var(--bg-surface); padding: 8px 9px; color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 400; }
.editor-form small { color: #94a3b8; font-size: 11px; font-weight: 400; line-height: 1.45; }
.inventory-mapping-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid #e2e8f0; }
.inventory-mapping-tabs button { border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 8px 12px; color: #64748b; font: inherit; font-size: 13px; cursor: pointer; }
@@ -1698,7 +1703,7 @@ onMounted(load);
.path-card { display: grid; grid-column: 1 / -1; border: 1px solid #dbe8ee; border-radius: 10px; background: #fff; overflow: hidden; }
.path-card-header { display: flex; align-items: center; gap: 10px; border: 0; background: #f7fbfd; padding: 10px 12px; cursor: pointer; font: inherit; text-align: left; }.path-card-header:hover { background: #eff7fa; }
.path-card-title { display: grid; flex: 1 1 auto; min-width: 0; gap: 2px; }.path-card-title b { color: #145f5a; font-size: 12px; font-weight: 800; }.path-card-title small { color: #94a3b8; font-size: 11px; font-weight: 400; }
.path-badge { flex: 0 0 auto; border-radius: 999px; background: #eef2f5; padding: 3px 8px; color: #7b8998; font-size: 11px; font-weight: 700; }.path-card.configured .path-badge.on { background: #e6f6ec; color: #19703a; }
.path-badge { flex: 0 0 auto; border-radius: 999px; background: #f1f5f9; padding: 3px 8px; color: #64748b; font-size: 11px; font-weight: 700; }.path-card.configured .path-badge.on { background: #dcfce7; color: #15803d; }
.path-card-toggle { flex: 0 0 auto; color: #4d849f; font-size: 14px; line-height: 1; }
.path-card-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; border-top: 1px solid #e6eef4; padding: 14px 12px; }.path-card-body .full { grid-column: 1 / -1; }
.condition-row, .mapping-row, .template-mapping { display: grid; align-items: center; gap: 8px; border-radius: 8px; background: #f8fafc; padding: 9px; }
@@ -1727,7 +1732,8 @@ onMounted(load);
.condition-empty { color: #8190a0; font-size: 12px; }
.inline-check { flex-direction: row !important; align-items: center; gap: 4px !important; white-space: nowrap; font-size: 11px !important; }
.switch-field { display: flex; flex-direction: column; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }.status-switch { display: inline-flex; width: fit-content; align-items: center; gap: 7px; border: 0; background: transparent; padding: 2px 0; color: #94a3b8; font: inherit; font-size: 12px; cursor: pointer; }.status-switch i { position: relative; width: 34px; height: 20px; border-radius: 999px; background: #cbd5e1; transition: background .18s; }.status-switch i::after { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 25%); content: ''; transition: transform .18s; }.status-switch.on { color: #15803d; }.status-switch.on i { background: #22c55e; }.status-switch.on i::after { transform: translateX(14px); }.status-switch b { font-weight: 500; }
.form-actions { position: sticky; z-index: 2; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; grid-column: 1 / -1; margin: 6px -20px -20px; border-top: 1px solid #dce6ef; background: rgb(255 255 255 / 96%); box-shadow: 0 -8px 18px rgb(15 23 42 / 7%); padding: 14px 20px; backdrop-filter: blur(8px); }
/* 底部操作栏是抽屉 flex 布局的独立层级:固定在抽屉底部,不随表单内容滚动/折叠区展开移动。模板中该栏位于 </form> 之后(不在 form 内),保存按钮为 type=button 显式 click 调用 saveCurrent,输入框回车提交仍走 form @submit */
.form-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border-default); background: rgb(255 255 255 / 96%); box-shadow: 0 -8px 18px rgb(15 23 42 / 7%); padding: 14px 20px; backdrop-filter: blur(8px); }
.source-enabled-footer { display: flex; margin-right: auto; min-width: 0; align-items: center; gap: 10px; }
.source-enabled-label { flex: 0 0 auto; color: #475569; font-size: 13px; font-weight: 600; }
.source-enabled-hint { overflow: hidden; color: #94a3b8; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
@@ -1741,7 +1747,7 @@ onMounted(load);
.audit-table td strong, .audit-table td small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.audit-table td strong { color: #263850; font-weight: 600; }.audit-table td small { margin-top: 4px; color: #94a3b8; }
.audit-cell { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-status { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 11px; white-space: nowrap; }.audit-status.ready { background: #dcfce7; color: #15803d; }.audit-status.failed { background: #fef2f2; color: #b91c1c; }.audit-status.neutral { background: #f1f5f9; color: #64748b; }
.audit-detail dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 0; margin: 0; padding: 18px 20px; }.audit-detail dt, .audit-detail dd { margin: 0; padding: 11px 0; border-bottom: 1px solid #edf2f7; font-size: 13px; }.audit-detail dt { color: #64748b; }.audit-detail dd { overflow-wrap: anywhere; color: #334155; }
.audit-detail dl { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-auto-rows: max-content; grid-template-columns: 130px minmax(0, 1fr); gap: 0; margin: 0; padding: 18px 20px; }.audit-detail dt, .audit-detail dd { margin: 0; padding: 11px 0; border-bottom: 1px solid #edf2f7; font-size: 13px; }.audit-detail dt { color: #64748b; }.audit-detail dd { overflow-wrap: anywhere; color: #334155; }
.object-list .empty-state { grid-column: 1 / -1; display: grid; min-height: 260px; place-items: center; }
.empty-state { border: 1px dashed #c9d7e5; border-radius: 10px; background: #f9fbfd; padding: 38px 18px; color: #7b899a; font-size: 13px; text-align: center; }
@media (max-width: 980px) { .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card { grid-template-columns: 1fr 1fr; } .mapping-value-row { grid-template-columns: minmax(0, 1.6fr) minmax(180px, 1fr); }.readiness-audit { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@@ -206,8 +206,8 @@ onBeforeUnmount(stopSampleRefresh);
.wizard-page { min-height: 100%; padding: 24px; background: #f6f8fc; }
.wizard-shell { width: 100%; }
.wizard-heading { margin-bottom: 28px; }.wizard-heading h1, .wizard-heading p { margin: 0; }
.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0 0 18px; padding: 0; list-style: none; }.stepper li { display: flex; align-items: center; gap: 10px; color: #94a3b8; font-size: .86rem; font-weight: 650; }.stepper li:not(:last-child)::after { width: 100%; height: 1px; margin-left: 10px; background: #dbe4f0; content: ''; }.stepper li.active { color: #1677d2; }.stepper li.complete { color: #0f8a65; }.stepper-icon { display: inline-grid; flex: 0 0 auto; width: 32px; height: 32px; place-items: center; border: 1px solid currentColor; border-radius: 50%; background: #fff; }.stepper .complete .stepper-icon { color: #fff; border-color: #0f8a65; background: #0f8a65; }.stepper small { display: block; margin-bottom: 1px; color: #94a3b8; font-size: .68rem; font-weight: 700; text-transform: uppercase; }
.wizard-card { min-height: 360px; padding: clamp(24px, 4vw, 44px); border: 1px solid #e1e8f2; border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgb(15 23 42 / .06); }.wizard-card__heading { margin-bottom: 28px; padding-bottom: 18px; border-bottom: 1px solid #edf1f7; }.wizard-card__heading span { color: #1677d2; font-size: .76rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }.wizard-card__heading h2 { margin: 6px 0 0; color: #1e293b; font-size: 1.25rem; }
.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0 0 18px; padding: 0; list-style: none; }.stepper li { display: flex; align-items: center; gap: 10px; color: #94a3b8; font-size: .86rem; font-weight: 650; }.stepper li:not(:last-child)::after { width: 100%; height: 1px; margin-left: 10px; background: #dbe4f0; content: ''; }/* 步骤状态色统一 Tailwind 标准值:激活=brand-600、完成=green-600 */.stepper li.active { color: #0284c7; }.stepper li.complete { color: #16a34a; }.stepper-icon { display: inline-grid; flex: 0 0 auto; width: 32px; height: 32px; place-items: center; border: 1px solid currentColor; border-radius: 50%; background: #fff; }.stepper .complete .stepper-icon { color: #fff; border-color: #16a34a; background: #16a34a; }.stepper small { display: block; margin-bottom: 1px; color: #94a3b8; font-size: .68rem; font-weight: 700; text-transform: uppercase; }
.wizard-card { min-height: 360px; padding: clamp(24px, 4vw, 44px); border: 1px solid #e1e8f2; border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgb(15 23 42 / .06); }.wizard-card__heading { margin-bottom: 28px; padding-bottom: 18px; border-bottom: 1px solid #edf1f7; }.wizard-card__heading span { color: #0284c7; font-size: .76rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }.wizard-card__heading h2 { margin: 6px 0 0; color: #1e293b; font-size: 1.25rem; }
.wizard-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }.wizard-actions__spacer { flex: 1; }
@media (max-width: 640px) { .wizard-page { padding: 24px 16px; }.stepper { grid-template-columns: 1fr; gap: 10px; }.stepper li:not(:last-child)::after { display: none; }.wizard-card { min-height: 300px; border-radius: 14px; }.wizard-actions { flex-wrap: wrap; }.wizard-actions__spacer { display: none; }.btn-secondary:first-child { margin-right: auto; } }
</style>
@@ -353,7 +353,7 @@ ul { margin: 8px 0; padding-left: 20px; color: #b91c1c; font-size: 13px; }
.metrics div { display: grid; gap: 4px; }
.metrics dt { color: #64748b; font-size: 12px; }
.metrics dd { margin: 0; color: #1e293b; font-size: 14px; font-weight: 600; }
.conflict-card { border: 1px solid #fecaca; background: #fff7f7; border-radius: 8px; padding: 12px; margin-top: 10px; }
.conflict-card { border: 1px solid #fecaca; background: #fef2f2; border-radius: 8px; padding: 12px; margin-top: 10px; }
.conflict-card strong { color: #991b1b; font-size: 13px; }
.conflict-card .reasons { color: #b45309; font-size: 12px; }
@media (max-width: 767px) {
@@ -688,8 +688,9 @@ watch(
}
.migration-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 1rem; background: rgb(15 23 42 / 45%); }
.migration-dialog { display: grid; width: min(100%, 42rem); max-height: min(44rem, calc(100vh - 2rem)); gap: 1rem; overflow: auto; padding: 1.5rem; border-radius: 1rem; background: var(--bg-surface); box-shadow: 0 20px 40px rgb(15 23 42 / 25%); }
.migration-dialog h2,.migration-dialog p { margin: 0; }.migration-note { color: var(--text-muted); font-size: .875rem; }.migration-changes { display: grid; gap: .75rem; }.migration-changes article { display: grid; gap: .45rem; padding: .85rem; border: 1px solid var(--border-default); border-radius: .75rem; }.migration-changes span { color: var(--text-muted); font-size: .8125rem; }.migration-changes label { display: grid; gap: .3rem; color: var(--text-secondary); font-size: .8125rem; font-weight: 600; }.migration-changes select { min-height: 2.25rem; border: 1px solid var(--border-default); border-radius: .5rem; background: var(--bg-surface); color: var(--text-primary); font: inherit; }.migration-dialog footer { display: flex; justify-content: flex-end; gap: .5rem; }
.migration-dialog { display: grid; grid-auto-rows: max-content; width: min(100%, 42rem); max-height: min(44rem, calc(100vh - 2rem)); gap: 1rem; overflow-y: auto; padding: 1.5rem; border-radius: 1rem; background: var(--bg-surface); box-shadow: 0 20px 40px rgb(15 23 42 / 25%); }
.migration-dialog h2,.migration-dialog p { margin: 0; }.migration-note { color: var(--text-muted); font-size: .875rem; }.migration-changes { display: grid; gap: .75rem; }.migration-changes article { display: grid; gap: .45rem; padding: .85rem; border: 1px solid var(--border-default); border-radius: .75rem; }.migration-changes span { color: var(--text-muted); font-size: .8125rem; }.migration-changes label { display: grid; gap: .3rem; color: var(--text-secondary); font-size: .8125rem; font-weight: 600; }.migration-changes select { min-height: 2.25rem; border: 1px solid var(--border-default); border-radius: .5rem; background: var(--bg-surface); color: var(--text-primary); font: inherit; }/* footer 用 sticky 钉在对话框可视底部:breaking changes 列表长时取消/确认迁移按钮始终可见,不需滚回底部 */
.migration-dialog footer { position: sticky; bottom: -1.5rem; display: flex; justify-content: flex-end; gap: .5rem; margin: 0 -1.5rem -1.5rem; border-top: 1px solid var(--border-default); background: var(--bg-surface); padding: 1rem 1.5rem 1.25rem; }
@media (max-width: 960px) {
.header-main,
@@ -127,5 +127,5 @@ onBeforeUnmount(stopPolling);
</template>
<style scoped>
.sample-step { display: grid; gap: 18px; max-width: 640px; }.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); }.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: var(--bg-surface-soft); }.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: var(--status-info-fg); background: var(--status-info-bg); }.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }.upload-panel h3,.reuse-panel h3 { color: var(--text-primary); font-size: 1rem; }.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: var(--text-muted); font-size: .84rem; }.upload-action { display: inline-flex; min-height: 38px; align-items: center; border-radius: 8px; padding: 0 13px; color: #fff; background: #1677d2; font-weight: 700; cursor: pointer; }.upload-action input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: var(--status-info-fg); background: var(--status-info-bg); }.parse-status strong,.selected-sample strong { display: block; color: var(--text-primary); }.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: var(--text-muted); font-size: .83rem; }.refresh-status { margin-top: 6px; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; text-decoration: underline; }.parse-status.failed { color: var(--status-error-fg); border-color: var(--status-error-border); background: var(--status-error-bg); }.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: var(--status-error-fg); font-weight: 800; }.selected-sample { color: var(--status-success-fg); border-color: var(--status-success-border); background: var(--status-success-bg); }.reuse-panel { padding: 18px; }.reuse-panel__heading { margin-bottom: 14px; }.field { display: grid; gap: 7px; color: var(--text-secondary); font-size: .88rem; font-weight: 700; }.field .select-field { min-height: 44px; font: inherit; } @media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
.sample-step { display: grid; gap: 18px; max-width: 640px; }.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); }.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: var(--bg-surface-soft); }.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: var(--status-info-fg); background: var(--status-info-bg); }.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }.upload-panel h3,.reuse-panel h3 { color: var(--text-primary); font-size: 1rem; }.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: var(--text-muted); font-size: .84rem; }.upload-action { display: inline-flex; min-height: 38px; align-items: center; border-radius: 8px; padding: 0 13px; color: #fff; background: #0284c7; font-weight: 700; cursor: pointer; }.upload-action input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: var(--status-info-fg); background: var(--status-info-bg); }.parse-status strong,.selected-sample strong { display: block; color: var(--text-primary); }.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: var(--text-muted); font-size: .83rem; }.refresh-status { margin-top: 6px; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; text-decoration: underline; }.parse-status.failed { color: var(--status-error-fg); border-color: var(--status-error-border); background: var(--status-error-bg); }.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: var(--status-error-fg); font-weight: 800; }.selected-sample { color: var(--status-success-fg); border-color: var(--status-success-border); background: var(--status-success-bg); }.reuse-panel { padding: 18px; }.reuse-panel__heading { margin-bottom: 14px; }.field { display: grid; gap: 7px; color: var(--text-secondary); font-size: .88rem; font-weight: 700; }.field .select-field { min-height: 44px; font: inherit; } @media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
</style>
@@ -1419,8 +1419,10 @@ onMounted(async () => {
<style scoped>
.compact-button { padding: 6px 10px; font-size: 12px; }
.impact-overlay { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; background: var(--overlay-soft); padding: 24px; }
.impact-dialog { display: grid; width: min(720px, 96vw); max-height: 82vh; gap: 14px; overflow: hidden; border-radius: 12px; background: var(--bg-surface); padding: 18px; box-shadow: 0 24px 64px rgb(15 23 42 / .24); }
.impact-dialog { display: grid; grid-auto-rows: max-content; width: min(720px, 96vw); max-height: 82vh; gap: 14px; overflow-y: auto; border-radius: 12px; background: var(--bg-surface); padding: 18px; box-shadow: 0 24px 64px rgb(15 23 42 / .24); }
.impact-dialog header, .impact-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* footer 用 sticky 钉在对话框可视底部:发布影响列表等长内容滚动时,确认/取消按钮始终可见(原 overflow:hidden 会把 footer 整条裁掉) */
.impact-dialog footer { position: sticky; bottom: -18px; margin: 4px -18px -18px; border-top: 1px solid var(--border-default); background: var(--bg-surface); padding: 12px 18px; }
.impact-dialog h2, .impact-dialog p { margin: 0; }
.impact-list { display: grid; gap: 8px; overflow: auto; }
.impact-list article { border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; }
@@ -236,3 +236,27 @@ export const retryTransferSourceRpa = (sourceCode: string) =>
method: 'POST',
headers: jsonHeaders(),
});
/** 批量来源重试响应:triggered=是否写了 batch trigger;results 逐来源真实结果 */
export interface TransferRetryRpaBatchResult {
ok: boolean;
triggered: boolean;
trigger_path?: string;
error_code?: string;
results: Array<{
source_code: string;
ok: boolean;
reparsed?: boolean;
file_status?: string;
error_code?: string;
}>;
}
/** 批量重试(2026-10-09):多来源合并写一个 batch trigger 文件,
* Worker 单次浏览器会话串行导出全部来源(逐来源单文件会开/关 N 次浏览器) */
export const retryTransferSourcesRpaBatch = (sourceCodes: string[]) =>
requestJson<TransferRetryRpaBatchResult>(`${BASE}/sources/retry-rpa-batch`, {
method: 'POST',
headers: jsonHeaders(),
body: JSON.stringify({ source_codes: sourceCodes }),
});
@@ -4,12 +4,12 @@
* 用途:对话页主区域,组合侧栏、消息列表、输入栏、货代会话 Workflow 时间线与内置浏览器。
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingWorkflowTimeline、ContractPaymentChatPanel、VoucherCheckChatPanel、chunkLoadRecovery、chat.context。
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingWorkflowTimeline、ContractPaymentChatPanel、EquipmentAcceptanceChatPanel、VoucherCheckChatPanel、chunkLoadRecovery、chat.context。
* 逻辑:本文件只做页面结构编排;货代 Chat 仅上传/进度通知,履约写操作不在本页;
* 货代会话主区域:有会话即全屏批次进度中心(常驻),无会话为欢迎页+输入框;会话标题取自侧栏历史并传给中心;
* 右侧「本次处理」由 conversationId 驱动 Workflow projection,extractionRunNo 仅作进度装饰;
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js;合同付款预警、立账凭证 Agent 用 Tab 作业面替换消息列表与输入框。
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js;合同付款预警、设备验收预警、立账凭证 Agent 用作业面替换消息列表与输入框。
*/
@@ -47,7 +47,7 @@ import { useChatPageContext } from '@/features/chat/composables/chat.context';
import { matchesTrainingAgent } from '@/features/chat/training/trainingWorkspace.utils';
import { agentHasIntentUiProfile, resolveAgentCode, AGENT_CODE_IN_TRANSIT_TRANSFER, isContractPaymentAgent, isVoucherCheckAgent } from '@/shared/utils/agent-registry.utils';
import { agentHasIntentUiProfile, resolveAgentCode, AGENT_CODE_IN_TRANSIT_TRANSFER, isContractPaymentAgent, isEquipmentAcceptanceAgent, isVoucherCheckAgent } from '@/shared/utils/agent-registry.utils';
import {
SHIPPING_WORKFLOW_KEY,
@@ -79,6 +79,10 @@ const ContractPaymentChatPanel = defineRecoverableAsyncComponent(
() => import('@/features/contract-payment/components/ContractPaymentChatPanel.vue'),
);
const EquipmentAcceptanceChatPanel = defineRecoverableAsyncComponent(
() => import('@/features/equipment-acceptance/components/EquipmentAcceptanceChatPanel.vue'),
);
const VoucherCheckChatPanel = defineRecoverableAsyncComponent(
() => import('@/features/voucher-check/components/VoucherCheckChatPanel.vue'),
);
@@ -130,11 +134,14 @@ const isInTransitTransferAgent = computed(() => resolveAgentCode(page.currentAge
/** 合同付款预警 Agent:主区嵌台账 Tab,隐藏对话输入与历史。 */
const isContractPaymentAgentPage = computed(() => isContractPaymentAgent(page.currentAgent));
/** 设备验收预警 Agent:主区嵌停留列表,隐藏对话输入与历史。 */
const isEquipmentAcceptanceAgentPage = computed(() => isEquipmentAcceptanceAgent(page.currentAgent));
/** 立账凭证 Agent:主区嵌检核任务 / 企微发送记录 Tab,隐藏对话输入与历史。 */
const isVoucherCheckAgentPage = computed(() => isVoucherCheckAgent(page.currentAgent));
/** builtin 作业面 Agent 共用:隐藏新会话、历史列表与输入框。 */
const hideTaskChatSessionUi = computed(() => isContractPaymentAgentPage.value || isVoucherCheckAgentPage.value);
const hideTaskChatSessionUi = computed(() => isContractPaymentAgentPage.value || isEquipmentAcceptanceAgentPage.value || isVoucherCheckAgentPage.value);
/** 在途仓自动调拨业务流激活(来源选择/待处理等子视图)时隐藏聊天输入框,模拟业务页。 */
const transferFlowActive = ref(false);
@@ -489,6 +496,8 @@ watch(() => page.currentAgentId, () => {
<ContractPaymentChatPanel v-else-if="isContractPaymentAgentPage" />
<EquipmentAcceptanceChatPanel v-else-if="isEquipmentAcceptanceAgentPage" />
<VoucherCheckChatPanel v-else-if="isVoucherCheckAgentPage" />
<div v-else class="flex min-h-0 min-w-0 flex-1">
@@ -1,12 +1,14 @@
<!--
features/chat/components/messages/TransferBacklogSummaryCard.vue
用途:待处理异常卡(可恢复/已关闭/结果未知三组)——列与匹配窗口一致,
支持关键字/结果筛选、多选批量操作(重查/恢复处理/标记无需处理)与行级快捷操作。
支持关键字/结果筛选、多选批量操作(重查/恢复/关闭)与行级快捷操作。
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo、transferFormat.formatQuantity。
逻辑:仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
可恢复行按 result_code 细分徽标(blocked_file_removed=文件已移除);
blocked_file_removed 行行内仅留「标记无需继续处理」(重查不可恢复——消失证据
blocked_file_removed 行行内仅留「关闭」(重查不可恢复——消失证据
无法由重查翻回,唯一出口=人工关闭或等文件重新同步);
批量按钮与行内按钮同用短文案键(重查/恢复/关闭,2026-10-12 文案一致化,
完整语义经 title 悬浮),勾选计数保留;
勾选集合为卡片本地态,操作经 emit 交父组件调用批量端点并刷新。
-->
<script setup lang="ts">
@@ -157,18 +159,22 @@ function resultLabelKey(item: TransferBacklogItem): string {
class="rounded-lg border border-brand-200 bg-brand-50 px-3 py-1 text-xs font-bold text-brand-700 transition hover:bg-brand-100 disabled:cursor-not-allowed disabled:opacity-40"
data-testid="transfer-backlog-batch-resume"
:disabled="busy"
:title="$t('chat.transfer.resumeAction')"
@click="emit('resume', selectedActionableIds)"
>
{{ $t('chat.transfer.resumeAction') }}({{ selectedActionableIds.length }})
<!-- [2026-10-12 文案一致化] 批量按钮与行内按钮同用短文案键(恢复/关闭),
勾选计数保留;完整语义经 title 悬浮透出(与行内按钮同模式) -->
{{ $t('chat.transfer.resumeActionShort') }}({{ selectedActionableIds.length }})
</button>
<button
type="button"
class="rounded-lg border border-red-200 bg-red-50 px-3 py-1 text-xs font-bold text-red-600 transition hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-40"
data-testid="transfer-backlog-batch-close"
:disabled="busy"
:title="$t('chat.transfer.manualClose')"
@click="emit('batchClose', selectedActionableIds)"
>
{{ $t('chat.transfer.manualClose') }}({{ selectedActionableIds.length }})
{{ $t('chat.transfer.manualCloseShort') }}({{ selectedActionableIds.length }})
</button>
<button
type="button"
@@ -10,6 +10,7 @@
import { computed, ref } from 'vue';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import { parseApiUtcDate } from '@/shared/utils/dateTime';
import type { TransferMatchingItem } from '../../types/transfer.types';
const props = defineProps<{
@@ -71,10 +72,11 @@ function rowKey(item: TransferMatchingItem): string {
return `${item.item_id ?? 'na'}|${item.invoice_no}`;
}
/** 查询时刻展示(HH:mm);无 checked_at 不渲染。 */
/** 查询时刻展示(HH:mm);后端 naive ISO 按 UTC 解析后转浏览器本地时区
* (仓库约定 parseApiUtcDate,2026-09-29 修复 UTC+8 展示异常);无 checked_at 不渲染。 */
function checkedTime(item: TransferMatchingItem): string {
if (!item.checked_at) return '';
const date = new Date(item.checked_at);
const date = parseApiUtcDate(item.checked_at);
return Number.isNaN(date.getTime()) ? '' : date.toTimeString().slice(0, 5);
}
</script>
@@ -10,7 +10,7 @@ import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import i18n from '@/i18n';
import TransferMatchCard from './TransferMatchCard.vue';
import type { TransferMatchingSummary, TransferSourceProgress } from '../../types/transfer.types';
import type { TransferMatchingItem, TransferMatchingSummary, TransferSourceProgress } from '../../types/transfer.types';
/** 最小合法匹配摘要(TransferMatchingSummary 全必填字段齐备,计数为 0) */
function buildSummary(): TransferMatchingSummary {
@@ -70,3 +70,81 @@ describe('TransferMatchCard 来源失败顶栏', () => {
expect(wrapper.find('[data-testid="transfer-match-failed-sources"]').exists()).toBe(false);
});
});
/** [2026-10-12 单据数口径修正] 预计 ERP 单据数按执行建单五元组去重。
* 行分组键 = (external_org, source_code, receipt_date, from_warehouse,
* to_warehouse),与后端 execution_service.prepare_execution 同口径:
* 同组多行执行期合并一张 ERP 单,预估数不得等于可执行行数。 */
function buildItem(overrides: Partial<TransferMatchingItem>): TransferMatchingItem {
return {
item_id: 1,
source_code: 'DBS-AWSBI',
material_no: 'MAT-001',
material_name: '连接器组件',
specification: 'A 型',
invoice_no: 'HOM-001',
receipt_date: '2026-08-05',
from_warehouse: 'DBS-TRANSIT',
from_quantity: '100',
to_warehouse: 'HUB-CN01',
to_quantity: '100',
result: 'executable',
external_org: 'HX-CN01',
...overrides,
};
}
/** 计数卡第 5 格 = 预计 ERP 单据(可执行/未成熟/阻断/数量/单据/待查/失效)。 */
function estimateCardText(wrapper: ReturnType<typeof mount>): string {
const cells = wrapper.find('[data-testid="transfer-match-counts"]').findAll('div.rounded-lg');
return cells[4]?.text() ?? '';
}
describe('TransferMatchCard 预计 ERP 单据数(五元组去重)', () => {
const sameGroupA = buildItem({ item_id: 1, invoice_no: 'HOM-001' });
const sameGroupB = buildItem({ item_id: 2, invoice_no: 'HOX-002' });
const crossDate = buildItem({ item_id: 3, invoice_no: 'HOM-003', receipt_date: '2026-08-04' });
it('计数卡:同组两行 + 跨日一行 → 预估 2(不等于可执行行数 3)', () => {
// [断言意图] 锁定五元组去重口径:receipt_date 入键,同组合并、跨组拆分,
// 历史快照旧口径(=行数)持久值不再上屏。
const wrapper = mount(TransferMatchCard, {
props: {
summary: buildSummary(),
items: [sameGroupA, sameGroupB, crossDate],
selected: new Set<number>(),
},
global: { plugins: [i18n] },
});
expect(estimateCardText(wrapper).replace(/\D/g, '')).toBe('2');
});
it('生成按钮旁预估随勾选联动:勾选同组两行仍为 1,跨组勾选后为 2', async () => {
// [断言意图] 底部预估回答「点生成会出几张单」:仅统计勾选的可执行行并
// 按五元组分组;同组两行勾选=1 张(合并),追加跨日行勾选=2 张。
const wrapper = mount(TransferMatchCard, {
props: {
summary: buildSummary(),
items: [sameGroupA, sameGroupB, crossDate],
selected: new Set<number>([1, 2]),
},
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="transfer-estimate-selected"]').text()).toContain(':1');
await wrapper.setProps({ selected: new Set<number>([1, 2, 3]) });
expect(wrapper.find('[data-testid="transfer-estimate-selected"]').text()).toContain(':2');
});
it('阻断行不参与预估:勾选阻断行不改变单据数', () => {
const blocked = buildItem({ item_id: 4, invoice_no: 'HOM-BLOCKED', result: 'blocked_quantity_mismatch' });
const wrapper = mount(TransferMatchCard, {
props: {
summary: buildSummary(),
items: [sameGroupA, blocked],
selected: new Set<number>([1, 4]),
},
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="transfer-estimate-selected"]').text()).toContain(':1');
});
});
@@ -15,13 +15,19 @@
emit execute(itemIds);来源级解析/文件失败经 sources.error_code 透出
(防"安静全 0"),但路由未解析失败(TRANSFER.ROUTE_NOT_RESOLVED)不进顶栏
——路由失败保持行级(result=blocked_route_not_resolved 行内展示),
顶栏按 error_code 客户端排除,历史卡片回放同样生效。
顶栏按 error_code 客户端排除,历史卡片回放同样生效;
[2026-10-12 单据数口径修正] 预计 ERP 单据数(计数卡=全部可执行行、
生成按钮旁=勾选可执行行)按执行建单五元组 (external_org, source_code,
receipt_date, from_warehouse, to_warehouse) 去重实时计算(与后端
execution_service 同键),同组多行合并一张单——原「=可执行行数」口径
高估单据数误导用户。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import { parseApiUtcDate } from '@/shared/utils/dateTime';
import type { TransferMatchingItem, TransferMatchingSummary, TransferSourceProgress } from '../../types/transfer.types';
const { t } = useI18n();
@@ -143,13 +149,43 @@ const executableCheckedItemIds = computed(() =>
props.items.filter((item) => isSelectable(item) && isChecked(item)).map((item) => item.item_id as number),
);
/** [2026-10-12 单据数口径修正] 执行建单五元组键(与后端 execution_service.
* prepare_execution 分组建单同键同 .trim() 规范化):(external_org, source_code,
* receipt_date, from_warehouse, to_warehouse),同组多行执行期合并一张 ERP 单。
* 老卡片行缺 external_org 按 '' 参与(分组退化为四元组,仅跨组织同仓库配置下有差异)。 */
function documentGroupKey(item: TransferMatchingItem): string {
return [
(item.external_org ?? '').trim(),
(item.source_code ?? '').trim(),
(item.receipt_date ?? '').trim(),
(item.from_warehouse ?? '').trim(),
(item.to_warehouse ?? '').trim(),
].join('\u001f');
}
/** 预计 ERP 单据数(计数卡):全部可执行行按五元组去重的组数。客户端实时计算,
* 使历史快照中旧口径(=可执行行数)的持久化估计值不再上屏误导。 */
const estimatedDocumentCountAll = computed(
() => new Set(props.items.filter((item) => item.result === 'executable').map(documentGroupKey)).size,
);
/** 预计 ERP 单据数(生成按钮旁):按当前勾选的可执行行分组计数,回答
* 「点生成会出几张单」;未勾选为 0。 */
const estimatedDocumentCountSelected = computed(
() => new Set(
props.items.filter((item) => item.result === 'executable' && isChecked(item)).map(documentGroupKey),
).size,
);
/**
* 库存查询时刻小字(HH:mm);无效/缺省 checked_at 返回 null 不渲染。
* 库存查询时刻小字(HH:mm);后端 naive ISO 按 UTC 解析后转浏览器本地时区
* (仓库约定 parseApiUtcDate,2026-09-29 修复 UTC+8 展示异常);
* 无效/缺省 checked_at 返回 null 不渲染。
* @param item 匹配明细行;checked_at 为后端 ISO 时间
*/
function checkedAtLabel(item: TransferMatchingItem): string | null {
if (!item.checked_at) return null;
const date = new Date(item.checked_at);
const date = parseApiUtcDate(item.checked_at);
if (Number.isNaN(date.getTime())) return null;
const hh = String(date.getHours()).padStart(2, '0');
const mm = String(date.getMinutes()).padStart(2, '0');
@@ -217,7 +253,9 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
<div class="text-[11px] text-muted">{{ $t('chat.transfer.estimatedQuantity') }}</div>
</div>
<div class="rounded-lg bg-surface-soft p-2 text-center">
<div class="text-lg font-black text-brand-600">{{ summary.estimated_external_write_count }}</div>
<!-- [2026-10-12 单据数口径修正] 按执行建单五元组去重(客户端计算),
不再透传旧口径持久值(=可执行行数)——同组多行合并一张 ERP 单 -->
<div class="text-lg font-black text-brand-600">{{ estimatedDocumentCountAll }}</div>
<div class="text-[11px] text-muted">{{ $t('chat.transfer.estimatedExternalWrites') }}</div>
</div>
<!-- 待查库存:文件已落地、尚未查过 ERP 库存的行数(历史回放缺省 0) -->
@@ -390,9 +428,10 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
</div>
<div class="mt-3 flex items-center justify-end gap-3 border-t border-subtle pt-3">
<span class="text-xs text-muted">
<span class="text-xs text-muted" data-testid="transfer-estimate-selected">
{{ $t('chat.transfer.selectedCount', { count: selectedCount }) }} ·
{{ $t('chat.transfer.estimatedExternalWrites') }}:{{ summary.estimated_external_write_count }}
<!-- [2026-10-12 单据数口径修正] 随勾选联动:按勾选可执行行五元组分组计数 -->
{{ $t('chat.transfer.estimatedExternalWrites') }}:{{ estimatedDocumentCountSelected }}
</span>
<button
type="button"
@@ -385,9 +385,13 @@ async function onSourceRetry(sourceCodes: string[]) {
const codes = Array.isArray(sourceCodes) ? sourceCodes : [sourceCodes];
retryingSource.value = new Set([...retryingSource.value, ...codes]);
try {
// 逐来源触发,避免一次并发 EPR/RPA 竞态;失败中断剩余。
for (const code of codes) {
await transfer.retrySourceRpa(code);
// 多来源一次批量端点(合并单 batch trigger,Worker 单次浏览器会话串行导出);
// 单来源沿用原接口(行级 ↻ 一源一文件语义不变)。
const [first, ...rest] = codes;
if (rest.length > 0) {
await transfer.retrySourcesRpaBatch(codes);
} else if (first !== undefined) {
await transfer.retrySourceRpa(first);
}
} catch (e) {
reportError(e);
@@ -4,8 +4,8 @@
* 确认提交、重试收料 RPA。
* 依赖:@vue/test-utils、i18n。
* 逻辑:平台 DBS/Crane 仅分组;实例为选择与执行边界(决策 2/3/4);
* 确认需至少一个 has_ready_file(兜底告警),提交范围静默过滤为 ready-only
* (无 ready 文件的勾选项不进匹配,2026-09-29 来源错误分层);
* 确认需至少一个 has_ready_file(兜底告警);混合选择(含非就绪项)先披露范围
* 再确认(知情部分确认 2026-10-09,替代历史静默剔除),提交范围 ready-only;
* 重试门禁=仅 fetching 在途不可重试(ready 亦可强制重抓,2026-09-29 去管控)。
*/
import { mount } from '@vue/test-utils';
@@ -54,18 +54,21 @@ describe('TransferSourceSelectCard', () => {
expect(wrapper.emitted('confirm')).toBeUndefined();
});
it('“全选可见”勾选全部启用实例,确认时静默剔除无 ready 文件来源', async () => {
// [断言意图] 门禁新语义:有 ready 文件的勾选项照常放行,无 ready 文件的勾选项
// (DBS-AWSSG none)静默剔除——确认范围只含可执行来源,不再整包提交。
it('“全选可见”勾选全部启用实例,混合选择先披露再确认 ready-only', async () => {
// [断言意图] 知情部分确认(2026-10-09):混合选择(2 ready + 1 none)点确认先出现
// 披露条且不提交;披露后确认只携带具备 ready 文件的来源码。
const wrapper = mountCard();
await wrapper.find('[data-testid="transfer-source-select-visible"]').trigger('click');
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
expect(wrapper.find('[data-testid="transfer-source-partial-confirm"]').exists()).toBe(true);
expect(wrapper.emitted('confirm')).toBeUndefined();
await wrapper.find('[data-testid="transfer-source-partial-proceed"]').trigger('click');
expect(wrapper.emitted('confirm')?.[0][0]).toEqual(['DBS-AWSBI', 'CRANE-SZ']);
});
it('勾选 ready+parse_failed 确认时只提交 ready 来源', async () => {
it('勾选 ready+parse_failed 先披露,披露后确认只提交 ready 来源', async () => {
// [断言意图] 解析失败来源(has_ready_file=false)勾选后不阻断确认,
// 但确认事件只携带具备 ready 文件的来源码。
// 但须经披露条确认,确认事件只携带具备 ready 文件的来源码。
const sources = [
{ source_code: 'DSV-OK', display_name: 'ok', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' as const },
{ source_code: 'DSV-BAD', display_name: 'bad', platform: 'dbs', enabled: true, has_ready_file: false, file_status: 'parse_failed' as const },
@@ -74,9 +77,64 @@ describe('TransferSourceSelectCard', () => {
await wrapper.find('[data-testid="transfer-source-option-DSV-OK"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-option-DSV-BAD"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
expect(wrapper.emitted('confirm')).toBeUndefined();
await wrapper.find('[data-testid="transfer-source-partial-proceed"]').trigger('click');
expect(wrapper.emitted('confirm')?.[0][0]).toEqual(['DSV-OK']);
});
it('混合选择披露条展示可匹配/暂不可匹配计数与状态分组', async () => {
// [断言意图] 披露必须让「抓取中」与「真失败」可区分:摘要含三段计数,
// 分组明细含「抓取中 1」——用户知情后再决定是否仅匹配就绪来源。
const sources = [
{ source_code: 'DSV-OK', display_name: 'ok', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' as const },
{ source_code: 'DSV-FETCH', display_name: 'fetching', platform: 'dbs', enabled: true, has_ready_file: false, file_status: 'fetching' as const },
];
const wrapper = mountCard({}, sources);
await wrapper.find('[data-testid="transfer-source-option-DSV-OK"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-option-DSV-FETCH"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
const summary = wrapper.find('[data-testid="transfer-source-partial-summary"]').text();
expect(summary).toContain('可匹配 1 个');
expect(summary).toContain('暂不可匹配 1 个');
expect(summary).toContain('抓取中 1');
});
it('披露后「取消」收回披露条且不提交,确认按钮还原', async () => {
// [断言意图] 披露是可退出的确认步:取消后回到选择状态、零副作用。
const wrapper = mountCard();
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSSG"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
expect(wrapper.find('[data-testid="transfer-source-partial-confirm"]').exists()).toBe(true);
await wrapper.find('[data-testid="transfer-source-partial-cancel"]').trigger('click');
expect(wrapper.find('[data-testid="transfer-source-partial-confirm"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="transfer-source-confirm"]').exists()).toBe(true);
expect(wrapper.emitted('confirm')).toBeUndefined();
});
it('披露展示期间调整勾选即收回披露(旧口径失效)', async () => {
// [断言意图] 披露基于确认瞬间的选择快照:勾选变化后旧披露必须失效收回,
// 防止按过期口径提交。
const wrapper = mountCard();
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSSG"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
expect(wrapper.find('[data-testid="transfer-source-partial-confirm"]').exists()).toBe(true);
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSSG"] input').setValue(false);
expect(wrapper.find('[data-testid="transfer-source-partial-confirm"]').exists()).toBe(false);
expect(wrapper.emitted('confirm')).toBeUndefined();
});
it('全就绪选择不出现披露,确认直达提交', async () => {
// [断言意图] 知情披露只在混合状态出现:全部就绪时确认一步直达(常态零额外点击)。
const wrapper = mountCard();
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-option-CRANE-SZ"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
expect(wrapper.find('[data-testid="transfer-source-partial-confirm"]').exists()).toBe(false);
expect(wrapper.emitted('confirm')?.[0][0]).toEqual(['DBS-AWSBI', 'CRANE-SZ']);
});
it('parse_failed 显示解析失败徽标且可重试', async () => {
// [断言意图] 当日收料文件解析失败(file_status=parse_failed)不得误报就绪;
// 与 none/failed/expired 一样允许重新触发收料 RPA。
@@ -180,6 +238,16 @@ describe('TransferSourceSelectCard', () => {
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSBI', 'DBS-AWSSG', 'CRANE-SZ']);
});
it('空数据来源显示「无收料数据」徽标而非抓取失败', async () => {
// [断言意图] 抓取成功但当日无收料记录(file_status=no_data)属业务结果,
// 必须如实展示"无收料数据",不得与"抓取失败"混淆(2026-10-08 PRD01 误标事故)。
const wrapper = mountCard({}, [
{ source_code: 'CRANE-NODATA', display_name: '空数据在途仓', platform: 'crane', enabled: true, has_ready_file: false, file_status: 'no_data' },
]);
expect(wrapper.find('[data-testid="transfer-source-status-CRANE-NODATA"]').text()).toBe('无收料数据');
expect((wrapper.find('[data-testid="transfer-source-retry-CRANE-NODATA"]').element as HTMLButtonElement).disabled).toBe(false);
});
it('已过期来源显示「文件已过期」徽标且可重试', async () => {
// [断言意图] 保留期已到的来源不得误报就绪(has_ready_file=false);
// expired 状态与 none/failed 一样允许重新触发收料 RPA。
@@ -6,14 +6,15 @@
逻辑:匹配参数区(调拨类型 + 收料日期,确认时一并提交)→ 选择辅助/上下文操作条
(有选中时原位替换辅助区,承载批量重试/下载/清空选择)→ 平台分组来源列表
(平台仅分组不可直接执行)→ 底部唯一实心主按钮「确认范围并匹配」(未选禁用);
确认只提交具备 ready 文件的来源(勾选的无 ready 项如 parse_failed/none 静默剔除,
门禁「至少一 ready」保留为兜底告警);重试除抓取中(fetching)外均可触发
确认只提交具备 ready 文件的来源:混合选择(含非就绪项)先披露范围再确认
(知情部分确认 2026-10-09,替代历史静默剔除),全就绪直达;
门禁「至少一 ready」保留为兜底告警;重试除抓取中(fetching)外均可触发
(ready 亦可强制重抓,2026-09-29 去管控),徽标独立文案;
调拨类型决定收料数据范围(类型 1 仅纳入 INVOICE 前缀 HOM/HOX/WTP),
类型 2/3 一期占位(禁用,后端同样 fail-closed)。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useMessage } from '@/shared/composables/useMessage';
import { eligibleReceiptDateTo } from './transferDate';
@@ -89,6 +90,37 @@ const confirmDisabled = computed(() =>
);
const downloadDisabled = computed(() => props.busy || !selectedHasReadyFile.value);
// ---- [知情部分确认 2026-10-09] 混合选择(含非就绪项)先披露范围再确认,替代历史静默剔除 ----
/** 披露条可见性:仅在「已选含就绪 + 非就绪」混合状态点确认后出现。 */
const showPartialConfirm = ref(false);
/** 已选来源中具备 ready 文件的数量。 */
const selectedReadyCount = computed(() =>
[...selected.value].filter((code) => props.sources.find((s) => s.source_code === code)?.has_ready_file).length,
);
const selectedUnreadyCount = computed(() => selectedCount.value - selectedReadyCount.value);
/** 非就绪状态分组展示顺序:先在途(fetching)后终态。 */
const unreadyStatusOrder = ['fetching', 'failed', 'parse_failed', 'no_data', 'expired', 'none'] as const;
/** 非就绪状态 → 徽标文案 key(复用既有状态徽标词汇,披露条逐组计数)。 */
const UNREADY_STATUS_LABEL_KEYS: Record<(typeof unreadyStatusOrder)[number], string> = {
fetching: 'chat.transfer.fileFetching',
failed: 'chat.transfer.fileFailed',
parse_failed: 'chat.transfer.fileParseFailed',
no_data: 'chat.transfer.fileNoData',
expired: 'chat.transfer.fileExpired',
none: 'chat.transfer.fileNone',
};
/** 非就绪来源按状态分组计数(固定顺序),让「抓取中」与「真失败」可区分。 */
const unreadyBreakdownText = computed(() => unreadyStatusOrder
.map((status) => ({
status,
count: [...selected.value].filter(
(code) => props.sources.find((s) => s.source_code === code)?.file_status === status,
).length,
}))
.filter((item) => item.count > 0)
.map((item) => `${t(UNREADY_STATUS_LABEL_KEYS[item.status])} ${item.count}`)
.join(' · '));
function toggle(sourceCode: string, checked: boolean) {
const next = new Set(selected.value);
if (checked) next.add(sourceCode);
@@ -141,23 +173,49 @@ function downloadSelected(): void {
if (codes.length) emit('download', codes);
}
/** 确认范围并匹配:只提交具备 ready 文件的来源;无 ready 文件的勾选项(如 parse_failed/none)
* 静默剔除(历史上是「至少一 ready 则整包提交」,会把不可执行来源带进匹配);
* 「至少一 ready」门禁保留为兜底告警(全部无 ready 时拦截)。 */
/** 确认范围并匹配:只提交具备 ready 文件的来源。混合选择(含非就绪项)先展示披露条
* (知情部分确认 2026-10-09,替代历史「至少一 ready 则静默剔除整包」),用户确认后
* 才提交 ready-only;全就绪直达。「至少一 ready」门禁保留为兜底告警。 */
function confirm() {
if (selectedCount.value === 0) {
notifyWarning(t('chat.transfer.needSelectSource'), t('chat.transfer.sourceSelectTitle'));
return;
}
const readyCodes = [...selected.value].filter(
(code) => props.sources.find((s) => s.source_code === code)?.has_ready_file,
);
const readyCodes = selectedReadyCodes();
if (readyCodes.length === 0) {
notifyWarning(t('chat.transfer.needReadyFile'), t('chat.transfer.sourceSelectTitle'));
return;
}
if (selectedUnreadyCount.value > 0) {
showPartialConfirm.value = true;
return;
}
emit('confirm', readyCodes, { from: dateFrom.value || undefined, to: dateTo.value || undefined }, transferType.value);
}
/** 已选来源中的 ready 来源码(每次 emit 时现算,避免披露期间勾选变化导致口径过期)。 */
function selectedReadyCodes(): string[] {
return [...selected.value].filter(
(code) => props.sources.find((s) => s.source_code === code)?.has_ready_file,
);
}
/** 披露后确认:仅提交就绪来源(其余来源就绪后可重新匹配补入,后端增量圈行不破坏已有行)。 */
function proceedPartialConfirm() {
const readyCodes = selectedReadyCodes();
showPartialConfirm.value = false;
emit('confirm', readyCodes, { from: dateFrom.value || undefined, to: dateTo.value || undefined }, transferType.value);
}
/** 披露后取消:收回披露条,可调整勾选或等待其余来源就绪。 */
function cancelPartialConfirm() {
showPartialConfirm.value = false;
}
// 勾选变化即收回披露:用户在调整范围,旧披露口径已失效。
watch(selected, () => {
showPartialConfirm.value = false;
});
</script>
<template>
@@ -278,7 +336,10 @@ function confirm() {
</span>
</div>
<div v-for="platform in platforms" :key="platform" class="mb-3 rounded-lg border border-subtle">
<!-- [ZONE 3] 来源列表:上限随视口伸缩(60vh)而非固定值——来源多时列表尽量占满可用高度再内部滚动,
避免固定小限高把列表压成几行+卡片下方大量留白;来源少时卡片自然收缩不受影响 -->
<div class="max-h-[60vh] space-y-3 overflow-y-auto" data-testid="transfer-source-list">
<div v-for="platform in platforms" :key="platform" class="rounded-lg border border-subtle">
<div class="flex items-center justify-between rounded-t-lg bg-surface-soft px-3 py-1.5">
<b class="text-xs text-secondary">{{ platform.toUpperCase() }}</b>
<label class="text-[11px] text-muted">
@@ -329,6 +390,14 @@ function confirm() {
>
{{ t('chat.transfer.fileFailed') }}
</span>
<!-- 无收料数据(no_data):抓取成功但当日无收料记录,属业务结果而非故障;当日稍后到货可重抓补数 -->
<span
v-else-if="source.file_status === 'no_data'"
class="inline-flex items-center gap-1 rounded-full bg-sky-50 px-2 py-0.5 text-[10px] font-bold text-sky-700"
:data-testid="`transfer-source-status-${source.source_code}`"
>
{{ t('chat.transfer.fileNoData') }}
</span>
<span
v-else-if="source.file_status === 'expired'"
class="inline-flex items-center gap-1 rounded-full bg-orange-50 px-2 py-0.5 text-[10px] font-bold text-orange-700"
@@ -365,9 +434,42 @@ function confirm() {
</div>
</div>
</div>
</div>
<div class="flex items-center justify-end border-t border-subtle pt-3">
<!-- [知情部分确认] 混合状态点确认后按钮区原位替换为披露条(同槽位切换惯例):
明确本次仅纳入就绪来源、逐状态分组展示未就绪项,用户显式确认后才提交。 -->
<div
v-if="showPartialConfirm"
class="flex w-full flex-col gap-1.5 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2"
data-testid="transfer-source-partial-confirm"
>
<p class="text-xs font-bold text-amber-700" data-testid="transfer-source-partial-summary">
{{ $t('chat.transfer.partialConfirmSummary', { total: selectedCount, ready: selectedReadyCount, unready: selectedUnreadyCount }) }}
<span v-if="unreadyBreakdownText" class="font-normal">{{ $t('chat.transfer.partialConfirmBreakdown', { items: unreadyBreakdownText }) }}</span>
</p>
<p class="text-xs text-amber-700">{{ $t('chat.transfer.partialConfirmHint') }}</p>
<div class="flex items-center justify-end gap-2">
<button
type="button"
class="rounded-lg border border-default px-3 py-1.5 text-xs font-bold text-secondary hover-surface-soft"
data-testid="transfer-source-partial-cancel"
@click="cancelPartialConfirm"
>
{{ $t('chat.transfer.partialConfirmCancel') }}
</button>
<button
type="button"
class="rounded-lg bg-brand-600 px-4 py-1.5 text-xs font-bold text-white hover:bg-brand-700"
data-testid="transfer-source-partial-proceed"
@click="proceedPartialConfirm"
>
{{ $t('chat.transfer.partialConfirmProceed') }}
</button>
</div>
</div>
<button
v-else
type="button"
class="rounded-lg bg-brand-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
:disabled="confirmDisabled"
@@ -5,6 +5,9 @@
逻辑:主卡内部 section = 「当前阶段/状态/正式OT → 下一步 → 动作区」;
状态文案严格绑定 user_status;blocking_reason 只作下一步问题说明;按钮显隐由后端 retryable + primary_action.parameters 决定;
主动作按钮文案 fail-closed:后端下发动作码但无受控 i18n 文案时整体隐藏该按钮(含图标),禁止渲染无文字裸按钮;
阶段能力禁用态:视图层把 preparation.capabilities 的 disabled_reason 并进动作对象
(capabilityDisabledReason),命中时按钮渲染 disabled + 原因 tooltip(capabilityDisabled 命名空间),
与 submitFormalGateAction 的点击拦截同源(展示=执行同源),禁止可点样式诱导用户点击后才被拦截;
loading 仅代表「权威投影读取中」而非系统运行态:已知阶段/状态/阻断仍照常展示
(与投影同源或后端 automation 运行态),空态自然落到「待机/状态待确认」,
禁止把读取占位误述为「系统处理中」,也不做骨架→真值的二次刷新;
@@ -45,12 +48,17 @@ const props = defineProps<{
| null;
retryable?: boolean;
blockingReason?: ShippingProcessingBlockingReason | null;
primaryAction?: ShippingProcessingPrimaryAction | null;
primaryAction?: (ShippingProcessingPrimaryAction & {
/** 阶段能力禁用原因(视图层从 preparation.capabilities 并入);非空=按钮渲染禁用态。 */
capabilityDisabledReason?: string | null;
}) | null;
recoveryActions?: Array<{
code: string;
i18nKey?: string | null;
label_key?: string | null;
parameters?: Record<string, unknown>;
/** 阶段能力禁用原因(视图层从 preparation.capabilities 并入);非空=按钮渲染禁用态。 */
capabilityDisabledReason?: string | null;
}>;
/** 正式 Gate 原始状态仅用于区分未入队、运行中与外部回执等待;不参与按钮裁决。 */
gateStatus?: string | null;
@@ -296,6 +304,11 @@ const businessActionLabel = computed(() => {
});
const businessActionTitle = computed(() => {
// 能力禁用原因优先于重试中提示:禁用态按钮的 tooltip 必须解释"为什么不可点"。
const capabilityText = capabilityDisabledText(
props.primaryAction ? capabilityDisabledReasonOf(props.primaryAction) : null,
);
if (capabilityText) return capabilityText;
const retryingFlag = Boolean(props.retrying);
if (retryingFlag) {
return t('chat.shippingOrderReview.currentTask.actionRetryRunningTooltip');
@@ -305,6 +318,29 @@ const businessActionTitle = computed(() => {
const actionIsRetry = computed(() => String(props.primaryAction?.code || '').trim().startsWith('retry_'));
const actionIsInventoryRpa = computed(() => String(props.primaryAction?.code || '').trim() === 'retry_inventory_preparation');
/**
* 阶段能力禁用态裁决:与视图层 submitFormalGateAction 的点击拦截同源(展示=执行同源)。
* 核心逻辑:视图层把 preparation.capabilities 的 disabled_reason 并进动作对象;本卡只负责
* 渲染禁用态与原因 tooltip,不自行推断业务能力。原因文案复用 capabilityDisabled 命名空间,
* 未登记的 reason fail-closed 禁用但不给 tooltip(禁止裸露内部原因码)。
*/
function capabilityDisabledReasonOf(action: { capabilityDisabledReason?: string | null }): string | null {
const reason = String(action.capabilityDisabledReason || '').trim();
return reason || null;
}
function capabilityDisabledText(reason: string | null | undefined): string {
const normalized = String(reason || '').trim();
if (!normalized) return '';
const key = `chat.shippingOrderReview.lifecycle.prepare.capabilityDisabled.${normalized}`;
return te(key) ? t(key) : '';
}
const businessActionCapabilityDisabled = computed(() => (
Boolean(props.primaryAction && capabilityDisabledReasonOf(props.primaryAction))
));
const recoveryActions = computed(() => (props.recoveryActions || []).filter((action) => {
const code = String(action.code || '').trim();
if (!code || isNonTaskCapabilityAction(code) || isInternalInventoryAction(code)) return false;
@@ -329,6 +365,8 @@ function recoveryActionLabel(action: (typeof recoveryActions.value)[number]): st
}
function handleBusinessActionClick() {
// 能力禁用态兜底:disabled 按钮通常不派发 click,此处防御键盘等旁路触发。
if (businessActionCapabilityDisabled.value) return;
const primaryActionCode = String(props.primaryAction?.code || '').trim();
if (!primaryActionCode || primaryActionCode === 'retry') return;
emit('action', primaryActionCode, props.primaryAction?.parameters ?? {});
@@ -464,9 +502,10 @@ type ReviewCurrentUserStatus =
<button
v-if="showBusinessAction"
type="button"
class="inline-flex items-center gap-1 rounded-md bg-sky-700 px-3 py-1.5 text-xs font-medium text-white shadow-sm transition hover:bg-sky-800 disabled:opacity-50 dark:bg-sky-600 dark:hover:bg-sky-500"
class="inline-flex items-center gap-1 rounded-md bg-sky-700 px-3 py-1.5 text-xs font-medium text-white shadow-sm transition hover:bg-sky-800 disabled:opacity-50 disabled:cursor-not-allowed dark:bg-sky-600 dark:hover:bg-sky-500"
:data-testid="actionIsRetry ? 'review-current-processing-retry' : 'review-current-task-primary-action'"
:disabled="retrying || locating"
:data-capability-disabled="businessActionCapabilityDisabled ? 'true' : undefined"
:disabled="retrying || locating || businessActionCapabilityDisabled"
:title="businessActionTitle"
@click="handleBusinessActionClick"
>
@@ -482,9 +521,11 @@ type ReviewCurrentUserStatus =
v-for="action in recoveryActions"
:key="action.code"
type="button"
class="inline-flex items-center gap-1 rounded-md border border-sky-300 bg-surface px-2.5 py-1.5 text-xs font-medium text-sky-800 shadow-sm transition hover:bg-sky-50 disabled:opacity-50 dark:border-sky-700 dark:bg-sky-900 dark:text-sky-100 dark:hover:bg-sky-800"
class="inline-flex items-center gap-1 rounded-md border border-sky-300 bg-surface px-2.5 py-1.5 text-xs font-medium text-sky-800 shadow-sm transition hover:bg-sky-50 disabled:opacity-50 disabled:cursor-not-allowed dark:border-sky-700 dark:bg-sky-900 dark:text-sky-100 dark:hover:bg-sky-800"
:data-testid="`review-current-task-recovery-${action.code}`"
:disabled="retrying || locating"
:data-capability-disabled="capabilityDisabledReasonOf(action) ? 'true' : undefined"
:disabled="retrying || locating || Boolean(capabilityDisabledReasonOf(action))"
:title="capabilityDisabledText(capabilityDisabledReasonOf(action))"
@click="$emit('action', action.code, action.parameters || {})"
>
{{ recoveryActionLabel(action) }}
@@ -35,6 +35,7 @@ import {
manualCloseTransferItem,
retryTransferItem,
retryTransferSourceRpa,
retryTransferSourcesRpaBatch,
} from '../api/transfer.api';
import type {
TransferBacklogItem,
@@ -458,6 +459,15 @@ export function useChatTransfer() {
return status;
}
/** 批量来源重试:一次批量端点调用(多来源合并单 batch trigger,Worker 单次浏览器
* 会话串行导出;逐来源循环会产生 N 个文件、开/关 N 次浏览器),随后刷新来源状态
* (loadSources 观察到 fetching 自动开始轮询)。 */
async function retrySourcesRpaBatch(sourceCodes: string[]) {
const result = await retryTransferSourcesRpaBatch(sourceCodes);
await loadSources();
return result;
}
/** 加载待处理异常列表与汇总 */
async function loadBacklog() {
const [items, summary] = await Promise.all([listTransferBacklog(), getTransferBacklogSummary()]);
@@ -559,6 +569,7 @@ export function useChatTransfer() {
manualClose,
loadSources,
retrySourceRpa,
retrySourcesRpaBatch,
loadBacklog,
loadBacklogSummary,
loadExecutableItems,
@@ -1529,6 +1529,8 @@ export interface ShippingTaskUiState {
part_number?: string | null;
required_qty?: string | number | null;
available_qty?: string | number | null;
/** 料号维度总可用量(忽略预约号、行允许源内汇总);无快照/未就绪为 null。 */
part_available_qty?: string | null;
shortage_qty?: string | number | null;
/** Match 正式匹配源;未匹配时为空,禁止用候选回填。 */
source_code?: string | null;
@@ -67,6 +67,9 @@ export interface TransferMatchingItem {
stale?: boolean;
/** 行评估所用收料文件版本与来源最新可用文件是否一致;false = 文件已更新需重新匹配 */
file_current?: boolean;
/** [2026-10-12 单据数口径修正] 执行建单五元组首键(路由解析所得外部组织);
* 匹配评估路径透出,历史回放缺省——预估 ERP 单据数按五元组去重的分组输入 */
external_org?: string;
}
/** 来源实例级进度(决策 18:来源隔离展示) */
@@ -246,7 +249,7 @@ export interface TransferSourceOption {
platform: string;
enabled: boolean;
/** 收料文件状态:ready / fetching / failed / parse_failed / expired / none(只读投影货代收料事实;parse_failed=当日可用收料文件解析失败) */
file_status?: 'ready' | 'fetching' | 'failed' | 'parse_failed' | 'expired' | 'none';
file_status?: 'ready' | 'fetching' | 'failed' | 'no_data' | 'parse_failed' | 'expired' | 'none';
/** 是否已有当前可用的收料文件(门禁:无 ready 文件禁止确认匹配) */
has_ready_file?: boolean;
file_no?: string | null;
@@ -256,7 +259,7 @@ export interface TransferSourceOption {
/** 来源收料文件状态(门禁 + 状态标识 + 重试返回) */
export interface TransferSourceFileStatus {
source_code: string;
file_status: 'ready' | 'fetching' | 'failed' | 'parse_failed' | 'expired' | 'none';
file_status: 'ready' | 'fetching' | 'failed' | 'no_data' | 'parse_failed' | 'expired' | 'none';
has_ready_file: boolean;
file_no?: string | null;
file_sha256?: string | null;
@@ -701,8 +701,13 @@ async function mountView(query: Record<string, string> = {}) {
releaseShortageHint: '放行后本次发货按缺口处理。',
releaseReasonPlaceholder: '可填写放行原因(选填)',
releaseConfirm: '确认放行',
reservedQty: '预约数量',
partAvailableQty: '可用数量',
shortage: '库存不足',
pending: '库存匹配或通知文件尚未生成。',
capabilityDisabled: {
no_match_result: '暂无库存匹配结果,请先重新获取库存',
},
},
uploadComplete: {
title: '通知完成',
@@ -759,6 +764,8 @@ async function mountView(query: Record<string, string> = {}) {
actionCodes: {
confirm_customer: '确认客户',
resolve_field_conflicts: '处理字段冲突',
retry_inventory_preparation: '重新获取库存',
retry_inventory_matching: '重新匹配库存',
},
},
},
@@ -1620,6 +1627,81 @@ describe('ShippingOrderReviewView layout phase 1', () => {
);
});
it('renders capability-disabled actions as disabled buttons with reason tooltip', async () => {
// 回归(展示=执行同源):A 渲染的 retry_inventory_matching 命中阶段能力 disabled
// (no_match_result)时,右卡必须直接渲染禁用态 + 原因 tooltip;
// 禁止可点样式诱导用户点击后才被 submitFormalGateAction 弹提示拦截。
activeCase.value = {
...activeCase.value,
status: 'confirmed', has_formal_ot: true, task_missing: false,
confirmed_task_id: 906, confirmed_task_no: 'SN-RPA-CAP-DISABLED',
};
shippingProcessingProjection.value = {
workItemType: 'order_task', workItemNo: 'SN-RPA-CAP-DISABLED',
status: 'failed', userStatus: 'retryable', stage: 'inventory_fetching',
progressVersion: 5, currentGate: { status: 'blocked_retryable' },
uiState: {
status: 'retryable', stage: 'inventory_fetching', lifecycleStage: 'fulfillment_prep',
primary_action: { code: 'retry_inventory_matching' },
secondary_actions: [{ code: 'retry_inventory_preparation', enabled: true }],
},
} as any;
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-RPA-CAP-DISABLED', status: 'processing', lines: [], events: [],
ui_state: {
actions: { primary: null, secondary: [] },
process_gate: {
execution_no: 'EXEC-RPA-CAP-DISABLED',
current_blocking_gate: {
gate_code: 'inventory_preparation', evaluation_version: 2, status: 'blocked_retryable',
},
allowed_actions: ['retry_inventory_matching', 'retry_inventory_preparation'],
},
stage_context: {
preparation: {
status: 'blocked', source_locked: false,
source_options: [{ source_code: 'DSV' }],
failed_source_codes: ['DSV'],
capabilities: [
{
code: 'retry_inventory_matching', scope: 'task',
action_code: 'retry_inventory_matching', enabled: false,
disabled_reason: 'no_match_result',
},
{
code: 'retry_inventory_preparation', scope: 'task',
action_code: 'retry_inventory_preparation', enabled: true,
disabled_reason: null,
},
],
frozen_order_lines: [], lines: [],
},
},
summary: {}, steps: [],
},
} as any);
submitProcessGatePrimaryActionMock.mockClear();
messageMocks.info.mockClear();
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
// 主按钮:能力禁用 → disabled + 原因 tooltip(复用 capabilityDisabled.no_match_result 文案)。
const primary = wrapper.get('[data-testid="review-current-processing-retry"]');
expect(primary.attributes('disabled')).toBeDefined();
expect(primary.attributes('data-capability-disabled')).toBe('true');
expect(primary.attributes('title')).toContain('暂无库存匹配结果');
// 侧路按钮:能力 enabled → 保持可点,不受主按钮禁用影响。
const recovery = wrapper.get('[data-testid="review-current-task-recovery-retry_inventory_preparation"]');
expect(recovery.attributes('disabled')).toBeUndefined();
// 点击禁用按钮不得触发提交,也不得弹任何 info 提示(此前会弹未翻译 key)。
await primary.trigger('click');
await flushPromises();
expect(submitProcessGatePrimaryActionMock).not.toHaveBeenCalled();
expect(messageMocks.info).not.toHaveBeenCalled();
});
it('refreshes the processing projection after field-conflict adjudication refreshes the Case', async () => {
activeCase.value = {
...activeCase.value,
@@ -2022,6 +2104,65 @@ describe('ShippingOrderReviewView layout phase 1', () => {
}
});
it('does not auto-advance when switching formal-downstream files without an activeCase identity', async () => {
// 回归:正式下游(通知准备/货代上传/通知完成,选法 2)activeCase 刻意为 null,
// 切换前后 activeCase 身份(case_no/document_id)恒为空值;自动推进守卫若用
// activeCase 做“同一文件”判据,会把目标文件更晚的阶段误判成当前文件被推进,
// 弹出“已自动推进到货代上传”。文件身份必须用 requestedCaseNo(与阶段解析同源,
// selectCase/beginCrossRunSwitch 同步块内更新):切换必变更 → 静默;真实推进
// 不触碰 requestedCaseNo → 提示行为不变。
const originalQueue = reviewQueue.value;
try {
reviewQueue.value = {
...reviewQueue.value,
summary: { total: 2, needs_action: 2, processing: 0, completed: 0 },
items: [
{
...reviewQueue.value.items[0],
has_formal_ot: true,
lifecycle_stage: 'fulfillment_prep',
lifecycle_entries: [
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
},
{
case_no: 'CASE-2', source_run_no: 'RUN-1', document_id: 2, file_name: 'po-2.pdf',
status: 'confirmed', has_formal_ot: true, issue_count: 0,
lifecycle_stage: 'freight_upload',
lifecycle_entries: [
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'freight_upload', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
},
],
};
// 选法 2 盲区:源文件无复核 Case 快照(懒加载失败/未完成时生产即如此),
// 此刻文件身份只剩 requestedCaseNo。
activeCase.value = null;
requestedCaseNo.value = 'CASE-1';
const wrapper = await mountView({ case_no: 'CASE-1', lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
messageMocks.success.mockClear();
// 模拟真实 selectCase 正式下游分支的同步块:更新 requestedCaseNo + activeCase 保持 null。
requestedCaseNo.value = 'CASE-2';
await nextTick();
await flushPromises();
expect(messageMocks.success).not.toHaveBeenCalledWith('已自动推进到货代上传');
// 守卫不得替用户改写深链:切文件是展示上下文切换,不是流程推进。
expect((wrapper.vm as any).$route.query.lifecycle_stage).toBe('fulfillment_prep');
} finally {
reviewQueue.value = originalQueue;
}
});
it('does not open a lifecycle stage before the backend authorizes lifecycle entries', async () => {
// 未收到正式 ui_state.lifecycle_entries 时,前端只能等待实时裁决,
// 不能因页面默认值自行开放订单复核或其他生命周期阶段。
@@ -2686,7 +2827,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
lines: [{
snapshot_line_id: 1001, line_no: 1,
reservation_id: 'RSV-FROZEN', part_number: 'PN-FROZEN',
required_qty: '6', available_qty: null, shortage_qty: null, source_code: 'DBS',
required_qty: '6', available_qty: null, part_available_qty: '9', shortage_qty: null, source_code: 'DBS',
inventory_file_no: 'SIF-LINE-DBS', status: 'shortage',
draft_line_id: 'line-frozen',
inventory_allowed_actions: ['retry_inventory_preparation', 'retry_inventory_matching'],
@@ -2719,6 +2860,12 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(workspace.text()).toContain('RSV-FROZEN');
expect(workspace.text()).toContain('PN-FROZEN');
expect(workspace.text()).toContain('DBS');
// 断言意图:原可用数量列头改由 reservedQty 键渲染(预约数量),
// 新增料号总库存列紧随其后,值来自 part_available_qty。
const headers = workspace.findAll('thead th').map((th) => th.text());
expect(headers).toContain('预约数量');
expect(headers.indexOf('可用数量')).toBe(headers.indexOf('预约数量') + 1);
expect(workspace.text()).toContain('9');
expect(wrapper.find('[data-testid="review-fulfillment-frozen-order"]').exists()).toBe(false);
// 展示态行级动作收纳进更多菜单(⋯):逐项断言授权动作入口存在,不再有常显按钮。
await openLineOverflowMenu(wrapper, 1001);
@@ -817,6 +817,33 @@ const LINE_SCOPE_INVENTORY_ACTIONS = new Set([
'override_line_inventory_source',
]);
/**
* 阶段能力按执行动作码索引(preparation.capabilities)。
* 核心逻辑:右卡按钮的禁用态渲染必须与 submitFormalGateAction 的点击拦截消费同一份
* 能力投影,保证「展示=执行同源」——禁止按钮渲染成可点、点击才被能力门禁弹提示。
*/
const stageCapabilityByActionCode = computed(() => {
const map = new Map<string, { enabled: boolean; disabled_reason?: string | null }>();
for (const cap of formalPreparationContext.value?.capabilities || []) {
const code = String(cap.action_code || '').trim();
if (code) map.set(code, cap);
}
return map;
});
/**
* 给右卡动作附加阶段能力禁用原因。
* @param action - 已统一到卡片域的动作对象(须含 code)
* @returns 原对象浅拷贝;能力禁用时带 capabilityDisabledReason,否则该字段为 null
*/
function withStageCapabilityState<T extends { code: string }>(
action: T,
): T & { capabilityDisabledReason?: string | null } {
const cap = stageCapabilityByActionCode.value.get(String(action.code || '').trim());
if (!cap || cap.enabled) return { ...action, capabilityDisabledReason: null };
return { ...action, capabilityDisabledReason: String(cap.disabled_reason || '').trim() || null };
}
const currentTaskPrimaryAction = computed(() => {
if (formalTaskProjectionPending.value) return null;
if (hasFormalOt.value) {
@@ -828,10 +855,10 @@ const currentTaskPrimaryAction = computed(() => {
// 故必须统一映射到卡片域,否则按钮会因 businessActionLabel 为空而 fail-closed 消失。
const action = currentTaskUiState.value?.primary_action ?? null;
if (!action?.code || LINE_SCOPE_INVENTORY_ACTIONS.has(action.code)) return null;
return {
return withStageCapabilityState({
code: String(action.code).trim(),
i18nKey: `workspace.shippingNotice.processGate.actionCodes.${action.code}`,
};
});
}
const projection = shippingProcessingProjection.value;
if (projection) {
@@ -914,6 +941,8 @@ const currentTaskRecoveryActions = computed(() => {
// [§2.4 单源] 任务级恢复按钮只读 A.secondary_actions;不再叠加 B.capabilities。
// capabilities 仍可作点击执行的 stageCapabilityBypass 查找(见 handleCurrentTaskAction),
// 但不得单独渲成右卡按钮——能力要展示须先并进 A。行级选源禁止出现在右卡。
// [展示=执行同源] A 已渲染的按钮若命中阶段能力 disabled(capabilityDisabledReason
// 非空),右卡必须渲染禁用态 + 原因 tooltip,禁止可点样式诱导用户点击后才被拦截。
return (currentTaskUiState.value?.secondary_actions || [])
.filter((action) => action.enabled
&& String(action.code || '').trim() !== 'download_excel'
@@ -923,7 +952,8 @@ const currentTaskRecoveryActions = computed(() => {
// 统一右卡 domain:actionCodes.<code>(见 currentTaskPrimaryAction 注;A 的 i18nKey 可能是 chat 域)。
i18nKey: `workspace.shippingNotice.processGate.actionCodes.${String(action.code || '').trim()}`,
}))
.filter((action): action is { code: string; i18nKey: string } => {
.map((action) => withStageCapabilityState(action))
.filter((action): action is { code: string; i18nKey: string; capabilityDisabledReason?: string | null } => {
const code = String(action.code || '').trim();
return Boolean(code) && !LINE_SCOPE_INVENTORY_ACTIONS.has(code);
});
@@ -2568,8 +2598,12 @@ const formalPreparationLines = computed(() => {
...line,
required_qty: displayDecimalQty(line.required_qty),
available_qty: displayDecimalQty(line.available_qty),
// available_qty 语义为「预约匹配量」(列头:预约数量);part_available_qty 为料号总库存
// (列头:可用数量)。null 透传,由模板渲染待确认占位,避免把「无快照」误显示为 0。
part_available_qty:
line.part_available_qty == null ? null : displayDecimalQty(line.part_available_qty),
shortage_qty: displayDecimalQty(line.shortage_qty),
})) as Array<typeof rows[number] & { snapshot_line_id?: number | null; required_qty: string; available_qty: string; shortage_qty: string }>;
})) as Array<typeof rows[number] & { snapshot_line_id?: number | null; required_qty: string; available_qty: string; shortage_qty: string; part_available_qty: string | null }>;
});
/** 通知准备固定展示冻结订单明细;库存匹配结果只作为附加事实合并。 */
@@ -4875,20 +4909,21 @@ watch(
watch(
() => [
lifecycleCurrentStageCode.value,
String(activeCase.value?.case_no || '').trim(),
activeReviewDocumentId(),
// 文件身份必须用 requestedCaseNo(与 lifecycleUiState 解析阶段同源):正式下游
// (通知准备/货代上传/通知完成,选法 2)activeCase 刻意为 null,其 case_no/document_id
// 在这些文件之间恒为空值,用 activeCase 做身份会让"切换文件"被误判成"同一文件的
// 阶段推进"而弹出"已自动推进"。requestedCaseNo 在 selectCase/beginCrossRunSwitch/
// load 里与阶段重算同一同步块内更新,切换文件时本 watcher 必然看到变化而静默;
// 真正的自动推进只改队列投影、不触碰 requestedCaseNo,提示行为不变。
String(requestedCaseNo.value || activeCase.value?.case_no || '').trim(),
] as const,
async (current, previous) => {
const [currentStage, currentCaseNo, currentDocumentId] = current;
const [previousStage, previousCaseNo, previousDocumentId] = previous || [];
const [currentStage, currentFileKey] = current;
const [previousStage, previousFileKey] = previous || [];
if (await syncPendingReleaseAutoAdvance()) return;
// 切换文件时生命周期阶段会随新 Case 一起变更;这不是当前文件的自动推进,
// 切换文件时生命周期阶段会随新文件身份一起变更;这不是当前文件的自动推进,
// 不能跳转或弹出“已自动推进”提示。
if (
!previous
|| currentCaseNo !== previousCaseNo
|| currentDocumentId !== previousDocumentId
) return;
if (!previous || currentFileKey !== previousFileKey) return;
if (!currentStage || !previousStage || currentStage === previousStage) return;
const pendingReparse = pendingReparseNavigation.value;
if (
@@ -5329,8 +5364,8 @@ watch(
</div>
<div class="overflow-x-auto overscroll-x-contain" data-testid="review-fulfillment-prep-table-scroll">
<table class="review-fulfillment-prep-table min-w-[1060px] text-xs">
<thead class="border-b border-default bg-surface-muted/50 text-left"><tr><th v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="allPreparationWaveSelected" :disabled="!preparationWaveSelectableLines.length || preparationWaveBusy" :aria-label="t('chat.shippingOrderReview.fulfillmentDecision.selectReady')" @change="toggleAllPreparationLineSelection(($event.target as HTMLInputElement).checked)"></th><th v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationCustomerPoLineLabel() }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.inventorySource') }}</th><th v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.odmConflict.column') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineStatus') }}</th><th class="review-fulfillment-sticky-action-head whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lineOps.moreActions') }}</th></tr></thead>
<tbody><template v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`"><tr :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.reservation_id" type="text" class="w-28 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultReservation')" :data-testid="`review-fulfillment-line-edit-reservation-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.reservation_id || '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.part_number" type="text" class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultPartNumber')" :data-testid="`review-fulfillment-line-edit-part-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else class="block max-w-[220px] truncate" :title="line.part_number || '—'">{{ line.part_number || '—' }}</span></td><td class="whitespace-nowrap px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input :value="editingLine.required_qty" type="number" min="0" step="any" class="w-20 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.requiredQty')" :data-testid="`review-fulfillment-line-edit-qty-${line.snapshot_line_id}`" @input="updateInlineEditQty(($event.target as HTMLInputElement).value)" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.required_qty ?? '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="isInlineEditing(line) && inlineSourceOptions(line).length"><select class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-fulfillment-line-edit-source-${line.snapshot_line_id}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="editingLine?.source_code" :disabled="inlineEditSaving" @change="updateInlineEditSource(($event.target as HTMLSelectElement).value)"><option v-for="option in inlineSourceOptions(line)" :key="option.value" :value="option.value">{{ option.label }}</option></select></template><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) || '—' }}</span></td><td v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2"><div v-if="(line.odm_values?.length || 0) > 1 && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-odm-${line.snapshot_line_id || lineIndex}`"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-odm-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.odmConflict.title')" :value="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || line.chosen_odm_id || ''" @change="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.odmConflict.placeholder') }}</option><option v-for="value in line.odm_values" :key="value" :value="value">{{ value }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-odm-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || lineOdmBusy" :aria-label="t('chat.shippingOrderReLine truncated
<thead class="border-b border-default bg-surface-muted/50 text-left"><tr><th v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="allPreparationWaveSelected" :disabled="!preparationWaveSelectableLines.length || preparationWaveBusy" :aria-label="t('chat.shippingOrderReview.fulfillmentDecision.selectReady')" @change="toggleAllPreparationLineSelection(($event.target as HTMLInputElement).checked)"></th><th v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationCustomerPoLineLabel() }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.inventorySource') }}</th><th v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.odmConflict.column') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.reservedQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.partAvailableQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineStatus') }}</th><th class="review-fulfillment-sticky-action-head whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lineOps.moreActions') }}</th></tr></thead>
<tbody><template v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`"><tr :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.reservation_id" type="text" class="w-28 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultReservation')" :data-testid="`review-fulfillment-line-edit-reservation-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.reservation_id || '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.part_number" type="text" class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultPartNumber')" :data-testid="`review-fulfillment-line-edit-part-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else class="block max-w-[220px] truncate" :title="line.part_number || '—'">{{ line.part_number || '—' }}</span></td><td class="whitespace-nowrap px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input :value="editingLine.required_qty" type="number" min="0" step="any" class="w-20 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.requiredQty')" :data-testid="`review-fulfillment-line-edit-qty-${line.snapshot_line_id}`" @input="updateInlineEditQty(($event.target as HTMLInputElement).value)" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.required_qty ?? '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="isInlineEditing(line) && inlineSourceOptions(line).length"><select class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-fulfillment-line-edit-source-${line.snapshot_line_id}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="editingLine?.source_code" :disabled="inlineEditSaving" @change="updateInlineEditSource(($event.target as HTMLSelectElement).value)"><option v-for="option in inlineSourceOptions(line)" :key="option.value" :value="option.value">{{ option.label }}</option></select></template><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) || '—' }}</span></td><td v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2"><div v-if="(line.odm_values?.length || 0) > 1 && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-odm-${line.snapshot_line_id || lineIndex}`"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-odm-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.odmConflict.title')" :value="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || line.chosen_odm_id || ''" @change="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.odmConflict.placeholder') }}</option><option v-for="value in line.odm_values" :key="value" :value="value">{{ value }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-odm-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || lineOdmBusy" :aria-label="t('chat.shippingOrderReLine truncated
</table>
</div>
</div>
@@ -0,0 +1,227 @@
/**
* features/equipment-acceptance/api/equipment-acceptance.api.ts
* 用途:设备验收预警同步列表、详情和手动同步。
* 依赖:统一 requestJson;后端 /api/equipment-acceptance。
* 逻辑:Chat 作业面调用。同步只读 E10。配置只保存天数和系统用户,不保存发送时刻。
* 发送记录只读已落库的行,扫描尚未写入时列表为空。
*/
import { requestJson } from '@/shared/api/client';
export interface EquipmentAcceptanceNode {
node_id?: string | null;
node_name?: string | null;
node_type?: number | null;
}
export interface EquipmentAcceptanceOperator {
node_id?: string | null;
user_id?: string | null;
handler_name?: string | null;
handler_job_num?: string | null;
}
export interface EquipmentAcceptanceOrder {
id: number;
acceptance_no?: string | null;
purchase_order_no?: string | null;
contract_no?: string | null;
timer_started_at?: string | null;
dwell_days?: number | null;
can_accept?: number | null;
cannot_accept_note?: string | null;
is_returned?: number | null;
flow_status_raw?: number | null;
finished_at?: string | null;
request_id?: string | null;
request_match_count: number;
owner_name?: string | null;
owner_job_num?: string | null;
applicant_name?: string | null;
applicant_job_num?: string | null;
monitor_status: string;
overdue?: boolean;
present_in_source: boolean;
synced_at?: string | null;
nodes: EquipmentAcceptanceNode[];
operators: EquipmentAcceptanceOperator[];
}
export interface EquipmentAcceptanceSummary {
watching: number;
overdue: number;
stopped: number;
not_started: number;
}
export interface EquipmentAcceptanceListResponse {
items: EquipmentAcceptanceOrder[];
total: number;
page: number;
page_size: number;
pages: number;
summary?: EquipmentAcceptanceSummary;
}
export interface EquipmentAcceptanceSyncResult {
upserted: number;
skipped_without_request_id: number;
absent: number;
by_status: Record<string, number>;
}
/**
* 分页查询已同步的验收单。
* 核心逻辑:focus 对应原型分组。空或 all 不过滤。
* @param params.focus - watching、overdue、stopped、not_started
* @param params.page - 页码,从 1 开始
* @param params.pageSize - 每页条数
* @returns 分页快照和全部单据汇总
*/
export function listEquipmentAcceptanceOrders(params?: {
focus?: string;
page?: number;
pageSize?: number;
}) {
const query = new URLSearchParams();
if (params?.focus && params.focus !== 'all') query.set('focus', params.focus);
if (params?.page) query.set('page', String(params.page));
if (params?.pageSize) query.set('page_size', String(params.pageSize));
const suffix = query.toString() ? `?${query.toString()}` : '';
return requestJson<EquipmentAcceptanceListResponse>(`/api/equipment-acceptance/orders${suffix}`);
}
/**
* 读取一张验收单的节点和操作人。
* @param orderId - 本地快照主键
* @returns 快照详情
*/
export function getEquipmentAcceptanceOrder(orderId: number) {
return requestJson<EquipmentAcceptanceOrder>(`/api/equipment-acceptance/orders/${orderId}`);
}
/**
* 从 E10 拉取验收单并更新本地快照。仅平台管理员可调用。
* @returns 本次写入、跳过和未见条数
*/
export function syncEquipmentAcceptance() {
return requestJson<EquipmentAcceptanceSyncResult>('/api/equipment-acceptance/sync', { method: 'POST' });
}
export interface EquipmentAcceptanceScanResult {
created: number;
updated: number;
cancelled: number;
}
export interface EquipmentAcceptanceSendResult {
sent: number;
failed: number;
records_sent: number;
records_failed: number;
}
/**
* 管理员立即同步 E10 并生成待发送记录。
* @returns 新增、更新和取消条数
*/
export function scanEquipmentAcceptanceAlerts() {
return requestJson<EquipmentAcceptanceScanResult>('/api/equipment-acceptance/alerts/scan', { method: 'POST' });
}
/**
* 管理员立即把待发送记录按收件人发到企业微信。
* @returns 成功和失败的收件人数
*/
export function sendEquipmentAcceptanceAlerts() {
return requestJson<EquipmentAcceptanceSendResult>('/api/equipment-acceptance/alerts/send', { method: 'POST' });
}
export interface EquipmentAcceptanceSendRecord {
id: number;
order_id?: number | null;
acceptance_no?: string | null;
purchase_order_no?: string | null;
tier: number;
threshold_days: number;
to_text?: string | null;
cc_text?: string | null;
status: string;
sent_at?: string | null;
error_message?: string | null;
created_at?: string | null;
}
export interface EquipmentAcceptanceSendListResponse {
items: EquipmentAcceptanceSendRecord[];
total: number;
page: number;
page_size: number;
}
/**
* 分页读取发送记录。
* 核心逻辑:按创建时间倒序。还没有扫描写入时 items 为空。
* @param params.page - 从 1 开始
* @param params.pageSize - 每页条数
* @returns 当前页记录和总数
*/
export function listEquipmentAcceptanceSends(params?: { page?: number; pageSize?: number }) {
const search = new URLSearchParams();
if (params?.page) search.set('page', String(params.page));
if (params?.pageSize) search.set('page_size', String(params.pageSize));
const suffix = search.toString() ? `?${search.toString()}` : '';
return requestJson<EquipmentAcceptanceSendListResponse>(`/api/equipment-acceptance/sends${suffix}`);
}
export interface EquipmentAcceptanceConfigUser {
id: number;
username: string;
real_name?: string | null;
employee_id?: string | null;
department?: string | null;
wecom_bound?: boolean;
}
export interface EquipmentAcceptanceConfig {
days: number[];
buyer_manager_user_id?: number | null;
coo_user_id?: number | null;
executive_user_id?: number | null;
selected_users: EquipmentAcceptanceConfigUser[];
users: EquipmentAcceptanceConfigUser[];
updated_at?: string | null;
}
/**
* 读取四档天数和三个固定岗位。管理员响应里带候选人。
* @returns 当前配置
*/
export function getEquipmentAcceptanceConfig() {
return requestJson<EquipmentAcceptanceConfig>('/api/equipment-acceptance/config');
}
/**
* 保存四档天数和三个岗位的系统用户。仅平台管理员。
* 核心逻辑:岗位传用户主键或 null,不传姓名。
* @param payload.days - 四个逐档增大的天数
* @param payload.buyerManagerUserId - 采购经副理
* @param payload.cooUserId - COO
* @param payload.executiveUserId - 廖总对应岗位
* @returns 保存后的配置
*/
export function saveEquipmentAcceptanceConfig(payload: {
days: number[];
buyerManagerUserId: number | null;
cooUserId: number | null;
executiveUserId: number | null;
}) {
return requestJson<EquipmentAcceptanceConfig>('/api/equipment-acceptance/config', {
method: 'PUT',
body: JSON.stringify({
days: payload.days,
buyer_manager_user_id: payload.buyerManagerUserId,
coo_user_id: payload.cooUserId,
executive_user_id: payload.executiveUserId,
}),
});
}
@@ -0,0 +1,225 @@
<!--
features/equipment-acceptance/components/EquipmentAcceptanceChatPanel.vue
用途:设备验收预警 Chat 主区:停留列表、详情、发送记录、预警配置,以及管理员同步、扫描和发送。
依赖:停留列表、详情、发送记录、配置页、auth.store、equipment-acceptance.api、DeleteConfirmDialog、vue-router query。
逻辑:由 ChatViewContent 在 agent_code=equipment_acceptance 时替换消息列表与输入框。
view=config 打开预警配置;view=sends 打开发送记录;orderId 只在停留列表下钻。
同步只在停留列表。扫描和发送只在发送记录,且仅平台管理员可见。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { RefreshCw } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import { useAuthStore } from '@/features/auth/stores/auth.store';
import { useMessage } from '@/shared/composables/useMessage';
import {
scanEquipmentAcceptanceAlerts,
sendEquipmentAcceptanceAlerts,
syncEquipmentAcceptance,
} from '../api/equipment-acceptance.api';
import EquipmentAcceptanceConfigPage from '../views/EquipmentAcceptanceConfigPage.vue';
import EquipmentAcceptanceDetailPage from '../views/EquipmentAcceptanceDetailPage.vue';
import EquipmentAcceptancePage from '../views/EquipmentAcceptancePage.vue';
import EquipmentAcceptanceSendsPage from '../views/EquipmentAcceptanceSendsPage.vue';
type WorkspaceView = 'ledger' | 'sends' | 'config';
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const auth = useAuthStore();
const msg = useMessage();
const syncing = ref(false);
const alertRunning = ref(false);
const pendingAlert = ref<'scan' | 'send' | null>(null);
const listPage = ref<{ reload: () => Promise<void> } | null>(null);
const sendsPage = ref<{ reload: () => Promise<void> } | null>(null);
const isAdmin = computed(() => Boolean(auth.isAdmin));
const activeView = computed<WorkspaceView>(() => {
if (route.query.view === 'config') return 'config';
if (route.query.view === 'sends') return 'sends';
return 'ledger';
});
const showAlertConfirm = computed({
get: () => pendingAlert.value !== null,
set: (open: boolean) => {
if (!open) pendingAlert.value = null;
},
});
const alertConfirmCopy = computed(() => (
pendingAlert.value === 'send'
? { title: t('admin.equipmentAcceptance.sendAlerts'), message: t('admin.equipmentAcceptance.sendConfirm') }
: { title: t('admin.equipmentAcceptance.scanAlerts'), message: t('admin.equipmentAcceptance.scanConfirm') }
));
const detailId = computed(() => {
if (activeView.value !== 'ledger') return null;
const raw = Number(route.query.orderId);
return Number.isInteger(raw) && raw > 0 ? raw : null;
});
const tabs = computed(() => ([
{ key: 'ledger' as const, label: t('admin.equipmentAcceptance.tabLedger') },
{ key: 'sends' as const, label: t('admin.equipmentAcceptance.tabSends') },
{ key: 'config' as const, label: t('admin.equipmentAcceptance.tabConfig') },
]));
/**
* 把当前 Tab 和详情写入 Chat 路由。
* 核心逻辑:配置和发送记录清掉 orderId。停留列表不写 view,避免旧链接被改掉。
* @param view - ledger、sends 或 config
* @param orderId - 本地快照主键,空表示列表
*/
async function syncQuery(view: WorkspaceView, orderId: number | null): Promise<void> {
const query = { ...route.query };
if (view === 'config' || view === 'sends') {
query.view = view;
delete query.orderId;
} else {
delete query.view;
if (orderId) query.orderId = String(orderId);
else delete query.orderId;
}
const sameView = String(route.query.view || '') === String(query.view || '');
const sameOrder = String(route.query.orderId || '') === String(query.orderId || '');
if (sameView && sameOrder) return;
await router.replace({ params: { ...route.params }, query });
}
/**
* 切换停留列表、发送记录和预警配置。
* @param view - 目标 Tab
*/
function selectView(view: WorkspaceView): void {
void syncQuery(view, null);
}
/**
* 管理员在发送记录页立即扫描或发送。
* 核心逻辑:公共确认框点确定后才调用。先取出动作再关掉弹窗,避免关闭时把待执行动作清掉。
*/
function confirmAlertAction(): void {
const action = pendingAlert.value;
pendingAlert.value = null;
if (action) void runAlertAction(action);
}
/**
* 执行已经确认的扫描或发送。
* 核心逻辑:扫描会同步 E10;发送把待发送记录推到企业微信。
* @param action - scan 或 send
*/
async function runAlertAction(action: 'scan' | 'send'): Promise<void> {
if (alertRunning.value) return;
alertRunning.value = true;
try {
if (action === 'scan') {
const result = await scanEquipmentAcceptanceAlerts();
msg.success(t('admin.equipmentAcceptance.scanDone', {
created: result.created,
updated: result.updated,
cancelled: result.cancelled,
}));
} else {
const result = await sendEquipmentAcceptanceAlerts();
msg.success(t('admin.equipmentAcceptance.sendDone', {
sent: result.sent,
failed: result.failed,
}));
}
await sendsPage.value?.reload();
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.syncFailed'));
} finally {
alertRunning.value = false;
}
}
/**
* 管理员从 E10 同步后刷新列表。
* 核心逻辑:成功提示写入、跳过和本次未见条数。失败展示业务错误。
*/
async function runSync(): Promise<void> {
if (syncing.value) return;
syncing.value = true;
try {
const result = await syncEquipmentAcceptance();
msg.success(t('admin.equipmentAcceptance.syncDone', {
upserted: result.upserted,
skipped: result.skipped_without_request_id,
absent: result.absent,
}));
await listPage.value?.reload();
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.syncFailed'));
} finally {
syncing.value = false;
}
}
</script>
<template>
<section class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[var(--surface-muted,#f4f7fb)]">
<div class="flex flex-wrap items-center justify-between gap-2 px-5 pt-3">
<div class="min-w-0">
<h1 class="text-lg font-bold text-primary md:text-xl">{{ t('admin.equipmentAcceptance.title') }}</h1>
</div>
<div v-if="isAdmin && activeView === 'sends'" class="flex flex-wrap items-center gap-2">
<button class="btn-secondary-ds" type="button" :disabled="alertRunning" @click="pendingAlert = 'scan'">
{{ t('admin.equipmentAcceptance.scanAlerts') }}
</button>
<button class="btn-secondary-ds" type="button" :disabled="alertRunning" @click="pendingAlert = 'send'">
{{ t('admin.equipmentAcceptance.sendAlerts') }}
</button>
</div>
<button
v-if="isAdmin && activeView === 'ledger' && !detailId"
class="btn-secondary-ds"
type="button"
:disabled="syncing"
@click="runSync"
>
<RefreshCw class="h-4 w-4" aria-hidden="true" />{{ t('admin.equipmentAcceptance.sync') }}
</button>
</div>
<div class="mt-2 flex gap-0 border-b border-default px-5">
<button
v-for="tab in tabs"
:key="tab.key"
type="button"
class="mb-[-1px] border-b-2 px-3 py-2 text-sm font-bold"
:class="activeView === tab.key
? 'border-brand-500 text-brand-600'
: 'border-transparent text-muted hover:text-secondary'"
@click="selectView(tab.key)"
>
{{ tab.label }}
</button>
</div>
<EquipmentAcceptanceDetailPage
v-if="detailId"
:order-id="detailId"
@back="syncQuery('ledger', null)"
/>
<EquipmentAcceptanceConfigPage
v-else-if="activeView === 'config'"
:editable="isAdmin"
/>
<EquipmentAcceptanceSendsPage v-else-if="activeView === 'sends'" ref="sendsPage" />
<EquipmentAcceptancePage
v-else
ref="listPage"
@open-detail="syncQuery('ledger', $event)"
/>
<DeleteConfirmDialog
v-if="isAdmin"
v-model="showAlertConfirm"
:title="alertConfirmCopy.title"
:message="alertConfirmCopy.message"
confirm-tone="primary"
@confirm="confirmAlertAction"
/>
</section>
</template>
@@ -0,0 +1,272 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptanceConfigPage.vue
用途:设备验收预警配置页。编辑四档天数,并为三个固定岗位选择系统用户。
依赖:equipment-acceptance.api、UserPickerDialog、userPicker.utils、vue-i18n。
逻辑:由 Chat 作业面的「预警配置」Tab 嵌入。姓名只用于展示。
发送时刻不在本页,由排程 Cron 配置。非管理员只能查看。
-->
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import UserPickerDialog from '@/shared/components/UserPickerDialog.vue';
import { useMessage } from '@/shared/composables/useMessage';
import { userPickerLabel } from '@/shared/utils/userPicker.utils';
import type { UserPickerPerson } from '@/shared/types/userPicker.types';
import {
getEquipmentAcceptanceConfig,
saveEquipmentAcceptanceConfig,
} from '../api/equipment-acceptance.api';
const props = defineProps<{
editable: boolean;
}>();
type RoleKey = 'buyer_manager' | 'coo' | 'executive';
const ROLE_FIELDS: RoleKey[] = ['buyer_manager', 'coo', 'executive'];
const TIER_WHO = ['tierWho1', 'tierWho2', 'tierWho3', 'tierWho4'] as const;
const { t } = useI18n();
const msg = useMessage();
const loading = ref(false);
const saving = ref(false);
const days = ref<number[]>([30, 37, 44, 51]);
const roleIds = ref<Record<RoleKey, number | null>>({
buyer_manager: null,
coo: null,
executive: null,
});
const candidates = ref<UserPickerPerson[]>([]);
const knownUsers = ref<UserPickerPerson[]>([]);
const pickerOpen = ref(false);
const pickerRole = ref<RoleKey | null>(null);
const people = computed(() => {
const map = new Map<number, UserPickerPerson>();
for (const user of candidates.value) map.set(user.id, user);
for (const user of knownUsers.value) map.set(user.id, user);
return map;
});
const pickerSelectedIds = computed(() => {
const id = pickerRole.value ? roleIds.value[pickerRole.value] : null;
return id ? [id] : [];
});
const ruleRows = computed(() => ([
{ to: 'ruleTo1', cc: 'ruleCc1' },
{ to: 'ruleTo2', cc: 'ruleCc2' },
{ to: 'ruleTo3', cc: 'ruleCc3' },
{ to: 'ruleTo4', cc: 'ruleCc4' },
]));
/**
* 读取当前配置。管理员响应里包含候选人。
* 核心逻辑:失败时保留页面上的默认天数,并用统一错误提示。
*/
async function load(): Promise<void> {
loading.value = true;
try {
const result = await getEquipmentAcceptanceConfig();
days.value = result.days?.length === 4 ? [...result.days] : [30, 37, 44, 51];
roleIds.value = {
buyer_manager: result.buyer_manager_user_id ?? null,
coo: result.coo_user_id ?? null,
executive: result.executive_user_id ?? null,
};
candidates.value = result.users || [];
knownUsers.value = result.selected_users || [];
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.configLoadFailed'));
} finally {
loading.value = false;
}
}
/**
* 打开某个岗位的选人弹窗。每个岗位只保留最后选中的一人。
* @param role - buyer_manager、coo、executive
*/
function openPicker(role: RoleKey): void {
if (!props.editable) return;
pickerRole.value = role;
pickerOpen.value = true;
}
/**
* 把弹窗结果写回当前岗位。选了多人时只留最后一人。
* @param ids - 弹窗确定时的用户主键
*/
function applyPicker(ids: number[]): void {
const role = pickerRole.value;
if (!role) return;
roleIds.value[role] = ids[ids.length - 1] ?? null;
pickerRole.value = null;
}
/**
* 清空一个岗位,保存后表示该岗位未配置。
* @param role - 岗位键
*/
function clearRole(role: RoleKey): void {
roleIds.value[role] = null;
}
/**
* 保存天数和三个岗位。天数须逐档增大。
* 核心逻辑:先在页面拦住空值和倒序,服务端再校验用户是否存在。
*/
async function save(): Promise<void> {
if (!props.editable || saving.value) return;
const nextDays = days.value.map((day) => Number(day));
const [first, second, third, fourth] = nextDays;
const increases = first !== undefined && second !== undefined && third !== undefined && fourth !== undefined
&& first < second && second < third && third < fourth;
if (nextDays.some((day) => !Number.isInteger(day) || day < 1) || !increases) {
msg.error(t('admin.equipmentAcceptance.configDaysInvalid'));
return;
}
saving.value = true;
try {
const result = await saveEquipmentAcceptanceConfig({
days: nextDays,
buyerManagerUserId: roleIds.value.buyer_manager,
cooUserId: roleIds.value.coo,
executiveUserId: roleIds.value.executive,
});
days.value = [...result.days];
knownUsers.value = result.selected_users || [];
candidates.value = result.users || [];
msg.success(t('admin.equipmentAcceptance.configSaved'));
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.configSaveFailed'));
} finally {
saving.value = false;
}
}
/**
* 岗位上已选用户的展示名。没有选择时返回空串,模板改显示未选择。
* @param role - 岗位键
* @returns 姓名,有工号时附在后面
*/
function roleLabel(role: RoleKey): string {
const id = roleIds.value[role];
if (!id) return '';
return userPickerLabel(people.value.get(id), id);
}
onMounted(() => {
void load();
});
</script>
<template>
<section class="min-h-0 flex-1 overflow-auto px-5 pb-6 pt-3">
<p class="mb-3 text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.configLead') }}</p>
<p v-if="loading" class="text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.loading') }}</p>
<template v-else>
<div class="grid grid-cols-4 gap-3">
<label
v-for="(who, index) in TIER_WHO"
:key="who"
class="rounded-xl border border-[#dce4ef] border-t-[3px] bg-white px-3 py-3"
:class="index === 0 ? 'border-t-[#93c5fd]' : index === 1 ? 'border-t-[#2563eb]' : index === 2 ? 'border-t-[#d97706]' : 'border-t-[#dc2626]'"
>
<span class="block text-xs font-bold text-[#64748b]">{{ t(`admin.equipmentAcceptance.tier${index + 1}`) }}</span>
<span class="mt-2 flex items-center gap-2">
<input
v-model.number="days[index]"
class="h-11 w-16 rounded-lg border border-[#d7dee8] bg-[#f8fafc] text-center text-xl font-bold text-[#142033] disabled:opacity-70"
type="number"
min="1"
:disabled="!editable"
/>
<span class="text-sm font-semibold text-[#94a3b8]">{{ t('admin.equipmentAcceptance.dayUnit') }}</span>
</span>
<span class="mt-2 block text-xs font-bold text-[#334155]">{{ t(`admin.equipmentAcceptance.${who}`) }}</span>
</label>
</div>
<div class="mt-3 grid gap-3 lg:grid-cols-2">
<article class="rounded-xl border border-[#dce4ef] bg-white">
<h2 class="px-4 pt-4 text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.fixedRoles') }}</h2>
<div class="px-4 pb-2">
<div
v-for="role in ROLE_FIELDS"
:key="role"
class="grid grid-cols-[108px_minmax(0,1fr)] items-center gap-3 border-b border-[#dce4ef] py-3 last:border-b-0"
>
<span class="text-sm font-bold text-[#334155]">{{ t(`admin.equipmentAcceptance.role.${role}`) }}</span>
<div class="flex min-w-0 flex-wrap items-center gap-2">
<span v-if="roleLabel(role)" class="truncate text-sm text-[#142033]">{{ roleLabel(role) }}</span>
<span v-else class="text-sm text-[#94a3b8]">{{ t('admin.equipmentAcceptance.roleEmpty') }}</span>
<button
v-if="editable"
class="ml-auto rounded-lg border border-[#bfdbfe] bg-[#eaf2ff] px-2.5 py-1 text-xs font-bold text-[#1d4ed8]"
type="button"
@click="openPicker(role)"
>
{{ t('admin.equipmentAcceptance.selectUser') }}
</button>
<button
v-if="editable && roleIds[role]"
class="text-xs font-bold text-[#64748b]"
type="button"
@click="clearRole(role)"
>
{{ t('admin.equipmentAcceptance.clearUser') }}
</button>
</div>
</div>
</div>
<div class="flex items-center justify-between gap-3 border-t border-[#dce4ef] bg-[#fafbfd] px-4 py-3">
<span class="text-xs text-[#64748b]">{{ editable ? t('admin.equipmentAcceptance.configSaveHint') : t('admin.equipmentAcceptance.configReadOnly') }}</span>
<button
v-if="editable"
class="rounded-lg bg-[#2563eb] px-3 py-1.5 text-xs font-bold text-white disabled:opacity-50"
type="button"
:disabled="saving"
@click="save"
>
{{ t('admin.equipmentAcceptance.saveConfig') }}
</button>
</div>
</article>
<article class="overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
<div class="px-4 pt-4">
<h2 class="text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.rulesTitle') }}</h2>
<p class="mt-1 text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.rulesLead') }}</p>
</div>
<table class="mt-3 w-full border-collapse text-left text-xs">
<thead class="bg-[#f8fbff] text-[#64748b]">
<tr>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTier') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleCc') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="(row, index) in ruleRows" :key="row.to" class="border-t border-[#dce4ef]">
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.ruleOver', { days: days[index] || '—' }) }}</td>
<td class="px-3 py-2.5">{{ t(`admin.equipmentAcceptance.${row.to}`) }}</td>
<td class="px-3 py-2.5">{{ t(`admin.equipmentAcceptance.${row.cc}`) }}</td>
</tr>
</tbody>
</table>
</article>
</div>
</template>
<UserPickerDialog
v-model="pickerOpen"
:users="candidates"
:selected-ids="pickerSelectedIds"
:title="t('admin.equipmentAcceptance.selectUser')"
:subtitle="t('admin.equipmentAcceptance.configPickOne')"
@confirm="applyPicker"
/>
</section>
</template>
@@ -0,0 +1,314 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptanceDetailPage.vue
用途:一张验收单的详情卡片,展示状态徽章、停留进度、当前节点和操作人。
依赖:equipment-acceptance.api、vue-i18n、统一消息提示。
逻辑:由 Chat 作业面在选中某行后展示。操作人只显示姓名和工号。
进度条只按签核天数画到 30/37/44/51,不表示已经发送。
-->
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import {
getEquipmentAcceptanceOrder,
type EquipmentAcceptanceOrder,
} from '../api/equipment-acceptance.api';
const props = defineProps<{
orderId: number;
}>();
const emit = defineEmits<{
back: [];
}>();
type BadgeTone = 'red' | 'green' | 'gray';
const STOPPED_STATUSES = new Set([
'stopped_returned',
'stopped_cannot_accept',
'stopped_archived',
'stopped_force_finished',
'stopped_voided',
'stopped_revoked',
]);
const FLOW_STATUS_KEYS: Record<number, string> = {
0: 'draft',
1: 'approving',
3: 'archived',
4: 'forceFinished',
5: 'voided',
6: 'pendingSubmit',
7: 'withdrawn',
8: 'withdrawn',
99: 'withdrawn',
[-99]: 'withdrawn',
};
const REMINDER_DAYS = [30, 37, 44, 51];
const { t } = useI18n();
const msg = useMessage();
const loading = ref(false);
const order = ref<EquipmentAcceptanceOrder | null>(null);
/**
* 读取当前验收单详情。
* 核心逻辑:orderId 变化时重新请求。失败清空详情,避免上一张单残留。
*/
async function load(): Promise<void> {
loading.value = true;
try {
order.value = await getEquipmentAcceptanceOrder(props.orderId);
} catch (error) {
order.value = null;
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.detailLoadFailed'));
} finally {
loading.value = false;
}
}
/**
* 只取日期部分。没有值时显示横线。
* @param value - 接口时间字符串
* @returns 日期文本
*/
function dateText(value?: string | null): string {
if (!value) return '—';
return value.slice(0, 10);
}
/**
* 把 0/1 写成否/是。可以验收为空时显示未标明,退回在同步时已把空收成否。
* @param value - 标准 0 否、1 是
* @param emptyLabel - 空值文案
* @returns 展示文案
*/
function yesNo(value: number | null | undefined, emptyLabel: string): string {
if (value === 1) return t('common.yes');
if (value === 0) return t('common.no');
return emptyLabel;
}
/**
* 把流程状态原值写成名称。7、8、99、-99 都显示为撤销,字典没有的数字仍显示原值。
* @param value - flowstatus
* @returns 流程状态文案
*/
function flowText(value?: number | null): string {
if (value === undefined || value === null) return '—';
const key = FLOW_STATUS_KEYS[value];
return key ? t(`admin.equipmentAcceptance.flowStatusName.${key}`) : String(value);
}
/**
* 未开始或没有天数时显示横线,其余显示「N 天」。
* @param item - 当前验收单
* @returns 签核天数文案
*/
function dwellText(item: EquipmentAcceptanceOrder): string {
if (item.monitor_status === 'not_started' || item.dwell_days == null) return '—';
return t('admin.equipmentAcceptance.daysValue', { days: item.dwell_days });
}
/**
* 当前节点名称。没有节点时为空,模板改显示横线。
* @param item - 当前验收单
* @returns 节点名称列表
*/
function nodeNames(item: EquipmentAcceptanceOrder): string[] {
return (item.nodes || []).map((node) => node.node_name).filter((name): name is string => Boolean(name));
}
/**
* 当前处理人去重后拼成一行。
* @param item - 当前验收单
* @returns 处理人姓名
*/
function handlerNames(item: EquipmentAcceptanceOrder): string {
const names = Array.from(new Set(
(item.operators || []).map((person) => person.handler_name).filter((name): name is string => Boolean(name)),
));
return names.length ? names.join('、') : '—';
}
/**
* 与列表相同的徽章颜色。红是已逾期,绿是不再提醒,灰是未开始和未超时。
* @param item - 当前验收单
* @returns 文案和颜色
*/
function statusBadge(item: EquipmentAcceptanceOrder): { label: string; tone: BadgeTone } {
if (item.monitor_status === 'watching' && item.overdue) {
return { label: t('admin.equipmentAcceptance.badgeOverdue'), tone: 'red' };
}
if (item.monitor_status === 'watching') {
return { label: t('admin.equipmentAcceptance.badgeOnTime'), tone: 'gray' };
}
return {
label: t(`admin.equipmentAcceptance.statusLabel.${item.monitor_status}`),
tone: STOPPED_STATUSES.has(item.monitor_status) ? 'green' : 'gray',
};
}
/**
* 徽章底色。
* @param tone - 徽章颜色
* @returns Tailwind 类名
*/
function badgeClass(tone: BadgeTone): string {
if (tone === 'red') return 'bg-[#fff0ef] text-[#b42318]';
if (tone === 'green') return 'bg-[#eafaf1] text-[#067647]';
return 'bg-[#edf1f6] text-[#475569]';
}
/**
* 按签核天数在 0 到第 4 档之间画进度。没有天数时不画。
* 核心逻辑:刻度至少到 60 天,避免 51 天贴在条的尽头。
*/
const track = computed(() => {
const days = order.value?.dwell_days;
if (order.value?.monitor_status === 'not_started' || days == null) return null;
const lastMark = REMINDER_DAYS[REMINDER_DAYS.length - 1] ?? 51;
const scale = Math.max(60, lastMark + 9, days);
return {
width: `${Math.min(100, Math.round((days / scale) * 100))}%`,
marks: [0, ...REMINDER_DAYS, scale].map((day) => ({
day,
left: `${(day / scale) * 100}%`,
label: day === scale ? t('admin.equipmentAcceptance.daysValue', { days: scale }) : String(day),
})),
};
});
onMounted(() => {
void load();
});
watch(() => props.orderId, () => {
void load();
});
</script>
<template>
<section class="min-h-0 flex-1 overflow-auto px-5 pb-6 pt-3">
<button
class="mb-3 rounded-lg border border-[#dce4ef] bg-white px-3 py-1.5 text-xs font-bold text-[#142033]"
type="button"
@click="emit('back')"
>
{{ t('admin.equipmentAcceptance.back') }}
</button>
<p v-if="loading && !order" class="text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.loading') }}</p>
<article v-else-if="order" class="overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
<div class="flex items-start justify-between gap-3 px-4 pt-4">
<h2 class="text-lg font-bold text-[#142033]">{{ order.acceptance_no || '—' }}</h2>
<span
class="inline-flex shrink-0 rounded-full px-2 py-0.5 text-[11px] font-extrabold"
:class="badgeClass(statusBadge(order).tone)"
>
{{ statusBadge(order).label }}
</span>
</div>
<div v-if="track" class="px-7 pt-5">
<div class="h-2 overflow-hidden rounded-full bg-[#e7edf5]">
<i class="block h-full rounded-full bg-gradient-to-r from-[#93c5fd] to-[#2563eb]" :style="{ width: track.width }"></i>
</div>
<div class="relative mt-1 h-4 text-[11px] text-[#64748b]">
<span
v-for="mark in track.marks"
:key="mark.day"
class="absolute -translate-x-1/2 whitespace-nowrap"
:style="{ left: mark.left }"
>
{{ mark.label }}
</span>
</div>
</div>
<div class="flex flex-wrap gap-1.5 px-4 pb-1 pt-4">
<span
v-for="(name, index) in nodeNames(order)"
:key="`${name}-${index}`"
class="rounded-full bg-[#dbeafe] px-2 py-1 text-[11px] font-extrabold text-[#1d4ed8]"
>
{{ name }}
</span>
<span v-if="!nodeNames(order).length" class="text-sm text-[#64748b]">—</span>
</div>
<dl class="mt-3 grid border-t border-[#dce4ef] px-4 sm:grid-cols-2">
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.purchaseOrderNo') }}</dt>
<dd class="text-[#142033]">{{ order.purchase_order_no || '—' }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.applicant') }}</dt>
<dd class="text-[#142033]">{{ order.applicant_name || '—' }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.dwellDays') }}</dt>
<dd class="text-[#142033]">{{ dwellText(order) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.timerStart') }}</dt>
<dd class="text-[#142033]">{{ dateText(order.timer_started_at) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:col-span-2">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.currentHandlers') }}</dt>
<dd class="text-[#142033]">{{ handlerNames(order) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.canAccept') }}</dt>
<dd class="text-[#142033]">{{ yesNo(order.can_accept, t('admin.equipmentAcceptance.unspecified')) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:col-span-2">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.cannotAcceptNote') }}</dt>
<dd class="whitespace-pre-wrap text-[#142033]">{{ order.cannot_accept_note || '—' }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.returnFlag') }}</dt>
<dd class="text-[#142033]">{{ yesNo(order.is_returned, t('common.no')) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.flowStatus') }}</dt>
<dd class="text-[#142033]">{{ flowText(order.flow_status_raw) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.finishedAt') }}</dt>
<dd class="text-[#142033]">{{ dateText(order.finished_at) }}</dd>
</div>
</dl>
<div class="px-4 pb-4 pt-4">
<h3 class="text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.operators') }}</h3>
<p class="mt-1 text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.operatorsNote') }}</p>
<div class="mt-3 overflow-auto rounded-xl border border-[#dce4ef]">
<table class="w-full min-w-[640px] border-collapse text-left text-xs">
<thead class="bg-[#f8fbff] text-[#64748b]">
<tr>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.operatorName') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.jobNum') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="(item, index) in order.operators"
:key="`${item.user_id}-${item.node_id}-${index}`"
class="border-t border-[#dce4ef]"
>
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ item.handler_name || '—' }}</td>
<td class="px-3 py-2.5">{{ item.handler_job_num || '—' }}</td>
</tr>
<tr v-if="!order.operators.length">
<td colspan="2" class="px-3 py-6 text-center text-[#64748b]">—</td>
</tr>
</tbody>
</table>
</div>
</div>
</article>
</section>
</template>
@@ -0,0 +1,264 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptancePage.vue
用途:设备验收预警停留列表,对齐原型的汇总卡、分组筛选和状态徽章。
依赖:equipment-acceptance.api、PaginationBar、统一消息提示、vue-i18n。
逻辑:由 Chat 作业面嵌入。点「查看详情」交给父级下钻。
已逾期只看接口给出的 overdue。发送结果在「发送记录」页,这里不显示第几档。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import { useMessage } from '@/shared/composables/useMessage';
import {
listEquipmentAcceptanceOrders,
type EquipmentAcceptanceOrder,
type EquipmentAcceptanceSummary,
} from '../api/equipment-acceptance.api';
const emit = defineEmits<{
'open-detail': [orderId: number];
}>();
type FocusKey = 'all' | 'watching' | 'overdue' | 'stopped' | 'not_started';
type BadgeTone = 'red' | 'green' | 'gray';
const STOPPED_STATUSES = new Set([
'stopped_returned',
'stopped_cannot_accept',
'stopped_archived',
'stopped_force_finished',
'stopped_voided',
'stopped_revoked',
]);
const filters: Array<{ key: FocusKey; label: string }> = [
{ key: 'all', label: 'filterAll' },
{ key: 'watching', label: 'filterWatching' },
{ key: 'overdue', label: 'filterOverdue' },
{ key: 'stopped', label: 'filterStopped' },
{ key: 'not_started', label: 'filterNotStarted' },
];
const { t } = useI18n();
const msg = useMessage();
const loading = ref(false);
const orders = ref<EquipmentAcceptanceOrder[]>([]);
const focus = ref<FocusKey>('all');
const page = ref(1);
const pageSize = ref(20);
const total = ref(0);
const pages = ref(1);
const summary = ref<EquipmentAcceptanceSummary>({
watching: 0,
overdue: 0,
stopped: 0,
not_started: 0,
});
/**
* 加载当前分组的验收单,并刷新全部单据的汇总数字。
* 核心逻辑:汇总不受当前筛选影响,由接口的 summary 给出。
* @param resetPage - 为 true 时回到第一页,用于更换筛选。
*/
async function load(resetPage = false): Promise<void> {
if (resetPage) page.value = 1;
loading.value = true;
try {
const result = await listEquipmentAcceptanceOrders({
focus: focus.value,
page: page.value,
pageSize: pageSize.value,
});
orders.value = result.items || [];
total.value = result.total || 0;
pages.value = result.pages || 1;
if (result.summary) summary.value = result.summary;
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.loadFailed'));
} finally {
loading.value = false;
}
}
/**
* 切换原型分组并回到第一页。
* @param next - all、watching、overdue、stopped、not_started
*/
function selectFocus(next: FocusKey): void {
if (focus.value === next) return;
focus.value = next;
void load(true);
}
/**
* 把节点名称拼成一格。没有节点时显示横线。
* @param order - 列表行
* @returns 节点名称
*/
function nodeNames(order: EquipmentAcceptanceOrder): string {
const names = (order.nodes || []).map((node) => node.node_name).filter((name): name is string => Boolean(name));
return names.length ? names.join('、') : '—';
}
/**
* 把当前处理人姓名去重后拼成一格。这些人不一定是未办。
* @param order - 列表行
* @returns 处理人姓名
*/
function handlerNames(order: EquipmentAcceptanceOrder): string {
const names = Array.from(new Set(
(order.operators || []).map((item) => item.handler_name).filter((name): name is string => Boolean(name)),
));
return names.length ? names.join('、') : '—';
}
/**
* 只取日期部分展示计时起点。
* @param value - 接口返回的时间字符串
* @returns 日期或横线
*/
function dateText(value?: string | null): string {
if (!value) return '—';
return value.slice(0, 10);
}
/**
* 未开始或没有天数时显示横线,其余显示「N 天」。
* @param order - 列表行
* @returns 签核天数文案
*/
function dwellText(order: EquipmentAcceptanceOrder): string {
if (order.monitor_status === 'not_started' || order.dwell_days == null) return '—';
return t('admin.equipmentAcceptance.daysValue', { days: order.dwell_days });
}
/**
* 按监控状态收成徽章。已逾期用红色,表示还要提醒。不再提醒用绿色,未开始和未超时用灰色。
* @param order - 列表行
* @returns 文案和颜色
*/
function statusBadge(order: EquipmentAcceptanceOrder): { label: string; tone: BadgeTone } {
if (order.monitor_status === 'watching' && order.overdue) {
return { label: t('admin.equipmentAcceptance.badgeOverdue'), tone: 'red' };
}
if (order.monitor_status === 'watching') {
return { label: t('admin.equipmentAcceptance.badgeOnTime'), tone: 'gray' };
}
return {
label: t(`admin.equipmentAcceptance.statusLabel.${order.monitor_status}`),
tone: STOPPED_STATUSES.has(order.monitor_status) ? 'green' : 'gray',
};
}
/**
* 徽章底色。红是已逾期,绿是不再提醒,灰是未超时、未开始和不在监控范围。
* @param tone - 徽章颜色
* @returns Tailwind 类名
*/
function badgeClass(tone: BadgeTone): string {
if (tone === 'red') return 'bg-[#fff0ef] text-[#b42318]';
if (tone === 'green') return 'bg-[#eafaf1] text-[#067647]';
return 'bg-[#edf1f6] text-[#475569]';
}
defineExpose({ reload: () => load(false) });
onMounted(() => {
void load();
});
</script>
<template>
<section class="flex min-h-0 flex-1 flex-col gap-3 px-5 pb-4 pt-3">
<div class="grid grid-cols-4 gap-3">
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.watching }}</b>
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.kpiWatching') }}</span>
</article>
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.overdue }}</b>
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.kpiOverdue') }}</span>
</article>
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.stopped }}</b>
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.kpiStopped') }}</span>
</article>
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.not_started }}</b>
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.filterNotStarted') }}</span>
</article>
</div>
<div class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
<div class="flex flex-wrap gap-2 p-3">
<button
v-for="item in filters"
:key="item.key"
type="button"
class="rounded-full border px-2.5 py-1 text-xs font-bold"
:class="focus === item.key
? 'border-[#bfdbfe] bg-[#eaf2ff] text-[#1d4ed8]'
: 'border-[#dce4ef] bg-white text-[#475569]'"
@click="selectFocus(item.key)"
>
{{ t(`admin.equipmentAcceptance.${item.label}`) }}
</button>
</div>
<div class="min-h-0 flex-1 overflow-auto">
<table class="min-w-[960px] w-full border-collapse text-left text-xs">
<thead class="sticky top-0 bg-[#f8fbff] text-[#64748b]">
<tr>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.acceptanceNo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.purchaseOrderNo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.applicant') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.currentNodes') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.currentHandlers') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.timerStart') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.dwellDays') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.status') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.actions') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="item in orders" :key="item.id" class="border-b border-[#dce4ef] hover:bg-[#f3f7ff]">
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ item.acceptance_no || '—' }}</td>
<td class="px-3 py-2.5">{{ item.purchase_order_no || '—' }}</td>
<td class="px-3 py-2.5">{{ item.applicant_name || '—' }}</td>
<td class="px-3 py-2.5">{{ nodeNames(item) }}</td>
<td class="px-3 py-2.5">{{ handlerNames(item) }}</td>
<td class="px-3 py-2.5">{{ dateText(item.timer_started_at) }}</td>
<td class="px-3 py-2.5">{{ dwellText(item) }}</td>
<td class="px-3 py-2.5">
<span
class="inline-flex rounded-full px-2 py-0.5 text-[11px] font-extrabold"
:class="badgeClass(statusBadge(item).tone)"
>
{{ statusBadge(item).label }}
</span>
</td>
<td class="px-3 py-2.5">
<button class="font-extrabold text-[#175cd3]" type="button" @click="emit('open-detail', item.id)">
{{ t('admin.equipmentAcceptance.detail') }}
</button>
</td>
</tr>
<tr v-if="!loading && !orders.length">
<td colspan="9" class="px-3 py-9 text-center text-[#64748b]">{{ t('admin.equipmentAcceptance.empty') }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<PaginationBar
class="shrink-0"
v-model:page="page"
v-model:page-size="pageSize"
:total="total"
:pages="pages"
@update:page="() => load()"
@update:page-size="() => load()"
/>
</section>
</template>
@@ -0,0 +1,137 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptanceSendsPage.vue
用途:设备验收预警发送记录页,列出每张验收单某一档的主送、抄送和结果。
依赖:equipment-acceptance.api、PaginationBar、统一消息提示、vue-i18n。
逻辑:由 Chat 作业面的「发送记录」Tab 嵌入。只读已落库记录。扫描尚未写入时显示空状态。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import { useMessage } from '@/shared/composables/useMessage';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import {
listEquipmentAcceptanceSends,
type EquipmentAcceptanceSendRecord,
} from '../api/equipment-acceptance.api';
const { t, te } = useI18n();
const msg = useMessage();
const records = ref<EquipmentAcceptanceSendRecord[]>([]);
const loading = ref(false);
const page = ref(1);
const pageSize = ref(20);
const total = ref(0);
const pages = ref(1);
/**
* 拉取当前页发送记录。
* 核心逻辑:失败时清空表格并提示。空列表留给模板显示「还没有发送记录」。
*/
async function load(): Promise<void> {
loading.value = true;
try {
const result = await listEquipmentAcceptanceSends({ page: page.value, pageSize: pageSize.value });
records.value = result.items || [];
total.value = result.total || 0;
pages.value = Math.max(1, Math.ceil(total.value / pageSize.value));
} catch (error) {
records.value = [];
total.value = 0;
pages.value = 1;
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.sendsFailed'));
} finally {
loading.value = false;
}
}
/**
* 轮次列写成「超过 N 天」。
* @param item - 一条发送记录
* @returns 轮次文案
*/
function tierText(item: EquipmentAcceptanceSendRecord): string {
return t('admin.equipmentAcceptance.ruleOver', { days: item.threshold_days });
}
/**
* 结果用已知状态文案。未知状态保留原值。
* @param status - pending、sent、failed、cancelled
* @returns 结果文案
*/
function statusText(status: string): string {
const key = `admin.equipmentAcceptance.sendStatus.${status}`;
return te(key) ? t(key) : status;
}
/**
* 已发送显示本地时间,待发送没有时间时显示横线。
* @param value - 接口返回的发送时间
* @returns 时间或横线
*/
function sentText(value?: string | null): string {
if (!value) return '—';
const text = formatLocalDateTime(value);
return text === '-' ? '—' : text;
}
onMounted(() => {
void load();
});
defineExpose({ reload: load });
</script>
<template>
<section class="flex min-h-0 flex-1 flex-col gap-3 px-5 pb-4 pt-3">
<p class="text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.sendsLead') }}</p>
<div class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
<div class="min-h-0 flex-1 overflow-auto">
<table class="min-w-[960px] w-full border-collapse text-left text-xs">
<thead class="sticky top-0 bg-[#f8fbff] text-[#64748b]">
<tr>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.acceptanceNo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.purchaseOrderNo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTier') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleCc') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.sendResult') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.sentAt') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="item in records" :key="item.id" class="border-b border-[#dce4ef]">
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ item.acceptance_no || '—' }}</td>
<td class="px-3 py-2.5">{{ item.purchase_order_no || '—' }}</td>
<td class="px-3 py-2.5">{{ tierText(item) }}</td>
<td class="px-3 py-2.5">{{ item.to_text || '—' }}</td>
<td class="px-3 py-2.5">{{ item.cc_text || '—' }}</td>
<td class="px-3 py-2.5">
{{ statusText(item.status) }}
<span v-if="item.error_message" class="mt-1 block text-[#b42318]">
{{ item.error_message }}
</span>
</td>
<td class="px-3 py-2.5">{{ sentText(item.sent_at) }}</td>
</tr>
<tr v-if="!loading && !records.length">
<td colspan="7" class="px-3 py-10 text-center text-[#64748b]">
{{ t('admin.equipmentAcceptance.sendsEmpty') }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
<PaginationBar
class="shrink-0"
v-model:page="page"
v-model:page-size="pageSize"
:total="total"
:pages="pages"
@update:page="() => load()"
@update:page-size="() => load()"
/>
</section>
</template>