refactor(系统设置): 插件表单支持按条件显示

This commit is contained in:
chenjianxing 2023-02-02 13:53:01 +08:00 committed by jianxing
parent ccaedcda59
commit 8650f3ea10
7 changed files with 60 additions and 29 deletions

View File

@ -3,16 +3,20 @@
<el-form-item :label="config.i18n ? $t(config.label) : config.label">
<ms-instructions-icon size="10" :content="config.i18n ? $t(config.instructionsInfo) : config.instructionsInfo"/>
</el-form-item>
<el-form-item
v-for="item in config.formItems"
:key="item.name"
:label="item.i18n ? $t(item.label) : item.label"
:prop="item.name">
<custom-filed-component :form="accountConfig"
<span v-for="item in config.formItems"
:key="item.name">
<el-form-item
v-if="!item.displayConditions
|| accountConfig[item.displayConditions.field] === item.displayConditions.value"
:label="item.i18n ? $t(item.label) : item.label"
:prop="item.name">
<custom-filed-component :form="accountConfig"
:data="item"
prop="defaultValue"/>
</el-form-item>
</span>
<el-form-item>
<el-button type="primary" style="float: right" @click="handleAuth" size="mini">
{{ $t('commons.validate') }}
@ -54,7 +58,7 @@ export default {
this.init();
},
},
mounted() {
created() {
this.init();
},
methods: {
@ -65,7 +69,9 @@ export default {
}
//
if (this.accountConfig[item.name]) {
this.$set(item, 'defaultValue', this.accountConfig[item.name]);
if (this.accountConfig[item.name]) {
this.$set(item, 'defaultValue', this.accountConfig[item.name]);
}
}
});
this.rules = getPlatformFormRules(this.config);

View File

@ -169,6 +169,7 @@ export default {
}
}
}
this.setFormData();
if (['member', 'multipleMember'].indexOf(this.data.type) < 0) {
return;
}
@ -180,6 +181,11 @@ export default {
}
});
},
watch: {
form() {
this.setFormData();
}
},
methods: {
getTranslateOption(item) {
return item.system ? this.$t(item.text) : item.text;
@ -191,6 +197,11 @@ export default {
this.$emit('change', this.data.name);
this.$forceUpdate();
},
setFormData() {
if (this.form && this.data && this.data[this.prop]) {
this.$set(this.form, this.data.name, this.data[this.prop]);
}
}
}
};
</script>

View File

@ -738,11 +738,14 @@ const message = {
app_key: 'APP key',
account: 'Account',
password: 'Password',
token_auth: 'Token',
password_auth: 'Password',
jira_url: 'JIRA url',
jira_issuetype: 'JIRA issue type',
jira_storytype: 'JIRA story type',
input_api_account: 'please enter account',
input_api_password: 'Please enter password',
input_token: 'Please enter token',
input_jira_url: 'Please enter Jira address, for example: https://metersphere.atlassian.net/',
input_jira_issuetype: 'Please enter the issue type',
input_jira_storytype: 'Please enter the story type',

View File

@ -746,11 +746,14 @@ const message = {
app_key: '密钥',
account: '账号',
password: '密码',
token_auth: 'Token 认证',
password_auth: '账号密码认证',
jira_url: 'JIRA 地址',
jira_issuetype: '问题类型',
jira_storytype: '需求类型',
input_api_account: '请输入账号',
input_api_password: '请输入密码',
input_token: '请输入Token',
input_jira_url: '请输入Jira地址https://metersphere.atlassian.net/',
input_jira_issuetype: '请输入问题类型',
input_jira_storytype: '请输入需求类型',

View File

@ -742,11 +742,14 @@ const message = {
app_key: '密鑰',
account: '賬號',
password: '密碼',
token_auth: 'Token 認證',
password_auth: '賬號密碼認證',
jira_url: 'JIRA 地址',
jira_issuetype: '問題類型',
jira_storytype: '需求類型',
input_api_account: '請輸入賬號',
input_api_password: '請輸入密碼',
input_token: '請輸入Token',
input_jira_url: '請輸入Jira地址https://metersphere.atlassian.net/',
input_jira_issuetype: '請輸入問題類型',
input_jira_storytype: '請輸入需求類型',

View File

@ -22,7 +22,7 @@
<java.version>11</java.version>
<spring-cloud.version>2021.0.5</spring-cloud.version>
<dubbo.version>2.7.18</dubbo.version>
<platform-plugin-sdk.version>1.3.0</platform-plugin-sdk.version>
<platform-plugin-sdk.version>1.4.0</platform-plugin-sdk.version>
<flyway.version>7.15.0</flyway.version>
<shiro.version>1.10.1</shiro.version>
<mssql-jdbc.version>7.4.1.jre8</mssql-jdbc.version>

View File

@ -3,24 +3,27 @@
<div style="width: 500px">
<div style="margin-top: 20px;margin-bottom: 10px">{{ $t('organization.integration.basic_auth_info') }}</div>
<el-form :model="form" ref="form" label-width="100px" size="small" :disabled="show" :rules="rules">
<el-form-item
v-for="item in config.formItems"
:key="item.name"
:label="item.i18n ? $t(item.label) : item.label"
:prop="item.name">
<custom-filed-component :form="form"
:data="item"
prop="defaultValue"/>
<ms-instructions-icon v-if="item.instructionsIcon || item.instructionsTip" effect="light">
<template>
<img v-if="item.instructionsIcon"
:src="getPlatformImageUrl(config, item)"/>
<span v-if="item.instructionsTip">
{{ item.instructionsTip }}
</span>
</template>
</ms-instructions-icon>
</el-form-item>
<span v-for="item in config.formItems"
:key="item.name">
<el-form-item
v-if="!item.displayConditions
|| form[item.displayConditions.field] === item.displayConditions.value"
:label="item.i18n ? $t(item.label) : item.label"
:prop="item.name">
<custom-filed-component :form="form"
:data="item"
prop="defaultValue"/>
<ms-instructions-icon v-if="item.instructionsIcon || item.instructionsTip" effect="light">
<template>
<img v-if="item.instructionsIcon"
:src="getPlatformImageUrl(config, item)"/>
<span v-if="item.instructionsTip">
{{ item.instructionsTip }}
</span>
</template>
</ms-instructions-icon>
</el-form-item>
</span>
</el-form>
</div>
@ -34,7 +37,7 @@
:show.sync="show"
ref="bugBtn"/>
<div class="defect-tip" >
<div class="defect-tip">
<div>{{ $t('organization.integration.use_tip') }}</div>
<div v-html="config.tips"></div>
<div>
@ -113,7 +116,9 @@ export default {
this.form = form;
//
this.config.formItems.forEach(item => {
this.$set(item, 'defaultValue', this.form[item.name]);
if (this.form[item.name]) {
this.$set(item, 'defaultValue', this.form[item.name]);
}
});
} else {
this.clear();