feat: 编辑模板-自定义字段设置

This commit is contained in:
chenjianxing 2021-04-22 18:18:46 +08:00 committed by jianxing
parent c77631de58
commit d4e1ffb578
6 changed files with 32 additions and 7 deletions

View File

@ -24,8 +24,8 @@ public class CustomFieldController {
private CustomFieldService customFieldService; private CustomFieldService customFieldService;
@PostMapping("/add") @PostMapping("/add")
public void add(@RequestBody CustomField customField) { public String add(@RequestBody CustomField customField) {
customFieldService.add(customField); return customFieldService.add(customField);
} }
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")

View File

@ -48,13 +48,14 @@ public class CustomFieldService {
@Resource @Resource
CustomFieldTemplateService customFieldTemplateService; CustomFieldTemplateService customFieldTemplateService;
public void add(CustomField customField) { public String add(CustomField customField) {
checkExist(customField); checkExist(customField);
customField.setId(UUID.randomUUID().toString()); customField.setId(UUID.randomUUID().toString());
customField.setCreateTime(System.currentTimeMillis()); customField.setCreateTime(System.currentTimeMillis());
customField.setUpdateTime(System.currentTimeMillis()); customField.setUpdateTime(System.currentTimeMillis());
customField.setGlobal(false); customField.setGlobal(false);
customFieldMapper.insert(customField); customFieldMapper.insert(customField);
return customField.getId();
} }
/** /**

View File

@ -110,7 +110,7 @@ public class IssuesService {
} }
if (CollectionUtils.isEmpty(platforms)) { if (CollectionUtils.isEmpty(platforms)) {
platforms.add("LOCAL"); platforms.add(IssuesManagePlatform.Local.toString());
} }
IssuesRequest issuesRequest = new IssuesRequest(); IssuesRequest issuesRequest = new IssuesRequest();
issuesRequest.setTestCaseId(updateRequest.getTestCaseId()); issuesRequest.setTestCaseId(updateRequest.getTestCaseId());

View File

@ -4,6 +4,7 @@
:visible.sync="visible" :visible.sync="visible"
@confirm="save" @confirm="save"
:title="'创建字段'" :title="'创建字段'"
append-to-body
ref="msEditDialog"> ref="msEditDialog">
<el-form :model="form" :rules="rules" label-position="right" label-width="140px" size="small" ref="form"> <el-form :model="form" :rules="rules" label-position="right" label-width="140px" size="small" ref="form">
@ -17,7 +18,7 @@
</el-form-item> </el-form-item>
<el-form-item :label="'使用场景'" prop="type"> <el-form-item :label="'使用场景'" prop="type">
<el-select :disabled="isSystem" filterable v-model="form.scene" placeholder="使用场景"> <el-select :disabled="isSystem || isTemplateEdit" filterable v-model="form.scene" placeholder="使用场景">
<el-option <el-option
v-for="item in sceneOptions" v-for="item in sceneOptions"
:key="item.value" :key="item.value"
@ -59,6 +60,7 @@ import {CUSTOM_FIELD_SCENE_OPTION, CUSTOM_FIELD_TYPE_OPTION, SYSTEM_FIELD_NAME_M
export default { export default {
name: "CustomFieldEdit", name: "CustomFieldEdit",
components: {MsSingleHandleDrag, MsEditDialog}, components: {MsSingleHandleDrag, MsEditDialog},
props: ['scene'],
data() { data() {
return { return {
form: { form: {
@ -99,6 +101,9 @@ export default {
}, },
systemNameMap() { systemNameMap() {
return SYSTEM_FIELD_NAME_MAP; return SYSTEM_FIELD_NAME_MAP;
},
isTemplateEdit() {
return this.scene ? true : false;
} }
}, },
methods: { methods: {
@ -124,6 +129,9 @@ export default {
system: false, system: false,
options: [] options: []
}; };
if (this.isTemplateEdit) {
this.form.scene = this.scene;
}
this.url = 'custom/field/add'; this.url = 'custom/field/add';
} }
}, },
@ -134,10 +142,12 @@ export default {
Object.assign(param, this.form); Object.assign(param, this.form);
param.workspaceId = getCurrentWorkspaceId(); param.workspaceId = getCurrentWorkspaceId();
param.options = JSON.stringify(this.form.options); param.options = JSON.stringify(this.form.options);
this.result = this.$post(this.url, param, () => { this.result = this.$post(this.url, param, (response) => {
this.visible = false; this.visible = false;
param.id = response.data;
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.$emit('refresh'); this.$emit('refresh');
this.$emit('save', param);
}); });
} }
}); });

View File

@ -34,7 +34,7 @@
<el-form-item :label="'已选字段'" class="filed-list"> <el-form-item :label="'已选字段'" class="filed-list">
<el-button type="primary" @click="relateField">添加字段</el-button> <el-button type="primary" @click="relateField">添加字段</el-button>
<el-button type="primary" plain>设置自定义字段</el-button> <el-button type="primary" @click="addField" plain>设置自定义字段</el-button>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -56,6 +56,8 @@
:scene="scene" :scene="scene"
ref="customFieldRelateList"/> ref="customFieldRelateList"/>
<custom-field-edit :scene="scene" @save="handleCustomFieldAdd" ref="customFieldEdit"/>
</el-scrollbar> </el-scrollbar>
</el-main> </el-main>
</template> </template>
@ -71,10 +73,12 @@ import MsFormDivider from "@/business/components/common/components/MsFormDivider
import CustomFieldFormList from "@/business/components/settings/workspace/template/CustomFieldFormList"; import CustomFieldFormList from "@/business/components/settings/workspace/template/CustomFieldFormList";
import CustomFieldRelateList from "@/business/components/settings/workspace/template/CustomFieldRelateList"; import CustomFieldRelateList from "@/business/components/settings/workspace/template/CustomFieldRelateList";
import {getCurrentWorkspaceId} from "@/common/js/utils"; import {getCurrentWorkspaceId} from "@/common/js/utils";
import CustomFieldEdit from "@/business/components/settings/workspace/template/CustomFieldEdit";
export default { export default {
name: "FieldTemplateEdit", name: "FieldTemplateEdit",
components: { components: {
CustomFieldEdit,
CustomFieldRelateList, CustomFieldRelateList,
CustomFieldFormList, CustomFieldFormList,
MsFormDivider, MsFormDivider,
@ -151,9 +155,18 @@ export default {
} }
}); });
}, },
handleCustomFieldAdd(data) {
this.templateContainIds.add(data.id);
data.fieldId = data.id;
data.id = null;
this.relateFields.push(data);
},
relateField() { relateField() {
this.$refs.customFieldRelateList.open(); this.$refs.customFieldRelateList.open();
}, },
addField() {
this.$refs.customFieldEdit.open();
},
getRelateFields() { getRelateFields() {
let condition = {}; let condition = {};
condition.templateId = this.form.id; condition.templateId = this.form.id;

View File

@ -103,6 +103,7 @@ export default {
issuePlatformMap:{ issuePlatformMap:{
metersphere: 'Metersphere', metersphere: 'Metersphere',
jira: 'JIRA', jira: 'JIRA',
Tapd: 'Tapd',
zentao: '禅道', zentao: '禅道',
}, },
operators: [ operators: [