修改导出方法,添加导入项目工程方法
This commit is contained in:
parent
dc5691e1f6
commit
144a4d5866
@ -104,11 +104,23 @@ export function simulationRun(projectId:string,scenarioId:string, data:any){
|
||||
|
||||
|
||||
|
||||
//新增项目
|
||||
export function exportAllExports(){
|
||||
|
||||
|
||||
export function exportAllExports(queryParams: any) {
|
||||
return request({
|
||||
url:'/projects/exportAllExports' ,
|
||||
method: 'get'
|
||||
url: '/projects/exportAllExports',
|
||||
method: 'get',
|
||||
params: queryParams,
|
||||
responseType: 'arraybuffer'
|
||||
});
|
||||
}
|
||||
export function exportProject(queryParams: any) {
|
||||
return request({
|
||||
url: '/projects/'+queryParams.projectId+'/exportProject',
|
||||
method: 'get',
|
||||
params: queryParams,
|
||||
responseType: 'arraybuffer'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -7,17 +7,17 @@ export default {
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, nextTick } from "vue";
|
||||
import { ElForm, ElMessage, ElMessageBox } from "element-plus";
|
||||
import { searchProjectsLsit,addProjects,updateProjects,deleteProjects,deleteBatchProjects,visibilityProjects} from "@/api/business/project";
|
||||
import { searchProjectsLsit,addProjects,updateProjects,deleteProjects,deleteBatchProjects,visibilityProjects,exportAllExports,exportProject} from "@/api/business/project";
|
||||
import Page from '@/components/Pagination/page.vue'
|
||||
import ScenarioModel from '@/views/component/scenario/index.vue'
|
||||
import Antvx6 from '@/components/antvx6/index.vue'
|
||||
import Readonlyx6 from '@/components/antvx6/readonlyx6.vue'
|
||||
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
const userStore = useUserStore();
|
||||
|
||||
const username = ref(userStore.username)
|
||||
|
||||
const url = import.meta.env.VITE_APP_BASE_API;
|
||||
|
||||
const apiUrl = import.meta.env.VITE_APP_BASE_API; // 基础路径
|
||||
const isShowAntvx6 = ref(false); // 是否展示分析设计弹窗
|
||||
@ -227,6 +227,65 @@ function closeAntvx6() {
|
||||
gettableData();
|
||||
isShowAntvx6.value = false;
|
||||
}
|
||||
|
||||
function downloadFile(obj :any, name :any, suffix :any) {
|
||||
const url = window.URL.createObjectURL(new Blob([obj]))
|
||||
const link = document.createElement('a')
|
||||
link.style.display = 'none'
|
||||
link.href = url
|
||||
const fileName = name.trim() + '.' + suffix
|
||||
link.setAttribute('download', fileName)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
|
||||
function exportAllExportsClick(){
|
||||
let params = {}
|
||||
exportAllExports(params).then((response:any) => {
|
||||
downloadFile(response, '全部项目' , 'xlsx')
|
||||
});
|
||||
}
|
||||
|
||||
function exportProjectClick(row: any){
|
||||
let params = {
|
||||
projectId: row.projectId,
|
||||
}
|
||||
exportProject(params).then((response:any) => {
|
||||
downloadFile(response, row.name , 'xlsx')
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function handlePreview(){
|
||||
// loadingtext.value = "正在导入数据,请耐心等待!"
|
||||
loading.value = true
|
||||
}
|
||||
const upload:any = ref(null)
|
||||
function handlesSuccess(file: any) {
|
||||
if(file !== false){
|
||||
ElMessage({
|
||||
message: "导入成功!",
|
||||
type: "success",
|
||||
});
|
||||
}else{
|
||||
ElMessage({
|
||||
message: "导入失败!",
|
||||
type: "error",
|
||||
});
|
||||
}
|
||||
|
||||
gettableData()
|
||||
upload.value.clearFiles()
|
||||
}
|
||||
function handleError(file: any){
|
||||
loading.value = false
|
||||
ElMessage({
|
||||
message: "导入失败!",
|
||||
type: "error",
|
||||
});
|
||||
upload.value.clearFiles()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -238,12 +297,23 @@ function closeAntvx6() {
|
||||
<el-input v-model="input" placeholder="请输入项目名称" @keyup.enter="gettableData" style="width: 200px" clearable />
|
||||
<el-button type="primary" style="margin-left: 10px" @click="gettableData">搜索</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: flex;display: -webkit-flex;">
|
||||
|
||||
<el-button type="primary" @click="addClick" style="margin-right: 10px">
|
||||
<el-button type="primary" @click="addClick" style="margin-right: 0px">
|
||||
新增</el-button>
|
||||
<a :href=" apiUrl + '/projects/exportAllExports'" target="_blank" rel="noopener noreferrer">
|
||||
<el-button type="primary">导出</el-button> </a>
|
||||
<el-button type="primary" @click="exportAllExportsClick">导出</el-button>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
accept=".xlsx,.xls"
|
||||
class="upload-demo"
|
||||
:action=" url + '/projects/import' "
|
||||
:headers="{ token: getToken() }"
|
||||
:show-file-list="false"
|
||||
:before-upload="handlePreview"
|
||||
:on-success="handlesSuccess"
|
||||
:on-error="handleError">
|
||||
<el-button type="primary" style="margin: 0 10px;">导入项目</el-button>
|
||||
</el-upload>
|
||||
<el-button type="primary"
|
||||
:disabled="multipleSelection.length <= 0" @click="delClick" style="margin-left: 10px"
|
||||
v-if="username == 'admin'">删除</el-button>
|
||||
@ -256,12 +326,18 @@ function closeAntvx6() {
|
||||
<el-table-column prop="code" label="项目编号" width="100"></el-table-column>
|
||||
<el-table-column prop="name" label="项目名称" width="180"></el-table-column>
|
||||
<el-table-column prop="description" label="项目描述" min-width="100"></el-table-column>
|
||||
<el-table-column prop="modifier" label="创建人" width="120"></el-table-column>
|
||||
<el-table-column prop="creator" label="创建人" width="120"></el-table-column>
|
||||
<el-table-column prop="createdAt" label="创建时间" width="200">
|
||||
<template #default="scope">
|
||||
{{ dateFormat(scope.row.createdAt) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="modifier" label="修改人" width="120"></el-table-column>
|
||||
<el-table-column prop="updatedAt" label="修改时间" width="200">
|
||||
<template #default="scope">
|
||||
{{ dateFormat(scope.row.updatedAt) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" label="操作" width="190">
|
||||
<template #default="scope">
|
||||
<span
|
||||
@ -276,13 +352,8 @@ function closeAntvx6() {
|
||||
style="cursor: pointer; ">
|
||||
|
||||
<img src="@/assets/table/permission.png" alt="" title="权限设置"
|
||||
style="cursor: pointer; " @click="permissionClick(scope.row)">
|
||||
|
||||
<a :href=" apiUrl + '/projects/' + scope.row.projectId + '/exportProject'" target="_blank" rel="noopener noreferrer">
|
||||
<img src="@/assets/table/export.png" alt="" title="导出项目工程"
|
||||
style="cursor: pointer; ">
|
||||
</a>
|
||||
|
||||
style="cursor: pointer; " @click="permissionClick(scope.row)" v-if="username == scope.row.creator || username == 'admin'">
|
||||
<img src="@/assets/table/export.png" alt="" title="导出项目工程" style="cursor: pointer; " @click="exportProjectClick(scope.row)">
|
||||
<img src="@/assets/table/del.png" alt="" title="删除"
|
||||
@click="delAloneClick(scope.row)" style="cursor: pointer;" v-if="username == scope.row.creator || username == 'admin'">
|
||||
</span>
|
||||
@ -307,8 +378,7 @@ function closeAntvx6() {
|
||||
<span class="dialog-footer"
|
||||
style="display: flex;display: -webkit-flex; justify-content: flex-end;-webkit-justify-content: flex-end;">
|
||||
<el-button @click="handleClose">取 消</el-button>
|
||||
<el-button type="primary" @click="confirmClick(infoForm)" v-if="username == 'admin' || 'PUBLIC' == info.visibility
|
||||
|| title == '新增项目'">确 定</el-button>
|
||||
<el-button type="primary" @click="confirmClick(infoForm)">确 定</el-button>
|
||||
</span>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user