feat: 出库上链菜单按登记/上链状态动态切换标题与只读回填
This commit is contained in:
@@ -144,28 +144,68 @@
|
||||
</template>
|
||||
</n-modal>
|
||||
|
||||
<n-modal v-model:show="outboundModal" preset="card" :title="t('pages.traceCode.registerOutbound')" style="width: 620px">
|
||||
<n-modal v-model:show="outboundModal" preset="card" :title="outboundModalTitle" style="width: 620px">
|
||||
<n-form :model="outboundForm" label-placement="top">
|
||||
<n-grid :cols="2" :x-gap="16">
|
||||
<n-form-item-gi :label="t('pages.outbound.outTime')">
|
||||
<n-date-picker v-model:formatted-value="outboundForm.outTime" value-format="yyyy-MM-dd HH:mm" type="datetime" clearable style="width: 100%" />
|
||||
<n-date-picker v-if="!outboundReadonly" v-model:formatted-value="outboundForm.outTime" value-format="yyyy-MM-dd HH:mm" type="datetime" clearable style="width: 100%" />
|
||||
<n-text v-else>{{ outboundForm.outTime || '-' }}</n-text>
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('common.label.remark')">
|
||||
<n-input v-model:value="outboundForm.remark" />
|
||||
<n-input v-if="!outboundReadonly" v-model:value="outboundForm.remark" />
|
||||
<n-text v-else>{{ outboundForm.remark || '-' }}</n-text>
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
<n-form-item :label="t('pages.outbound.outImage')">
|
||||
<media-upload v-model="outImages" type="image" :max="8" />
|
||||
<media-upload v-if="!outboundReadonly || outImages.length" v-model="outImages" type="image" :max="8" :disabled="outboundReadonly" />
|
||||
<n-text v-else>-</n-text>
|
||||
</n-form-item>
|
||||
<n-alert type="info" :bordered="false" class="onchain-tip">
|
||||
|
||||
<template v-if="targetOnchain && targetProof">
|
||||
<n-divider style="margin: 4px 0 12px">{{ t('pages.blockchain.title') }}</n-divider>
|
||||
<n-descriptions :column="1" label-placement="left" size="small" bordered>
|
||||
<n-descriptions-item :label="t('pages.blockchain.status')">
|
||||
<n-tag size="small" :type="proofStatusType(targetProof)">{{ proofStatusText(targetProof) }}</n-tag>
|
||||
</n-descriptions-item>
|
||||
<n-descriptions-item v-if="targetProof.dataHash" :label="t('pages.blockchain.dataHash')">
|
||||
<span class="onchain-mono">{{ targetProof.dataHash }}</span>
|
||||
</n-descriptions-item>
|
||||
<n-descriptions-item v-if="targetProof.txHash" :label="t('pages.blockchain.txHash')">
|
||||
<span class="onchain-mono">{{ targetProof.txHash }}</span>
|
||||
</n-descriptions-item>
|
||||
<n-descriptions-item v-if="targetProof.tokenId" :label="t('pages.blockchain.tokenId')">
|
||||
<span class="onchain-mono">{{ targetProof.tokenId }}</span>
|
||||
</n-descriptions-item>
|
||||
<n-descriptions-item v-if="targetProof.contractAddress" :label="t('pages.blockchain.contract')">
|
||||
<span class="onchain-mono">{{ targetProof.contractAddress }}</span>
|
||||
</n-descriptions-item>
|
||||
<n-descriptions-item v-if="targetProof.blockHeight" :label="t('pages.blockchain.blockHeight')">
|
||||
{{ targetProof.blockHeight }}
|
||||
</n-descriptions-item>
|
||||
<n-descriptions-item v-if="targetProof.onchainAt" :label="t('pages.blockchain.onchainAt')">
|
||||
{{ fmt(targetProof.onchainAt) }}
|
||||
</n-descriptions-item>
|
||||
<n-descriptions-item v-if="targetProof.explorerUrl" :label="t('pages.blockchain.explorer')">
|
||||
<a :href="targetProof.explorerUrl" target="_blank" rel="noopener" style="color: var(--brand)">{{ targetProof.explorerUrl }}</a>
|
||||
</n-descriptions-item>
|
||||
</n-descriptions>
|
||||
</template>
|
||||
|
||||
<n-alert v-if="!targetOnchain" type="info" :bordered="false" class="onchain-tip">
|
||||
{{ t('pages.outbound.onchainAutoTip') }}
|
||||
</n-alert>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<div style="text-align: right">
|
||||
<n-button class="mr8" @click="outboundModal = false">{{ t('common.action.cancel') }}</n-button>
|
||||
<n-button class="mr8" :loading="outboundSaving" @click="saveOutbound(false)">{{ t('pages.outbound.saveRecord') }}</n-button>
|
||||
<n-button type="primary" :loading="outboundTriggering" @click="saveOutbound(true)">{{ t('pages.outbound.saveAndTriggerOnchain') }}</n-button>
|
||||
<n-button class="mr8" @click="outboundModal = false">
|
||||
{{ targetOnchain ? t('common.action.close') : t('common.action.cancel') }}
|
||||
</n-button>
|
||||
<template v-if="!targetOnchain">
|
||||
<n-button v-if="!targetOutbound" class="mr8" :loading="outboundSaving" @click="saveOutbound(false)">{{ t('pages.outbound.saveRecord') }}</n-button>
|
||||
<n-button type="primary" :loading="outboundTriggering" @click="saveOutbound(true)">
|
||||
{{ targetOutbound ? t('pages.blockchain.trigger') : t('pages.outbound.saveAndTriggerOnchain') }}
|
||||
</n-button>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</n-modal>
|
||||
@@ -281,6 +321,23 @@ const outboundForm = reactive<any>({
|
||||
remark: '',
|
||||
});
|
||||
|
||||
function rowIsOutbound(row: any) {
|
||||
return Boolean(row?.outTime || getOutImages(row).length);
|
||||
}
|
||||
function rowIsOnchain(row: any) {
|
||||
return Boolean(row?.latestProof);
|
||||
}
|
||||
function outboundMenuLabel(row: any) {
|
||||
if (rowIsOnchain(row)) return t('pages.traceCode.onchainInfo');
|
||||
if (rowIsOutbound(row)) return t('pages.traceCode.triggerOnchainOnly');
|
||||
return t('pages.traceCode.registerOutbound');
|
||||
}
|
||||
const targetOutbound = computed(() => rowIsOutbound(outboundTarget.value));
|
||||
const targetOnchain = computed(() => rowIsOnchain(outboundTarget.value));
|
||||
const outboundReadonly = computed(() => targetOutbound.value || targetOnchain.value);
|
||||
const targetProof = computed<any>(() => outboundTarget.value?.latestProof ?? null);
|
||||
const outboundModalTitle = computed(() => outboundMenuLabel(outboundTarget.value));
|
||||
|
||||
const columns = computed<DataTableColumns<any>>(() => {
|
||||
const base: DataTableColumns<any> = [
|
||||
{ type: 'selection' },
|
||||
@@ -619,7 +676,7 @@ function rowActionOptions(row: any): DropdownOption[] {
|
||||
const options: DropdownOption[] = [
|
||||
{ label: t('pages.traceCode.changeGroup'), key: 'changeGroup', children: rowGroupOptions.value },
|
||||
{ label: t('pages.traceCode.changeBatch'), key: 'batch:open' },
|
||||
{ label: t('pages.traceCode.registerOutbound'), key: 'outbound:open' },
|
||||
{ label: outboundMenuLabel(row), key: 'outbound:open' },
|
||||
];
|
||||
if (canManualConfirm(row.latestAnyProof)) {
|
||||
options.push({ label: t('pages.traceCode.reconfirmOnchain'), key: 'onchain:confirm' });
|
||||
@@ -775,12 +832,14 @@ async function saveOutbound(triggerOnchain: boolean) {
|
||||
outboundSaving.value = true;
|
||||
}
|
||||
try {
|
||||
await outboundApi.updateSingle(String(outboundTarget.value.id), {
|
||||
outTime: outboundForm.outTime ? dayjs(outboundForm.outTime).toISOString() : null,
|
||||
outImageKey: outImages.value[0]?.key ?? null,
|
||||
outImageKeys: outImages.value.map((item) => item.key).filter(Boolean),
|
||||
remark: outboundForm.remark || null,
|
||||
});
|
||||
if (!outboundReadonly.value) {
|
||||
await outboundApi.updateSingle(String(outboundTarget.value.id), {
|
||||
outTime: outboundForm.outTime ? dayjs(outboundForm.outTime).toISOString() : null,
|
||||
outImageKey: outImages.value[0]?.key ?? null,
|
||||
outImageKeys: outImages.value.map((item) => item.key).filter(Boolean),
|
||||
remark: outboundForm.remark || null,
|
||||
});
|
||||
}
|
||||
if (triggerOnchain) {
|
||||
await traceCodeApi.onchain(String(outboundTarget.value.id));
|
||||
}
|
||||
@@ -946,6 +1005,11 @@ onUnmounted(() => {
|
||||
.onchain-tip {
|
||||
margin-top: 4px;
|
||||
}
|
||||
.onchain-mono {
|
||||
font-family: 'JetBrains Mono', Consolas, monospace;
|
||||
font-size: 12px;
|
||||
word-break: break-all;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.toolbar-control,
|
||||
.toolbar-control.wide,
|
||||
|
||||
Reference in New Issue
Block a user