|
|
@@ -0,0 +1,84 @@
|
|
|
+import {
|
|
|
+ NButton,
|
|
|
+ NSpace,
|
|
|
+ NUpload,
|
|
|
+ NUploadFileList,
|
|
|
+ NUploadTrigger,
|
|
|
+ type UploadCustomRequestOptions,
|
|
|
+} from 'naive-ui';
|
|
|
+import {PropType, defineComponent, h, SlotsType} from 'vue';
|
|
|
+import {useI18n} from 'vue-i18n';
|
|
|
+import {
|
|
|
+ Download,
|
|
|
+ FileAdditionOne,
|
|
|
+ FileExcel,
|
|
|
+ Refresh,
|
|
|
+ Upload,
|
|
|
+} from '@icon-park/vue-next';
|
|
|
+import {useMutation} from '@tanstack/vue-query';
|
|
|
+import {ImportBomInfoDetail} from '@apis';
|
|
|
+import {useTableTitle} from '@hooks';
|
|
|
+import './index.css';
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'LDUploadTool',
|
|
|
+ props: {
|
|
|
+ title: String,
|
|
|
+ onAdd: Function as PropType<() => void>,
|
|
|
+ onAddMplan: Function as PropType<() => void>,
|
|
|
+ onExport: Function as PropType<() => void>,
|
|
|
+ isExporting: Boolean,
|
|
|
+ isAddMplan: Boolean,
|
|
|
+ onModalExport: Function as PropType<() => void>,
|
|
|
+ onModalImport: Function as PropType<() => void>,
|
|
|
+ },
|
|
|
+ setup(props, {slots}) {
|
|
|
+ const {t} = useI18n();
|
|
|
+ const tableTitle = useTableTitle();
|
|
|
+ const {isLoading, mutate} = useMutation({
|
|
|
+ mutationFn: ImportBomInfoDetail,
|
|
|
+ onSuccess: (data, variables) => {
|
|
|
+ console.log(data);
|
|
|
+ },
|
|
|
+ });
|
|
|
+ const fn = ({file, data}: UploadCustomRequestOptions) => {
|
|
|
+ // const formData = new FormData();
|
|
|
+ // formData.append(file.name, file.file as File);
|
|
|
+ mutate(file.file);
|
|
|
+ };
|
|
|
+ return () => (
|
|
|
+ <div style={{height: '100%'}}>{
|
|
|
+ props.onModalImport && <NUpload
|
|
|
+ abstract
|
|
|
+ defaultFileList={[]}
|
|
|
+ style={{
|
|
|
+ background: 'red',
|
|
|
+ height: '100%',
|
|
|
+ borderRadius: '6px',
|
|
|
+ }}
|
|
|
+ trigger-style={{
|
|
|
+ height: '100%',
|
|
|
+ color: '#fff',
|
|
|
+ display: 'flex',
|
|
|
+ alignItems: 'center',
|
|
|
+ justifyContent: 'center',
|
|
|
+ padding: '0px 10px',
|
|
|
+ gap: '6px',
|
|
|
+ cursor: 'pointer',
|
|
|
+ background: '#1E3588 ',
|
|
|
+ borderRadius: '6px',
|
|
|
+ }}
|
|
|
+ customRequest={fn}
|
|
|
+ data={{
|
|
|
+ 'naive-data': 'cool! naive!',
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <NUploadTrigger>
|
|
|
+ { h(Upload)} {t('common.tableTool.modalImport')}
|
|
|
+ </NUploadTrigger>
|
|
|
+ </NUpload>
|
|
|
+ }</div>
|
|
|
+
|
|
|
+ );
|
|
|
+ },
|
|
|
+});
|