明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jt_backend
Project
Project
Details
Activity
Releases
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
zengfanpei
jt_backend
Commits
6d2514b4
Commit
6d2514b4
authored
Dec 03, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Plain Diff
update
parents
803b3e13
8674e6c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
11 deletions
+66
-11
a.js
a.js
+24
-1
projectController.js
controller/projectController.js
+4
-3
projectModule.js
module/projectModule.js
+38
-7
No files found.
a.js
View file @
6d2514b4
...
...
@@ -136,4 +136,27 @@ console.log(flattenTree(complexForest, 'xh', 'parentXh'));
// ], 'xh', 'parentXh')))
// [{ "xh": "1", "zb": "项目资本金", "dw": "万元", "parentXh": null, "children": [{ "xh": "1.1", "zb": "能建方出资", "dw": "万元", "parentXh": "1", "children": [] }, { "xh": "1.2", "zb": "外部股东", "dw": "万元", "parentXh": "1", "children": [] }] }, { "xh": "2", "zb": "贷款", "dw": "万元", "parentXh": null, "children": [{ "xh": "2.1", "zb": "其中:并非表项目我方贷款/投保额", "dw": "万元", "parentXh": "2", "children": [] }] }, { "xh": "3", "zb": "其他出资", "dw": "万元", "parentXh": null, "children": [{ "xh": "3.1", "zb": "其中:能建方出资", "dw": "万元", "parentXh": "3", "children": [] }] }, { "xh": "", "zb": "批复总出资", "dw": "万元", "parentXh": null, "children": [] }]
\ No newline at end of file
// [{ "xh": "1", "zb": "项目资本金", "dw": "万元", "parentXh": null, "children": [{ "xh": "1.1", "zb": "能建方出资", "dw": "万元", "parentXh": "1", "children": [] }, { "xh": "1.2", "zb": "外部股东", "dw": "万元", "parentXh": "1", "children": [] }] }, { "xh": "2", "zb": "贷款", "dw": "万元", "parentXh": null, "children": [{ "xh": "2.1", "zb": "其中:并非表项目我方贷款/投保额", "dw": "万元", "parentXh": "2", "children": [] }] }, { "xh": "3", "zb": "其他出资", "dw": "万元", "parentXh": null, "children": [{ "xh": "3.1", "zb": "其中:能建方出资", "dw": "万元", "parentXh": "3", "children": [] }] }, { "xh": "", "zb": "批复总出资", "dw": "万元", "parentXh": null, "children": [] }]
function
disTree
(
tree
)
{
let
parallel
=
[];
function
addToParallel
(
nodes
)
{
nodes
.
forEach
(
node
=>
{
parallel
.
push
({
...
node
,
children
:
undefined
});
if
(
node
.
children
&&
node
.
children
.
length
)
{
addToParallel
(
node
.
children
);
}
});
}
addToParallel
(
tree
)
return
parallel
}
console
.
log
(
disTree
(
[
1
,
2
,
3
]))
\ No newline at end of file
controller/projectController.js
View file @
6d2514b4
...
...
@@ -678,8 +678,10 @@ async function getOwnProjects(req, res, next) {
//
let
cArr
=
[
{
projectCreator
:
req
.
user
.
id
},
{
id
:
{
[
Op
.
in
]:
projectIds
}
}
]
if
(
projectIds
.
length
>
0
)
{
cArr
.
push
({
id
:
{
[
Op
.
in
]:
projectIds
}
})
}
if
(
req
.
body
.
projectName
)
{
cArr
.
push
({
projectName
:
{
[
Op
.
like
]:
`%
${
req
.
body
.
projectName
}
%`
}
});
}
...
...
@@ -693,8 +695,7 @@ async function getOwnProjects(req, res, next) {
if
(
req
.
body
.
attributes
&&
req
.
body
.
attributes
.
length
)
{
search
.
attributes
=
req
.
body
.
attributes
;
}
search
.
raw
=
true
;
console
.
log
(
search
,
"-=="
)
console
.
log
(
JSON
.
stringify
(
search
),
"-=="
)
let
ret
=
await
DB
.
Project
.
findAndCountAll
(
search
);
let
lastRet
=
await
projectModule
.
handleProjectData
(
ret
,
search
.
attributes
);
return
res
.
sendData
(
lastRet
);
...
...
module/projectModule.js
View file @
6d2514b4
...
...
@@ -14,21 +14,52 @@ const projectModule = require('../module/projectModule');
async
function
handleProjectData
(
ret
,
queryAttrs
)
{
let
rawAttributes
=
DB
.
Project
.
rawAttributes
;
let
rawAttributes
=
_
.
cloneDeep
(
DB
.
Project
.
rawAttributes
)
;
console
.
log
(
rawAttributes
,
"===="
)
let
queryRawAtr
=
[],
resourceKeys
=
[];
let
queryRawAtr
=
[],
resourceKeys
=
[];
for
(
let
index
=
0
;
index
<
queryAttrs
.
length
;
index
++
)
{
const
element
=
queryAttrs
[
index
];
if
(
rawAttributes
[
element
])
{
if
(
rawAttributes
[
element
])
{
queryRawAtr
.
push
(
rawAttributes
[
element
]);
//查询得所有字段
if
([
'danxuan'
].
includes
(
rawAttributes
[
element
]
&&
rawAttributes
[
element
].
zjType
))
{
//其中需要处理的资源库字段,单选、
if
([
'danxuan'
].
includes
(
rawAttributes
[
element
]
&&
rawAttributes
[
element
].
zjType
))
{
//其中需要处理的资源库字段,单选、
resourceKeys
.
push
(
element
);
}
}
}
console
.
log
(
resourceKeys
);
let
groupAttr
=
_
.
groupBy
(
queryRawAtr
,
'zjType'
);
return
groupAttr
;
let
resources
=
await
getResourceByKeys
(
resourceKeys
);
console
.
log
(
resources
);
// let groupAttr = _.groupBy(queryRawAtr, 'zjType');
//获取对应得资源库说明
return
resources
;
}
async
function
getResourceByKeys
(
keys
)
{
if
(
!
(
keys
&&
keys
.
length
))
{
return
{};
}
let
ret
=
await
DB
.
Resources
.
findAll
({
where
:
{
key
:
{
[
Op
.
in
]:
keys
}
,
del
:
0
},
include
:
[
{
model
:
DB
.
ResourcesInfo
,
as
:
'resourcesInfos'
,
}
]
});
let
obj
=
{};
for
(
let
index
=
0
;
index
<
ret
.
length
;
index
++
)
{
const
element
=
ret
[
index
];
element
.
resourcesInfos
=
element
.
resourcesInfos
||
[];
let
oobj
=
{};
for
(
let
i
=
0
;
i
<
element
.
resourcesInfos
.
length
;
i
++
)
{
const
e
=
element
.
resourcesInfos
[
i
];
oobj
[
e
.
key
]
=
e
.
value
;
}
obj
[
element
.
key
]
=
oobj
;
}
return
obj
;
}
...
...
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