提交 4134e410 authored 作者: 姚鑫国's avatar 姚鑫国

优化 upObjKey

上级 8ba4e9ea
......@@ -727,7 +727,7 @@ export function upObjKey(obj, setKey = {}) {
if (objType === "[object Object]" && Object.keys(obj).length > 0) {
for (var e in setKey) {
let upKey = setKey[e];
let { newKey, type, timeFormat } = getSetKeyValue(upKey);
let { newKey = e, type, timeFormat } = getSetKeyValue(upKey);
obj = getSetKeyJson({
obj, e, newKey, type, timeFormat
});
......@@ -737,7 +737,7 @@ export function upObjKey(obj, setKey = {}) {
obj.forEach((v, i, arr) => {
for (var e in setKey) {
let upKey = setKey[e];
let { newKey, type, timeFormat } = getSetKeyValue(upKey);
let { newKey = e, type, timeFormat } = getSetKeyValue(upKey);
arr[i] = getSetKeyJson({
obj: v, e, newKey, type, timeFormat
});
......@@ -779,15 +779,15 @@ function getSetKeyValue(value) {
function getSetKeyJson({
obj, e, newKey, type, timeFormat
}) {
let value = obj[e];
delete obj[e];
switch (type) {
case "time":
debugger
obj[newKey] = timeFormat && obj[e] ? moment(obj[e]).format(timeFormat) : obj[e] || "";
obj[newKey] = timeFormat && value ? moment(value).format(timeFormat) : value || "";
break;
default:
obj[newKey] = obj[e] || "";
}
delete obj[e];
return obj;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论