Browse Source

修复已知bug

pre-production
马远东 8 months ago
parent
commit
7ab2a39fa7
  1. 76
      src/components/Tableexportcomponent/Tableexportcomponent.vue
  2. 29
      src/views/financialsector/CustomerBaseprice.vue

76
src/components/Tableexportcomponent/Tableexportcomponent.vue

@ -1,6 +1,6 @@
<template>
<div class="el_TablePage">
<span> 表格导出名称 </span>
<span>表格导出名称</span>
<el-input
v-model="exportFileName"
placeholder="请输入导出的表格名称"
@ -11,17 +11,12 @@
:data="transferData"
:titles="['可选字段', '已选字段']"
:filterable="true"
value-key="prop"
:props="{
key: 'prop',
label: 'label',
}"
>
</el-transfer>
:props="transferProps"
/>
<div class="el_TablePage_btn">
<el-button type="primary" @click="exportToExcel">
<el-icon><Download /></el-icon></el-button
>
<el-icon><Download /></el-icon>
</el-button>
</div>
</div>
</template>
@ -30,6 +25,8 @@
import { ref, computed } from 'vue';
import { ElMessage } from 'element-plus';
import * as XLSX from 'xlsx';
import { Download } from '@element-plus/icons-vue';
//
const props = defineProps({
data: {
@ -42,26 +39,44 @@ const props = defineProps({
},
});
const index = props.menuData.findIndex(item => item.label === '序号');
if (index !== -1) {
props.menuData.splice(index, 1);
}
// menuData 便 setup
const menuData = ref([...props.menuData]);
//
const removeColumn = (columnLabel) => {
const index = menuData.value.findIndex(item => item.label === columnLabel);
if (index !== -1) {
menuData.value.splice(index, 1);
}
};
// ''
removeColumn('序号');
removeColumn('操作');
removeColumn('复选框');
const exportFileName = ref('');
//
const checkedColumns = ref([]);
// el-transfer
const transferData = computed(() => {
if (Array.isArray(props.menuData)) {
return props.menuData.map(item => ({
if (Array.isArray(menuData.value)) {
return menuData.value.map(item => ({
...item,
key: item.prop,
}));
} else {
console.error('menuData 不是一个数组:', props.menuData);
console.error('menuData 不是一个数组:', menuData.value);
return [];
}
});
// el-transfer props
const transferProps = {
key: 'key',
label: 'label',
};
// Excel
const exportToExcel = () => {
if (checkedColumns.value.length === 0) {
ElMessage.warning('请选择要导出的字段');
@ -74,8 +89,9 @@ const exportToExcel = () => {
});
return;
}
const selectedColumns = transferData.value.filter(item =>
checkedColumns.value.includes(item.prop)
checkedColumns.value.includes(item.key)
);
const headers = selectedColumns.map(col => col.label);
const fields = selectedColumns.map(col => col.prop);
@ -114,32 +130,20 @@ const fillEmptyCells = (data) => {
const rowCount = data.length;
const colCount = data[0].length;
//
for (let col = 0; col < colCount; col++) {
let lastNonEmptyValue = '';
let inFillSection = false;
for (let row = 0; row < rowCount; row++) {
if (data[row][0] !== '') { // A
inFillSection = true;
if (data[row][col] !== '') { //
lastNonEmptyValue = data[row][col];
} else if (lastNonEmptyValue !== '') { //
data[row][col] = lastNonEmptyValue; //
}
} else if (inFillSection) { // A
if (lastNonEmptyValue !== '') {
data[row][col] = lastNonEmptyValue; //
}
} else { // A
lastNonEmptyValue = '';
inFillSection = false;
if (data[row][col] !== '') {
lastNonEmptyValue = data[row][col];
} else {
data[row][col] = lastNonEmptyValue;
}
}
}
return data;
};
//
const applyStyles = (worksheet, data) => {
const rowCount = data.length;
@ -195,4 +199,4 @@ const applyStyles = (worksheet, data) => {
text-align: right;
margin-top: 10px;
}
</style>
</style>

29
src/views/financialsector/CustomerBaseprice.vue

@ -23,6 +23,9 @@
<el-button type="primary" @click="Deletetemplate">
<el-icon><Delete /></el-icon> </el-button
>
<el-button type="primary" @click="Tableexport">
<el-icon><Delete /></el-icon> </el-button
>
</div>
<!-- 头部右侧按钮模块 -->
<div class="avue-crud__right">
@ -79,6 +82,9 @@
</el-row>
</div>
</basic-container>
<el-dialog v-model="tcTableexport" title="导出" width="40%">
<Tableexportcomponent :menuData="details.columnList" :data="data"></Tableexportcomponent>
</el-dialog>
<!-- 列表配置显示 -->
<edittablehead
@closce="showdrawer"
@ -89,20 +95,35 @@
</template>
<script setup>
import { ref, reactive, toRefs, computed, onMounted, nextTick, watch, onActivated } from 'vue';
import {
ref,
reactive,
toRefs,
computed,
onMounted,
nextTick,
watch,
onActivated,
defineAsyncComponent,
} from 'vue';
import { columnList } from '@/option/financialsector/index.js';
import { $_getpriceTemplate, $_deletelpriceTemplate } from '@/api/financialsector/index'; //
// import Tableexportcomponent from '@/components/Tableexportcomponent/Tableexportcomponent.vue';
import { getDictionaryBiz } from '@/api/system/dict'; //
import { processRowProperty, setNodeHeight, deepClone, downloadXls } from '@/utils/util';
import { getToken } from 'utils/auth'; // Token
import functions from '@/utils/functions.js';
import { ElMessageBox, ElMessage } from 'element-plus';
const Tableexportcomponent = defineAsyncComponent(() =>
import('@/components/Tableexportcomponent/Tableexportcomponent.vue')
);
import { useStore } from 'vuex';
import dayjs from 'dayjs';
const $router = useRouter(); //
const $useStore = useStore(); //
const $route = useRoute(); //
const dialogTemp = ref(false); //
const tcTableexport=ref(false);//
const details = reactive({
/** 是否开启搜索 */
search: false,
@ -269,6 +290,9 @@ function updateDictionary(targetArray, dictionaryType) {
});
});
}
const Tableexport=()=>[
tcTableexport.value=true
]
//
const priceTemplate = () => {
let data = {
@ -356,8 +380,7 @@ const Modifytemplate = row => {
});
};
//
const dialogVisible = () => {};
onActivated(() => {
console.log('进入缓存');

Loading…
Cancel
Save