Browse Source

fix(gui-v2): add@import & emit

pull/2885/head
Wing-Kam Wong 2 years ago
parent
commit
c464277aab
  1. 3
      packages/nc-gui-v2/components/dlg/QuickImport.vue
  2. 7
      packages/nc-gui-v2/components/template/Editor.vue

3
packages/nc-gui-v2/components/dlg/QuickImport.vue

@ -265,7 +265,8 @@ function getAdapter(name: string, val: any) {
ref="templateEditorRef" ref="templateEditorRef"
:project-template="templateData" :project-template="templateData"
:import-data="importData" :import-data="importData"
:quick-import-type="importType" :quick-import-type="props.importType"
@import="handleImport"
/> />
<a-tabs v-else v-model:activeKey="activeKey" hide-add type="editable-card" :tab-position="top"> <a-tabs v-else v-model:activeKey="activeKey" hide-add type="editable-card" :tab-position="top">
<a-tab-pane key="uploadTab" :closable="false"> <a-tab-pane key="uploadTab" :closable="false">

7
packages/nc-gui-v2/components/template/Editor.vue

@ -28,6 +28,8 @@ interface Option {
const { quickImportType, projectTemplate, importData } = defineProps<Props>() const { quickImportType, projectTemplate, importData } = defineProps<Props>()
const emit = defineEmits(['import'])
const useForm = Form.useForm const useForm = Form.useForm
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
@ -73,6 +75,9 @@ const { sqlUi, project, loadTables } = useProject()
onMounted(() => { onMounted(() => {
parseAndLoadTemplate() parseAndLoadTemplate()
nextTick(() => {
inputRefs.value[0]?.focus()
})
}) })
const validators = computed(() => const validators = computed(() =>
@ -282,7 +287,7 @@ defineExpose({
<template> <template>
<a-spin :spinning="isImporting" :tip="importingTip" size="large"> <a-spin :spinning="isImporting" :tip="importingTip" size="large">
<a-card> <a-card>
<a-form :model="data" name="template-editor-form"> <a-form :model="data" name="template-editor-form" @keydown.enter="emit('import')">
<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' : '' }}
available for import available for import

Loading…
Cancel
Save