Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soss
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
hooloo
web
soss
Commits
5d3b0e42
Commit
5d3b0e42
authored
Jul 29, 2022
by
赵永成
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buildPS
parent
fd456ef4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
4 deletions
+107
-4
src/views/coupon/coupon/index.vue
+107
-4
No files found.
src/views/coupon/coupon/index.vue
View file @
5d3b0e42
...
@@ -550,17 +550,109 @@ export default {
...
@@ -550,17 +550,109 @@ export default {
}
}
//省市区门店
//省市区门店
let
ps_ary
=
this
.
buildPS
(
response
.
data
);
let
ps_ary
=
this
.
buildPS
(
response
.
data
);
//this.storesRange=[[1,"110000","110000","110105","48"]];
this
.
storesRange
=
ps_ary
;
}
}
});
});
},
},
/** 组装省市区门店数据,供回显使用 */
/** 组装省市区门店数据,供回显使用 */
buildPS
(
pdata
){
buildPS
(
pdata
){
//this.storesRange=[[1,"110000","110000","110105","48"]];
//0,1
//province: "110000"
//city: "110000"
// area
//shopIds
let
province
=
pdata
.
province
;
let
ps_ary
=
new
Array
();
if
(
province
==
0
){
ps_ary
.
push
([
"0"
]);
}
else
{
//如果 shopIds有值,其实不管哪个省市区商店有值 都用统一的方法处理 找到对应节点-找到所有最底节点-逐级找到父节点
let
t_shopIds
=
pdata
.
shopIds
;
let
t_area
=
pdata
.
area
;
let
t_city
=
pdata
.
city
;
let
t_province
=
pdata
.
province
;
let
child_ary
=
new
Array
();
//找到对应的节点
if
(
t_shopIds
){
this
.
getChildNodeData
(
t_shopIds
,
child_ary
);
}
if
(
t_area
){
this
.
getChildNodeData
(
t_area
,
child_ary
);
}
if
(
t_city
){
this
.
getChildNodeData
(
t_city
,
child_ary
);
}
if
(
t_province
){
this
.
getChildNodeData
(
t_province
,
child_ary
);
}
console
.
log
(
"child_ary "
,
child_ary
);
//循环所有最底层子节点找到parent,生成数组;
for
(
let
i
=
0
;
i
<
child_ary
.
length
;
i
++
){
let
cdata_ary
=
new
Array
();
cdata_ary
.
push
(
child_ary
[
i
].
value
);
this
.
getNodeData
(
child_ary
[
i
],
cdata_ary
);
cdata_ary
.
unshift
(
"1"
);
ps_ary
.
push
(
cdata_ary
)
}
}
console
.
log
(
"ps_ary "
,
ps_ary
);
return
ps_ary
;
},
getChildNodeData
(
pval
,
child_ary
){
for
(
let
i
=
0
;
i
<
pval
.
length
;
i
++
){
//找到指定值对应的节点
let
tobj
=
this
.
cascadTreeData
(
this
.
shopAreaTreeList
[
1
],
pval
[
i
]);
console
.
log
(
"tobj "
,
tobj
);
//找到所有的最底层子节点
this
.
getNodeList
(
tobj
,
child_ary
);
}
},
//填充所有父节点的值
getNodeData
(
child
,
pary
){
if
(
child
.
parentObj
){
pary
.
unshift
(
child
.
parentObj
.
value
);
this
.
getNodeData
(
child
.
parentObj
,
pary
);
}
},
//找到当前的值对应的节点,
cascadTreeData
(
tdata
,
pval
){
if
(
!
pval
||
pval
==
null
)
return
null
;
if
(
tdata
&&
tdata
.
value
&&
tdata
.
value
==
pval
){
return
tdata
;
}
else
{
let
tchild
=
tdata
.
children
;
if
(
tchild
){
for
(
let
i
=
0
;
i
<
tchild
.
length
;
i
++
){
let
titem
=
tchild
[
i
];
if
(
titem
.
value
==
pval
){
return
titem
;
}
else
{
let
tobj
=
this
.
cascadTreeData
(
titem
,
pval
);
if
(
tobj
)
return
tobj
;
}
}
}
}
},
//找到指定节点所有的子节点
getNodeList
(
pnode
,
pary
){
if
(
pnode
==
null
)
return
;
if
(
pnode
.
children
){
for
(
let
i
=
0
;
i
<
pnode
.
children
.
length
;
i
++
){
let
titem
=
pnode
.
children
[
i
];
if
(
titem
.
children
){
this
.
getNodeList
(
titem
,
pary
);
}
else
{
pary
.
push
(
titem
);
}
}
}
else
{
pary
.
push
(
pnode
);
}
},
},
/** 提交按钮 */
/** 提交按钮 */
submitForm
()
{
submitForm
()
{
...
@@ -701,6 +793,7 @@ export default {
...
@@ -701,6 +793,7 @@ export default {
getShopAreaTree
().
then
((
response
)
=>
{
getShopAreaTree
().
then
((
response
)
=>
{
if
(
response
.
code
==
200
){
if
(
response
.
code
==
200
){
let
treeList
=
response
.
data
;
let
treeList
=
response
.
data
;
console
.
log
(
"treeList "
,
treeList
);
//填充省市区的label值
//填充省市区的label值
for
(
let
i
=
0
;
i
<
treeList
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
treeList
.
length
;
i
++
){
treeList
[
i
].
label
=
list
.
get
(
treeList
[
i
].
value
);
treeList
[
i
].
label
=
list
.
get
(
treeList
[
i
].
value
);
...
@@ -708,10 +801,20 @@ export default {
...
@@ -708,10 +801,20 @@ export default {
let
firChildrenList
=
treeList
[
i
].
children
;
let
firChildrenList
=
treeList
[
i
].
children
;
for
(
let
j
=
0
;
j
<
firChildrenList
.
length
;
j
++
){
for
(
let
j
=
0
;
j
<
firChildrenList
.
length
;
j
++
){
firChildrenList
[
j
].
label
=
list
.
get
(
firChildrenList
[
j
].
value
);
firChildrenList
[
j
].
label
=
list
.
get
(
firChildrenList
[
j
].
value
);
firChildrenList
[
j
].
parentObj
=
treeList
[
i
];
if
(
firChildrenList
[
j
].
children
.
length
>
0
){
if
(
firChildrenList
[
j
].
children
.
length
>
0
){
let
childrenList
=
firChildrenList
[
j
].
children
;
let
childrenList
=
firChildrenList
[
j
].
children
;
for
(
let
s
=
0
;
s
<
childrenList
.
length
;
s
++
){
for
(
let
s
=
0
;
s
<
childrenList
.
length
;
s
++
){
childrenList
[
s
].
label
=
list
.
get
(
childrenList
[
s
].
value
);
childrenList
[
s
].
label
=
list
.
get
(
childrenList
[
s
].
value
);
childrenList
[
s
].
parentObj
=
firChildrenList
[
j
];
if
(
childrenList
[
s
].
children
){
for
(
let
k
=
0
;
k
<
childrenList
[
s
].
children
.
length
;
k
++
){
childrenList
[
s
].
children
[
k
].
parentObj
=
childrenList
[
s
];
}
}
}
}
}
}
}
}
...
...
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