Commit d0b86e83 authored by 高滢's avatar 高滢

feat(项目): 导入

parent 8e0179fe
......@@ -73,3 +73,6 @@ export const downImportT = (params?: any) =>
},
{ errorMessageMode: 'none', isTransformResponse: false },
);
export const exportTemplate = (params?: any) =>
defHttp.post<ProjectModel>({ url: Api.importDetails, params });
......@@ -53,7 +53,21 @@
<template #toolbar>
<a-button type="primary" preIcon="mdi:plus" @click="handleCreate"> 新增项目 </a-button>
<a-button type="primary" @click="downloadTemplate"> 下载模板 </a-button>
<a-button type="primary" @click="exportProjectData"> 导入数据 </a-button>
<a-button type="primary" @click="exportTemplate"> 导入数据 </a-button>
<BasicUpload :maxSize="20" :maxNumber="1" @change="handleChange" :accept="['.xlsx','docx']" :api="uploadApi" name="multipartFile" :value="fileList"/>
<Upload :action="uploadAction"
v-model:file-list="fileList"
name="file"
:multiple="false"
methods="post"
@change="uploadFile"
>
<Button>
<upload-outlined></upload-outlined>
导入文件
</Button>
</Upload>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'projectName'">
......@@ -90,24 +104,29 @@
</template>
</template>
</BasicTable>
<projectDrawer @register="registerDrawer" @success="handleSuccess" />
<uploadModal @register="registerModal"/>
<projectDrawer @register="registerDrawer" @success="handleSuccess"/>
<uploadContractModal @register="registerModal2" />
</div>
</template>
<script lang="ts" setup>
import { Tag } from 'ant-design-vue';
import { uploadApi } from '@/api/sys/upload';
import uploadContractModal from './uploadContractModal.vue';
import { useModal } from '@/components/Modal';
import { Tag, Row, Col ,Upload,Button} from 'ant-design-vue';
import { BasicTable, useTable, TableAction } from '@/components/Table';
import { getListByPage, deleteItem, getProjectCount,downImportT } from '@/api/project/project';
import { getListByPage, deleteItem, getProjectCount, downImportT } from '@/api/project/project';
import { columns, searchFormSchema } from './project.data';
import { Row, Col } from 'ant-design-vue';
import projectDrawer from './projectDrawer.vue';
import { useDrawer } from '@/components/Drawer';
import {useModal} from "@/components/Modal";
import { BasicUpload } from '@/components/Upload';
import { useRouter } from 'vue-router';
import { onMounted, ref ,computed} from 'vue';
import { downloadByData } from '@/utils/file/download';
const env = import.meta.env.MODE;
const uploadAction = "https://dev.unitj.cn/api/system/file/add"
const [registerModal2, { openModal: openModal2 }] = useModal();
const { push } = useRouter();
import { onMounted, ref } from 'vue';
import {downloadByData} from "@/utils/file/download";
const [registerModal, { openModal: openModal }] = useModal();
const fileList = ref([]);
const countData = ref({});
const [registerDrawer, { openDrawer }] = useDrawer();
const prefixCls = 'list-basic';
......@@ -130,19 +149,12 @@
fixed: undefined,
},
});
function downloadTemplate(){
downImportT().then((data) =>{
downloadByData( data,"项目库导入模板.xlsx");
})
function downloadTemplate() {
downImportT().then((data) => {
downloadByData(data, '项目库导入模板.xlsx');
});
}
function exportProjectData(){
openModal(true)
}
function handleChange(file){
console.log('112',file)
}
function handleCreate() {
openDrawer(true, {
isUpdate: false,
......@@ -181,8 +193,33 @@
let res = await getProjectCount();
console.log(res);
countData.value = res;
});
console.log(
'12132',uploadAction
)
})
function exportTemplate(){
openModal2(true);
};
function handleChange(file){
console.log('21212',file)
};
function uploadFile (info) {
console.log('上传文件', info)
// ant design 框架中此回调会运行三次,上传中、完成、失败都会调用这个函数。
const fileList = [...info.fileList]
this.fileList= fileList.slice(-1)
if (info.file.status === 'uploading') {
this.$loading.show()
return
}
if (info.file.status === 'done') {
// 上传成功 可以在下面写自己也业务逻辑了
this.$loading.hide()
}
};
</script>
<style lang="less" scoped>
.list-basic {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment