|
@@ -43,6 +43,7 @@
|
|
|
}"
|
|
|
:pagination="paginationProps"
|
|
|
:scroll="{ y: '340px' }"
|
|
|
+ :rowKey="props.valueField || props.uniqueKey"
|
|
|
/>
|
|
|
</a-tab-pane>
|
|
|
<a-tab-pane key="2" :tab="t('已选记录')" force-render>
|
|
@@ -50,6 +51,7 @@
|
|
|
:dataSource="selectedList"
|
|
|
:columns="state.selectedColumns"
|
|
|
:scroll="{ y: '340px' }"
|
|
|
+ :rowKey="props.valueField || props.uniqueKey"
|
|
|
>
|
|
|
<template #bodyCell="{ column, record, index }">
|
|
|
<template v-if="column.key === 'delete'">
|
|
@@ -75,6 +77,7 @@
|
|
|
type: 'radio',
|
|
|
}"
|
|
|
:scroll="{ y: '200px' }"
|
|
|
+ :rowKey="props.valueField || props.uniqueKey"
|
|
|
/>
|
|
|
</a-modal>
|
|
|
</template>
|
|
@@ -251,14 +254,17 @@
|
|
|
},
|
|
|
);
|
|
|
const initData = () => {
|
|
|
+ console.log('props.valueField', props.valueField, props.uniqueKey);
|
|
|
if (!props.isSubFormUse) {
|
|
|
state.dataSourceList.map((data: any, index: number) => {
|
|
|
- data.key = index + 1;
|
|
|
+ const id = data[props.valueField!] || data[props.uniqueKey!];
|
|
|
+ // data.key = index + 1;
|
|
|
if (props.value) {
|
|
|
props.selectedDataSource.map((select: any) => {
|
|
|
- if (data.key === select.key) {
|
|
|
+ const sId = select[props.valueField!] || select[props.uniqueKey!];
|
|
|
+ if (id === sId) {
|
|
|
selectedList.value.push(data);
|
|
|
- state.selectedRowKeys.push(data.key);
|
|
|
+ state.selectedRowKeys.push(id);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -266,11 +272,13 @@
|
|
|
}
|
|
|
if (props.isSubFormUse) {
|
|
|
state.dataSourceList.map((data: any, index: number) => {
|
|
|
- data.key = index + 1;
|
|
|
+ // data.key = index + 1;
|
|
|
+ const id = data[props.valueField!] || data[props.uniqueKey!];
|
|
|
props.selectedDataSource.map((select: any) => {
|
|
|
- if (select[props.uniqueKey!] === data[props.valueField!]) {
|
|
|
+ const sId = select[props.valueField!] || select[props.uniqueKey!];
|
|
|
+ if (id === sId) {
|
|
|
selectedList.value.push(data);
|
|
|
- state.selectedRowKeys.push(data.key);
|
|
|
+ state.selectedRowKeys.push(id);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
@@ -432,6 +440,31 @@
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ const removeDuplicate = (tagerData, sourceData, key) => {
|
|
|
+ if (tagerData.length === 0) {
|
|
|
+ tagerData = [...sourceData];
|
|
|
+ } else {
|
|
|
+ sourceData.forEach((item) => {
|
|
|
+ if (key) {
|
|
|
+ const findIndex = tagerData.findIndex(
|
|
|
+ (row) =>
|
|
|
+ (row[props.valueField!] || row[props.uniqueKey!]) ===
|
|
|
+ (item[props.valueField!] || item[props.uniqueKey!]),
|
|
|
+ );
|
|
|
+ if (findIndex < 0) {
|
|
|
+ tagerData.push(item);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const findIndex = tagerData.findIndex((row) => row === item);
|
|
|
+ if (findIndex < 0) {
|
|
|
+ tagerData.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return tagerData;
|
|
|
+ };
|
|
|
+
|
|
|
const onSelectChange = (rowKeys, selectedRows) => {
|
|
|
if (!props.multiple) {
|
|
|
selectedRows = selectedRows.slice(selectedRows.length - 1);
|
|
@@ -439,8 +472,8 @@
|
|
|
state.selectedRowKeys = rowKeys;
|
|
|
selectedList.value = selectedRows;
|
|
|
} else {
|
|
|
- state.selectedRowKeys = rowKeys;
|
|
|
- selectedList.value = selectedRows;
|
|
|
+ state.selectedRowKeys = removeDuplicate([...state.selectedRowKeys], [...rowKeys], false);
|
|
|
+ selectedList.value = removeDuplicate([...selectedList.value], [...selectedRows], true);
|
|
|
}
|
|
|
};
|
|
|
|