|
|
@@ -1,15 +1,22 @@
|
|
|
<script setup lang='ts'>
|
|
|
import {useTableData, useColumns} from './hooks';
|
|
|
import {useTableExportEvent} from '@hooks';
|
|
|
-import {NCard} from 'naive-ui';
|
|
|
-import {BomInfoDetailExport} from '@apis';
|
|
|
+import {
|
|
|
+ NCard,
|
|
|
+ type UploadCustomRequestOptions,
|
|
|
+ useMessage,
|
|
|
+ UploadInst,
|
|
|
+} from 'naive-ui';
|
|
|
+import {BomInfoDetailExport, ImportBomInfoDetail} from '@apis';
|
|
|
import {LDTableTool, LDTable} from '@components';
|
|
|
import {pageSymbol, searchSymbol, pidSymbol, filterSymbol} from '../state';
|
|
|
import Modal from './modal/index.vue';
|
|
|
-import {inject} from 'vue';
|
|
|
+import {useMutation} from '@tanstack/vue-query';
|
|
|
+import {inject, ref, onMounted} from 'vue';
|
|
|
|
|
|
defineOptions({name: 'BomInfoPageTableDetail'});
|
|
|
|
|
|
+const id = inject<string>(pidSymbol)!;
|
|
|
const [
|
|
|
{isFetching, data, count},
|
|
|
{refetch},
|
|
|
@@ -19,9 +26,31 @@ const [isExporting, onExport] = useTableExportEvent(
|
|
|
pageSymbol,
|
|
|
{fn: BomInfoDetailExport},
|
|
|
);
|
|
|
+const message = useMessage();
|
|
|
+const uploadRef = ref();
|
|
|
const [{columns, visible, editId}, {onAdd}] = useColumns(refetch);
|
|
|
-</script>
|
|
|
+const {isLoading, mutate} = useMutation({
|
|
|
+ mutationFn: ImportBomInfoDetail,
|
|
|
+ onSuccess: async (data, variables) => {
|
|
|
+ if (data.msg === '200')
|
|
|
+ message.success('上传成功');
|
|
|
+ if (uploadRef.value)
|
|
|
+ await uploadRef.value.$.exposed.clear();
|
|
|
+ refetch();
|
|
|
+ },
|
|
|
+});
|
|
|
+const fileimport = ({file}: UploadCustomRequestOptions) => {
|
|
|
+ if (file.file) {
|
|
|
+ mutate({
|
|
|
+ file: file.file,
|
|
|
+ id,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ message.info('没有文件信息,请重新上传');
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
+</script>
|
|
|
<template>
|
|
|
<NCard class="table-wrapper">
|
|
|
<LDTableTool
|
|
|
@@ -29,7 +58,8 @@ const [{columns, visible, editId}, {onAdd}] = useColumns(refetch);
|
|
|
@refresh="refetch"
|
|
|
@add="onAdd"
|
|
|
@export="onExport"
|
|
|
- @modalImport="()=>{}"
|
|
|
+ @modalImport="fileimport"
|
|
|
+ ref="uploadRef"
|
|
|
/>
|
|
|
|
|
|
<LDTable
|