feat: 接入天河链存证接口
This commit is contained in:
@@ -157,24 +157,9 @@
|
||||
<n-form-item :label="t('pages.outbound.outImage')">
|
||||
<media-upload v-model="outImages" type="image" :max="8" />
|
||||
</n-form-item>
|
||||
<n-divider style="margin: 4px 0 14px">{{ t('pages.outbound.onchainSection') }}</n-divider>
|
||||
<n-grid :cols="2" :x-gap="16">
|
||||
<n-form-item-gi span="2" :label="t('pages.blockchain.txHash')">
|
||||
<n-input v-model:value="outboundForm.txHash" :placeholder="t('pages.outbound.txHashTip')" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="t('pages.blockchain.onchainAt')">
|
||||
<n-date-picker v-model:formatted-value="outboundForm.onchainAt" value-format="yyyy-MM-dd HH:mm" type="datetime" clearable style="width: 100%" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2">
|
||||
<n-collapse>
|
||||
<n-collapse-item :title="t('pages.outbound.moreOnchainInfo')" name="more-onchain">
|
||||
<n-form-item :label="t('pages.blockchain.blockHeight')">
|
||||
<n-input-number v-model:value="outboundForm.blockHeight" :min="0" style="width: 100%" />
|
||||
</n-form-item>
|
||||
</n-collapse-item>
|
||||
</n-collapse>
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
<n-alert type="info" :bordered="false" class="onchain-tip">
|
||||
{{ t('pages.outbound.onchainAutoTip') }}
|
||||
</n-alert>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<div style="text-align: right">
|
||||
@@ -293,9 +278,6 @@ const outImages = ref<any[]>([]);
|
||||
const outboundForm = reactive<any>({
|
||||
outTime: null,
|
||||
remark: '',
|
||||
txHash: '',
|
||||
onchainAt: null,
|
||||
blockHeight: null,
|
||||
});
|
||||
|
||||
const columns = computed<DataTableColumns<any>>(() => {
|
||||
@@ -721,12 +703,6 @@ function formatDateTime(value?: string | Date | null) {
|
||||
return value ? dayjs(value).format('YYYY-MM-DD HH:mm') : null;
|
||||
}
|
||||
|
||||
function toNumber(value: unknown) {
|
||||
if (value === null || value === undefined || value === '') return null;
|
||||
const n = Number(value);
|
||||
return Number.isFinite(n) ? n : null;
|
||||
}
|
||||
|
||||
function fileName(key: string) {
|
||||
return key.split('/').pop() || key;
|
||||
}
|
||||
@@ -743,12 +719,8 @@ function getOutImages(row: any) {
|
||||
|
||||
function openOutboundModal(row: any) {
|
||||
outboundTarget.value = row;
|
||||
const latestProof = row.latestProof;
|
||||
outboundForm.outTime = formatDateTime(row.outTime);
|
||||
outboundForm.remark = row.remark || '';
|
||||
outboundForm.txHash = latestProof?.txHash || '';
|
||||
outboundForm.onchainAt = formatDateTime(latestProof?.onchainAt);
|
||||
outboundForm.blockHeight = toNumber(latestProof?.blockHeight);
|
||||
outImages.value = getOutImages(row);
|
||||
outboundModal.value = true;
|
||||
}
|
||||
@@ -765,9 +737,6 @@ async function saveOutbound(triggerOnchain: boolean) {
|
||||
outTime: outboundForm.outTime ? dayjs(outboundForm.outTime).toISOString() : null,
|
||||
outImageKey: outImages.value[0]?.key ?? null,
|
||||
outImageKeys: outImages.value.map((item) => item.key).filter(Boolean),
|
||||
txHash: outboundForm.txHash || undefined,
|
||||
onchainAt: outboundForm.onchainAt ? dayjs(outboundForm.onchainAt).toISOString() : undefined,
|
||||
blockHeight: outboundForm.blockHeight ?? undefined,
|
||||
remark: outboundForm.remark || null,
|
||||
});
|
||||
if (triggerOnchain) {
|
||||
@@ -932,6 +901,9 @@ onUnmounted(() => {
|
||||
.mr8 {
|
||||
margin-right: 8px;
|
||||
}
|
||||
.onchain-tip {
|
||||
margin-top: 4px;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.toolbar-control,
|
||||
.toolbar-control.wide,
|
||||
|
||||
@@ -152,7 +152,10 @@
|
||||
"3014": "Batch not found",
|
||||
"3015": "Artwork file has business data and cannot be deleted"
|
||||
},
|
||||
"lang": { "zh": "Simplified Chinese", "en": "English" }
|
||||
"lang": {
|
||||
"zh": "Simplified Chinese",
|
||||
"en": "English"
|
||||
}
|
||||
},
|
||||
"menu": {
|
||||
"dashboard": "Dashboard",
|
||||
@@ -354,8 +357,8 @@
|
||||
"import": "Batch Import",
|
||||
"outTime": "Outbound Time",
|
||||
"outImage": "Outbound Photo",
|
||||
"onchainSection": "On-chain info (optional; filling a hash records the result)",
|
||||
"txHashTip": "Paste the on-chain transaction/attestation hash",
|
||||
"onchainSection": "On-chain Info",
|
||||
"txHashTip": "Written automatically from the blockchain API response",
|
||||
"moreOnchainInfo": "More On-chain Info",
|
||||
"saveRecord": "Save Record",
|
||||
"saveAndTriggerOnchain": "Save & Trigger On-chain",
|
||||
@@ -365,7 +368,7 @@
|
||||
"successCount": "Success",
|
||||
"failCount": "Failed",
|
||||
"downloadResult": "Download Details",
|
||||
"tip": "Download the template first, fill it in and upload (xlsx). Includes outbound photo, on-chain hash/time/block height.",
|
||||
"tip": "Download the template ZIP, fill it in, and upload. On-chain results are recorded automatically from the blockchain API response.",
|
||||
"downloadZipTemplate": "Download Template ZIP",
|
||||
"uploadZipPreview": "Upload & Preview",
|
||||
"totalRows": "Rows",
|
||||
@@ -390,7 +393,8 @@
|
||||
"IMPORTED": "Imported",
|
||||
"FAILED": "Failed",
|
||||
"EXPIRED": "Expired"
|
||||
}
|
||||
},
|
||||
"onchainAutoTip": "On-chain hash, attestation link, and on-chain time are written automatically from the configured blockchain API response."
|
||||
},
|
||||
"blockchain": {
|
||||
"title": "Blockchain Attestation",
|
||||
@@ -441,7 +445,20 @@
|
||||
"scheduleOff": "Off",
|
||||
"scheduleDaily": "Daily",
|
||||
"scheduleWeekly": "Weekly",
|
||||
"saved": "Settings saved"
|
||||
"saved": "Settings saved",
|
||||
"blockchainSettings": "Blockchain Attestation",
|
||||
"blockchainDriver": "Attestation Driver",
|
||||
"blockchainDriverMock": "Mock",
|
||||
"blockchainDriverTianhe": "Tianhe Chain",
|
||||
"tianheEnv": "Tianhe Environment",
|
||||
"tianheEnvTest": "Test",
|
||||
"tianheEnvProduction": "Production",
|
||||
"tianheEnvCustom": "Custom",
|
||||
"tianheBaseUrl": "API URL",
|
||||
"tianheAppId": "App ID",
|
||||
"tianheAppKey": "App Key",
|
||||
"tianheUserId": "User ID",
|
||||
"tianheUserKey": "User Key"
|
||||
},
|
||||
"profile": {
|
||||
"title": "Personal Info",
|
||||
|
||||
@@ -152,7 +152,10 @@
|
||||
"3014": "批次不存在",
|
||||
"3015": "艺术品档案已有业务数据,无法删除"
|
||||
},
|
||||
"lang": { "zh": "简体中文", "en": "English" }
|
||||
"lang": {
|
||||
"zh": "简体中文",
|
||||
"en": "English"
|
||||
}
|
||||
},
|
||||
"menu": {
|
||||
"dashboard": "数据看板",
|
||||
@@ -354,8 +357,8 @@
|
||||
"import": "批量导入",
|
||||
"outTime": "出库时间",
|
||||
"outImage": "出库实况图",
|
||||
"onchainSection": "上链信息(选填,填写哈希即登记上链结果)",
|
||||
"txHashTip": "粘贴链上交易/存证哈希",
|
||||
"onchainSection": "上链信息",
|
||||
"txHashTip": "由区块链接口返回后自动写入",
|
||||
"moreOnchainInfo": "更多上链信息",
|
||||
"saveRecord": "保存登记",
|
||||
"saveAndTriggerOnchain": "保存并触发上链",
|
||||
@@ -365,7 +368,7 @@
|
||||
"successCount": "成功",
|
||||
"failCount": "失败",
|
||||
"downloadResult": "下载结果明细",
|
||||
"tip": "请先下载模板,按模板填写后上传(支持 xlsx)。模板含出库实况图、上链哈希/时间/区块高度等字段。",
|
||||
"tip": "下载模板 ZIP 后按说明填写并上传;链上结果由区块链接口返回后自动记录。",
|
||||
"downloadZipTemplate": "下载模板包",
|
||||
"uploadZipPreview": "上传并预览",
|
||||
"totalRows": "总行数",
|
||||
@@ -390,7 +393,8 @@
|
||||
"IMPORTED": "已导入",
|
||||
"FAILED": "失败",
|
||||
"EXPIRED": "已过期"
|
||||
}
|
||||
},
|
||||
"onchainAutoTip": "链上哈希、存证链接、上链时间由当前配置的区块链接口返回后自动写入。"
|
||||
},
|
||||
"blockchain": {
|
||||
"title": "区块链存证",
|
||||
@@ -441,7 +445,20 @@
|
||||
"scheduleOff": "关闭",
|
||||
"scheduleDaily": "每天",
|
||||
"scheduleWeekly": "每周",
|
||||
"saved": "设置已保存"
|
||||
"saved": "设置已保存",
|
||||
"blockchainSettings": "区块链存证",
|
||||
"blockchainDriver": "存证驱动",
|
||||
"blockchainDriverMock": "模拟存证",
|
||||
"blockchainDriverTianhe": "天河链",
|
||||
"tianheEnv": "天河链环境",
|
||||
"tianheEnvTest": "测试环境",
|
||||
"tianheEnvProduction": "正式环境",
|
||||
"tianheEnvCustom": "自定义",
|
||||
"tianheBaseUrl": "接口地址",
|
||||
"tianheAppId": "App ID",
|
||||
"tianheAppKey": "App Key",
|
||||
"tianheUserId": "User ID",
|
||||
"tianheUserKey": "User Key"
|
||||
},
|
||||
"profile": {
|
||||
"title": "个人信息",
|
||||
|
||||
@@ -125,7 +125,6 @@ const columns = computed<DataTableColumns<any>>(() => [
|
||||
align: 'center',
|
||||
render: (row) => renderImages(row),
|
||||
},
|
||||
{ title: t('pages.blockchain.txHash'), key: 'txHash', minWidth: 260, ellipsis: { tooltip: true } },
|
||||
{ title: t('common.label.remark'), key: 'remark', minWidth: 220, ellipsis: { tooltip: true } },
|
||||
{
|
||||
title: t('pages.outbound.errorReason'),
|
||||
|
||||
@@ -64,6 +64,45 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="settings-card">
|
||||
<div class="card-title">{{ t('pages.settings.blockchainSettings') }}</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.blockchainDriver')">
|
||||
<n-select v-model:value="form.blockchainDriver" :options="blockchainDriverOptions" class="select-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.tianheEnv')">
|
||||
<n-select v-model:value="form.tianheEnv" :options="tianheEnvOptions" class="select-control" @update:value="onTianheEnvChange" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.tianheBaseUrl')">
|
||||
<n-input v-model:value="form.tianheBaseUrl" class="url-control" :disabled="form.tianheEnv !== 'custom'" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.tianheAppId')">
|
||||
<n-input v-model:value="form.tianheAppId" class="text-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.tianheAppKey')">
|
||||
<n-input v-model:value="form.tianheAppKey" type="password" show-password-on="click" class="text-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.tianheUserId')">
|
||||
<n-input v-model:value="form.tianheUserId" class="text-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.tianheUserKey')">
|
||||
<n-input v-model:value="form.tianheUserKey" type="password" show-password-on="click" class="text-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="settings-card">
|
||||
<div class="card-title">{{ t('pages.settings.backupPolicy') }}</div>
|
||||
<div class="setting-row">
|
||||
@@ -105,6 +144,17 @@ import { DEFAULT_APP_ICON_URL, resolveAppIcon, setFavicon } from '@/utils/appIco
|
||||
|
||||
const { t } = useI18n();
|
||||
const saving = ref(false);
|
||||
const TIANHE_TEST_URL = 'https://test.api.tichain.tianhecloud.com';
|
||||
const TIANHE_PRODUCTION_URL = 'https://api.tichain.tianhecloud.com';
|
||||
const blockchainDriverOptions = computed(() => [
|
||||
{ label: t('pages.settings.blockchainDriverMock'), value: 'mock' },
|
||||
{ label: t('pages.settings.blockchainDriverTianhe'), value: 'tianhe' },
|
||||
]);
|
||||
const tianheEnvOptions = computed(() => [
|
||||
{ label: t('pages.settings.tianheEnvTest'), value: 'test' },
|
||||
{ label: t('pages.settings.tianheEnvProduction'), value: 'production' },
|
||||
{ label: t('pages.settings.tianheEnvCustom'), value: 'custom' },
|
||||
]);
|
||||
const backupScheduleOptions = computed(() => [
|
||||
{ label: t('pages.settings.scheduleOff'), value: 'off' },
|
||||
{ label: t('pages.settings.scheduleDaily'), value: 'daily' },
|
||||
@@ -129,6 +179,13 @@ const form = reactive({
|
||||
backupSchedule: 'daily',
|
||||
backupRetentionDays: 30,
|
||||
backupRetentionCount: 10,
|
||||
blockchainDriver: 'mock',
|
||||
tianheEnv: 'test',
|
||||
tianheBaseUrl: TIANHE_TEST_URL,
|
||||
tianheAppId: '',
|
||||
tianheAppKey: '',
|
||||
tianheUserId: '',
|
||||
tianheUserKey: '',
|
||||
});
|
||||
|
||||
async function load() {
|
||||
@@ -145,6 +202,18 @@ async function load() {
|
||||
form.backupSchedule = s.backupSchedule || 'daily';
|
||||
form.backupRetentionDays = Number(s.backupRetentionDays || 30);
|
||||
form.backupRetentionCount = Number(s.backupRetentionCount || 10);
|
||||
form.blockchainDriver = s.blockchainDriver || 'mock';
|
||||
form.tianheEnv = s.tianheEnv || 'test';
|
||||
form.tianheBaseUrl = s.tianheBaseUrl || TIANHE_TEST_URL;
|
||||
form.tianheAppId = s.tianheAppId || '';
|
||||
form.tianheAppKey = s.tianheAppKey || '';
|
||||
form.tianheUserId = s.tianheUserId || '';
|
||||
form.tianheUserKey = s.tianheUserKey || '';
|
||||
}
|
||||
|
||||
function onTianheEnvChange(value: string) {
|
||||
if (value === 'test') form.tianheBaseUrl = TIANHE_TEST_URL;
|
||||
if (value === 'production') form.tianheBaseUrl = TIANHE_PRODUCTION_URL;
|
||||
}
|
||||
|
||||
async function save() {
|
||||
@@ -163,6 +232,13 @@ async function save() {
|
||||
backupSchedule: form.backupSchedule,
|
||||
backupRetentionDays: String(form.backupRetentionDays),
|
||||
backupRetentionCount: String(form.backupRetentionCount),
|
||||
blockchainDriver: form.blockchainDriver,
|
||||
tianheEnv: form.tianheEnv,
|
||||
tianheBaseUrl: form.tianheBaseUrl,
|
||||
tianheAppId: form.tianheAppId,
|
||||
tianheAppKey: form.tianheAppKey,
|
||||
tianheUserId: form.tianheUserId,
|
||||
tianheUserKey: form.tianheUserKey,
|
||||
});
|
||||
setFavicon(appIconUrl);
|
||||
window.dispatchEvent(new CustomEvent('artveris-settings-updated'));
|
||||
@@ -287,6 +363,9 @@ const currentIconUrl = computed(() => resolveAppIcon(form.appIconFiles[0]?.url |
|
||||
.text-control {
|
||||
width: 180px;
|
||||
}
|
||||
.url-control {
|
||||
width: 220px;
|
||||
}
|
||||
.number-control {
|
||||
width: 128px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user