提交 4e9d7ac0 authored 作者: yaoxinguo's avatar yaoxinguo

优化通用方法

上级 7707a86e
......@@ -48,8 +48,8 @@ export function giveSmartFormGlobalProps({
"getColumnsDataRealize({data, mergeKey, columns, styles, defect, fileName, ext , eliminateStr})":`下载列表合并的数据;参数-> 前三个必填data, mergeKey, columns`,
"getColumnsSqlKeyRealize({sqlKey, columns, styles, fileName, ext})":`下载列表表头合并的数据;参数->前两个个必填sqlKey, columns`,
"getWord({templatePath,params, title, allValues, listConfig, ext})":`下载文档地址 ;参数->前五个必填 templatePath,params, title, allValues, listConfig`,
"renderContentAll(value, row, index, key, spanData, cloumnNames) ":`ant表头横向、纵向合并 ;参数->所有必填 value, row, index, key, spanData, cloumnNames 实例:render:(value, row, index)=>{return renderContent(value, row, index,"inst_name",spanData,cloumnNames)}`,
"renderContentRow(value, row, index, key, spanData, cloumnNames) ":`ant表头纵向合并 ;参数->所有必填 value, row, index, key, spanData, cloumnNames 实例:render:(value, row, index)=>{return renderContent(value, row, index,"inst_name",spanData,cloumnNames)}`,
"renderContentAll(value, row, index, key, spanData, cloumnNames) ":`ant表头横向、纵向合并 ;参数->所有必填 value, row, index, key, spanData, cloumnNames 实例:render:(value, row, index)=>{return renderContentAll(value, row, index,"inst_name",spanData,cloumnNames)}`,
"renderContentRow(value, row, index, key, spanData, cloumnNames) ":`ant表头纵向合并 ;参数->所有必填 value, row, index, key, spanData, cloumnNames 实例:render:(value, row, index)=>{return renderContentRow(value, row, index,"inst_name",spanData,cloumnNames)}`,
}
},
publicComponent: {
......
import { giveFilePostDataInfoForTrue } from '@/webPublic/one_stop_public/Base16';
import { queryOauthActionPath } from '@/webPublic/one_stop_public/utils/queryConfig';
import { getToken } from '@/webPublic/one_stop_public/utils/token';
export { deepCopy} from '@/webPublic/zyd_public/utils/utils';
const apiUrl = queryOauthActionPath();
/**
......@@ -21,10 +23,12 @@ const apiUrl = queryOauthActionPath();
export function getSpanJson({
mergeKey, data, eliminateRow = [], eliminateCol = []
}) {
try {
try {
let dataList = deepCopy(data);
return {
rowSpanData: getRowSpanJson(mergeKey, data, eliminateRow),
colSpanData: getColSpanJson(mergeKey, data, eliminateCol),
rowSpanData: getRowSpanJson(mergeKey,dataList, eliminateRow),
colSpanData: getColSpanJson(mergeKey, dataList, eliminateCol),
};
} catch (err) {
console.table(err);
......@@ -32,6 +36,7 @@ export function getSpanJson({
}
function getRowSpanJson(cloumnNames, data, eliminateStr = []) {
data = deepCopy(data);
//纵向合并
// 获取列的 dataIndex 集合
var rowSpanJson = {};
......@@ -71,6 +76,7 @@ function getRowSpanJson(cloumnNames, data, eliminateStr = []) {
}
function getColSpanJson(cloumnNames, data, eliminateStr = []) {
data = deepCopy(data);
//横向合并
var colSpanJson = {};
for (let idx = 0; idx < data.length; idx++) {
......@@ -130,6 +136,7 @@ function getColSpanJson(cloumnNames, data, eliminateStr = []) {
* columnsHeight 行数
* */
export function getColumns(columns) {
columns = deepCopy(columns);
const uj = {
t: 1,
......@@ -240,7 +247,10 @@ export function getColumnsSqlKeyRealize({
fileName = '导出文件',
ext = 'xlsx',
}) {
columns = deepCopy(columns);
let { columnsList, columnsMerges, columnsKey } = getColumns(columns);
let content = {
sheets: [
{
......@@ -286,7 +296,7 @@ export function getColumnsSqlKeyRealize({
},
`${apiUrl + '/DataObjApi/exportCustom'}`,
);
let token = getToken();
let token = getToken();
downloadFile(
getFileData.url,
{
......@@ -325,6 +335,8 @@ export function getColumnsDataRealize({
eliminateRow = [],
eliminateCol = [],
}) {
columns = deepCopy(columns);
data = deepCopy(data);
let { columnsList, columnsMerges, columnsKey, columnsHeight } = getColumns(columns);
let { colSpanData, rowSpanData } = getSpanJson({ mergeKey, data, eliminateRow, eliminateCol });
// 处理数据
......@@ -411,7 +423,7 @@ export function getColumnsDataRealize({
},
`${apiUrl + '/DataObjApi/exportCustom'}`,
);
let token = localStorage.getItem('antd-pro-token-onestop');
let token = getToken();
downloadFile(
getFileData.url,
{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论