提交代码
This commit is contained in:
		
							parent
							
								
									4e833e0cba
								
							
						
					
					
						commit
						874ac4fd7d
					
				| 
						 | 
				
			
			@ -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'
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -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'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue