fix(项目管理): 修复修改文件标签时可能会出现无法保存的问题

--bug=1020239 --user=宋天阳 【项目管理】文件管理-操作-查看-新增标签-刷新页面-标签未显示-实际未添加成功
https://www.tapd.cn/55049933/s/1317464
This commit is contained in:
song-tianyang 2022-12-20 15:18:08 +08:00 committed by 建国
parent fc133714ec
commit f5959f7363
2 changed files with 165 additions and 104 deletions

View File

@ -121,11 +121,7 @@
:label="$t('api_test.automation.tag')" :label="$t('api_test.automation.tag')"
prop="tags" prop="tags"
> >
<ms-input-tag <ms-input-tag :currentScenario="data" ref="tag" />
:currentScenario="data"
ref="tag"
@onblur="save"
/>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
@ -245,6 +241,7 @@ export default {
isFirst: false, isFirst: false,
isLast: false, isLast: false,
isPullBtnLoading: false, isPullBtnLoading: false,
showPanel: "baseInfo",
results: [], results: [],
moduleObj: { moduleObj: {
id: "id", id: "id",
@ -368,9 +365,13 @@ export default {
this.visible = false; this.visible = false;
}, },
saveAndClose() { saveAndClose() {
this.save();
this.$emit("setCurrentPage", this.currentPage);
this.$nextTick(() => {
this.$emit("getProjectFiles");
this.showPanel = "baseInfo"; this.showPanel = "baseInfo";
this.visible = false; this.visible = false;
this.$emit("setCurrentPage", this.currentPage); });
}, },
open(data, size, page, t) { open(data, size, page, t) {
this.showPanel = "baseInfo"; this.showPanel = "baseInfo";

View File

@ -1,15 +1,21 @@
<template> <template>
<el-card v-loading="result.loading" class="table-card"> <el-card v-loading="tableLoading" class="table-card">
<template v-slot:header> <template v-slot:header>
<ms-table-header :condition.sync="condition" <ms-table-header
:condition.sync="condition"
:show-create="false" :show-create="false"
@change="change" @change="change"
@search="getProjectFiles" title=""> @search="getProjectFiles"
title=""
>
<template v-slot:button> <template v-slot:button>
<ms-table-button icon="el-icon-upload2" v-if="moduleType==='repository'" <ms-table-button
icon="el-icon-upload2"
v-if="moduleType === 'repository'"
:content="$t('variables.add_file')" :content="$t('variables.add_file')"
@click="addRepositoryFile" @click="addRepositoryFile"
v-permission="['PROJECT_FILE:READ+UPLOAD+JAR']"/> v-permission="['PROJECT_FILE:READ+UPLOAD+JAR']"
/>
<el-upload <el-upload
v-else v-else
action="" action=""
@ -17,16 +23,20 @@
:show-file-list="false" :show-file-list="false"
:before-upload="beforeUploadFile" :before-upload="beforeUploadFile"
:http-request="handleUpload" :http-request="handleUpload"
:on-exceed="handleExceed"> :on-exceed="handleExceed"
<ms-table-button icon="el-icon-upload2" >
<ms-table-button
icon="el-icon-upload2"
:content="$t('variables.add_file')" :content="$t('variables.add_file')"
v-permission="['PROJECT_FILE:READ+UPLOAD+JAR']"/> v-permission="['PROJECT_FILE:READ+UPLOAD+JAR']"
/>
</el-upload> </el-upload>
</template> </template>
</ms-table-header> </ms-table-header>
</template> </template>
<div v-if="showView === 'list'"> <div v-if="showView === 'list'">
<ms-table v-loading="data.loading" <ms-table
v-loading="data.loading"
class="basic-config" class="basic-config"
:total="total" :total="total"
:screen-height="height" :screen-height="height"
@ -34,41 +44,49 @@
:data="metadataArr" :data="metadataArr"
:condition="condition" :condition="condition"
:hidePopover="true" :hidePopover="true"
@refresh="getProjectFiles" ref="table"> @refresh="getProjectFiles"
ref="table"
>
<ms-table-column <ms-table-column
prop="name" prop="name"
show-overflow-tooltip show-overflow-tooltip
:min-width="120" :min-width="120"
:label="$t('load_test.file_name')"> :label="$t('load_test.file_name')"
>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
sortable sortable
prop="type" prop="type"
:min-width="120" :min-width="120"
:filters="typeFilters" :filters="typeFilters"
:label="$t('load_test.file_type')"> :label="$t('load_test.file_type')"
>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column prop="description" :label="$t('group.description')">
prop="description"
:label="$t('group.description')">
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
prop="tags" prop="tags"
min-width="60px" min-width="60px"
:show-overflow-tooltip=false :show-overflow-tooltip="false"
:label="$t('commons.tag')"> :label="$t('commons.tag')"
>
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-tooltip class="item" effect="dark" placement="top"> <el-tooltip class="item" effect="dark" placement="top">
<div v-html="getTagToolTips(scope.row.tags)" slot="content"></div> <div v-html="getTagToolTips(scope.row.tags)" slot="content"></div>
<div class="oneLine"> <div class="oneLine">
<ms-tag v-for="(itemName,index) in scope.row.tags" <ms-tag
v-for="(itemName, index) in scope.row.tags"
:key="index" :key="index"
:show-tooltip="scope.row.tags.length === 1 && itemName.length * 12 <= 20" :show-tooltip="
scope.row.tags.length === 1 && itemName.length * 12 <= 20
"
:content="itemName" :content="itemName"
type="success" effect="plain" type="success"
class="ms-tags"/> effect="plain"
class="ms-tags"
/>
</div> </div>
</el-tooltip> </el-tooltip>
<span /> <span />
@ -79,19 +97,22 @@
sortable sortable
prop="createUser" prop="createUser"
:min-width="100" :min-width="100"
:label="$t('commons.create_user')"> :label="$t('commons.create_user')"
>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
sortable sortable
prop="updateUser" prop="updateUser"
:min-width="100" :min-width="100"
:label="$t('ui.update_user')"> :label="$t('ui.update_user')"
>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
sortable sortable
:label="$t('commons.create_time')" :label="$t('commons.create_time')"
:min-width="120" :min-width="120"
prop="createTime"> prop="createTime"
>
<template v-slot="scope"> <template v-slot="scope">
<span>{{ scope.row.createTime | datetimeFormat }}</span> <span>{{ scope.row.createTime | datetimeFormat }}</span>
</template> </template>
@ -101,20 +122,26 @@
sortable sortable
:min-width="120" :min-width="120"
:label="$t('commons.update_time')" :label="$t('commons.update_time')"
prop="updateTime"> prop="updateTime"
>
<template v-slot="scope"> <template v-slot="scope">
<span>{{ scope.row.updateTime | datetimeFormat }}</span> <span>{{ scope.row.updateTime | datetimeFormat }}</span>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column :label="$t('commons.operating')" fixed="right" :width="130"> <ms-table-column
:label="$t('commons.operating')"
fixed="right"
:width="130"
>
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-table-operator-button <ms-table-operator-button
icon="el-icon-view" icon="el-icon-view"
type="primary" type="primary"
:tip="$t('permission.project_report_analysis.read')" :tip="$t('permission.project_report_analysis.read')"
v-permission="['PROJECT_FILE:READ']" v-permission="['PROJECT_FILE:READ']"
@exec="handleView(scope.row)"> @exec="handleView(scope.row)"
>
</ms-table-operator-button> </ms-table-operator-button>
<ms-table-operator-button <ms-table-operator-button
@ -122,14 +149,16 @@
type="success" type="success"
:tip="$t('project.file_download')" :tip="$t('project.file_download')"
v-permission="['PROJECT_FILE:READ+DOWNLOAD+JAR']" v-permission="['PROJECT_FILE:READ+DOWNLOAD+JAR']"
@exec="handleDownload(scope.row)"> @exec="handleDownload(scope.row)"
>
</ms-table-operator-button> </ms-table-operator-button>
<ms-table-operator-button <ms-table-operator-button
icon="el-icon-delete" icon="el-icon-delete"
type="danger" type="danger"
:tip="$t('commons.delete')" :tip="$t('commons.delete')"
v-permission="['PROJECT_FILE:READ+DELETE+JAR']" v-permission="['PROJECT_FILE:READ+DELETE+JAR']"
@exec="handleDelete(scope.row)"> @exec="handleDelete(scope.row)"
>
</ms-table-operator-button> </ms-table-operator-button>
</template> </template>
</ms-table-column> </ms-table-column>
@ -138,7 +167,8 @@
:change="getProjectFiles" :change="getProjectFiles"
:current-page.sync="currentPage" :current-page.sync="currentPage"
:page-size.sync="pageSize" :page-size.sync="pageSize"
:total="total"/> :total="total"
/>
</div> </div>
<!-- 缩略图 --> <!-- 缩略图 -->
<div v-else> <div v-else>
@ -153,7 +183,8 @@
@delete="handleDelete" @delete="handleDelete"
@refreshModule="refreshModule" @refreshModule="refreshModule"
@setCurrentPage="setCurrentPage" @setCurrentPage="setCurrentPage"
@change="changeList"/> @change="changeList"
/>
</div> </div>
<!-- 移动组建--> <!-- 移动组建-->
<ms-file-batch-move @refreshModule="refreshModule" ref="batchMove" /> <ms-file-batch-move @refreshModule="refreshModule" ref="batchMove" />
@ -166,8 +197,14 @@
@reload="getProjectFiles" @reload="getProjectFiles"
@download="handleDownload" @download="handleDownload"
@setCurrentPage="setCurrentPage" @setCurrentPage="setCurrentPage"
@delete="handleDelete" ref="editFileMetadata"/> @delete="handleDelete"
<file-metadata-dialog :module-id="moduleId" @refresh="refreshModuleAndList" ref="repositoryFileDialog"/> ref="editFileMetadata"
/>
<file-metadata-dialog
:module-id="moduleId"
@refresh="refreshModuleAndList"
ref="repositoryFileDialog"
/>
</el-card> </el-card>
</template> </template>
@ -175,7 +212,10 @@
import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination"; import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination";
import MsTableButton from "metersphere-frontend/src/components/MsTableButton"; import MsTableButton from "metersphere-frontend/src/components/MsTableButton";
import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter"; import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter";
import {getCurrentProjectID, getCurrentUserId} from "metersphere-frontend/src/utils/token"; import {
getCurrentProjectID,
getCurrentUserId,
} from "metersphere-frontend/src/utils/token";
import { operationConfirm } from "metersphere-frontend/src/utils"; import { operationConfirm } from "metersphere-frontend/src/utils";
import MsTableOperatorButton from "metersphere-frontend/src/components/MsTableOperatorButton"; import MsTableOperatorButton from "metersphere-frontend/src/components/MsTableOperatorButton";
import MsTableHeader from "../header/FileHeader"; import MsTableHeader from "../header/FileHeader";
@ -195,7 +235,7 @@ import {
downloadFileZip, downloadFileZip,
downloadMetaData, downloadMetaData,
getAllTypeFileMeta, getAllTypeFileMeta,
getFileMetaPages getFileMetaPages,
} from "../../../../api/file"; } from "../../../../api/file";
export default { export default {
@ -221,7 +261,7 @@ export default {
nodeTree: Array, nodeTree: Array,
moduleType: { moduleType: {
type: String, type: String,
default: 'module', default: "module",
}, },
}, },
data() { data() {
@ -237,23 +277,23 @@ export default {
metadataArr: [], metadataArr: [],
condition: {}, condition: {},
projectId: getCurrentProjectID(), projectId: getCurrentProjectID(),
height: 'calc(100vh - 160px)', height: "calc(100vh - 160px)",
typeFilters: [], typeFilters: [],
buttons: [ buttons: [
{ {
name: this.$t('file_manage.batch_delete'), name: this.$t("file_manage.batch_delete"),
handleClick: this.handleDeleteBatch, handleClick: this.handleDeleteBatch,
permissions: ['PROJECT_FILE:READ+BATCH+DELETE'] permissions: ["PROJECT_FILE:READ+BATCH+DELETE"],
}, },
{ {
name: this.$t('file_manage.batch_download'), name: this.$t("file_manage.batch_download"),
handleClick: this.exportZip, handleClick: this.exportZip,
permissions: ['PROJECT_FILE:READ+BATCH+DOWNLOAD'] permissions: ["PROJECT_FILE:READ+BATCH+DOWNLOAD"],
}, },
{ {
name: this.$t('file_manage.batch_move'), name: this.$t("file_manage.batch_move"),
handleClick: this.handleBatchMove, handleClick: this.handleBatchMove,
permissions: ['PROJECT_FILE:READ+BATCH+MOVE'] permissions: ["PROJECT_FILE:READ+BATCH+MOVE"],
}, },
], ],
showView: "list", showView: "list",
@ -273,7 +313,7 @@ export default {
this.showView = value; this.showView = value;
}, },
refreshModule() { refreshModule() {
this.$emit('refreshModule'); this.$emit("refreshModule");
}, },
refreshList() { refreshList() {
this.$emit("refreshList"); this.$emit("refreshList");
@ -297,11 +337,16 @@ export default {
this.getProjectFiles(); this.getProjectFiles();
}, },
getProjectFiles() { getProjectFiles() {
this.tableLoading = getFileMetaPages(this.projectId, this.currentPage, this.pageSize, this.condition).then(res => { this.tableLoading = getFileMetaPages(
this.projectId,
this.currentPage,
this.pageSize,
this.condition
).then((res) => {
let data = res.data; let data = res.data;
this.total = data.itemCount; this.total = data.itemCount;
this.metadataArr = data.listObject; this.metadataArr = data.listObject;
this.metadataArr.forEach(item => { this.metadataArr.forEach((item) => {
if (item.tags && item.tags.length > 0) { if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
} }
@ -322,7 +367,7 @@ export default {
return false; return false;
} }
if (file.size / 1024 / 1024 > 500) { if (file.size / 1024 / 1024 > 500) {
this.$warning(this.$t('api_test.request.body_upload_limit_size')); this.$warning(this.$t("api_test.request.body_upload_limit_size"));
return false; return false;
} }
return true; return true;
@ -333,26 +378,31 @@ export default {
createUser: getCurrentUserId(), createUser: getCurrentUserId(),
updateUser: getCurrentUserId(), updateUser: getCurrentUserId(),
projectId: this.projectId, projectId: this.projectId,
moduleId: this.moduleId moduleId: this.moduleId,
}; };
this.cardLoading = createFileMeta(file, request).then(() => { this.cardLoading = createFileMeta(file, request).then(() => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t("commons.save_success"));
this.getProjectFiles(); this.getProjectFiles();
this.refreshModule(); this.refreshModule();
}); });
}, },
handleExceed() { handleExceed() {
this.$error(this.$t('load_test.file_size_limit')); this.$error(this.$t("load_test.file_size_limit"));
}, },
handleView(row) { handleView(row) {
this.$refs.editFileMetadata.open(row, this.pageSize, this.currentPage, this.total); this.$refs.editFileMetadata.open(
row,
this.pageSize,
this.currentPage,
this.total
);
}, },
getTagToolTips(tags) { getTagToolTips(tags) {
try { try {
let showTips = ""; let showTips = "";
tags.forEach(item => { tags.forEach((item) => {
showTips += item + ","; showTips += item + ",";
}) });
return showTips.substr(0, showTips.length - 1); return showTips.substr(0, showTips.length - 1);
} catch (e) { } catch (e) {
return ""; return "";
@ -378,49 +428,59 @@ export default {
}, },
exportZip() { exportZip() {
let array = []; let array = [];
this.$refs.table.selectRows.forEach(item => { this.$refs.table.selectRows.forEach((item) => {
let request = JSON.parse(JSON.stringify(item)); let request = JSON.parse(JSON.stringify(item));
request.tags = ""; request.tags = "";
array.push(request); array.push(request);
}) });
let request = { projectId: getCurrentProjectID, requests: array }; let request = { projectId: getCurrentProjectID, requests: array };
downloadFileZip(request); downloadFileZip(request);
// this.$fileDownloadPost("/file/metadata/download/zip", request, ".zip"); // this.$fileDownloadPost("/file/metadata/download/zip", request, ".zip");
}, },
handleDeleteBatch() { handleDeleteBatch() {
operationConfirm(this, this.$t('project.file_delete_tip', [this.$refs.table.selectIds.length + " 条 "]), () => { operationConfirm(
this,
this.$t("project.file_delete_tip", [
this.$refs.table.selectIds.length + " 条 ",
]),
() => {
batchDeleteMetaData(this.$refs.table.selectIds).then(() => { batchDeleteMetaData(this.$refs.table.selectIds).then(() => {
this.$refs.table.clear(); this.$refs.table.clear();
this.$success(this.$t('commons.delete_success')); this.$success(this.$t("commons.delete_success"));
this.getProjectFiles(); this.getProjectFiles();
this.refreshModule(); this.refreshModule();
})
}); });
}
);
}, },
handleDelete(row) { handleDelete(row) {
if (row && row.confirm) { if (row && row.confirm) {
deleteFileMetaById(row.id).then(() => { deleteFileMetaById(row.id).then(() => {
this.$success(this.$t('commons.delete_success')); this.$success(this.$t("commons.delete_success"));
this.getProjectFiles(); this.getProjectFiles();
this.refreshModule(); this.refreshModule();
}); });
return; return;
} }
operationConfirm(this, this.$t('project.file_delete_tip', [row.name]), () => { operationConfirm(
this,
this.$t("project.file_delete_tip", [row.name]),
() => {
deleteFileMetaById(row.id).then(() => { deleteFileMetaById(row.id).then(() => {
this.$success(this.$t('commons.delete_success')); this.$success(this.$t("commons.delete_success"));
this.getProjectFiles(); this.getProjectFiles();
this.refreshModule(); this.refreshModule();
}); });
}); }
);
}, },
getTypes() { getTypes() {
this.typeFilters = []; this.typeFilters = [];
getAllTypeFileMeta().then(res => { getAllTypeFileMeta().then((res) => {
res.data.forEach(item => { res.data.forEach((item) => {
this.typeFilters.push({ text: item, value: item }); this.typeFilters.push({ text: item, value: item });
}) });
}); });
}, },
moduleChange(ids) { moduleChange(ids) {
@ -437,8 +497,8 @@ export default {
}, },
moveSave(param) { moveSave(param) {
// this.buildBatchParam(param); // this.buildBatchParam(param);
} },
} },
}; };
</script> </script>