Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
S
shop-new
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
王天霸
shop-new
Commits
58248eae
提交
58248eae
authored
5月 23, 2022
作者:
郑伟娜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
地区数据处理
上级
52f250f1
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
232 行增加
和
107 行删除
+232
-107
index.vue
src/views/system/freight/freight_list/index.vue
+6
-2
templateFreight.vue
src/views/system/freight/freight_list/templateFreight.vue
+226
-105
没有找到文件。
src/views/system/freight/freight_list/index.vue
浏览文件 @
58248eae
...
...
@@ -172,10 +172,14 @@
// 处理最后一级显示暂无数据
getTreeData
(
data
)
{
for
(
let
i
=
0
,
len
=
data
.
length
;
i
<
len
;
i
++
)
{
if
(
!
data
[
i
].
children
.
length
)
{
if
(
data
[
i
].
type
>=
2
)
{
data
[
i
].
children
=
undefined
}
else
{
this
.
getTreeData
(
data
[
i
].
children
)
if
(
!
data
[
i
].
children
.
length
)
{
data
[
i
].
children
=
undefined
}
else
{
this
.
getTreeData
(
data
[
i
].
children
)
}
}
}
return
data
...
...
src/views/system/freight/freight_list/templateFreight.vue
浏览文件 @
58248eae
...
...
@@ -59,9 +59,15 @@
label=
"配送区域"
>
<template
slot-scope=
"scope"
>
<span
v-if=
"scope.row.a.length && scope.row.a[0] == 0"
>
【默认】全国
</span>
<span
v-if=
"scope.row.a.length && scope.row.a[0] != 0"
>
【指定】
{{
scope
.
row
.
value
}}
</span>
<span
v-if=
"!scope.row.a.length"
style=
"color: #1890ff; cursor: pointer;"
@
click=
"editAddress(scope.row, scope.$index)"
>
【点击选择配送地区】
</span>
<div
v-if=
"scope.row.a.length && scope.row.a[0].province_id == 0"
>
【默认】全国
</div>
<div
v-if=
"scope.row.a.length && scope.row.a[0].province_id != 0"
>
【指定】
<span
v-for=
"(item, index) in scope.row.value"
:key=
"index"
>
<span>
{{
item
.
province_name
}}{{
item
.
city_name
.
length
?
`(${ item.city_name.join()
}
)`
:
''
}}
<
/span
>
<
span
v
-
if
=
"index < scope.row.value.length - 1"
>
,
&
nbsp
;
<
/span
>
<
/span
>
<
/div
>
<
div
v
-
if
=
"!scope.row.a.length"
style
=
"color: #1890ff; cursor: pointer;"
@
click
=
"editAddress(scope.row, scope.$index)"
>
【点击选择配送地区】
<
/div
>
<
/template
>
<
/el-table-column
>
<
el
-
table
-
column
...
...
@@ -149,7 +155,11 @@
prop
=
"dis_dispatching"
>
<
template
slot
-
scope
=
"scope"
>
{{
scope
.
row
.
value
}}
<!--
{{
scope
.
row
.
value
}}
-->
<
span
v
-
for
=
"(item, index) in scope.row.value"
:
key
=
"index"
>
<
span
>
{{
item
.
province_name
}}
{{
item
.
city_name
.
length
?
`(${ item.city_name.join()
}
)`
:
''
}}
<
/span
>
<
span
v
-
if
=
"index < scope.row.value.length - 1"
>
,
&
nbsp
;
<
/span
>
<
/span
>
<
/template
>
<
/el-table-column
>
<!--
样式占位
-->
...
...
@@ -202,7 +212,6 @@
<
/template
>
<
script
>
import
{
addressList
}
from
'@/api/module/freight'
import
{
addFreight
,
updateFreight
}
from
'@/api/module/freight'
export
default
{
...
...
@@ -237,8 +246,10 @@
}
,
deliveryTableData
:
[
{
a
:
[
0
],
value
:
''
,
a
:
[{
province_id
:
0
,
province_name
:
'全国'
}
],
f
:
''
,
fp
:
''
,
n
:
''
,
...
...
@@ -263,7 +274,6 @@
mounted
()
{
this
.
addressOptions
=
this
.
addressAll
this
.
initData
()
// this.getaddressList()
}
,
methods
:
{
// 初始化数据
...
...
@@ -279,8 +289,10 @@
}
this
.
deliveryTableData
=
[
{
a
:
[
0
],
value
:
''
,
a
:
[{
province_id
:
0
,
province_name
:
'全国'
}
],
f
:
''
,
fp
:
''
,
n
:
''
,
...
...
@@ -297,39 +309,23 @@
charge_type
:
this
.
option
.
charge_type
,
publish
:
this
.
option
.
publish
}
this
.
deliveryTableData
=
this
.
option
.
dispatching
this
.
deliveryTableData
=
this
.
option
.
new_
dispatching
this
.
deliveryTableData
.
forEach
(
item
=>
{
item
.
fp
=
Number
(
item
.
fp
/
100
)
item
.
np
=
Number
(
item
.
np
/
100
)
item
.
value
=
this
.
getSelectData
(
item
.
a
)
item
.
id
=
this
.
getBackData
(
item
.
a
)
}
)
this
.
noDeliveryTableData
[
0
]
=
{
a
:
this
.
option
.
dis_dispatching
,
value
:
''
a
:
this
.
option
.
new_dis_dispatching
,
value
:
this
.
getSelectData
(
this
.
option
.
new_dis_dispatching
),
id
:
this
.
getBackData
(
this
.
option
.
new_dis_dispatching
)
}
}
}
,
// 获取全部地区
getaddressList
()
{
addressList
().
then
(
res
=>
{
if
(
res
.
code
==
1
)
{
this
.
addressOptions
=
this
.
getTreeData
(
res
.
data
)
}
})
},
// 处理最后一级显示暂无数据
getTreeData
(
data
)
{
for
(
let
i
=
0
,
len
=
data
.
length
;
i
<
len
;
i
++
)
{
if
(
!
data
[
i
].
children
.
length
)
{
data
[
i
].
children
=
undefined
}
else
{
this
.
getTreeData
(
data
[
i
].
children
)
}
}
return
data
},
// 设置全国选项不可选
selectEnable
(
row
)
{
if
(
row
.
a
.
length
&&
row
.
a
[
0
]
==
0
)
{
if
(
row
.
a
.
length
&&
row
.
a
[
0
]
.
province_id
==
0
)
{
return
false
}
else
{
return
true
...
...
@@ -358,7 +354,6 @@
this
.
deliveryTableData
.
push
(
{
a
:
[],
value
:
''
,
f
:
''
,
fp
:
''
,
n
:
''
,
...
...
@@ -396,24 +391,83 @@
this
.
rowItem
=
row
this
.
addType
=
1
}
this
.
selectAddress
=
row
.
a
this
.
selectAddress
=
row
.
id
this
.
dialogAddress
=
true
}
,
// 选择的地区赋值
saveAddress
()
{
if
(
this
.
addType
==
1
)
{
this
.
rowItem
.
a
=
this
.
selectAddress
this
.
rowItem
.
value
=
this
.
getAddressName
()
this
.
rowItem
.
a
=
this
.
getAfferentData
()
this
.
rowItem
.
value
=
[]
this
.
rowItem
.
id
=
[]
this
.
rowItem
.
value
=
this
.
getSelectData
(
this
.
rowItem
.
a
)
this
.
rowItem
.
id
=
this
.
getBackData
(
this
.
rowItem
.
a
)
}
else
{
this
.
noDeliveryTableData
.
push
({
a
:
this
.
selectAddress
,
value
:
this
.
getAddressName
(),
a
:
this
.
getAfferentData
(
this
.
getAfferentData
()),
value
:
this
.
getSelectData
(
this
.
getAfferentData
()),
id
:
this
.
getBackData
(
this
.
getAfferentData
())
}
)
}
this
.
dialogAddress
=
false
}
,
// 将数据组合成省市县及是否选中的是全部地区 山东省【济南市(市中区,天桥区,长清区,济阳县)】 河北省(全部地区)
getAddressName
()
{
// 获取对应数据显示的地址名称
getSelectData
(
data
)
{
let
a
=
[]
let
b
=
[]
let
c
=
[]
// 地址名称 省 市
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
a
.
push
(
data
[
i
].
province_id
)
}
b
=
Array
.
from
(
new
Set
(
a
))
for
(
let
i
=
0
;
i
<
b
.
length
;
i
++
)
{
let
name
=
''
let
arr
=
[]
for
(
let
j
=
0
;
j
<
data
.
length
;
j
++
)
{
if
(
b
[
i
]
==
data
[
j
].
province_id
)
{
if
(
data
[
j
].
city_id
)
{
name
=
data
[
j
].
province_name
arr
.
push
(
data
[
j
].
city_name
)
}
else
{
name
=
data
[
j
].
province_name
}
}
}
c
.
push
({
province_name
:
name
,
city_name
:
arr
}
)
}
return
c
}
,
// 将后台返回的格式处理成组件需要的格式
getBackData
(
data
)
{
let
arr
=
[]
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
let
arrItem
=
[]
if
(
data
[
i
].
city_id
)
{
arrItem
.
push
(
data
[
i
].
province_id
)
arrItem
.
push
(
data
[
i
].
city_id
)
arr
.
push
(
arrItem
)
}
else
{
for
(
let
j
=
0
;
j
<
this
.
addressOptions
.
length
;
j
++
)
{
if
(
data
[
i
].
province_id
==
this
.
addressOptions
[
j
].
id
)
{
for
(
let
k
=
0
;
k
<
this
.
addressOptions
[
j
].
children
.
length
;
k
++
)
{
arrItem
.
push
(
data
[
i
].
province_id
)
arrItem
.
push
(
this
.
addressOptions
[
j
].
children
[
k
].
id
)
arr
.
push
(
arrItem
)
arrItem
=
[]
}
}
}
}
}
return
arr
}
,
// 组装成后台需要的格式 省市
getAfferentData
()
{
let
a
=
[]
let
b
=
[]
let
c
=
[]
// 将每个省的数据组合到一个数组中
...
...
@@ -429,95 +483,156 @@
}
}
}
let
selectData
=
[]
let
addressName
=
[]
for
(
let
i
=
0
;
i
<
c
.
length
;
i
++
)
{
let
name1
=
[]
let
name2
=
[]
let
name3
=
[]
let
str
=
''
let
arr1
=
[]
for
(
let
j
=
0
;
j
<
this
.
addressOptions
.
length
;
j
++
)
{
if
(
c
[
i
][
0
][
0
]
==
this
.
addressOptions
[
j
].
id
)
{
name1
.
push
(
this
.
addressOptions
[
j
].
name
)
let
d
=
[]
let
e
=
[]
c
[
i
].
map
(
item
=>
{
d
.
push
(
item
[
1
])
}
)
e
=
Array
.
from
(
new
Set
(
d
))
if
(
e
.
length
==
this
.
addressOptions
[
j
].
children
.
length
)
{
name2
.
push
(
'全部地区'
)
arr1
.
push
({
province_id
:
this
.
addressOptions
[
j
].
id
,
province_name
:
this
.
addressOptions
[
j
].
name
}
)
}
else
{
if
(
'children'
in
this
.
addressOptions
[
j
])
{
for
(
let
k
=
0
;
k
<
e
.
length
;
k
++
)
{
let
data
=
''
let
h
=
[]
for
(
let
p
=
0
;
p
<
d
.
length
;
p
++
)
{
if
(
e
[
k
]
==
d
[
p
])
{
h
.
push
(
d
[
p
])
}
for
(
let
k
=
0
;
k
<
e
.
length
;
k
++
)
{
for
(
let
l
=
0
;
l
<
this
.
addressOptions
[
j
].
children
.
length
;
l
++
)
{
if
(
e
[
k
]
==
this
.
addressOptions
[
j
].
children
[
l
].
id
)
{
arr1
.
push
({
province_id
:
this
.
addressOptions
[
j
].
id
,
province_name
:
this
.
addressOptions
[
j
].
name
,
city_id
:
this
.
addressOptions
[
j
].
children
[
l
].
id
,
city_name
:
this
.
addressOptions
[
j
].
children
[
l
].
name
}
)
}
for
(
let
l
=
0
;
l
<
this
.
addressOptions
[
j
].
children
.
length
;
l
++
)
{
if
(
e
[
k
]
==
this
.
addressOptions
[
j
].
children
[
l
].
id
)
{
data
+=
(
this
.
addressOptions
[
j
].
children
[
l
].
name
)
let
f
=
[]
let
g
=
[]
c
[
i
].
map
(
item
=>
{
if
(
e
[
k
]
==
item
[
1
])
{
g
.
push
(
item
[
2
])
}
})
if
(
'children'
in
this
.
addressOptions
[
j
].
children
[
l
])
{
if
(
h
.
length
==
this
.
addressOptions
[
j
].
children
[
l
].
children
.
length
)
{
name3
.
push
(
'全部地区'
)
}
else
{
for
(
let
m
=
0
;
m
<
g
.
length
;
m
++
)
{
for
(
let
n
=
0
;
n
<
this
.
addressOptions
[
j
].
children
[
l
].
children
.
length
;
n
++
)
{
if
(
g
[
m
]
==
this
.
addressOptions
[
j
].
children
[
l
].
children
[
n
].
id
)
{
name3
.
push
(
this
.
addressOptions
[
j
].
children
[
l
].
children
[
n
].
name
)
}
}
}
}
}
}
}
data
+=
`(
${
name3
.
join
()}
)`
name2
.
push
(
data
)
data
=
[]
name3
=
[]
}
}
}
}
}
str
=
name1
.
join
()
+
`【
${
name2
.
join
()}
】`
addressName
.
push
(
str
)
name2
=
[]
name3
=
[]
selectData
=
selectData
.
concat
(
arr1
)
}
console
.
log
(
'-------------'
)
console
.
log
(
addressName
)
return
addressName
.
join
()
return
selectData
}
,
// 将数据组合成省市县及是否选中的是全部地区 山东省【济南市(市中区,天桥区,长清区,济阳县)】 河北省(全部地区)
// getAddressName()
{
// let a = []
// let b = []
// let c = [] // 将每个省的数据组合到一个数组中
// for(let i = 0; i < this.selectAddress.length; i++)
{
// a.push(this.selectAddress[i][0])
//
}
// b = Array.from(new Set(a))
// for(let i = 0; i < b.length; i++)
{
// c[i] = []
// for(let j = 0; j < this.selectAddress.length; j++)
{
// if (b[i] == this.selectAddress[j][0])
{
// c[i].push(this.selectAddress[j])
//
}
//
}
//
}
// let addressName = []
// for(let i = 0; i < c.length; i++)
{
// let name1 = []
// let name2 = []
// let name3 = []
// let str = ''
// for(let j = 0; j < this.addressOptions.length; j++)
{
// if (c[i][0][0] == this.addressOptions[j].id)
{
// name1.push(this.addressOptions[j].name)
// let d = []
// let e = []
// c[i].map(item =>
{
// d.push(item[1])
//
}
)
// e = Array.from(new Set(d))
// if (e.length == this.addressOptions[j].children.length)
{
// name2.push('全部地区')
//
}
else
{
// if ('children' in this.addressOptions[j])
{
// for(let k = 0; k < e.length; k++)
{
// let data = ''
// let h = []
// for(let p = 0; p < d.length; p++)
{
// if (e[k] == d[p])
{
// h.push(d[p])
//
}
//
}
// for(let l = 0; l < this.addressOptions[j].children.length; l++)
{
// if (e[k] == this.addressOptions[j].children[l].id)
{
// data += (this.addressOptions[j].children[l].name)
// let f = []
// let g = []
// c[i].map(item =>
{
// if (e[k] == item[1])
{
// g.push(item[2])
//
}
//
}
)
// if ('children' in this.addressOptions[j].children[l])
{
// if (h.length == this.addressOptions[j].children[l].children.length)
{
// name3.push('全部地区')
//
}
else
{
// for(let m = 0; m < g.length; m++)
{
// for(let n = 0; n < this.addressOptions[j].children[l].children.length; n++)
{
// if (g[m] == this.addressOptions[j].children[l].children[n].id)
{
// name3.push(this.addressOptions[j].children[l].children[n].name)
//
}
//
}
//
}
//
}
//
}
//
}
//
}
// data += `($
{
name3
.
join
()
}
)
`
// name2.push(data)
// data = []
// name3 = []
//
}
//
}
//
}
//
}
//
}
// str = name1.join() + `
【
$
{
name2
.
join
()
}】
`
// addressName.push(str)
// name2 = []
// name3 = []
//
}
// console.log('-------------')
// console.log(addressName)
// return addressName
//
}
,
// 提交
handleSubmit() {
this.$refs['ruleForm'].validate((valid) => {
if (valid) {
if (this.option.id == 0) {
let
params
=
JSON
.
parse
(
JSON
.
stringify
(
Object
.
assign
({},
this
.
ruleForm
,
{
dispatching
:
this
.
deliveryTableData
})))
if
(
params
.
dispatching
.
length
)
{
params
.
dispatching
.
forEach
(
item
=>
{
let params = JSON.parse(JSON.stringify(Object.assign({
}
, this.ruleForm, {
new_
dispatching: this.deliveryTableData
}
)))
if (params.
new_
dispatching.length) {
params.
new_
dispatching.forEach(item=>{
item.fp = Number(item.fp * 100)
item.np = Number(item.np * 100)
item.value = undefined
item.id = undefined
}
)
}
params
.
dis_dispatching
=
this
.
noDeliveryTableData
.
length
?
this
.
noDeliveryTableData
[
0
].
a
:
[]
params.new_dis_dispatching = this.noDeliveryTableData.length ? this.noDeliveryTableData[0].a : []
if (params.new_dis_dispatching.length) {
this.noDeliveryTableData[0].value = undefined
this.noDeliveryTableData[0].id = undefined
}
addFreight(params).then(res => {
if (res.code == 1) {
this.$message.success('新增成功')
...
...
@@ -525,14 +640,20 @@
}
}
)
}
else {
let
params
=
JSON
.
parse
(
JSON
.
stringify
(
Object
.
assign
({},
this
.
ruleForm
,
{
dispatching
:
this
.
deliveryTableData
})))
if
(
params
.
dispatching
.
length
)
{
params
.
dispatching
.
forEach
(
item
=>
{
let params = JSON.parse(JSON.stringify(Object.assign({
}
, this.ruleForm, {
new_
dispatching: this.deliveryTableData
}
)))
if (params.
new_
dispatching.length) {
params.
new_
dispatching.forEach(item=>{
item.fp = Number(item.fp * 100)
item.np = Number(item.np * 100)
item.value = undefined
item.id = undefined
}
)
}
params
.
dis_dispatching
=
this
.
noDeliveryTableData
.
length
?
this
.
noDeliveryTableData
[
0
].
a
:
[]
params.new_dis_dispatching = this.noDeliveryTableData.length ? this.noDeliveryTableData[0].a : []
if (params.new_dis_dispatching.length) {
this.noDeliveryTableData[0].value = undefined
this.noDeliveryTableData[0].id = undefined
}
updateFreight(params).then(res => {
if (res.code == 1) {
this.$message.success('修改成功')
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论