fix(项目设置): 编辑模板自定义字段默认值,文本过大无法编辑

--bug=1019378 --user=陈建星 【项目设置】模板管理,接口模板里添加富文本框,无法编辑富文本框的默认值 https://www.tapd.cn/55049933/s/1289478
This commit is contained in:
chenjianxing 2022-11-04 16:29:20 +08:00 committed by jianxing
parent a9e13a7750
commit 1d38e7cb40
4 changed files with 2 additions and 357 deletions

View File

@ -1,161 +0,0 @@
<template>
<ms-table
v-loading="loading"
:enable-selection="false"
:operators="operators"
:data="tableData"
:screen-height="null"
@refresh="refreshTable"
ref="table">
<ms-table-column
:label="$t('commons.name')"
prop="name">
<template v-slot="scope">
<span v-if="scope.row.system">
{{$t(systemNameMap[scope.row.name])}}
</span>
<span v-else>
{{scope.row.name}}
</span>
</template>
</ms-table-column>
<ms-table-column
:label="$t('commons.default')"
min-width="200"
prop="type">
<template v-slot="scope">
<el-scrollbar>
<custom-filed-component class="default-value-item" :data="scope.row" prop="defaultValue" :is-template-edit="true"/>
</el-scrollbar>
</template>
</ms-table-column>
<field-custom-data-table-item :scene="scene"/>
<ms-table-column
:label="$t('api_test.definition.document.table_coloum.is_required')"
width="80"
prop="type">
<template v-slot="scope">
<el-checkbox v-model="scope.row.required"/>
</template>
</ms-table-column>
<ms-table-column
:label="$t('custom_field.system_field')"
width="80"
prop="system">
<template v-slot="scope">
<span v-if="scope.row.system">
{{$t('commons.yes')}}
</span>
<span v-else>
{{$t('commons.no')}}
</span>
</template>
</ms-table-column>
<ms-table-column
:label="$t('commons.remark')"
prop="remark">
</ms-table-column>
</ms-table>
</template>
<script>
import MsTableOperatorButton from "../MsTableOperatorButton";
import MsTable from "../table/MsTable";
import MsTableColumn from "../table/MsTableColumn";
// import FieldCustomDataTableItem from "./FieldCustomDataTableItem";
import CustomFiledComponent from "./CustomFiledComponent";
// import {getCustomFields} from "../../../api/template";
import {SYSTEM_FIELD_NAME_MAP} from "../../utils/table-constants";
export default {
name: "CustomFieldFormList",
components: {
CustomFiledComponent,
// FieldCustomDataTableItem,
MsTableColumn, MsTable, MsTableOperatorButton
},
data() {
return {
result: {},
loading: false,
operators: [
{
tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger",
exec: this.handleDelete,
isDisable: (row) => {
if (row.name === '用例等级') {
return true;
}
return false;
}
}
],
};
},
props: {
tableData: {
type: Array,
default() {
return [];
},
},
scene: String,
platform: String,
templateContainIds: Set
},
watch: {
'customFieldIds.length'() {
this.initTableData();
}
},
computed: {
systemNameMap() {
return SYSTEM_FIELD_NAME_MAP;
}
},
methods: {
handleDelete(item, index) {
this.templateContainIds.delete(item.fieldId);
this.tableData.splice(index, 1);
},
refreshTable() {
this.$refs.table.reloadTable();
},
appendData(customFieldIds) {
let condition = {};
condition.ids = customFieldIds;
this.loading = getCustomFields(condition).then((response) => {
let data = response.data;
data.forEach(item => {
if (item.id) {
this.templateContainIds.add(item.id);
}
item.fieldId = item.id;
item.id = null;
item.options = JSON.parse(item.options);
if (item.type === 'checkbox') {
item.defaultValue = [];
}
});
this.tableData.push(...data);
});
}
}
};
</script>
<style scoped>
:deep(.el-table--border, .el-table--group ) {
border: 0px;
}
</style>

View File

