提交代码

This commit is contained in:
jiang 2024-11-18 09:06:12 +08:00
parent 4e833e0cba
commit 874ac4fd7d
6 changed files with 882 additions and 0 deletions

View File

@ -0,0 +1,57 @@
import request from '@/utils/request'
// 查询文件基础列表
export function listFile(query) {
return request({
url: '/ai/dataSetBasicFile/list',
method: 'get',
params: query
})
}
// 查询文件基础详细
export function getFile(fileId) {
return request({
url: '/ai/dataSetBasicFile/' + fileId,
method: 'get'
})
}
// 新增文件基础
export function addFile(data) {
return request({
url: '/ai/dataSetBasicFile',
method: 'post',
data: data
})
}
// 修改文件基础
export function updateFile(data) {
return request({
url: '/ai/dataSetBasicFile',
method: 'put',
data: data
})
}
// 删除文件基础
export function delFile(fileId) {
return request({
url: '/ai/dataSetBasicFile/' + fileId,
method: 'delete'
})
}
// 上传文件
export function uploadFiles(formData) {
return request({
url: '/ai/dataSetBasicFile/uploadFiles',
method: 'post',
data: formData,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
}

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询样本标签管理列表
export function listDataSetLabels(query) {
return request({
url: '/ai/dataSetLabels/list',
method: 'get',
params: query
})
}
// 查询样本标签管理详细
export function getDataSetLabels(labelId) {
return request({
url: '/ai/dataSetLabels/' + labelId,
method: 'get'
})
}
// 新增样本标签管理
export function addDataSetLabels(data) {
return request({
url: '/ai/dataSetLabels',
method: 'post',
data: data
})
}
// 修改样本标签管理
export function updateDataSetLabels(data) {
return request({
url: '/ai/dataSetLabels',
method: 'put',
data: data
})
}
// 删除样本标签管理
export function delDataSetLabels(labelId) {
return request({
url: '/ai/dataSetLabels/' + labelId,
method: 'delete'
})
}

View File

@ -0,0 +1,277 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="标签名称" prop="labelName">
<el-input
v-model="queryParams.labelName"
placeholder="请输入标签名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:DataSetLabels:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="labelsList"
row-key="labelId"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column label="标签名称" align="center" prop="labelName" :show-overflow-tooltip="true" width="160"/>
<el-table-column label="状态" align="center" prop="labelName" />
<el-table-column label="创建人" align="center" prop="createBy" />
<el-table-column label="描述" align="center" prop="labelName" />
<el-table-column label="创建时间" align="center" prop="labelName">
<template slot-scope="scope">
<span>{{parseTime(scope.row.createTime)}}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:DataSetLabels:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['system:DataSetLabels:add']"
>新增</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:DataSetLabels:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改样本标签管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="父节点id" prop="parentId">
<treeselect v-model="form.parentId" :options="labelsListOptions" :normalizer="normalizer" placeholder="请选择父节点id" />
</el-form-item>
<el-form-item label="标签名称" prop="labelName">
<el-input v-model="form.labelName" placeholder="请输入标签名称" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listDataSetLabels, getDataSetLabels, delDataSetLabels, addDataSetLabels, updateDataSetLabels } from "@/api/dataCenter/labels";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { parseTime } from '../../../utils/bonus'
export default {
name: "DataSetLabels",
components: {
Treeselect
},
data() {
return {
//
loading: true,
//
showSearch: true,
//
labelsList: [],
//
labelsListOptions: [],
//
title: "",
//
open: false,
//
isExpandAll: true,
//
refreshTable: true,
//
queryParams: {
ancestors: null,
parentId: null,
labelName: null,
},
//
form: {},
//
rules: {
parentId: [
{ required: true, message: "父节点id不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
parseTime,
/** 查询样本标签管理列表 */
getList() {
this.loading = true;
listDataSetLabels(this.queryParams).then(response => {
console.log(response)
this.labelsList = this.handleTree(response.data, "labelId", "parentId");
this.loading = false;
});
},
/** 转换样本标签管理数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.labelId,
label: node.labelName,
children: node.children
};
},
/** 查询样本标签管理下拉树结构 */
getTreeselect() {
listDataSetLabels().then(response => {
this.labelsListOptions = [];
const data = { labelId: 0, labelName: '顶级节点', children: [] };
data.children = this.handleTree(response.data, "labelId", "parentId");
this.labelsListOptions.push(data);
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
labelId: null,
ancestors: null,
parentId: null,
labelName: null,
delFlag: null,
createBy: null,
updateBy: null,
updateTime: null,
createTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset();
this.getTreeselect();
if (row != null && row.labelId) {
this.form.parentId = row.labelId;
} else {
this.form.parentId = 0;
}
this.open = true;
this.title = "添加样本标签管理";
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false;
this.isExpandAll = !this.isExpandAll;
this.$nextTick(() => {
this.refreshTable = true;
});
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.getTreeselect();
if (row != null) {
this.form.parentId = row.labelId;
}
getDataSetLabels(row.labelId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改样本标签管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.labelId != null) {
updateDataSetLabels(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addDataSetLabels(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal.confirm('是否确认删除样本标签管理编号为"' + row.labelId + '"的数据项?').then(function() {
return delDataSetLabels(row.labelId);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}
};
</script>

View File

@ -0,0 +1,175 @@
<template>
<div class="app-container">
<el-upload
style="width: 70%"
:http-request="customUpload"
action="#"
multiple
:file-list="fileList"
:auto-upload="true"
:show-file-list="false"
:on-change="handleChange"
:on-exceed="handleExceed"
accept="*"
:directory="true"
>
<el-row>
<el-button type="primary">上传文件夹</el-button>
</el-row>
</el-upload>
<el-drawer
title="上传进度"
:visible.sync="drawer"
:before-close="handleClose"
:close-on-click-modal="false"
:wrapper-closable="false">
<!-- 显示所有文件的上传进度 -->
<div v-for="([filename, progress], index) in Object.entries(uploadProgress)" :key="index" style="padding-left: 20px;padding-right: 20px">
<div style="display: flex;flex-direction: row;align-items: center;justify-content: flex-start;margin-bottom: 10px">
<i v-if="progress ===100 && !uploadFailed[filename]" style="color: #13ce66;font-size: 18px" class="el-icon-success"></i>
<i v-if="progress !==100 && !uploadFailed[filename]" style="font-size: 18px;color: rgba(110,106,106,0.3)" class="el-icon-upload"></i>
<i v-if="uploadFailed[filename]" style="font-size: 18px;color: red" class="el-icon-warning"></i>
<span style="margin-left: 2%;font-size: 18px">{{ filename }}</span>
</div>
<el-progress :color="progress === 100 ? '#13ce66' : '#6E6A6A4C'" :percentage="progress"></el-progress>
<el-divider></el-divider>
</div>
</el-drawer>
</div>
</template>
<script>
import { uploadFiles } from '@/api/dataCenter/basicFile'
export default {
props: {
parentId: {
type: String,
required: true,
},
fileUrl: {
type: String,
required: true,
},
},
data() {
return {
fileList: [], //
chunkSize: 1024 * 1024 * 20, // 2MB
drawer: false,
uploadProgress: {}, //
uploadFailed: {}, //
queue: [], //
maxConcurrentUploads: 5, //
uploadsNum:{}
};
},
beforeMount() {
this.resetComponent();
},
mounted() {
this.resetComponent(); //
},
methods: {
handleClose(done) {
this.$modal.confirm('您确认要关闭吗?关闭后,未完成上传的文件将停止上传。').then(function() {
return done();
}).then(() => {
this.resetComponent()
//this.getList()
}).catch(function() {
})
},
//
resetComponent() {
this.fileList = [];
this.uploadProgress = {};
this.uploadFailed = {};
this.queue = [];
this.uploadsNum = {};
},
//
customUpload(uploadFile) {
this.drawer = true;
const file = uploadFile.file;
this.$set(this.uploadProgress, file.name, 0); //
//
this.queue.push(file);
this.startNextUpload();
},
//
handleChange(file, fileList) {
//
if (file && file.webkitRelativePath) {
const folderPath = file.webkitRelativePath.split('/')[0]; //
const filesInFolder = fileList.filter(f => f.webkitRelativePath.startsWith(folderPath));
}
},
//
uploadChunks(file) {
this.$set(this.uploadsNum, file.name, 0); //
const totalChunks = Math.ceil(file.size / this.chunkSize); //
let currentChunk = 0; //
const uploadNextChunk = () => {
const start = currentChunk * this.chunkSize;
const end = Math.min(file.size, start + this.chunkSize);
const chunk = file.slice(start, end);
const formData = new FormData();
formData.append("file", chunk);
formData.append("filename", file.name);
formData.append("chunk", currentChunk + 1); //
formData.append("totalChunks", totalChunks); //
formData.append("parentId", this.parentId);
formData.append("fileUrl", this.fileUrl);
// 使 fetch
uploadFiles(formData)
.then(() => {
currentChunk++;
const progress = Math.floor((currentChunk / totalChunks) * 100);
this.$set(this.uploadsNum, file.name, progress); //
this.$set(this.uploadProgress, file.name, progress); //
if (currentChunk < totalChunks) {
uploadNextChunk(); //
} else {
this.startNextUpload(); //
}
})
.catch((error) => {
this.$set(this.uploadFailed, file.name, true);
this.startNextUpload(); //
});
};
uploadNextChunk(); //
},
//
startNextUpload() {
Object.keys(this.uploadsNum).forEach(fileName => {
if (this.uploadsNum[fileName] === 100) {
delete this.uploadsNum[fileName]; // Remove completed files from the progress list
}
});
if (this.queue.length === 0 || Object.values(this.uploadsNum).length >= this.maxConcurrentUploads) {
return; //
}
const nextFile = this.queue.shift(); //
this.uploadChunks(nextFile); //
},
//
handleExceed(files, fileList) {
this.$message.warning(`最多只能选择50个文件当前选择了 ${files.length + fileList.length} 个文件`);
}
}
};
</script>
<style scoped>
.el-upload__tip {
font-size: 12px;
color: #909399;
}
</style>

View File

@ -0,0 +1,262 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="文件名" prop="fileName">
<el-input
v-model="queryParams.fileName"
placeholder="请输入文件名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<uploadFiles :parenId="queryParams.parentId.toString()" :fileUrl="fileUrl" />
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<div style="display: flex;flex-direction: row;
align-items: center;">
<span><i @click="popFromStack" class="el-icon-arrow-left"></i></span>
<el-breadcrumb separator="/" class="app-container">
<el-breadcrumb-item ><a @click="folderName = []"> 我的样本库</a></el-breadcrumb-item>
<el-breadcrumb-item v-for="item in folderName" :key="item.fileId"><a @click="removeAfter(item)">{{item.fileName}}</a></el-breadcrumb-item>
</el-breadcrumb>
</div>
<el-table v-loading="loading" :data="fileList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="名称" align="center" prop="fileName">
<template slot-scope="scope">
<!-- 根据条件生成点击事件 -->
<span
:class="{ 'link-type': scope.row.isDirectory === '1' }"
@click="scope.row.isDirectory === '1' ? pushToStack(scope.row) : null"
>
{{ scope.row.fileName }}
</span>
</template>
</el-table-column>
<el-table-column label="文件类型" align="center" prop="fileUrl" />
<el-table-column label="文件大小" align="center" prop="fileSize" />
<el-table-column label="上传时间" align="center" prop="uploadTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.uploadTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="最后修改时间" align="center" prop="fileLastModifytime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.fileLastModifytime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:file:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:file:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import { listFile, getFile, delFile, addFile, updateFile } from "@/api/dataCenter/basicFile";
import uploadFiles from '../child/uploadFiles.vue'
export default {
name: "File",
components:{uploadFiles},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
fileList: [],
//
file:[],
//
folderName:[],
fileUrl:"",
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
parentId: 0,
fileName: null,
},
//
form: {},
//
rules: {
parentId: [
{ required: true, message: "父节点id不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
watch:{
folderName(newVal, oldVal){
this.queryParams.parentId = newVal.length > 0 ? newVal[newVal.length - 1].fileId : 0;
this.fileUrl = this.folderName.map(item => item.fileName).join("/") + "/";
this.getList();
}
},
methods: {
//
pushToStack(item) {
if (item) { //
this.folderName.push(item); //
}
},
//
popFromStack() {
if (this.folderName.length > 0) {
this.folderName.pop();
}
},
//
removeAfter(item) {
const index = this.folderName.findIndex(element => element.fileId === item.fileId);
if (index !== -1) {
// 使 splice
this.folderName.splice(index + 1);
}
},
/** 查询文件基础列表 */
getList() {
this.loading = true;
listFile(this.queryParams).then(response => {
this.fileList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
fileId: null,
parentId: null,
ancestors: null,
fileName: null,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.fileId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加文件基础";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const fileId = row.fileId || this.ids
getFile(fileId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改文件基础";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.fileId != null) {
updateFile(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addFile(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const fileIds = row.fileId || this.ids;
this.$modal.confirm('是否确认删除文件基础编号为"' + fileIds + '"的数据项?').then(function() {
return delFile(fileIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/file/export', {
...this.queryParams
}, `file_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -0,0 +1,67 @@
<template>
<div class="app-container">
<el-tabs type="border-card" @tab-click="handleClick">
<!-- 我的文件 -->
<el-tab-pane label="我的文件">
<div v-if="activeTab === 'files'">
<MyFile v-if="activeTab === 'files'" />
</div>
</el-tab-pane>
<!-- 我共享的 -->
<el-tab-pane label="我共享的">
<div v-if="activeTab === 'shared'">
<h3>我共享的内容</h3>
<!-- 可以在这里插入与我共享的相关的组件或内容 -->
</div>
</el-tab-pane>
<!-- 共享空间 -->
<el-tab-pane label="共享空间">
<div v-if="activeTab === 'space'">
<h3>共享空间内容</h3>
<!-- 可以在这里插入与共享空间相关的组件或内容 -->
</div>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import MyFile from './components/MyFile.vue'
export default {
components: { MyFile },
data() {
return {
activeTab: 'files' // ""
}
},
methods: {
handleClick(tab, event) {
// activeTab
if (tab.label === '我的文件') {
this.activeTab = 'files';
} else if (tab.label === '我共享的') {
this.activeTab = 'shared';
} else if (tab.label === '共享空间') {
this.activeTab = 'space';
}
}
}
}
</script>
<style scoped lang="scss">
.app-container {
.el-tabs {
margin-bottom: 20px;
}
.el-tab-pane {
padding: 20px;
background-color: #f9f9f9;
border-radius: 4px;
}
}
</style>