refactor(项目管理): 用例模板责任人的默认值增加“创建人”选项

--bug=1014455 --user=李玉号
【项目管理】用例模板,责任人的默认值增加“创建人”选项
https://www.tapd.cn/55049933/s/1193112
This commit is contained in:
shiziyuan9527 2022-07-01 14:46:32 +08:00 committed by shiziyuan9527
parent d58264983b
commit 93d75e039a
4 changed files with 27 additions and 21 deletions

View File

@ -27,7 +27,7 @@
prop="type"> prop="type">
<template v-slot="scope"> <template v-slot="scope">
<el-scrollbar> <el-scrollbar>
<custom-filed-component class="default-value-item" :data="scope.row" prop="defaultValue"/> <custom-filed-component class="default-value-item" :data="scope.row" prop="defaultValue" :is-template-edit="true"/>
</el-scrollbar> </el-scrollbar>
</template> </template>
</ms-table-column> </ms-table-column>

View File

@ -87,7 +87,7 @@
<el-option <el-option
v-for="(item) in memberOptions" v-for="(item) in memberOptions"
:key="item.id" :key="item.id"
:label="item.name + ' (' + item.email + ')'" :label="item.name + (item.email ? ' (' + item.email + ')' : '')"
:value="item.id"> :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
@ -113,7 +113,6 @@
<script> <script>
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn"; import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";
import {getCurrentProjectID} from "@/common/js/utils";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag"; import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsMarkDownText from "@/business/components/track/case/components/MsMarkDownText"; import MsMarkDownText from "@/business/components/track/case/components/MsMarkDownText";
import {getProjectMemberOption} from "@/network/user"; import {getProjectMemberOption} from "@/network/user";
@ -126,7 +125,8 @@ export default {
'prop', 'prop',
'form', 'form',
'disabled', 'disabled',
'defaultOpen' 'defaultOpen',
'isTemplateEdit'
], ],
data() { data() {
return { return {
@ -136,6 +136,9 @@ export default {
mounted() { mounted() {
getProjectMemberOption((data) => { getProjectMemberOption((data) => {
this.memberOptions = data; this.memberOptions = data;
if (this.data.name === '责任人' && this.data.system && this.isTemplateEdit) {
this.memberOptions.unshift({id: 'CURRENT_USER', name: '创建人', email: ''});
}
}); });
}, },
methods: { methods: {

View File

@ -63,7 +63,7 @@
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button v-else type="primary" class="ms-api-buttion" @click="handleCommand" <el-button v-else type="primary" class="ms-api-buttion" @click="handleCommand"
:disabled="readOnly" :disabled="readOnly"
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.save') }} {{ $t('commons.save') }}
@ -79,21 +79,21 @@
prop="prerequisite"/> prop="prerequisite"/>
<step-change-item :label-width="formLabelWidth" :form="form"/> <step-change-item :label-width="formLabelWidth" :form="form"/>
<form-rich-text-item v-if="form.stepModel === 'TEXT'" <form-rich-text-item v-if="form.stepModel === 'TEXT'"
prop="stepDescription" prop="stepDescription"
:disabled="readOnly" :disabled="readOnly"
:label-width="formLabelWidth" :label-width="formLabelWidth"
:title="$t('test_track.case.step_desc')" :title="$t('test_track.case.step_desc')"
:data="form" :data="form"
:default-open="richTextDefaultOpen"/> :default-open="richTextDefaultOpen"/>
<form-rich-text-item v-if="form.stepModel === 'TEXT'" <form-rich-text-item v-if="form.stepModel === 'TEXT'"
prop="expectedResult" prop="expectedResult"
:disabled="readOnly" :disabled="readOnly"
:label-width="formLabelWidth" :label-width="formLabelWidth"
:title="$t('test_track.case.expected_results')" :title="$t('test_track.case.expected_results')"
:data="form" :data="form"
:default-open="richTextDefaultOpen"/> :default-open="richTextDefaultOpen"/>
<test-case-step-item v-if="form.stepModel === 'STEP' || !form.stepModel" <test-case-step-item v-if="form.stepModel === 'STEP' || !form.stepModel"
:label-width="formLabelWidth" :label-width="formLabelWidth"
@ -223,7 +223,7 @@ export default {
showFollow: false, showFollow: false,
isValidate: false, isValidate: false,
currentValidateName: "", currentValidateName: "",
type:"", type: "",
form: { form: {
name: '', name: '',
module: 'default-module', module: 'default-module',

View File

@ -1,5 +1,6 @@
import i18n from '../../i18n/i18n' import i18n from '../../i18n/i18n'
import {SYSTEM_FIELD_NAME_MAP} from "@/common/js/table-constants"; import {SYSTEM_FIELD_NAME_MAP} from "@/common/js/table-constants";
import {getCurrentUserId} from "@/common/js/utils";
function setDefaultValue(item, value) { function setDefaultValue(item, value) {
item.defaultValue = value; item.defaultValue = value;
@ -10,7 +11,6 @@ function setDefaultValue(item, value) {
* 设置默认值添加自定义校验 * 设置默认值添加自定义校验
* @param data 原表单值 * @param data 原表单值
* @param template 模板 * @param template 模板
* @param customFieldForm 用于自定义表单的校验
* @param rules 自定义表单的校验规则 * @param rules 自定义表单的校验规则
* @param oldFields 用于兼容旧版本数据 * @param oldFields 用于兼容旧版本数据
*/ */
@ -34,6 +34,9 @@ export function parseCustomField(data, template, rules, oldFields) {
} catch (e) { } catch (e) {
// //
} }
if (item.name === '责任人' && item.system && val && val === 'CURRENT_USER') {
val = getCurrentUserId();
}
setDefaultValue(item, val); setDefaultValue(item, val);
} }