@ -1,190 +0,0 @@
<template>
<ms-edit-dialog
appendToBody
width="70%"
:visible.sync="visible"
@confirm="save"
:title="$t('custom_field.add_field')"
ref="msEditDialog">
<template v-slot:header>
<ms-table-header :condition.sync="condition" @search="search"
:show-create="false"/>
</template>
<ms-table
v-loading="loading"
:data="tableData"
:condition="condition"
:total="total"
:show-select-all="false"
:page-size.sync="pageSize"
@handlePageChange="initTableData"
@refresh="initTableData"
ref="table">
<ms-table-column
:label="$t('commons.name')"
:fields="fields"
prop="name">
<template v-slot="scope">
<span v-if="scope.row.system">
{{$t(systemNameMap[scope.row.name])}}
</span>
<span v-else>
{{scope.row.name}}
</span>
</template>
</ms-table-column>
<ms-table-column
:label="$t('custom_field.attribute_type')"
:fields="fields"
:filters="fieldFilters"
prop="type">
<template v-slot="scope">
<span>{{ $t(fieldTypeMap[scope.row.type]) }}</span>
</template>
</ms-table-column>
<ms-table-column
:label="$t('custom_field.system_field')"
:fields="fields"
prop="system">
<template v-slot="scope">
<span v-if="scope.row.system">
{{$t('commons.yes')}}
</span>
<span v-else>
{{$t('commons.no')}}
</span>
</template>
</ms-table-column>
<ms-table-column
:label="$t('commons.remark')"
:fields="fields"
prop="remark">
</ms-table-column>
<ms-table-column
sortable
:label="$t('commons.create_time')"
:fields="fields"
prop="createTime">
<template v-slot="scope">
<span>{{ scope.row.createTime | datetimeFormat }}</span>
</template>
</ms-table-column>
<ms-table-column
sortable
:label="$t('commons.update_time')"
:fields="fields"
prop="updateTime">
<template v-slot="scope">
<span>{{ scope.row.updateTime | datetimeFormat }}</span>
</template>
</ms-table-column>
</ms-table>
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize" :total="total"/>
</ms-edit-dialog>
</template>
<script>
import MsTable from "metersphere-frontend/src/components/table/MsTable";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
import {CUSTOM_FIELD_LIST} from "metersphere-frontend/src/utils/default-table-header";
import MsTableButton from "metersphere-frontend/src/components/MsTableButton";
import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination";
import {
CUSTOM_FIELD_TYPE_FILTERS,
FIELD_TYPE_MAP,
SYSTEM_FIELD_NAME_MAP
} from "metersphere-frontend/src/utils/table-constants";
import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader";
// import {getCustomFieldRelatePages} from "../../../api/template";
import MsEditDialog from "../../components/MsEditDialog";
export default {
name: "CustomFieldRelateList",
components: {
MsEditDialog,
MsTableHeader,
MsTablePagination, MsTableButton, MsTableColumn, MsTable},
data() {
return {
tableData: [],
condition: {},
visible: false,
total: 0,
pageSize: 10,
currentPage: 1,
result: {},
loading: false,
};
},
props: [
'scene',
'templateId',
'templateContainIds',
],
computed: {
fields() {
return CUSTOM_FIELD_LIST;
},
fieldFilters() {
return CUSTOM_FIELD_TYPE_FILTERS(this);
},
fieldTypeMap() {
return FIELD_TYPE_MAP;
},
systemNameMap() {
return SYSTEM_FIELD_NAME_MAP;
}
},
methods: {
search() {
if (!(this.condition.name.trim())) {
this.currentPage = 1;
}
this.initTableData();
},
initTableData() {
this.condition.projectId = getCurrentProjectID();
this.condition.templateId = this.templateId;
this.condition.templateContainIds = Array.from(this.templateContainIds);
let filters = this.condition.filters;
if (filters) {
filters.scene = [this.scene];
} else {
this.condition.filters = {scene: [this.scene]};
}
if (this.scene) {
this.loading = getCustomFieldRelatePages(this.currentPage, this.pageSize, this.condition).then((response) => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
});
}
},
open() {
this.initTableData();
this.visible = true;
},
save() {
if (this.$refs.table.selectIds.length > 0) {
this.$emit('save', this.$refs.table.selectIds);
}
this.visible = false;
},
}
};
</script>
<style scoped>
</style>

View File

@ -21,7 +21,7 @@
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column <el-table-column
:label="$t('commons.default')" :label="$t('commons.default')"
min-width="200" min-width="200"
prop="type"> prop="type">
@ -34,7 +34,7 @@
:is-template-edit="true"/> :is-template-edit="true"/>
</el-scrollbar> </el-scrollbar>
</template> </template>
</ms-table-column> </el-table-column>
<field-custom-data-table-item :scene="scene"/> <field-custom-data-table-item :scene="scene"/>

View File

@ -192,8 +192,6 @@
import TemplateComponentEditHeader from "@/business/plan/view/comonents/report/TemplateComponentEditHeader"; import TemplateComponentEditHeader from "@/business/plan/view/comonents/report/TemplateComponentEditHeader";
import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider"; import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider";
import CustomFieldFormList from "metersphere-frontend/src/components/template/CustomFieldFormList";
import CustomFieldRelateList from "metersphere-frontend/src/components/template/CustomFieldRelateList";
import FormRichTextItem from "metersphere-frontend/src/components/FormRichTextItem"; import FormRichTextItem from "metersphere-frontend/src/components/FormRichTextItem";
import {buildCustomFields, parseCustomField} from "metersphere-frontend/src/utils/custom_field"; import {buildCustomFields, parseCustomField} from "metersphere-frontend/src/utils/custom_field";
import CustomFiledComponent from "metersphere-frontend/src/components/template/CustomFiledComponent"; import CustomFiledComponent from "metersphere-frontend/src/components/template/CustomFiledComponent";
@ -240,8 +238,6 @@ export default {
TestCaseIssueList, TestCaseIssueList,
CustomFiledComponent, CustomFiledComponent,
FormRichTextItem, FormRichTextItem,
CustomFieldRelateList,
CustomFieldFormList,
MsFormDivider, MsFormDivider,
TemplateComponentEditHeader, TemplateComponentEditHeader,
MsMarkDownText, MsMarkDownText,