jhprjv2/ruoyi-ui/src/views/project/surBuildNode/buildNodeDrawer.vue

197 lines
7.2 KiB
Vue
Raw Normal View History

2023-08-10 21:09:49 +08:00
<template>
<div class="project-build-node-drawer" v-if="isOpen">
<el-drawer v-if="isOpen" :visible.sync="isOpen" direction="rtl" size="60%" style="padding-left: 20px;">
<template slot="title">
<div>{{ title + ' 【计划节点】' }}</div>
<right-toolbar @queryTable="loadData" :search="false">
2023-08-18 00:18:13 +08:00
<template slot="left">
<el-button type="primary" @click="doExport"></el-button>
<el-popover placement="top-start" title="提示" trigger="hover" content="请选择导出的模板修改后的文件。">
<el-button type="success" slot="reference" @click="doImport" style="margin:0px 12px;">导入</el-button>
</el-popover>
</template>
2023-08-10 21:09:49 +08:00
</right-toolbar>
</template>
2023-08-18 00:18:13 +08:00
<el-tabs v-model="activeName">
<el-tab-pane :label="'' + it.nodeText" :name="'' + it.id" :key="idx" v-for="(it, idx) in nodes">
<node-item :item="it" :showLabel="false" style="border-bottom: solid 1px #ccc;"></node-item>
<div v-for="(it2, idx) in it.children" :key="idx" class="lvl-2">
<node-item :item="it2"></node-item>
<div v-for="(it3, idx) in it2.children" :key="idx" v-if="it2.children.length > 0"
style="padding-left: 40px;" class="lvl-3">
<node-item :item="it3"></node-item>
2023-08-10 21:09:49 +08:00
</div>
2023-08-18 00:18:13 +08:00
</div>
</el-tab-pane>
2023-08-10 21:09:49 +08:00
</el-tabs>
</el-drawer>
2023-08-18 00:18:13 +08:00
<!-- 用户导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="600px"
:close-on-click-modal="false" :close-on-press-escape="false"
append-to-body :custom-class="'build-node-import-dlg file-'+ upload.files.length">
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :multiple="false" :on-change="uploadChange"
:action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-remove="uploadChange"
:on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
@click="doExport">下载模板</el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
2023-08-10 21:09:49 +08:00
</div>
</template>
<script>
2023-08-18 00:18:13 +08:00
import { listByProject } from '@/api/project/build_node_data.js'
import { getToken } from "@/utils/auth";
2023-08-10 21:09:49 +08:00
import NodeItem from './nodeItem.vue'
export default {
name: 'RuoyiUiBuildNodeDrawer',
2023-08-18 00:18:13 +08:00
components: {
2023-08-10 21:09:49 +08:00
NodeItem
},
data() {
return {
2023-08-18 00:18:13 +08:00
isOpen: false,
2023-08-10 21:09:49 +08:00
prj: null,
2023-08-18 00:18:13 +08:00
nodes: [],
activeName: '',
// 用户导入参数
upload: {
files:[],
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API+"/project/build_node_data/importData"
},
2023-08-10 21:09:49 +08:00
};
},
mounted() {
},
methods: {
2023-08-18 00:18:13 +08:00
uploadChange(a,b,c){
this.upload.files=b;
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
this.loadData();
},
submitFileForm() {
this.$refs.upload.submit();
},
doImport() {
this.upload.title = `${this.prj.projectName}_项目计划节点导入`;
this.upload.open = true;
},
doExport() {
this.download('project/build_node_data/export', {
projectId: this.prj.id
}, `${this.prj.projectName}_项目计划节点.xlsx`);
},
loadData(init) {
listByProject(this.prj.id).then(d => {
let tmps = (d.data || []).map(it => {
it.lvl = it.baseBuildNode.nodeLvl;
it.parentLvl = it.lvl.substring(0, it.lvl.length - 2);
it.nodeText = it.baseBuildNode.nodeText;
it.file = this.$tryToJson(it.files, []);
return it;
2023-08-10 21:09:49 +08:00
});
2023-08-18 00:18:13 +08:00
let objs = tmps.filter(d => d.parentLvl.length == 0);
objs.forEach(it => {
it.children = tmps.filter(item => item.parentLvl == it.lvl)
it.children.forEach(item => {
item.children = tmps.filter(item3 => item3.parentLvl == item.lvl);
});
})
this.nodes = objs;
if (init) {
this.activeName = objs.length > 0 ? objs[0].id + '' : '';
}
2023-08-10 21:09:49 +08:00
});
},
show(prj) {
this.prj = prj;
this.title = prj.projectName;
this.isOpen = true;
this.loadData(true);
}
},
};
</script>
<style lang="scss" scoped>
2023-08-18 00:18:13 +08:00
.project-build-node-drawer {
::v-deep .el-drawer {
2023-08-10 21:09:49 +08:00
min-width: 1600px;
}
2023-08-18 00:18:13 +08:00
::v-deep .el-drawer__header {
2023-08-10 21:09:49 +08:00
margin-bottom: 0px;
}
2023-08-18 00:18:13 +08:00
::v-deep .el-drawer__body {
padding: 0px 24px;
2023-08-10 21:09:49 +08:00
.el-form {
overflow: hidden;
2023-08-18 00:18:13 +08:00
.el-form-item {
2023-08-10 21:09:49 +08:00
margin-bottom: 15px !important;
}
}
2023-08-18 00:18:13 +08:00
.lvl-3 {
.lbl-title {
2023-08-10 21:09:49 +08:00
font-size: 12px;
}
}
}
}
</style>
2023-08-18 00:18:13 +08:00
<style lang="scss">
.build-node-import-dlg{
.el-upload{
width:100%;
.el-upload-dragger{
width: 100%;
}
}
&.file-1{
.el-upload{
display: none;
}
.el-upload__tip{
display: none;
}
}
}
</style>