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

优化通用方法

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