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 个修改的文件
包含
43 行增加
和
29 行删除
+43
-29
globalFunction.js
one_stop_public/Table/globalFunction.js
+43
-29
没有找到文件。
one_stop_public/Table/globalFunction.js
浏览文件 @
df7cd9cf
...
@@ -32,16 +32,16 @@ export function getSpanJson({
...
@@ -32,16 +32,16 @@ export function getSpanJson({
})
{
})
{
const
dataList
=
deepCopy
(
data
);
const
dataList
=
deepCopy
(
data
);
let
rowSpanData
,
colSpanData
=
null
;
let
rowSpanData
,
colSpanData
=
null
;
try
{
try
{
rowSpanData
=
getRowSpanJson
(
mergeKey
,
dataList
,
eliminateRow
);
rowSpanData
=
getRowSpanJson
(
mergeKey
,
dataList
,
eliminateRow
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
table
(
"rowSpanData"
,
err
);
console
.
table
(
"rowSpanData"
,
err
);
}
}
try
{
try
{
colSpanData
=
getColSpanJson
(
mergeKey
,
dataList
,
eliminateCol
);
colSpanData
=
getColSpanJson
(
mergeKey
,
dataList
,
eliminateCol
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
table
(
"colSpanData"
,
err
);
console
.
table
(
"colSpanData"
,
err
);
}
}
return
{
return
{
rowSpanData
,
rowSpanData
,
...
@@ -191,16 +191,16 @@ export function getColumns(columns) {
...
@@ -191,16 +191,16 @@ export function getColumns(columns) {
}
}
return
res
;
return
res
;
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
table
(
"getColumnsData"
,
e
);
console
.
table
(
"getColumnsData"
,
e
);
return
false
;
return
false
;
}
}
}
}
//递归行数
//递归行数
function
getColumnsMaxLevel
(
arr
=
[]
)
{
function
getColumnsMaxLevel
(
arr
=
[])
{
//递归计算树形数据最大的层级数
//递归计算树形数据最大的层级数
let
maxLevel
=
0
;
let
maxLevel
=
0
;
(
function
multiArr
(
arr
,
level
=
0
)
{
(
function
multiArr
(
arr
,
level
=
0
)
{
++
level
;
++
level
;
maxLevel
=
Math
.
max
(
level
,
maxLevel
);
maxLevel
=
Math
.
max
(
level
,
maxLevel
);
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
...
@@ -343,7 +343,7 @@ export function getColumnsSqlKeyRealize({
...
@@ -343,7 +343,7 @@ export function getColumnsSqlKeyRealize({
ext
,
ext
,
);
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
table
(
"getColumnsSqlKeyRealize"
,
err
);
console
.
table
(
"getColumnsSqlKeyRealize"
,
err
);
}
}
}
}
...
@@ -427,7 +427,7 @@ export function getColumnsDataRealize({
...
@@ -427,7 +427,7 @@ export function getColumnsDataRealize({
});
});
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
table
(
"getColumnsDataRealize"
,
err
);
console
.
table
(
"getColumnsDataRealize"
,
err
);
}
}
...
@@ -485,7 +485,7 @@ export function getColumnsDataRealize({
...
@@ -485,7 +485,7 @@ export function getColumnsDataRealize({
ext
,
ext
,
);
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
table
(
"getColumnsDataRealize"
,
err
);
console
.
table
(
"getColumnsDataRealize"
,
err
);
}
}
}
}
...
@@ -498,7 +498,7 @@ export function renderContentAll(value, row, index, key, spanData, cloumnNames =
...
@@ -498,7 +498,7 @@ export function renderContentAll(value, row, index, key, spanData, cloumnNames =
colSpan
=
spanData
.
colSpanData
[
key
][
index
];
// 横向合并
colSpan
=
spanData
.
colSpanData
[
key
][
index
];
// 横向合并
rowSpan
=
spanData
.
rowSpanData
[
key
][
index
];
// 纵向合并
rowSpan
=
spanData
.
rowSpanData
[
key
][
index
];
// 纵向合并
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
table
(
"renderContentAll"
,
err
);
console
.
table
(
"renderContentAll"
,
err
);
}
}
const
obj
=
{
const
obj
=
{
children
:
value
,
children
:
value
,
...
@@ -526,7 +526,7 @@ export function renderContentRow(value, row, index, key, spanData, cloumnNames =
...
@@ -526,7 +526,7 @@ export function renderContentRow(value, row, index, key, spanData, cloumnNames =
}
}
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
table
(
"renderContentRow"
,
err
);
console
.
table
(
"renderContentRow"
,
err
);
}
}
const
obj
=
{
const
obj
=
{
children
:
value
,
children
:
value
,
...
@@ -662,7 +662,7 @@ export function getListWord({
...
@@ -662,7 +662,7 @@ export function getListWord({
paramsList
.
forEach
((
v
,
i
)
=>
{
paramsList
.
forEach
((
v
,
i
)
=>
{
let
files
=
[];
let
files
=
[];
let
paramsObj
=
deepCopy
(
v
);
let
paramsObj
=
deepCopy
(
v
);
for
(
var
ki
in
filesKey
)
{
for
(
var
ki
in
filesKey
)
{
let
files_
=
v
[
filesKey
[
ki
]];
let
files_
=
v
[
filesKey
[
ki
]];
try
{
try
{
files
=
[...
files
,
...
JSON
.
parse
(
files_
).
files
]
files
=
[...
files
,
...
JSON
.
parse
(
files_
).
files
]
...
@@ -680,7 +680,7 @@ export function getListWord({
...
@@ -680,7 +680,7 @@ export function getListWord({
...
getObjectsKey
(
allValuesKey
,
paramsObj
)
...
getObjectsKey
(
allValuesKey
,
paramsObj
)
},
},
title
:
(
paramsObj
[
sonTitleKey
]
||
"未设置名称"
)
+
`.
${
sonExt
}
`
,
title
:
(
paramsObj
[
sonTitleKey
]
||
"未设置名称"
)
+
`.
${
sonExt
}
`
,
files
:
JSON
.
stringify
(
files
)
files
:
JSON
.
stringify
(
files
)
});
});
});
});
let
getFileData
=
giveFilePostDataInfoForTrue
(
let
getFileData
=
giveFilePostDataInfoForTrue
(
...
@@ -740,38 +740,51 @@ function setObjectKey(data) {
...
@@ -740,38 +740,51 @@ function setObjectKey(data) {
* @param {*} setKey {"被修改的key":"修改后的key"}
* @param {*} setKey {"被修改的key":"修改后的key"}
* @returns
* @returns
*/
*/
export
function
upObjKey
(
obj
,
setKey
=
{},
defaultValue
=
""
)
{
export
function
upObjKey
(
obj
,
setKey
=
{},
defaultValue
=
""
)
{
try
{
try
{
obj
=
deepCopy
(
obj
);
obj
=
deepCopy
(
obj
);
setKey
=
deepCopy
(
setKey
);
setKey
=
deepCopy
(
setKey
);
let
objType
=
Object
.
prototype
.
toString
.
call
(
obj
);
let
objType
=
Object
.
prototype
.
toString
.
call
(
obj
);
if
(
obj
&&
(
objType
.
indexOf
(
"Array"
)
>
-
1
||
objType
.
indexOf
(
"Object"
)
>
-
1
)
&&
Object
.
keys
(
setKey
).
length
>
0
)
{
if
(
obj
&&
(
objType
.
indexOf
(
"Array"
)
>
-
1
||
objType
.
indexOf
(
"Object"
)
>
-
1
)
&&
Object
.
keys
(
setKey
).
length
>
0
)
{
if
(
objType
===
"[object Object]"
&&
Object
.
keys
(
obj
).
length
>
0
)
{
let
nowObj
=
null
;
if
(
objType
===
"[object Object]"
&&
!
Array
.
isArray
(
obj
)
&&
Object
.
keys
(
obj
).
length
>
0
)
{
nowObj
=
deepCopy
(
obj
);
for
(
var
e
in
setKey
)
{
for
(
var
e
in
setKey
)
{
let
upKey
=
setKey
[
e
];
let
upKey
=
setKey
[
e
];
let
{
newKey
=
e
,
type
,
timeFormat
}
=
getSetKeyValue
(
upKey
);
let
{
newKey
=
e
,
type
,
timeFormat
}
=
getSetKeyValue
(
upKey
);
obj
=
getSetKeyJson
({
nowObj
=
{
obj
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
...
nowObj
,
});
...
getSetKeyJson
({
obj
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
})
};
delete
nowObj
[
e
];
}
}
}
}
if
(
objType
===
"[object Array]"
&&
obj
.
length
>
0
)
{
if
(
objType
===
"[object Array]"
&&
Array
.
isArray
(
obj
)
&&
obj
.
length
>
0
)
{
nowObj
=
new
Array
();
obj
.
forEach
((
v
,
i
,
arr
)
=>
{
obj
.
forEach
((
v
,
i
,
arr
)
=>
{
let
newJson
=
deepCopy
(
v
);
for
(
var
e
in
setKey
)
{
for
(
var
e
in
setKey
)
{
let
upKey
=
setKey
[
e
];
let
upKey
=
setKey
[
e
];
let
{
newKey
=
e
,
type
,
timeFormat
}
=
getSetKeyValue
(
upKey
);
let
{
newKey
=
e
,
type
,
timeFormat
}
=
getSetKeyValue
(
upKey
);
arr
[
i
]
=
getSetKeyJson
({
newJson
=
{
obj
:
v
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
...
newJson
,
});
...
getSetKeyJson
({
obj
:
v
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
})
};
delete
newJson
[
e
];
}
}
nowObj
.
push
(
newJson
);
})
})
}
}
return
o
bj
;
return
nowO
bj
;
}
else
{
}
else
{
return
null
;
return
null
;
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
"upObjKey"
,
error
);
console
.
log
(
"upObjKey"
,
error
);
return
undefined
;
return
undefined
;
}
}
}
}
...
@@ -800,19 +813,20 @@ function getSetKeyValue(value) {
...
@@ -800,19 +813,20 @@ function getSetKeyValue(value) {
}
}
function
getSetKeyJson
({
function
getSetKeyJson
({
obj
,
e
,
newKey
,
type
,
timeFormat
,
defaultValue
obj
,
e
,
newKey
,
type
,
timeFormat
=
"YYYY-MM-DD HH:mm:ss"
,
defaultValue
})
{
})
{
obj
=
deepCopy
(
obj
);
obj
=
deepCopy
(
obj
);
let
value
=
obj
[
e
];
let
value
=
obj
[
e
];
delete
obj
[
e
];
let
newKeyObj
=
{};
// delete obj[e];
switch
(
type
)
{
switch
(
type
)
{
case
"time"
:
case
"time"
:
o
bj
[
newKey
]
=
(
timeFormat
&&
value
?
moment
(
value
).
format
(
timeFormat
)
:
value
)
||
defaultValue
;
newKeyO
bj
[
newKey
]
=
(
timeFormat
&&
value
?
moment
(
value
).
format
(
timeFormat
)
:
value
)
||
defaultValue
;
break
;
break
;
default
:
default
:
o
bj
[
newKey
]
=
value
||
defaultValue
;
newKeyO
bj
[
newKey
]
=
value
||
defaultValue
;
}
}
return
o
bj
;
return
newKeyO
bj
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论