Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-app-operator-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
lanbaoming
jiedao-app-operator-master
Commits
fb9a50f8
Commit
fb9a50f8
authored
Dec 28, 2023
by
dragondean@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量修改空运价格
parent
363b6903
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
424 additions
and
0 deletions
+424
-0
batchEditAir.vue
src/views/ecw/productPrice/batchEditAir.vue
+424
-0
No files found.
src/views/ecw/productPrice/batchEditAir.vue
0 → 100644
View file @
fb9a50f8
<
template
>
<div
class=
"app-container"
>
<el-form
ref=
"form"
:model=
"form"
:rules=
"rules"
label-width=
"150px"
>
<products-selector
ref=
"productSelector"
v-model=
"form.productIdList"
show-all
@
setall=
"isAllProduct=$event"
:default-ids=
"form.productIdList"
enable-filtered
@
setFiltered=
"isAllFilteredProduct=$event"
class=
"mb-20"
/>
<routers-selector
v-model=
"selectedRoutes"
type=
"air"
/>
<el-card
style=
"margin-bottom: 10px"
>
<div
slot=
"header"
style=
"font-size:20px;"
>
{{
$t
(
'
价格设置
'
)
}}
</div>
<el-row
:gutter=
"20"
>
<el-col
:span=
"12"
>
<el-form-item
:label=
"$t('预付')"
prop=
"needPay"
>
<el-radio-group
v-model=
"form.needPay"
>
<el-radio
:label=
"1"
>
{{
$t
(
'
预付
'
)
}}
</el-radio>
<el-radio
:label=
"0"
>
{{
$t
(
'
均可
'
)
}}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
:label=
"$t('单价模式')"
prop=
"priceType"
>
<dict-selector
:type=
"DICT_TYPE.ECW_PRICE_TYPE"
v-model=
"form.priceType"
form-type=
"radio"
formatter=
'number'
/>
</el-form-item>
<el-form-item
:label=
"$t('最小起计量')"
:prop=
"`minWeight`"
>
<el-input-number
v-model=
"form.minWeight"
:controls=
"false"
class=
"w-100"
/>
/
<selector
v-model=
"form.minWeightUnit"
:options=
"unitList"
:label-field=
"$l(null, 'title')"
value-field=
"id"
defaultable2
class=
"w-100"
disabled
/>
</el-form-item>
</el-col>
<el-col
:span=
"12"
>
<quick-set
:unit-list=
"unitList"
:currency-list=
"currencyList"
:value=
"form"
></quick-set>
</el-col>
</el-row>
<!--全包价-->
<template
v-if=
"form.priceType==1"
>
<div
v-for=
"(item, index) in form.fullPriceStepList"
:key=
"index"
>
<price-step
ref=
"stepPrice"
:index=
"index"
:currency-list=
"currencyList"
:unit-list=
"unitList"
field-prefix=
"all"
:price-name=
"$t('全包价')"
:show-add=
"index === form.fullPriceStepList.length -1"
:value=
"item"
@
add=
"handleAddPrice('fullPriceStepList', $event)"
@
delete=
"handleDeletePrice('fullPriceStepList', $event)"
@
changeUnit=
"handleUnitChange(form.fullPriceStepList, index, ...$event)"
></price-step>
</div>
</
template
>
<el-row
v-else
:gutter=
"20"
class=
"mt-20"
>
<el-col
:span=
"12"
>
<div
v-for=
"(item, index) in form.freightPriceStepList"
:key=
"index"
>
<price-step
ref=
"stepPrice"
:index=
"index"
:currency-list=
"currencyList"
:unit-list=
"unitList"
field-prefix=
"transport"
:price-name=
"$t('运费')"
:show-add=
"index === form.freightPriceStepList.length -1"
:value=
"item"
@
add=
"handleAddPrice('freightPriceStepList', $event)"
@
delete=
"handleDeletePrice('freightPriceStepList', $event)"
@
changeUnit=
"handleUnitChange(form.freightPriceStepList, index, ...$event)"
></price-step>
</div>
</el-col>
<el-col
:span=
"12"
>
<div
v-for=
"(item, index) in form.clearancePriceStepList"
:key=
"index"
>
<price-step
ref=
"stepPrice"
:index=
"index"
:currency-list=
"currencyList"
:unit-list=
"unitList"
field-prefix=
"clearance"
:price-name=
"$t('清关费')"
:show-add=
"index === form.clearancePriceStepList.length -1"
:value=
"item"
@
add=
"handleAddPrice('clearancePriceStepList', $event)"
@
delete=
"handleDeletePrice('clearancePriceStepList', $event)"
@
changeUnit=
"handleUnitChange(form.clearancePriceStepList, index, ...$event)"
></price-step>
</div>
</el-col>
</el-row>
<el-form-item
:label=
"$t('价格有效期')"
>
<el-date-picker
v-model=
"form.validateStartDate"
value-format=
"yyyy-MM-dd HH:mm:ss"
></el-date-picker>
-
<el-date-picker
v-model=
"form.validateEndDate"
value-format=
"yyyy-MM-dd HH:mm:ss"
></el-date-picker>
</el-form-item>
</el-card>
<el-card>
<div
slot=
"header"
style=
"font-size:20px;"
>
{{$t('基础信息')}}
</div>
<el-form-item
:label=
"$t('是否预约入仓')"
prop=
"needBook"
>
<el-radio
v-model.number=
"form.needBook"
:label=
"1"
>
{{$t('是')}}
</el-radio>
<el-radio
v-model.number=
"form.needBook"
:label=
"0"
>
{{$t('否')}}
</el-radio>
</el-form-item>
<el-form-item
:label=
"$t('是否单询')"
prop=
"inquiry"
>
<dict-selector
:type=
"DICT_TYPE.NEED_ORDER_INQUIRY"
v-model=
"form.needOrderInquiry"
form-type=
"radio"
formatter=
"number"
></dict-selector>
</el-form-item>
</el-card>
</el-form>
<div
style=
"margin: 20px 0"
>
<el-button
@
click=
"submitForm"
type=
"primary"
:loading=
"loading"
>
{{$t('确认提交')}}
</el-button>
<el-button
type=
"default"
@
click=
"$router.back()"
>
{{$t('返回上一页')}}
</el-button>
</div>
</div>
</template>
<
script
>
import
RoutersSelector
from
'
@/components/RoutersSelector
'
import
{
batchUpdateProductPrice
,
batchUpdateProductPriceAir
,
getProductPrice
}
from
"
@/api/ecw/productPrice
"
;
import
{
getCurrencyList
}
from
'
@/api/ecw/currency
'
;
import
{
getUnitList
}
from
'
@/api/ecw/unit
'
;
import
ProductsSelector
from
'
@/components/ProductsSelector
'
import
Selector
from
'
@/components/Selector
'
import
Inputor
from
'
@/components/Inputor
'
import
Decimal
from
'
decimal.js
'
import
{
getProduct
}
from
"
@/api/ecw/product
"
;
import
QuickSet
from
"
@/views/ecw/productPrice/components/QuickSet.vue
"
;
import
PriceStep
from
"
@/views/ecw/productPrice/components/PriceStep.vue
"
;
import
{
getProductTypeList
}
from
"
@/api/ecw/productType
"
;
// 定义默认的价格单位和体积单位
const
DEFAULT_PRICE_UNIT
=
1
const
DEFAULT_VOLUME_UNIT
=
6
const
DEFAULT_WEIGHT_UNIT
=
6
export
default
{
components
:
{
PriceStep
,
QuickSet
,
RoutersSelector
,
ProductsSelector
,
Selector
,
Inputor
},
data
()
{
return
{
checkList
:
[],
selectedRoutes
:
[],
// 勾选的路线渠道
form
:
{
stepPrice
:
0
,
priceType
:
null
},
isAllProduct
:
false
,
// 是否全部商品
isAllFilteredProduct
:
false
,
// 是否勾選全部搜索結果
specialProducts
:
[],
rules
:
{},
product
:
null
,
currencyList
:
[],
unitList
:
[],
productTypeList
:
[],
productDisabled
:
true
,
lineList
:
[],
//路线数组
loading
:
false
,
}
},
computed
:
{
// 判断是否空值
isEmpty
()
{
return
(
content
)
=>
{
return
!
content
&&
content
!==
0
&&
content
!==
'
0
'
}
},
},
watch
:
{
checkList
()
{
//选择路线
if
(
this
.
checkList
.
length
>
0
)
{
this
.
form
.
lineChannelList
=
this
.
checkList
.
map
(
item
=>
{
return
{
lineId
:
item
,
shippingChannelId
:
0
}
})
}
else
{
this
.
form
.
lineChannelList
=
[]
}
},
product
()
{
this
.
$set
(
this
.
form
,
'
productType
'
,
this
.
product
.
typeId
)
},
// 价格类型切换,需要初始化对应的字段
'
form.priceType
'
(
priceType
){
if
(
priceType
==
1
&&
!
this
.
form
.
fullPriceStepList
?.
length
){
this
.
handleAddPrice
(
'
fullPriceStepList
'
,
'
all
'
)
}
if
(
priceType
==
0
){
if
(
!
this
.
form
.
freightPriceStepList
?.
length
){
this
.
handleAddPrice
(
'
freightPriceStepList
'
,
'
transport
'
)
}
if
(
!
this
.
form
.
clearancePriceStepList
?.
length
){
this
.
handleAddPrice
(
'
clearancePriceStepList
'
,
'
clearance
'
)
}
}
},
'
form.needBook
'
(
val
){
if
(
val
)
this
.
$set
(
this
.
form
,
'
dayLimit
'
,
10000
)
else
delete
this
.
form
.
dayLimit
},
},
async
created
()
{
this
.
currencyList
=
(
await
getCurrencyList
())?.
data
||
[]
this
.
unitList
=
(
await
getUnitList
())?.
data
||
[]
this
.
$set
(
this
.
form
,
'
stepPrice
'
,
1
)
// 如果是复制,则获取数据并填充,先复制,然后填充特需,避免数据的特需不全导致部分不显示
if
(
this
.
$route
.
query
.
templateId
){
await
this
.
getTemplateDetail
(
this
.
$route
.
query
.
templateId
)
}
},
methods
:
{
// 获取模板数据(复制的源路线价格信息)
async
getTemplateDetail
(
id
){
const
res
=
await
getProductPrice
(
id
)
// 填充商品、线路、价格信息、出货渠道(空运)
// this.form.productIdList = [res.data.productId]
/* 23-11-07要求不复制商品和线路 https://zentao.test.jdshangmen.com/bug-view-5145.html
this.selectedRoutes = [{
"lineId": res.data.warehouseLineId,
"channelId": res.data.shippingChannelId,
"transportId": res.data.warehouseLineDO.transportType,
"shippingChannelId":res.data.channelId
}]*/
// 要复制过来的字段
const
{
allPrice
,
allPriceUnit
,
allVolumeUnit
,
transportPrice
,
transportPriceUnit
,
transportVolumeUnit
,
clearancePrice
,
clearancePriceUnit
,
clearanceVolumeUnit
,
priceType
,
stepPrice
,
specialList
,
priceStepList
,
minWeight
,
minWeightUnit
,
needOrderInquiry
,
needBook
,
needPay
}
=
res
.
data
const
data
=
{
allPrice
,
allPriceUnit
,
allVolumeUnit
,
transportPrice
,
transportPriceUnit
,
transportVolumeUnit
,
clearancePrice
,
clearancePriceUnit
,
clearanceVolumeUnit
,
priceType
,
stepPrice
,
specialList
,
priceStepList
,
minWeight
,
minWeightUnit
,
needOrderInquiry
,
needBook
,
needPay
}
this
.
$set
(
this
,
'
form
'
,
Object
.
assign
({},
this
.
form
,
data
))
// 产品选择器默认选择的商品
/* 23-11-07要求不复制商品和线路 https://zentao.test.jdshangmen.com/bug-view-5145.html
getProduct(res.data.productId).then(res => {
this.$refs.productSelector.choose(res.data)
})*/
},
handleAddPrice
(
field
,
fieldPrefix
){
if
(
!
this
.
form
[
field
]){
this
.
$set
(
this
.
form
,
field
,
[])
}
let
priceUnit
=
DEFAULT_PRICE_UNIT
let
volumeUnit
=
DEFAULT_VOLUME_UNIT
let
weightUnit
=
DEFAULT_WEIGHT_UNIT
if
(
this
.
form
[
field
].
length
){
const
first
=
this
.
form
[
field
][
0
]
priceUnit
=
first
[
`
${
fieldPrefix
}
PriceUnit`
]
volumeUnit
=
first
[
`
${
fieldPrefix
}
VolumeUnit`
]
weightUnit
=
first
.
weightUnit
}
console
.
log
(
"
添加价格的默认单位
"
,
{
priceUnit
,
volumeUnit
,
weightUnit
})
this
.
form
[
field
].
push
({
[
`
${
fieldPrefix
}
PriceUnit`
]:
priceUnit
,
[
`
${
fieldPrefix
}
VolumeUnit`
]:
volumeUnit
,
weightUnit
:
weightUnit
,
specialList
:[]
})
},
handleDeletePrice
(
field
,
index
){
this
.
form
[
field
].
splice
(
index
,
1
)
},
handleUnitChange
(
stepPriceList
,
index
,
data
){
console
.
log
(
'
handleUnitChange
'
,
...
arguments
)
if
(
index
>
0
)
return
// 如果是重量单位,且不是清关费想换的,则需要同步最小起计量单位
if
(
data
.
field
===
'
weightUnit
'
&&
data
.
type
!=
'
clearance
'
){
this
.
form
.
minWeightUnit
=
data
.
value
}
stepPriceList
.
forEach
(
item
=>
{
item
[
data
.
field
]
=
data
.
value
if
(
item
.
packagingList
?.
length
){
item
.
packagingList
.
forEach
(
p
=>
{
p
[
data
.
field
]
=
data
.
value
})
}
if
(
item
.
specialList
?.
length
){
item
.
specialList
.
forEach
(
p
=>
{
p
[
data
.
field
]
=
data
.
value
})
}
})
},
// 获得用语提交的阶梯价副本
getPriceList
(
stepList
){
if
(
!
stepList
?.
length
)
return
[]
let
stepPriceList
=
JSON
.
parse
(
JSON
.
stringify
(
stepList
))
stepPriceList
.
forEach
((
item
,
index
)
=>
{
item
.
rankNum
=
index
+
1
item
.
packagingList
=
item
.
packagingList
.
filter
(
p
=>
!!
p
.
packagingTypes
?.
length
)
item
.
packagingList
=
item
.
packagingList
.
map
(
p
=>
{
p
.
packagingTypes
=
p
.
packagingTypes
.
join
(
"
,
"
)
return
p
})
})
return
stepPriceList
},
submitForm
()
{
this
.
$refs
[
"
form
"
].
validate
(
async
(
valid
)
=>
{
if
(
!
valid
)
{
return
;
}
// 只有新增的时候做判断
if
(
!
this
.
$route
.
query
.
ids
&&
(
!
this
.
selectedRoutes
||
!
this
.
selectedRoutes
.
length
))
{
this
.
$message
.
error
(
this
.
$t
(
'
请选择线路
'
));
return
;
}
let
data
=
Object
.
assign
({},
this
.
form
,
{
isAllProduct
:
this
.
isAllProduct
?
1
:
0
})
// 如果是勾選了全部篩選商品,則獲取商品ID
if
(
this
.
isAllFilteredProduct
){
data
.
productIdList
=
await
this
.
$refs
.
productSelector
.
getFilteredIds
()
}
if
(
!
data
.
isAllProduct
&&
(
!
data
.
productIdList
||
!
data
.
productIdList
.
length
)){
return
this
.
$message
.
error
(
'
请选择商品
'
)
}
data
.
lineChannelList
=
this
.
selectedRoutes
let
isValid
=
true
for
(
let
stepPrice
of
this
.
$refs
.
stepPrice
){
if
(
!
stepPrice
.
validate
()){
isValid
=
false
break
}
}
if
(
!
isValid
)
return
// 全包价
if
(
this
.
form
.
priceType
==
1
)
{
data
.
fullPriceStepList
=
this
.
getPriceList
(
this
.
form
.
fullPriceStepList
)
}
else
{
data
.
clearancePriceStepList
=
this
.
getPriceList
(
this
.
form
.
clearancePriceStepList
)
data
.
freightPriceStepList
=
this
.
getPriceList
(
this
.
form
.
freightPriceStepList
)
}
if
(
data
.
lineChannelList
.
length
<
1
){
return
this
.
$message
.
error
(
this
.
$t
(
'
请选择需要修改的路线
'
))
}
await
this
.
$confirm
(
this
.
$t
(
'
已选择{route}条路线,{product}个商品;确认提交修改?
'
,
{
route
:
data
.
lineChannelList
.
length
,
product
:
this
.
isAllProduct
?
this
.
$refs
.
productSelector
.
allTotal
:
data
.
productIdList
.
length
}))
this
.
loading
=
true
batchUpdateProductPriceAir
(
data
).
then
(
response
=>
{
this
.
$modal
.
msgSuccess
(
this
.
$t
(
"
修改成功
"
));
this
.
$router
.
replace
(
'
/lineProject/product-price?
'
+
(
new
URLSearchParams
(
this
.
$route
.
query
)).
toString
())
})
.
finally
(
res
=>
this
.
loading
=
false
)
});
},
// 快捷设置,只更新默认运费
quickSet
(){
// 字段,根据是否全包价来取
let
field
=
this
.
form
.
priceType
==
1
?
'
allPrice
'
:
'
transportPrice
'
// 取得要加的数额(减少则是负数)
let
amount
=
Decimal
(
this
.
quickForm
.
plus
||
-
this
.
quickForm
.
minus
)
this
.
form
.
priceStepList
.
forEach
(
item
=>
{
// 加上对应的价格,但是不能小于0
this
.
$set
(
item
,
field
,
Math
.
max
(
0
,
Decimal
(
item
[
field
]
||
0
).
plus
(
amount
).
toNumber
()))
})
}
}
}
</
script
>
<
style
scoped
>
.w100
{
width
:
100px
;
}
.mr10
{
margin-right
:
10px
;
}
</
style
>
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