Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-gjjs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhouqian
vue-gjjs
Commits
2f40df9c
Commit
2f40df9c
authored
Jul 14, 2020
by
fukai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交object加工处理
parent
c2174da3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
0 deletions
+95
-0
index.js
src/utils/index.js
+69
-0
vuefunc.js
src/utils/vuefunc.js
+26
-0
index.vue
src/views/Business/Sptsel/index.vue
+0
-0
No files found.
src/utils/index.js
0 → 100644
View file @
2f40df9c
export
default
class
Utils
{
static
toDepthObject
(
obj
)
{
var
target
=
{};
for
(
var
key
in
obj
)
{
var
keyArr
=
key
.
split
(
"_"
);
//以下划线或分割
var
tempobj
=
target
;
for
(
var
i
=
0
;
i
<
keyArr
.
length
-
1
;
i
++
)
{
if
(
tempobj
[
keyArr
[
i
]])
tempobj
=
tempobj
[
keyArr
[
i
]];
else
{
tempobj
[
keyArr
[
i
]]
=
{};
tempobj
=
tempobj
[
keyArr
[
i
]];
}
}
//给叶子元素赋值
tempobj
[
keyArr
[
keyArr
.
length
-
1
]]
=
obj
[
key
];
}
return
target
;
}
static
flatObject
(
obj
,
target
,
pkey
)
{
target
=
target
||
{};
for
(
var
key
in
obj
)
{
var
nkey
=
pkey
?
pkey
+
"_"
+
key
:
key
;
if
(
!
obj
[
key
])
target
[
nkey
]
=
obj
[
key
];
else
if
(
obj
[
key
]
instanceof
Array
)
target
[
nkey
]
=
obj
[
key
];
else
if
(
typeof
obj
[
key
]
==
"object"
)
Utils
.
flatObject
(
obj
[
key
],
target
,
nkey
);
//递归赋值
else
target
[
nkey
]
=
obj
[
key
];
}
return
target
;
}
static
copyValueFromVO
(
model
,
vo
)
{
var
target
=
model
;
for
(
var
key
in
vo
)
{
var
keyArr
=
key
.
split
(
"_"
);
//以下划线或分割
var
tempobj
=
target
;
for
(
var
i
=
0
;
i
<
keyArr
.
length
-
1
;
i
++
)
{
if
(
tempobj
[
keyArr
[
i
]])
tempobj
=
tempobj
[
keyArr
[
i
]];
else
{
tempobj
=
null
;
break
;
}
}
//给叶子元素赋值
if
(
tempobj
)
{
let
leafProp
=
keyArr
[
keyArr
.
length
-
1
];
if
(
tempobj
.
hasOwnProperty
(
leafProp
))
tempobj
[
leafProp
]
=
obj
[
key
];
}
}
return
target
;
}
}
\ No newline at end of file
src/utils/vuefunc.js
View file @
2f40df9c
...
...
@@ -9,8 +9,34 @@ export function findCodeLabel(codes,val)
return
item
.
label
}
export
function
dateFormat
(
date
,
format
)
{
let
_format
=
format
||
'yyyy-MM-dd'
;
const
d
=
date
;
const
o
=
{
'M+'
:
d
.
getMonth
()
+
1
,
// month
'd+'
:
d
.
getDate
(),
// day
'h+'
:
d
.
getHours
(),
// hour
'm+'
:
d
.
getMinutes
(),
// minute
's+'
:
d
.
getSeconds
(),
// second
'q+'
:
Math
.
floor
((
d
.
getMonth
()
+
3
)
/
3
),
// quarter
'S'
:
d
.
getMilliseconds
()
// millisecond
};
if
(
/
(
y+
)
/
.
test
(
_format
))
{
_format
=
_format
.
replace
(
RegExp
.
$1
,
(
d
.
getFullYear
()
+
''
).
substr
(
4
-
RegExp
.
$1
.
length
));
}
for
(
const
k
in
o
)
{
if
(
o
.
hasOwnProperty
(
k
)
&&
new
RegExp
(
'('
+
k
+
')'
).
test
(
_format
))
{
_format
=
_format
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
===
1
?
o
[
k
]
:
(
'00'
+
o
[
k
]).
substr
((
''
+
o
[
k
]).
length
));
}
}
return
_format
;
}
export
default
{
install
(
Vue
){
Vue
.
prototype
.
findCodeLabel
=
findCodeLabel
Vue
.
prototype
.
dateFormat
=
dateFormat
}
}
src/views/Business/Sptsel/index.vue
View file @
2f40df9c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment