提交代码

This commit is contained in:
jiang 2024-12-01 18:43:48 +08:00
parent 27534f574c
commit 0183956746
4 changed files with 136 additions and 90 deletions

View File

@ -24,7 +24,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['dataCenter:dataSet:import']" v-hasPermi="['dataCenter:dataSet:import']"
>导入</el-button> >导入
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -35,7 +36,8 @@
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['dataCenter:dataSet:file:delete']" v-hasPermi="['dataCenter:dataSet:file:delete']"
>删除</el-button> >删除
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -44,24 +46,27 @@
icon="el-icon-close" icon="el-icon-close"
size="mini" size="mini"
@click="handleClose" @click="handleClose"
>关闭</el-button> >关闭
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table style="width: 100%" v-loading="loading" :data="list" :height="tableHeight" @selection-change="handleSelectionChange"> <el-table style="width: 100%" v-loading="loading" :data="list" :height="tableHeight"
<el-table-column type="selection" width="50" align="center" /> @selection-change="handleSelectionChange"
<el-table-column type="index" label="序号" :index="indexMethod" width="50" /> >
<el-table-column label="文件名称" align="center" show-overflow-tooltip prop="fileName" min-width="100" /> <el-table-column type="selection" width="50" align="center"/>
<el-table-column label="文件大小" align="center" show-overflow-tooltip prop="fileSize" > <el-table-column type="index" label="序号" :index="indexMethod" width="50"/>
<el-table-column label="文件名称" align="center" show-overflow-tooltip prop="fileName" min-width="100"/>
<el-table-column label="文件大小" align="center" show-overflow-tooltip prop="fileSize">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{scope.row.fileSize < 1024 * 1024?(scope.row.fileSize/1024).toFixed(2)+'KB':(scope.row.fileSize/1024/1024).toFixed(2)+'MB'}}</span> <span>{{ scope.row.fileSize < 1024 * 1024 ? (scope.row.fileSize / 1024).toFixed(2) + 'KB' : (scope.row.fileSize / 1024 / 1024).toFixed(2) + 'MB' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="格式" align="center" show-overflow-tooltip prop="createBy" min-width="100"> <el-table-column label="格式" align="center" show-overflow-tooltip prop="createBy" min-width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<span> <span>
{{scope.row.fileName.split('.').pop()}} {{ scope.row.fileName.split('.').pop() }}
</span> </span>
</template> </template>
</el-table-column> </el-table-column>
@ -70,7 +75,7 @@
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" min-width="100" class-name="small-padding fixed-width" > <el-table-column label="操作" align="center" min-width="100" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
@ -78,7 +83,8 @@
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['dataCenter:dataSet:file:delete']" v-hasPermi="['dataCenter:dataSet:file:delete']"
>删除</el-button> >删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -92,20 +98,23 @@
/> />
<!-- 导入 --> <!-- 导入 -->
<import-dialog :get-list="getList" :open="importOpen" :data-type="dataType" :dataset-id="datasetId.toString()" @dialog-cancel="handleCancel"/> <import-dialog :get-list="getList" :open="importOpen" :data-type="dataType" :dataset-id="datasetId.toString()"
@dialog-cancel="handleCancel"
/>
</div> </div>
</template> </template>
<script> <script>
import { list,remove} from '@/api/dataCenter/dataSetDetails' import { list, remove } from '@/api/dataCenter/dataSetDetails'
import importDialog from './importDialog.vue' import importDialog from './importDialog.vue'
export default { export default {
components: { importDialog }, components: { importDialog },
name: "DataSet", name: 'DataSet',
data() { data() {
return { return {
dataType:'0', dataType: '0',
datasetId: '0', datasetId: '0',
// //
loading: true, loading: true,
@ -128,78 +137,92 @@ export default {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
datasetName: null, datasetName: null
}, }
}; }
}, },
created() { created() {
this.dataType = this.$route.query && this.$route.query.dataType; this.dataType = this.$route.query && this.$route.query.dataType
this.datasetId = this.$route.params && this.$route.params.dataSetId; this.datasetId = this.$route.params && this.$route.params.dataSetId
this.getList(); this.getList()
// //
this.updateTableHeight(); this.updateTableHeight()
// //
window.addEventListener("resize", this.updateTableHeight); window.addEventListener('resize', this.updateTableHeight)
},
watch: {
$route(to, from) {
//
if (to.fullPath !== from.fullPath) {
this.dataType = this.$route.query && this.$route.query.dataType
this.datasetId = this.$route.params && this.$route.params.dataSetId
this.getList()
//
this.updateTableHeight()
//
window.addEventListener('resize', this.updateTableHeight)
}
}
}, },
methods: { methods: {
indexMethod(index){ indexMethod(index) {
console.log(index); return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
}, },
updateTableHeight() { updateTableHeight() {
// //
const headerHeight = 200; // const headerHeight = 200 //
const footerHeight = 80; // const footerHeight = 80 //
this.tableHeight = window.innerHeight - headerHeight - footerHeight; this.tableHeight = window.innerHeight - headerHeight - footerHeight
}, },
/**获取数据 **/ /**获取数据 **/
getList(){ getList() {
this.loading =true this.loading = true
this.queryParams.dataSetId = this.datasetId; this.queryParams.dataSetId = this.datasetId
list(this.queryParams).then(response => { list(this.queryParams).then(response => {
this.list = response.rows; this.list = response.rows
this.total = response.total; this.total = response.total
this.loading =false this.loading = false
}) })
}, },
/** 返回按钮操作 */ /** 返回按钮操作 */
handleClose() { handleClose() {
const obj = { path: "/dataCenter/dataSet" }; const obj = { path: '/dataCenter/dataSet' }
this.$tab.closeOpenPage(obj); this.$tab.closeOpenPage(obj)
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1
this.getList(); this.getList()
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm('queryForm')
this.handleQuery(); this.handleQuery()
}, },
handleAdd(){ handleAdd() {
this.importOpen = true; this.importOpen = true
}, },
handleDelete(row){ handleDelete(row) {
const datasetId = this.datasetId; const datasetId = this.datasetId
const ids = row.fileId || this.ids.join(","); const ids = row.fileId || this.ids.join(',')
this.$modal.confirm('是否确认删除数据项?').then(function() { this.$modal.confirm('是否确认删除数据项?').then(function() {
return remove(datasetId,ids); return remove(datasetId, ids)
}).then(() => { }).then(() => {
this.getList(); this.getList()
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess('删除成功')
}).catch(() => {}); }).catch(() => {
})
}, },
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.fileId) this.ids = selection.map(item => item.fileId)
this.single = selection.length!==1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
// //
handleCancel() { handleCancel() {
this.importOpen= false; this.importOpen = false
}, }
} }
} }
</script> </script>
@ -207,10 +230,12 @@ export default {
.demo-table-expand { .demo-table-expand {
font-size: 0; font-size: 0;
} }
.demo-table-expand label { .demo-table-expand label {
width: 90px; width: 90px;
color: #99a9bf; color: #99a9bf;
} }
.demo-table-expand .el-form-item { .demo-table-expand .el-form-item {
margin-right: 0; margin-right: 0;
margin-bottom: 0; margin-bottom: 0;

View File

@ -48,8 +48,8 @@
<template slot-scope="scope"> <template slot-scope="scope">
<router-link :to="{ <router-link :to="{
path: '/dataCenter/dataSet-details/index/' + scope.row.datasetId, path: '/dataCenter/dataSet-details/index/' + scope.row.datasetId,
query: { dataType: scope.row.dataType } query: { dataType: scope.row.dataType,_t: Date.now() }
}" class="link-type"> }" class="link-type" @click="">
<span>{{ scope.row.datasetName }}</span> <span>{{ scope.row.datasetName }}</span>
</router-link> </router-link>
</template> </template>
@ -183,7 +183,6 @@ export default {
}, },
methods: { methods: {
indexMethod(index){ indexMethod(index){
console.log(index);
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1; return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
}, },
updateTableHeight() { updateTableHeight() {

View File

@ -75,7 +75,8 @@ export default {
uploadFailed: {}, // uploadFailed: {}, //
queue: [], // queue: [], //
maxConcurrentUploads: 5, // maxConcurrentUploads: 5, //
uploadsNum:{} uploadsNum:{},
isUploading: true, //
}; };
}, },
beforeMount() { beforeMount() {
@ -86,14 +87,17 @@ export default {
}, },
methods: { methods: {
handleClose(done) { handleClose(done) {
this.$modal.confirm('您确认要关闭吗?关闭后,未完成上传的文件将停止上传。').then(function() { this.$modal
return done(); .confirm('您确认要关闭吗?关闭后,未完成上传的文件将停止上传。')
}).then(() => { .then(() => {
this.resetComponent() this.queue = []; //
//this.getList() done();
this.getList() })
}).catch(function() { .then(() => {
}) this.resetComponent();
this.getList && this.getList(); //
})
.catch(() => {});
}, },
// //
resetComponent() { resetComponent() {
@ -102,6 +106,7 @@ export default {
this.uploadFailed = {}; this.uploadFailed = {};
this.queue = []; this.queue = [];
this.uploadsNum = {}; this.uploadsNum = {};
this.isUploading = true; //
}, },
// //
customUpload(uploadFile) { customUpload(uploadFile) {
@ -124,40 +129,44 @@ export default {
// //
uploadChunks(file) { uploadChunks(file) {
this.$set(this.uploadsNum, file.name, 0); // if (!this.drawer) return; //
const totalChunks = Math.ceil(file.size / this.chunkSize); // this.$set(this.uploadsNum, file.name, 0);
let currentChunk = 0; // const totalChunks = Math.ceil(file.size / this.chunkSize);
let currentChunk = 0;
const uploadNextChunk = () => { const uploadNextChunk = () => {
console.log(this.queue.length)
if (!this.drawer) return; //
const start = currentChunk * this.chunkSize; const start = currentChunk * this.chunkSize;
const end = Math.min(file.size, start + this.chunkSize); const end = Math.min(file.size, start + this.chunkSize);
const chunk = file.slice(start, end); const chunk = file.slice(start, end);
const formData = new FormData(); const formData = new FormData();
formData.append("file", chunk); formData.append('file', chunk);
formData.append("filename", file.name); formData.append('filename', file.name);
formData.append("chunk", currentChunk + 1); // formData.append('chunk', currentChunk + 1);
formData.append("totalChunks", totalChunks); // formData.append('totalChunks', totalChunks);
formData.append("parentId", this.parentId); formData.append('parentId', this.parentId);
formData.append("fileUrl", this.fileUrl); formData.append('fileUrl', this.fileUrl);
// 使 fetch
uploadFiles(formData) uploadFiles(formData)
.then(() => { .then(() => {
currentChunk++; currentChunk++;
const progress = Math.floor((currentChunk / totalChunks) * 100); const progress = Math.floor((currentChunk / totalChunks) * 100);
this.$set(this.uploadsNum, file.name, progress); // this.$set(this.uploadsNum, file.name, progress);
this.$set(this.uploadProgress, file.name, progress); // this.$set(this.uploadProgress, file.name, progress);
if (currentChunk < totalChunks) { if (currentChunk < totalChunks) {
uploadNextChunk(); // uploadNextChunk();
} else { } else {
this.startNextUpload(); // this.startNextUpload();
this.checkAllUploadsComplete(); // this.checkAllUploadsComplete();
} }
}) })
.catch((error) => { .catch(() => {
this.$set(this.uploadFailed, file.name, true); this.$set(this.uploadFailed, file.name, true);
this.startNextUpload(); // this.startNextUpload();
}); });
}; };
uploadNextChunk(); //
uploadNextChunk();
}, },
checkAllUploadsComplete() { checkAllUploadsComplete() {
const allComplete = Object.values(this.uploadProgress).every(progress => progress === 100); const allComplete = Object.values(this.uploadProgress).every(progress => progress === 100);
@ -165,20 +174,24 @@ export default {
this.$message.success("所有文件上传完成!"); this.$message.success("所有文件上传完成!");
this.drawer = false; // this.drawer = false; //
this.getList && this.getList(); // this.getList && this.getList(); //
this.resetComponent();
} }
}, },
// //
startNextUpload() { startNextUpload() {
Object.keys(this.uploadsNum).forEach(fileName => { if (!this.isUploading) return; //
Object.keys(this.uploadsNum).forEach((fileName) => {
if (this.uploadsNum[fileName] === 100) { if (this.uploadsNum[fileName] === 100) {
delete this.uploadsNum[fileName]; // Remove completed files from the progress list delete this.uploadsNum[fileName];
} }
}); });
if (this.queue.length === 0 || Object.values(this.uploadsNum).length >= this.maxConcurrentUploads) { if (this.queue.length === 0 || Object.values(this.uploadsNum).length >= this.maxConcurrentUploads) {
return; // return;
} }
const nextFile = this.queue.shift(); // const nextFile = this.queue.shift();
this.uploadChunks(nextFile); // this.uploadChunks(nextFile);
}, },
beforeUpload(file) { beforeUpload(file) {
const maxSize = 2 * 1024 * 1024*1024; // 5MB const maxSize = 2 * 1024 * 1024*1024; // 5MB
@ -186,6 +199,10 @@ export default {
this.$message.error('文件大小不能超过 2GB'); this.$message.error('文件大小不能超过 2GB');
return false; // return false; //
} }
if ( file.size < 0) {
this.$message.error('文件大小错误');
return false; //
}
return true; // return true; //
}, },
// //

View File

@ -114,7 +114,7 @@
/> />
<!-- 添加或修改标注人员和角色关联对话框 --> <!-- 添加或修改标注人员和角色关联对话框 -->
<el-dialog title="添加" :visible.sync="addOpen" width="800px" append-to-body> <el-dialog title="添加" :visible.sync="addOpen" width="800px" append-to-body @close="cancel">
<el-form ref="addForm" :model="addForm" :rules="addRules" label-width="80px"> <el-form ref="addForm" :model="addForm" :rules="addRules" label-width="80px">
<el-form-item label="角色" prop="roleIds"> <el-form-item label="角色" prop="roleIds">
<el-select v-model="addForm.roleIds" multiple style="width: 30%;" placeholder="请选择"> <el-select v-model="addForm.roleIds" multiple style="width: 30%;" placeholder="请选择">
@ -128,6 +128,8 @@
</el-form-item> </el-form-item>
<el-form-item prop="selectedData"> <el-form-item prop="selectedData">
<el-transfer <el-transfer
:key="transferKey"
ref="transfer"
style="text-align: left; display: inline-block" style="text-align: left; display: inline-block"
v-model="addForm.selectedData" v-model="addForm.selectedData"
filterable filterable
@ -201,6 +203,7 @@ export default {
selectUser:[], selectUser:[],
// //
title: "", title: "",
transferKey: 0, // key
// //
addOpen:false, addOpen:false,
open: false, open: false,
@ -292,6 +295,7 @@ export default {
}, },
// //
cancel() { cancel() {
this.transferKey += 1; // key el-transfer
this.open = false; this.open = false;
this.addOpen = false; this.addOpen = false;
this.reset(); this.reset();
@ -303,6 +307,7 @@ export default {
addTeamMember(this.addForm).then(response => { addTeamMember(this.addForm).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.addOpen = false; this.addOpen = false;
this.transferKey += 1; // key el-transfer
this.getList(); this.getList();
}); });
} }