提交 184311f7 authored 作者: yaoxinguo's avatar yaoxinguo

通用方法优化

上级 a68f0416
......@@ -17,10 +17,14 @@ import { getToken } from '@/webPublic/one_stop_public/utils/token';
* rowSpanData 列合并数据,colSpanData行合并数据
* */
export function getSpanJson(mergeKey, data, eliminateStr = []) {
try {
return {
rowSpanData: getRowSpanJson(mergeKey, data, eliminateStr),
colSpanData: getColSpanJson(mergeKey, data, eliminateStr),
};
} catch (err) {
console.table(err);
}
}
function getRowSpanJson(cloumnNames, data, eliminateStr = []) {
......@@ -120,6 +124,7 @@ function getColSpanJson(cloumnNames, data, eliminateStr = []) {
* columnsHeight 行数
* */
export function getColumns(columns) {
const uj = {
t: 1,
v: '序号',
......@@ -254,7 +259,7 @@ export function getColumnsSqlKeyRealize({
verticalAlignment: 'CENTER', //TOP、CENTER、BOTTOM、JUSTIFY、DISTRIBUTED
wrapText: true,
rowHeights: 20,
colWidths: 200,
colWidths: 250,
},
head: {
font: {
......@@ -267,6 +272,7 @@ export function getColumnsSqlKeyRealize({
if (styles) {
content.styles = styles;
}
try {
let getFileData = giveFilePostDataInfoForTrue(
{
content: JSON.stringify(content),
......@@ -284,6 +290,9 @@ export function getColumnsSqlKeyRealize({
fileName,
ext,
);
} catch (err) {
console.table(err);
}
}
/**
......@@ -312,11 +321,13 @@ export function getColumnsDataRealize({
let { colSpanData, rowSpanData } = getSpanJson(mergeKey, data, eliminateStr);
// 处理数据
let bodyData = [];
let dataMerges = [];
const uj = {
t: 1,
v: '序号',
s: 'header',
};
try {
data.forEach((dv, di) => {
let nowArroy = new Array(columnsKey.length).fill({});
columnsKey.forEach((av, ai) => {
......@@ -328,7 +339,6 @@ export function getColumnsDataRealize({
bodyData.push(nowArroy);
});
// 处理合并数据
let dataMerges = [];
mergeKey.forEach((mv, mi) => {
rowSpanData[mv].forEach((cv, ci) => {
if (cv > 1) {
......@@ -345,6 +355,10 @@ export function getColumnsDataRealize({
}
});
});
} catch (err) {
console.table(err);
}
let content = {
sheets: [
......@@ -368,7 +382,7 @@ export function getColumnsDataRealize({
verticalAlignment: 'CENTER', //TOP、CENTER、BOTTOM、JUSTIFY、DISTRIBUTED
wrapText: true,
rowHeights: 20,
colWidths: 200,
colWidths: 250,
},
head: {
font: {
......@@ -381,6 +395,7 @@ export function getColumnsDataRealize({
if (styles) {
content.styles = styles;
}
try {
let getFileData = giveFilePostDataInfoForTrue(
{
content: JSON.stringify(content),
......@@ -398,12 +413,21 @@ export function getColumnsDataRealize({
fileName,
ext,
);
} catch (err) {
console.table(err);
}
}
// ant列表组件合并表格 render属性,合并纵向、横向。
export function renderContentAll(value, row, index, key, spanData, cloumnNames = []) {
let colSpan = spanData.colSpanData[key][index];// 横向合并
let rowSpan = spanData.rowSpanData[key][index];// 纵向合并
let colSpan, rowSpan = null;
try {
colSpan = spanData.colSpanData[key][index];// 横向合并
rowSpan = spanData.rowSpanData[key][index];// 纵向合并
} catch (err) {
console.table(err);
}
const obj = {
children: value,
props: {
......@@ -413,9 +437,24 @@ export function renderContentAll(value, row, index, key, spanData, cloumnNames =
};
return obj;
}
// ant列表组件合并表格 render属性,合并纵向。
export function renderContentRow(value, row, index, key, spanData, cloumnNames = []) {
let rowSpan = spanData.rowSpanData[key][index];// 纵向合并
// ant列表组件合并表格 render属性,合并纵向。 meanwhileKey :key 是本身字段key,value 是同步的字段key
export function renderContentRow(value, row, index, key, spanData, cloumnNames = [], meanwhileKey = {}) {
let colSpan, rowSpan = null;
try {
if (cloumnNames.indexOf(key) !== -1) {
rowSpan = spanData.rowSpanData[key][index];// 纵向合并
} else {
if (key in meanwhileKey && meanwhileKey[key]) {
let meanwhileKeyValue = meanwhileKey[key];
rowSpan = spanData.rowSpanData[meanwhileKeyValue][index];// 同步字段 的纵向合并
} else {
rowSpan = 1;
}
}
} catch (err) {
console.table(err);
}
const obj = {
children: value,
props: {
......@@ -446,8 +485,7 @@ export function getWord({
listConfig = {},
ext = 'docx',
}) {
//可更新的
try {
let getFileData = giveFilePostDataInfoForTrue(
{
templatePath: templatePath,
......@@ -470,6 +508,11 @@ export function getWord({
title,
ext,
);
} catch (err) {
console.table(err);
}
//可更新的
function setObjectKey(data) {
return (
Object.keys(data)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论