|
|
@ -7,7 +7,7 @@ import MdiFileIcon from '~icons/mdi/file-plus-outline' |
|
|
|
import MdiFileUploadOutlineIcon from '~icons/mdi/file-upload-outline' |
|
|
|
import MdiFileUploadOutlineIcon from '~icons/mdi/file-upload-outline' |
|
|
|
import MdiLinkVariantIcon from '~icons/mdi/link-variant' |
|
|
|
import MdiLinkVariantIcon from '~icons/mdi/link-variant' |
|
|
|
import MdiCodeJSONIcon from '~icons/mdi/code-json' |
|
|
|
import MdiCodeJSONIcon from '~icons/mdi/code-json' |
|
|
|
import { fieldRequiredValidator } from '~/utils/validation' |
|
|
|
import { fieldRequiredValidator, importUrlValidator } from '~/utils/validation' |
|
|
|
const { t } = useI18n() |
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
@ -32,7 +32,7 @@ const importState = ref({ |
|
|
|
|
|
|
|
|
|
|
|
const validators = computed(() => { |
|
|
|
const validators = computed(() => { |
|
|
|
return { |
|
|
|
return { |
|
|
|
url: [fieldRequiredValidator], |
|
|
|
url: [fieldRequiredValidator, importUrlValidator], |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -42,22 +42,31 @@ const handleDrop = (e: DragEvent) => { |
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rejectDrop = (fileList: any[]) => { |
|
|
|
|
|
|
|
fileList.map((file) => { |
|
|
|
|
|
|
|
toast.error(`Failed to upload file ${file.name}`) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const importMeta = computed(() => { |
|
|
|
const importMeta = computed(() => { |
|
|
|
if (importType === 'excel') { |
|
|
|
if (importType === 'excel') { |
|
|
|
return { |
|
|
|
return { |
|
|
|
uploadHint: t('msg.info.excelSupport'), |
|
|
|
uploadHint: t('msg.info.excelSupport'), |
|
|
|
urlInputLabel: t('msg.info.excelURL'), |
|
|
|
urlInputLabel: t('msg.info.excelURL'), |
|
|
|
loadUrlDirective: ['c:quick-import:excel:load-url'], |
|
|
|
loadUrlDirective: ['c:quick-import:excel:load-url'], |
|
|
|
|
|
|
|
acceptTypes: '.xls, .xlsx, .xlsm, .ods, .ots', |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (importType === 'csv') { |
|
|
|
} else if (importType === 'csv') { |
|
|
|
return { |
|
|
|
return { |
|
|
|
uploadHint: '', |
|
|
|
uploadHint: '', |
|
|
|
urlInputLabel: t('msg.info.csvURL'), |
|
|
|
urlInputLabel: t('msg.info.csvURL'), |
|
|
|
loadUrlDirective: ['c:quick-import:csv:load-url'], |
|
|
|
loadUrlDirective: ['c:quick-import:csv:load-url'], |
|
|
|
|
|
|
|
acceptTypes: '.csv', |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (importType === 'json') { |
|
|
|
} else if (importType === 'json') { |
|
|
|
return { |
|
|
|
return { |
|
|
|
uploadHint: '', |
|
|
|
uploadHint: '', |
|
|
|
|
|
|
|
acceptTypes: '.json', |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return {} |
|
|
|
return {} |
|
|
@ -78,9 +87,9 @@ const handleChange = (info: UploadChangeParam) => { |
|
|
|
console.log(info.file, info.fileList) |
|
|
|
console.log(info.file, info.fileList) |
|
|
|
} |
|
|
|
} |
|
|
|
if (status === 'done') { |
|
|
|
if (status === 'done') { |
|
|
|
toast.success(`${info.file.name} file uploaded successfully.`) |
|
|
|
toast.success(`Uploaded file ${info.file.name} successfully`) |
|
|
|
} else if (status === 'error') { |
|
|
|
} else if (status === 'error') { |
|
|
|
toast.error(`${info.file.name} file upload failed.`) |
|
|
|
toast.error(`Failed to upload file ${info.file.name}`) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -124,8 +133,10 @@ const handleSubmit = () => { |
|
|
|
v-model:fileList="importState.fileList" |
|
|
|
v-model:fileList="importState.fileList" |
|
|
|
name="file" |
|
|
|
name="file" |
|
|
|
:multiple="true" |
|
|
|
:multiple="true" |
|
|
|
|
|
|
|
:accept="importMeta.acceptTypes" |
|
|
|
@change="handleChange" |
|
|
|
@change="handleChange" |
|
|
|
@drop="handleDrop" |
|
|
|
@drop="handleDrop" |
|
|
|
|
|
|
|
@reject="rejectDrop" |
|
|
|
list-type="picture" |
|
|
|
list-type="picture" |
|
|
|
> |
|
|
|
> |
|
|
|
<MdiFileIcon size="large" /> |
|
|
|
<MdiFileIcon size="large" /> |
|
|
|