|
|
@ -92,8 +92,6 @@ const validators = computed(() => |
|
|
|
}, {}), |
|
|
|
}, {}), |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const editorTitle = computed(() => `${quickImportType.toUpperCase()} Import: ${data.title}`) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { validate, validateInfos } = useForm(data, validators) |
|
|
|
const { validate, validateInfos } = useForm(data, validators) |
|
|
|
|
|
|
|
|
|
|
|
function filterOption(input: string, option: Option) { |
|
|
|
function filterOption(input: string, option: Option) { |
|
|
@ -229,7 +227,7 @@ async function importTemplate() { |
|
|
|
await $api.dbTableColumn.primaryColumnSet(tableMeta.columns[0].id as string) |
|
|
|
await $api.dbTableColumn.primaryColumnSet(tableMeta.columns[0].id as string) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// bulk imsert data |
|
|
|
// bulk insert data |
|
|
|
if (importData) { |
|
|
|
if (importData) { |
|
|
|
let total = 0 |
|
|
|
let total = 0 |
|
|
|
let progress = 0 |
|
|
|
let progress = 0 |
|
|
@ -244,7 +242,7 @@ async function importTemplate() { |
|
|
|
for (let i = 0; i < data.length; i += offset) { |
|
|
|
for (let i = 0; i < data.length; i += offset) { |
|
|
|
importingTip.value = `Importing data to ${projectName}: ${progress}/${total} records` |
|
|
|
importingTip.value = `Importing data to ${projectName}: ${progress}/${total} records` |
|
|
|
const batchData = remapColNames(data.slice(i, i + offset), tableMeta.columns) |
|
|
|
const batchData = remapColNames(data.slice(i, i + offset), tableMeta.columns) |
|
|
|
await $api.dbTableRow.bulkCreate('noco', projectName, tableMeta.table_title, batchData) |
|
|
|
await $api.dbTableRow.bulkCreate('noco', projectName, tableMeta.title, batchData) |
|
|
|
progress += batchData.length |
|
|
|
progress += batchData.length |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -265,16 +263,15 @@ async function importTemplate() { |
|
|
|
isImporting.value = false |
|
|
|
isImporting.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defineExpose({ |
|
|
|
|
|
|
|
importTemplate, |
|
|
|
|
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<a-spin :spinning="isImporting" :tip="importingTip" size="large"> |
|
|
|
<a-spin :spinning="isImporting" :tip="importingTip" size="large"> |
|
|
|
<a-card :title="editorTitle"> |
|
|
|
<a-card> |
|
|
|
<template #extra> |
|
|
|
|
|
|
|
<a-button type="primary" size="large" @click="importTemplate"> |
|
|
|
|
|
|
|
{{ $t('activity.import') }} |
|
|
|
|
|
|
|
</a-button> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
<a-form :model="data" name="template-editor-form"> |
|
|
|
<a-form :model="data" name="template-editor-form"> |
|
|
|
<p v-if="data.tables && quickImportType === 'excel'" class="text-center"> |
|
|
|
<p v-if="data.tables && quickImportType === 'excel'" class="text-center"> |
|
|
|
{{ data.tables.length }} sheet{{ data.tables.length > 1 ? 's' : '' }} |
|
|
|
{{ data.tables.length }} sheet{{ data.tables.length > 1 ? 's' : '' }} |
|
|
@ -299,11 +296,7 @@ async function importTemplate() { |
|
|
|
@keydown.enter="setEditableTn(tableIdx, false)" |
|
|
|
@keydown.enter="setEditableTn(tableIdx, false)" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
<span |
|
|
|
<span v-else class="font-weight-bold text-lg flex items-center gap-2" @click="setEditableTn(tableIdx, true)"> |
|
|
|
v-else |
|
|
|
|
|
|
|
class="font-weight-bold text-lg flex items-center gap-2" |
|
|
|
|
|
|
|
@click="$event.stopPropagation() && setEditableTn(tableIdx, true)" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<MdiTableIcon class="text-primary" /> |
|
|
|
<MdiTableIcon class="text-primary" /> |
|
|
|
{{ table.table_name }} |
|
|
|
{{ table.table_name }} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|