|
|
|
@ -11,6 +11,7 @@
|
|
|
|
|
<el-tabs v-model="radio" class="el_TablePage_radio"> |
|
|
|
|
<el-tab-pane label="当前页全部导出" name="1"></el-tab-pane> |
|
|
|
|
<el-tab-pane label="当前页勾选导出" name="2"></el-tab-pane> |
|
|
|
|
<el-tab-pane label="全部数据导出" name="3"></el-tab-pane> |
|
|
|
|
</el-tabs> |
|
|
|
|
|
|
|
|
|
<el-transfer |
|
|
|
@ -34,6 +35,8 @@ import { ref, computed, watch } from 'vue';
|
|
|
|
|
import { ElMessage } from 'element-plus'; |
|
|
|
|
import * as XLSX from 'xlsx'; |
|
|
|
|
import { Download } from '@element-plus/icons-vue'; |
|
|
|
|
import { useRoute } from 'vue-router'; |
|
|
|
|
const $route = useRoute(); |
|
|
|
|
const radio = ref('1'); |
|
|
|
|
// 传入的参数 |
|
|
|
|
const props = defineProps({ |
|
|
|
@ -58,18 +61,20 @@ const props = defineProps({
|
|
|
|
|
watch( |
|
|
|
|
() => props.tcTableexport, |
|
|
|
|
(newPath, oldPath) => { |
|
|
|
|
menuData.value = JSON.parse(JSON.stringify(props.menuData)); |
|
|
|
|
const removeColumn = columnLabel => { |
|
|
|
|
const index = menuData.value.findIndex(item => item.label === columnLabel); |
|
|
|
|
if (index !== -1) { |
|
|
|
|
menuData.value.splice(index, 1); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
initializeCheckedColumns(); |
|
|
|
|
// 移除 '序号' 列 |
|
|
|
|
removeColumn('序号'); |
|
|
|
|
removeColumn('操作'); |
|
|
|
|
removeColumn('复选框'); |
|
|
|
|
if (newPath) { |
|
|
|
|
menuData.value = JSON.parse(JSON.stringify(props.menuData)); |
|
|
|
|
const removeColumn = columnLabel => { |
|
|
|
|
const index = menuData.value.findIndex(item => item.label === columnLabel); |
|
|
|
|
if (index !== -1) { |
|
|
|
|
menuData.value.splice(index, 1); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
initializeCheckedColumns(); |
|
|
|
|
// 移除 '序号' 列 |
|
|
|
|
removeColumn('序号'); |
|
|
|
|
removeColumn('操作'); |
|
|
|
|
removeColumn('复选框'); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ immediate: true, deep: true } |
|
|
|
|
); |
|
|
|
@ -91,8 +96,13 @@ removeColumn('复选框');
|
|
|
|
|
const exportFileName = ref(''); |
|
|
|
|
// 已选择的列 |
|
|
|
|
const checkedColumns = ref([]); |
|
|
|
|
// const initializeCheckedColumns = () => { |
|
|
|
|
// checkedColumns.value = transferData.value.map(item => item.key); |
|
|
|
|
// }; |
|
|
|
|
const initializeCheckedColumns = () => { |
|
|
|
|
checkedColumns.value = transferData.value.map(item => item.key); |
|
|
|
|
checkedColumns.value = transferData.value |
|
|
|
|
.filter(item => item.head !== true) // 只选择 head 为 false 的列 |
|
|
|
|
.map(item => item.key); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 构建 el-transfer 所需的数据格式,并添加类型检查 |
|
|
|
|