Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
f32ece3b
Commit
f32ece3b
authored
Jun 04, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
aee8f573
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
17 deletions
+82
-17
center-manage/app/base/controller/impl/common/treearchCtl.js
+6
-0
center-manage/app/base/service/impl/common/treearchSve.js
+76
-17
No files found.
center-manage/app/base/controller/impl/common/treearchCtl.js
View file @
f32ece3b
...
...
@@ -4,6 +4,12 @@ class TreearchCtl extends CtlBase {
constructor
()
{
super
(
"common"
,
CtlBase
.
getServiceName
(
TreearchCtl
));
}
async
getTreeArchByCode
(
p
,
q
,
req
){
let
code
=
p
.
code
;
let
archName
=
p
.
archName
;
let
rtn
=
await
this
.
service
.
getTreeArchByCode
(
archName
,
code
)
return
system
.
getResult
(
rtn
)
}
async
getRegions
(
p
,
q
,
req
){
let
regionjson
=
await
this
.
service
.
getRegions
();
return
system
.
getResult
({
regionJson
:
regionjson
})
...
...
center-manage/app/base/service/impl/common/treearchSve.js
View file @
f32ece3b
...
...
@@ -4,29 +4,88 @@ class TreeArchService extends ServiceBase {
constructor
()
{
super
(
"common"
,
ServiceBase
.
getDaoName
(
TreeArchService
));
}
async
getRegions
(){
let
rs
=
await
this
.
dao
.
model
.
findAll
({
attributes
:[
'regionJSON'
]
})
async
getRegions
()
{
let
rs
=
await
this
.
dao
.
model
.
findAll
({
attributes
:
[
'regionJSON'
]
})
return
JSON
.
parse
(
rs
[
0
].
regionJSON
)
}
async
saveRegions
(
regionJson
){
let
rs
=
await
this
.
dao
.
model
.
findAll
()
let
upobj
=
rs
[
0
]
upobj
.
regionJSON
=
JSON
.
stringify
(
regionJson
)
async
saveRegions
(
regionJson
)
{
let
rs
=
await
this
.
dao
.
model
.
findAll
()
let
upobj
=
rs
[
0
]
upobj
.
regionJSON
=
JSON
.
stringify
(
regionJson
)
upobj
.
save
()
return
regionJson
}
async
getProductcats
(){
let
rs
=
await
this
.
dao
.
model
.
findAll
({
attributes
:[
'productcatJSON'
]
})
async
getProductcats
()
{
let
rs
=
await
this
.
dao
.
model
.
findAll
({
attributes
:
[
'productcatJSON'
]
})
return
JSON
.
parse
(
rs
[
0
].
productcatJSON
)
}
async
saveProductcats
(
productcatJson
){
let
rs
=
await
this
.
dao
.
model
.
findAll
()
let
upobj
=
rs
[
0
]
upobj
.
productcatJSON
=
JSON
.
stringify
(
productcatJson
)
upobj
.
save
()
return
productcatJson
}
}
async
saveProductcats
(
productcatJson
)
{
let
rs
=
await
this
.
dao
.
model
.
findAll
()
let
upobj
=
rs
[
0
]
upobj
.
productcatJSON
=
JSON
.
stringify
(
productcatJson
)
upobj
.
save
()
return
productcatJson
}
// async itetree(jsontree, level, results) {
// jsontree.forEach(item => {
// if (item.level < level) {
// let cloneobj = { ...item }
// if (results) {
// results.push(cloneobj)
// }
// if (item.children) {
// cloneobj.children = []
// itetree(item.children, level, cloneobj.children)
// }
// } else {
// if (results) {
// results.push(cloneobj)
// }
// }
// })
// }
findNodeByCode
(
jsontree
,
code
,
results
)
{
jsontree
.
forEach
(
item
=>
{
if
(
item
.
code
==
code
)
{
if
(
item
.
children
)
{
item
.
children
.
forEach
(
c
=>
{
let
tmp
=
{
...
c
}
tmp
.
loading
=
false
if
(
tmp
.
children
)
{
tmp
.
children
=
[]
}
results
.
push
(
tmp
)
})
//this.findNodeByCode(item.children, code, results)
}
}
else
{
if
(
item
.
children
){
this
.
findNodeByCode
(
item
.
children
,
code
,
results
)
}
}
})
}
async
getTreeArchByCode
(
archName
,
code
)
{
let
results
=
[]
let
rs
=
await
this
.
dao
.
model
.
findAll
({
attributes
:
[
archName
]
})
let
jsontree
=
JSON
.
parse
(
rs
[
0
][
archName
])
this
.
findNodeByCode
(
jsontree
,
code
,
results
)
console
.
log
(
results
)
return
results
;
}
/**
* 按照字段和及级别读取树部分节点
* @param {*} archName
* @param {*} level
*/
// async getTreeArchs(archName, level) {
// let results = []
// let rs = await this.dao.model.findAll({ attributes: [archName] })
// let jsontree = JSON.parse(rs[0].[archName])
// await this.itetree(jsontree, level, results)
// console.log(results)
// return results;
// }
}
module
.
exports
=
TreeArchService
;
// (async ()=>{
...
...
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