Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
df7cd9cf
提交
df7cd9cf
authored
10月 12, 2022
作者:
姚鑫国
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upObjKey 函数优化
上级
e3fa9942
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
85 行增加
和
71 行删除
+85
-71
globalFunction.js
one_stop_public/Table/globalFunction.js
+85
-71
没有找到文件。
one_stop_public/Table/globalFunction.js
浏览文件 @
df7cd9cf
...
...
@@ -32,16 +32,16 @@ export function getSpanJson({
})
{
const
dataList
=
deepCopy
(
data
);
let
rowSpanData
,
colSpanData
=
null
;
let
rowSpanData
,
colSpanData
=
null
;
try
{
rowSpanData
=
getRowSpanJson
(
mergeKey
,
dataList
,
eliminateRow
);
}
catch
(
err
)
{
console
.
table
(
"rowSpanData"
,
err
);
console
.
table
(
"rowSpanData"
,
err
);
}
try
{
colSpanData
=
getColSpanJson
(
mergeKey
,
dataList
,
eliminateCol
);
}
catch
(
err
)
{
console
.
table
(
"colSpanData"
,
err
);
console
.
table
(
"colSpanData"
,
err
);
}
return
{
rowSpanData
,
...
...
@@ -191,30 +191,30 @@ export function getColumns(columns) {
}
return
res
;
}
catch
(
e
)
{
console
.
table
(
"getColumnsData"
,
e
);
console
.
table
(
"getColumnsData"
,
e
);
return
false
;
}
}
//递归行数
function
getColumnsMaxLevel
(
arr
=
[]
)
{
//递归计算树形数据最大的层级数
let
maxLevel
=
0
;
(
function
multiArr
(
arr
,
level
=
0
)
{
++
level
;
maxLevel
=
Math
.
max
(
level
,
maxLevel
);
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
let
item
=
arr
[
i
];
item
.
level
=
level
;
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
multiArr
(
item
.
children
,
level
);
}
else
{
delete
item
.
children
;
}
}
})(
arr
,
0
);
return
maxLevel
;
}
function
getColumnsMaxLevel
(
arr
=
[])
{
//递归计算树形数据最大的层级数
let
maxLevel
=
0
;
(
function
multiArr
(
arr
,
level
=
0
)
{
++
level
;
maxLevel
=
Math
.
max
(
level
,
maxLevel
);
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
let
item
=
arr
[
i
];
item
.
level
=
level
;
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
multiArr
(
item
.
children
,
level
);
}
else
{
delete
item
.
children
;
}
}
})(
arr
,
0
);
return
maxLevel
;
}
//递归当前数据宽度
...
...
@@ -343,7 +343,7 @@ export function getColumnsSqlKeyRealize({
ext
,
);
}
catch
(
err
)
{
console
.
table
(
"getColumnsSqlKeyRealize"
,
err
);
console
.
table
(
"getColumnsSqlKeyRealize"
,
err
);
}
}
...
...
@@ -427,7 +427,7 @@ export function getColumnsDataRealize({
});
});
}
catch
(
err
)
{
console
.
table
(
"getColumnsDataRealize"
,
err
);
console
.
table
(
"getColumnsDataRealize"
,
err
);
}
...
...
@@ -485,7 +485,7 @@ export function getColumnsDataRealize({
ext
,
);
}
catch
(
err
)
{
console
.
table
(
"getColumnsDataRealize"
,
err
);
console
.
table
(
"getColumnsDataRealize"
,
err
);
}
}
...
...
@@ -498,7 +498,7 @@ export function renderContentAll(value, row, index, key, spanData, cloumnNames =
colSpan
=
spanData
.
colSpanData
[
key
][
index
];
// 横向合并
rowSpan
=
spanData
.
rowSpanData
[
key
][
index
];
// 纵向合并
}
catch
(
err
)
{
console
.
table
(
"renderContentAll"
,
err
);
console
.
table
(
"renderContentAll"
,
err
);
}
const
obj
=
{
children
:
value
,
...
...
@@ -526,7 +526,7 @@ export function renderContentRow(value, row, index, key, spanData, cloumnNames =
}
}
}
catch
(
err
)
{
console
.
table
(
"renderContentRow"
,
err
);
console
.
table
(
"renderContentRow"
,
err
);
}
const
obj
=
{
children
:
value
,
...
...
@@ -662,12 +662,12 @@ export function getListWord({
paramsList
.
forEach
((
v
,
i
)
=>
{
let
files
=
[];
let
paramsObj
=
deepCopy
(
v
);
for
(
var
ki
in
filesKey
)
{
for
(
var
ki
in
filesKey
)
{
let
files_
=
v
[
filesKey
[
ki
]];
try
{
files
=
[...
files
,
...
JSON
.
parse
(
files_
).
files
]
}
catch
(
e
)
{
}
delete
paramsObj
[
filesKey
[
ki
]];
}
...
...
@@ -680,7 +680,7 @@ export function getListWord({
...
getObjectsKey
(
allValuesKey
,
paramsObj
)
},
title
:
(
paramsObj
[
sonTitleKey
]
||
"未设置名称"
)
+
`.
${
sonExt
}
`
,
files
:
JSON
.
stringify
(
files
)
files
:
JSON
.
stringify
(
files
)
});
});
let
getFileData
=
giveFilePostDataInfoForTrue
(
...
...
@@ -740,79 +740,93 @@ function setObjectKey(data) {
* @param {*} setKey {"被修改的key":"修改后的key"}
* @returns
*/
export
function
upObjKey
(
obj
,
setKey
=
{},
defaultValue
=
""
)
{
export
function
upObjKey
(
obj
,
setKey
=
{},
defaultValue
=
""
)
{
try
{
obj
=
deepCopy
(
obj
);
setKey
=
deepCopy
(
setKey
);
let
objType
=
Object
.
prototype
.
toString
.
call
(
obj
);
if
(
obj
&&
(
objType
.
indexOf
(
"Array"
)
>
-
1
||
objType
.
indexOf
(
"Object"
)
>
-
1
)
&&
Object
.
keys
(
setKey
).
length
>
0
)
{
if
(
objType
===
"[object Object]"
&&
Object
.
keys
(
obj
).
length
>
0
)
{
for
(
var
e
in
setKey
)
{
let
upKey
=
setKey
[
e
];
let
{
newKey
=
e
,
type
,
timeFormat
}
=
getSetKeyValue
(
upKey
);
obj
=
getSetKeyJson
({
obj
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
});
}
}
if
(
objType
===
"[object Array]"
&&
obj
.
length
>
0
)
{
obj
.
forEach
((
v
,
i
,
arr
)
=>
{
for
(
var
e
in
setKey
)
{
let
upKey
=
setKey
[
e
];
let
{
newKey
=
e
,
type
,
timeFormat
}
=
getSetKeyValue
(
upKey
);
arr
[
i
]
=
getSetKeyJson
({
obj
:
v
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
});
}
let
nowObj
=
null
;
if
(
objType
===
"[object Object]"
&&
!
Array
.
isArray
(
obj
)
&&
Object
.
keys
(
obj
).
length
>
0
)
{
nowObj
=
deepCopy
(
obj
);
for
(
var
e
in
setKey
)
{
let
upKey
=
setKey
[
e
];
let
{
newKey
=
e
,
type
,
timeFormat
}
=
getSetKeyValue
(
upKey
);
nowObj
=
{
...
nowObj
,
...
getSetKeyJson
({
obj
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
})
};
delete
nowObj
[
e
];
}
return
obj
;
}
if
(
objType
===
"[object Array]"
&&
Array
.
isArray
(
obj
)
&&
obj
.
length
>
0
)
{
nowObj
=
new
Array
();
obj
.
forEach
((
v
,
i
,
arr
)
=>
{
let
newJson
=
deepCopy
(
v
);
for
(
var
e
in
setKey
)
{
let
upKey
=
setKey
[
e
];
let
{
newKey
=
e
,
type
,
timeFormat
}
=
getSetKeyValue
(
upKey
);
newJson
=
{
...
newJson
,
...
getSetKeyJson
({
obj
:
v
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
})
};
delete
newJson
[
e
];
}
nowObj
.
push
(
newJson
);
})
}
return
nowObj
;
}
else
{
return
null
;
return
null
;
}
}
catch
(
error
)
{
console
.
log
(
"upObjKey"
,
error
);
console
.
log
(
"upObjKey"
,
error
);
return
undefined
;
}
}
function
getSetKeyValue
(
value
)
{
let
valeuType
=
Object
.
prototype
.
toString
.
call
(
value
);
let
newName
=
null
;
let
extendJson
=
{
"type"
:
"string"
"type"
:
"string"
};
if
(
valeuType
===
"[object String]"
)
{
newName
=
value
;
newName
=
value
;
}
if
(
valeuType
===
"[object Object]"
)
{
newName
=
value
[
"new"
];
delete
value
[
"new"
];
extendJson
=
{
...
extendJson
,
...
value
};
newName
=
value
[
"new"
];
delete
value
[
"new"
];
extendJson
=
{
...
extendJson
,
...
value
};
}
return
{
newKey
:
newName
,
...
extendJson
newKey
:
newName
,
...
extendJson
}
}
function
getSetKeyJson
({
obj
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
obj
,
e
,
newKey
,
type
,
timeFormat
=
"YYYY-MM-DD HH:mm:ss"
,
defaultValue
})
{
obj
=
deepCopy
(
obj
);
let
value
=
obj
[
e
];
delete
obj
[
e
];
let
newKeyObj
=
{};
// delete obj[e];
switch
(
type
)
{
case
"time"
:
o
bj
[
newKey
]
=
(
timeFormat
&&
value
?
moment
(
value
).
format
(
timeFormat
)
:
value
)
||
defaultValue
;
break
;
default
:
o
bj
[
newKey
]
=
value
||
defaultValue
;
case
"time"
:
newKeyO
bj
[
newKey
]
=
(
timeFormat
&&
value
?
moment
(
value
).
format
(
timeFormat
)
:
value
)
||
defaultValue
;
break
;
default
:
newKeyO
bj
[
newKey
]
=
value
||
defaultValue
;
}
return
o
bj
;
return
newKeyO
bj
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论