监管管理问题修改
这个提交包含在:
@@ -2,14 +2,23 @@ import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { Page, Audit } from './index';
|
||||
export interface Filter { field: string; operator: string; values: string[] }
|
||||
export interface Selection { resourceCode: string; periodField: string; keyFields: string[]; filters: Filter[]; attachmentFields: string[] }
|
||||
export interface Selection { resourceCode: string; periodField: string; keyFields: string[]; filters: Filter[]; attachmentFields: string[]; parameters?: Record<string, string> }
|
||||
export interface TaskDefinition { name: string; planId: string; planVersion: number; periodType: string; selections: Selection[] }
|
||||
export interface Task { id: string; version: number; enabled: boolean; definition: TaskDefinition; updatedAt: string }
|
||||
export interface Issue { resource: string; row: number; key: string; field: string; rule: string; severity: string; message: string }
|
||||
export interface Batch { id: string; taskId: string; taskVersion: number; version: number; state: string; startDate: string; endDate: string; rowCount: number; blockingCount: number; warningCount: number; issues: Issue[]; snapshotId?: string; packageId?: string; message?: string; updatedAt: string }
|
||||
export interface Artifact { id: string; batchId: string; kind: string; name: string; sha256: string; length: number; state: string; createdAt: string }
|
||||
export interface Attachment { name: string; md5: string; artifactId?: string; state: string; length: number; uses: { resource: string; row: number; field: string }[] }
|
||||
export interface Submission { id: string; batchId: string; packageId: string; packageSha256: string; state: string; httpStatus?: number; serviceFlag?: number; message: string; startedAt: string; finishedAt?: string }
|
||||
export interface Verification { id: string; target: string; outcome: string; evidenceRef: string; note: string; actorId: string; createdAt: string }
|
||||
export interface VerificationCommand { version: number; target: string; outcome: string; evidenceRef: string; note: string }
|
||||
export interface SnapshotView { readCount: number; selectedCount: number; passedCount: number; failedCount: number; batchBlocked: boolean; submittedCount: number | null; rows: { resource: string; row: number; values: Record<string, string | null> }[]; parameters: Record<string, Record<string, string>>; readinessEvidence: Record<string, string> }
|
||||
const base = '/api/integration/v1/regulatory-reporting/execution';
|
||||
export const dailyTasks = (topicId: string, pageNum: number, pageSize: number): AxiosPromise<Page<Task>> => request({ url: `${base}/daily/tasks`, params: { topicId, pageNum, pageSize } });
|
||||
export const startReport = (id: string, task: Task, startDate: string, endDate: string, parameters: Record<string, Record<string, string>>, readinessEvidence: Record<string, string>): AxiosPromise<Batch> => request({ url: `${base}/daily/batches/${id}`, method: 'post', data: { taskId: task.id, taskVersion: task.version, startDate, endDate, parameters, readinessEvidence }, timeout: 180000, headers: { repeatSubmit: false } });
|
||||
export const batchSubmissions = (id: string): AxiosPromise<Submission[]> => request({ url: `${base}/batches/${id}/submissions` });
|
||||
export const batchVerifications = (id: string): AxiosPromise<Verification[]> => request({ url: `${base}/batches/${id}/verifications` });
|
||||
export const recordVerification = (id: string, verificationId: string, data: VerificationCommand): AxiosPromise<Batch> => request({ url: `${base}/batches/${id}/verifications/${verificationId}`, method: 'put', data, headers: { repeatSubmit: false } });
|
||||
export const resolveQualityReference = (ruleId: string): AxiosPromise<string> => request({ url: `${base}/quality-rules/${ruleId}/reference` });
|
||||
export const listTasks = (pageNum: number, pageSize: number): AxiosPromise<Page<Task>> => request({ url: `${base}/tasks`, params: { pageNum, pageSize } });
|
||||
export const saveTask = (id: string, version: number, definition: TaskDefinition): AxiosPromise<Task> => request({ url: `${base}/tasks/${id}`, method: 'put', data: { version, definition }, headers: { repeatSubmit: false } });
|
||||
@@ -18,6 +27,7 @@ export const listBatches = (taskId: string, pageNum: number, pageSize: number):
|
||||
export const createBatch = (id: string, task: Task, startDate: string, endDate: string): AxiosPromise<Batch> => request({ url: `${base}/batches/${id}`, method: 'put', data: { taskId: task.id, taskVersion: task.version, startDate, endDate }, headers: { repeatSubmit: false } });
|
||||
export const batchAction = (batch: Batch, operation: string, reason: string): AxiosPromise<Batch> => request({ url: `${base}/batches/${batch.id}/${operation}`, method: 'post', data: { version: batch.version, reason }, timeout: 180000, headers: { repeatSubmit: false } });
|
||||
export const getBatch = (id: string): AxiosPromise<Batch> => request({ url: `${base}/batches/${id}` });
|
||||
export const batchData = (id: string, pageNum: number, pageSize: number): AxiosPromise<SnapshotView> => request({ url: `${base}/batches/${id}/data`, params: { pageNum, pageSize } });
|
||||
export const batchFiles = (id: string): AxiosPromise<Artifact[]> => request({ url: `${base}/batches/${id}/files` });
|
||||
export const batchAttachments = (id: string): AxiosPromise<Attachment[]> => request({ url: `${base}/batches/${id}/attachments` });
|
||||
export const uploadAttachment = (batch: Batch, name: string, file: File): AxiosPromise<Batch> => {
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
export const topicDefaults = (topicId: string): AxiosPromise<Plan[]> => request({ url: '/api/integration/v1/regulatory-reporting/plans/topic-defaults', params: { topicId } });
|
||||
import type { Page, Audit } from './index';
|
||||
export interface DatasetField { name: string; label: string; type: string; nullable: boolean }
|
||||
export interface Dataset { id: string; code: string; name: string; version: number; releaseId: string; schemaVersionId: string; schemaSha256: string; fields: DatasetField[] }
|
||||
export interface Transform { kind: string; argument: string; outputFormat: string; values: Record<string, string>; sources: string[] }
|
||||
export interface Mapping { target: string; source: string; confirmed: boolean; transform?: Transform }
|
||||
export interface DirectTable { alias: string; catalog: string | null; schema: string | null; table: string }
|
||||
export interface DirectDefinition { sourceId: string; tables: DirectTable[]; joins: { leftTable: string; leftField: string; rightTable: string; rightField: string }[]; fields: { name: string; tableAlias: string; column: string }[] }
|
||||
export interface SqlParameter { name: string; type: string; value: string }
|
||||
export interface DirectDefinition { sourceId: string; tables: DirectTable[]; joins: { leftTable: string; leftField: string; rightTable: string; rightField: string }[]; fields: { name: string; tableAlias: string; column: string }[]; mode?: 'SQL' | 'TABLE' | 'INTERMEDIATE_TABLE' | null; sql?: string; catalog?: string | null; schema?: string | null; parameters?: SqlParameter[]; readinessAgreement?: string }
|
||||
export interface DirectSource { definition: DirectDefinition; sourceVersion: number; schemaSha256: string; fields: DatasetField[] }
|
||||
export const previewDirect = (standardId: string, resourceCode: string, source: DirectDefinition): AxiosPromise<{ source: DirectSource; rows: Record<string, string | null>[] }> => request({ url: '/api/integration/v1/regulatory-reporting/plans/direct-preview', method: 'post', data: { standardId, resourceCode, source }, timeout: 30000 });
|
||||
export interface Binding { resourceCode: string; datasetId: string | null; datasetVersion: number; releaseId: string | null; schemaVersionId: string | null; schemaSha256: string | null; mappings: Mapping[]; directSource?: DirectSource | null }
|
||||
export interface PlanDefinition { code: string; name: string; versionLabel: string; regulatorId: string; systemId: string; topicId: string; standardId: string; standardVersion: number; adapterProfile: string; description: string; bindings: Binding[] }
|
||||
export interface Plan { id: string; version: number; state: string; definition: PlanDefinition; updatedAt: string }
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<el-card class="table-panel mt-3" shadow="hover">
|
||||
<template #header><div class="table-heading"><h3>开始报送</h3><p>使用已保存配置,按本批范围准备数据并校验</p></div></template>
|
||||
<el-form label-width="120px" :disabled="busy">
|
||||
<el-form-item label="报送主题" required><el-select v-model="topicId" filterable remote :remote-method="searchTopics" @change="chooseTopic"><el-option v-for="topic in topics" :key="topic.id" :value="topic.id" :label="topic.name" /></el-select></el-form-item>
|
||||
<el-form-item label="报送配置" required><el-select v-model="taskId" filterable @change="chooseTask"><el-option v-for="task in tasks" :key="task.id" :value="task.id" :label="task.definition.name" /></el-select><el-button :disabled="!topicId" link @click="chooseTopic">刷新配置</el-button><el-button v-if="tasks.length < total" link @click="loadTasks(true)">加载更多</el-button><span v-if="topicId && !tasks.length">请先保存并启用该主题的报送任务</span></el-form-item>
|
||||
<el-form-item label="报送期间" required><el-date-picker v-model="dates" type="daterange" value-format="YYYY-MM-DD" start-placeholder="起日(含)" end-placeholder="止日(不含)" /></el-form-item>
|
||||
<template v-for="binding in bindings" :key="binding.resourceCode">
|
||||
<template v-if="binding.directSource?.definition.mode === 'SQL'">
|
||||
<el-form-item v-for="parameter in binding.directSource.definition.parameters || []" :key="parameter.name" :label="`${binding.resourceCode} · ${parameter.name}`" required><el-input v-model="parameters[binding.resourceCode][parameter.name]" maxlength="4000" :placeholder="parameter.type" /><span>{{ parameter.type }};本次填写的值随批次保存</span></el-form-item>
|
||||
</template>
|
||||
<el-form-item v-if="binding.directSource?.definition.mode === 'INTERMEDIATE_TABLE'" :label="`${binding.resourceCode} 完成确认`" required><div class="w-full"><p>{{ binding.directSource.definition.readinessAgreement }}</p><el-input v-model="readiness[binding.resourceCode]" type="textarea" maxlength="1000" show-word-limit placeholder="确认本批范围已推送完整,填写批次号、完成标记或人工核对依据;未完成时请勿报送" /></div></el-form-item>
|
||||
</template>
|
||||
<el-alert v-for="message in scopeWarnings" :key="message" :title="message" type="warning" :closable="false" class="mb-3" />
|
||||
<el-form-item v-if="scopeWarnings.length" label="范围确认" required><el-checkbox v-model="scopeConfirmed">已核对 SQL 参数和过滤条件,确认本批实际取数范围符合报送要求</el-checkbox></el-form-item>
|
||||
<el-alert v-if="error" :title="error" type="error" :closable="false" class="mb-3" />
|
||||
<el-form-item><el-button v-hasPermi="['aixun:integration:regulatory-reporting:edit']" type="primary" :loading="busy" :disabled="!taskId || dates?.length !== 2 || !!scopeWarnings.length && !scopeConfirmed" @click="start">准备并校验报送数据</el-button></el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { listConfigs } from '@/api/datagov/regulatory-reporting';
|
||||
import type { ConfigView } from '@/api/datagov/regulatory-reporting';
|
||||
import { getPlan } from '@/api/datagov/regulatory-reporting/plans';
|
||||
import type { Plan } from '@/api/datagov/regulatory-reporting/plans';
|
||||
import { dailyTasks, startReport } from '@/api/datagov/regulatory-reporting/execution';
|
||||
import type { Batch, Task } from '@/api/datagov/regulatory-reporting/execution';
|
||||
const emit = defineEmits<{ prepared: [batch: Batch] }>();
|
||||
const topics = ref<ConfigView[]>([]), tasks = ref<Task[]>([]), topicId = ref(''), taskId = ref(''), total = ref(0), page = ref(1);
|
||||
const bindings = ref<Plan['definition']['bindings']>([]), parameters = ref<Record<string, Record<string, string>>>({}), readiness = ref<Record<string, string>>({});
|
||||
const dates = ref<string[]>([]), busy = ref(false), error = ref(''), pendingId = ref('');
|
||||
const scopeConfirmed = ref(false);
|
||||
const scopeWarnings = computed(() => {
|
||||
const task = tasks.value.find(t => t.id === taskId.value);
|
||||
return bindings.value.filter(b => !task?.definition.selections.find(s => s.resourceCode === b.resourceCode)?.periodField).map(b =>
|
||||
`${b.resourceCode} 未配置期间字段:页面所选期间不会自动过滤来源数据。${b.directSource?.definition.parameters?.length ? 'SQL 参数按本页实际填写值执行,请核对其是否限制了报送期间。' : '将读取全部符合 SQL 和过滤条件的记录,可能包含其他期间的数据。'}`);
|
||||
});
|
||||
watch([taskId, dates, parameters, readiness], () => { pendingId.value = ''; }, { deep: true });
|
||||
watch([taskId, dates, parameters, readiness, bindings], () => { scopeConfirmed.value = false; }, { deep: true });
|
||||
async function searchTopics(keyword = '') { topics.value = (await listConfigs({ kind: 'TOPIC', enabled: true, keyword, pageNum: 1, pageSize: 100 })).data.rows; }
|
||||
async function chooseTopic() { taskId.value = ''; bindings.value = []; tasks.value = []; await loadTasks(false); if (tasks.value.length === 1 && total.value === 1) { taskId.value = tasks.value[0].id; await chooseTask(); } }
|
||||
async function loadTasks(append: boolean) { const next = append ? page.value + 1 : 1; const result = (await dailyTasks(topicId.value, next, 100)).data; tasks.value = append ? [...tasks.value, ...result.rows] : result.rows; total.value = result.total; page.value = next; }
|
||||
async function chooseTask() {
|
||||
bindings.value = []; parameters.value = {}; readiness.value = {}; error.value = '';
|
||||
const task = tasks.value.find(t => t.id === taskId.value); if (!task) return;
|
||||
busy.value = true;
|
||||
try { const plan = (await getPlan(task.definition.planId)).data; for (const binding of plan.definition.bindings) { parameters.value[binding.resourceCode] = Object.fromEntries((binding.directSource?.definition.parameters || []).map(p => [p.name, p.value])); Object.assign(parameters.value[binding.resourceCode], task.definition.selections.find(s => s.resourceCode === binding.resourceCode)?.parameters || {}); readiness.value[binding.resourceCode] = ''; } bindings.value = plan.definition.bindings; }
|
||||
finally { busy.value = false; }
|
||||
}
|
||||
async function start() {
|
||||
const task = tasks.value.find(t => t.id === taskId.value); if (!task || busy.value || dates.value?.length !== 2) return;
|
||||
if (scopeWarnings.value.length && !scopeConfirmed.value) { error.value = '请先确认实际取数范围;页面期间不会自动代入 SQL'; return; }
|
||||
const intermediate = bindings.value.filter(b => b.directSource?.definition.mode === 'INTERMEDIATE_TABLE');
|
||||
if (intermediate.some(b => !readiness.value[b.resourceCode]?.trim())) { error.value = '请逐个确认中间库本批范围已推送完成,并填写依据'; return; }
|
||||
busy.value = true; error.value = ''; pendingId.value ||= crypto.randomUUID();
|
||||
try { const batch = (await startReport(pendingId.value, task, dates.value[0], dates.value[1], parameters.value, Object.fromEntries(intermediate.map(b => [b.resourceCode, readiness.value[b.resourceCode]])))).data; pendingId.value = ''; emit('prepared', batch); }
|
||||
catch { error.value = '准备未完成,请查看接口提示。结果不明时保留当前输入重试,将使用同一批次编号核对。'; }
|
||||
finally { busy.value = false; }
|
||||
}
|
||||
onMounted(() => searchTopics());
|
||||
</script>
|
||||
@@ -1,15 +1,25 @@
|
||||
<template>
|
||||
<div class="w-full">
|
||||
<el-button :disabled="disabled" @click="open">{{ current ? '调整直连来源' : '选择业务库 / 中间库' }}</el-button>
|
||||
<el-drawer v-model="visible" title="业务数据库或标准中间库直连" size="min(1000px, 96vw)" append-to-body :close-on-click-modal="false">
|
||||
<el-alert title="选择已有数据源及表;关联保留主表记录,关联缺失或多义结果由批次校验阻断。取数条件在任务中设置,源数据不会被修改。" type="info" :closable="false" class="mb-3" />
|
||||
<el-button :disabled="disabled" @click="open">{{ current ? '调整取数来源' : '选择 SQL / 标准表来源' }}</el-button>
|
||||
<el-drawer v-model="visible" title="配置报送来源" size="min(1000px, 96vw)" append-to-body :close-on-click-modal="false">
|
||||
<el-alert title="选择已有数据源,通过只读 SQL 或标准表取数。标准同名字段自动对应;别名、类型差异和缺失字段需核对。" type="info" :closable="false" class="mb-3" />
|
||||
<el-alert v-if="error" :title="error" type="error" :closable="false" class="mb-3" />
|
||||
<el-form label-width="100px" :disabled="busy || disabled">
|
||||
<el-form-item label="业务场景"><el-select :model-value="definition.mode || 'TABLE'" @change="modeChanged"><el-option label="业务库 SQL 取数" value="SQL" /><el-option label="中间库标准表" value="INTERMEDIATE_TABLE" /><el-option label="业务库标准表" value="TABLE" /></el-select></el-form-item>
|
||||
<el-form-item label="已有数据源"><el-select v-model="definition.sourceId" filterable @change="sourceChanged"><el-option v-for="source in sources" :key="String(source.id)" :label="`${source.name} (${source.type})`" :value="String(source.id)" /></el-select></el-form-item>
|
||||
<template v-if="definition.mode === 'SQL'">
|
||||
<el-form-item label="数据库"><el-select v-model="definition.catalog" @change="sqlCatalogChanged"><el-option v-for="name in catalogs" :key="name" :label="name" :value="name" /></el-select></el-form-item>
|
||||
<el-form-item v-if="sqlSchemas.length" label="Schema"><el-select :model-value="schemaKey(sqlSchemas, definition.schema ?? null)" @change="key => definition.schema = sqlSchemas.find(choice => choice.key === key)?.schema ?? null"><el-option v-for="choice in sqlSchemas" :key="choice.key" :label="choice.label" :value="choice.key" /></el-select></el-form-item>
|
||||
<el-form-item label="查询 SQL" required><el-input v-model="definition.sql" type="textarea" :rows="12" maxlength="100000" placeholder="每个目标资源保存一条 SELECT,支持关联及子查询。参数用 :year 等命名占位符。" /></el-form-item>
|
||||
<el-table :data="definition.parameters || []" border><el-table-column label="参数名"><template #default="{ row }"><el-input v-model="row.name" /></template></el-table-column><el-table-column label="类型"><template #default="{ row }"><el-select v-model="row.type"><el-option v-for="type in ['STRING', 'INTEGER', 'DECIMAL', 'DATE', 'DATETIME', 'BOOLEAN']" :key="type" :value="type" :label="type" /></el-select></template></el-table-column><el-table-column label="默认值"><template #default="{ row }"><el-input v-model="row.value" /></template></el-table-column><el-table-column width="80"><template #default="{ $index }"><el-button link type="danger" @click="definition.parameters?.splice($index, 1)">删除</el-button></template></el-table-column></el-table>
|
||||
<el-button class="my-3" @click="(definition.parameters ||= []).push({ name: '', type: 'STRING', value: '' })">添加参数</el-button>
|
||||
</template>
|
||||
<el-form-item v-if="definition.mode === 'INTERMEDIATE_TABLE'" label="完成约定" required><el-input v-model="definition.readinessAgreement" type="textarea" maxlength="1000" placeholder="填写业务批次、完成标记或完成窗口约定;每次报送须确认该范围已全部推送完成。" /></el-form-item>
|
||||
<template v-if="definition.mode !== 'SQL'">
|
||||
<el-card v-for="(table, index) in definition.tables" :key="table.alias" class="mb-3" shadow="never">
|
||||
<template #header>{{ index === 0 ? '主表' : '关联表' }} · {{ table.alias }}</template>
|
||||
<el-form-item label="数据库"><el-select v-model="table.catalog" @change="catalogChanged(index)"><el-option v-for="name in catalogs" :key="name" :label="name" :value="name" /></el-select></el-form-item>
|
||||
<el-form-item v-if="schemaOptions[table.alias]?.length" label="Schema"><el-select v-model="table.schema" @change="loadTables(index)"><el-option v-for="name in schemaOptions[table.alias]" :key="name" :label="name" :value="name" /></el-select></el-form-item>
|
||||
<el-form-item v-if="schemaOptions[table.alias]?.length" label="Schema"><el-select :model-value="schemaKey(schemaOptions[table.alias] || [], table.schema)" @change="schemaChanged(index, $event)"><el-option v-for="choice in schemaOptions[table.alias]" :key="choice.key" :label="choice.label" :value="choice.key" /></el-select></el-form-item>
|
||||
<el-form-item label="表 / 视图"><el-select v-model="table.table" filterable @change="loadColumns(index)"><el-option v-for="item in tableOptions[table.alias] || []" :key="item.name" :value="item.name" :label="item.name" /></el-select></el-form-item>
|
||||
<template v-if="index > 0 && definition.joins[index - 1]">
|
||||
<el-form-item label="左侧表"><el-select v-model="definition.joins[index - 1].leftTable" @change="definition.joins[index - 1].leftField = ''"><el-option v-for="left in definition.tables.slice(0, index)" :key="left.alias" :value="left.alias" :label="`${left.alias} ${left.table}`" /></el-select></el-form-item>
|
||||
@@ -21,25 +31,35 @@
|
||||
</el-card>
|
||||
<el-button :disabled="!definition.sourceId || definition.tables.length >= 5" @click="addTable">添加关联表</el-button>
|
||||
<el-table :data="definition.fields" class="mt-3" border><el-table-column label="来源"><template #default="{ row }">{{ row.tableAlias }}.{{ row.column }}</template></el-table-column><el-table-column label="输出字段别名"><template #default="{ row }"><el-input v-model="row.name" maxlength="128" /></template></el-table-column></el-table>
|
||||
</template>
|
||||
<el-button class="my-3" :disabled="!definition.sourceId" @click="preview">预览结果(最多5条)</el-button>
|
||||
<el-table v-if="previewRows" :data="previewRows" border max-height="300" empty-text="所选范围暂无记录"><el-table-column v-for="field in previewFields" :key="field" :prop="field" :label="field" min-width="150" /></el-table>
|
||||
</el-form>
|
||||
<template #footer><el-button @click="visible = false">取消</el-button><el-button type="primary" :loading="busy" :disabled="disabled || !definition.fields.length" @click="confirm">核对来源并绑定</el-button></template>
|
||||
<template #footer><el-button @click="visible = false">取消</el-button><el-button type="primary" :loading="busy" :disabled="disabled || (!definition.fields.length && definition.mode !== 'SQL')" @click="confirm">核对来源并绑定</el-button></template>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { listDataSources, browseSourceObjects } from '@/api/datagov/data-sources';
|
||||
import type { DataSourceVO, SourceObjectQuery } from '@/api/datagov/data-sources/types';
|
||||
import { matchDirect } from '@/api/datagov/regulatory-reporting/plans';
|
||||
import { matchDirect, previewDirect } from '@/api/datagov/regulatory-reporting/plans';
|
||||
import type { DirectDefinition, DirectSource, Suggestion } from '@/api/datagov/regulatory-reporting/plans';
|
||||
import { schemaChoices, schemaKey, objectQuery, clearTableFields, sourceError } from './directSourceChoices';
|
||||
import type { SchemaChoice } from './directSourceChoices';
|
||||
const props = defineProps<{ standardId: string; resourceCode: string; disabled: boolean; current?: DirectSource | null }>();
|
||||
const emit = defineEmits<{ bound: [value: { source: DirectSource; suggestions: Suggestion[] }] }>();
|
||||
const visible = ref(false), busy = ref(false), error = ref(''), sources = ref<DataSourceVO[]>([]), catalogs = ref<string[]>([]);
|
||||
type Entry = { name: string; schema?: string; type?: string; masked?: boolean };
|
||||
const schemaOptions = ref<Record<string, string[]>>({}), tableOptions = ref<Record<string, Entry[]>>({}), columns = ref<Record<string, Entry[]>>({});
|
||||
type Entry = { name: string; schema?: string | null; type?: string; masked?: boolean };
|
||||
const schemaOptions = ref<Record<string, SchemaChoice[]>>({}), tableOptions = ref<Record<string, Entry[]>>({}), columns = ref<Record<string, Entry[]>>({});
|
||||
const blank = (): DirectDefinition => ({ sourceId: '', tables: [{ alias: 't1', catalog: null, schema: null, table: '' }], joins: [], fields: [] });
|
||||
const definition = ref<DirectDefinition>(blank());
|
||||
async function run(action: () => Promise<void>) { if (busy.value) return; busy.value = true; error.value = ''; try { await action(); } catch (e) { error.value = e instanceof Error ? e.message : '来源读取失败,请核对权限或连接状态'; } finally { busy.value = false; } }
|
||||
const sqlSchemas = ref<SchemaChoice[]>([]), previewRows = ref<Record<string, string | null>[]>(), previewFields = ref<string[]>([]);
|
||||
watch(definition, () => { previewRows.value = undefined; }, { deep: true });
|
||||
function modeChanged(mode: DirectDefinition['mode']) { const sourceId = definition.value.sourceId; definition.value = { ...blank(), sourceId, mode, ...(mode === 'SQL' ? { tables: [], sql: '', parameters: [] } : {}) }; sqlSchemas.value = []; tableOptions.value = {}; columns.value = {}; schemaOptions.value = {}; }
|
||||
async function sqlCatalogChanged() { definition.value.schema = null; sqlSchemas.value = []; await run(async () => { sqlSchemas.value = schemaChoices(await browse({ level: 'SCHEMA', catalog: definition.value.catalog ?? undefined })); }); }
|
||||
async function preview() { await run(async () => { const result = (await previewDirect(props.standardId, props.resourceCode, definition.value)).data; previewFields.value = result.source.fields.map(field => field.name); previewRows.value = result.rows; }); }
|
||||
async function run(action: () => Promise<void>) { if (busy.value) return; busy.value = true; error.value = ''; try { await action(); } catch (e) { error.value = sourceError(e); } finally { busy.value = false; } }
|
||||
async function browse(query: Omit<SourceObjectQuery, 'pageNum' | 'pageSize'>): Promise<Entry[]> {
|
||||
const rows: Entry[] = [];
|
||||
for (let pageNum = 1; pageNum <= 20; pageNum++) {
|
||||
@@ -50,14 +70,25 @@ async function browse(query: Omit<SourceObjectQuery, 'pageNum' | 'pageSize'>): P
|
||||
throw new Error('来源对象超过2000项,请缩小数据库范围');
|
||||
}
|
||||
function queryFor(index: number, level: SourceObjectQuery['level']): Omit<SourceObjectQuery, 'pageNum' | 'pageSize'> {
|
||||
const t = definition.value.tables[index]; return { level, ...(t.catalog ? { catalog: t.catalog } : {}), ...(t.schema ? { schema: t.schema } : {}), ...(level === 'COLUMN' ? { table: t.table } : {}) };
|
||||
return objectQuery(definition.value.tables[index], level);
|
||||
}
|
||||
async function open() { visible.value = true; definition.value = props.current ? JSON.parse(JSON.stringify(props.current.definition)) : blank(); columns.value = {}; tableOptions.value = {}; schemaOptions.value = {}; await run(async () => { sources.value = (await listDataSources()).data.filter(s => !['HIVE', 'MARIADB'].includes(s.type)); if (definition.value.sourceId) { catalogs.value = (await browse({ level: 'CATALOG' })).map(r => r.name); for (let i = 0; i < definition.value.tables.length; i++) { const t = definition.value.tables[i]; schemaOptions.value[t.alias] = (await browse({ level: 'SCHEMA', catalog: t.catalog || undefined })).map(r => r.name); tableOptions.value[t.alias] = await browse(queryFor(i, 'TABLE')); columns.value[t.alias] = await browse(queryFor(i, 'COLUMN')); } } }); }
|
||||
async function sourceChanged() { const sourceId = definition.value.sourceId; definition.value = { ...blank(), sourceId }; columns.value = {}; tableOptions.value = {}; schemaOptions.value = {}; await run(async () => { catalogs.value = (await browse({ level: 'CATALOG' })).map(r => r.name); }); }
|
||||
async function catalogChanged(index: number) { const t = definition.value.tables[index]; t.schema = null; t.table = ''; clearFields(t.alias); await run(async () => { schemaOptions.value[t.alias] = (await browse({ level: 'SCHEMA', catalog: t.catalog || undefined })).map(r => r.name); tableOptions.value[t.alias] = schemaOptions.value[t.alias].length ? [] : await browse(queryFor(index, 'TABLE')); }); }
|
||||
async function loadTables(index: number) { const t = definition.value.tables[index]; t.table = ''; clearFields(t.alias); await run(async () => { tableOptions.value[t.alias] = await browse(queryFor(index, 'TABLE')); }); }
|
||||
async function loadColumns(index: number) { const t = definition.value.tables[index]; clearFields(t.alias); await run(async () => { columns.value[t.alias] = await browse(queryFor(index, 'COLUMN')); }); }
|
||||
function clearFields(alias: string) { columns.value[alias] = []; definition.value.fields = definition.value.fields.filter(f => f.tableAlias !== alias); for (const join of definition.value.joins) { if (join.leftTable === alias) join.leftField = ''; if (join.rightTable === alias) join.rightField = ''; } }
|
||||
async function open() {
|
||||
if (busy.value) return;
|
||||
visible.value = true; definition.value = props.current ? JSON.parse(JSON.stringify(props.current.definition)) : blank(); catalogs.value = []; columns.value = {}; tableOptions.value = {}; schemaOptions.value = {}; sqlSchemas.value = [];
|
||||
await run(async () => {
|
||||
sources.value = (await listDataSources()).data.filter(s => !['HIVE', 'MARIADB'].includes(s.type));
|
||||
if (!definition.value.sourceId) return;
|
||||
catalogs.value = (await browse({ level: 'CATALOG' })).map(r => r.name);
|
||||
if (definition.value.mode === 'SQL') { sqlSchemas.value = schemaChoices(await browse({ level: 'SCHEMA', catalog: definition.value.catalog ?? undefined })); if (sqlSchemas.value.length && schemaKey(sqlSchemas.value, definition.value.schema ?? null) === undefined) throw new Error('已保存的 Schema 不在当前目录中,请重新选择'); return; }
|
||||
for (let i = 0; i < definition.value.tables.length; i++) { const t = definition.value.tables[i]; const choices = schemaChoices(await browse({ level: 'SCHEMA', catalog: t.catalog ?? undefined })); schemaOptions.value[t.alias] = choices; if (choices.length && schemaKey(choices, t.schema) === undefined) { t.schema = null; t.table = ''; clearFields(t.alias); throw new Error('已保存的 Schema 不在当前目录中,请重新选择'); } tableOptions.value[t.alias] = await browse(queryFor(i, 'TABLE')); if (t.table) columns.value[t.alias] = await browse(queryFor(i, 'COLUMN')); }
|
||||
});
|
||||
}
|
||||
async function sourceChanged() { const mode = definition.value.mode; modeChanged(mode); catalogs.value = []; await run(async () => { catalogs.value = (await browse({ level: 'CATALOG' })).map(r => r.name); }); }
|
||||
async function catalogChanged(index: number) { const t = definition.value.tables[index]; t.schema = null; t.table = ''; clearFields(t.alias); tableOptions.value[t.alias] = []; schemaOptions.value[t.alias] = []; await run(async () => { const choices = schemaChoices(await browse({ level: 'SCHEMA', catalog: t.catalog ?? undefined })); schemaOptions.value[t.alias] = choices; if (!choices.length || choices.some(choice => choice.schema === null)) tableOptions.value[t.alias] = await browse(queryFor(index, 'TABLE')); }); }
|
||||
async function schemaChanged(index: number, key: string) { const t = definition.value.tables[index]; const choice = schemaOptions.value[t.alias]?.find(item => item.key === key); if (!choice) return; t.schema = choice.schema; await loadTables(index); }
|
||||
async function loadTables(index: number) { const t = definition.value.tables[index]; t.table = ''; tableOptions.value[t.alias] = []; clearFields(t.alias); await run(async () => { tableOptions.value[t.alias] = await browse(queryFor(index, 'TABLE')); }); }
|
||||
async function loadColumns(index: number) { const t = definition.value.tables[index]; clearFields(t.alias); await run(async () => { columns.value[t.alias] = await browse(queryFor(index, 'COLUMN')); selectColumns(t.alias, columns.value[t.alias].filter(field => !field.masked).map(field => field.name)); }); }
|
||||
function clearFields(alias: string) { columns.value[alias] = []; clearTableFields(definition.value, alias); }
|
||||
function selectColumns(alias: string, selected: string[]) { const old = definition.value.fields.filter(f => f.tableAlias === alias), remaining = definition.value.fields.filter(f => f.tableAlias !== alias); definition.value.fields = [...remaining, ...selected.map(column => old.find(f => f.column === column) || { tableAlias: alias, column, name: remaining.some(f => f.name === column) ? `${alias}_${column}` : column })]; }
|
||||
function addTable() { const alias = `t${definition.value.tables.length + 1}`; definition.value.tables.push({ alias, catalog: null, schema: null, table: '' }); definition.value.joins.push({ leftTable: 't1', leftField: '', rightTable: alias, rightField: '' }); }
|
||||
function removeLast() { const t = definition.value.tables.pop(); definition.value.joins.pop(); if (t) clearFields(t.alias); }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<DailyReportPanel @prepared="details" />
|
||||
<el-card class="table-panel mt-3" shadow="hover">
|
||||
<template #header><div class="toolbar-shell"><div class="table-heading"><h3>报送任务与批次</h3><p>选择固定方案,按期间生成、校验和审核报送数据</p></div><div><el-button icon="Refresh" @click="load">刷新</el-button><el-button v-hasPermi="[editPermission]" type="primary" icon="Plus" @click="editTask()">新建任务</el-button></div></div></template>
|
||||
<el-alert v-if="failed" title="任务读取失败,请刷新重试" type="error" :closable="false" />
|
||||
@@ -8,8 +9,9 @@
|
||||
</el-card>
|
||||
<el-drawer v-model="taskVisible" title="配置报送任务" size="min(1000px, 96vw)" :close-on-click-modal="false">
|
||||
<el-form v-loading="busy" label-width="110px"><el-form-item label="任务名称" required><el-input v-model="draft.name" maxlength="160" /></el-form-item><el-form-item label="冻结方案" required><el-select v-model="draft.planId" filterable remote :remote-method="searchPlans" @change="choosePlan"><el-option v-for="p in planChoices" :key="p.id" :value="p.id" :label="`${p.definition.name} · ${p.definition.versionLabel}`" :disabled="p.state !== 'FROZEN'" /></el-select></el-form-item><el-form-item label="期间类型"><el-select v-model="draft.periodType"><el-option v-for="(label, value) in periods" :key="value" :value="value" :label="label" /></el-select></el-form-item>
|
||||
<el-alert title="当前由操作人手动创建批次。期间采用起日包含、止日不包含;未选择期间字段时读取全部符合过滤条件的记录。" type="info" :closable="false" class="mb-3" />
|
||||
<el-alert title="首次保存并启用后,可从“开始报送”复用配置。期间采用起日包含、止日不包含;未配置期间字段或SQL期间参数时读取全部符合过滤条件的记录。" type="info" :closable="false" class="mb-3" />
|
||||
<el-collapse><el-collapse-item v-for="selection in draft.selections" :key="selection.resourceCode" :title="selection.resourceCode" :name="selection.resourceCode">
|
||||
<el-form-item v-for="parameter in sourceParams[selection.resourceCode] || []" :key="parameter.name" :label="parameter.name"><el-input :model-value="selection.parameters?.[parameter.name] ?? parameter.value" :placeholder="parameter.type" maxlength="4000" @update:model-value="value => { selection.parameters ||= {}; selection.parameters[parameter.name] = value; }" /></el-form-item>
|
||||
<el-form-item label="业务主键" required><el-select v-model="selection.keyFields" multiple filterable><el-option v-for="f in columns[selection.resourceCode] || []" :key="f.name" :label="f.name" :value="f.name" /></el-select></el-form-item>
|
||||
<el-form-item label="期间字段"><el-select v-model="selection.periodField" clearable filterable><el-option v-for="f in columns[selection.resourceCode] || []" :key="f.name" :label="`${f.name} · ${f.type}`" :value="f.name" /></el-select></el-form-item>
|
||||
<el-form-item label="附件引用字段"><el-select v-model="selection.attachmentFields" multiple filterable placeholder="无附件可不选"><el-option v-for="field in targets[selection.resourceCode] || []" :key="field" :label="field" :value="field" /></el-select></el-form-item>
|
||||
@@ -20,63 +22,69 @@
|
||||
</el-form><template #footer><el-button @click="taskVisible = false">取消</el-button><el-button type="primary" :loading="busy" @click="save">保存任务</el-button></template>
|
||||
</el-drawer>
|
||||
<el-drawer v-model="batchesVisible" :title="`任务批次 · ${currentTask?.definition.name || ''}`" size="min(1250px, 98vw)">
|
||||
<el-form v-hasPermi="[editPermission]" inline><el-form-item label="报送期间"><el-date-picker v-model="dates" type="daterange" value-format="YYYY-MM-DD" start-placeholder="起日(含)" end-placeholder="止日(不含)" /></el-form-item><el-form-item><el-button type="primary" :disabled="!currentTask?.enabled" :loading="busy" @click="newBatch">创建批次</el-button></el-form-item></el-form>
|
||||
<el-alert title="新增报送请在“开始报送”选择主题、已保存配置和本批范围。" type="info" :closable="false" class="mb-3" />
|
||||
<el-button icon="Refresh" class="mb-3" @click="loadBatches">刷新批次</el-button>
|
||||
<el-table :data="batches" border><el-table-column label="期间" min-width="210"><template #default="{ row }">{{ row.startDate }} 至 {{ row.endDate }}</template></el-table-column><el-table-column label="状态" width="130"><template #default="{ row }">{{ states[row.state] || row.state }}</template></el-table-column><el-table-column prop="rowCount" label="记录数" width="100" /><el-table-column prop="blockingCount" label="阻断" width="80" /><el-table-column prop="warningCount" label="警告" width="80" /><el-table-column label="操作" width="330" fixed="right"><template #default="{ row }"><el-button link type="primary" @click="details(row)">详情</el-button><template v-for="operation in actions(row.state)" :key="operation"><el-button v-hasPermi="[editPermission]" link type="primary" :disabled="busy" @click="act(row, operation)">{{ actionNames[operation] }}</el-button></template></template></el-table-column></el-table>
|
||||
<pagination v-show="batchTotal > 0" v-model:page="batchPage" v-model:limit="batchSize" :total="batchTotal" @pagination="loadBatches" />
|
||||
</el-drawer>
|
||||
<el-drawer v-model="detailVisible" title="批次详情" size="min(1150px, 96vw)" append-to-body>
|
||||
<template v-if="selected"><el-alert :title="selected.message || states[selected.state]" type="info" :closable="false" /><p class="my-3">批次 {{ selected.id }} · {{ states[selected.state] }} · {{ selected.rowCount }} 条记录</p><p v-if="selected.snapshotId" class="mb-3">{{ rowSummary(selected) }}</p>
|
||||
<template v-if="selected"><el-alert :title="selected.message || states[selected.state]" type="info" :closable="false" /><p class="my-3">批次 {{ selected.id }} · {{ states[selected.state] }} · {{ selected.rowCount }} 条记录;阻断问题 {{ selected.blockingCount }} 项,警告 {{ selected.warningCount }} 项(问题数不是失败记录数)</p><p v-if="selected.rowCount || selected.snapshotId" class="mb-3">{{ rowSummary(selected) }}</p>
|
||||
<el-alert v-if="['UNKNOWN', 'ATTACHMENT_UNKNOWN'].includes(selected.state)" title="文件结果尚未确认,不能审核或提交。核对只恢复原文件操作,不会重新读取源数据或对外发送;若原文件未创建或未写完整,须先核实原操作结束并修复存储,再另建批次重新校验。" type="warning" :closable="false" class="mb-3" />
|
||||
<div class="my-3"><el-button v-for="operation in actions(selected.state)" :key="operation" v-hasPermi="[editPermission]" :disabled="busy" @click="act(selected, operation)">{{ actionNames[operation] }}</el-button></div>
|
||||
<el-tabs><el-tab-pane label="校验问题"><el-button class="mb-3" @click="exportIssues">导出整改清单</el-button><el-table :data="selected.issues" border max-height="500" empty-text="暂无校验问题记录"><el-table-column prop="resource" label="资源" /><el-table-column prop="row" label="记录序号" width="100" /><el-table-column prop="key" label="主键摘要" /><el-table-column prop="field" label="字段" /><el-table-column prop="rule" label="规则" /><el-table-column label="级别" width="80"><template #default="{ row }">{{ row.severity === 'BLOCKING' ? '阻断' : '警告' }}</template></el-table-column><el-table-column prop="message" label="原因" min-width="250" /></el-table></el-tab-pane>
|
||||
<el-tab-pane label="本批数据"><el-button :disabled="!selected.snapshotId" @click="loadData">读取已保存快照</el-button><template v-if="snapshotData"><p class="my-3">范围内读取 {{ snapshotData.readCount }} 条,选定 {{ snapshotData.selectedCount }} 条;逐条通过 {{ snapshotData.passedCount }} 条,失败 {{ snapshotData.failedCount }} 条;接口受理 {{ snapshotData.submittedCount ?? '待核实' }} 条(不代表最终入库)。{{ snapshotData.batchBlocked ? '仍有批次级问题阻断提交。' : '' }}</p><p v-for="(value, resource) in snapshotData.readinessEvidence" :key="resource">{{ resource }} 完成确认:{{ value }}</p><p v-for="(value, resource) in snapshotData.parameters" :key="resource">{{ resource }} 本批参数:{{ JSON.stringify(value) }}</p><el-table :data="snapshotData.rows" border><el-table-column prop="resource" label="资源" width="180" /><el-table-column prop="row" label="记录序号" width="100" /><el-table-column label="标准字段及值"><template #default="{ row }"><pre style="white-space: pre-wrap; word-break: break-word">{{ JSON.stringify(row.values, null, 2) }}</pre></template></el-table-column></el-table><pagination v-show="snapshotData.selectedCount > 0" v-model:page="dataPage" v-model:limit="dataSize" :total="snapshotData.selectedCount" @pagination="loadData" /></template></el-tab-pane>
|
||||
<el-tab-pane label="快照与文件"><el-alert title="下载时重新校验原取数来源权限、结构及过滤范围;文件始终来自同一冻结快照。" type="info" :closable="false" class="mb-3" /><el-table :data="artifacts" border><el-table-column prop="name" label="文件" min-width="240" /><el-table-column prop="length" label="字节数" width="100" /><el-table-column label="状态" width="100"><template #default="{ row }">{{ row.state === 'BOUND' ? '已保存' : '待核对' }}</template></el-table-column><el-table-column label="操作" width="100"><template #default="{ row }"><el-button link type="primary" :disabled="row.state !== 'BOUND'" @click="download(row)">下载</el-button></template></el-table-column></el-table></el-tab-pane>
|
||||
<el-tab-pane label="业务附件" lazy><AttachmentPanel :key="`${selected.id}:${selected.version}`" :batch="selected" @refresh="refreshDetails" /></el-tab-pane>
|
||||
<el-tab-pane label="审核与操作记录"><el-table :data="audits" border><el-table-column prop="occurredAt" label="时间" width="190" /><el-table-column prop="action" label="操作" /><el-table-column prop="actorId" label="操作人" /><el-table-column prop="reason" label="意见 / 原因" min-width="300" /></el-table><pagination v-show="auditTotal > 0" v-model:page="auditPage" v-model:limit="auditSize" :total="auditTotal" @pagination="loadAudit" /></el-tab-pane>
|
||||
<el-tab-pane label="提交预检"><el-alert v-for="item in blockers" :key="item" :title="item" type="warning" :closable="false" class="mb-3" /></el-tab-pane>
|
||||
<el-tab-pane label="提交与核验" lazy><SubmissionPanel :key="`${selected.id}:${selected.version}`" :batch="selected" @refresh="refreshDetails" /></el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import AttachmentPanel from './AttachmentPanel.vue';
|
||||
import SubmissionPanel from './SubmissionPanel.vue';
|
||||
import DailyReportPanel from './DailyReportPanel.vue';
|
||||
import * as api from '@/api/datagov/regulatory-reporting/execution';
|
||||
import type { Audit } from '@/api/datagov/regulatory-reporting';
|
||||
import { listPlans, getPlan, matchFields, matchDirect } from '@/api/datagov/regulatory-reporting/plans';
|
||||
import type { Plan, DatasetField } from '@/api/datagov/regulatory-reporting/plans';
|
||||
import type { Plan, DatasetField, SqlParameter } from '@/api/datagov/regulatory-reporting/plans';
|
||||
const editPermission = 'aixun:integration:regulatory-reporting:edit';
|
||||
function rowSummary(batch: api.Batch) {
|
||||
const failures = new Set(batch.issues.filter(i => i.severity === 'BLOCKING' && i.row > 0).map(i => `${i.resource}:${i.row}`)).size;
|
||||
const global = batch.issues.some(i => i.severity === 'BLOCKING' && i.row === 0);
|
||||
return `共 ${batch.rowCount} 条,逐条校验失败 ${failures} 条,${global ? '其余仍受批次级阻断影响' : `逐条检查通过 ${Math.max(0, batch.rowCount - failures)} 条`};全部记录保留,未静默排除失败数据。`;
|
||||
return `共 ${batch.rowCount} 条,逐条校验失败 ${failures} 条,${global ? '其余仍受批次级阻断影响' : `逐条检查通过 ${Math.max(0, batch.rowCount - failures)} 条`};${batch.snapshotId ? '全部记录保留于快照,未静默排除失败数据。' : '快照尚未保存完成,以上只是已记录的校验结果,不代表可审核或提交。'}`;
|
||||
}
|
||||
const periods: Record<string, string> = { MONTH: '月报', QUARTER: '季报', YEAR: '年报', CUSTOM: '自定义期间' };
|
||||
const operators = { EQ: '等于', NE: '不等于', GT: '大于', GTE: '大于等于', LT: '小于', LTE: '小于等于', IN: '属于所选集合', NOT_IN: '不属于所选集合', IS_NULL: '为空', IS_NOT_NULL: '不为空' };
|
||||
const states: Record<string, string> = { DRAFT: '待生成候选数据', READING: '读取中', VALIDATION_FAILED: '校验未通过', REVIEW_PENDING: '待审核', ATTACHING: '附件保存中', ATTACHMENT_UNKNOWN: '附件待核对', REJECTED: '审核驳回', FROZEN: '已审核冻结', GENERATING: '文件生成中', FILE_READY: '文件已生成', FAILED: '处理失败', UNKNOWN: '结果待核对', CANCELED: '已撤销' };
|
||||
const actionNames: Record<string, string> = { prepare: '生成候选数据', approve: '审核并冻结', reject: '驳回', generate: '生成文件', reconcile: '核对结果', cancel: '撤销' };
|
||||
Object.assign(states, { SUBMITTING: '提交中', ACCEPTED: '接口已受理', SUBMISSION_REJECTED: '接口拒绝', SUBMISSION_UNKNOWN: '接收结果待核实', NOT_SENT: '请求未发送' });
|
||||
const actionNames: Record<string, string> = { prepare: '生成候选数据', approve: '审核通过并生成文件', reject: '驳回', generate: '生成文件', reconcile: '核对结果', cancel: '撤销' };
|
||||
const tasks = ref<api.Task[]>([]), total = ref(0), page = ref(1), size = ref(20), loading = ref(false), failed = ref(false), busy = ref(false);
|
||||
const taskVisible = ref(false), taskId = ref(''), taskVersion = ref(-1), planChoices = ref<Plan[]>([]), columns = ref<Record<string, DatasetField[]>>({});
|
||||
const targets = ref<Record<string, string[]>>({});
|
||||
const sourceParams = ref<Record<string, SqlParameter[]>>({});
|
||||
const blank = (): api.TaskDefinition => ({ name: '', planId: '', planVersion: 0, periodType: 'MONTH', selections: [] });
|
||||
const draft = ref(blank()), currentTask = ref<api.Task>(), batchesVisible = ref(false), batches = ref<api.Batch[]>([]), batchTotal = ref(0), batchPage = ref(1), batchSize = ref(20), dates = ref<string[]>([]);
|
||||
const detailVisible = ref(false), selected = ref<api.Batch>(), artifacts = ref<api.Artifact[]>([]), audits = ref<Audit[]>([]), blockers = ref<string[]>([]), auditPage = ref(1), auditSize = ref(20), auditTotal = ref(0);
|
||||
const pendingBatchId = ref('');
|
||||
watch(dates, () => { pendingBatchId.value = ''; });
|
||||
const draft = ref(blank()), currentTask = ref<api.Task>(), batchesVisible = ref(false), batches = ref<api.Batch[]>([]), batchTotal = ref(0), batchPage = ref(1), batchSize = ref(20);
|
||||
const detailVisible = ref(false), selected = ref<api.Batch>(), artifacts = ref<api.Artifact[]>([]), audits = ref<Audit[]>([]), auditPage = ref(1), auditSize = ref(20), auditTotal = ref(0);
|
||||
const snapshotData = ref<api.SnapshotView>(), dataPage = ref(1), dataSize = ref(20);
|
||||
async function loadData() { if (selected.value?.snapshotId) snapshotData.value = (await api.batchData(selected.value.id, dataPage.value, dataSize.value)).data; }
|
||||
async function load() { loading.value = true; failed.value = false; try { const r = (await api.listTasks(page.value, size.value)).data; tasks.value = r.rows; total.value = r.total; } catch { failed.value = true; tasks.value = []; } finally { loading.value = false; } }
|
||||
async function searchPlans(keyword: string) { planChoices.value = (await listPlans({ keyword, pageNum: 1, pageSize: 100 })).data.rows; }
|
||||
async function editTask(row?: unknown) { const task = row as api.Task | undefined; taskId.value = task?.id || crypto.randomUUID(); taskVersion.value = task?.version ?? -1; draft.value = task ? JSON.parse(JSON.stringify(task.definition)) : blank(); draft.value.selections.forEach(s => { s.attachmentFields ||= []; }); columns.value = {}; targets.value = {}; await searchPlans(''); if (task) await loadColumns((await getPlan(task.definition.planId)).data); taskVisible.value = true; }
|
||||
async function loadColumns(plan: Plan) { for (const binding of plan.definition.bindings) { columns.value[binding.resourceCode] = binding.directSource ? (await matchDirect(plan.definition.standardId, binding.resourceCode, binding.directSource.definition)).data.source.fields : (await matchFields(plan.definition.standardId, binding.resourceCode, binding.datasetId!)).data.dataset.fields; targets.value[binding.resourceCode] = binding.mappings.map(m => m.target); } }
|
||||
async function loadColumns(plan: Plan) { sourceParams.value = {}; for (const binding of plan.definition.bindings) { sourceParams.value[binding.resourceCode] = binding.directSource?.definition.parameters || []; columns.value[binding.resourceCode] = binding.directSource ? (await matchDirect(plan.definition.standardId, binding.resourceCode, binding.directSource.definition)).data.source.fields : (await matchFields(plan.definition.standardId, binding.resourceCode, binding.datasetId!)).data.dataset.fields; targets.value[binding.resourceCode] = binding.mappings.map(m => m.target); } }
|
||||
async function choosePlan(id: string) { busy.value = true; try { const plan = (await getPlan(id)).data; draft.value.planVersion = plan.version; draft.value.selections = plan.definition.bindings.map(b => ({ resourceCode: b.resourceCode, periodField: '', keyFields: [], filters: [], attachmentFields: [] })); await loadColumns(plan); } finally { busy.value = false; } }
|
||||
async function save() { if (busy.value) return; busy.value = true; try { for (const selection of draft.value.selections) for (const filter of selection.filters) if (filter.operator.includes('NULL')) filter.values = []; await api.saveTask(taskId.value, taskVersion.value, draft.value); taskVisible.value = false; ElMessage.success('任务已保存'); await load(); } finally { busy.value = false; } }
|
||||
async function reason(title: string) { return (await ElMessageBox.prompt('请填写操作原因;审核通过时须说明警告项和空报记录的核对结论。', title, { inputType: 'textarea', inputValidator: (v: string) => !!v?.trim() && v.length <= 1000 || '请填写1—1000字意见' })).value; }
|
||||
async function toggle(row: unknown) { const task = row as api.Task; await api.enableTask(task, await reason(task.enabled ? '停用任务' : '启用任务')); await load(); }
|
||||
async function openBatches(row: unknown) { const task = row as api.Task; currentTask.value = task; batchPage.value = 1; dates.value = []; await loadBatches(); batchesVisible.value = true; }
|
||||
async function openBatches(row: unknown) { const task = row as api.Task; currentTask.value = task; batchPage.value = 1; await loadBatches(); batchesVisible.value = true; }
|
||||
async function loadBatches() { if (!currentTask.value) return; const r = (await api.listBatches(currentTask.value.id, batchPage.value, batchSize.value)).data; batches.value = r.rows; batchTotal.value = r.total; }
|
||||
async function newBatch() { if (!currentTask.value || dates.value?.length !== 2 || busy.value) return; busy.value = true; pendingBatchId.value ||= crypto.randomUUID(); try { await api.createBatch(pendingBatchId.value, currentTask.value, dates.value[0], dates.value[1]); pendingBatchId.value = ''; await loadBatches(); } finally { busy.value = false; } }
|
||||
function actions(state: string): string[] { return ({ DRAFT: ['prepare', 'cancel'], REVIEW_PENDING: ['approve', 'reject'], FROZEN: ['generate', 'cancel'], READING: ['reconcile'], GENERATING: ['reconcile'], UNKNOWN: ['reconcile'], ATTACHING: ['reconcile'], ATTACHMENT_UNKNOWN: ['reconcile'], VALIDATION_FAILED: ['cancel'], REJECTED: ['cancel'], FAILED: ['cancel'], FILE_READY: ['cancel'] } as Record<string, string[]>)[state] || []; }
|
||||
async function act(row: unknown, operation: string) { const batch = row as api.Batch; if (busy.value) return; const opinion = await reason(actionNames[operation]); busy.value = true; try { const r = (await api.batchAction(batch, operation, opinion)).data; ElMessage.info(r.message || states[r.state]); } finally { busy.value = false; await loadBatches(); } }
|
||||
async function details(row: unknown) { const batch = row as api.Batch; selected.value = (await api.getBatch(batch.id)).data; artifacts.value = (await api.batchFiles(batch.id)).data; auditPage.value = 1; await loadAudit(); blockers.value = (await api.batchPrecheck(batch.id)).data.blockers; detailVisible.value = true; }
|
||||
async function act(row: unknown, operation: string) { const batch = row as api.Batch; if (busy.value) return; const opinion = await reason(actionNames[operation]); busy.value = true; try { const r = (await api.batchAction(batch, operation === 'approve' ? 'approve-and-generate' : operation, opinion)).data; ElMessage.info(r.message || states[r.state]); if (selected.value?.id === r.id) await details(r); } finally { busy.value = false; await loadBatches(); } }
|
||||
async function details(row: unknown) { const batch = row as api.Batch; snapshotData.value = undefined; dataPage.value = 1; selected.value = (await api.getBatch(batch.id)).data; artifacts.value = (await api.batchFiles(batch.id)).data; auditPage.value = 1; await loadAudit(); detailVisible.value = true; }
|
||||
async function refreshDetails() { if (selected.value) await details(selected.value); await loadBatches(); }
|
||||
async function loadAudit() { if (!selected.value) return; const r = (await api.batchAudit(selected.value.id, auditPage.value, auditSize.value)).data; audits.value = r.rows; auditTotal.value = r.total; }
|
||||
function saveBlob(blob: Blob, name: string) { const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = name; a.click(); URL.revokeObjectURL(url); }
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
<el-form-item label="方案编码" required><el-input v-model="draft.code" :disabled="version >= 0" maxlength="64" /></el-form-item>
|
||||
<el-form-item label="方案名称" required><el-input v-model="draft.name" maxlength="160" /></el-form-item>
|
||||
<el-form-item label="方案版本" required><el-input v-model="draft.versionLabel" :disabled="version >= 0" maxlength="64" placeholder="如 V1.0" /></el-form-item>
|
||||
<el-form-item label="监管接收机构" required><el-select v-model="draft.regulatorId" filterable @change="regulatorChanged"><el-option v-for="r in regulators" :key="r.id" :value="r.id" :label="r.name" /></el-select></el-form-item>
|
||||
<el-form-item label="上报系统" required><el-select v-model="draft.systemId" filterable @change="systemChanged"><el-option v-for="r in systems" :key="r.id" :value="r.id" :label="r.name" /></el-select></el-form-item>
|
||||
<el-form-item label="报送主题" required><el-select v-model="draft.topicId" filterable><el-option v-for="r in topics" :key="r.id" :value="r.id" :label="r.name" /></el-select></el-form-item>
|
||||
<el-form-item label="报送主题" required><el-select v-model="draft.topicId" filterable @change="topicChanged"><el-option v-for="r in topics" :key="r.id" :value="r.id" :label="r.name" /></el-select></el-form-item>
|
||||
<el-form-item label="监管接收机构"><el-input :model-value="regulators.find(r => r.id === draft.regulatorId)?.name || ''" readonly /></el-form-item>
|
||||
<el-form-item label="上报系统"><el-input :model-value="systems.find(r => r.id === draft.systemId)?.name || ''" readonly /></el-form-item>
|
||||
<el-form-item label="固定标准版本" required><el-select v-model="draft.standardId" filterable remote :remote-method="searchStandards" :loading="standardLoading" :no-data-text="standardError ? '加载失败,请重试' : '暂无匹配的已发布标准'" @change="standardChanged"><el-option v-for="s in standardOptions" :key="s.id" :value="s.id" :label="`${s.definition.name} · ${s.definition.versionLabel} (${s.status === 'PUBLISHED' ? '已发布' : '不可用'})`" :disabled="s.status !== 'PUBLISHED'" /></el-select><el-button v-if="standards.length < standardTotal" link :loading="standardLoading" @click="loadStandards(true)">加载更多({{ standards.length }}/{{ standardTotal }})</el-button></el-form-item>
|
||||
<el-alert v-if="standardError" :title="standardError" type="error" :closable="false" class="mb-3"><el-button link type="primary" @click="searchStandards(standardKeyword)">重新加载标准</el-button></el-alert>
|
||||
<el-form-item label="适配配置" required><el-select v-model="draft.adapterProfile"><el-option label="科技创新 B 接口" value="SASAC_SCIENCE_B" /><el-option label="司库 B 接口" value="SASAC_TREASURY_B" /></el-select></el-form-item>
|
||||
@@ -38,7 +38,7 @@
|
||||
<div v-show="step === 1">
|
||||
<el-alert v-if="!resources.length" title="请先选择已发布的标准" type="warning" :closable="false" />
|
||||
<el-tabs v-model="activeResource"><el-tab-pane v-for="resource in resources" :key="resource.code" :label="`${resource.name} (${resource.fields.length})`" :name="resource.code">
|
||||
<el-form-item label="业务库直连"><DirectSourcePicker :standard-id="draft.standardId" :resource-code="resource.code" :disabled="!editing || busy" :current="binding(resource.code)?.directSource" @bound="bindDirect(resource.code, $event)" /></el-form-item>
|
||||
<el-form-item label="SQL / 表取数"><DirectSourcePicker :standard-id="draft.standardId" :resource-code="resource.code" :disabled="!editing || busy" :current="binding(resource.code)?.directSource" @bound="bindDirect(resource.code, $event)" /></el-form-item>
|
||||
<el-form-item label="或授权数据集"><el-select :model-value="binding(resource.code)?.datasetId" filterable remote :remote-method="searchDatasets" :loading="datasetLoading" @visible-change="value => value && searchDatasets('')" @change="bind(resource.code, $event)"><el-option v-for="d in datasetOptions" :key="d.id" :value="d.id" :label="`${d.name} (${d.code})`" /></el-select></el-form-item>
|
||||
<el-alert v-if="datasetError" :title="datasetError" type="error" :closable="false" class="mb-3" />
|
||||
<p v-if="binding(resource.code)?.directSource" class="mb-3">已绑定直连来源 · 连接版本 {{ binding(resource.code)?.directSource?.sourceVersion }} · {{ binding(resource.code)?.directSource?.definition.tables.map(t => t.table).join('、') }}</p>
|
||||
@@ -49,14 +49,14 @@
|
||||
<el-table-column label="来源字段" min-width="220"><template #default="{ row }"><el-select v-model="row.source" filterable clearable @change="row.confirmed = false"><el-option v-for="f in sourceFields[resource.code] || []" :key="f.name" :value="f.name" :label="`${f.name} · ${f.type}`" /><el-option v-if="row.source && !sourceFields[resource.code]?.some(f => f.name === row.source)" :value="row.source" :label="row.source" /></el-select></template></el-table-column>
|
||||
<el-table-column label="匹配依据" min-width="230"><template #default="{ row }"><template v-if="suggestion(resource.code, row.target)">{{ methodLabels[suggestion(resource.code, row.target)!.method] || '人工核对' }} · {{ confidenceLabels[suggestion(resource.code, row.target)!.confidence] || '待核对' }}<p>{{ suggestion(resource.code, row.target)?.reason }}</p></template><span v-else>已保存映射;可重新读取后检查</span></template></el-table-column>
|
||||
<el-table-column label="转换" width="130"><template #default="{ row }"><el-button link type="primary" @click="configureTransform(row, resource.code)">{{ row.transform?.kind || '直接映射' }}</el-button></template></el-table-column>
|
||||
<el-table-column label="人工确认" width="110"><template #default="{ row }"><el-checkbox v-model="row.confirmed" :disabled="!row.source && !['CONSTANT', 'REPORTER_CODE', 'CONCAT'].includes(row.transform?.kind || '')">已核对</el-checkbox></template></el-table-column>
|
||||
<el-table-column label="对应确认" width="120"><template #default="{ row }"><el-checkbox v-model="row.confirmed" :disabled="!row.source && !['CONSTANT', 'REPORTER_CODE', 'CONCAT'].includes(row.transform?.kind || '')">{{ suggestion(resource.code, row.target)?.method === 'AUTOMATIC' && row.source === suggestion(resource.code, row.target)?.candidates[0] && !row.transform ? '自动对应' : '已核对' }}</el-checkbox></template></el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane></el-tabs>
|
||||
</div>
|
||||
<div v-show="step === 2"><p class="mb-3">{{ draft.name || '--' }} · {{ draft.versionLabel || '--' }},{{ resources.length }} 个资源,已绑定 {{ draft.bindings.length }} 个取数来源。</p>
|
||||
<el-button v-if="editing" :loading="busy" @click="check">运行预检查</el-button><el-button v-if="editing" :loading="busy" @click="sample">当前资源映射试算(最多5条)</el-button><el-button v-if="checks" @click="exportIssues">导出检查结果</el-button>
|
||||
<template v-if="samples !== undefined"><el-alert title="样例仅用于核对映射;不含任务过滤,不代表完整数据、批次校验或快照。" type="info" :closable="false" class="my-3" /><el-table :data="samples" border empty-text="当前权限范围内没有样例记录"><el-table-column prop="resource" label="资源" width="150" /><el-table-column prop="row" label="样例" width="70" /><el-table-column label="源值"><template #default="{ row }"><pre style="white-space: pre-wrap; word-break: break-word">{{ JSON.stringify(row.source, null, 2) }}</pre></template></el-table-column><el-table-column label="转换后"><template #default="{ row }"><pre style="white-space: pre-wrap; word-break: break-word">{{ JSON.stringify(row.target, null, 2) }}</pre></template></el-table-column><el-table-column label="问题"><template #default="{ row }"><div v-for="(issue, i) in row.issues" :key="i">{{ issue.location }}:{{ issue.message }}</div></template></el-table-column></el-table></template>
|
||||
<el-alert v-if="checks" class="my-3" :title="checks.configurationValid ? '基础引用和字段映射检查通过;执行条件尚未齐备' : '检查发现待处理项'" type="warning" :closable="false" />
|
||||
<el-alert v-if="checks" class="my-3" :title="checks.executable ? '配置及外部提交条件检查通过;仍需批次校验与审核' : checks.configurationValid ? '配置可用于准备批次;外部提交仍有待处理项' : '配置检查发现待处理项'" :type="checks.executable ? 'success' : 'warning'" :closable="false" />
|
||||
<el-table v-if="checks" :data="checks.issues" border><el-table-column prop="location" label="位置" width="180" /><el-table-column prop="message" label="原因" /></el-table>
|
||||
</div>
|
||||
</el-form>
|
||||
@@ -70,7 +70,9 @@
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import DirectSourcePicker from './DirectSourcePicker.vue';
|
||||
import { listConfigs } from '@/api/datagov/regulatory-reporting';
|
||||
import { initialMappings } from './directSourceChoices';
|
||||
import { listConfigs, getConfig } from '@/api/datagov/regulatory-reporting';
|
||||
import { topicDefaults } from '@/api/datagov/regulatory-reporting/plans';
|
||||
import type { Audit, ConfigKind, ConfigView } from '@/api/datagov/regulatory-reporting';
|
||||
import { getStandard, listStandards } from '@/api/datagov/regulatory-reporting/standards';
|
||||
import type { StandardView } from '@/api/datagov/regulatory-reporting/standards';
|
||||
@@ -104,13 +106,13 @@ async function bindDirect(code: string, result: { source: DirectSource; suggesti
|
||||
if (binding(code)?.mappings.some(m => m.confirmed)) await ElMessageBox.confirm('替换来源将清除当前映射确认,是否继续?', '更换取数来源');
|
||||
sourceFields.value[code] = result.source.fields; suggestions.value[code] = result.suggestions;
|
||||
draft.value.bindings = draft.value.bindings.filter(b => b.resourceCode !== code);
|
||||
draft.value.bindings.push({ resourceCode: code, datasetId: null, datasetVersion: 0, releaseId: null, schemaVersionId: null, schemaSha256: null, directSource: result.source, mappings: result.suggestions.map(s => ({ target: s.target, source: s.candidates.length === 1 ? s.candidates[0] : '', confirmed: false })) });
|
||||
draft.value.bindings.push({ resourceCode: code, datasetId: null, datasetVersion: 0, releaseId: null, schemaVersionId: null, schemaSha256: null, directSource: result.source, mappings: initialMappings(result.suggestions) });
|
||||
}
|
||||
const methodLabels: Record<string, string> = { EXACT_CODE: '字段编码一致', NAME_CANDIDATE: '名称候选', NONE: '无候选' };
|
||||
const methodLabels: Record<string, string> = { AUTOMATIC: '自动对应', REPORTER_CODE: '使用上报单位配置', EXACT_CODE: '字段编码一致', NAME_CANDIDATE: '名称候选', NONE: '无候选' };
|
||||
const confidenceLabels: Record<string, string> = { HIGH: '高置信度', REVIEW_REQUIRED: '需核对', AMBIGUOUS: '无唯一匹配' };
|
||||
const auditLabels: Record<string, string> = { PLAN_CREATE: '创建方案', PLAN_UPDATE: '修改草稿', PLAN_FREEZE: '冻结配置', PLAN_DISABLE: '停用方案' };
|
||||
const auditRows = ref<Audit[]>([]), auditVisible = ref(false), auditId = ref(''), auditPage = ref(1), auditSize = ref(20), auditTotal = ref(0);
|
||||
const transformKinds = { DIRECT: '直接映射', CONSTANT: '常量', REPORTER_CODE: '上报系统单位信用代码', STABLE_GUID: '稳定GUID(业务主键+固定命名空间)', DEFAULT: '空值默认值', TRIM: '去首尾空白', UPPER: '转大写', LOWER: '转小写', DICTIONARY: '字典 / 组织编码 / 枚举映射', DATE: '日期格式', DATETIME: '日期时间格式', DECIMAL: '小数位规范', CONCAT: '多字段拼接' };
|
||||
const transformKinds = { DIRECT: '直接映射', CONSTANT: '常量', REPORTER_CODE: '上报系统单位信用代码', STABLE_GUID: '稳定GUID(业务主键+固定命名空间)', DEFAULT: '空值默认值', TRIM: '去首尾空白', UPPER: '转大写', LOWER: '转小写', DICTIONARY: '字典 / 组织编码 / 枚举映射', DATE: '日期格式', DATETIME: '日期时间格式', DECIMAL: '小数位规范', DECIMAL_PLAIN: '数值不变去尾零', CONCAT: '多字段拼接' };
|
||||
const transformVisible = ref(false), transformResource = ref(''), transformTarget = ref<Mapping>(), dictionaryRows = ref<{ source: string; target: string }[]>([]);
|
||||
const transform = ref<Transform>({ kind: 'DIRECT', argument: '', outputFormat: '', values: {}, sources: [] });
|
||||
const samples = ref<MappingSample[]>();
|
||||
@@ -124,13 +126,20 @@ watch(draft, () => { checks.value = undefined; samples.value = undefined; }, { d
|
||||
async function load() { loading.value = true; failed.value = false; try { const r = (await listPlans(query)).data; rows.value = r.rows; total.value = r.total; } catch { failed.value = true; rows.value = []; total.value = 0; } finally { loading.value = false; } }
|
||||
function search() { query.pageNum = 1; void load(); }
|
||||
async function configs(kind: ConfigKind, parentId?: string) { const result: ConfigView[] = []; for (let pageNum = 1; ; pageNum++) { const r = (await listConfigs({ kind, parentId, pageNum, pageSize: 100 })).data; result.push(...r.rows); if (result.length >= r.total) return result; if (!r.rows.length) throw new Error('配置分页读取不完整'); } }
|
||||
async function choices() { regulators.value = (await configs('DEPARTMENT')).filter(r => r.department?.role === 'REGULATOR'); await searchStandards(''); }
|
||||
async function choices() { regulators.value = (await configs('DEPARTMENT')).filter(r => r.department?.role === 'REGULATOR'); topics.value = await configs('TOPIC'); await searchStandards(''); }
|
||||
function reset() { step.value = 0; selectedStandard.value = undefined; sourceFields.value = {}; suggestions.value = {}; checks.value = undefined; datasetOptions.value = []; datasetError.value = ''; systems.value = []; topics.value = []; }
|
||||
async function create() { reset(); id.value = crypto.randomUUID(); version.value = -1; draft.value = blankPlan(); await choices(); editing.value = true; visible.value = true; }
|
||||
async function create() { reset(); id.value = crypto.randomUUID(); version.value = -1; draft.value = { ...blankPlan(), code: `report_${id.value.replaceAll('-', '')}`, versionLabel: 'V1' }; await choices(); editing.value = true; visible.value = true; }
|
||||
async function open(planId: string, edit: boolean) { reset(); const plan = (await getPlan(planId)).data; id.value = plan.id; version.value = plan.version; draft.value = plan.definition; await choices(); systems.value = await configs('SYSTEM', draft.value.regulatorId); topics.value = await configs('TOPIC', draft.value.systemId); selectedStandard.value = (await getStandard(draft.value.standardId)).data; activeResource.value = resources.value[0]?.code || ''; editing.value = edit; visible.value = true; }
|
||||
async function copy(planId: string) { await open(planId, true); id.value = crypto.randomUUID(); version.value = -1; draft.value.versionLabel = ''; }
|
||||
async function regulatorChanged() { draft.value.systemId = ''; draft.value.topicId = ''; topics.value = []; systems.value = draft.value.regulatorId ? await configs('SYSTEM', draft.value.regulatorId) : []; }
|
||||
async function systemChanged() { draft.value.topicId = ''; topics.value = draft.value.systemId ? await configs('TOPIC', draft.value.systemId) : []; }
|
||||
async function topicChanged() {
|
||||
const topic = topics.value.find(t => t.id === draft.value.topicId); if (!topic?.parentId) return;
|
||||
busy.value = true;
|
||||
try { const system = (await getConfig(topic.parentId)).data; systems.value = [system]; draft.value.systemId = system.id; draft.value.regulatorId = system.parentId || ''; draft.value.name ||= `${topic.name}报送方案`; draft.value.standardId = ''; draft.value.bindings = []; selectedStandard.value = undefined; sourceFields.value = {}; suggestions.value = {};
|
||||
const previous = (await topicDefaults(topic.id)).data[0];
|
||||
if (previous) { const standard = (await getStandard(previous.definition.standardId)).data; if (standard.status === 'PUBLISHED') { draft.value.standardId = standard.id; draft.value.adapterProfile = previous.definition.adapterProfile; await standardChanged(); } }
|
||||
else if (standardTotal.value === 1 && standards.value.length === 1) { draft.value.standardId = standards.value[0].id; await standardChanged(); }
|
||||
} finally { busy.value = false; }
|
||||
}
|
||||
async function standardChanged() { draft.value.bindings = []; sourceFields.value = {}; suggestions.value = {}; selectedStandard.value = (await getStandard(draft.value.standardId)).data; draft.value.standardVersion = selectedStandard.value.version; activeResource.value = resources.value[0]?.code || ''; }
|
||||
let datasetRequest = 0;
|
||||
async function searchDatasets(keyword: string) { const current = ++datasetRequest; datasetLoading.value = true; datasetError.value = ''; try { const page = (await listDatasets({ keyword, pageNum: 1, pageSize: 100 })).data; if (current === datasetRequest) { datasetOptions.value = page.rows; if (page.total > 100) ElMessage.info('候选超过 100 项,请输入名称缩小范围'); } } catch (e) { if (current === datasetRequest) { datasetOptions.value = []; datasetError.value = `数据集候选加载失败:${e instanceof Error ? e.message : '请重试'}。可单独使用业务库直连来源。`; } } finally { if (current === datasetRequest) datasetLoading.value = false; } }
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<div v-loading="busy">
|
||||
<el-alert v-if="error" :title="error" type="error" :closable="false" class="mb-3" />
|
||||
<el-alert title="接口受理、企业 DS 入库和委端入库分别核验。结果待核实时先核对原尝试,不重复发送。" type="info" :closable="false" class="mb-3" />
|
||||
<el-button class="mb-3" :disabled="busy" @click="load">刷新预检和提交记录</el-button>
|
||||
<el-alert v-for="item in check.blockers" :key="item" :title="item" type="warning" :closable="false" class="mb-3" />
|
||||
<el-alert v-if="check.submissionReady" title="当前满足提交条件;点击提交后将向已配置的接收端发送本批次正式 ZIP。" type="success" :closable="false" class="mb-3" />
|
||||
<el-button v-if="batch.state === 'FILE_READY'" v-hasPermi="[permission]" type="primary" :disabled="busy || !check.submissionReady" @click="submit">提交 B 接口</el-button>
|
||||
<el-button v-if="batch.state === 'SUBMITTING'" v-hasPermi="[permission]" :disabled="busy" @click="reconcile">核对中断的提交</el-button>
|
||||
<el-table :data="attempts" border class="my-3" empty-text="尚无提交尝试">
|
||||
<el-table-column prop="id" label="尝试标识" min-width="230" />
|
||||
<el-table-column prop="startedAt" label="提交时间" min-width="170" />
|
||||
<el-table-column prop="httpStatus" label="HTTP" width="80" />
|
||||
<el-table-column prop="serviceFlag" label="serviceFlag" width="100" />
|
||||
<el-table-column prop="message" label="接收结果" min-width="260" />
|
||||
<el-table-column prop="packageId" label="文件引用" min-width="230" />
|
||||
</el-table>
|
||||
<el-table :data="verifications" border empty-text="尚无企业 DS 或委端核验证据">
|
||||
<el-table-column label="人工核验目标" width="140"><template #default="{ row }">{{ row.target === 'ENTERPRISE_DS' ? '企业 DS' : '委端' }}</template></el-table-column>
|
||||
<el-table-column label="核验结果" width="110"><template #default="{ row }">{{ outcomes[row.outcome] }}</template></el-table-column>
|
||||
<el-table-column prop="evidenceRef" label="证据引用" min-width="180" />
|
||||
<el-table-column prop="note" label="说明" min-width="200" />
|
||||
<el-table-column prop="actorId" label="登记人" width="120" />
|
||||
<el-table-column prop="createdAt" label="登记时间" min-width="170" />
|
||||
</el-table>
|
||||
<el-form v-if="canVerify" v-hasPermi="[permission]" label-width="110px" class="mt-3" :disabled="busy">
|
||||
<el-form-item label="核验目标"><el-select v-model="verification.target"><el-option label="企业 DS" value="ENTERPRISE_DS" /><el-option label="委端" value="REGULATOR" /></el-select></el-form-item>
|
||||
<el-form-item label="核验结果"><el-select v-model="verification.outcome"><el-option v-for="(label, value) in outcomes" :key="value" :label="label" :value="value" /></el-select></el-form-item>
|
||||
<el-form-item label="证据引用" required><el-input v-model="verification.evidenceRef" maxlength="500" placeholder="填写可核对的文件引用或工单编号" /></el-form-item>
|
||||
<el-form-item label="核验说明" required><el-input v-model="verification.note" type="textarea" maxlength="1000" /></el-form-item>
|
||||
<el-form-item><el-button type="primary" :disabled="!verification.evidenceRef.trim() || !verification.note.trim()" @click="verify">登记人工核验证据</el-button></el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import * as api from '@/api/datagov/regulatory-reporting/execution';
|
||||
import { sourceError } from './directSourceChoices';
|
||||
const props = defineProps<{ batch: api.Batch }>();
|
||||
const emit = defineEmits<{ refresh: [] }>();
|
||||
const permission = 'aixun:integration:regulatory-reporting:edit';
|
||||
const busy = ref(false), error = ref('');
|
||||
const check = ref({ fileReady: false, submissionReady: false, blockers: [] as string[] });
|
||||
const attempts = ref<api.Submission[]>([]), verifications = ref<api.Verification[]>([]);
|
||||
const outcomes: Record<string, string> = { FOUND: '已核实入库', NOT_FOUND: '未发现记录', UNKNOWN: '待核实' };
|
||||
const verification = ref({ target: 'ENTERPRISE_DS', outcome: 'UNKNOWN', evidenceRef: '', note: '' });
|
||||
const canVerify = computed(() => attempts.value.length > 0 && ['ACCEPTED', 'SUBMISSION_REJECTED', 'SUBMISSION_UNKNOWN', 'NOT_SENT'].includes(props.batch.state));
|
||||
async function load() {
|
||||
if (busy.value) return; busy.value = true; error.value = ''; check.value.submissionReady = false;
|
||||
try { const [c, a, v] = await Promise.all([api.batchPrecheck(props.batch.id), api.batchSubmissions(props.batch.id), api.batchVerifications(props.batch.id)]); check.value = c.data; attempts.value = a.data; verifications.value = v.data; }
|
||||
catch (e) { error.value = sourceError(e); } finally { busy.value = false; }
|
||||
}
|
||||
async function mutate(action: () => Promise<unknown>) {
|
||||
if (busy.value) return; busy.value = true; error.value = '';
|
||||
try { await action(); emit('refresh'); } catch (e) { error.value = sourceError(e); check.value.submissionReady = false; } finally { busy.value = false; }
|
||||
}
|
||||
async function submit() {
|
||||
if (busy.value || !check.value.submissionReady) return;
|
||||
try { const { value } = await ElMessageBox.prompt('确认发送本批次已审核的正式 ZIP,请填写提交原因。', '提交 B 接口', { inputValidator: value => !!value?.trim() && value.length <= 1000 || '请填写1至1000字的提交原因' }); await mutate(() => api.batchAction(props.batch, 'submit', value)); }
|
||||
catch { /* User cancelled the prompt. Network failures are displayed by mutate. */ }
|
||||
}
|
||||
async function reconcile() { await mutate(() => api.batchAction(props.batch, 'submission-reconcile', '核对原提交')); }
|
||||
async function verify() { await mutate(() => api.recordVerification(props.batch.id, crypto.randomUUID(), { version: props.batch.version, ...verification.value })); }
|
||||
onMounted(load);
|
||||
</script>
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { schemaChoices, schemaKey, objectQuery, clearTableFields, sourceError, initialMappings } from './directSourceChoices';
|
||||
import type { DirectDefinition } from '@/api/datagov/regulatory-reporting/plans';
|
||||
describe('直连目录值契约', () => {
|
||||
it('标准同名字段自动确认,别名和单位默认值保留首次确认', () => {
|
||||
const mappings = initialMappings([
|
||||
{ target: 'ID', candidates: ['id'], method: 'AUTOMATIC', confidence: 'HIGH', compatible: true, reason: '' },
|
||||
{ target: 'COMPANY_ID', candidates: ['unified_social_credit_code'], method: 'NAME_CANDIDATE', confidence: 'REVIEW_REQUIRED', compatible: false, reason: '' },
|
||||
{ target: 'EXT_REPORTSOCIALCODE', candidates: [], method: 'REPORTER_CODE', confidence: 'REVIEW_REQUIRED', compatible: true, reason: '' }
|
||||
]);
|
||||
expect(mappings[0].confirmed).toBe(true); expect(mappings[0].source).toBe('id');
|
||||
expect(mappings[1].confirmed).toBe(false); expect(mappings[1].source).toBe('unified_social_credit_code');
|
||||
expect(mappings[2].confirmed).toBe(false); expect(mappings[2].transform?.kind).toBe('REPORTER_CODE');
|
||||
});
|
||||
it('MySQL/Doris空Schema使用null,真实名为--的Schema不改写', () => {
|
||||
const choices = schemaChoices([{ name: '--', schema: null }, { name: '--', schema: '--' }, { name: '业务', schema: 'business' }]);
|
||||
expect(choices.map(choice => choice.schema)).toEqual([null, '--', 'business']);
|
||||
for (const choice of choices) {
|
||||
const saved = JSON.parse(JSON.stringify({ alias: 't1', catalog: 'db', schema: choice.schema, table: 'table' }));
|
||||
expect(schemaKey(choices, saved.schema)).toBe(choice.key);
|
||||
expect(objectQuery(saved, 'TABLE').schema).toBe(choice.schema);
|
||||
expect(objectQuery(saved, 'COLUMN')).toEqual({ level: 'COLUMN', catalog: 'db', schema: choice.schema, table: 'table' });
|
||||
expect(JSON.stringify(saved)).not.toContain('schema-');
|
||||
}
|
||||
});
|
||||
it('目录刷新按实际值恢复选中项,不依赖选项顺序', () => {
|
||||
const choices = schemaChoices([{ name: '业务', schema: 'business' }, { name: '--', schema: null }]);
|
||||
expect(schemaKey(choices, null)).toBe('schema-1');
|
||||
expect(schemaKey(choices, 'gone')).toBeUndefined();
|
||||
});
|
||||
it('改变关联表清除其输出和所有关联条件,保留其他表', () => {
|
||||
const d: DirectDefinition = { sourceId: '1', tables: [], fields: [{ tableAlias: 't1', column: 'id', name: 'id' }, { tableAlias: 't2', column: 'credit', name: 'credit' }], joins: [{ leftTable: 't1', leftField: 'id', rightTable: 't2', rightField: 'company_id' }, { leftTable: 't2', leftField: 'dept', rightTable: 't3', rightField: 'id' }] };
|
||||
clearTableFields(d, 't2');
|
||||
expect(d.fields.map(f => f.tableAlias)).toEqual(['t1']);
|
||||
expect(d.joins[0].rightField).toBe(''); expect(d.joins[1].leftField).toBe(''); expect(d.joins[0].leftField).toBe('id');
|
||||
});
|
||||
it('保留400业务原因与定位信息', () => {
|
||||
expect(sourceError({ message: 'Request failed with status code 400', response: { data: { code: 110101, msg: '对象结构已变化', traceId: 'test-trace' } } })).toBe('对象结构已变化(定位标识:test-trace) [110101]');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { DirectDefinition, Mapping, Suggestion } from '@/api/datagov/regulatory-reporting/plans';
|
||||
import type { SourceObjectQuery } from '@/api/datagov/data-sources/types';
|
||||
|
||||
export interface SchemaChoice { key: string; label: string; schema: string | null }
|
||||
export function initialMappings(suggestions: Suggestion[]): Mapping[] {
|
||||
return suggestions.map(s => ({ target: s.target, source: s.candidates.length === 1 ? s.candidates[0] : '', confirmed: s.method === 'AUTOMATIC' && s.compatible,
|
||||
...(s.method === 'REPORTER_CODE' ? { transform: { kind: 'REPORTER_CODE', argument: '', outputFormat: '', values: {}, sources: [] } } : {}) }));
|
||||
}
|
||||
export function schemaChoices(rows: { name: string; schema?: string | null }[]): SchemaChoice[] {
|
||||
return rows.map((row, index) => ({ key: `schema-${index}`, label: row.schema == null ? '默认 Schema' : row.name, schema: row.schema ?? null }));
|
||||
}
|
||||
export function schemaKey(choices: SchemaChoice[], schema: string | null): string | undefined {
|
||||
return choices.find(choice => choice.schema === schema)?.key;
|
||||
}
|
||||
export function objectQuery(table: DirectDefinition['tables'][number], level: SourceObjectQuery['level']): Omit<SourceObjectQuery, 'pageNum' | 'pageSize'> {
|
||||
return { level, catalog: table.catalog ?? undefined, schema: table.schema, ...(level === 'COLUMN' ? { table: table.table } : {}) };
|
||||
}
|
||||
export function clearTableFields(definition: DirectDefinition, alias: string) {
|
||||
definition.fields = definition.fields.filter(field => field.tableAlias !== alias);
|
||||
for (const join of definition.joins) {
|
||||
if (join.leftTable === alias) join.leftField = '';
|
||||
if (join.rightTable === alias) join.rightField = '';
|
||||
}
|
||||
}
|
||||
export function sourceError(error: unknown): string {
|
||||
const e = error as { response?: { data?: { msg?: string; message?: string; traceId?: string; errorId?: string; code?: number } }; message?: string };
|
||||
const data = e?.response?.data;
|
||||
const message = data?.msg || data?.message || e?.message || '来源读取失败,请核对权限或连接状态';
|
||||
const identifier = data?.errorId || data?.traceId;
|
||||
return `${message}${identifier ? `(定位标识:${identifier})` : ''}${data?.code ? ` [${data.code}]` : ''}`;
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户