Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
张杰
/
car-service-system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ee0e968f
authored
Dec 07, 2023
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复bug
1 parent
26496c93
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
52 deletions
src/components/Area/index.vue
src/views/vehicleService/list/audit.vue
src/components/Area/index.vue
View file @
ee0e968
...
...
@@ -4,9 +4,10 @@
:options=
"areaList"
v-model=
"areas"
:props=
"cascaderProps"
@
change=
"handleAsycChange"
@
expand-change=
"handleAsycChange"
placeholder=
"请选择"
:key=
"areasKeys"
@
change=
"onChange"
@
expand-change=
"onChange"
/>
</
template
>
<
script
>
...
...
@@ -25,11 +26,12 @@ export default {
areas
:
[],
cascaderProps
:
{
label
:
"areaName"
,
value
:
"
areaCode
"
,
value
:
"
id
"
,
children
:
"children"
,
lazy
:
true
,
lazyLoad
:
this
.
loadProvince
,
//
lazy: true,
//
lazyLoad: this.loadProvince,
},
areasKeys
:
""
,
};
},
watch
:
{
...
...
@@ -37,7 +39,7 @@ export default {
handler
:
function
(
n
,
o
)
{
if
(
n
&&
n
!=
o
)
{
this
.
areas
=
n
;
this
.
fill
District
(
n
);
this
.
fill
Province
(
n
);
}
},
immediate
:
true
,
...
...
@@ -69,61 +71,80 @@ export default {
});
},
// 动态加载
async
loadProvince
(
node
,
resolve
)
{
console
.
log
(
"触发加载...."
);
const
{
level
,
data
}
=
node
;
if
(
!
node
.
children
||
node
.
children
.
length
<=
0
)
{
resolve
([]);
return
false
;
}
let
res
=
await
this
.
getList
(
data
?
data
.
areaCode
:
0
);
resolve
(
res
);
// 填充省市区
fillProvince
(
codes
)
{
let
_this
=
this
;
this
.
getList
(
0
).
then
((
res
)
=>
{
_this
.
getCity
(
codes
);
});
},
// 省市区
handleAsycChange
(
val
)
{
if
(
val
&&
val
.
length
==
3
)
{
this
.
$emit
(
"input"
,
val
);
}
var
newPro
=
new
Promise
((
resolve
)
=>
{
var
riVal
=
val
[
val
.
length
-
1
];
this
.
getList
(
riVal
).
then
((
response
)
=>
{
this
.
areaList
.
map
((
item
)
=>
{
if
(
item
.
id
==
riVal
)
{
item
.
children
=
response
;
}
else
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
// console.log('active item:', response);
item
.
children
.
map
((
citem
)
=>
{
if
(
citem
.
id
==
riVal
)
{
if
(
val
.
length
<
2
)
{
citem
.
children
=
response
;
}
else
{
response
.
map
((
ccitem
)
=>
{
ccitem
.
children
=
null
;
});
citem
.
children
=
response
;
}
}
});
}
});
resolve
();
// 根据省份code 获取城市列表
getCity
(
codes
)
{
let
_this
=
this
;
let
list
=
this
.
areaList
||
[];
let
params
=
{};
params
.
id
=
codes
[
0
];
params
.
type
=
"children"
;
getAddress
(
params
).
then
((
response
)
=>
{
let
arr
=
response
.
data
||
[];
let
idx
=
list
.
findIndex
((
k
)
=>
k
.
areaCode
==
codes
[
0
]);
let
province
=
list
[
idx
];
arr
.
map
((
k
)
=>
{
k
.
children
=
[];
return
k
;
});
province
.
children
=
arr
;
_this
.
$set
(
_this
.
areaList
,
idx
,
province
);
if
(
codes
.
length
>
2
)
{
_this
.
getArea
(
codes
);
}
});
return
newPro
;
},
//
填充省市区
fillDistrict
(
districtArr
)
{
//
根据城市code 获取地区列表
getArea
(
codes
)
{
let
_this
=
this
;
_this
.
$nextTick
(()
=>
{
if
(
districtArr
.
length
!==
3
)
return
;
_this
.
handleAsycChange
([
districtArr
[
0
]]).
then
(()
=>
{
_this
.
handleAsycChange
([
districtArr
[
0
],
districtArr
[
1
]])
let
list
=
this
.
areaList
||
[];
let
params
=
{};
params
.
id
=
codes
[
1
];
params
.
type
=
"children"
;
getAddress
(
params
).
then
((
response
)
=>
{
let
arr
=
response
.
data
||
[];
let
province
=
list
.
find
((
k
)
=>
k
.
areaCode
==
codes
[
0
]);
let
idx
=
(
province
.
children
||
[]).
findIndex
(
(
k
)
=>
k
.
areaCode
==
codes
[
1
]
);
let
city
=
province
.
children
[
idx
];
arr
.
map
((
k
)
=>
{
delete
k
.
children
;
return
k
;
});
city
.
children
=
arr
;
_this
.
$set
(
_this
.
areaList
,
idx
,
province
);
// _this.areas = codes;
if
(
codes
.
length
==
3
)
{
_this
.
areasKeys
=
Math
.
random
();
}
});
},
// 监听编号
onChange
(
node
)
{
console
.
log
(
";555555555"
);
console
.
log
(
node
);
// 切换省份
if
(
node
.
length
==
1
)
{
this
.
getCity
(
node
);
}
// 切换城市
if
(
node
.
length
==
2
)
{
this
.
getArea
(
node
);
}
},
},
};
</
script
>
\ No newline at end of file
src/views/vehicleService/list/audit.vue
View file @
ee0e968
...
...
@@ -104,7 +104,7 @@
</el-form-item>
</div>
<el-form-item
label=
"邮寄地址:"
>
<
!--
<area-cascader
v-model=
"ruleForm.returnDistrict"
/>
--
>
<
area-cascader
v-model=
"ruleForm.returnDistrict"
/
>
</el-form-item>
<el-form-item
label=
"详细地址:"
>
<el-input
v-model=
"ruleForm.returnAddress"
/>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment