fix: 列表展示模板字段失效
This commit is contained in:
parent
062a237775
commit
a9f2301033
|
@ -18,8 +18,7 @@
|
||||||
<script>
|
<script>
|
||||||
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
||||||
import treeTransfer from 'el-tree-transfer'
|
import treeTransfer from 'el-tree-transfer'
|
||||||
import {saveCustomTableHeader} from "@/common/js/tableUtils";
|
import {getAllFieldWithCustomFields, saveCustomTableHeader} from "@/common/js/tableUtils";
|
||||||
import {CUSTOM_TABLE_HEADER} from "@/common/js/default-table-header";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsCustomTableHeader",
|
name: "MsCustomTableHeader",
|
||||||
|
@ -37,6 +36,7 @@ export default {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
type: String,
|
type: String,
|
||||||
|
customFields: Array
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
allowDrop(draggingNode, dropNode, type) {
|
allowDrop(draggingNode, dropNode, type) {
|
||||||
|
@ -44,7 +44,7 @@ export default {
|
||||||
},
|
},
|
||||||
open(items) {
|
open(items) {
|
||||||
items = JSON.parse(JSON.stringify(items));
|
items = JSON.parse(JSON.stringify(items));
|
||||||
let fields = JSON.parse(JSON.stringify(CUSTOM_TABLE_HEADER[this.type]));
|
let fields = getAllFieldWithCustomFields(this.type, this.customFields);
|
||||||
this.selectedKeys = [];
|
this.selectedKeys = [];
|
||||||
this.fromFields = [];
|
this.fromFields = [];
|
||||||
this.selectedKeys = items.map(item => item.key);
|
this.selectedKeys = items.map(item => item.key);
|
||||||
|
|
|
@ -56,8 +56,9 @@
|
||||||
|
|
||||||
<ms-custom-table-header
|
<ms-custom-table-header
|
||||||
v-if="fieldKey"
|
v-if="fieldKey"
|
||||||
@reload="reloadTable"
|
@reload="resetHeader"
|
||||||
:type="fieldKey"
|
:type="fieldKey"
|
||||||
|
:custom-fields="customFields"
|
||||||
ref="customTableHeader"/>
|
ref="customTableHeader"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -187,6 +188,7 @@ export default {
|
||||||
},
|
},
|
||||||
fields: Array,
|
fields: Array,
|
||||||
fieldKey: String,
|
fieldKey: String,
|
||||||
|
customFields: Array
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
getLabel(this, TEST_CASE_LIST);
|
getLabel(this, TEST_CASE_LIST);
|
||||||
|
@ -291,8 +293,11 @@ export default {
|
||||||
openCustomHeader() {
|
openCustomHeader() {
|
||||||
this.$refs.customTableHeader.open(this.fields);
|
this.$refs.customTableHeader.open(this.fields);
|
||||||
},
|
},
|
||||||
|
resetHeader() {
|
||||||
|
this.$emit('update:fields', getCustomTableHeader(this.fieldKey, this.customFields));
|
||||||
|
this.reloadTable();
|
||||||
|
},
|
||||||
reloadTable() {
|
reloadTable() {
|
||||||
this.$emit('update:fields', getCustomTableHeader(this.fieldKey));
|
|
||||||
this.tableActive = false;
|
this.tableActive = false;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.tableActive = true;
|
this.tableActive = true;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
:fields.sync="fields"
|
:fields.sync="fields"
|
||||||
field-key="TRACK_TEST_CASE"
|
field-key="TRACK_TEST_CASE"
|
||||||
@refresh="initTableData"
|
@refresh="initTableData"
|
||||||
|
:custom-fields="testCaseTemplate.customFields"
|
||||||
ref="table">
|
ref="table">
|
||||||
|
|
||||||
<span v-for="item in fields" :key="item.key">
|
<span v-for="item in fields" :key="item.key">
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
:fields.sync="fields"
|
:fields.sync="fields"
|
||||||
field-key="ISSUE_LIST"
|
field-key="ISSUE_LIST"
|
||||||
@refresh="getIssues"
|
@refresh="getIssues"
|
||||||
|
:custom-fields="issueTemplate.customFields"
|
||||||
ref="table"
|
ref="table"
|
||||||
>
|
>
|
||||||
<span v-for="(item) in fields" :key="item.key">
|
<span v-for="(item) in fields" :key="item.key">
|
||||||
|
|
|
@ -171,7 +171,6 @@ export const CUSTOM_TABLE_HEADER = {
|
||||||
{id: 'nodePath', key: '5', label: i18n.t('test_track.case.module')},
|
{id: 'nodePath', key: '5', label: i18n.t('test_track.case.module')},
|
||||||
{id: 'updateTime', key: '6', label: i18n.t('commons.update_time')},
|
{id: 'updateTime', key: '6', label: i18n.t('commons.update_time')},
|
||||||
{id: 'createUser', key: '7', label: i18n.t('commons.create_user')},
|
{id: 'createUser', key: '7', label: i18n.t('commons.create_user')},
|
||||||
{id: 'maintainer', key: '8', label: i18n.t('custom_field.case_maintainer')},
|
|
||||||
],
|
],
|
||||||
//缺陷列表
|
//缺陷列表
|
||||||
ISSUE_LIST: [
|
ISSUE_LIST: [
|
||||||
|
|
|
@ -237,11 +237,17 @@ export function getPageDate(response, page) {
|
||||||
* @param key
|
* @param key
|
||||||
* @returns {[]|*}
|
* @returns {[]|*}
|
||||||
*/
|
*/
|
||||||
export function getCustomTableHeader(key) {
|
export function getCustomTableHeader(key, customFields) {
|
||||||
let fieldSetting = CUSTOM_TABLE_HEADER[key];
|
let fieldSetting = getAllFieldWithCustomFields(key, customFields);
|
||||||
return getCustomTableHeaderByFiledSetting(key, fieldSetting);
|
return getCustomTableHeaderByFiledSetting(key, fieldSetting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 localStorage 的值,过滤
|
||||||
|
* @param key
|
||||||
|
* @param fieldSetting
|
||||||
|
* @returns {[]|*}
|
||||||
|
*/
|
||||||
function getCustomTableHeaderByFiledSetting(key, fieldSetting) {
|
function getCustomTableHeaderByFiledSetting(key, fieldSetting) {
|
||||||
let fieldStr = localStorage.getItem(key);
|
let fieldStr = localStorage.getItem(key);
|
||||||
if (fieldStr !== null) {
|
if (fieldStr !== null) {
|
||||||
|
@ -268,7 +274,7 @@ function getCustomTableHeaderByFiledSetting(key, fieldSetting) {
|
||||||
* @returns {[]|*}
|
* @returns {[]|*}
|
||||||
*/
|
*/
|
||||||
export function getTableHeaderWithCustomFields(key, customFields) {
|
export function getTableHeaderWithCustomFields(key, customFields) {
|
||||||
let fieldSetting = [CUSTOM_TABLE_HEADER[key]];
|
let fieldSetting = [...CUSTOM_TABLE_HEADER[key]]; // 复制
|
||||||
let keys = getCustomFieldsKeys(customFields);
|
let keys = getCustomFieldsKeys(customFields);
|
||||||
customFields.forEach(item => {
|
customFields.forEach(item => {
|
||||||
if (!item.key) {
|
if (!item.key) {
|
||||||
|
@ -287,6 +293,28 @@ export function getTableHeaderWithCustomFields(key, customFields) {
|
||||||
return getCustomTableHeaderByFiledSetting(key, fieldSetting);
|
return getCustomTableHeaderByFiledSetting(key, fieldSetting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有字段
|
||||||
|
* @param key
|
||||||
|
* @param customFields
|
||||||
|
* @returns {*[]}
|
||||||
|
*/
|
||||||
|
export function getAllFieldWithCustomFields(key, customFields) {
|
||||||
|
let fieldSetting = [...CUSTOM_TABLE_HEADER[key]];
|
||||||
|
if (customFields) {
|
||||||
|
customFields.forEach(item => {
|
||||||
|
let field = {
|
||||||
|
id: item.name,
|
||||||
|
key: item.key,
|
||||||
|
label: item.name,
|
||||||
|
isCustom: true
|
||||||
|
}
|
||||||
|
fieldSetting.push(field);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return fieldSetting;
|
||||||
|
}
|
||||||
|
|
||||||
export function generateTableHeaderKey(keys) {
|
export function generateTableHeaderKey(keys) {
|
||||||
let customFieldKeys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
let customFieldKeys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
for (let i = 0; i < customFieldKeys.length; i++) {
|
for (let i = 0; i < customFieldKeys.length; i++) {
|
||||||
|
|
Loading…
Reference in New Issue