refactor: jar包管理优化

This commit is contained in:
chenjianxing 2021-02-03 17:21:20 +08:00
parent 117571cd94
commit 937ce3f3c6
2 changed files with 33 additions and 34 deletions

View File

@ -2,28 +2,32 @@
<el-dialog width="50%" :close-on-click-modal="false" :title="$t('api_test.jar_config.title')" :visible.sync="visible" class="jar-import" @close="close"> <el-dialog width="50%" :close-on-click-modal="false" :title="$t('api_test.jar_config.title')" :visible.sync="visible" class="jar-import" @close="close">
<div v-loading="result.loading"> <div v-loading="result.loading">
<ms-jar-config-from :config="currentConfig" :callback="saveConfig" ref="jarConfigFrom" :read-only="isReadOnly"/> <ms-jar-config-from :config="currentConfig" :callback="saveConfig" ref="jarConfigFrom" :read-only="isReadOnly"/>
<ms-jar-search-bar @refresh="getJarConfigs" :table-data="configs" ref="jarSearchBar"/> <ms-jar-search-bar v-if="(!isSearchBarQuery && configs.length > 0) || isSearchBarQuery" :condition="condition"
@search="getJarConfigs" :table-data="configs" ref="jarSearchBar"/>
<ms-jar-config-list @refresh="getJarConfigs" v-if="configs.length > 0" @rowSelect="rowSelect" :table-data="configs" ref="jarConfigList"/> <ms-jar-config-list @refresh="getJarConfigs" v-if="configs.length > 0" @rowSelect="rowSelect" :table-data="configs" ref="jarConfigList"/>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import MsDialogFooter from "../../../../common/components/MsDialogFooter"; import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils"; import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils";
import MsJarConfigList from "./JarConfigList"; import MsJarConfigList from "./JarConfigList";
import MsJarConfigFrom from "./JarConfigFrom"; import MsJarConfigFrom from "./JarConfigFrom";
import MsJarSearchBar from "./JarSearchBar"; import MsJarSearchBar from "./JarSearchBar";
export default {
name: "MsJarConfig", export default {
components: {MsJarConfigFrom, MsJarSearchBar, MsJarConfigList, MsDialogFooter}, name: "MsJarConfig",
data() { components: {MsJarConfigFrom, MsJarSearchBar, MsJarConfigList, MsDialogFooter},
return { data() {
visible: false, return {
result: {}, visible: false,
currentConfig: {}, result: {},
configs: [] currentConfig: {},
} configs: [],
condition: {},
isSearchBarQuery: false
}
}, },
props: { props: {
isReadOnly: { isReadOnly: {
@ -34,6 +38,8 @@
methods: { methods: {
open() { open() {
this.visible = true; this.visible = true;
this.condition = {};
this.getJarConfigs(); this.getJarConfigs();
listenGoBack(this.close); listenGoBack(this.close);
}, },
@ -54,11 +60,14 @@
this.getJarConfigs(); this.getJarConfigs();
}); });
}, },
getJarConfigs(condition) { getJarConfigs(isSearchBarQuery) {
this.result = this.$post("/jar/list", {name: condition}, response => { if (isSearchBarQuery) {
this.configs = response.data; this.isSearchBarQuery = isSearchBarQuery;
this.currentConfig = {}; }
}); this.result = this.$post("/jar/list", this.condition, response => {
this.configs = response.data;
this.currentConfig = {};
});
}, },
rowSelect(config) { rowSelect(config) {
this.currentConfig = config; this.currentConfig = config;

View File

@ -1,10 +1,10 @@
<template> <template>
<el-input class="jar-header-search" <el-input class="jar-header-search"
v-model="searchCondition" v-model="condition.name"
type="text" type="text"
size="small" size="small"
prefix-icon="el-icon-search" prefix-icon="el-icon-search"
@keyup.enter.native="search" @blur="search"
:placeholder="$t('project.search_by_name_jar')" clearable/> :placeholder="$t('project.search_by_name_jar')" clearable/>
</template> </template>
@ -19,19 +19,9 @@
}, },
}, },
}, },
data() {
return {
searchCondition: this.condition
};
},
watch: {
inputCondition(value) {
this.searchCondition = value;
}
},
methods: { methods: {
search() { search() {
this.$emit('refresh', this.searchCondition); this.$emit('search', true);
} }
}, },
} }