fix(项目管理): 修复jar包上传

This commit is contained in:
shiziyuan9527 2021-10-27 15:30:16 +08:00 committed by shiziyuan9527
parent c78f9fa178
commit e789cac2da
3 changed files with 217 additions and 1 deletions

View File

@ -0,0 +1,81 @@
<template>
<el-dialog width="50%" :close-on-click-modal="false" top="5vh" :title="$t('api_test.jar_config.title')" :visible.sync="visible" class="jar-import" @close="close">
<div v-loading="result.loading">
<ms-jar-config-from :config="currentConfig" :callback="saveConfig" ref="jarConfigFrom" :read-only="isReadOnly"/>
<!-- <ms-jar-search-bar v-if="(!isSearchBarQuery && configs.length > 0) || isSearchBarQuery" :condition="condition"-->
<!-- @search="getJarConfigs" :table-data="configs" ref="jarSearchBar"/>-->
<ms-jar-config-list :show-upload-btn="false" :table-data="configs" ref="jarConfigList"/>
</div>
</el-dialog>
</template>
<script>
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import MsJarConfigFrom from "@/business/components/api/test/components/jar/JarConfigFrom";
import MsJarSearchBar from "@/business/components/api/test/components/jar/JarSearchBar";
import MsJarConfigList from "@/business/components/settings/workspace/JarConfigList";
export default {
name: "MsJarConfig",
components: {MsJarConfigFrom, MsJarSearchBar, MsDialogFooter, MsJarConfigList},
data() {
return {
visible: false,
result: {},
currentConfig: {},
configs: [],
condition: {},
isSearchBarQuery: false
}
},
props: {
isReadOnly: {
type: Boolean,
default: false
},
},
methods: {
open() {
this.visible = true;
this.condition = {};
listenGoBack(this.close);
},
saveConfig(config, file) {
for (let item of this.configs) {
if (item.name === config.name && item.id !== config.id) {
this.$warning(this.$t('commons.already_exists'));
return;
}
if (item.fileName === file.name && item.id !== config.id) {
this.$warning(this.$t('api_test.jar_config.file_exist'));
return;
}
}
let url = config.id ? "/jar/update" : "/jar/add";
this.result = this.$fileUpload(url, file, null, config, () => {
this.$success(this.$t('commons.save_success'));
this.$refs.jarConfigList.getJarConfigs();
this.$refs.jarConfigFrom.clear();
});
},
rowSelect(config) {
this.currentConfig = config;
},
close() {
this.$refs.jarConfigFrom.clear();
removeGoBackListener(this.close);
this.visible = false;
}
}
}
</script>
<style scoped>
.jar-config-list {
max-height: 600px;
overflow: scroll;
}
</style>

View File

@ -0,0 +1,135 @@
<template>
<div class="jar-config-list">
<el-card style="height: 100%;">
<template v-slot:header>
<ms-table-header :show-create="false" :condition.sync="condition"
@search="getJarConfigs"
:create-tip="$t('project.create')">
</ms-table-header>
</template>
<el-table border :data="tableData"
class="adjust-table table-content"
:height="tableHeight"
@row-click="handleView">
<el-table-column prop="name" :label="$t('commons.name')" show-overflow-tooltip/>
<el-table-column prop="fileName" :label="$t('api_test.jar_config.jar_file')" show-overflow-tooltip/>
<el-table-column prop="description" :label="$t('commons.description')" show-overflow-tooltip/>
<el-table-column prop="updateTime" :label="$t('commons.update_time')" show-overflow-tooltip>
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column prop="creator" :label="$t('report.user_name')" show-overflow-tooltip/>
<el-table-column prop="modifier" :label="$t('commons.modifier')" show-overflow-tooltip/>
<el-table-column :label="$t('commons.operating')" min-width="100">
<template v-slot:default="scope">
<div>
<ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete" type="danger"
@exec="handleDelete(scope.row.id)" v-permission="['PROJECT_FILE:READ+DELETE+JAR']"/>
</div>
</template>
</el-table-column>
</el-table>
<ms-table-pagination :change="getJarConfigs" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
<ms-jar-config ref="jarConfig" @refresh="getJarConfigs"/>
</el-card>
</div>
</template>
<script>
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import MsContainer from "@/business/components/common/components/MsContainer";
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTableButton from "@/business/components/common/components/MsTableButton";
import MsJarConfig from "@/business/components/api/test/components/jar/JarConfig";
export default {
name: "MsJarConfigList",
components: {
MsTableOperatorButton,
MsTablePagination,
MsMainContainer,
MsContainer,
MsTableHeader,
MsTableButton,
MsJarConfig
},
props: {
isReadOnly: {
type: Boolean,
default: false
},
},
created() {
this.getJarConfigs();
},
data() {
return {
result: {},
currentPage: 1,
pageSize: 5,
total: 0,
tableData: [],
condition: {},
tableHeight: 'calc(50vh - 250px)'
}
},
methods: {
openJarConfig() {
this.$nextTick(() => {
this.$refs.jarConfig.open();
})
},
getJarConfigs(isSearchBarQuery) {
if (isSearchBarQuery) {
this.isSearchBarQuery = isSearchBarQuery;
}
this.result = this.$post("/jar/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
let data = response.data;
let {itemCount, listObject} = data;
this.total = itemCount;
this.tableData = listObject;
});
},
handleView(row) {
this.$emit('rowSelect', row);
},
handleDelete(id) {
this.$confirm(this.$t('api_test.jar_config.delete_tip'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.result = this.$get("/jar/delete/" + id, () => {
this.$success(this.$t('commons.delete_success'));
this.getJarConfigs();
});
}).catch(() => {
this.$message({
type: 'info',
message: this.$t('commons.delete_cancelled')
});
});
},
}
}
</script>
<style scoped>
.el-icon-check {
font-size: 20px;
font-weight: bold;
color: green;
margin-left: 20px;
}
</style>

View File

@ -268,7 +268,7 @@ import MsTableOperatorButton from "../../common/components/MsTableOperatorButton
import ApiEnvironmentConfig from "../../api/test/components/ApiEnvironmentConfig";
import TemplateComponent from "../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent";
import {GROUP_PROJECT, PROJECT_ID} from "@/common/js/constants";
import MsJarConfig from "../../api/test/components/jar/JarConfig";
import MsJarConfig from "@/business/components/settings/workspace/JarConfig";
import MsTableButton from "../../common/components/MsTableButton";
import {_filter, _sort} from "@/common/js/tableUtils";
import MsResourceFiles from "@/business/components/performance/test/components/ResourceFiles";