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

优化 upObjKey

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